        /* Inter Variable — the exact font Overseerr/seerr uses (self-hosted, offline). */
        @font-face {
            font-family: 'Inter Variable';
            font-style: normal;
            font-display: swap;
            font-weight: 100 900;
            src: url('/fonts/inter-latin-wght-normal.woff2') format('woff2-variations');
            unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
        }
        @font-face {
            font-family: 'Inter Variable';
            font-style: normal;
            font-display: swap;
            font-weight: 100 900;
            src: url('/fonts/inter-latin-ext-wght-normal.woff2') format('woff2-variations');
            unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
        }

        /* ============================================================
           CRUNCHARR DESIGN TOKENS  (v2 — distinct themes, working glass,
           visible scrollbars). Every color/space/radius/shadow/motion/type
           value lives here so components never hardcode. Theme blocks below
           override only what differs. All token names are back-compat.
           ============================================================ */
        :root {
            /* --- Brand / accent (Crunchyroll orange) --- */
            --accent: #F47521;
            --accent-bright: #ff9145;
            --accent-orange: var(--accent);             /* back-compat alias */
            --accent-orange-bright: var(--accent-bright);
            --accent-soft: rgba(244, 117, 33, 0.15);
            --accent-softer: rgba(244, 117, 33, 0.08);
            --accent-glow: rgba(244, 117, 33, 0.40);
            --accent-grad: linear-gradient(135deg, var(--accent), var(--accent-bright));

            /* --- Surfaces (#0A0A0A–#1F1F23) — warm-neutral near-black --- */
            --bg-primary: #0a0a0c;
            --bg-secondary: #121216;
            --bg-tertiary: #1a1a20;
            --bg-card: #16161c;
            --bg-hover: #23232b;
            --surface-border: rgba(255, 255, 255, 0.07);
            --border-color: rgba(255, 255, 255, 0.09);
            --sidebar-bg: linear-gradient(180deg, #15151b, #0c0c10);

            /* --- Text (WCAG AA on near-black) --- */
            --text-primary: #f6f7f9;
            --text-secondary: #c0c4ce;
            --text-muted: #888e9a;

            /* --- Status + soft fills --- */
            --accent-blue: #4aa8ff;   --info-soft: rgba(74, 168, 255, 0.16);
            --accent-green: #36d399;  --success-soft: rgba(54, 211, 153, 0.16);
            --accent-red: #ff5a63;    --error-soft: rgba(255, 90, 99, 0.16);
            --accent-yellow: #ffb020; --warning-soft: rgba(255, 176, 32, 0.16);
            --premium-soft: var(--accent-soft);

            /* --- Glass (backdrop blur) --- */
            --glass-bg: rgba(20, 20, 26, 0.72);
            --glass-border: rgba(255, 255, 255, 0.11);
            --glass-blur: 16px;
            /* Ambient page bloom + card translucency (overridden per theme) */
            --bloom:
                radial-gradient(1200px 620px at 78% -8%, rgba(244, 117, 33, 0.12), transparent 60%),
                radial-gradient(1000px 720px at -10% 110%, rgba(86, 120, 255, 0.08), transparent 55%);
            --card-blur: 0px;

            /* --- Scrollbars (themed; visible against sidebar + content) --- */
            --scrollbar-thumb: rgba(255, 255, 255, 0.18);
            --scrollbar-thumb-hover: rgba(255, 255, 255, 0.32);
            --scrollbar-thumb-sidebar: rgba(255, 255, 255, 0.14);
            --scrollbar-thumb-sidebar-hover: var(--accent);

            /* --- Spacing scale (4px base) --- */
            --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
            --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px;

            /* --- Radius scale --- */
            --radius-xs: 6px; --radius-sm: 10px; --radius-md: 14px;
            --radius-lg: 18px; --radius-xl: 24px; --radius-full: 999px;
            --radius: var(--radius-md);                 /* back-compat */

            /* --- Shadow scale --- */
            --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.40);
            --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.45);
            --shadow-lg: 0 28px 64px rgba(0, 0, 0, 0.55);
            --shadow-xl: 0 40px 90px rgba(0, 0, 0, 0.6);
            --shadow-glow: 0 8px 30px rgba(244, 117, 33, 0.30);

            /* --- Typography scale --- */
            --font-sans: 'Inter Variable', ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
            --text-xs: 0.72rem; --text-sm: 0.85rem; --text-base: 0.95rem;
            --text-md: 1.05rem; --text-lg: 1.25rem; --text-xl: 1.6rem;
            --text-2xl: 2.1rem; --text-3xl: 2.6rem;
            --fw-medium: 500; --fw-semibold: 600; --fw-bold: 700; --fw-black: 800;

            /* --- Motion (200–350ms, ease-out, no bounce) --- */
            --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
            --dur-fast: 200ms; --dur-base: 250ms; --dur-slow: 350ms;
            --transition: var(--dur-base) var(--ease-out);  /* back-compat */

            /* --- Legacy CR aliases (still referenced by a few rules) --- */
            --cr-orange: var(--accent); --cr-orange-classic: var(--accent);
            --cr-gray-700: #2a2a2e; --cr-gray-600: #3a3a40; --cr-gray-300: #c9ccd4;

            --sidebar-width: 16rem; /* seerr sidebar = w-64 (256px) */
            --header-height: 64px;
        }

        /* ── System theme: follow OS preference. The JS applies "light" when the
              OS is in light mode; when OS is dark it leaves :root alone (= Dark).
              So System ≠ Dark is only visible when the OS is set to light. To make
              System feel meaningfully different from Dark even on dark-OS setups,
              it uses a slightly cooler, higher-contrast dark base. ── */
        [data-theme="system"] {
            --bg-primary: #08080a;
            --bg-secondary: #0f0f13;
            --bg-tertiary: #18181f;
            --sidebar-bg: linear-gradient(180deg, #131319, #0a0a0d);
            --bloom:
                radial-gradient(1200px 620px at 78% -8%, rgba(86, 120, 255, 0.10), transparent 60%),
                radial-gradient(1000px 720px at -10% 110%, rgba(244, 117, 33, 0.06), transparent 55%);
        }
        @media (prefers-color-scheme: light) {
            [data-theme="system"] {
                --bg-primary: #f4f5f7; --bg-secondary: #ffffff; --bg-tertiary: #eceef1;
                --bg-hover: #e6e9ee; --bg-card: #ffffff;
                --text-primary: #1b1f24; --text-secondary: #5c636e; --text-muted: #767d88;
                --accent: #d9600f; --accent-bright: #e8730f;
                --accent-soft: rgba(244,117,33,0.12); --accent-softer: rgba(244,117,33,0.06);
                --accent-glow: rgba(244,117,33,0.22);
                --accent-blue: #0277bd; --accent-green: #2e7d32;
                --accent-red: #c62828; --accent-yellow: #b7791f;
                --info-soft: rgba(2,119,189,0.12); --success-soft: rgba(46,125,50,0.12);
                --error-soft: rgba(198,40,40,0.12); --warning-soft: rgba(183,121,31,0.14);
                --border-color: #e3e6ea; --surface-border: #e7eaee;
                --glass-bg: rgba(255,255,255,0.78); --glass-border: rgba(16,24,40,0.08);
                --sidebar-bg: linear-gradient(180deg, #ffffff, #f7f8fa);
                --scrollbar-thumb: rgba(16,24,40,0.22); --scrollbar-thumb-hover: rgba(16,24,40,0.38);
                --scrollbar-thumb-sidebar: rgba(255,255,255,0.22); --scrollbar-thumb-sidebar-hover: var(--accent);
                --shadow-sm: 0 1px 2px rgba(16,24,40,0.06);
                --shadow-md: 0 8px 24px rgba(16,24,40,0.10);
                --shadow-lg: 0 20px 48px rgba(16,24,40,0.14);
                --bloom: none;
            }
        }

        /* ── Light: clean *arr-stack palette, high-contrast text, no bloom ── */
        [data-theme="light"] {
            --bg-primary: #f4f5f7;
            --bg-secondary: #ffffff;
            --bg-tertiary: #eceef1;
            --bg-hover: #e6e9ee;
            --bg-card: #ffffff;
            --text-primary: #1b1f24;
            --text-secondary: #5c636e;
            --text-muted: #767d88;
            --accent: #d9600f;
            --accent-bright: #e8730f;
            --accent-orange: var(--accent);
            --accent-orange-bright: var(--accent-bright);
            --accent-blue: #0277bd;
            --accent-green: #2e7d32;
            --accent-red: #c62828;
            --accent-yellow: #b7791f;
            --accent-soft: rgba(244, 117, 33, 0.12);
            --accent-softer: rgba(244, 117, 33, 0.06);
            --accent-glow: rgba(244, 117, 33, 0.22);
            --info-soft: rgba(2, 119, 189, 0.12);
            --success-soft: rgba(46, 125, 50, 0.12);
            --error-soft: rgba(198, 40, 40, 0.12);
            --warning-soft: rgba(183, 121, 31, 0.14);
            --premium-soft: var(--accent-soft);
            --border-color: #e3e6ea;
            --surface-border: #e7eaee;
            --glass-bg: rgba(255, 255, 255, 0.78);
            --glass-border: rgba(16, 24, 40, 0.08);
            --sidebar-bg: linear-gradient(180deg, #ffffff, #f7f8fa);
            --shadow-sm: 0 1px 2px rgba(16,24,40,0.06);
            --shadow-md: 0 8px 24px rgba(16,24,40,0.10);
            --shadow-lg: 0 20px 48px rgba(16,24,40,0.14);
            --shadow-glow: 0 8px 24px rgba(232, 93, 4, 0.20);
            --bloom: none;
            --card-blur: 0px;
            --scrollbar-thumb: rgba(16,24,40,0.22);
            --scrollbar-thumb-hover: rgba(16,24,40,0.38);
            --scrollbar-thumb-sidebar: rgba(255,255,255,0.30);
            --scrollbar-thumb-sidebar-hover: var(--accent);
        }

        /* ── AMOLED: pure-black surfaces for OLED + a faint accent vignette so
              it reads as intentional "cinematic black", not "flat darker dark".
              Bloom kept minimal (OLED battery savings). ── */
        [data-theme="amoled"] {
            --bg-primary: #000000;
            --bg-secondary: #000000;
            --bg-tertiary: #0c0c0d;
            --bg-card: #070708;
            --bg-hover: #161618;
            --surface-border: rgba(255, 255, 255, 0.08);
            --border-color: rgba(255, 255, 255, 0.11);
            --sidebar-bg: linear-gradient(180deg, #050505, #000000);
            --bloom:
                radial-gradient(900px 480px at 50% -10%, rgba(244, 117, 33, 0.06), transparent 65%);
            --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.6);
            --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.65);
            --shadow-lg: 0 28px 64px rgba(0, 0, 0, 0.75);
            --scrollbar-thumb: rgba(255, 255, 255, 0.16);
            --scrollbar-thumb-hover: rgba(255, 255, 255, 0.30);
            --scrollbar-thumb-sidebar: rgba(255, 255, 255, 0.12);
            --scrollbar-thumb-sidebar-hover: var(--accent);
        }

        /* ── Cinematic: the glassy theme. Glass actually works here — stronger
              ambient bloom behind translucent surfaces, visible backdrop-blur on
              cards/panels, layered glass on header + modal. ── */
        [data-theme="cinematic"] {
            --bg-primary: #07070b;
            --bg-secondary: rgba(20, 20, 28, 0.55);
            --bg-tertiary: rgba(32, 32, 42, 0.62);
            --bg-card: rgba(24, 24, 34, 0.46);
            --bg-hover: rgba(48, 48, 62, 0.55);
            --surface-border: rgba(255, 255, 255, 0.12);
            --border-color: rgba(255, 255, 255, 0.11);
            --glass-bg: rgba(22, 22, 32, 0.55);
            --glass-border: rgba(255, 255, 255, 0.14);
            --glass-blur: 18px;
            --card-blur: 18px;
            --sidebar-bg: linear-gradient(180deg, rgba(20,20,30,0.72), rgba(8,8,14,0.82));
            --bloom:
                radial-gradient(1300px 720px at 82% -12%, rgba(244, 117, 33, 0.22), transparent 58%),
                radial-gradient(1100px 820px at -14% 116%, rgba(126, 92, 231, 0.20), transparent 58%),
                radial-gradient(700px 500px at 50% 50%, rgba(20, 20, 35, 0.30), transparent 70%);
            --shadow-glow: 0 8px 30px rgba(244, 117, 33, 0.35);
            --scrollbar-thumb: rgba(255, 255, 255, 0.20);
            --scrollbar-thumb-hover: rgba(244, 117, 33, 0.55);
            --scrollbar-thumb-sidebar: rgba(255, 255, 255, 0.16);
            --scrollbar-thumb-sidebar-hover: var(--accent);
        }
        /* Cinematic: header + content use translucent surfaces so the bloom blur
           is actually visible behind them. */
        [data-theme="cinematic"] .header {
            background: rgba(14, 14, 22, 0.55);
            backdrop-filter: blur(18px);
            -webkit-backdrop-filter: blur(18px);
        }
        [data-theme="cinematic"] .content { background: transparent; }

        /* ── Seerr (Nebula): indigo→purple aurora on a mid-slate dashboard.
              Distinct from Dark: lighter slate surfaces, vivid purple aurora,
              lavender-tinted text highlights, signature gradient active nav. ── */
        [data-theme="nebula"] {
            --accent: #6366f1;            /* indigo-500 */
            --accent-bright: #a855f7;     /* purple-500 */
            --accent-orange: var(--accent);
            --accent-orange-bright: var(--accent-bright);
            --accent-soft: rgba(99, 102, 241, 0.20);
            --accent-softer: rgba(168, 85, 247, 0.12);
            --accent-glow: rgba(99, 102, 241, 0.45);
            --accent-grad: linear-gradient(135deg, #6366f1, #a855f7);

            --bg-primary: #1a1d29;        /* slate-900-ish, lifted from near-black */
            --bg-secondary: #232736;      /* slate-800 */
            --bg-tertiary: #2c3142;
            --bg-card: #232736;
            --bg-hover: #353a4d;
            --surface-border: rgba(255, 255, 255, 0.08);
            --border-color: rgba(255, 255, 255, 0.11);
            --sidebar-bg: linear-gradient(180deg, #262b3c, #181b27);

            --text-primary: #f5f6ff;
            --text-secondary: #c7cbdf;
            --text-muted: #8b91ad;

            --accent-blue: #818cf8;   --info-soft: rgba(129, 140, 248, 0.18);
            --accent-green: #34d399;  --success-soft: rgba(52, 211, 153, 0.18);
            --accent-red: #fb7185;    --error-soft: rgba(251, 113, 133, 0.18);
            --accent-yellow: #fbbf24; --warning-soft: rgba(251, 191, 36, 0.18);
            --premium-soft: var(--accent-soft);

            --glass-bg: rgba(35, 39, 54, 0.82);
            --glass-border: rgba(168, 85, 247, 0.18);
            --glass-blur: 14px;
            --card-blur: 0px;

            --bloom:
                radial-gradient(1200px 640px at 84% -10%, rgba(168, 85, 247, 0.22), transparent 58%),
                radial-gradient(1100px 760px at -12% 116%, rgba(99, 102, 241, 0.20), transparent 58%);
            --shadow-glow: 0 8px 30px rgba(99, 102, 241, 0.40);
            --scrollbar-thumb: rgba(199, 203, 223, 0.22);
            --scrollbar-thumb-hover: rgba(168, 85, 247, 0.65);
            --scrollbar-thumb-sidebar: rgba(199, 203, 223, 0.18);
            --scrollbar-thumb-sidebar-hover: var(--accent-bright);
        }
        /* Seerr signature: active nav uses the full vivid indigo→purple gradient. */
        [data-theme="nebula"] .nav-item.active {
            background: var(--accent-grad);
            color: #fff;
            box-shadow: 0 6px 18px rgba(99, 102, 241, 0.32);
        }
        [data-theme="nebula"] .nav-item.active .nav-icon { color: #fff; }
        [data-theme="nebula"] .nav-item.active::before { background: #fff; }

        /* ── Seerr: exact Overseerr palette — near-black navy surfaces + indigo→purple accent.
              Distinct from nebula (which is a lifted slate). Layout is shared/app-wide; only the
              colour tokens differ here. ── */
        [data-theme="seerr"] {
            /* Exact Overseerr palette, lifted from the saved Series-Seerr CSS: Tailwind
               gray-900/800/700 surfaces + indigo-500/indigo-600 -> purple accent. */
            --accent: #6366f1;            /* indigo-500 */
            --accent-bright: #a855f7;     /* purple-500 */
            --accent-orange: var(--accent);
            --accent-orange-bright: var(--accent-bright);
            --accent-soft: rgba(99, 102, 241, 0.18);
            --accent-softer: rgba(168, 85, 247, 0.12);
            --accent-glow: rgba(99, 102, 241, 0.40);
            --accent-grad: linear-gradient(to bottom right, #4f46e5, #9333ea);  /* seerr from-indigo-600 to-purple-600 (bg-gradient-to-br) */

            --bg-primary: #111827;        /* gray-900 content */
            --bg-secondary: #1f2937;      /* gray-800 cards / header */
            --bg-tertiary: #374151;       /* gray-700 */
            --bg-card: #1f2937;
            --bg-hover: #374151;
            --surface-border: rgba(255, 255, 255, 0.06);
            --border-color: #374151;      /* gray-700 */
            --sidebar-bg: linear-gradient(#1f2937 0%, #131928 100%);  /* exact Overseerr .sidebar */

            --text-primary: #f9fafb;      /* gray-50 */
            --text-secondary: #d1d5db;    /* gray-300 */
            --text-muted: #9ca3af;        /* gray-400 */

            --accent-blue: #3b82f6;   --info-soft: rgba(59, 130, 246, 0.18);
            --accent-green: #22c55e;  --success-soft: rgba(34, 197, 94, 0.18);
            --accent-red: #ef4444;    --error-soft: rgba(239, 68, 68, 0.18);
            --accent-yellow: #eab308; --warning-soft: rgba(234, 179, 8, 0.18);
            --premium-soft: var(--accent-soft);

            --glass-bg: rgba(31, 41, 55, 0.82);
            --glass-border: rgba(168, 85, 247, 0.18);
            --glass-blur: 14px;
            --card-blur: 0px;

            --bloom:
                radial-gradient(1200px 640px at 84% -10%, rgba(168, 85, 247, 0.16), transparent 58%),
                radial-gradient(1100px 760px at -12% 116%, rgba(99, 102, 241, 0.16), transparent 58%);
            --shadow-glow: 0 8px 30px rgba(99, 102, 241, 0.40);
            --scrollbar-thumb: rgba(209, 213, 219, 0.22);
            --scrollbar-thumb-hover: rgba(168, 85, 247, 0.65);
            --scrollbar-thumb-sidebar: rgba(209, 213, 219, 0.16);
            --scrollbar-thumb-sidebar-hover: var(--accent-bright);
        }
        /* Seerr signature: active nav uses the full indigo→purple gradient pill. */
        [data-theme="seerr"] .nav-item.active {
            background: var(--accent-grad);
            color: #fff;
            box-shadow: 0 6px 18px rgba(99, 102, 241, 0.32);
        }
        [data-theme="seerr"] .nav-item.active .nav-icon { color: #fff; }
        [data-theme="seerr"] .nav-item.active::before { background: #fff; }

        /* ── Sonarr: signature cyan top bar, dark slate sidebar, light content.
              Mixed theme: content tokens are light; sidebar + header re-skinned. ── */
        [data-theme="sonarr"] {
            --accent: #35c5f0;
            --accent-bright: #1aa9da;
            --accent-orange: var(--accent);
            --accent-orange-bright: var(--accent-bright);
            --accent-soft: rgba(53, 197, 240, 0.14);
            --accent-softer: rgba(53, 197, 240, 0.07);
            --accent-glow: rgba(53, 197, 240, 0.28);

            --bg-primary: #f5f6f8;
            --bg-secondary: #ffffff;
            --bg-tertiary: #eceef1;
            --bg-hover: #e6e9ee;
            --bg-card: #ffffff;
            --text-primary: #1b1f24;
            --text-secondary: #5c636e;
            --text-muted: #767d88;

            --accent-blue: #1899c4;   --info-soft: rgba(24, 153, 196, 0.14);
            --accent-green: #27c24c;  --success-soft: rgba(39, 194, 76, 0.14);
            --accent-red: #e6312f;    --error-soft: rgba(230, 49, 47, 0.14);
            --accent-yellow: #e0a800; --warning-soft: rgba(224, 168, 0, 0.16);
            --premium-soft: var(--accent-soft);

            --border-color: #e3e6ea;
            --surface-border: #e7eaee;
            --glass-bg: rgba(255, 255, 255, 0.80);
            --glass-border: rgba(16, 24, 40, 0.08);
            --sidebar-bg: linear-gradient(180deg, #4a515f, #3f4654);

            --shadow-sm: 0 1px 2px rgba(16,24,40,0.06);
            --shadow-md: 0 8px 24px rgba(16,24,40,0.10);
            --shadow-lg: 0 20px 48px rgba(16,24,40,0.14);
            --shadow-glow: 0 8px 24px rgba(53, 197, 240, 0.22);
            --bloom: none;
            --card-blur: 0px;
            --scrollbar-thumb: rgba(16,24,40,0.22);
            --scrollbar-thumb-hover: rgba(53,197,240,0.55);
            --scrollbar-thumb-sidebar: rgba(255,255,255,0.18);
            --scrollbar-thumb-sidebar-hover: #ffffff;
        }
        /* Dark sidebar needs light text — re-scope tokens just for it. */
        [data-theme="sonarr"] .sidebar {
            color: #e7eaf0;
            --text-primary: #ffffff;
            --text-secondary: #c3c9d4;
            --text-muted: #99a1ae;
            --bg-hover: rgba(255, 255, 255, 0.08);
            --bg-tertiary: rgba(255, 255, 255, 0.08);
            --border-color: rgba(255, 255, 255, 0.14);
            --surface-border: rgba(255, 255, 255, 0.10);
        }
        [data-theme="sonarr"] .nav-item.active { background: var(--accent); color: #06303d; }
        [data-theme="sonarr"] .nav-item.active .nav-icon { color: #06303d; }
        [data-theme="sonarr"] .nav-item.active::before { background: #06303d; }
        [data-theme="sonarr"] .header {
            background: var(--accent);
            border-bottom: 1px solid rgba(0, 0, 0, 0.12);
        }
        [data-theme="sonarr"] .header-search {
            background: rgba(255, 255, 255, 0.18);
            border-color: rgba(255, 255, 255, 0.32);
        }
        [data-theme="sonarr"] .header-search input { color: #ffffff; }
        [data-theme="sonarr"] .header-search input::placeholder { color: rgba(255, 255, 255, 0.82); }

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

        body {
            font-family: var(--font-sans);
            color: var(--text-primary);
            line-height: 1.5;
            overflow: hidden;
            -webkit-tap-highlight-color: transparent;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
            /* Ambient bloom is theme-controlled via the --bloom token */
            background-color: var(--bg-primary);
            background-image: var(--bloom);
            background-attachment: fixed;
        }

        /* Entrance + interaction animations */
        @keyframes fadeSlideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
        @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
        @keyframes popIn { from { opacity: 0; transform: translateY(-6px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

        .app-container { display: flex; height: 100vh; }

        /* Sidebar — themed gradient surface with a subtle top accent glow */
        .sidebar {
            width: var(--sidebar-width);
            background: var(--sidebar-bg);
            border-right: 1px solid var(--border-color);
            display: flex;
            flex-direction: column;
            overflow-y: auto;
            position: relative;
            z-index: 5;
        }
        /* No sidebar top-glow — seerr's sidebar is flat. */
        .sidebar::before { content: none; }
        .sidebar > * { position: relative; z-index: 1; }

        /* seerr brand block: a tall (h-24 = 96px) logo area, px-4 py-2. */
        .sidebar-header {
            padding: 8px 16px;
            min-height: 96px;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 14px;
        }

        .sidebar-logo {
            width: 60px;
            height: 60px;
            border-radius: var(--radius-sm);
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            overflow: hidden;
        }
        .sidebar-logo-img {
            width: 60px;
            height: 60px;
            border-radius: var(--radius-sm);
            object-fit: contain;
            flex-shrink: 0;
            filter: drop-shadow(0 2px 6px var(--accent-glow));
        }

        .sidebar-title {
            font-size: 2em;
            font-weight: 800;
            letter-spacing: -0.01em;
            background: var(--accent-grad);
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent;
            color: var(--accent);
        }

        .sidebar-nav { flex: 1; padding: 10px 0; }

        /* seerr SidebarItem: px-2 py-2 text-lg/leading-6 font-medium rounded-md, white text. */
        .nav-item {
            display: flex;
            align-items: center;
            margin: 2px 12px;
            padding: 8px 12px;
            cursor: pointer;
            transition: background 0.15s, color 0.15s;
            gap: 12px;
            color: var(--text-primary);
            text-decoration: none;
            border-radius: 6px;
            font-weight: 500;
            font-size: 1.125rem;
            line-height: 1.5rem;
        }

        .nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
        .nav-item.active { background: var(--accent-soft); color: var(--accent-orange); }
        .nav-item.active .nav-icon { color: var(--accent-orange); }

        /* "More" is a mobile-only bottom-bar affordance; hidden on the desktop sidebar. */
        .nav-more { display: none; }

        /* Mobile "More" bottom sheet (holds the secondary nav items). */
        .more-sheet-overlay {
            display: none;
            position: fixed;
            inset: 0;
            z-index: 1100;
            background: rgba(0,0,0,0.5);
            align-items: flex-end;
        }
        .more-sheet-overlay.open { display: flex; }
        .more-sheet {
            width: 100%;
            background: var(--bg-secondary);
            border-top-left-radius: var(--radius-lg, 16px);
            border-top-right-radius: var(--radius-lg, 16px);
            border-top: 1px solid var(--border-color);
            padding: 8px 12px calc(12px + env(safe-area-inset-bottom, 0px));
            box-shadow: var(--shadow-lg, 0 -8px 24px rgba(0,0,0,0.4));
            animation: fadeSlideUp 220ms var(--ease-out, ease);
        }
        .more-sheet-handle {
            width: 40px; height: 4px; border-radius: 999px;
            background: var(--border-color);
            margin: 6px auto 12px;
        }
        .more-sheet-item {
            display: flex; align-items: center; gap: 14px;
            padding: 14px 12px;
            color: var(--text-primary);
            text-decoration: none;
            border-radius: var(--radius, 10px);
            font-size: 1rem;
        }
        .more-sheet-item:active { background: var(--bg-hover); }
        .more-sheet-item .nav-icon { width: 22px; color: var(--text-secondary); }

        .nav-icon { width: 24px; text-align: center; display: flex; align-items: center; justify-content: center; }
        .nav-icon svg { width: 24px; height: 24px; }

        .sidebar-footer {
            padding: 14px 16px;
            font-size: 0.8em;
            color: var(--text-muted);
            display: flex;
            align-items: center;
            gap: 10px;
        }
        /* Rounded version/status pill (Seerr-style "Stable 3.3.0" badge). */
        .version-pill {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            padding: 6px 12px;
            background: var(--bg-tertiary);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-full);
            font-size: 0.72rem;
            font-weight: 600;
            letter-spacing: 0.02em;
            color: var(--text-secondary);
            cursor: default;
        }
        .version-dot {
            width: 7px;
            height: 7px;
            border-radius: 50%;
            flex: 0 0 auto;
            background: var(--accent-green);
            box-shadow: 0 0 6px var(--accent-green);
        }
        /* GitHub repo link next to the version pill in the sidebar footer. */
        .github-link {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 30px;
            height: 30px;
            flex: 0 0 auto;
            border-radius: var(--radius-full);
            color: var(--text-muted);
            background: var(--bg-tertiary);
            border: 1px solid var(--border-color);
            transition: color var(--transition), border-color var(--transition), transform var(--transition);
        }
        .github-link:hover { color: var(--text-primary); border-color: var(--accent-orange); transform: translateY(-1px); }
        .github-link svg { width: 18px; height: 18px; display: block; }

        /* Top-right profile chip */
        .topbar-profile {
            position: fixed;
            /* Vertically centered on the header band so it lines up with the search bar. */
            top: calc(var(--header-height) / 2);
            transform: translateY(-50%);
            right: 24px;
            /* Above the header bar (z-index:100) so it isn't covered, but below modals
               (1000) and toasts (2000). */
            z-index: 150;
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 6px 14px 6px 6px;
            background: var(--glass-bg);
            backdrop-filter: blur(var(--glass-blur));
            -webkit-backdrop-filter: blur(var(--glass-blur));
            border: 1px solid var(--glass-border);
            border-radius: var(--radius-full);
            cursor: pointer;
            box-shadow: var(--shadow-sm);
            transition: transform var(--transition), border-color var(--transition);
        }
        .topbar-profile:hover { transform: translateY(calc(-50% - 1px)); border-color: var(--accent-orange); }
        .topbar-profile-avatar {
            width: 30px; height: 30px; border-radius: 50%;
            overflow: hidden; flex-shrink: 0;
            display: flex; align-items: center; justify-content: center;
            background: var(--bg-tertiary); color: var(--text-secondary); font-size: 16px;
        }
        .topbar-profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
        .topbar-profile-name { font-size: 0.9em; font-weight: 600; color: var(--text-primary); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .topbar-profile.hidden { display: none; }
        @media (max-width: 768px) { .topbar-profile { right: 10px; } .topbar-profile-name { display: none; } }

        .nav-section-title {
            padding: 8px 20px;
            font-size: 0.7em;
            text-transform: uppercase;
            letter-spacing: 1px;
            color: var(--text-muted);
        }

        /* Main Content */
        .main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

        /* Header */
        .header {
            height: var(--header-height);
            background: var(--bg-secondary);
            border-bottom: 1px solid var(--border-color);
            display: flex;
            align-items: center;
            padding: 0 25px;
            justify-content: space-between;
            /* Sit above .content (which makes its own stacking context via fadeSlideUp),
               so the search dropdown always renders in the foreground. */
            position: relative;
            z-index: 100;
        }

        .header-search {
            display: flex;
            align-items: center;
            background: var(--bg-primary);
            border: 1px solid var(--border-color);
            border-radius: 6px;
            padding: 8px 15px;
            width: 400px;
            gap: 10px;
        }

        .header-search input {
            background: transparent;
            border: none;
            color: var(--text-primary);
            outline: none;
            width: 100%;
            font-size: 0.95em;
        }

        .header-search input::placeholder { color: var(--text-muted); }

        /* Full-width global search bar in the top header; leaves room on the right for the
           fixed profile chip so they don't overlap. */
        .global-search { flex: 1; width: auto; position: relative; margin-right: 200px; }
        @media (max-width: 768px) { .global-search { margin-right: 52px; } }

        .header-actions { display: flex; gap: 15px; align-items: center; }

        .header-btn {
            background: var(--bg-tertiary);
            border: 1px solid var(--border-color);
            color: var(--text-primary);
            padding: 8px 16px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.9em;
            transition: all 0.2s;
        }

        .header-btn:hover { background: var(--bg-hover); }
        .header-btn.primary { background: var(--accent-orange); color: #000; border: none; font-weight: 600; }
        .header-btn.primary:hover { background: var(--accent-bright); }
        .header-btn:disabled { opacity: 0.5; cursor: not-allowed; }

        /* Content Area */
        .content { flex: 1; overflow-y: auto; padding: 32px 36px; animation: fadeSlideUp 0.45s var(--transition); }

        /* seerr page heading: text-3xl (1.875rem / 2.25rem), bold. */
        .page-title { font-size: 1.875rem; line-height: 2.25rem; font-weight: 700; letter-spacing: -0.01em; margin-bottom: var(--space-1); color: var(--accent); }
        .page-subtitle { color: var(--text-secondary); font-size: var(--text-base); margin-bottom: var(--space-6); }

        /* Cards */
        .card {
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 8px;
            padding: 20px;
            margin-bottom: 20px;
        }

        .card-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
        }

        .card-title { font-size: 1.1em; font-weight: 600; }

        /* Toggle Switch */
        .toggle-switch {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            cursor: pointer;
            font-size: 0.9em;
            color: var(--text-secondary);
        }

        .toggle-switch input { display: none; }

        .toggle-slider {
            width: 36px;
            height: 20px;
            background: var(--bg-tertiary);
            border-radius: 10px;
            position: relative;
            transition: background 0.2s;
            border: 1px solid var(--border-color);
        }

        .toggle-slider::after {
            content: '';
            position: absolute;
            width: 16px;
            height: 16px;
            background: var(--text-secondary);
            border-radius: 50%;
            top: 1px;
            left: 1px;
            transition: all 0.2s;
        }

        .toggle-switch input:checked + .toggle-slider { background: var(--accent-orange); border-color: var(--accent-orange); }
        .toggle-switch input:checked + .toggle-slider::after { left: 17px; background: #fff; }

        /* Buttons */
        .btn-icon {
            background: transparent;
            border: 1px solid var(--border-color);
            color: var(--text-secondary);
            padding: 6px 10px;
            border-radius: 4px;
            cursor: pointer;
            font-size: 0.9em;
            transition: all 0.2s;
            display: inline-flex;
            align-items: center;
            gap: 4px;
        }

        .btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }
        .btn-icon.danger:hover { background: var(--error-soft); color: var(--accent-red); border-color: var(--accent-red); }
        .btn-icon.success:hover { background: var(--success-soft); color: var(--accent-green); border-color: var(--accent-green); }
        .header-btn.danger { color: var(--accent-red); }
        .header-btn.danger:hover { background: var(--error-soft); border-color: var(--accent-red); }

        /* Progress Bars */
        .progress-container {
            width: 100%;
            height: 5px;
            background: var(--bg-primary);
            border-radius: 3px;
            overflow: hidden;
        }

        .progress-bar {
            height: 100%;
            background: var(--accent-orange);
            border-radius: 3px;
            transition: width 0.3s ease;
        }

        /* Status Badges */
        .badge {
            display: inline-flex;
            align-items: center;
            padding: 4px 10px;
            border-radius: 4px;
            font-size: 0.85em;
            font-weight: 600;
            gap: 5px;
        }

        .badge-queued { background: var(--info-soft); color: var(--accent-blue); }
        .badge-downloading { background: var(--accent-soft); color: var(--accent-orange); }
        .badge-done { background: var(--success-soft); color: var(--accent-green); }
        .badge-error { background: var(--error-soft); color: var(--accent-red); }
        .badge-retry { background: var(--warning-soft); color: var(--accent-yellow); }
        .badge-premium { background: var(--accent-soft); color: var(--accent-orange); }

        /* Download Item */
        .download-item {
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 8px;
            padding: 15px;
            margin-bottom: 10px;
            display: flex;
            gap: 15px;
        }

        .download-thumb {
            width: 208px;
            height: 117px;
            background: var(--bg-tertiary);
            border-radius: 4px;
            flex-shrink: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--text-muted);
            overflow: hidden;
        }

        .download-thumb img { width: 100%; height: 100%; object-fit: cover; }

        .download-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }

        .download-header {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            margin-bottom: 5px;
        }

        .download-title {
            font-weight: bold;
            font-size: 1.1em;
            margin-bottom: 4px;
            word-break: break-word;
        }

        .download-title.highlight { color: var(--accent-orange); }

        .download-info {
            font-size: 0.9em;
            color: var(--text-secondary);
            margin-bottom: 8px;
            word-break: break-word;
        }

        .download-actions {
            display: flex;
            gap: 5px;
        }

        .download-footer {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-top: auto;
            font-size: 0.85em;
            color: var(--text-secondary);
        }

        /* Search Popup */
        .search-popup {
            position: absolute;
            top: 100%;
            left: 0;
            right: 0;
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 8px;
            margin-top: 5px;
            max-height: 400px;
            overflow-y: auto;
            z-index: 1000;
            box-shadow: 0 4px 12px rgba(0,0,0,0.4);
        }

        .search-result-item {
            display: flex;
            gap: 15px;
            padding: 12px;
            cursor: pointer;
            border-bottom: 1px solid var(--border-color);
            transition: background 0.2s;
        }

        .search-result-item:hover { background: var(--bg-hover); }

        .search-result-poster {
            width: 120px;
            height: 180px;
            background: var(--bg-tertiary);
            border-radius: 4px;
            flex-shrink: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--text-muted);
            overflow: hidden;
        }

        .search-result-poster img { width: 100%; height: 100%; object-fit: cover; }

        .search-result-info { flex: 1; min-width: 0; }
        .search-result-title { font-size: 1.3em; font-weight: 600; margin-bottom: 8px; }
        .search-result-desc { font-size: 0.9em; color: var(--text-secondary); line-height: 1.4; }

        /* Episode Item */
        .episode-item {
            display: flex;
            gap: 12px;
            padding: 10px;
            border: 1px solid var(--border-color);
            border-radius: 6px;
            margin-bottom: 8px;
            background: var(--bg-secondary);
            cursor: pointer;
            transition: background 0.2s;
        }

        .episode-item:hover { background: var(--bg-hover); }
        .episode-item.selected { border-color: var(--accent-orange); }

        .episode-thumb {
            width: 208px;
            height: 117px;
            background: var(--bg-tertiary);
            border-radius: 4px;
            flex-shrink: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--text-muted);
            overflow: hidden;
        }

        .episode-thumb img { width: 100%; height: 100%; object-fit: cover; }

        .episode-content { flex: 1; min-width: 0; }
        .episode-title { font-weight: 600; margin-bottom: 4px; }
        .episode-desc { font-size: 0.85em; color: var(--text-secondary); margin-bottom: 4px; }
        .episode-dubs { font-size: 0.8em; color: var(--text-muted); font-style: italic; }

        /* Calendar */
        .calendar-grid {
            display: grid;
            grid-template-columns: repeat(7, 1fr);
            gap: 10px;
        }

        .calendar-day {
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 8px;
            min-height: 300px;
            display: flex;
            flex-direction: column;
        }

        .calendar-day-header {
            padding: 10px;
            text-align: center;
            border-bottom: 1px solid var(--border-color);
            background: var(--bg-tertiary);
            border-radius: 8px 8px 0 0;
        }

        .calendar-day-date { font-weight: bold; }
        .calendar-day-name { font-size: 0.85em; color: var(--text-secondary); }

        .calendar-day-content {
            flex: 1;
            padding: 8px;
            overflow-y: auto;
        }

        .calendar-episode {
            background: var(--bg-primary);
            border-radius: 6px;
            padding: 8px;
            margin-bottom: 8px;
            text-align: center;
            cursor: pointer;
            transition: background 0.2s;
            position: relative;
        }

        .calendar-episode:hover { background: var(--bg-hover); }
        .calendar-episode.premiere { background: var(--accent-soft); }

        /* Calendar history marks (upstream parity) */
        .calendar-history-mark {
            position: absolute;
            top: 6px;
            right: 6px;
            width: 10px;
            height: 10px;
            border-radius: 50%;
            z-index: 1;
        }
        .calendar-history-mark.mark-downloaded { background: var(--accent-green); }
        .calendar-history-mark.mark-partlydownloaded { background: var(--accent-yellow); }
        .calendar-history-mark.mark-notdownloaded { background: var(--text-muted); }
        .calendar-history-mark.mark-none { display: none; }

        .calendar-episode-time { font-size: 0.8em; color: var(--text-secondary); margin-bottom: 4px; }
        .calendar-episode-locale { font-size: 0.7em; color: var(--text-muted); margin-top: 2px; }
        .calendar-episode-langs { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
        .cal-lang {
            font-size: 0.62em;
            font-weight: 600;
            letter-spacing: 0.02em;
            padding: 1px 5px;
            border-radius: 5px;
            background: var(--accent-soft);
            color: var(--accent-orange);
            white-space: nowrap;
        }

        .calendar-episode-thumb {
            width: 100%;
            aspect-ratio: 16/9;
            background: var(--bg-tertiary);
            border-radius: 4px;
            margin-bottom: 6px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--text-muted);
            overflow: hidden;
            position: relative;
        }

        .calendar-episode-thumb img { width: 100%; height: 100%; object-fit: cover; }

        .calendar-episode-number {
            position: absolute;
            top: 0;
            right: 0;
            background: var(--accent-orange);
            color: #000;
            width: 26px;
            height: 26px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            font-size: 0.8em;
            border-radius: 0 0 0 8px;
        }

        .calendar-episode-title {
            font-size: 0.8em;
            font-weight: 500;
            line-height: 1.3;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }

        /* History */
        .history-toolbar {
            display: flex;
            gap: 8px;
            margin-bottom: 20px;
            flex-wrap: wrap;
            align-items: center;
        }

        .toolbar-btn {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 4px;
            padding: 8px 12px;
            background: transparent;
            border: 1px solid var(--border-color);
            border-radius: 6px;
            color: var(--text-secondary);
            cursor: pointer;
            font-size: 0.75em;
            transition: all 0.2s;
            min-width: 70px;
        }

        .toolbar-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
        .toolbar-btn.active { background: var(--bg-tertiary); color: var(--accent-orange); border-color: var(--accent-orange); }
        .toolbar-btn .icon { font-size: 1.5em; }

        /* Exact Overseerr/seerr poster grid: ul.cards-vertical = minmax(9.375rem,1fr), gap 1rem. */
        .history-poster-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(9.375rem, 1fr));
            gap: 1rem;
        }
        @media (max-width: 480px) {
            .history-poster-grid { grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr)); gap: 0.75rem; }
        }

        .history-poster {
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 8px;
            overflow: hidden;
            cursor: pointer;
            transition: transform 0.2s;
            position: relative;
        }

        .history-poster:hover { transform: translateY(-2px); }

        .history-poster-img {
            width: 100%;
            aspect-ratio: 2/3;
            background: var(--bg-tertiary);
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--text-muted);
            position: relative;
            overflow: hidden;
        }

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

        .history-poster-badge {
            position: absolute;
            top: 0;
            right: 0;
            background: var(--accent-orange);
            color: #000;
            width: 28px;
            height: 28px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            font-size: 0.85em;
            border-radius: 0 0 0 8px;
        }

        .history-poster-info { padding: 10px; text-align: center; }
        .history-poster-title { font-weight: 600; font-size: 0.9em; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .history-poster-meta { font-size: 0.8em; color: var(--text-secondary); }

        /* seerr-style content-type pill, top-left of the poster art. */
        .poster-type-badge {
            position: absolute;
            top: 6px;
            left: 6px;
            background: var(--accent);
            color: #fff;
            font-size: 0.62rem;
            font-weight: 700;
            letter-spacing: 0.04em;
            text-transform: uppercase;
            padding: 2px 7px;
            border-radius: 6px;
            z-index: 2;
            line-height: 1.4;
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
        }

        .history-table table { width: 100%; border-collapse: collapse; }
        .history-table th { padding: 12px 15px; text-align: left; font-weight: 600; font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); background: var(--bg-tertiary); }
        .history-table td { padding: 12px 15px; border-bottom: 1px solid var(--border-color); }
        .history-table tbody tr:hover { background: var(--bg-hover); }

        /* Account */
        .account-container {
            display: flex;
            flex-direction: column;
            align-items: center;
            padding-top: 60px;
        }

        .account-avatar {
            width: 170px;
            height: 170px;
            border-radius: 50%;
            background: var(--bg-tertiary);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 4em;
            color: var(--text-muted);
            margin-bottom: 20px;
            overflow: hidden;
            position: relative;
        }

        .account-avatar img { width: 100%; height: 100%; object-fit: cover; }

        .account-name { font-size: 1.4em; font-weight: 600; margin-bottom: 10px; }
        .account-subscription { font-size: 1.2em; color: var(--text-secondary); margin-bottom: 25px; }

        /* Settings Tabs */
        /* Two labeled categories (Application vs Crunchyroll), mirroring upstream's
           split between app-level settings and content/Crunchyroll settings. */
        .settings-tabs {
            display: flex;
            flex-direction: column;
            gap: 8px;
            border-bottom: 1px solid var(--border-color);
            margin-bottom: 20px;
            padding-bottom: 4px;
        }
        .settings-cat {
            display: flex;
            align-items: center;
            gap: 12px;
            flex-wrap: wrap;
        }
        .settings-cat-label {
            flex: 0 0 auto;
            min-width: 104px;
            font-size: 0.68rem;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.08em;
            color: var(--text-muted);
        }
        .settings-cat-tabs {
            display: flex;
            flex-wrap: wrap;
        }

        /* Seasonal page: Fall/Winter/Spring/Summer pill tabs. */
        .season-tabs {
            display: flex;
            gap: 8px;
            align-items: center;
            flex-wrap: wrap;
            margin-bottom: 20px;
        }
        .season-tab {
            padding: 8px 20px;
            border: 1px solid var(--border-color);
            background: var(--bg-tertiary);
            color: var(--text-secondary);
            border-radius: var(--radius-full);
            cursor: pointer;
            font-weight: 600;
            font-size: 0.9rem;
            font-family: inherit;
            transition: background var(--transition), color var(--transition), border-color var(--transition);
        }
        .season-tab:hover { color: var(--text-primary); }
        .season-tab.active {
            background: var(--accent-soft);
            color: var(--accent);
            border-color: var(--accent);
        }

        .settings-tab {
            padding: 12px 24px;
            background: transparent;
            border: none;
            border-bottom: 3px solid transparent;
            color: var(--text-secondary);
            cursor: pointer;
            font-size: 0.95em;
            transition: all 0.2s;
        }

        .settings-tab:hover { color: var(--text-primary); }
        .settings-tab.active { color: var(--accent-orange); border-bottom-color: var(--accent-orange); }

        .settings-section {
            background: var(--bg-card);
            backdrop-filter: blur(var(--card-blur));
            -webkit-backdrop-filter: blur(var(--card-blur));
            border: 1px solid var(--surface-border);
            border-radius: var(--radius);
            margin-bottom: 16px;
            overflow: hidden;
            box-shadow: var(--shadow-sm);
        }

        .settings-section-header {
            padding: 16px 22px;
            background: rgba(255, 255, 255, 0.03);
            display: flex;
            align-items: center;
            gap: 10px;
            cursor: pointer;
        }

        .settings-section-title { font-weight: 600; }
        .settings-section-desc { font-size: 0.85em; color: var(--text-secondary); margin-left: auto; }

        .settings-section-body { padding: 15px 20px; }

        .setting-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 10px 0;
            border-bottom: 1px solid var(--border-color);
        }

        .setting-row:last-child { border-bottom: none; }

        .setting-label { font-weight: 500; }
        .setting-desc { font-size: 0.85em; color: var(--text-secondary); margin-top: 2px; }

        .setting-control { display: flex; align-items: center; gap: 10px; }

        /* Form Elements */
        .form-group { margin-bottom: 15px; }
        .form-label { display: block; margin-bottom: 5px; font-weight: 500; font-size: 0.9em; }

        .form-input, .form-select {
            width: 100%;
            padding: 10px;
            background: var(--bg-primary);
            border: 1px solid var(--border-color);
            border-radius: 6px;
            color: var(--text-primary);
            font-size: 0.95em;
        }

        .form-input:focus, .form-select:focus { outline: none; border-color: var(--accent-orange); }

        .form-input[type="number"] { width: 120px; }

        select[multiple].form-select { min-height: 120px; padding: 4px; background: var(--bg-primary); }
        select[multiple].form-select option { 
            padding: 6px 10px; 
            border-radius: 4px; 
            margin: 2px 0; 
            cursor: pointer;
            position: relative;
            padding-left: 28px;
        }
        select[multiple].form-select option::before {
            content: '';
            position: absolute;
            left: 8px;
            top: 50%;
            transform: translateY(-50%);
            width: 14px;
            height: 14px;
            border: 2px solid var(--border-color);
            border-radius: 3px;
            background: var(--bg-primary);
        }
        select[multiple].form-select option:checked { 
            background: rgba(244,117,33,0.15); 
            color: var(--accent-orange); 
        }
        select[multiple].form-select option:checked::before {
            background: var(--accent-orange);
            border-color: var(--accent-orange);
        }
        select[multiple].form-select option:checked::after {
            content: '\2713';
            position: absolute;
            left: 10px;
            top: 50%;
            transform: translateY(-50%);
            color: white;
            font-size: 10px;
            font-weight: bold;
        }

        .list-input { display: flex; flex-direction: column; gap: 6px; }
        .list-row { display: flex; gap: 6px; align-items: center; }
        .list-row .form-input { flex: 1; }

        /* Modal */
        .modal-overlay {
            display: none;
            position: fixed;
            top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0,0,0,0.7);
            z-index: 1000;
            align-items: center;
            justify-content: center;
        }

        .modal-overlay.active { display: flex; }

        .modal {
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 8px;
            width: 90%;
            max-width: 700px;
            max-height: 85vh;
            overflow-y: auto;
        }

        .modal-header {
            padding: 20px;
            border-bottom: 1px solid var(--border-color);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .modal-title { font-size: 1.2em; font-weight: 600; }
        .modal-close { background: none; border: none; color: var(--text-secondary); font-size: 1.5em; cursor: pointer; }

        .modal-body { padding: 20px; }
        .modal-footer { padding: 15px 20px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 10px; }

        /* Loading */
        .loading { display: flex; align-items: center; justify-content: center; padding: 40px; color: var(--text-secondary); }
        .spinner {
            width: 20px; height: 20px;
            border: 2px solid var(--border-color);
            border-top-color: var(--accent-orange);
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin-right: 10px;
        }

        @keyframes spin { to { transform: rotate(360deg); } }

        /* Empty State */
        .empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
        .empty-state-icon { font-size: 4em; margin-bottom: 20px; }
        .empty-state-title { font-size: 1.2em; color: var(--text-secondary); margin-bottom: 10px; }

        /* Toast Notifications */
        .toast-container {
            position: fixed;
            top: 20px; right: 20px;
            z-index: 2000;
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        .toast {
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 6px;
            padding: 15px 20px;
            display: flex;
            align-items: center;
            gap: 10px;
            min-width: 300px;
            animation: slideIn 0.3s ease;
        }

        .toast.success { border-left: 4px solid var(--accent-green); }
        .toast.error { border-left: 4px solid var(--accent-red); }
        .toast.warning { border-left: 4px solid var(--accent-yellow); }

        @keyframes slideIn {
            from { transform: translateX(100%); opacity: 0; }
            to { transform: translateX(0); opacity: 1; }
        }

        /* Dropdown / Popup */
        .dropdown-menu {
            position: absolute;
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 6px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.4);
            z-index: 500;
            min-width: 200px;
            display: none;
        }

        .dropdown-menu.active { display: block; }

        .dropdown-item {
            padding: 10px 15px;
            cursor: pointer;
            font-size: 0.9em;
            transition: background 0.2s;
        }

        .dropdown-item:hover { background: var(--bg-hover); }
        .dropdown-divider { border-top: 1px solid var(--border-color); margin: 4px 0; }

        /* Checkbox */
        .checkbox-label {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            cursor: pointer;
            font-size: 0.9em;
        }

        .checkbox-label input { width: 16px; height: 16px; accent-color: var(--accent-orange); }

        .changelog-block {
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 8px;
            padding: 15px 20px;
            margin-bottom: 12px;
        }

        .changelog-version { font-weight: 600; margin-bottom: 8px; }
        .changelog-item { font-size: 0.9em; color: var(--text-secondary); padding: 3px 0; }

        /* Season dropdown container */
        .season-selector { display: flex; gap: 10px; align-items: center; margin-bottom: 15px; }

        /* Sonarr icon placeholder */
        .sonarr-icon { width: 24px; height: 24px; background: var(--accent-green); border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; font-size: 0.7em; color: #fff; }

        /* Sonarr match status indicators */
        .sonarr-matched { border-left: 3px solid var(--accent-green); }
        .sonarr-unmatched { border-left: 3px solid var(--text-secondary); }
        .sonarr-match-badge { font-size: 0.7em; padding: 2px 6px; border-radius: 3px; background: var(--accent-green); color: #fff; margin-left: 5px; }
        .sonarr-ep-badge { display: inline-flex; align-items: center; padding: 2px 6px; border-radius: 3px; font-size: 0.7em; margin-right: 4px; white-space: nowrap; }
        .sonarr-ep-badge.has-file { background: var(--accent-green); color: #fff; }
        .sonarr-ep-badge.missing { background: var(--accent-soft); color: var(--accent-orange); border: 1px solid var(--accent-orange); }
        .history-episode-airdate { font-size: 0.8em; color: var(--text-muted); font-weight: normal; }

        /* Browse dub-language filter bar */
        .browse-filter-bar { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-4); }
        .browse-filter-label { font-weight: var(--fw-semibold); font-size: var(--text-sm); color: var(--text-secondary); }
        .browse-filter-count { font-size: var(--text-sm); color: var(--text-muted); }

        /* Dub Language Selection */
        .dub-selector {
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
            margin-top: 8px;
            padding-top: 8px;
            border-top: 1px solid var(--border-color);
        }
        .dub-option {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            padding: 3px 8px;
            background: var(--bg-tertiary);
            border: 1px solid var(--border-color);
            border-radius: 4px;
            font-size: 0.8em;
            cursor: pointer;
            transition: all 0.2s;
            user-select: none;
        }
        .dub-option:hover {
            background: var(--bg-hover);
            border-color: var(--accent-orange);
        }
        .season-dub-bar {
            display: flex;
            align-items: center;
            flex-wrap: wrap;
            gap: var(--space-2);
            padding: var(--space-3) var(--space-4);
            margin-bottom: var(--space-3);
            background: var(--bg-card);
            border: 1px solid var(--surface-border);
            border-radius: var(--radius-sm);
        }
        .season-dub-label { font-weight: var(--fw-semibold); font-size: var(--text-sm); color: var(--text-secondary); margin-right: var(--space-2); }
        .season-dub-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
        .dub-option.selected {
            background: var(--accent-soft);
            border-color: var(--accent-orange);
            color: var(--accent-orange);
        }
        .dub-option input {
            display: none;
        }
        .dub-option.premium::after {
            content: '+';
            color: var(--accent-orange);
            font-weight: bold;
            margin-left: 2px;
        }
        .episode-multi-dub {
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 8px;
            padding: 12px;
            margin-bottom: 10px;
            display: flex;
            gap: 12px;
            transition: border-color 0.2s;
        }
        .episode-multi-dub.selected {
            border-color: var(--accent-orange);
        }
        .episode-multi-dub .episode-info {
            flex: 1;
            min-width: 0;
        }
        .episode-multi-dub .episode-title {
            font-weight: 600;
            margin-bottom: 4px;
            font-size: 1em;
        }
        .episode-multi-dub .episode-meta {
            font-size: 0.85em;
            color: var(--text-secondary);
            margin-bottom: 6px;
        }
        .dub-lang-badge {
            display: inline-flex;
            align-items: center;
            padding: 2px 6px;
            border-radius: 3px;
            font-size: 0.75em;
            background: var(--bg-tertiary);
            border: 1px solid var(--border-color);
            color: var(--text-secondary);
        }
        .dub-lang-badge.selected {
            background: var(--accent-soft);
            border-color: var(--accent-orange);
            color: var(--accent-orange);
        }
        .dub-section-label {
            font-size: 0.75em;
            color: var(--text-muted);
            margin-bottom: 4px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        /* Tooltip */
        .tooltip-container {
            position: relative;
            display: inline-flex;
            cursor: help;
        }
        .tooltip-text {
            visibility: hidden;
            position: absolute;
            bottom: 125%;
            left: 50%;
            transform: translateX(-50%);
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 6px;
            padding: 8px 12px;
            font-size: 0.8em;
            white-space: nowrap;
            z-index: 100;
            box-shadow: 0 4px 12px rgba(0,0,0,0.4);
            color: var(--text-primary);
        }
        .tooltip-container:hover .tooltip-text {
            visibility: visible;
        }

        /* Partial download indicators */
        .status-icon {
            width: 20px;
            height: 20px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            font-size: 0.8em;
            font-weight: bold;
        }
        .status-full { background: var(--accent-green); color: #000; }
        .status-partial { background: var(--accent-orange); color: #000; }
        .status-none { background: var(--bg-tertiary); color: var(--text-muted); border: 1px solid var(--border-color); }

        /* Search popup active indicator */
        .search-active-dot {
            width: 8px;
            height: 8px;
            background: var(--accent-orange);
            border-radius: 50%;
            position: absolute;
            top: -2px;
            right: -2px;
        }

        /* Settings override popup */
        .settings-override-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 10px 0;
            border-bottom: 1px solid var(--border-color);
        }
        .settings-override-row:last-child { border-bottom: none; }

        /* Only Download mode selector */
        .mode-selector {
            display: flex;
            gap: 4px;
            background: var(--bg-tertiary);
            border-radius: 6px;
            padding: 4px;
            border: 1px solid var(--border-color);
        }
        .mode-btn {
            padding: 6px 12px;
            border: none;
            background: transparent;
            color: var(--text-secondary);
            border-radius: 4px;
            cursor: pointer;
            font-size: 0.85em;
            transition: all 0.2s;
        }
        .mode-btn.active {
            background: var(--accent-orange);
            color: #000;
            font-weight: 600;
        }

        /* History detail view */
        .history-detail-header {
            display: flex;
            gap: 20px;
            margin-bottom: 20px;
            padding-bottom: 20px;
            border-bottom: 1px solid var(--border-color);
        }
        .history-detail-poster {
            width: 150px;
            aspect-ratio: 2/3;
            background: var(--bg-tertiary);
            border-radius: 8px;
            overflow: hidden;
            flex-shrink: 0;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .history-detail-poster img { width: 100%; height: 100%; object-fit: cover; }
        .history-detail-info { flex: 1; }
        .history-detail-title { font-size: 1.4em; font-weight: 600; margin-bottom: 8px; }
        .history-detail-meta { color: var(--text-secondary); font-size: 0.9em; margin-bottom: 8px; }

        .history-season {
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 8px;
            margin-bottom: 15px;
            overflow: hidden;
        }
        .history-season-header {
            padding: 12px 15px;
            background: var(--bg-tertiary);
            display: flex;
            justify-content: space-between;
            align-items: center;
            cursor: pointer;
        }
        .history-season-title { font-weight: 600; }
        .history-season-actions { display: flex; gap: 8px; }
        .history-season-body { padding: 0 15px 15px; }
        .season-collapse-chevron { font-size: 0.7em; color: var(--text-muted); width: 10px; display: inline-block; }

        .history-episode {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 10px 15px;
            border-bottom: 1px solid var(--border-color);
        }
        .history-episode:last-child { border-bottom: none; }
        .history-episode:hover { background: var(--bg-hover); }
        .history-episode-number {
            width: 40px;
            text-align: center;
            font-weight: 600;
            color: var(--text-secondary);
            flex-shrink: 0;
        }
        .history-episode-title { flex: 1; font-size: 0.95em; min-width: 0; }
        .history-episode-status {
            display: flex;
            gap: 8px;
            align-items: center;
            flex-shrink: 0;
        }
        .history-episode-langs {
            font-size: 0.8em;
            color: var(--text-muted);
            display: flex;
            gap: 4px;
            flex-wrap: wrap;
        }

        .lang-badge {
            display: inline-flex;
            align-items: center;
            padding: 2px 6px;
            border-radius: 3px;
            font-size: 0.75em;
            background: var(--bg-tertiary);
            border: 1px solid var(--border-color);
            color: var(--text-secondary);
        }
        .lang-badge.selected {
            background: var(--accent-soft);
            border-color: var(--accent-orange);
            color: var(--accent-orange);
        }
        .lang-badge.downloaded {
            background: var(--success-soft);
            border-color: var(--accent-green);
            color: var(--accent-green);
        }

        /* Mobile Responsive - Comprehensive */
        /* ================== MODERN UI POLISH ================== */

        /* Themed scrollbars — visible against both content and sidebar surfaces.
           Per-theme --scrollbar-thumb* tokens keep contrast correct in every theme
           (was --cr-gray-700, invisible on dark sidebar). */
        ::-webkit-scrollbar { width: 10px; height: 10px; }
        ::-webkit-scrollbar-track { background: transparent; }
        ::-webkit-scrollbar-thumb {
            background: var(--scrollbar-thumb);
            border-radius: 6px;
            border: 2px solid transparent;
            background-clip: padding-box;
        }
        ::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); background-clip: padding-box; }
        /* Sidebar gets its own thumb token (against the sidebar gradient). */
        .sidebar::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb-sidebar); background-clip: padding-box; }
        .sidebar::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-sidebar-hover); background-clip: padding-box; }
        * { scrollbar-width: thin; scrollbar-color: var(--scrollbar-thumb) transparent; }
        .sidebar { scrollbar-color: var(--scrollbar-thumb-sidebar) transparent; }

        /* Respect reduced motion */
        @media (prefers-reduced-motion: reduce) {
            *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
        }

        /* Header: translucent with blur (Cinematic overrides with stronger glass) */
        .header {
            background: color-mix(in srgb, var(--bg-secondary) 88%, transparent);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
        }

        /* Sidebar nav: smooth color transitions (no translateX — caused jitter) */
        .nav-item { transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out); }
        .nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
        .nav-item:hover .nav-icon { color: var(--accent); }
        /* seerr-style active nav: solid filled accent pill, app-wide. Colour comes from the
           theme's --accent-grad so each theme keeps its own hue. */
        .nav-item.active {
            background: var(--accent-grad);
            color: #fff;
            box-shadow: 0 6px 18px var(--accent-glow);
        }
        .nav-item.active .nav-icon { color: #fff; }

        /* Monochrome icons highlight accent on hover */
        .btn-icon:hover, .toolbar-btn:hover .nav-icon { color: var(--accent); }

        /* Cards: surface honors --card-blur (glass in Cinematic; solid elsewhere) */
        .card {
            background: var(--bg-card);
            backdrop-filter: blur(var(--card-blur));
            -webkit-backdrop-filter: blur(var(--card-blur));
            border: 1px solid var(--surface-border);
            border-radius: var(--radius);
            box-shadow: var(--shadow-sm);
            transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out);
        }
        .card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--accent-softer); }

        /* Buttons: rounder, focus ring, primary glow */
        .header-btn, .btn-icon, .toolbar-btn {
            border-radius: 8px;
            transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
        }
        .header-btn:hover, .toolbar-btn:hover { transform: translateY(-1px); }
        .header-btn:active, .btn-icon:active, .toolbar-btn:active { transform: scale(0.97); }
        .header-btn.primary {
            background: var(--accent-grad);
            color: #0a0a0a; font-weight: 700; border: none;
            box-shadow: var(--shadow-glow);
        }
        .header-btn.primary:hover { box-shadow: 0 12px 34px var(--accent-glow); transform: translateY(-1px); }
        .header-btn:focus-visible, .btn-icon:focus-visible, .toolbar-btn:focus-visible,
        .form-input:focus-visible, .form-select:focus-visible, .settings-tab:focus-visible {
            outline: 2px solid var(--accent);
            outline-offset: 2px;
        }

        /* Inputs: rounder + accent focus glow */
        .form-input, .form-select {
            border-radius: 8px;
            transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
        }
        .form-input:focus, .form-select:focus {
            border-color: var(--accent);
            box-shadow: 0 0 0 3px var(--accent-softer);
        }
        .header-search { border-radius: var(--radius-full); transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out); }
        .header-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-softer); }

        /* Toggle switch: white knob when on */
        .toggle-slider::after { background: var(--cr-gray-300); }
        .toggle-switch input:checked + .toggle-slider::after { background: #ffffff; }

        /* Progress bar: gradient fill + glow */
        .progress-container { border-radius: 6px; overflow: hidden; }
        .progress-bar {
            background: var(--accent-grad);
            border-radius: 6px;
            transition: width 0.4s ease;
        }
        .progress-bar.complete { background: var(--accent-green); }
        .progress-bar.error { background: var(--accent-red); }

        /* Download / episode rows: hover lift (theme-safe border) */
        .download-item, .episode-multi-dub {
            border-radius: var(--radius-md);
            transition: border-color var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
        }
        .download-item:hover, .episode-multi-dub:hover {
            border-color: var(--accent-softer);
            box-shadow: var(--shadow-sm);
        }

        /* Poster cards: zoom + shadow on hover */
        .history-poster {
            border-radius: var(--radius-md);
            overflow: hidden;
            transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
        }
        .history-poster:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
        .history-poster-img { overflow: hidden; }
        .history-poster-img img { transition: transform var(--dur-slow) var(--ease-out); }
        .history-poster:hover .history-poster-img img { transform: scale(1.05); }

        /* Calendar polish */
        .calendar-day { border-radius: var(--radius-md); }
        .calendar-episode { transition: background var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out); }
        .calendar-episode:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }

        /* Settings tabs: pill style */
        .settings-tab { border-radius: var(--radius-full); transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out); }

        /* Modal: overlay = blurred dark backdrop, panel = glass surface.
           (Previously reversed: .modal panel got overlay styling + .modal-content
           was dead code — the panel was nearly invisible.) */
        .modal-overlay {
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            background: rgba(0, 0, 0, 0.55);
        }
        .modal {
            background: var(--glass-bg);
            backdrop-filter: blur(28px);
            -webkit-backdrop-filter: blur(28px);
            border: 1px solid var(--glass-border);
            box-shadow: var(--shadow-lg);
            animation: popIn 0.25s var(--transition);
        }

        /* Toast + dropdown + search popup: depth */
        .toast { border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); }
        .dropdown-menu, .search-popup { border-radius: 10px; box-shadow: 0 10px 32px rgba(0, 0, 0, 0.45); overflow: hidden; }

        /* History table: row hover + scroll safety */
        .history-table { overflow-x: auto; border-radius: 12px; }
        .history-table tbody tr { transition: background 0.15s; }
        .history-table tbody tr:hover { background: var(--bg-hover); }

        /* ================== END MODERN UI POLISH ================== */

        @media (max-width: 768px) {
            :root { --sidebar-width: 0px; --header-height: 50px; } /* keep --header-height in sync with the 50px mobile .header so the fixed top-right profile chip stays vertically centered on the search bar */
            
            .app-container { flex-direction: column; }
            
            /* Mobile Sidebar - Bottom Navigation */
            .sidebar {
                position: fixed;
                bottom: 0;
                left: 0;
                right: 0;
                width: 100%;
                height: 60px;
                flex-direction: row;
                border-right: none;
                border-top: 1px solid var(--border-color);
                z-index: 1000;
                background: var(--bg-secondary);
                overflow: visible;
            }

            /* Flatten both nav wrappers so all bottom-bar cells are direct flex
               children of .sidebar and distribute evenly (5 primary + More). */
            .sidebar-nav, .sidebar-system { display: contents; }
            .nav-secondary { display: none !important; }
            .nav-more { display: flex !important; }

            /* "Add Download" is too wide for a phone cell - show "Add". Note the
               em unit can't be used on ::after here because the span's font-size is
               zeroed to hide the original text (0.85em of 0 = 0). */
            .nav-item[data-page="add-download"] > span:last-child { font-size: 0; line-height: 0; }
            .nav-item[data-page="add-download"] > span:last-child::after {
                content: "Add";
                font-size: 0.55rem;
                line-height: 1.1;
            }

            .sidebar-header { display: none; }
            .sidebar-footer { display: none; }
            .nav-section-title { display: none; }
            
            /* .sidebar-nav + .sidebar-system are display:contents (above) so their
               nav-items are direct flex children of .sidebar and split the bar
               evenly - no horizontal scroll, no cut-off items. */

            .nav-item {
                flex-direction: column;
                padding: 6px 8px;
                gap: 2px;
                font-size: 0.65em;
                border-left: none;
                border-top: 3px solid transparent;
                border-radius: 0;
                margin-right: 0;
                flex: 1 0 auto;
                min-width: 64px;
                justify-content: center;
                text-align: center;
            }
            .nav-item.active { background: transparent; }
            
            .nav-item.active {
                border-left-color: transparent;
                border-top-color: var(--accent-orange);
            }
            
            .nav-item span {
                display: block;
                font-size: 0.85em;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
                max-width: 100%;
            }
            
            .nav-icon {
                width: 22px;
                height: 22px;
                font-size: 1.3em;
            }
            
            /* Main Content Adjustments */
            .main-content {
                height: calc(100vh - 60px);
                padding-bottom: 60px;
            }
            
            .header {
                height: 50px;
                padding: 0 12px;
            }
            
            .header-search {
                width: 100%;
                max-width: 200px;
            }
            
            .header-actions { gap: 8px; }
            .header-btn { padding: 6px 10px; font-size: 0.8em; }
            
            .content { padding: 12px; }
            
            .page-title { font-size: 1.3em; }
            .page-subtitle { font-size: 0.85em; }
            
            /* Cards */
            .card { padding: 12px; margin-bottom: 12px; }
            .card-title { font-size: 1em; }
            
            /* Downloads */
            .download-item {
                flex-direction: column;
                gap: 10px;
                padding: 12px;
            }
            
            .download-thumb {
                width: 100%;
                height: auto;
                aspect-ratio: 16/9;
            }
            
            .download-info { width: 100%; }
            .download-actions {
                width: 100%;
                justify-content: flex-start;
                flex-wrap: wrap;
            }
            
            /* Episodes */
            .episode-item {
                flex-direction: column;
                gap: 8px;
                padding: 10px;
            }
            
            .episode-thumb {
                width: 100%;
                height: auto;
                aspect-ratio: 16/9;
            }
            
            .episode-info { width: 100%; }
            
            /* Series Grid */
            .series-grid {
                grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
                gap: 10px;
            }
            
            .series-card-thumb {
                height: 180px;
            }
            
            .series-card-title {
                font-size: 0.8em;
            }
            
            /* Calendar */
            .calendar-grid { grid-template-columns: 1fr; }
            .calendar-day { min-height: auto; }
            
            /* History */
            .history-item {
                flex-direction: column;
                gap: 8px;
                padding: 10px;
            }
            
            .history-thumb {
                width: 100%;
                height: auto;
                aspect-ratio: 16/9;
            }
            
            /* Forms */
            .form-grid {
                grid-template-columns: 1fr;
                gap: 12px;
            }
            
            .form-group {
                margin-bottom: 12px;
            }
            
            /* Settings */
            .settings-tabs {
                gap: 4px;
            }
            .settings-cat { gap: 4px; }
            /* Category label on its own line above its tabs on phones. */
            .settings-cat-label { min-width: 100%; margin-top: 2px; }

            .settings-tab {
                padding: 6px 10px;
                font-size: 0.8em;
            }
            
            .setting-row {
                flex-direction: column;
                align-items: flex-start;
                gap: 6px;
            }

            .setting-label {
                font-size: 0.85em;
            }

            /* Inline width:300px etc. on settings inputs overflow small screens */
            .setting-row .form-input,
            .setting-row .form-select,
            .settings-section-body .form-input,
            .settings-section-body .form-select,
            .settings-section-body textarea {
                width: 100% !important;
                max-width: 100%;
            }

            /* Add Download: stack episode rows */
            .episode-multi-dub {
                flex-direction: column;
                gap: 10px;
                padding: 12px;
            }
            .episode-multi-dub .episode-thumb {
                width: 100%;
                height: auto;
                aspect-ratio: 16/9;
            }
            .season-selector { flex-wrap: wrap; }
            .season-selector > div { margin-left: 0 !important; width: 100%; }
            .season-selector .form-select { width: 100%; }

            /* History toolbar: wrap buttons */
            .history-toolbar { flex-wrap: wrap; gap: 6px; }
            .toolbar-btn { padding: 6px 10px; font-size: 0.8em; }

            /* History table: horizontal scroll instead of squeeze */
            .history-table table { min-width: 640px; }

            /* Calendar controls: wrap on narrow screens */
            .calendar-controls { flex-wrap: wrap; gap: 8px; }
            .calendar-controls > div { flex-wrap: wrap; }
            
            /* Queue Stats */
            .stats-grid {
                grid-template-columns: repeat(2, 1fr);
                gap: 8px;
            }
            
            .stat-card {
                padding: 10px;
            }
            
            .stat-value {
                font-size: 1.5em;
            }
            
            /* Modals */
            .modal {
                width: 95%;
                max-width: 95%;
                margin: 10px;
                max-height: 90vh;
            }
            
            /* Toast */
            .toast {
                left: 10px;
                right: 10px;
                max-width: none;
                bottom: 70px;
            }
            
            /* Touch-friendly buttons */
            .header-btn, .action-btn, .nav-item {
                min-height: 36px;
                min-width: 36px;
            }
            
            /* Progress bars */
            .progress-bar {
                height: 6px;
            }
            
            /* Search results */
            .search-results {
                max-height: 50vh;
            }
        }
        
        /* Tablet (769px - 1024px) */
        @media (min-width: 769px) and (max-width: 1024px) {
            :root { --sidebar-width: 180px; }
            
            .sidebar-header {
                padding: 15px;
            }
            
            .nav-item {
                padding: 10px 15px;
                font-size: 0.85em;
            }
            
            .header-search {
                width: 250px;
            }
            
            .series-grid {
                grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
            }
        }
        
        /* Large screens */
        @media (min-width: 1400px) {
            .series-grid {
                grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
            }
            
            .content {
                padding: 30px;
            }
        }
        
        /* Safe area for notched phones */
        @supports (padding-bottom: env(safe-area-inset-bottom)) {
            @media (max-width: 768px) {
                .sidebar {
                    padding-bottom: env(safe-area-inset-bottom);
                    height: calc(60px + env(safe-area-inset-bottom));
                }
                
                .main-content {
                    padding-bottom: calc(60px + env(safe-area-inset-bottom));
                }
                
                .toast {
                    bottom: calc(70px + env(safe-area-inset-bottom));
                }
            }
        }
        
        /* Touch device optimizations */
        @media (hover: none) and (pointer: coarse) {
            .nav-item, .header-btn, .action-btn, .series-card, .episode-item, .download-item {
                cursor: default;
            }
            
            /* Larger touch targets */
            .nav-item {
                padding-top: 8px;
                padding-bottom: 8px;
            }
            
            /* Remove hover effects that stick on touch */
            .nav-item:hover {
                background: transparent;
            }
            
            .nav-item.active:hover {
                background: var(--bg-tertiary);
            }
        }

        /* ── UI polish: scrollbars, card depth, focus states, skeletons ── */

        /* Thin themed scrollbars for content + sidebar (WebKit) — tokens set above. */
        .content::-webkit-scrollbar,
        .sidebar::-webkit-scrollbar { width: 8px; }
        .content::-webkit-scrollbar-track,
        .sidebar::-webkit-scrollbar-track { background: transparent; }
        .content, .sidebar { scrollbar-width: thin; }

        /* Card depth + hover (accent-tinted border on hover) */
        .card {
            border-radius: var(--radius-md);
            box-shadow: var(--shadow-sm);
            transition: transform var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
        }
        .card:hover { border-color: var(--accent-softer); box-shadow: var(--shadow-md); }

        /* Download item polish */
        .download-item {
            border-radius: var(--radius-md);
            transition: border-color var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
        }
        .download-item:hover { border-color: var(--accent-softer); box-shadow: var(--shadow-sm); }

        /* Search bar — rounded, focus glow */
        .header-search {
            border-radius: var(--radius-full);
            transition: border-color var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
        }
        .header-search:focus-within {
            border-color: var(--accent);
            box-shadow: 0 0 0 3px var(--accent-softer);
        }

        /* Sidebar active nav — left accent bar */
        .nav-item.active {
            position: relative;
            font-weight: var(--fw-semibold);
        }
        /* Left accent bar removed — the active item is now a solid filled pill (seerr style). */
        .nav-item.active::before { display: none; }

        /* Nav item hover — accent tint */
        .nav-item { transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out); }
        .nav-item:hover { background: var(--bg-hover); }

        /* Poster/card hover — subtle lift */
        .history-poster, .series-card, .episode-card, .calendar-day-card {
            transition: transform var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
        }
        .history-poster:hover, .series-card:hover, .episode-card:hover {
            transform: translateY(-3px);
            border-color: var(--accent-softer);
            box-shadow: var(--shadow-md);
        }

        /* Progress bar — smoother gradient */
        .progress-bar {
            background: linear-gradient(90deg, var(--accent), var(--accent-bright));
            box-shadow: 0 0 8px var(--accent-glow);
        }

        /* Shimmer skeleton loading placeholder */
        @keyframes shimmer {
            0% { background-position: -200% 0; }
            100% { background-position: 200% 0; }
        }
        .skeleton {
            background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-hover) 50%, var(--bg-tertiary) 75%);
            background-size: 200% 100%;
            animation: shimmer 1.5s infinite;
            border-radius: var(--radius-sm);
        }

        /* Empty-state styling */
        .empty-state {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 80px 20px;
            text-align: center;
            color: var(--text-muted);
        }
        .empty-state .empty-icon { font-size: 3em; margin-bottom: 16px; opacity: 0.4; }
        .empty-state .empty-text { font-size: 1.05rem; margin-bottom: 4px; color: var(--text-secondary); }
        .empty-state .empty-hint { font-size: 0.88rem; }

        /* Focus-visible for keyboard navigation */
        *:focus-visible {
            outline: 2px solid var(--accent);
            outline-offset: 2px;
        }

        /* Loading splash — shown immediately on page load, removed by JS
           once the app shell renders. Prevents the blank-page flash. */
        #loading-splash {
            position: fixed;
            inset: 0;
            z-index: 9999;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 18px;
            background: var(--bg-primary, #0a0a0a);
            background-image: var(--bloom, none);
            background-attachment: fixed;
            transition: opacity 0.4s var(--ease-out, ease-out);
        }
        #loading-splash.hidden { opacity: 0; pointer-events: none; }
        #loading-splash .splash-logo-img {
            width: 56px; height: 56px;
            border-radius: 14px;
            object-fit: contain;
        }
        #loading-splash .splash-spinner {
            width: 28px; height: 28px;
            border: 3px solid var(--border-color, rgba(255,255,255,0.08));
            border-top-color: var(--accent, #F47521);
            border-radius: 50%;
            animation: splash-spin 0.7s linear infinite;
        }
        @keyframes splash-spin { to { transform: rotate(360deg); } }
        #loading-splash .splash-text {
            font-size: 0.82rem;
            color: var(--text-muted, #898e98);
            letter-spacing: 0.04em;
        }

/* ============================================================
   PHASE 2 — LAYOUT UTILITIES + RESPONSIVE COLLAPSE (beta.84+)
   Desktop values are IDENTICAL to the fixed-width inline styles
   these classes replaced (zero desktop change). The @media block
   lets narrow viewports collapse them — impossible while the
   widths were inline (inline beats media-query rules).
   ============================================================ */
.w-80{width:80px}.w-100{width:100px}.w-120{width:120px}.w-200{width:200px}
.w-220{width:220px}.w-250{width:250px}.w-300{width:300px}.w-400{width:400px}
.mw-100{min-width:100px}.mw-150{min-width:150px}.mw-170{min-width:170px}
.mw-180{min-width:180px}.mw-200{min-width:200px}.mw-240{min-width:240px}
@media (max-width:640px){
  .w-100,.w-120,.w-200,.w-220,.w-250,.w-300,.w-400{width:100%}
  .w-80{width:auto;max-width:100%}
  .mw-100,.mw-150,.mw-170,.mw-180,.mw-200,.mw-240{min-width:0}
}

/* Phase 2 batch 2 — dedup repeated component styles (beta.86) */
.stat-tile{padding:15px;text-align:center;margin-bottom:0}
.stat-num{font-size:1.8em;font-weight:600}
.hint{font-size:0.85em;color:var(--text-secondary)}
.mt-6{margin-top:6px}.mt-10{margin-top:10px}
.mh-120{min-height:120px}
.clickable{cursor:pointer}
