* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Theme Variables */
/* Colors of cards, panels and secondary text: the light look unless a theme sets them */
:root {
    --card-bg: white;
    --panel-bg: #f4f4f8;
    --placeholder-bg: #ddd;
    --hover-bg: #f7f7fd;
    --border-color: #e3e3e8;
    --muted-text: #666;
    --strong-text: #333;
}

:root[data-theme="dark"] {
    color-scheme: dark; /* inputs, menus and scrollbars drawn dark too */
    --primary-color: #6c7ae0;
    --primary-dark: #5867cf;
    --secondary-color: #8b7bd8;
    --background-gradient: linear-gradient(180deg, #121217 0%, #16161d 100%);
    --text-color: #e4e4ea;
    --surface-color: #1d1d25;
    --surface-hover: #2a2a34;
    --card-bg: #1d1d25;
    --panel-bg: #25252e;
    --placeholder-bg: #2e2e38;
    --hover-bg: #2a2a35;
    --border-color: #393945;
    --muted-text: #a2a2ae;
    --strong-text: #e4e4ea;
    --success-bg: #2f7a4b;
    --danger-bg: #8f3a33;
    --danger-hover: #7a302a;
    --button-bg: #474f99; /* darker than the accent text color */
    --button-hover: #3b4285;
    --progress-color: #6c7ae0; /* progress lines on thumbnails, the watched check */
    --progress-label: #ffffff;
    --button-secondary-bg: #333659; /* quieter buttons (btn-secondary), outlined in the button color */
    --button-secondary-text: #e4e4ea;
}

/* Ember, the default: the Weird Streamer logo's aubergine, gold and cream */
:root[data-theme="default"] {
    color-scheme: dark; /* inputs, menus and scrollbars drawn dark too */
    --primary-color: #F6C445; /* the logo's gold: accent text, borders, focus */
    --primary-dark: #E0A82E;
    --secondary-color: #E0892C;
    --background-gradient: linear-gradient(180deg, #1C0F1B 0%, #28142A 100%);
    --text-color: #FFF2D8; /* the logo's cream */
    --surface-color: #321B2F; /* the logo's aubergine */
    --surface-hover: #4A2A45;
    --card-bg: #321B2F;
    --panel-bg: #3D2239;
    --placeholder-bg: #4A2A45;
    --hover-bg: #43263F;
    --border-color: #5A3654;
    --muted-text: #D8C6B4;
    --strong-text: #FFF2D8;
    --success-bg: #2f7a4b;
    --danger-bg: #8f3a33;
    --danger-hover: #7a302a;
    --button-bg: #6A3A62; /* plum: white labels stay readable, unlike on gold */
    --button-hover: #7C4672;
    --button-text: #FFF2D8; /* cream labels, like the rest of Ember's text */
    --button-focus: #F6C445; /* hovered and focused buttons: gold, as on the TV */
    --button-focus-text: #321B2F;
    --heading-color: #F6C445; /* settings headings and tabs, the image title (purple elsewhere) */
    --placeholder-gradient: linear-gradient(135deg, #4A2A45 0%, #321B2F 100%); /* missing thumbnails and posters */
    --progress-color: #F6C445; /* progress lines on thumbnails, the watched check */
    --progress-label: #321B2F;
    --button-secondary-bg: #4F2C49; /* quieter buttons (btn-secondary), outlined in the button color */
    --button-secondary-text: #FFF2D8;
}

/* Cinema Blue: a theater's deep navy and gold */
:root[data-theme="cinema-blue"] {
    color-scheme: dark; /* inputs, menus and scrollbars drawn dark too */
    --primary-color: #FBB024;
    --primary-dark: #D97706;
    --secondary-color: #3B82F6;
    --background-gradient: linear-gradient(135deg, #0F172A 0%, #1E3A8A 100%);
    --text-color: #E5E7EB;
    --surface-color: #1E3A8A;
    --surface-hover: #3B82F6;
    --card-bg: #142563; /* Settings, dialogs and cards: dark, as the theme's text is light */
    --panel-bg: #1B3278;
    --placeholder-bg: #22398A;
    --hover-bg: #1E3780;
    --border-color: #2E4A9E;
    --muted-text: #B4C0E6;
    --strong-text: #E5E7EB;
    --success-bg: #2f7a4b;
    --danger-bg: #8f3a33;
    --danger-hover: #7a302a;
    --button-bg: #2D4AA8;
    --button-hover: #3B5BC0;
    --button-text: #E5E7EB;
    --button-focus: #FBB024;
    --button-focus-text: #0F172A;
    --heading-color: #FBB024;
    --placeholder-gradient: linear-gradient(135deg, #22398A 0%, #142563 100%);
    --progress-color: #FBB024; /* progress lines on thumbnails, the watched check */
    --progress-label: #0F172A;
    --button-secondary-bg: #1B3278; /* quieter buttons (btn-secondary), outlined in the button color */
    --button-secondary-text: #E5E7EB;
}

/* Cinema Red: a velvet curtain's deep burgundy and gold */
:root[data-theme="cinema-red"] {
    color-scheme: dark;
    --primary-color: #FBB024;
    --primary-dark: #D97706;
    --secondary-color: #DC2626;
    --background-gradient: linear-gradient(135deg, #7F1D1D 0%, #991B1B 100%);
    --text-color: #E5E7EB;
    --surface-color: #991B1B;
    --surface-hover: #DC2626;
    --card-bg: #5E1515;
    --panel-bg: #721B1B;
    --placeholder-bg: #852222;
    --hover-bg: #7A1F1F;
    --border-color: #9C3434;
    --muted-text: #E8BDBD;
    --strong-text: #F3E4E4;
    --success-bg: #2f7a4b;
    --danger-bg: #3d1010;
    --danger-hover: #2e0b0b;
    --button-bg: #A32A2A;
    --button-hover: #B93838;
    --button-text: #F3E4E4;
    --button-focus: #FBB024;
    --button-focus-text: #5E1515;
    --heading-color: #FBB024;
    --placeholder-gradient: linear-gradient(135deg, #852222 0%, #5E1515 100%);
    --progress-color: #FBB024; /* progress lines on thumbnails, the watched check */
    --progress-label: #7F1D1D;
    --button-secondary-bg: #721B1B; /* quieter buttons (btn-secondary), outlined in the button color */
    --button-secondary-text: #F3E4E4;
}

/* Teal: deep sea teal with aqua (the Android theme's colors) */
:root[data-theme="teal"] {
    color-scheme: dark;
    --primary-color: #5EEAD4;
    --primary-dark: #50C7B4;
    --secondary-color: #F2A65A;
    --background-gradient: linear-gradient(180deg, #0B1E1E 0%, #0E2827 100%);
    --text-color: #E4F5F3;
    --surface-color: #123130;
    --surface-hover: #1B4443;
    --card-bg: #123130;
    --panel-bg: #163A3A;
    --placeholder-bg: #1B4443;
    --hover-bg: #183E3D;
    --border-color: #1D524F;
    --muted-text: #A6CDC9;
    --strong-text: #E4F5F3;
    --success-bg: #2f7a4b;
    --danger-bg: #8f3a33;
    --danger-hover: #7a302a;
    --button-bg: #1F5F5B;
    --button-hover: #37716D;
    --button-text: #E4F5F3;
    --button-focus: #5EEAD4;
    --button-focus-text: #0B2423;
    --heading-color: #5EEAD4;
    --placeholder-gradient: linear-gradient(135deg, #1B4443 0%, #123130 100%);
    --progress-color: #5EEAD4;
    --progress-label: #0B2423;
    --button-secondary-bg: #1A4947; /* quieter buttons (btn-secondary), outlined in the button color */
    --button-secondary-text: #E4F5F3;
}

/* Orange: burnt orange with tangerine (the Android theme's colors) */
:root[data-theme="orange"] {
    color-scheme: dark;
    --primary-color: #FFA24A;
    --primary-dark: #D98A3F;
    --secondary-color: #F6C445;
    --background-gradient: linear-gradient(180deg, #1D110A 0%, #28180D 100%);
    --text-color: #FFF0E0;
    --surface-color: #331E10;
    --surface-hover: #4A2D18;
    --card-bg: #331E10;
    --panel-bg: #3E2614;
    --placeholder-bg: #4A2D18;
    --hover-bg: #432816;
    --border-color: #6A3C1A;
    --muted-text: #E2C2A2;
    --strong-text: #FFF0E0;
    --success-bg: #2f7a4b;
    --danger-bg: #8f3a33;
    --danger-hover: #7a302a;
    --button-bg: #8A4A1B;
    --button-hover: #985E33;
    --button-text: #FFF0E0;
    --button-focus: #FFA24A;
    --button-focus-text: #2B1607;
    --heading-color: #FFA24A;
    --placeholder-gradient: linear-gradient(135deg, #4A2D18 0%, #331E10 100%);
    --progress-color: #FFA24A;
    --progress-label: #2B1607;
    --button-secondary-bg: #5C3417; /* quieter buttons (btn-secondary), outlined in the button color */
    --button-secondary-text: #FFF0E0;
}

/* Brown: coffee brown with caramel (the Android theme's colors) */
:root[data-theme="brown"] {
    color-scheme: dark;
    --primary-color: #E3B676;
    --primary-dark: #C19B64;
    --secondary-color: #C77C4A;
    --background-gradient: linear-gradient(180deg, #18120D 0%, #221A13 100%);
    --text-color: #F5EADC;
    --surface-color: #2D2219;
    --surface-hover: #423226;
    --card-bg: #2D2219;
    --panel-bg: #382A20;
    --placeholder-bg: #423226;
    --hover-bg: #3C2D22;
    --border-color: #56402E;
    --muted-text: #CDB9A2;
    --strong-text: #F5EADC;
    --success-bg: #2f7a4b;
    --danger-bg: #8f3a33;
    --danger-hover: #7a302a;
    --button-bg: #6B4D36;
    --button-hover: #7C604A;
    --button-text: #F5EADC;
    --button-focus: #E3B676;
    --button-focus-text: #2D2219;
    --heading-color: #E3B676;
    --placeholder-gradient: linear-gradient(135deg, #423226 0%, #2D2219 100%);
    --progress-color: #E3B676;
    --progress-label: #2D2219;
    --button-secondary-bg: #4C3829; /* quieter buttons (btn-secondary), outlined in the button color */
    --button-secondary-text: #F5EADC;
}

/* Purple: violet with lavender (the Android theme's colors) */
:root[data-theme="purple"] {
    color-scheme: dark;
    --primary-color: #C3A6FF;
    --primary-dark: #A68DD9;
    --secondary-color: #F29FC5;
    --background-gradient: linear-gradient(180deg, #140E22 0%, #1C142E 100%);
    --text-color: #EEE8FF;
    --surface-color: #23193B;
    --surface-hover: #322556;
    --card-bg: #23193B;
    --panel-bg: #2A1F48;
    --placeholder-bg: #322556;
    --hover-bg: #2E214E;
    --border-color: #403070;
    --muted-text: #BCB1DD;
    --strong-text: #EEE8FF;
    --success-bg: #2f7a4b;
    --danger-bg: #8f3a33;
    --danger-hover: #7a302a;
    --button-bg: #4F3C8A;
    --button-hover: #625198;
    --button-text: #EEE8FF;
    --button-focus: #C3A6FF;
    --button-focus-text: #1E1436;
    --heading-color: #C3A6FF;
    --placeholder-gradient: linear-gradient(135deg, #322556 0%, #23193B 100%);
    --progress-color: #C3A6FF;
    --progress-label: #1E1436;
    --button-secondary-bg: #392B62; /* quieter buttons (btn-secondary), outlined in the button color */
    --button-secondary-text: #EEE8FF;
}

/* Gray: charcoal with silver (the Android theme's colors) */
:root[data-theme="gray"] {
    color-scheme: dark;
    --primary-color: #DDE2E7;
    --primary-dark: #BCC0C4;
    --secondary-color: #8FB8E8;
    --background-gradient: linear-gradient(180deg, #151617 0%, #1C1E1F 100%);
    --text-color: #EFF1F3;
    --surface-color: #232527;
    --surface-hover: #313437;
    --card-bg: #232527;
    --panel-bg: #2A2C2F;
    --placeholder-bg: #313437;
    --hover-bg: #2D3032;
    --border-color: #3E4145;
    --muted-text: #B3B8BD;
    --strong-text: #EFF1F3;
    --success-bg: #2f7a4b;
    --danger-bg: #8f3a33;
    --danger-hover: #7a302a;
    --button-bg: #4A4E53;
    --button-hover: #5E6266;
    --button-text: #EFF1F3;
    --button-focus: #DDE2E7;
    --button-focus-text: #232527;
    --heading-color: #DDE2E7;
    --placeholder-gradient: linear-gradient(135deg, #313437 0%, #232527 100%);
    --progress-color: #DDE2E7;
    --progress-label: #232527;
    --button-secondary-bg: #373A3D; /* quieter buttons (btn-secondary), outlined in the button color */
    --button-secondary-text: #EFF1F3;
}

/* Yellow: dark olive with sunflower (the Android theme's colors) */
:root[data-theme="yellow"] {
    color-scheme: dark;
    --primary-color: #FFE04D;
    --primary-dark: #D9BE41;
    --secondary-color: #F29B38;
    --background-gradient: linear-gradient(180deg, #181606 0%, #221F08 100%);
    --text-color: #FFF9DA;
    --surface-color: #2B2809;
    --surface-hover: #3F3A10;
    --card-bg: #2B2809;
    --panel-bg: #35310C;
    --placeholder-bg: #3F3A10;
    --hover-bg: #39350E;
    --border-color: #544D12;
    --muted-text: #DAD19E;
    --strong-text: #FFF9DA;
    --success-bg: #2f7a4b;
    --danger-bg: #8f3a33;
    --danger-hover: #7a302a;
    --button-bg: #6A6015;
    --button-hover: #7C722D;
    --button-text: #FFF9DA;
    --button-focus: #FFE04D;
    --button-focus-text: #2B2809;
    --heading-color: #FFE04D;
    --placeholder-gradient: linear-gradient(135deg, #3F3A10 0%, #2B2809 100%);
    --progress-color: #FFE04D;
    --progress-label: #2B2809;
    --button-secondary-bg: #4A4410; /* quieter buttons (btn-secondary), outlined in the button color */
    --button-secondary-text: #FFF9DA;
}

/* Green: forest green with lime (the Android theme's colors) */
:root[data-theme="green"] {
    color-scheme: dark;
    --primary-color: #93E27D;
    --primary-dark: #7DC06A;
    --secondary-color: #E8C55A;
    --background-gradient: linear-gradient(180deg, #0D190F 0%, #122214 100%);
    --text-color: #E8F6E9;
    --surface-color: #162B19;
    --surface-hover: #213F26;
    --card-bg: #162B19;
    --panel-bg: #1C3520;
    --placeholder-bg: #213F26;
    --hover-bg: #1E3922;
    --border-color: #28542E;
    --muted-text: #B0D2B3;
    --strong-text: #E8F6E9;
    --success-bg: #2f7a4b;
    --danger-bg: #8f3a33;
    --danger-hover: #7a302a;
    --button-bg: #2E6A37;
    --button-hover: #447B4C;
    --button-text: #E8F6E9;
    --button-focus: #93E27D;
    --button-focus-text: #12261A;
    --heading-color: #93E27D;
    --placeholder-gradient: linear-gradient(135deg, #213F26 0%, #162B19 100%);
    --progress-color: #93E27D;
    --progress-label: #12261A;
    --button-secondary-bg: #234A29; /* quieter buttons (btn-secondary), outlined in the button color */
    --button-secondary-text: #E8F6E9;
}

/* Harbor Lights: navy boxes, brick buttons and lamp gold (the Android theme's colors) */
:root[data-theme="harbor-lights"] {
    color-scheme: dark;
    --primary-color: #F2B544;
    --primary-dark: #CE9A3A;
    --secondary-color: #B0786A;
    --background-gradient: linear-gradient(180deg, #0C1626 0%, #101D32 100%);
    --text-color: #F3EAD8;
    --surface-color: #14243D;
    --surface-hover: #322A39;
    --card-bg: #14243D;
    --panel-bg: #23273B;
    --placeholder-bg: #322A39;
    --hover-bg: #29283A;
    --border-color: #5F3234;
    --muted-text: #BBB8B1;
    --strong-text: #F3EAD8;
    --success-bg: #2f7a4b;
    --danger-bg: #8f3a33;
    --danger-hover: #7a302a;
    --button-bg: #8C3B2E;
    --button-hover: #985042;
    --button-text: #F3EAD8;
    --button-focus: #F2B544;
    --button-focus-text: #14243D;
    --heading-color: #F2B544;
    --placeholder-gradient: linear-gradient(135deg, #322A39 0%, #14243D 100%);
    --progress-color: #F2B544;
    --progress-label: #14243D;
    --button-secondary-bg: #4D2F36; /* quieter buttons (btn-secondary), outlined in the button color */
    --button-secondary-text: #F3EAD8;
}

/* Moss and Rose: forest boxes, dusty rose buttons and cream gold (the Android theme's colors) */
:root[data-theme="moss-and-rose"] {
    color-scheme: dark;
    --primary-color: #F1D49B;
    --primary-dark: #CDB484;
    --secondary-color: #B28087;
    --background-gradient: linear-gradient(180deg, #0F1F18 0%, #162B22 100%);
    --text-color: #F4EEDF;
    --surface-color: #1D372B;
    --surface-hover: #393A36;
    --card-bg: #1D372B;
    --panel-bg: #2B3830;
    --placeholder-bg: #393A36;
    --hover-bg: #313933;
    --border-color: #643F47;
    --muted-text: #BEC0B2;
    --strong-text: #F4EEDF;
    --success-bg: #2f7a4b;
    --danger-bg: #8f3a33;
    --danger-hover: #7a302a;
    --button-bg: #8E4458;
    --button-hover: #9A5868;
    --button-text: #F4EEDF;
    --button-focus: #F1D49B;
    --button-focus-text: #1D372B;
    --heading-color: #F1D49B;
    --placeholder-gradient: linear-gradient(135deg, #393A36 0%, #1D372B 100%);
    --progress-color: #F1D49B;
    --progress-label: #1D372B;
    --button-secondary-bg: #533D40; /* quieter buttons (btn-secondary), outlined in the button color */
    --button-secondary-text: #F4EEDF;
}

/* Desert Bloom: plum-brown boxes, terracotta buttons and turquoise (the Android theme's colors) */
:root[data-theme="desert-bloom"] {
    color-scheme: dark;
    --primary-color: #4FD1C5;
    --primary-dark: #43B2A7;
    --secondary-color: #C5866B;
    --background-gradient: linear-gradient(180deg, #1E0F17 0%, #2B1821 100%);
    --text-color: #FBEDE3;
    --surface-color: #38202B;
    --surface-hover: #542C2B;
    --card-bg: #38202B;
    --panel-bg: #46262B;
    --placeholder-bg: #542C2B;
    --hover-bg: #4C282B;
    --border-color: #7E3D2A;
    --muted-text: #CABAB5;
    --strong-text: #FBEDE3;
    --success-bg: #2f7a4b;
    --danger-bg: #8f3a33;
    --danger-hover: #7a302a;
    --button-bg: #A84E2A;
    --button-hover: #B26140;
    --button-text: #FBEDE3;
    --button-focus: #4FD1C5;
    --button-focus-text: #1E0F17;
    --heading-color: #4FD1C5;
    --placeholder-gradient: linear-gradient(135deg, #542C2B 0%, #38202B 100%);
    --progress-color: #4FD1C5;
    --progress-label: #1E0F17;
    --button-secondary-bg: #6D362B; /* quieter buttons (btn-secondary), outlined in the button color */
    --button-secondary-text: #FBEDE3;
}

/* Arctic Berry: slate blue boxes, raspberry buttons and ice mint (the Android theme's colors) */
:root[data-theme="arctic-berry"] {
    color-scheme: dark;
    --primary-color: #9BE7D8;
    --primary-dark: #84C4B8;
    --secondary-color: #BD7393;
    --background-gradient: linear-gradient(180deg, #10172A 0%, #182037 100%);
    --text-color: #EEF2FA;
    --surface-color: #1F2A44;
    --surface-hover: #402B4A;
    --card-bg: #1F2A44;
    --panel-bg: #302A47;
    --placeholder-bg: #402B4A;
    --hover-bg: #362B48;
    --border-color: #722C52;
    --muted-text: #BAC0CC;
    --strong-text: #EEF2FA;
    --success-bg: #2f7a4b;
    --danger-bg: #8f3a33;
    --danger-hover: #7a302a;
    --button-bg: #A32E5B;
    --button-hover: #AC466E;
    --button-text: #EEF2FA;
    --button-focus: #9BE7D8;
    --button-focus-text: #10172A;
    --heading-color: #9BE7D8;
    --placeholder-gradient: linear-gradient(135deg, #402B4A 0%, #1F2A44 100%);
    --progress-color: #9BE7D8;
    --progress-label: #10172A;
    --button-secondary-bg: #5E2C4F; /* quieter buttons (btn-secondary), outlined in the button color */
    --button-secondary-text: #EEF2FA;
}

/* Copper Sea: deep teal boxes, copper buttons and sand (the Android theme's colors) */
:root[data-theme="copper-sea"] {
    color-scheme: dark;
    --primary-color: #EAD7A1;
    --primary-dark: #C7B789;
    --secondary-color: #BA8A6D;
    --background-gradient: linear-gradient(180deg, #082221 0%, #0C2E2E 100%);
    --text-color: #F1EBDD;
    --surface-color: #0F3B3A;
    --surface-hover: #324238;
    --card-bg: #0F3B3A;
    --panel-bg: #203E39;
    --placeholder-bg: #324238;
    --hover-bg: #284039;
    --border-color: #674C34;
    --muted-text: #B8BFB4;
    --strong-text: #F1EBDD;
    --success-bg: #2f7a4b;
    --danger-bg: #8f3a33;
    --danger-hover: #7a302a;
    --button-bg: #9C5530;
    --button-hover: #A66745;
    --button-text: #F1EBDD;
    --button-focus: #EAD7A1;
    --button-focus-text: #0F3B3A;
    --heading-color: #EAD7A1;
    --placeholder-gradient: linear-gradient(135deg, #324238 0%, #0F3B3A 100%);
    --progress-color: #EAD7A1;
    --progress-label: #0F3B3A;
    --button-secondary-bg: #524735; /* quieter buttons (btn-secondary), outlined in the button color */
    --button-secondary-text: #F1EBDD;
}

/* Neon Arcade: charcoal boxes, electric violet buttons and lime (the Android theme's colors) */
:root[data-theme="neon-arcade"] {
    color-scheme: dark;
    --primary-color: #B8F04A;
    --primary-dark: #9CCC3F;
    --secondary-color: #9076D7;
    --background-gradient: linear-gradient(180deg, #111116 0%, #17171E 100%);
    --text-color: #F1EEFF;
    --surface-color: #1D1D26;
    --surface-hover: #2C234D;
    --card-bg: #1D1D26;
    --panel-bg: #24203A;
    --placeholder-bg: #2C234D;
    --hover-bg: #282141;
    --border-color: #442C88;
    --muted-text: #BCBAC9;
    --strong-text: #F1EEFF;
    --success-bg: #2f7a4b;
    --danger-bg: #8f3a33;
    --danger-hover: #7a302a;
    --button-bg: #5B36C2;
    --button-hover: #6D4CC9;
    --button-text: #F1EEFF;
    --button-focus: #B8F04A;
    --button-focus-text: #16161E;
    --heading-color: #B8F04A;
    --placeholder-gradient: linear-gradient(135deg, #2C234D 0%, #1D1D26 100%);
    --progress-color: #B8F04A;
    --progress-label: #16161E;
    --button-secondary-bg: #3A2970; /* quieter buttons (btn-secondary), outlined in the button color */
    --button-secondary-text: #F1EEFF;
}

/* Terminal Green: an old monitor's green phosphor on black (the Android theme's colors) */
:root[data-theme="terminal-green"] {
    color-scheme: dark;
    --primary-color: #33FF66;
    --primary-dark: #2BD957;
    --secondary-color: #C8FFD2;
    --background-gradient: linear-gradient(180deg, #020802 0%, #040D04 100%);
    --text-color: #8CFF9E;
    --surface-color: #061206;
    --surface-hover: #0B200C;
    --card-bg: #061206;
    --panel-bg: #081909;
    --placeholder-bg: #0B200C;
    --hover-bg: #0A1C0A;
    --border-color: #0D2D10;
    --muted-text: #4FC963;
    --strong-text: #8CFF9E;
    --success-bg: #2f7a4b;
    --danger-bg: #8f3a33;
    --danger-hover: #7a302a;
    --button-bg: #0F3A14;
    --button-hover: #1E5225;
    --button-text: #8CFF9E;
    --button-focus: #33FF66;
    --button-focus-text: #021202;
    --heading-color: #33FF66;
    --placeholder-gradient: linear-gradient(135deg, #0B200C 0%, #061206 100%);
    --progress-color: #33FF66;
    --progress-label: #021202;
    --button-secondary-bg: #0B260D; /* quieter buttons (btn-secondary), outlined in the button color */
    --button-secondary-text: #8CFF9E;
}

/* Terminal Amber: an old monitor's amber phosphor on black (the Android theme's colors) */
:root[data-theme="terminal-amber"] {
    color-scheme: dark;
    --primary-color: #FFB000;
    --primary-dark: #D99600;
    --secondary-color: #FFE3A8;
    --background-gradient: linear-gradient(180deg, #080500 0%, #0E0800 100%);
    --text-color: #FFC870;
    --surface-color: #140C00;
    --surface-hover: #221500;
    --card-bg: #140C00;
    --panel-bg: #1B1000;
    --placeholder-bg: #221500;
    --hover-bg: #1E1200;
    --border-color: #301E00;
    --muted-text: #C98A2E;
    --strong-text: #FFC870;
    --success-bg: #2f7a4b;
    --danger-bg: #8f3a33;
    --danger-hover: #7a302a;
    --button-bg: #3D2600;
    --button-hover: #54390D;
    --button-text: #FFC870;
    --button-focus: #FFB000;
    --button-focus-text: #140C00;
    --heading-color: #FFB000;
    --placeholder-gradient: linear-gradient(135deg, #221500 0%, #140C00 100%);
    --progress-color: #FFB000;
    --progress-label: #140C00;
    --button-secondary-bg: #291900; /* quieter buttons (btn-secondary), outlined in the button color */
    --button-secondary-text: #FFC870;
}

/* The terminal themes: every piece of text in a monospace font, the same one as the Android app
   (bundled: some phones' "monospace" isn't one) */
@font-face {
    font-family: 'Terminal Mono';
    src: url('../fonts/DejaVuSansMono.ttf') format('truetype');
    font-weight: 400;
}
@font-face {
    font-family: 'Terminal Mono';
    src: url('../fonts/DejaVuSansMono-Bold.ttf') format('truetype');
    font-weight: 700;
}
:root:is([data-theme="terminal-green"], [data-theme="terminal-amber"]) body,
:root:is([data-theme="terminal-green"], [data-theme="terminal-amber"]) :is(button, input, select, textarea) {
    font-family: 'Terminal Mono', ui-monospace, Menlo, Consolas, monospace;
}

/* Scrollbars in the theme's colors (every scrolling box inherits them): its button color on a
   see-through track. The page's always keeps its room, so a page or Settings tab too short to
   scroll doesn't move its content sideways when the scrollbar comes and goes. */
:root {
    scrollbar-color: var(--button-bg, var(--primary-color)) transparent;
    scrollbar-gutter: stable;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background-gradient);
    min-height: 100vh;
    color: var(--text-color);
}

.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* Login Screen */
.login-container {
    max-width: 400px;
    margin: 100px auto;
    background: var(--surface-color);
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.login-container h1 {
    text-align: center;
    margin-bottom: 30px;
}

.brand-logo {
    display: block;
    width: clamp(180px, 24vw, 260px);
    height: auto;
}

/* The header's wordmark: cream letters (the aubergine ones are for a light header) */
.brand-logo.brand-on-light {
    display: none;
}

.login-container .brand-logo {
    width: min(100%, 320px);
    margin: 0 auto;
}

/* Settings → Groups, and the groups that can see each library */
.settings-hint {
    color: var(--muted-text);
    font-size: 13px;
    margin-bottom: 10px;
}

.group-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color);
}

.group-name {
    flex: 1;
    font-weight: 500;
}

/* The first group, which new users start in (like the users list's badges) */
.group-default {
    display: inline-block;
    padding: 1px 6px;
    background: var(--button-bg, var(--primary-color));
    color: var(--button-text, white);
    border-radius: 3px;
    font-size: 11px;
    font-weight: normal;
    vertical-align: middle;
}

.groups-add {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.groups-add .settings-input {
    flex: 1;
    margin: 0;
}

.groups-message {
    margin-top: 8px;
    font-weight: bold;
}

.groups-message:empty {
    display: none;
}

/* Settings, Media Paths: a library, read-only (with Edit) or being edited */
.media-path {
    margin-bottom: 12px;
    padding: 10px;
    background: var(--card-bg);
    border-radius: 5px;
}

.media-path.editing {
    box-shadow: inset 3px 0 0 var(--heading-color, var(--primary-color));
}

.media-path-head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.media-path-move:disabled {
    opacity: 0.35;
    cursor: default;
}

.media-path-names {
    flex: 1;
    min-width: 0;
}

.media-path-name {
    font-weight: 600;
}

.media-path-folder {
    color: var(--muted-text);
    font-size: 13px;
    overflow-wrap: anywhere;
}

/* Its settings, a label and a value per row, under a line */
.media-path-details {
    display: grid;
    grid-template-columns: max-content 1fr;
    align-items: center;
    gap: 6px 18px;
    margin: 10px 0 0;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
    font-size: 13px;
}

.media-path-details dt {
    color: var(--muted-text);
}

.media-path-details dd {
    margin: 0;
}

.media-path-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.media-path-chip {
    padding: 1px 10px;
    border-radius: 999px;
    background: var(--button-bg, var(--primary-color));
    color: var(--button-text, white);
    font-size: 12px;
}

.path-groups {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 14px;
    margin-bottom: 6px;
    font-size: 13px;
}

.path-groups-label {
    color: var(--muted-text);
}

.path-group {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

/* The Android app's download links (shown once an APK is published) */
.app-download {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.app-download[hidden],
.app-download-group[hidden] {
    display: none;
}

.app-download svg {
    flex: none;
}

.app-download-info {
    opacity: 0.75;
    font-size: 0.85em;
}

/* The sign-in page's link to GitHub's latest release: the server gives the app only to those signed in */
.app-download-github {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
    color: var(--primary-color);
    font-size: 14px;
}

.app-download-github svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.app-download-github:hover {
    text-decoration: underline;
}

/* Settings › Damaged videos */
.damaged-list {
    list-style: none;
    padding: 0;
    margin: 8px 0;
}

.damaged-list li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
}

.damaged-list li {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.damaged-thumb {
    width: 160px;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 6px;
    flex: none;
}

.damaged-body {
    min-width: 0;
}

.damaged-name {
    font-weight: 600;
}

.damaged-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.app-download-text {
    color: var(--muted-text);
    margin-bottom: 12px;
}

#login-form input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 14px;
}

#login-form button {
    width: 100%;
    padding: 12px;
    background: var(--button-bg, var(--primary-color));
    color: var(--button-text, white);
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

#login-form button:hover {
    background: var(--button-focus, var(--button-hover, var(--primary-dark)));
    color: var(--button-focus-text, white);
}

.error {
    color: #e74c3c;
    font-size: 14px;
    margin-top: 10px;
    text-align: center;
}

/* Main Screen */
#main-screen {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

header {
    background: var(--surface-color);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

header h1 {
    flex: 0 1 auto;
    display: flex;
    flex-wrap: wrap; /* the server line goes under the wordmark when there's no room */
    align-items: center;
    gap: 4px 16px;
    min-width: 0;
}

/* The server and user after the wordmark */
.header-server {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--muted-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.header-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

/* Buttons use the theme's accent, unless a theme sets --button-bg (Dark) */
.btn {
    padding: 10px 20px;
    background: var(--button-bg, var(--primary-color));
    color: var(--button-text, white);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
}

.btn:hover {
    background: var(--button-focus, var(--button-hover, var(--primary-dark)));
    color: var(--button-focus-text, white);
}

/* Tabs */
.tabs {
    background: var(--surface-color);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.tab {
    padding: 10px 20px;
    background: var(--surface-hover);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--text-color);
}

.tab:hover {
    opacity: 0.8;
}

.tab.active {
    background: var(--button-bg, var(--primary-color));
    color: var(--button-text, white);
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 0;
    min-height: 56px;
    background: var(--surface-color);
    padding: 10px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.breadcrumb a {
    color: var(--primary-color);
    text-decoration: none;
    margin: 0 5px;
}

.breadcrumb > span {
    margin: 0 5px; /* the current title, spaced like the links */
}

.breadcrumb a:hover {
    text-decoration: underline;
}

/* Content */
.content {
    background: var(--surface-color);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.directory-list {
    margin-bottom: 20px;
}

.folder-thumbnail {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 80px;
    background: linear-gradient(135deg, #FFA500 0%, #FF8C00 100%);
}

.directory-item .media-name {
    font-weight: 600;
    padding: 10px 10px 0;
    margin-bottom: 10px; /* the name is the card's last line unless a match label follows */
}

.directory-item .media-match {
    margin-top: -6px;
}

/* Media Grid */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.media-item {
    background: var(--panel-bg);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
}

.media-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

.media-thumbnail {
    width: 100%;
    height: 200px;
    background: var(--placeholder-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 64px;
    overflow: hidden;
    position: relative;
}

.media-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-thumbnail.no-thumb {
    background: var(--placeholder-gradient, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
    color: white;
}

/* Transcode button overlay on video thumbnails */
.transcode-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    opacity: 0;
    z-index: 10;
}

.media-item:hover .transcode-btn {
    opacity: 1;
}

.transcode-btn:hover {
    background: var(--button-focus, var(--button-bg, var(--primary-color)));
    border-color: white;
    transform: scale(1.1);
    color: var(--button-focus-text, white);
}

.transcode-btn:active {
    transform: scale(0.95);
}

.media-info {
    padding: 10px;
}

.media-name {
    font-weight: 500;
    margin-bottom: 5px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
    max-height: 3.9em;
    word-break: break-word;
}

.media-size {
    font-size: 12px;
    color: var(--muted-text);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 10px;
    max-width: 90%;
    max-height: 90%;
    position: relative;
    overflow: auto;
    display: flex;
    flex-direction: column;
}

.close {
    position: absolute;
    right: 20px;
    top: 10px;
    font-size: 30px;
    cursor: pointer;
    color: var(--muted-text);
    z-index: 10;
}

.close:hover {
    color: var(--strong-text);
}

#video-player {
    width: 100%;
    max-height: 70vh;
    margin-top: 20px;
}

#image-viewer {
    max-width: 100%;
    height: auto;
    display: block;
}

/* An Apple Live Photo: its video plays over the still, then the still shows again */
.live-photo {
    position: relative;
    margin-top: 20px;
}

#live-photo-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.live-photo-button {
    align-self: flex-start; /* the modal is a flex column, which would stretch it */
    padding: 2px 10px;
    border: 1px solid currentColor;
    border-radius: 12px;
    background: transparent;
    color: var(--heading-color, #667eea);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    cursor: pointer;
}

.live-photo-button:hover {
    background: var(--button-focus, #667eea);
    color: var(--button-focus-text, #fff);
}

#player-title,
#image-title {
    margin-bottom: 10px;
    color: var(--heading-color, #667eea);
}

/* The file name, under a show's or movie's title */
.player-filename {
    margin: -6px 0 10px;
    font-size: 13px;
    color: var(--muted-text);
    overflow-wrap: anywhere;
}

/* Settings Screen */
#settings-screen {
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
}

.settings-container {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.settings-container h1 {
    color: var(--heading-color, #667eea);
    margin-bottom: 20px;
}

.settings-group {
    margin-top: 30px;
    padding: 20px;
    background: var(--panel-bg);
    border-radius: 5px;
}

.settings-group h3 {
    color: var(--heading-color, #667eea);
    margin-bottom: 15px;
}

.settings-group label {
    display: block;
    margin-bottom: 10px;
    color: var(--strong-text);
}

.settings-input {
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 14px;
}

#media-paths-list {
    max-height: 300px;
    overflow-y: auto;
}
/* One line of tabs: a narrow window scrolls it sideways rather than wrapping the names */
.settings-tabs {
    display: flex;
    gap: 6px;
    margin: 20px 0;
    border-bottom: 2px solid var(--border-color);
    overflow-x: auto;
    /* Scrolls sideways when the tabs don't fit, without a scrollbar over their labels (the wheel scrolls
       it too, and a chosen tab scrolls into view: app.js) */
    scrollbar-width: none;
}

.settings-tabs::-webkit-scrollbar {
    display: none;
}

.settings-tab {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 10px 14px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted-text);
    font-size: 14px;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
}

.settings-tab:hover {
    color: var(--heading-color, #667eea);
}

.settings-tab.active {
    color: var(--heading-color, #667eea);
    border-bottom-color: var(--heading-color, #667eea);
}

.settings-tab-content {
    display: none;
}

.settings-tab-content.active {
    display: block;
}

#users-list {
    margin-top: 15px;
}

.user-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: var(--card-bg);
    border-radius: 5px;
    margin-bottom: 10px;
}

.user-item .user-info {
    flex: 1;
}

.user-item .user-badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--button-bg, var(--primary-color));
    color: var(--button-text, white);
    border-radius: 3px;
    font-size: 12px;
    margin-left: 10px;
}

.user-item button {
    padding: 5px 15px;
    font-size: 12px;
}

.user-item .user-badge-you {
    background: var(--success-bg, #27ae60);
}

/* Thumbnail loading and update animations */
.media-thumbnail img.placeholder {
    opacity: 0.5;
    filter: grayscale(100%);
}

.media-thumbnail .loading-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    opacity: 0.3;
}

@keyframes thumbnailUpdate {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.8; }
}

.media-thumbnail img.placeholder {
    animation: pulse 2s ease-in-out infinite;
}


/* Metadata match line under item names */
.media-match {
    font-size: 12px;
    color: var(--primary-color);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.directory-item .media-match {
    padding: 0 10px 10px;
}


/* "Fix match" button: a light pill at the top-right of the thumbnail, readable on dark posters.
   Shown on hover (always on touch screens), admins only. */
.fix-match-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 11px 6px 9px;
    border-radius: 999px;
    border: none;
    background: rgba(255, 255, 255, 0.95);
    color: #1d1d27;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s, color 0.2s;
    z-index: 10;
}

.media-item:hover .fix-match-btn,
.fix-match-btn:focus-visible {
    opacity: 1;
}

@media (hover: none) {
    .fix-match-btn {
        opacity: 1;
    }
}

.fix-match-btn:hover,
.fix-match-btn:focus-visible {
    background: var(--button-focus, var(--button-bg, var(--primary-color)));
    color: var(--button-focus-text, white);
    outline: 2px solid white;
}

/* Fix match dialog */
.match-dialog {
    width: min(760px, 92vw);
    gap: 12px;
}

.match-close {
    position: absolute;
    right: 20px;
    top: 10px;
    font-size: 30px;
    cursor: pointer;
    color: var(--muted-text);
}

.match-target {
    color: var(--muted-text);
    font-size: 13px;
    word-break: break-all;
    margin-top: -6px;
}

.match-current {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    background: var(--panel-bg);
    border-radius: 8px;
    padding: 10px;
}

.match-current img {
    width: 46px;
    height: 69px;
    object-fit: cover;
    border-radius: 4px;
}

.match-status {
    flex: 1;
    min-width: 200px;
}

.match-hint {
    flex-basis: 100%;
    font-size: 12px;
    color: var(--muted-text);
}

.match-search {
    display: flex;
    gap: 8px;
}

.match-search #match-query {
    flex: 1;
}

.match-search #match-year {
    width: 90px;
}

.match-results {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 50vh;
    overflow-y: auto;
}

.match-hit {
    display: flex;
    gap: 12px;
    text-align: left;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

.match-hit:hover,
.match-hit:focus-visible {
    border-color: var(--primary-color);
    background: var(--hover-bg);
}

.match-hit.current {
    border-color: var(--primary-color);
    box-shadow: inset 4px 0 0 var(--primary-color);
}

.match-hit-poster {
    flex: 0 0 60px;
    height: 90px;
    background: var(--placeholder-bg);
    border-radius: 4px;
    overflow: hidden;
}

.match-hit-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.match-hit-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.match-hit-overview {
    font-size: 13px;
    color: var(--muted-text);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.match-empty {
    color: var(--muted-text);
    padding: 8px;
}

.match-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.match-message {
    flex: 1;
    font-size: 13px;
    color: #27ae60;
}

.match-message.error {
    color: #e74c3c;
}

/* A quieter button: each theme's --button-secondary-bg and -text, outlined in its button color;
   hovered, it takes the focus colors like any button (.btn:hover). */
.btn-secondary {
    background: var(--button-secondary-bg, #888);
    color: var(--button-secondary-text, white);
    box-shadow: inset 0 0 0 1px var(--button-bg, var(--primary-color));
}

/* Settings, My Account: the theme picker, a tile per theme drawn in its own colors */
.theme-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 10px;
}

.theme-tile {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 6px;
    background: none;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font: inherit;
    color: inherit;
    text-align: center;
}

.theme-tile:hover,
.theme-tile:focus-visible {
    border-color: var(--border-color);
    outline: none;
}

.theme-tile[aria-checked="true"] {
    border-color: var(--heading-color, var(--primary-color));
}

.theme-preview {
    display: block;
    height: 64px;
    border-radius: 5px;
    padding: 8px;
    box-shadow: inset 0 0 0 1px rgba(127, 127, 127, 0.35);
}

.theme-preview-box {
    position: relative;
    display: block;
    height: 100%;
    border-radius: 4px;
}

.theme-preview-heading,
.theme-preview-line {
    position: absolute;
    left: 7px;
    height: 4px;
    border-radius: 2px;
}

.theme-preview-heading { top: 8px; width: 40%; }
.theme-preview-line { top: 17px; width: 55%; opacity: 0.6; }

.theme-preview-button {
    position: absolute;
    right: 6px;
    bottom: 6px;
    padding: 1px 7px;
    border-radius: 3px;
    font-size: 11px;
    line-height: 1.4;
}

.theme-name {
    font-size: 13px;
    line-height: 1.3;
}

.theme-tile[aria-checked="true"] .theme-name {
    font-weight: 600;
}

@media (max-width: 600px) {
    .theme-picker { gap: 4px; }
    .theme-preview { height: 46px; padding: 6px; }
    .theme-preview-heading { top: 6px; }
    .theme-preview-line { top: 13px; }
    .theme-preview-button { bottom: 4px; right: 4px; font-size: 10px; }
}

/* Settings, Media Paths: a new library's folder, Browse…, its type and Add Path, all one height */
.new-path-row {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 8px;
    margin-top: 10px;
}

.new-path-row #new-path-input {
    flex: 1 1 220px;
    min-width: 0;
}

.new-path-row > * {
    margin: 0;
}

/* Folder picker (Settings, Media Paths) */
.folder-dialog {
    width: min(640px, 92vw);
    gap: 12px;
}

.folder-go {
    display: flex;
    gap: 8px;
}

.folder-go #folder-path {
    flex: 1;
    min-width: 0;
}

.folder-go #folder-up svg {
    margin: 0;
}

.folder-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    height: min(50vh, 420px);
    overflow-y: auto;
    background: var(--panel-bg);
    border-radius: 8px;
    padding: 6px;
}

.folder-entry {
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 7px 10px;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

.folder-entry svg {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    fill: var(--heading-color, var(--primary-color));
}

.folder-entry span {
    overflow-wrap: anywhere;
}

.folder-entry:hover,
.folder-entry:focus-visible {
    border-color: var(--primary-color);
    background: var(--hover-bg);
}

.folder-info {
    color: var(--muted-text);
}

/* Movies | TV shows switch of the fix match dialog */
.match-kind {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--muted-text);
}

.match-kind[hidden] {
    display: none;
}

.match-kind button {
    padding: 5px 12px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--card-bg);
    color: var(--strong-text);
    font: inherit;
    cursor: pointer;
}

.match-kind button.active {
    background: var(--button-bg, var(--primary-color));
    border-color: var(--primary-color);
    color: var(--button-text, white);
}

/* Poster section of the fix match dialog */
.match-posters:empty {
    display: none;
}

.match-posters {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.match-posters h3 {
    font-size: 15px;
}

.match-posters-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.match-posters-header .match-hint {
    flex: 1;
    flex-basis: auto;
}

.btn-small {
    padding: 4px 10px;
    font-size: 13px;
}

.match-posters-caption {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.match-poster-strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
}

.match-poster {
    flex: 0 0 auto;
    width: 80px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 3px;
    background: var(--card-bg);
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font: inherit;
    font-size: 11px;
    color: var(--muted-text);
}

.match-poster img {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: 4px;
    background: var(--placeholder-bg);
}

.match-poster span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.match-poster:hover,
.match-poster:focus-visible {
    border-color: var(--border-color);
}

.match-poster.current {
    border-color: var(--primary-color);
}

/* Episode section of the fix match dialog */
.match-episode:empty {
    display: none;
}

.match-episode {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
}

.match-episode h3 {
    font-size: 15px;
    margin-bottom: 4px;
}

.match-episode-summary {
    font-size: 13px;
    margin-bottom: 8px;
}

.match-episode-controls,
.match-episode-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.match-episode-actions {
    margin-top: 8px;
}

.match-episode-actions:empty {
    display: none;
}

.match-episode-list {
    display: flex;
    flex-direction: column;
    max-height: 200px;
    overflow-y: auto;
    margin-top: 8px;
    border-top: 1px solid var(--border-color);
}

.match-episode-row {
    display: grid;
    grid-template-columns: 70px 1fr auto;
    gap: 8px;
    text-align: left;
    background: none;
    border: none;
    border-bottom: 1px solid #f0f0f0;
    padding: 6px 4px;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    color: inherit;
}

.match-episode-row:hover,
.match-episode-row:focus-visible {
    background: var(--hover-bg);
}

.match-episode-row .code {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.match-episode-row .date {
    color: var(--muted-text);
}

.match-episode-row.current {
    box-shadow: inset 4px 0 0 #aaa;
}

.match-episode-row.picked {
    background: var(--button-bg, var(--primary-color));
    color: var(--button-text, white);
}

.match-episode-row.picked .date {
    color: rgba(255, 255, 255, 0.85);
}

/* Folders | Library switch */
.view-toggle {
    order: 1; /* after the path, at the right end */
    margin-left: auto;
    display: inline-flex;
    border: 1px solid var(--primary-color);
    border-radius: 999px;
    overflow: hidden;
}

.view-toggle button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: none;
    background: transparent;
    color: var(--primary-color);
    padding: 4px 14px;
    font: inherit;
    cursor: pointer;
    transition: background 0.2s;
}

/* The other view: clickable, so it fills like a button on hover */
.view-toggle button:not(.active):hover {
    background: var(--button-bg, var(--primary-color));
    color: var(--button-text, white);
}

/* The current view: filled in the accent, with a check, and nothing to click */
.view-toggle button.active {
    background: var(--primary-color);
    color: var(--button-focus-text, white);
    font-weight: 600;
    cursor: default;
}

.view-toggle button svg {
    width: 16px;
    height: 16px;
}

/* Library view */
.library-view {
    padding-bottom: 20px;
}

.library-empty {
    color: var(--muted-text);
    padding: 20px 0;
}

.library-section {
    font-size: 18px;
    margin: 28px 0 12px;
}

.poster-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 20px 16px;
}

.poster-card {
    display: flex;
    flex-direction: column;
    text-align: left;
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
}

.poster-card .poster {
    position: relative;
    aspect-ratio: 2 / 3;
    border-radius: 8px;
    overflow: hidden;
    background: var(--placeholder-bg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s, box-shadow 0.2s;
}

.poster-card:hover .poster,
.poster-card:focus-visible .poster {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.poster-card:focus-visible {
    outline: none;
}

.poster-card:focus-visible .poster {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

.poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.poster.no-poster {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    background: var(--placeholder-gradient, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
    color: white;
}

.poster-card:hover .fix-match-btn {
    opacity: 1;
}

.poster-title {
    font-weight: 600;
    margin-top: 8px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.poster-year {
    font-size: 13px;
    color: var(--muted-text);
}

/* Title page */
.title-hero {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    gap: 28px;
    padding: 24px;
    border-radius: 12px;
    background: var(--panel-bg);
    overflow: hidden;
    isolation: isolate;
}

.title-hero.has-backdrop {
    color: white;
    background: #111;
}

.title-hero.has-backdrop::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: linear-gradient(90deg, rgba(10, 10, 16, 0.92) 30%, rgba(10, 10, 16, 0.6)), var(--backdrop);
    background-size: cover;
    background-position: center top;
    z-index: -1;
}

/* The poster whole, at its own shape (not every poster is 2:3, and a crop cuts off its title) */
.title-poster {
    flex: 0 0 240px;
    align-self: flex-start;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}

.title-poster img {
    width: 100%;
    height: auto;
    display: block;
}

.title-poster.no-poster {
    aspect-ratio: 2 / 3;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 72px;
    background: var(--placeholder-gradient, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
}

.title-info {
    flex: 1 1 320px;
    min-width: 0;
}

.title-info h1 {
    font-size: 32px;
    margin-bottom: 6px;
}

.title-meta {
    opacity: 0.85;
    margin-bottom: 10px;
}

.title-tagline {
    font-style: italic;
    opacity: 0.85;
    margin-bottom: 10px;
}

.title-overview {
    line-height: 1.5;
    margin-bottom: 12px;
    max-width: 70ch;
}

.title-credit {
    margin-bottom: 6px;
}

.title-cast {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding: 10px 0 4px;
}

.cast-member {
    flex: 0 0 84px;
    text-align: center;
    font-size: 12px;
}

.cast-face {
    width: 64px;
    height: 64px;
    margin: 0 auto 6px;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(128, 128, 128, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 600;
}

.cast-face img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cast-name {
    font-weight: 600;
}

.cast-role {
    opacity: 0.75;
}

.title-files .media-grid {
    margin-top: 20px;
}

.title-file {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.play-btn {
    align-self: flex-start;
}

/* TV: seasons and episodes */
.season-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0;
}

/* As on Android: square-cornered (as the buttons are), the season shown filled, the others outlined in the raised color */
.season-picker button {
    border: 1px solid var(--placeholder-bg);
    background: transparent;
    color: var(--text-color);
    border-radius: 5px; /* as .btn's */
    padding: 6px 14px;
    display: inline-flex; /* centers a two-line label (as a block, it sat on the text baseline) */
    align-items: center;
    font: inherit;
    cursor: pointer;
}

.season-picker button.active {
    background: var(--button-bg, var(--primary-color));
    border-color: var(--button-bg, var(--primary-color));
    color: var(--button-text, white);
}

.season-picker button:hover {
    border-color: var(--button-focus, var(--button-bg, var(--primary-color)));
}

/* "Season 1" small above a season's own name */
.season-label {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.2;
    text-align: left;
}

.season-label small {
    font-size: 11px;
}

.episode-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.episode-row {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 16px;
    align-items: center;
    background: var(--panel-bg);
    border-radius: 8px;
    padding: 10px;
}

.episode-still {
    aspect-ratio: 16 / 9;
    border: none;
    padding: 0;
    border-radius: 6px;
    overflow: hidden;
    background: var(--placeholder-bg);
    cursor: pointer;
}

.episode-still img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.episode-title {
    font-weight: 600;
}

.episode-meta {
    font-size: 12px;
    color: var(--muted-text);
    margin: 2px 0 4px;
}

.episode-overview {
    font-size: 13px;
    color: var(--muted-text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Play, Fix and watched, left-aligned under the description, all one height (a Resume button's
   label can make it the tallest) */
.episode-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: stretch;
    margin-top: 8px;
}

.episode-actions .btn.icon-btn {
    align-self: stretch;
}

@media (max-width: 640px) {
    .episode-row {
        grid-template-columns: 1fr;
    }
    .title-poster {
        flex-basis: 160px;
    }
}

/* Elements toggled with the hidden attribute stay hidden whatever their display rule */
[hidden] {
    display: none !important;
}

/* Streams page */
.streams-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.streams-updated {
    color: var(--muted-text);
    font-size: 13px;
}

.streams-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.streams-empty {
    color: var(--muted-text);
    padding: 30px 0;
    text-align: center;
}

/* Settings → Jobs: a card per background job (sharing the Streams page's head, badge and bar) */
.jobs-load { font-size: 13px; color: var(--muted-text); margin-bottom: 12px; }
.jobs-list { display: flex; flex-direction: column; gap: 12px; }
.trickplay-settings { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 14px; }
.trickplay-settings[hidden] { display: none; }
.trickplay-settings label { display: flex; align-items: center; gap: 8px; margin: 0; }
.trickplay-settings input { width: 100px; }
.trickplay-settings .settings-hint { flex-basis: 100%; margin: 0; }
.trickplay-settings #tp-gpu-row { flex-basis: 100%; }
.trickplay-settings #tp-gpu-row[hidden] { display: none; }
.trickplay-settings #tp-gpu { width: auto; }
.tp-frames-fields { display: contents; }
.tp-frames-title { flex-basis: 100%; font-weight: 600; }
.wait-limits input { width: 90px; }
.wait-limits-title { flex-basis: 100%; font-weight: 600; }
/* What the settings need with 4K videos against what the server has: one row for its memory, one for an NVIDIA card's */
.tp-memory { flex-basis: 100%; max-width: 680px; border-collapse: collapse; font-size: 0.9em; }
.tp-memory[hidden] { display: none; }
.tp-memory th, .tp-memory td { text-align: left; padding: 3px 16px 3px 0; }
.tp-memory th { color: var(--text-secondary, inherit); font-weight: 600; }
.tp-memory .num { text-align: right; font-variant-numeric: tabular-nums; }
.tp-memory .tp-warn { color: var(--danger-color, #c62828); }
.job-card {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}
.storage-list { display: grid; grid-template-columns: 1fr auto auto; column-gap: 16px; row-gap: 6px; }
.storage-row { display: contents; font-size: 14px; }
.storage-size { text-align: right; font-weight: 600; }
.storage-bytes { text-align: right; color: var(--muted-text); font-variant-numeric: tabular-nums; }
.storage-total span { padding-top: 6px; border-top: 1px solid var(--border-color, rgba(128, 128, 128, 0.3)); font-weight: 700; }
@media (max-width: 500px) {
    .storage-list { grid-template-columns: 1fr auto; }
    .storage-bytes { grid-column: 2; font-size: 12px; }
    .storage-total .storage-bytes { border-top: none; padding-top: 0; }
}
.job-about, .job-line { font-size: 13px; color: var(--muted-text); overflow-wrap: anywhere; }
.job-note { font-size: 13px; font-weight: 600; color: var(--strong-text); }
.job-progress { display: flex; flex-direction: column; gap: 4px; }
.job-bar-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--progress-color, #6c7ae0); }
.job-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.job-state.state-running { background: #e3f6e8; color: #1e7b3a; }
.job-state.state-waiting { background: #fff4d6; color: #8a6200; }
.job-state.state-paused { background: #fde8e6; color: #a8322a; }

.stream-card {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.stream-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.stream-title {
    font-weight: 600;
    font-size: 17px;
    flex: 1;
    min-width: 200px;
    overflow-wrap: anywhere;
}

.stream-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--panel-bg);
    color: var(--muted-text);
}

.stream-badge.state-playing { background: #e3f6e8; color: #1e7b3a; }
.stream-badge.state-paused { background: #fff4d6; color: #8a6200; }
.stream-badge.state-streaming { background: #e6ecff; color: #3346a8; }
.stream-badge.mode-transcode { background: #fde8e6; color: #a8322a; }

.stream-who,
.stream-progress-label,
.stream-ua {
    font-size: 13px;
    color: var(--muted-text);
}

.stream-ua {
    color: var(--muted-text);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.stream-bar {
    position: relative;
    height: 8px;
    border-radius: 4px;
    background: var(--panel-bg);
    overflow: hidden;
}

.stream-bar-sent,
.stream-bar-pos {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
}

.stream-bar-sent {
    background: #c9cff3;
}

.stream-bar-pos {
    background: var(--primary-color);
}

.stream-progress-label {
    margin-top: 4px;
}

.stream-facts {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 3px 14px;
    font-size: 13px;
}

.stream-facts dt {
    color: var(--muted-text);
}

.stream-facts dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.stream-args summary {
    cursor: pointer;
    font-size: 13px;
    color: var(--muted-text);
}

.stream-args code {
    display: block;
    margin-top: 6px;
    padding: 8px;
    background: var(--panel-bg);
    border-radius: 6px;
    font-size: 12px;
    overflow-wrap: anywhere;
}

/* The player's controls under the video */
.player-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    margin-top: 10px;
    font-size: 14px;
}

.player-controls[hidden],
.player-controls label[hidden] {
    display: none;
}

.player-controls label {
    display: flex;
    align-items: center;
    gap: 6px;
}

.player-controls select {
    padding: 4px 6px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    max-width: 220px;
}

.player-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    flex-basis: 100%;
    min-width: 0;
    position: relative;
}

/* The seek bar and the time on a row of their own above the buttons */
.player-bar #player-seek {
    order: -2;
    flex: 1 1 calc(100% - 140px);
    min-width: 120px;
    margin: 0;
    accent-color: var(--primary-color);
}

.player-bar .player-position {
    order: -1;
    min-width: 120px;
    text-align: right;
}

/* The fullscreen button at the right end of the buttons */
.player-bar #player-fullscreen {
    margin-left: auto;
}

.player-position {
    color: var(--muted-text);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.player-volume {
    width: 80px;
    accent-color: var(--primary-color);
}

#video-player:not([controls]) {
    cursor: pointer;
}

/* Fullscreen playback: the video fills the screen, the controls over its bottom */
#player-modal .modal-content:fullscreen {
    max-width: none;
    max-height: none;
    width: 100vw;
    height: 100vh;
    overflow: hidden; /* the video fills it and the controls lie over it: nothing to scroll to */
    border-radius: 0;
    background: black;
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#player-modal .modal-content:fullscreen #video-player {
    flex: 1;
    min-height: 0;
    width: 100%;
    height: 100%;
    max-height: none;
}

/* The controls lie over the bottom of the video, and fade out with the cursor when idle */
#player-modal .modal-content:fullscreen {
    position: relative;
    padding: 0;
}

#player-modal .modal-content:fullscreen .player-controls {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    padding: 40px 24px 20px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
    transition: opacity 0.3s;
}

#player-modal .modal-content:fullscreen.controls-hidden,
#player-modal .modal-content:fullscreen.controls-hidden #video-player {
    cursor: none;
}

#player-modal .modal-content:fullscreen.controls-hidden .player-controls {
    opacity: 0;
    pointer-events: none;
}

#player-modal .modal-content:fullscreen #player-title,
#player-modal .modal-content:fullscreen .player-filename,
#player-modal .modal-content:fullscreen .close {
    display: none;
}

#player-modal .modal-content:fullscreen .player-position {
    color: #ccc;
}

/* What's at a point of the seek bar: a trickplay frame and the time */
.player-preview {
    position: absolute;
    bottom: calc(100% + 6px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    pointer-events: none;
    z-index: 5;
}

.player-preview[hidden],
.player-preview img[hidden] {
    display: none;
}

.player-preview img {
    width: 192px;
    height: auto;
    border-radius: 3px;
}

.player-status {
    flex-basis: 100%;
    color: var(--muted-text);
    font-size: 13px;
}

.player-status:empty {
    display: none;
}

#player-modal .modal-content:fullscreen .player-status {
    color: #ccc;
}

/* Player buttons: Material icons, fixed sizes so they don't shift as icons change */
.player-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 32px;
    min-width: 40px;
    padding: 0 8px;
    line-height: 1;
}

.player-icon-btn svg {
    flex: none;
}

.player-play-btn {
    width: 56px;
}

.player-skip-btn {
    width: 72px;
    font-size: 13px;
}

/* Dark, Ember and the colored themes: pieces whose light colors aren't theme variables */
:root:is([data-theme="dark"], [data-theme="default"], [data-theme="cinema-blue"], [data-theme="cinema-red"], [data-theme="teal"], [data-theme="orange"], [data-theme="brown"], [data-theme="purple"], [data-theme="gray"], [data-theme="yellow"], [data-theme="green"], [data-theme="harbor-lights"], [data-theme="moss-and-rose"], [data-theme="desert-bloom"], [data-theme="arctic-berry"], [data-theme="copper-sea"], [data-theme="neon-arcade"], [data-theme="terminal-green"], [data-theme="terminal-amber"]) .stream-badge.state-playing { background: #1d3a26; color: #7ee2a0; }
:root:is([data-theme="dark"], [data-theme="default"], [data-theme="cinema-blue"], [data-theme="cinema-red"], [data-theme="teal"], [data-theme="orange"], [data-theme="brown"], [data-theme="purple"], [data-theme="gray"], [data-theme="yellow"], [data-theme="green"], [data-theme="harbor-lights"], [data-theme="moss-and-rose"], [data-theme="desert-bloom"], [data-theme="arctic-berry"], [data-theme="copper-sea"], [data-theme="neon-arcade"], [data-theme="terminal-green"], [data-theme="terminal-amber"]) .stream-badge.state-paused { background: #3d3216; color: #f2cf6b; }
:root:is([data-theme="dark"], [data-theme="default"], [data-theme="cinema-blue"], [data-theme="cinema-red"], [data-theme="teal"], [data-theme="orange"], [data-theme="brown"], [data-theme="purple"], [data-theme="gray"], [data-theme="yellow"], [data-theme="green"], [data-theme="harbor-lights"], [data-theme="moss-and-rose"], [data-theme="desert-bloom"], [data-theme="arctic-berry"], [data-theme="copper-sea"], [data-theme="neon-arcade"], [data-theme="terminal-green"], [data-theme="terminal-amber"]) .stream-badge.state-streaming { background: #232c52; color: #a9b6ff; }
:root:is([data-theme="dark"], [data-theme="default"], [data-theme="cinema-blue"], [data-theme="cinema-red"], [data-theme="teal"], [data-theme="orange"], [data-theme="brown"], [data-theme="purple"], [data-theme="gray"], [data-theme="yellow"], [data-theme="green"], [data-theme="harbor-lights"], [data-theme="moss-and-rose"], [data-theme="desert-bloom"], [data-theme="arctic-berry"], [data-theme="copper-sea"], [data-theme="neon-arcade"], [data-theme="terminal-green"], [data-theme="terminal-amber"]) .stream-badge.mode-transcode { background: #4a2220; color: #ff9c92; }
:root:is([data-theme="dark"], [data-theme="default"], [data-theme="cinema-blue"], [data-theme="cinema-red"], [data-theme="teal"], [data-theme="orange"], [data-theme="brown"], [data-theme="purple"], [data-theme="gray"], [data-theme="yellow"], [data-theme="green"], [data-theme="harbor-lights"], [data-theme="moss-and-rose"], [data-theme="desert-bloom"], [data-theme="arctic-berry"], [data-theme="copper-sea"], [data-theme="neon-arcade"], [data-theme="terminal-green"], [data-theme="terminal-amber"]) .stream-bar-sent { background: #3b416b; }
:root:is([data-theme="dark"], [data-theme="default"], [data-theme="cinema-blue"], [data-theme="cinema-red"], [data-theme="teal"], [data-theme="orange"], [data-theme="brown"], [data-theme="purple"], [data-theme="gray"], [data-theme="yellow"], [data-theme="green"], [data-theme="harbor-lights"], [data-theme="moss-and-rose"], [data-theme="desert-bloom"], [data-theme="arctic-berry"], [data-theme="copper-sea"], [data-theme="neon-arcade"], [data-theme="terminal-green"], [data-theme="terminal-amber"]) .modal-content,
:root:is([data-theme="dark"], [data-theme="default"], [data-theme="cinema-blue"], [data-theme="cinema-red"], [data-theme="teal"], [data-theme="orange"], [data-theme="brown"], [data-theme="purple"], [data-theme="gray"], [data-theme="yellow"], [data-theme="green"], [data-theme="harbor-lights"], [data-theme="moss-and-rose"], [data-theme="desert-bloom"], [data-theme="arctic-berry"], [data-theme="copper-sea"], [data-theme="neon-arcade"], [data-theme="terminal-green"], [data-theme="terminal-amber"]) .settings-container,
:root:is([data-theme="dark"], [data-theme="default"], [data-theme="cinema-blue"], [data-theme="cinema-red"], [data-theme="teal"], [data-theme="orange"], [data-theme="brown"], [data-theme="purple"], [data-theme="gray"], [data-theme="yellow"], [data-theme="green"], [data-theme="harbor-lights"], [data-theme="moss-and-rose"], [data-theme="desert-bloom"], [data-theme="arctic-berry"], [data-theme="copper-sea"], [data-theme="neon-arcade"], [data-theme="terminal-green"], [data-theme="terminal-amber"]) .user-item,
:root:is([data-theme="dark"], [data-theme="default"], [data-theme="cinema-blue"], [data-theme="cinema-red"], [data-theme="teal"], [data-theme="orange"], [data-theme="brown"], [data-theme="purple"], [data-theme="gray"], [data-theme="yellow"], [data-theme="green"], [data-theme="harbor-lights"], [data-theme="moss-and-rose"], [data-theme="desert-bloom"], [data-theme="arctic-berry"], [data-theme="copper-sea"], [data-theme="neon-arcade"], [data-theme="terminal-green"], [data-theme="terminal-amber"]) .match-hit,
:root:is([data-theme="dark"], [data-theme="default"], [data-theme="cinema-blue"], [data-theme="cinema-red"], [data-theme="teal"], [data-theme="orange"], [data-theme="brown"], [data-theme="purple"], [data-theme="gray"], [data-theme="yellow"], [data-theme="green"], [data-theme="harbor-lights"], [data-theme="moss-and-rose"], [data-theme="desert-bloom"], [data-theme="arctic-berry"], [data-theme="copper-sea"], [data-theme="neon-arcade"], [data-theme="terminal-green"], [data-theme="terminal-amber"]) .match-poster,
:root:is([data-theme="dark"], [data-theme="default"], [data-theme="cinema-blue"], [data-theme="cinema-red"], [data-theme="teal"], [data-theme="orange"], [data-theme="brown"], [data-theme="purple"], [data-theme="gray"], [data-theme="yellow"], [data-theme="green"], [data-theme="harbor-lights"], [data-theme="moss-and-rose"], [data-theme="desert-bloom"], [data-theme="arctic-berry"], [data-theme="copper-sea"], [data-theme="neon-arcade"], [data-theme="terminal-green"], [data-theme="terminal-amber"]) .stream-card {
    color: var(--text-color);
}
:root:is([data-theme="dark"], [data-theme="default"], [data-theme="cinema-blue"], [data-theme="cinema-red"], [data-theme="teal"], [data-theme="orange"], [data-theme="brown"], [data-theme="purple"], [data-theme="gray"], [data-theme="yellow"], [data-theme="green"], [data-theme="harbor-lights"], [data-theme="moss-and-rose"], [data-theme="desert-bloom"], [data-theme="arctic-berry"], [data-theme="copper-sea"], [data-theme="neon-arcade"], [data-theme="terminal-green"], [data-theme="terminal-amber"]) .settings-input,
:root:is([data-theme="dark"], [data-theme="default"], [data-theme="cinema-blue"], [data-theme="cinema-red"], [data-theme="teal"], [data-theme="orange"], [data-theme="brown"], [data-theme="purple"], [data-theme="gray"], [data-theme="yellow"], [data-theme="green"], [data-theme="harbor-lights"], [data-theme="moss-and-rose"], [data-theme="desert-bloom"], [data-theme="arctic-berry"], [data-theme="copper-sea"], [data-theme="neon-arcade"], [data-theme="terminal-green"], [data-theme="terminal-amber"]) #login-form input,
:root:is([data-theme="dark"], [data-theme="default"], [data-theme="cinema-blue"], [data-theme="cinema-red"], [data-theme="teal"], [data-theme="orange"], [data-theme="brown"], [data-theme="purple"], [data-theme="gray"], [data-theme="yellow"], [data-theme="green"], [data-theme="harbor-lights"], [data-theme="moss-and-rose"], [data-theme="desert-bloom"], [data-theme="arctic-berry"], [data-theme="copper-sea"], [data-theme="neon-arcade"], [data-theme="terminal-green"], [data-theme="terminal-amber"]) .player-controls select {
    background: var(--panel-bg);
    color: var(--text-color);
}

/* Header buttons: Material icon and label */
.header-controls .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px; /* icons only: their names are tooltips */
}

.header-controls .btn svg {
    flex: none;
}

/* Headings with a Material icon (Settings, Active streams, Theme) */
.icon-heading {
    display: flex;
    align-items: center;
    gap: 0.35em;
}

.icon-heading svg {
    width: 1.1em;
    height: 1.1em;
    flex: none;
}

#transcode-btn,
.settings-group .btn,
#save-settings-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Destructive buttons (Remove a media path): red, deeper in Dark */
.btn.btn-danger {
    background: var(--danger-bg, #e74c3c);
}

.btn.btn-danger:hover {
    background: var(--danger-hover, #c0392b);
}

.btn.btn-danger,
.settings-group .btn.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    align-self: center; /* not stretched to the height of a long path beside it */
    flex: none;
    font-size: 12px;
    line-height: 1;
}

.btn.btn-danger svg {
    width: 16px;
    height: 16px;
}

/* A password-type field with an eye button inside it to show the value */
.secret-field {
    position: relative;
    display: inline-block;
    max-width: 100%;
}

.secret-field input {
    width: 100%;
    padding-right: 38px;
}

.secret-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--muted-text);
    cursor: pointer;
}

.secret-toggle:hover,
.secret-toggle:focus-visible {
    background: var(--hover-bg);
    color: var(--text-color);
}

/* Material icons standing in for missing thumbnails and posters */
.placeholder-icon {
    width: 42%;
    height: 42%;
    max-width: 96px;
    max-height: 96px;
    opacity: 0.85;
}

/* Folders, plain or with a picture, are the same square icon at the same size. */
.folder-thumbnail .placeholder-icon {
    color: #f0b429; /* folders stay folder-coloured */
    width: auto;
    height: 88%;
    aspect-ratio: 1;
    max-width: none;
    max-height: none;
    opacity: 1;
}

/* Settings › Streaming: what graphics hardware the server has */
.backup-list {
    margin: 10px 0 0;
    padding-left: 20px;
    color: var(--muted-text);
    font-size: 13px;
}

.backup-message {
    margin-left: 10px;
    font-size: 13px;
}

.hardware-heading {
    margin: 18px 0 6px;
}

.hardware-status {
    font-size: 13px;
    color: var(--muted-text);
    margin: 6px 0;
    line-height: 1.5;
}

/* A folder with a picture from inside it in its front (the icon's body is x 2-22, y 6-20 of 24). */
.folder-preview {
    position: relative;
    height: 88%;
    aspect-ratio: 1;
    color: #f0b429;
}

.folder-preview-shape {
    width: 100%;
    height: 100%;
    display: block;
}

.media-thumbnail img.folder-preview-image {
    position: absolute;
    left: 14%;
    right: 14%;
    top: 34%;
    bottom: 22%;
    width: 72%;
    height: 44%;
    object-fit: cover;
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

/* Videos in a folder: sprocket strips down both edges, telling them from photos */
.media-thumbnail.filmstrip::before,
.media-thumbnail.filmstrip::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 14px;
    z-index: 1;
    pointer-events: none;
    background-color: #111;
    background-image: linear-gradient(to bottom, rgba(240, 236, 228, 0.85) 0 7px, transparent 7px 14px);
    background-size: 6px 14px;
    background-position: center 4px;
    background-repeat: repeat-y;
}

.media-thumbnail.filmstrip::before { left: 0; }
.media-thumbnail.filmstrip::after { right: 0; }

/* Playback progress: a line along the bottom of a thumbnail or poster, a check once watched */
.watch-progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 4px;
    background: rgba(0, 0, 0, 0.55);
    z-index: 2;
}

.watch-progress span {
    display: block;
    height: 100%;
    background: var(--progress-color, var(--primary-color));
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15) inset;
}

.watched-badge {
    position: absolute;
    right: 8px;
    bottom: 10px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--progress-color, var(--primary-color));
    color: var(--progress-label, white);
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
    z-index: 2;
}

.watched-badge svg {
    width: 18px;
    height: 18px;
}

.episode-still {
    position: relative;
}

/* Corner buttons on video thumbnails: Play from start, and Mark watched */
.card-actions {
    position: absolute;
    top: 8px;
    left: 8px;
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
}

.media-item:hover .card-actions,
.card-actions:focus-within {
    opacity: 1;
}

@media (hover: none) {
    .card-actions {
        opacity: 1;
    }
}

.card-action {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    color: #1d1d27;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
    cursor: pointer;
    padding: 0;
}

.card-action:hover,
.card-action:focus-visible,
.card-action.is-watched {
    background: var(--button-focus, var(--button-bg, var(--primary-color)));
    color: var(--button-focus-text, white);
}

/* Play / Resume with Play from start beside it */
.play-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.play-buttons .btn,
.watched-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
}

.btn.secondary {
    background: transparent;
    color: var(--text-color);
    box-shadow: inset 0 0 0 1px var(--button-bg, var(--primary-color));
}

.btn.secondary:hover {
    background: var(--button-focus, var(--button-bg, var(--primary-color)));
    color: var(--button-focus-text, white);
}

.btn.icon-btn {
    padding: 6px;
    align-self: flex-start;
}

/* The check: solid once watched, dimmed until then */
.watched-btn:not(.is-watched) svg {
    opacity: 0.35;
}

.title-info .watched-btn {
    margin-top: 14px;
    align-self: flex-start;
}

.season-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 24px 0 0;
}

.season-ring {
    flex: none;
    margin-left: 10px;
}

/* Under the seasons: how many episodes the one shown has */
.episode-count {
    color: var(--muted-text);
    margin: 0 0 12px;
}

/* A sideways row's ‹ and › buttons (withScrollButtons), over its ends while the pointer is on it */
.scroll-row {
    position: relative;
}

.scroll-row-btn {
    position: absolute;
    top: var(--scroll-button-top, 50%);
    transform: translateY(-50%);
    z-index: 2;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--button-bg, var(--primary-color));
    color: var(--button-text, white);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, background 0.2s;
}

.scroll-row-btn svg {
    width: 26px;
    height: 26px;
}

.scroll-row-btn.prev { left: 4px; }
.scroll-row-btn.next { right: 4px; }

.scroll-row-btn:hover {
    background: var(--button-focus, var(--button-hover, var(--primary-dark)));
    color: var(--button-focus-text, white);
}

.scroll-row.can-prev:hover .scroll-row-btn.prev,
.scroll-row.can-next:hover .scroll-row-btn.next {
    opacity: 1;
    pointer-events: auto;
}

@media (hover: none) {
    .scroll-row-btn { display: none; }
}

/* Continue Watching and Recently Added: the buttons sit on the middle of the pictures (16:9, 240 wide) */
.continue-row .scroll-row {
    --scroll-button-top: 71px;
}

/* Continue Watching: a scrolling row of videos in progress */
.continue-row {
    margin-bottom: 24px;
}

.continue-items {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding: 4px 2px 10px;
    scroll-snap-type: x proximity;
}

.continue-card {
    flex: 0 0 240px;
    width: 240px;
    min-width: 0;
    cursor: pointer;
    scroll-snap-align: start;
}

.continue-card:focus-visible {
    outline: none;
}

.continue-card:focus-visible .continue-thumb {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

.continue-thumb {
    position: relative;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
    overflow: hidden;
    background: var(--placeholder-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.continue-thumb img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.continue-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    opacity: 0;
    transition: opacity 0.2s;
}

.continue-card:hover .continue-remove,
.continue-remove:focus-visible {
    opacity: 1;
}

@media (hover: none) {
    .continue-remove {
        opacity: 1;
    }
}

.continue-title {
    font-weight: 600;
    margin-top: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.continue-subtitle {
    font-size: 13px;
    color: var(--muted-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Resume or Play from start, for a partly watched video opened from a folder */
.resume-choice {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 16px;
}

.resume-choice-box {
    background: var(--panel-bg, var(--surface-color));
    color: var(--text-color);
    border-radius: 12px;
    padding: 22px;
    width: min(380px, 100%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.resume-choice-title {
    font-weight: 600;
    font-size: 17px;
    overflow-wrap: anywhere;
}

.resume-choice-meta {
    color: var(--muted-text);
    font-size: 14px;
    margin-bottom: 6px;
}

.resume-choice-box .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* The A–Z bar (setAzIndex): fixed down the right side, beside the folders or posters. */
.az-bar {
    position: fixed;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 2px;
    border-radius: 14px;
    z-index: 50;
    touch-action: none;
    user-select: none;
}
.az-bar[hidden] { display: none; }
.az-bar:hover, .az-bar.dragging { background: var(--surface-color); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3); }
body.has-az #main-screen .content { padding-right: 28px; }
.az-letter {
    flex: 0 1 22px;
    min-height: 0;
    width: 24px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: none;
    color: var(--muted-text);
    font: inherit;
    font-size: clamp(9px, 2.2vh, 13px);
    line-height: 1;
    cursor: pointer;
}
.az-letter:hover, .az-letter:focus-visible { background: var(--progress-color); color: var(--progress-label); outline: none; }
.az-letter.current { color: var(--progress-color); font-weight: 700; }
.az-letter.current:hover { color: var(--progress-label); }
.az-divider { flex: 0 0 auto; width: 12px; height: 1px; margin: 5px 0; background: var(--border-color); }
.az-bubble {
    position: absolute;
    right: calc(100% + 12px);
    width: 56px;
    height: 56px;
    margin-top: -28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50% 50% 0 50%;
    background: var(--progress-color);
    color: var(--progress-label);
    font-size: 28px;
    font-weight: 700;
    pointer-events: none;
}
.az-bubble[hidden] { display: none; }

/* Subtitles online: a panel over the player (inside it, so it shows in fullscreen too) */
.subtitle-search {
    position: absolute;
    top: 50px;
    right: 20px;
    bottom: 20px;
    width: min(520px, calc(100% - 40px));
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
.subtitle-search[hidden] { display: none; }
.subtitle-search-head { display: flex; align-items: center; justify-content: space-between; }
.subtitle-search-head h3 { margin: 0; color: var(--heading-color, var(--primary-color)); }
.subtitle-search-head .match-close { position: static; background: none; border: none; }
.subtitle-search-form { display: flex; gap: 8px; align-items: center; }
.subtitle-search-form label { display: flex; gap: 8px; align-items: center; flex: 1; }
.subtitle-search-form input { flex: 1; min-width: 0; }
.subtitle-search-note { margin: 0; font-size: 13px; color: var(--muted-text); }
.subtitle-results { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; min-height: 0; }
.subtitle-hit {
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: left;
    background: var(--panel-bg, var(--card-bg));
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
    font: inherit;
    color: inherit;
}
.subtitle-hit:hover:not(:disabled), .subtitle-hit:focus-visible { border-color: var(--primary-color); background: var(--hover-bg); }
.subtitle-hit:disabled { opacity: 0.6; cursor: default; }
.subtitle-hit-name { overflow-wrap: anywhere; }
.subtitle-hit-details { font-size: 12px; color: var(--muted-text); }

/* Settings → Subtitles: the options and a preview over a dark, picture-like stage */
.subtitle-style-note { font-size: 13px; color: var(--muted-text); margin-bottom: 12px; }
.subtitle-preview {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    height: 180px;
    padding-bottom: 18px;
    margin-bottom: 16px;
    border-radius: 8px;
    background: linear-gradient(135deg, #2b4a6b 0%, #6b5a3a 55%, #d8c48a 100%);
}
.subtitle-preview span { text-align: center; line-height: 1.3; padding: 2px 6px; }
.subtitle-preview span[hidden] { display: none; }
/* Text: None subtitles, drawn cut out over the video, where the browser's cues would be */
.player-cutout-subs {
    position: absolute;
    z-index: 4;
    /* Its own layer: else Chrome can leave it under the playing video's */
    will-change: transform;
    display: flex;
    justify-content: center;
    pointer-events: none;
}
.player-cutout-subs[hidden] { display: none; }

/* Picture subtitles (PGS), drawn over the video. Their frame can be taller than a cropped video:
   the box keeps it from overflowing the player, which would give it a scrollbar. */
.player-pgs-box {
    position: absolute;
    z-index: 4;
    overflow: hidden;
    will-change: transform;
    pointer-events: none;
}
.player-pgs-box[hidden] { display: none; }
#player-ass { position: absolute; left: 0; top: 0; }
.player-pgs-box canvas { position: absolute; }

/* Stays over the picture once a video can't play, as on Android */
.player-failed {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 4;
    padding: 8px 16px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    font-size: 22px;
    white-space: nowrap;
    pointer-events: none;
}
.player-failed[hidden] { display: none; }
.player-seek-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
    padding: 10px 20px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 28px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    pointer-events: none;
}
.player-seek-indicator[hidden] { display: none; }
.player-failed-reason { display: block; max-width: 60vw; margin-top: 4px; font-size: 15px; white-space: normal; text-align: center; }
.player-failed-reason:empty { display: none; }
.subtitle-style-mode { display: flex; gap: 20px; margin-bottom: 12px; }
.subtitle-style-options { display: flex; flex-direction: column; gap: 10px; }
.subtitle-style-options label { display: flex; gap: 10px; align-items: center; }
.subtitle-style-options select { min-width: 200px; }
.subtitle-style-options.disabled { opacity: 0.55; }

.account-language { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; max-width: 360px; }
.account-language select { min-width: 200px; margin-left: auto; }

.account-signed-in { margin-top: 20px; font-size: 15px; color: var(--muted-text); }

/* A new web UI is on the server: a click loads it. Under the player, so a video isn't covered. */
.update-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 900;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: calc(100vw - 32px);
    padding: 10px 18px;
    border: none;
    border-radius: 10px;
    background: var(--button-focus, #667eea);
    color: var(--button-focus-text, #fff);
    font: inherit;
    font-weight: 600;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
    cursor: pointer;
}
.update-banner[hidden] { display: none; }

/* Skip Intro / Skip Credits: over the picture's lower right, above the controls */
#player-modal .modal-content {
    position: relative;
}

.player-skip {
    position: absolute;
    right: 32px;
    bottom: 150px;
    z-index: 5;
    padding: 12px 22px;
    font-size: 16px;
    font-weight: 600;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

#player-modal .modal-content:fullscreen .player-skip {
    bottom: 110px;
}

/* Auto Skip, beside a show's watched buttons */
.auto-skip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 6px;
    cursor: pointer;
}

/* Subtitle timing: Already said / the correction / Not said yet / the step */
.player-sync {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.sync-value {
    min-width: 7em;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* Settings: the HTTPS certificate is about to expire, has, or a newer one waits for a restart */
.cert-warning {
    margin: 12px 0;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--heading-color, #F6C445);
    background: rgba(246, 196, 69, 0.12);
    color: var(--text-color, inherit);
    line-height: 1.4;
}
.cert-warning.cert-expired { border-color: #e05a47; background: rgba(224, 90, 71, 0.15); }
.cert-warning[hidden] { display: none; }

/* A setting that is a single checkbox (Settings › My Account › Playback) */
.settings-check { display: flex; gap: 10px; align-items: center; }

/* Collection view: a collection's films the library doesn't have */
.poster-card.missing { opacity: 0.4; cursor: default; }
.poster-card.missing:hover, .poster-card.missing:focus-visible { transform: none; }
.collection-head { margin-bottom: 16px; }
.collection-count { color: var(--muted-text); margin: 4px 0; }
.collection-overview { max-width: 70ch; line-height: 1.5; }

/* Collections view: a collage of up to four posters */
.poster.collage { display: grid; gap: 2px; background: var(--card-bg); }
.poster.collage img { width: 100%; height: 100%; object-fit: cover; min-height: 0; }
.poster.collage-1 { grid-template: 1fr / 1fr; }
.poster.collage-2 { grid-template: 1fr / 1fr 1fr; }
.poster.collage-3 { grid-template: 1fr 1fr / 1fr 1fr; }
.poster.collage-3 img:first-child { grid-row: span 2; }
.poster.collage-4 { grid-template: 1fr 1fr / 1fr 1fr; }
.collection-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 16px; }
.collection-remove {
    position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; cursor: pointer;
    background: rgba(0, 0, 0, 0.65); color: #fff;
}
.collection-remove svg { width: 18px; height: 18px; }
.collection-editor { width: min(620px, 92vw); gap: 10px; }
.collection-editor label { display: flex; flex-direction: column; gap: 4px; }
.collection-picker-head { display: flex; align-items: center; gap: 12px; }
.collection-picker-head input { flex: 1; }
.collection-picked { color: var(--muted-text); font-size: 13px; }
.collection-picker { max-height: 40vh; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.collection-editor .collection-pick { flex-direction: row; align-items: center; gap: 10px; padding: 4px 2px; cursor: pointer; }
.collection-pick[hidden] { display: none; }
.collection-message { color: var(--muted-text); min-height: 1em; margin: 0; }
.collection-buttons { display: flex; justify-content: flex-end; gap: 8px; }
.collection-add-btn { align-self: flex-start; margin-top: 12px; }
.poster.collage.no-poster { display: flex; }
.collection-editor textarea { font: inherit; resize: vertical; }
.collection-editor .collection-picker { min-height: 160px; }

/* A person's window (from a title page's cast) */
/* A button that looks as the cast's plain boxes did: their size of text, laid out from the top */
button.cast-member { background: none; border: none; color: inherit; font-family: inherit; font-size: 12px; line-height: inherit;
    cursor: pointer; padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; }
button.cast-member:hover .cast-face, button.cast-member:focus-visible .cast-face { outline: 3px solid var(--primary-color); outline-offset: 2px; }
.person-dialog { width: min(860px, 94vw); gap: 14px; }
.person-head { display: flex; gap: 20px; align-items: flex-start; }
.person-photo { flex: 0 0 160px; aspect-ratio: 2 / 3; border-radius: 10px; overflow: hidden; background: var(--placeholder-bg); }
.person-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.person-facts h2 { margin: 0 0 8px; }
.person-fact { margin: 4px 0; }
.person-facts { flex: 1; min-width: 0; }
.person-bio { line-height: 1.55; white-space: pre-line; margin: 12px 0 0; }
.person-body h3 { margin: 18px 0 10px; color: var(--heading-color, inherit); }
.person-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.person-films { display: flex; flex-direction: column; gap: 6px; }
.person-film { display: flex; gap: 12px; align-items: center; text-align: left; background: none; border: none; color: inherit;
    font: inherit; padding: 4px; border-radius: 6px; }
.person-film.here { cursor: pointer; }
.person-film.here:hover, .person-film.here:focus-visible { background: var(--card-hover-bg, rgba(255,255,255,0.06)); }
.person-film-poster { flex: 0 0 40px; height: 60px; border-radius: 4px; overflow: hidden; background: var(--placeholder-bg); }
.person-film-poster img { width: 100%; height: 100%; object-fit: cover; }
.person-film-title { font-weight: 600; }
.person-film.here .person-film-title { color: var(--heading-color, inherit); }
.person-film-meta { color: var(--muted-text); font-size: 13px; }
@media (max-width: 600px) { .person-head { flex-direction: column; } .person-photo { flex-basis: auto; width: 140px; } }
.title-file-list { margin-top: 20px; }
/* A movie's files: fewer than a season's episodes, so a larger thumbnail */
.title-file-list .episode-row { grid-template-columns: 320px 1fr; }
@media (max-width: 640px) { .title-file-list .episode-row { grid-template-columns: 1fr; } }

/* A video's format line: under its name, above its size and length */
.media-format { font-size: 12px; color: var(--muted-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.episode-format { font-size: 13px; color: var(--muted-text); margin-top: 2px; }

/* The Guide (js/guide.js): the channel playing top left, its program's details beside it, the grid
   of channels and half hours below */
.guide-row {
    margin-bottom: 20px;
}

.guide-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    padding: 12px 22px;
}

/* The Guide fills the window: the player and details stay put, only the grid scrolls. */
#guide-screen {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

#guide-screen.active {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

body:has(#guide-screen.active) {
    overflow: hidden;
}

body:has(#guide-screen.active) > footer {
    display: none;
}

.guide-container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    padding: 20px;
    border-radius: 10px;
}

.guide-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.guide-header h1 {
    color: var(--heading-color, #667eea);
    margin: 0;
}

.guide-top {
    flex: none;
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 800px) {
    .guide-top {
        grid-template-columns: 1fr;
    }
}

.guide-player {
    position: relative;
    aspect-ratio: 16 / 9;
    max-height: 48vh; /* room for the grid */
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

.guide-player:fullscreen {
    border-radius: 0;
}

.guide-player video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    cursor: pointer;
}

.guide-player-bar {
    position: absolute;
    right: 8px;
    bottom: 8px;
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s;
}

.guide-player:hover .guide-player-bar,
.guide-player:focus-within .guide-player-bar {
    opacity: 1;
}

.guide-player-button {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.guide-player-button svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

/* The channel's number after tuning, as a cable box shows it */
.guide-osd {
    position: absolute;
    top: 12px;
    right: 16px;
    font: bold 32px/1 monospace;
    color: #7CFC00;
    text-shadow: 2px 2px 0 #000;
    letter-spacing: 2px;
    pointer-events: none;
}

/* A bumper: "Up next…" between programs */
.guide-card {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5%;
    padding: 6%;
    background: radial-gradient(circle at 30% 30%, var(--channel-color), #0b0b1e 75%);
    cursor: pointer;
    color: #fff;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.6);
    container-type: inline-size;
}

.guide-card-logo {
    display: block;
    width: 30cqw;
    margin-bottom: 2cqw;
    filter: drop-shadow(3px 3px 0 rgba(0, 0, 0, 0.6));
}

.guide-osd-logo {
    position: absolute;
    left: 16px;
    top: 12px;
    width: 22%;
    pointer-events: none;
    filter: drop-shadow(3px 3px 0 rgba(0, 0, 0, 0.5));
}

.guide-card-poster {
    height: 80%;
    max-width: 35%;
    object-fit: contain;
    border: 3px solid #fff;
    box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.5);
}

.guide-card-kicker {
    font-size: 4cqw;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #FFD23F;
}

.guide-card-title {
    font-size: 6.5cqw;
    font-weight: 900;
    line-height: 1.05;
    margin: 2cqw 0;
}

.guide-card-line {
    font-size: 3.2cqw;
}

/* A voice-over's squeeze: the credits shrink into the corner beside what's next */
.guide-player video {
    transition: width 0.6s ease, height 0.6s ease, margin 0.6s ease;
}

.guide-player--squeezed video {
    width: 52%;
    height: 52%;
    margin: 3% 0 0 3%;
    border: 0.4cqh solid #fff;
    box-shadow: 0.8cqh 0.8cqh 0 rgba(0, 0, 0, 0.5);
}

.guide-player--squeezed {
    background: radial-gradient(circle at 75% 40%, var(--squeeze-color, #3a2a6a), #0b0b1e 80%);
}

.guide-upnext {
    position: absolute;
    left: 58%;
    right: 3%;
    top: 6%;
    bottom: 6%;
    display: flex;
    flex-direction: column;
    gap: 1.2cqh;
    color: #fff;
    text-shadow: 0.3cqh 0.3cqh 0 rgba(0, 0, 0, 0.6);
    animation: guide-upnext-in 0.6s ease;
}

@keyframes guide-upnext-in {
    from { opacity: 0; transform: translateX(10%); }
}

.guide-upnext-logo {
    width: 70%;
    filter: drop-shadow(0.4cqh 0.4cqh 0 rgba(0, 0, 0, 0.5));
}

.guide-upnext-kicker {
    font: 900 4cqh/1.1 sans-serif;
    color: #FFD23F;
    text-transform: uppercase;
}

.guide-upnext-title {
    font: 900 6.5cqh/1.05 sans-serif;
}

.guide-upnext-line {
    font: bold 3.6cqh/1.2 sans-serif;
}

.guide-upnext-poster {
    flex: 1;
    min-height: 0;
    align-self: flex-start;
    object-fit: contain;
    border: 0.4cqh solid #fff;
}

.guide-report-voice {
    align-self: flex-start;
    margin-top: 8px;
}

/* ---- The channels of their own: drawn over the picture, sized to it (container units) ---- */
.guide-player {
    container-type: size;
}

/* The Guide channel: the picture (or card) on top, every channel's listings below */
.guide-player--listings video {
    height: 58%;
}

.guide-player--listings .guide-card {
    inset: 0 0 42% 0;
    padding: 2% 6%;
}

.guide-player--listings .guide-card-logo {
    width: 18cqw;
    margin-bottom: 1cqw;
}

.guide-player--listings .guide-card-kicker {
    font-size: 2.6cqw;
}

.guide-player--listings .guide-card-title {
    font-size: 4.2cqw;
    margin: 1cqw 0;
}

.guide-player--listings .guide-card-line {
    font-size: 2.4cqw;
}

.guide-card-credit {
    margin-top: 1.5cqw;
    font-size: 1.6cqw;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60cqw;
}

.guide-caption {
    position: absolute;
    left: 2cqw;
    top: calc(58cqh - 11cqh);
    max-width: 70%;
    padding: 0.8cqh 1.6cqw;
    background: rgba(0, 0, 40, 0.75);
    color: #fff;
    border-left: 0.8cqw solid #FFD23F;
    pointer-events: none;
}

.guide-caption-when {
    font: bold 2.8cqh/1.2 sans-serif;
    color: #FFD23F;
    text-transform: uppercase;
}

.guide-caption-title {
    font: bold 3.6cqh/1.2 sans-serif;
}

.guide-listings {
    position: absolute;
    inset: 58% 0 0 0;
    display: flex;
    flex-direction: column;
    background: linear-gradient(#0a1a6a, #06104a);
    color: #fff;
    font-family: sans-serif;
    pointer-events: none;
}

.guide-listings-head,
.guide-listings-row {
    display: grid;
    grid-template-columns: 22% 26% 26% 26%;
}

.guide-listings-row {
    grid-template-columns: 22% 78%;
}

/* a channel's programs, each as wide as its time (flex-basis from listingSpans) */
.guide-listings-spans {
    display: flex;
    min-width: 0;
}

.guide-listings-head {
    background: #c8a000;
    color: #1a1a1a;
    font: bold 3.2cqh/1.6 sans-serif;
}

.guide-listings-head > div {
    padding: 0 1cqw;
}

.guide-listings-roll {
    flex: 1;
    overflow: hidden;
}

.guide-listings-list {
    animation: guide-roll linear infinite;
}

@keyframes guide-roll {
    from { transform: translateY(0); }
    to { transform: translateY(var(--roll, -50%)); }
}

.guide-listings-row {
    height: 9cqh;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.guide-listings-channel {
    display: flex;
    align-items: center;
    gap: 0.8cqw;
    padding: 0 0.8cqw;
    background: rgba(255, 255, 255, 0.08);
    min-width: 0;
}

.guide-listings-logo {
    height: 6cqh;
    max-width: 45%;
    object-fit: contain;
}

.guide-listings-number {
    font: bold 2.6cqh/1.1 sans-serif;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.guide-listings-cell {
    flex: 0 0 auto;
    min-width: 0;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    padding: 0 1cqw;
    font: bold 3cqh/1.1 sans-serif;
    border-left: 1px solid rgba(255, 255, 255, 0.15);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* The Weather channel: an 80s local forecast, blue, with the warnings scrolling in red */
.guide-weather {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: linear-gradient(#1d3f9a, #0a1f5c 60%, #081640);
    color: #fff;
    font-family: sans-serif;
    text-shadow: 0.3cqh 0.3cqh 0 rgba(0, 0, 0, 0.6);
    cursor: pointer;
}

.weather-head {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: baseline;
    gap: 3cqw;
    padding: 2.5cqh 4cqw 1.5cqh;
    background: linear-gradient(#e6b800, #b38600);
    color: #10204a;
    text-shadow: none;
}

.weather-title {
    font: 900 6cqh/1 sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.weather-place {
    font: bold 4cqh/1 sans-serif;
}

.weather-clock {
    font: bold 4cqh/1 monospace;
}

.weather-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 3cqh 4cqw;
    min-height: 0;
}

.weather-icon {
    width: 14cqh;
    height: 14cqh;
    filter: drop-shadow(0.4cqh 0.4cqh 0 rgba(0, 0, 0, 0.5));
}

.weather-icon-big {
    width: 30cqh;
    height: 30cqh;
    filter: drop-shadow(0.5cqh 0.5cqh 0 rgba(0, 0, 0, 0.5));
}

.weather-now-main {
    display: grid;
    grid-template-columns: auto auto;
    align-items: center;
    column-gap: 3cqw;
}

.weather-now-temp {
    font: 900 22cqh/1 sans-serif;
}

.weather-now-sky {
    grid-column: 1 / -1;
    font: bold 5cqh/1.2 sans-serif;
    text-align: center;
}

.weather-facts {
    display: grid;
    grid-template-columns: auto auto;
    gap: 1.2cqh 3cqw;
    font: bold 4.6cqh/1.1 sans-serif;
}

.weather-fact-label {
    color: #9fc3ff;
}

.weather-period,
.weather-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2cqh;
    flex: 1;
    text-align: center;
    padding: 0 1cqw;
}

.weather-period + .weather-period,
.weather-day + .weather-day {
    border-left: 0.3cqw solid rgba(255, 255, 255, 0.25);
}

.weather-period-name {
    font: 900 4.6cqh/1.1 sans-serif;
    color: #ffd23f;
    text-transform: uppercase;
}

.weather-period-temp {
    font: 900 6cqh/1 sans-serif;
}

.weather-period-temp.low {
    color: #9fc3ff;
}

.weather-period-sky {
    font: bold 3.6cqh/1.2 sans-serif;
}

.weather-period-precip {
    font: bold 3.2cqh/1 sans-serif;
    color: #9fc3ff;
}

.weather-day-temps {
    font: 900 5cqh/1 sans-serif;
}

/* Latest Observations and the Travel Forecast: a city a row */
.weather-table {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    column-gap: 3cqw;
    row-gap: 0.6cqh;
    align-items: center;
    width: 100%;
    font: bold 4.2cqh/1.15 sans-serif;
}

.weather-travel-table {
    grid-template-columns: auto 1fr auto auto;
    font-size: 3.8cqh;
}

.weather-table-head.num {
    text-align: right;
}

.weather-table-head {
    color: #ffd23f;
    font-size: 3.4cqh;
    text-transform: uppercase;
}

.weather-table-city {
    white-space: nowrap;
}

.weather-table-temp {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.weather-table-temp.low {
    color: #9fc3ff;
}

.weather-table-sky,
.weather-table-wind {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.weather-table-sky {
    display: flex;
    align-items: center;
    gap: 1cqw;
}

.weather-table-icon {
    height: 4.6cqh;
}

/* The Regional and National Forecast: the server's map, the cities over it */
.weather-map {
    position: relative;
    height: 100%;
    aspect-ratio: 16 / 9;
    max-width: 100%;
}

.weather-map-land {
    width: 100%;
    height: 100%;
    display: block;
}

.weather-map-city {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-shadow: 0.3cqh 0.3cqh 0 #000;
    white-space: nowrap;
}

.weather-map-reading {
    display: flex;
    align-items: center;
    gap: 0.4cqw;
}

.weather-map-icon {
    height: 6cqh;
    filter: drop-shadow(0.3cqh 0.3cqh 0 rgba(0, 0, 0, 0.6));
}

.weather-map-temp {
    font: 900 5cqh/1 sans-serif;
    color: #ffd23f;
}

.weather-map-name {
    font: bold 2.6cqh/1.1 sans-serif;
}

.weather-radar {
    height: 100%;
    max-width: 100%;
    object-fit: contain;
    border: 0.5cqh solid #fff;
}

.weather-error {
    font: bold 5cqh/1.3 sans-serif;
    text-align: center;
}

.weather-foot {
    height: 7cqh;
    display: flex;
    align-items: center;
    padding: 0 4cqw;
    font: bold 3cqh/1 sans-serif;
    background: rgba(0, 0, 0, 0.35);
    overflow: hidden;
    white-space: nowrap;
}

.weather-credit {
    padding: 0.6cqh 4cqw;
    font: 2.6cqh/1.2 sans-serif;
    color: #c9dcff;
    text-align: right;
}

.weather-alerts {
    background: #b00020;
    padding: 0;
}

.weather-ticker {
    display: inline-block;
    padding-left: 100%;
    font: bold 4cqh/1 sans-serif;
    animation: weather-ticker linear infinite;
}

@keyframes weather-ticker {
    from { transform: translateX(0); }
    to { transform: translateX(-100%); }
}

.guide-info {
    display: flex;
    gap: 16px;
    min-width: 0;
    max-height: 48vh;
    overflow-y: auto;
}

.guide-info-poster {
    width: 120px;
    height: 180px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.guide-info-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.guide-info-title {
    margin: 0;
    color: var(--heading-color, #667eea);
    font-size: 22px;
}

.guide-info-episode {
    font-weight: bold;
}

.guide-info-when,
.guide-info-facts {
    color: var(--muted-text);
    font-size: 14px;
}

.guide-info-overview {
    margin: 4px 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 6;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.guide-info-text .btn {
    align-self: flex-start;
}

.guide-grid {
    position: relative;
    flex: 1;
    min-height: 120px;
    overflow: auto; /* down the channels, and across the hours to the end of the plan */
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.guide-grid-row {
    display: flex;
    min-width: max-content;
    min-height: 60px;
    border-top: 1px solid var(--border-color);
}

.guide-grid-head {
    position: sticky; /* the times stay over the channels as they scroll */
    top: 0;
    z-index: 5; /* over the channels' names, which stay as the hours scroll */
    min-height: 34px;
    border-top: none;
    background: var(--panel-bg);
    font-weight: bold;
}

.guide-channel {
    width: 230px;
    flex-shrink: 0;
    position: sticky; /* the channels stay as the hours scroll */
    left: 0;
    z-index: 4;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    background: var(--panel-bg);
    border: none;
    border-right: 1px solid var(--border-color);
    color: var(--text-color);
    text-align: left;
    font: inherit;
    cursor: pointer;
}

.guide-corner {
    cursor: default;
    font-size: 13px;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 0;
}

.guide-corner-day {
    font-weight: normal;
}

.guide-corner-time {
    font-size: 15px;
    font-weight: 900;
}

.guide-grid-row.tuned .guide-channel {
    box-shadow: inset 4px 0 0 var(--primary-color);
}

.guide-badge {
    min-width: 34px;
    padding: 3px 6px;
    border-radius: 4px;
    background: var(--button-bg);
    color: #fff;
    font-weight: 900;
    text-align: center;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
}

.guide-channel-logo {
    width: 104px;
    height: 52px;
    flex-shrink: 0;
    object-fit: contain;
}

.guide-channel-words {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.guide-channel-number {
    font-weight: 900;
    font-size: 18px;
    line-height: 1.1;
}

.guide-channel-name {
    /* up to two lines, so names aren't cut short */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
    line-height: 1.2;
    font-weight: bold;
}

.guide-programs {
    position: relative;
    flex: none;
    width: var(--programs-width, 1400px);
}

.guide-time {
    position: absolute;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: flex-end; /* on the row's bottom, beside the time now */
    padding-left: 8px;
    padding-bottom: 6px;
    font-size: 13px;
    border-left: 1px solid var(--border-color);
}

/* the quarter past and to the hour: a short tick under the half hours' times */
.guide-quarter {
    position: absolute;
    bottom: 0;
    height: 8px;
    border-left: 1px solid var(--border-color);
}

.guide-program {
    position: absolute;
    top: 3px;
    bottom: 3px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding: 4px 8px;
    overflow: hidden;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-color);
    text-align: left;
    font: inherit;
    cursor: pointer;
}

.guide-program.continues {
    border-left-style: dashed;
}

/* ◀ and ▶ at the shown part's edges (placeGuideTitles): the program started before what's shown, or ends after */
.guide-program.starts-before::before,
.guide-program.ends-after::after {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
}

.guide-program.starts-before::before {
    content: '◀';
    left: calc(var(--shift-start, 0px) + 6px);
}

.guide-program.ends-after::after {
    content: '▶';
    right: calc(var(--shift-end, 0px) + 6px);
}

.guide-program.sliver > *,
.guide-program.sliver::before,
.guide-program.sliver::after {
    visibility: hidden;
}

.guide-program.on-now {
    background: var(--surface-hover);
}

.guide-program:hover,
.guide-program:focus-visible {
    background: var(--button-focus);
    color: var(--button-focus-text);
    outline: none;
    z-index: 1;
}

.guide-program-title {
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* a program starting at a quarter hour: its start, above the title */
.guide-program.quarter {
    gap: 1px;
    padding-top: 2px;
    padding-bottom: 2px;
}

.guide-program-start {
    font-size: 11px;
    line-height: 12px;
    white-space: nowrap;
    opacity: 0.85;
}

.guide-program-episode {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.85;
}

.guide-now-line {
    position: absolute;
    top: 0; /* its height is the grid's whole height, set by placeTimeLine */
    width: 2px;
    background: var(--primary-color);
    pointer-events: none;
    z-index: 2;
}

/* The voice-over tester (Settings › Server › Guide) */
.voice-tester {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
    max-width: 760px;
}

.voice-tester h4,
.voice-tester h5 {
    margin: 8px 0 0;
}

.voice-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.voice-row .settings-input {
    flex: 1;
    min-width: 160px;
}

.voice-line {
    width: 100%;
    font: inherit;
}

.voice-out audio {
    width: 100%;
}

.voice-phonemes,
.voice-fix,
.voice-report-line {
    font-family: monospace;
    font-size: 13px;
    overflow-wrap: anywhere;
}

.voice-report {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
}

/* The Guide tab (Settings): typed channels and the libraries' Guide switches */
.typed-channels {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
}

.typed-channel {
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
    border-radius: 8px;
    padding: 12px;
}

.typed-channel-head {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.typed-channel-head .btn {
    margin-left: auto;
}

.typed-channel-libraries {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 6px;
}

.typed-channel p {
    margin: 4px 0 0;
}

.guide-libraries-table {
    border-collapse: collapse;
    width: 100%;
}

.guide-libraries-table th,
.guide-libraries-table td {
    text-align: left;
    padding: 6px 10px 6px 0;
    vertical-align: middle;
}

.guide-libraries-table tr + tr td {
    border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
}

/* The home screen: a TV Shows or Movies library's kind on its folder (over the folder's front, or in a
   corner badge over its picture), the Guide's tile after them, and the other libraries from the next row. */
.folder-thumbnail {
    position: relative;
}

.library-kind {
    position: absolute;
    left: 50%;
    top: 57%;
    height: 34%;
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
    color: #3a2405;
    pointer-events: none;
}

.library-kind svg {
    width: 100%;
    height: 100%;
    display: block;
}

.library-kind-corner {
    left: auto;
    top: auto;
    right: 10%;
    bottom: 10%;
    height: 26%;
    transform: none;
    padding: 4%;
    border-radius: 50%;
    background: #f0b429;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.grid-row-end {
    grid-column: 1 / -1;
    height: 0;
    margin-top: -20px; /* the grid's gap above it is enough */
}

.guide-tile .folder-thumbnail .placeholder-icon {
    height: 72%;
}
