/* ═══════════════════════════════════════════════════════════════
   Phene — Soft Dusk Theme
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --bg-primary: #121018;
    --bg-secondary: #1a1625;
    --bg-card: rgba(255,255,255,0.035);
    --bg-card-hover: rgba(255,255,255,0.06);
    --bg-elevated: rgba(255,255,255,0.06);
    --bg-input: rgba(255,255,255,0.03);
    --text-primary: #e8e0f0;
    --text-secondary: rgba(232,224,240,0.62);
    --text-muted: rgba(232,224,240,0.55);
    --accent: #a78bfa;
    --accent-hover: #bfa4ff;
    --accent-glow: rgba(167, 139, 250, 0.2);
    --danger: #ef4444;
    --danger-hover: #f87171;
    --success: #22c55e;
    --on-accent: #121018;
    --warning: #f0b870;
    --border: rgba(255, 255, 255, 0.05);
    --border-focus: rgba(167, 139, 250, 0.5);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    --radius: 14px;
    --radius-sm: 8px;
    --radius-lg: 18px;
    --font-body: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --transition: 200ms ease;
}

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

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background: radial-gradient(ellipse at 20% 0%, rgba(167, 139, 250, 0.05), transparent 55%),
                radial-gradient(ellipse at 80% 100%, rgba(240, 184, 112, 0.03), transparent 50%);
    pointer-events: none;
}

/* ── Scrollbar ─────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ── Top Navigation ────────────────────────────────────────────── */

.top-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 28px;
    background: rgba(18, 16, 24, 0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
    cursor: pointer;
}

.logo .logo-img {
    height: 30px;
    width: auto;
}

.nav-tabs {
    display: flex;
    gap: 4px;
    margin-left: 24px;
}

.nav-tab {
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    border: none;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.nav-tab:hover { color: var(--text-primary); background: rgba(255,255,255,0.04); }
.nav-tab.active { color: var(--text-primary); background: rgba(167, 139, 250, 0.12); }

/* ── Nav dropdown menus (Guides, Downloads) ── */
.nav-dropdown-group { position: relative; }
.nav-dropdown-group > .nav-tab::after {
    content: "";
    display: inline-block;
    width: 0; height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid currentColor;
    margin-left: 6px;
    vertical-align: middle;
    transition: transform 0.2s;
}
.nav-dropdown-group:hover > .nav-tab::after { transform: rotate(180deg); }
.nav-dropdown-group { padding-bottom: 6px; margin-bottom: -6px; }
.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: rgba(20,20,30,0.95);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-width: 180px;
    padding: 6px 0;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    backdrop-filter: blur(12px);
    z-index: 200;
}
.nav-dropdown-group:hover .nav-dropdown-menu { display: block; }
.nav-dropdown-menu a, .nav-dropdown-menu button {
    display: block;
    width: 100%;
    padding: 10px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s;
}
.nav-dropdown-menu a:hover, .nav-dropdown-menu button:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text-primary);
}
.nav-dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }
.nav-dropdown-hide { color: var(--text-muted) !important; font-size: 0.8rem !important; }
.nav-dropdown-hide:hover { color: var(--accent) !important; }

/* ── Mobile nav accordion for dropdowns ── */
.nav-mobile-section { display: none; }
.nav-mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: color 0.2s, background 0.2s;
    width: 100%;
    background: none;
    border: none;
    font-family: inherit;
}
.nav-mobile-header:hover { color: var(--text-primary); background: rgba(167,139,250,0.15); }
.nav-mobile-chevron { opacity: 0.5; transition: transform 0.2s; }
.nav-mobile-header.open .nav-mobile-chevron { transform: rotate(180deg); }
.nav-mobile-items { display: none; flex-direction: column; }
.nav-mobile-items.open { display: flex; }
.nav-mobile-items a, .nav-mobile-items button {
    padding: 12px 20px 12px 40px;
    color: var(--text-secondary);
    text-decoration: none;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
}
.nav-mobile-items a:hover, .nav-mobile-items button:hover {
    color: var(--text-primary);
    background: rgba(167,139,250,0.1);
}
.nav-mobile-items .nav-dropdown-divider { margin: 4px 20px 4px 40px; }
.nav-mobile-items .nav-dropdown-hide { color: var(--text-muted); font-size: 0.85rem; }
.nav-mobile-items .nav-dropdown-hide:hover { color: var(--accent); }

/* Burger button — hidden on desktop, shown on mobile via media query */
.burger-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    z-index: 110;
}
.burger-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s ease;
}
.burger-btn.open span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.burger-btn.open span:nth-child(2) { opacity: 0; }
.burger-btn.open span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

.search-wrapper {
    margin-left: auto;
    position: relative;
    width: 300px;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 14px;
    width: 100%;
    transition: border-color var(--transition);
}

.search-bar:focus-within { border-color: var(--border-focus); }

.search-bar input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font: inherit;
    font-size: 0.9rem;
    outline: none;
    min-width: 0;
}

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

.search-bar .search-icon { color: var(--text-muted); font-size: 1rem; }

.search-clear-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 2px 4px;
    line-height: 1;
}
.search-clear-btn:hover { color: var(--text-primary); }

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 200;
    overflow: hidden;
}

.search-suggestions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.search-suggestions-header a {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.75rem;
    text-transform: none;
    letter-spacing: 0;
}
.search-suggestions-header a:hover { text-decoration: underline; }

.search-suggestion-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background var(--transition);
}
.search-suggestion-item:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text-primary);
}
.search-suggestion-icon { font-size: 0.8rem; color: var(--text-muted); }

/* ── Main Content ──────────────────────────────────────────────── */

.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 28px;
}

.page { display: none; }
.page.active { display: block; }

/* ── Section Headers ───────────────────────────────────────────── */

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

.section-title {
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.section-subtitle {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 2px;
}

/* ── Downloads Tabs ───────────────────────────────────────────── */

.downloads-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}

.downloads-tab {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.2s, border-color 0.2s;
    font-family: inherit;
}

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

/* ── Addon Management ──────────────────────────────────────────── */

.addon-install-form {
    display: flex;
    gap: 10px;
    margin-bottom: 28px;
}

.addon-install-form input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: border-color var(--transition);
}

.addon-install-form input:focus { border-color: var(--border-focus); }
.addon-install-form input::placeholder { color: var(--text-muted); }

.addon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 14px;
}

.addon-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: all var(--transition);
}

.addon-card:hover { background: var(--bg-card-hover); border-color: rgba(255,255,255,0.1); }

.addon-card .addon-logo {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    background: var(--bg-elevated);
    object-fit: contain;
    flex-shrink: 0;
}

.addon-card .addon-logo-placeholder {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--accent), #c4a0ff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    flex-shrink: 0;
}

.addon-info { flex: 1; min-width: 0; }
.addon-info h3 { font-size: 1rem; font-weight: 600; margin-bottom: 2px; }
.addon-info p { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.4; }
.addon-info .addon-types { font-size: 0.75rem; color: var(--text-muted); margin-top: 6px; font-family: var(--font-mono); }

.addon-card .btn-remove {
    flex-shrink: 0;
    padding: 6px 12px;
    font-size: 0.78rem;
}

/* ── Stremio Sync ─────────────────────────────────────────────── */

.stremio-mode-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.mode-tabs {
    display: flex;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.mode-tab {
    padding: 8px 20px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.mode-tab:hover { color: var(--text-primary); background: rgba(255,255,255,0.04); }
.mode-tab.active {
    background: var(--accent);
    color: var(--on-accent);
}

.btn-help {
    width: 26px; height: 26px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    font: inherit; font-size: 0.75rem; font-weight: 700;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--transition);
}
.btn-help:hover { border-color: var(--accent); color: var(--accent); }

.stremio-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

.stremio-panel-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.stremio-panel-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 14px;
}

/* ── Addon Toggle Switch ──────────────────────────────────────── */

.addon-toggle {
    position: relative;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}
.addon-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.addon-toggle .slider {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.1);
    border-radius: 22px;
    cursor: pointer;
    transition: all 0.25s ease;
}
.addon-toggle .slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    bottom: 3px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: all 0.25s ease;
}
.addon-toggle input:checked + .slider {
    background: var(--accent);
}
.addon-toggle input:checked + .slider::before {
    transform: translateX(18px);
    background: var(--on-accent);
}

.addon-card.disabled {
    opacity: 0.45;
}
.addon-card.disabled .addon-info h3,
.addon-card.disabled .addon-info p,
.addon-card.disabled .addon-types {
    color: var(--text-muted);
}

/* Built-in addon badge */
.addon-badge-builtin {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 2px 7px;
    border-radius: 4px;
    background: rgba(167, 139, 250, 0.12);
    color: var(--accent);
    vertical-align: middle;
    margin-left: 6px;
}

/* Locked toggle (built-in addon is only provider) */
.addon-toggle.locked .slider { cursor: not-allowed; opacity: 0.5; }

/* ── Disabled Search Bar ──────────────────────────────────────── */
.search-bar.disabled {
    opacity: 1;
    cursor: not-allowed;
    border-color: rgba(239, 68, 68, 0.2);
    background: rgba(239, 68, 68, 0.03);
}
.search-bar.disabled input {
    cursor: not-allowed;
    pointer-events: none;
}
.search-bar.disabled .search-icon {
    color: rgba(239, 68, 68, 0.35);
}
.search-disabled-text {
    font-weight: 800;
    color: var(--text-muted);
    font-size: 0.78rem;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

/* Search disabled hover overlay */
.search-disabled-overlay {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: 340px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-lg);
    z-index: 50;
    animation: searchOverlayIn 0.2s ease;
}
@keyframes searchOverlayIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-4px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.search-disabled-overlay::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 12px;
    height: 12px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    border-top: 1px solid var(--border);
}
.search-wrapper:hover .search-disabled-overlay {
    display: block;
}

/* ── Buttons ───────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 12px 22px;
    border: none;
    border-radius: 12px;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: var(--on-accent);
}

.btn-primary:hover { background: var(--accent-hover); filter: brightness(1.08); transform: translateY(-1px); }

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--bg-card-hover); }

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover { background: rgba(239, 68, 68, 0.1); color: var(--danger-hover); }

.btn-sm { padding: 6px 14px; font-size: 0.82rem; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Content Grid (Posters) ────────────────────────────────────── */

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

/* ── Carousel Layout ──────────────────────────────────────────── */

.carousel-wrapper {
    position: relative;
}
.carousel-track {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
}
.carousel-track::-webkit-scrollbar { display: none; }
.carousel-track .poster-card {
    flex-shrink: 0;
    width: 150px;
}
.carousel-arrow {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 44px;
    border: none;
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #fff;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}
.carousel-wrapper:hover .carousel-arrow { opacity: 1; pointer-events: auto; }
.carousel-arrow-left {
    left: 0;
    background: linear-gradient(to right, rgba(18, 16, 24, 0.8), transparent);
    border-radius: var(--radius) 0 0 var(--radius);
}
.carousel-arrow-right {
    right: 0;
    background: linear-gradient(to left, rgba(18, 16, 24, 0.8), transparent);
    border-radius: 0 var(--radius) var(--radius) 0;
}
.carousel-arrow:hover { color: var(--accent); }

@media (hover: none), (pointer: coarse) {
    .carousel-arrow { opacity: 0.7; pointer-events: auto; }
}

.poster-card {
    cursor: pointer;
    border-radius: var(--radius);
    overflow: hidden;
    transition: all var(--transition);
    position: relative;
}

.poster-card:hover { transform: translateY(-4px); }
.poster-card:hover .poster-overlay { opacity: 1; }

.poster-card img {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    display: block;
    background: linear-gradient(110deg, var(--bg-card) 30%, #252230 50%, var(--bg-card) 70%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}
.poster-card img.loaded { animation: none; background: var(--bg-card); }

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.poster-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, transparent 50%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 12px;
    opacity: 0;
    transition: opacity var(--transition);
}

.poster-overlay .title {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.3;
}

.poster-overlay .year {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.poster-placeholder {
    width: 100%;
    aspect-ratio: 2 / 3;
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: center;
    padding: 12px;
}

/* ── Catalog Tabs ──────────────────────────────────────────────── */

.catalog-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 22px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.catalog-tab {
    padding: 7px 16px;
    border-radius: 20px;
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.catalog-tab:hover { border-color: rgba(255,255,255,0.12); color: var(--text-primary); }
.catalog-tab.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 700; }

/* ── Detail Page ───────────────────────────────────────────────── */

.detail-hero {
    position: relative;
    margin: -28px -28px 0;
    padding: 120px 40px 40px;
    background-size: cover;
    background-position: center top;
    min-height: 350px;
    display: flex;
    align-items: flex-end;
}

.detail-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, var(--bg-primary) 5%, rgba(18,16,24,0.7) 50%, rgba(18,16,24,0.4));
}

.detail-hero-content {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 28px;
    align-items: flex-end;
    max-width: 1400px;
    width: 100%;
}

.detail-poster {
    width: 180px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    flex-shrink: 0;
}

.detail-info { flex: 1; }
.detail-info h1 { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 6px; }

.detail-meta {
    display: flex;
    gap: 16px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.detail-meta .rating { color: var(--warning); font-weight: 600; }

.detail-description {
    font-size: 0.92rem;
    color: var(--text-secondary);
    line-height: 1.6;
    max-width: 700px;
}

/* ── Streams List ──────────────────────────────────────────────── */

.streams-section { margin-top: 32px; padding: 0 12px; }

.stream-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all var(--transition);
}

.stream-card.playable:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent-glow);
}

.stream-card.external:hover {
    background: var(--bg-card-hover);
    border-color: rgba(34, 197, 94, 0.4);
}

.stream-card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.stream-play-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 2px;
    color: var(--on-accent);
}

.stream-card.external .stream-play-icon {
    background: var(--success);
}

.stream-card.disabled .stream-play-icon {
    background: var(--bg-elevated);
}

.stream-info { flex: 1; min-width: 0; }

.stream-info .stream-name {
    font-size: 0.92rem;
    font-weight: 600;
    word-break: break-word;
    white-space: pre-line;
    line-height: 1.5;
    margin-bottom: 6px;
}

.stream-info .stream-title {
    font-size: 0.78rem;
    color: var(--text-secondary);
    white-space: pre-line;
    line-height: 1.6;
    word-break: break-word;
    font-family: var(--font-mono);
    background: rgba(255, 255, 255, 0.02);
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border-left: 2px solid var(--accent);
    margin-bottom: 4px;
}

.stream-info .stream-description {
    font-size: 0.76rem;
    color: var(--text-muted);
    white-space: pre-line;
    line-height: 1.5;
    word-break: break-word;
    margin-top: 4px;
}

/* stream-source removed — addon name now shown inside stream-name */

/* ── Stream Compatibility Indicators ───────────────────────────── */

.stream-compat-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: 4px 0 0 4px;
}

.stream-compat-bar.great { background: var(--success); }
.stream-compat-bar.good { background: #5bc0de; }
.stream-compat-bar.maybe { background: var(--warning); }
.stream-compat-bar.unlikely { background: var(--danger); }
.stream-compat-bar.download { background: var(--accent); }

.stream-card { position: relative; padding-left: 22px; }

/* ── Stream Card Groups (play + download side by side) ─────── */

.stream-card-group {
    margin-bottom: 8px;
    display: flex;
    gap: 0;
}

.stream-card-group .stream-card {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
}

/* When there's a download button, adjust the play card's right border */
.stream-card-group.has-download .stream-card {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
}

.stream-download-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-left: 1px solid var(--border);
    border-top-right-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    min-width: 56px;
}

.stream-download-btn:hover {
    background: rgba(167, 139, 250, 0.1);
    border-color: var(--accent);
}

.stream-download-btn .dl-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    color: var(--on-accent);
}

.stream-compat-badge {
    font-size: 0.72rem;
    margin-top: 6px;
    padding: 3px 8px;
    border-radius: 4px;
    display: inline-block;
    font-family: var(--font-mono);
}

.stream-compat-badge.great { background: rgba(34, 197, 94, 0.1); color: var(--success); }
.stream-compat-badge.good { background: rgba(91, 192, 222, 0.1); color: #5bc0de; }
.stream-compat-badge.maybe { background: rgba(240, 160, 48, 0.1); color: var(--warning); }
.stream-compat-badge.unlikely { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.stream-compat-badge.download { background: rgba(124, 92, 252, 0.1); color: var(--accent); }

.compat-issue { opacity: 0.7; }

.compat-legend {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.compat-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 2px;
}

.compat-dot.great { background: var(--success); }
.compat-dot.good { background: #5bc0de; }
.compat-dot.maybe { background: var(--warning); }
.compat-dot.unlikely { background: var(--danger); }
.compat-dot.download { background: var(--accent); }

.stream-card.download:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
}

/* ── Fade-in animation for progressive loading ─────────────── */

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Episodes List ─────────────────────────────────────────────── */

.seasons-container { margin-top: 28px; padding: 0 12px; }

.season-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.season-tab {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    font: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all var(--transition);
}

.season-tab:hover { color: var(--text-primary); }
.season-tab.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 700; }

.episode-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 6px;
    cursor: pointer;
    transition: all var(--transition);
}

.episode-card:hover { background: var(--bg-card-hover); border-color: rgba(255,255,255,0.1); }
.episode-card.cw-highlight {
    background: rgba(167, 139, 250, 0.12);
    border-color: rgba(167, 139, 250, 0.4);
    box-shadow: 0 0 12px rgba(167, 139, 250, 0.2);
    transition: all 0.3s ease;
}
.ep-progress-container { margin-top: 6px; }
.ep-progress-bar {
    width: 100%; height: 3px; border-radius: 2px;
    background: rgba(255,255,255,0.2); overflow: hidden;
}
.ep-progress-fill { height: 100%; background: var(--accent); border-radius: 2px; }
.ep-progress-times {
    display: flex; justify-content: space-between; margin-top: 2px;
    font-size: 0.7rem;
}
.ep-progress-times .ep-current { color: var(--accent); }
.ep-progress-times .ep-total { color: var(--text-muted); }

.episode-number {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    width: 40px;
    text-align: center;
    flex-shrink: 0;
}

.episode-info { flex: 1; }
.episode-info .ep-title { font-size: 0.9rem; font-weight: 500; }
.episode-info .ep-overview { font-size: 0.78rem; color: var(--text-secondary); margin-top: 2px; }

.ep-play-btn {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.85rem;
    opacity: 0;
    transition: opacity var(--transition);
}

.episode-card:hover .ep-play-btn { opacity: 1; }
@media (hover: none), (pointer: coarse) {
    .ep-play-btn { opacity: 1; }
    .cw-remove { display: flex; }
}

/* ── Video Player ──────────────────────────────────────────────── */

.player-container {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: #000;
    display: none;
}
.player-container.active { display: block; }

.player-container video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}
.player-container.controls-visible video { pointer-events: none; }

/* ── Controls Overlay ─────────────────────────────────────────── */

.controls-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    background: linear-gradient(
        to bottom,
        rgba(0,0,0,0.7) 0%,
        transparent 25%,
        transparent 65%,
        rgba(0,0,0,0.8) 100%
    );
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
    cursor: default;
}
.player-container.controls-visible .controls-overlay {
    opacity: 1;
    pointer-events: auto;
}

/* ── Top Bar ──────────────────────────────────────────────────── */

.player-top-bar {
    position: absolute;
    top: 0; left: 0; right: 0;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 28px;
    z-index: 12;
}

.player-back-btn {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}
.player-back-btn:hover { background: rgba(255,255,255,0.2); }

.player-title-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.player-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.player-subtitle {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.player-subtitle:empty { display: none; }

.player-play-indicator {
    flex-shrink: 0;
    color: rgba(255,255,255,0.5);
    display: flex;
    align-items: center;
}

/* ── Bottom Section ───────────────────────────────────────────── */

.player-bottom-section {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 0 28px 20px;
    z-index: 12;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ── Pill Bar ─────────────────────────────────────────────────── */

.player-pill-bar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 8px;
    transition: opacity 0.2s, transform 0.2s;
    position: relative;
}
.player-pill-bar.hidden { opacity: 0; transform: translateY(8px); pointer-events: none; }

.player-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: rgba(255,255,255,0.1);
    border: 1.5px solid transparent;
    border-radius: 14px;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
    white-space: nowrap;
}
.player-pill:hover {
    background: rgba(167,139,250,0.2);
    border-color: rgba(167,139,250,0.4);
}
.player-pill:active { transform: scale(0.96); }

.player-pill-two-line .pill-arrow {
    color: var(--text-muted);
    flex-shrink: 0;
    transition: color 0.2s;
}
.player-pill-two-line:hover .pill-arrow { color: var(--accent); }

.pill-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.2;
}
.pill-label {
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    text-transform: uppercase;
}
.player-pill:hover .pill-label { color: var(--accent); }
.pill-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-pill-episode {
    gap: 5px;
    padding: 10px 14px;
    font-size: 0.85rem;
    font-weight: 600;
}
.player-pill-episode svg { flex-shrink: 0; color: var(--text-muted); transition: color 0.2s; }
.player-pill-episode:hover svg { color: var(--accent); }

.player-center-pills {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

/* ── Flyout Menu ──────────────────────────────────────────────── */

.pill-flyout-menu {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    min-width: 180px;
    max-width: 300px;
    max-height: 440px;
    overflow-y: auto;
    background: rgba(30, 26, 46, 0.96);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 6px 0;
    z-index: 25;
    backdrop-filter: blur(16px);
    animation: flyoutIn 0.15s ease;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
@keyframes flyoutIn {
    from { opacity: 0; transform: translateX(-50%) translateY(6px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.pill-flyout-item {
    padding: 9px 14px;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s;
    margin: 0 6px;
    border-radius: 8px;
}
.pill-flyout-item:hover { background: rgba(167,139,250,0.15); }
.pill-flyout-item.selected { color: var(--accent); font-weight: 600; }
.pill-flyout-item.selected .flyout-check { display: inline; }
.pill-flyout-item .flyout-check { display: none; font-weight: 700; font-size: 0.8rem; }
.pill-flyout-item.preferred { border-left: 2px solid var(--accent); margin-left: 4px; padding-left: 12px; border-radius: 0 8px 8px 0; }
.pill-flyout-item.failed { color: #ef4444; opacity: 0.7; }
.pill-flyout-item.failed .flyout-fail-label {
    font-size: 0.7rem;
    color: rgba(239,68,68,0.6);
    margin-left: auto;
}

/* ── Progress Bar ─────────────────────────────────────────────── */

.player-progress-area {
    width: 100%;
}

.player-progress-hitbox {
    position: relative;
    height: 30px;
    display: flex;
    align-items: center;
    cursor: pointer;
    touch-action: none;
}

.player-progress-track {
    position: relative;
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    overflow: visible;
    transition: height 0.15s;
}
.player-progress-area:hover .player-progress-track,
.player-progress-area.dragging .player-progress-track { height: 6px; }

.player-progress-fill {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    border-radius: 2px;
    transition: width 0.1s linear;
}
.player-progress-area.dragging .player-progress-fill { transition: none; }

.player-progress-handle {
    position: absolute;
    top: 50%;
    left: 0%;
    width: 14px; height: 14px;
    margin-top: -7px;
    margin-left: -7px;
    background: white;
    border: 2px solid var(--accent);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.15s, transform 0.15s;
    pointer-events: none;
    z-index: 2;
}
.player-progress-area:hover .player-progress-handle,
.player-progress-area.dragging .player-progress-handle {
    opacity: 1;
}
.player-progress-area.dragging .player-progress-handle { transform: scale(1.2); }

.player-time-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    font-size: 0.8rem;
}
.player-time-current { color: rgba(255,255,255,0.7); transition: color 0.2s; }
.player-progress-area.dragging .player-time-current { color: var(--accent); }
.player-time-total { color: rgba(255,255,255,0.7); }

/* ── Center Pill ──────────────────────────────────────────────── */

.center-pill {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
    pointer-events: auto;
    transition: opacity 0.25s ease;
}
.center-pill.fading-out { opacity: 0; }

.center-pill-content {
    background: rgba(30, 26, 46, 0.95);
    border: 1px solid rgba(167,139,250,0.3);
    border-radius: 20px;
    padding: 20px 36px;
    text-align: center;
    backdrop-filter: blur(12px);
    min-width: 200px;
    max-width: 420px;
}
.center-pill-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: white;
    margin-bottom: 4px;
}
.center-pill-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.center-pill-spinner {
    display: inline-block;
    width: 18px; height: 18px;
    border: 2px solid transparent;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.center-pill-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 12px;
}
.center-pill-actions .btn {
    font-size: 0.85rem;
    padding: 8px 20px;
}
.center-pill-actions .btn-cancel {
    background: rgba(255,255,255,0.1);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s;
}
.center-pill-actions .btn-cancel:hover { background: rgba(255,255,255,0.2); }

/* ── Scrub Indicator ──────────────────────────────────────────── */

.scrub-indicator {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 18;
    text-align: center;
    pointer-events: none;
}
.scrub-time {
    font-size: 3rem;
    font-weight: 700;
    color: white;
    line-height: 1.1;
}
.scrub-delta {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--accent);
}

/* ── Auto-Play Overlay (centered, TV-style) ───────────────────── */

.auto-play-overlay {
    position: absolute;
    inset: 0;
    z-index: 22;
    background: rgba(0,0,0,0.7);
    align-items: center;
    justify-content: center;
}
.auto-play-content {
    text-align: center;
}
.auto-play-label {
    font-size: 1.4rem;
    font-weight: 600;
    color: white;
    margin-bottom: 12px;
}
.auto-play-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 8px;
}
.auto-play-countdown {
    font-size: 0.95rem;
    color: rgba(255,255,255,0.7);
    margin-bottom: 16px;
}
.auto-play-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}
.auto-play-cancel {
    background: rgba(255,255,255,0.1) !important;
    color: white !important;
    border: none;
}
.auto-play-cancel:hover { background: rgba(255,255,255,0.2) !important; }

/* ── Player Loading / Error ───────────────────────────────────── */

.player-loading {
    position: absolute;
    inset: 0;
    z-index: 16;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.player-error-overlay {
    position: absolute;
    inset: 0;
    z-index: 22;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}
.player-error-content { text-align: center; }
.player-error-msg {
    font-size: 1rem;
    color: #ef4444;
    margin-bottom: 16px;
    max-width: 400px;
}
.player-error-actions { display: flex; gap: 12px; justify-content: center; }
.player-error-back {
    background: rgba(255,255,255,0.1) !important;
    color: white !important;
    border: none;
}

/* ── PiP Active State ────────────────────────────────────────── */
.player-container.pip-active .controls-overlay,
.player-container.pip-active .center-pill,
.player-container.pip-active .auto-play-overlay,
.player-container.pip-active .player-loading { display: none !important; }

/* ── Player Mobile Responsive ─────────────────────────────────── */
@media (max-width: 640px) {
    .player-top-bar { padding: 12px 16px; gap: 10px; }
    .player-title { font-size: 0.9rem; }
    .player-subtitle { font-size: 0.78rem; }
    .player-bottom-section { padding: 0 16px 14px; gap: 8px; }
    .pill-value { font-size: 0.78rem; max-width: 90px; }
    .pill-label { font-size: 0.6rem; }
    .player-pill { padding: 6px 10px; }
    .player-pill-episode { padding: 8px 10px; font-size: 0.78rem; }
    .player-progress-hitbox { height: 36px; }
    .player-time-labels { font-size: 0.72rem; }
    .player-center-pills { gap: 6px; }
    .scrub-time { font-size: 2.2rem; }
    .scrub-delta { font-size: 1rem; }
    .center-pill-content { padding: 16px 24px; min-width: 160px; }
    .center-pill-title { font-size: 1rem; }
    .center-pill-desc { font-size: 0.82rem; }
}

/* ── Continue Watching ────────────────────────────────────────── */

.continue-watching-grid {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
}
.continue-watching-grid::-webkit-scrollbar { display: none; }

.cw-card {
    flex-shrink: 0;
    width: 200px;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}
.cw-card:hover { border-color: rgba(255,255,255,0.12); transform: translateY(-2px); }

.cw-card img {
    width: 100%; height: 112px; object-fit: cover; display: block;
}
.cw-card .cw-placeholder {
    width: 100%; height: 112px; background: var(--bg-elevated);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; color: var(--text-muted); padding: 8px; text-align: center;
}

.cw-card .cw-info { padding: 8px 10px; }
.cw-card .cw-title { font-size: 0.82rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cw-card .cw-sub { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

.cw-progress-bar {
    height: 3px; background: var(--bg-elevated); width: 100%;
}
.cw-progress-fill {
    height: 100%; background: var(--accent); border-radius: 0 2px 2px 0;
    transition: width 0.3s;
}

.cw-remove {
    position: absolute; top: 4px; right: 4px;
    width: 22px; height: 22px;
    background: rgba(0,0,0,0.7); border: none; border-radius: 50%;
    color: white; font-size: 12px; cursor: pointer;
    display: none; align-items: center; justify-content: center;
}
.cw-card:hover .cw-remove { display: flex; }
.poster-card:hover .cw-remove { display: flex; }

.library-btn.in-library {
    background: rgba(167, 139, 250, 0.18);
    border-color: var(--accent);
    color: var(--accent);
}

/* ── Library Categories ──────────────────────────────────────── */

.library-category {
    margin-bottom: 28px;
}

.library-category-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.library-category-icon {
    font-size: 1.3rem;
}

.library-category-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.library-category-count {
    background: var(--accent);
    color: var(--on-accent);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.player-container video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ── Toast Notifications ───────────────────────────────────────── */

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 16px 12px 14px;
    border-radius: var(--radius);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    color: var(--text-primary);
    font-size: 0.88rem;
    box-shadow: var(--shadow-lg);
    animation: toast-in 0.3s ease;
    max-width: 380px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast-icon { flex-shrink: 0; font-size: 1rem; line-height: 1; }

.toast.error { border-left-color: var(--danger); background: rgba(239, 68, 68, 0.08); }
.toast.success { border-left-color: var(--success); background: rgba(34, 197, 94, 0.08); }
.toast.warning { border-left-color: var(--warning); background: rgba(240, 184, 112, 0.08); }
.toast.info { border-left-color: var(--accent); background: rgba(167, 139, 250, 0.08); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Loading ───────────────────────────────────────────────────── */

.loading,
.loading-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 10px;
}

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

/* ── Empty State ───────────────────────────────────────────────── */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    color: var(--text-muted);
    text-align: center;
}

.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h2 { font-size: 1.2rem; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p { font-size: 0.9rem; max-width: 400px; }

/* ── Stream Action Modal ────────────────────────────────────── */

.stream-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 900;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
}

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

.stream-modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 520px;
    max-width: 92vw;
    box-shadow: var(--shadow-lg);
    animation: modal-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes modal-in {
    from { opacity: 0; transform: scale(0.97) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

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

.stream-modal-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
}

.stream-modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.stream-modal-close:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.06);
}

.stream-modal-body {
    padding: 22px;
}

.stream-modal-info {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    white-space: pre-line;
    line-height: 1.5;
    background: var(--bg-card);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    max-height: 120px;
    overflow-y: auto;
}

.stream-modal-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.btn-lg {
    padding: 14px 20px;
    font-size: 0.95rem;
    justify-content: flex-start;
    text-align: left;
    width: 100%;
}

.stream-modal-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-align: center;
}

.stream-modal-hint a {
    color: var(--accent);
    text-decoration: none;
}

.stream-modal-hint a:hover {
    text-decoration: underline;
}

/* Audio codec warning */
.audio-warning {
    background: rgba(255, 140, 0, 0.08);
    border: 1px solid rgba(255, 140, 0, 0.3);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin: 12px 0;
}

.audio-warning-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 6px;
    color: #ffa726;
}

.audio-warning-text {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    line-height: 1.4;
}

.audio-warning-options {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.7;
}

.audio-warning-options strong {
    color: var(--text-secondary);
}

.audio-warning-options em {
    color: #ffa726;
    font-style: normal;
}

/* Track selection UI */

.track-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.track-select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.88rem;
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23a78bfa' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    transition: border-color var(--transition);
}

.track-select:focus {
    border-color: var(--border-focus);
}

.track-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 8px;
}

.track-info-box {
    font-size: 0.82rem;
    color: var(--text-secondary);
    background: var(--bg-card);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-family: var(--font-mono);
}

.ffmpeg-warning {
    background: rgba(240, 160, 48, 0.08);
    border: 1px solid rgba(240, 160, 48, 0.25);
    border-radius: var(--radius);
    padding: 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.ffmpeg-warning a { color: var(--accent); }
.ffmpeg-warning code {
    background: var(--bg-card);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
}

/* Player audio track switcher */

.player-controls-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.player-audio-select {
    padding: 6px 28px 6px 10px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    color: white;
    font: inherit;
    font-size: 0.8rem;
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='white' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.player-audio-select option {
    background: #222;
    color: white;
}

/* ── Auth Pages ─────────────────────────────────────────────────── */

.auth-container {
    max-width: 380px;
    margin: 60px auto;
    text-align: center;
    padding: 44px 36px;
    background: rgba(255,255,255,0.025);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(30px);
}

.auth-brand {
    position: relative;
    overflow: hidden;
    margin: 0 -36px 24px;
    padding: 0 36px;
}
.auth-brand .auth-logo-img {
    position: relative;
    z-index: 1;
    display: block;
    margin: 0 auto;
    width: 65%;
    height: auto;
}
.auth-brand .auth-wave-img {
    position: absolute;
    left: 50%;
    top: 62%;
    transform: translate(-50%, -50%);
    width: 3000px;
    max-width: none;
    height: auto;
    z-index: 0;
    pointer-events: none;
}

.auth-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 24px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-form label {
    display: block;
    text-align: left;
    font-size: 0.73rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.03em;
}

.auth-form input {
    padding: 12px 16px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.92rem;
    outline: none;
    transition: all var(--transition);
}

.auth-form input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.12);
}
.auth-form input::placeholder { color: var(--text-muted); }

.auth-forgot {
    display: flex;
    justify-content: flex-end;
    margin: 2px 0 4px;
    font-size: 0.82rem;
}
.auth-forgot a { color: var(--accent); text-decoration: none; font-weight: 600; }
.auth-forgot a:hover { text-decoration: underline; }

.auth-switch {
    margin-top: 22px;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.auth-switch a { color: var(--text-primary); text-decoration: none; font-weight: 700; }
.auth-switch a:hover { color: var(--accent); }

/* ── Email Verification ───────────────────────────────────────── */

.verify-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.verify-email-highlight {
    color: var(--accent);
    font-weight: 700;
}

.code-inputs {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 24px 0;
}

.code-digit {
    width: 50px; height: 58px;
    text-align: center;
    font-size: 1.4rem;
    font-weight: 700;
    font-family: var(--font-body);
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 12px;
    color: var(--text-primary);
    outline: none;
    transition: all 0.2s;
}

.code-digit:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.12);
}

.code-digit.filled {
    border-color: var(--accent);
    background: rgba(167, 139, 250, 0.12);
}

.code-sent-time {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin: 4px 0 12px;
    opacity: 0.7;
}

.verify-resend {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 16px;
}

.verify-resend a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 700;
}

.verify-resend a:hover { text-decoration: underline; }
.verify-resend a.disabled { opacity: 0.4; pointer-events: none; }

/* ── User Menu ─────────────────────────────────────────────────── */

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    flex-shrink: 0;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition);
}

.user-badge:hover { border-color: rgba(255,255,255,0.12); }

.user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--on-accent);
}

/* ── User Dropdown ────────────────────────────────────────────── */

.user-badge { position: relative; }
.user-chevron { opacity: 0.5; transition: transform 0.2s; }
.user-badge.open .user-chevron { transform: rotate(180deg); }

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 180px;
    background: rgba(20,20,30,0.95);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 0;
    backdrop-filter: blur(12px);
    z-index: 200;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.user-dropdown-item:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }
.user-dropdown-item svg { opacity: 0.7; flex-shrink: 0; }
.user-dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }
.user-dropdown-signout:hover { color: #ef4444; }
.user-dropdown-signout:hover svg { stroke: #ef4444; }

/* ── Invites Page ─────────────────────────────────────────────── */

.invite-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

.invite-card-title { font-size: 0.95rem; font-weight: 700; margin-bottom: 4px; }
.invite-card-desc { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 14px; }

.invite-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    gap: 12px;
    flex-wrap: wrap;
}

.invite-row .invite-info { flex: 1; min-width: 200px; }
.invite-row .invite-name { font-size: 0.9rem; font-weight: 600; }
.invite-row .invite-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

.status-badge {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    flex-shrink: 0;
}

.status-pending { color: var(--warning); background: rgba(240,184,112,0.12); }
.status-used { color: var(--success); background: rgba(34,197,94,0.12); }
.status-expired { color: var(--text-muted); background: rgba(255,255,255,0.04); }
.status-revoked { color: var(--danger); background: rgba(239,68,68,0.12); }

.btn-revoke {
    padding: 4px 12px;
    font-size: 0.75rem;
    font-weight: 700;
    background: rgba(239,68,68,0.1);
    color: #ef4444;
    border: 1px solid rgba(239,68,68,0.3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font-body);
}

.btn-revoke:hover { background: rgba(239,68,68,0.2); }

.btn-copy-sm {
    padding: 4px 12px;
    font-size: 0.75rem;
    font-weight: 700;
    background: rgba(167,139,250,0.1);
    color: var(--accent);
    border: 1px solid rgba(167,139,250,0.3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font-body);
    white-space: nowrap;
}
.btn-copy-sm:hover { background: rgba(167,139,250,0.2); }

.invite-link-result {
    margin-top: 14px;
    padding: 12px;
    background: rgba(34,197,94,0.06);
    border: 1px solid rgba(34,197,94,0.2);
    border-radius: var(--radius-sm);
}

.invite-link-result .invite-link-row { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.invite-link-result input {
    flex: 1;
    padding: 8px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.78rem;
}

.btn-copy {
    padding: 8px 14px;
    font-size: 0.78rem;
    font-weight: 700;
    background: rgba(167,139,250,0.15);
    color: var(--accent);
    border: 1px solid rgba(167,139,250,0.3);
    border-radius: 6px;
    cursor: pointer;
    font-family: var(--font-body);
}

.btn-copy:hover { background: rgba(167,139,250,0.25); }

.invite-row.clickable { cursor: pointer; }
.invite-row.clickable:hover { border-color: rgba(255,255,255,0.12); background: var(--bg-card-hover); }

/* (invite-controls moved into flyout styles in admin user section) */

/* ── Settings Page ─────────────────────────────────────────────── */

.settings-form { max-width: 500px; }

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    gap: 16px;
}

.setting-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    flex-shrink: 0;
}

.settings-form .track-select { width: 220px; }

.toggle { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0;
    background: var(--bg-elevated); border-radius: 24px;
    cursor: pointer; transition: 0.3s; border: 1px solid var(--border);
}
.toggle-slider::before {
    content: ''; position: absolute;
    height: 18px; width: 18px; left: 2px; bottom: 2px;
    background: var(--text-muted); border-radius: 50%; transition: 0.3s;
}
.toggle input:checked + .toggle-slider { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); background: white; }

/* ── Font Size Slider ─────────────────────────────────────────── */
.font-slider { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 3px; background: var(--border); outline: none; }
.font-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); cursor: pointer; border: 2px solid var(--bg-primary); }
.font-slider::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); cursor: pointer; border: 2px solid var(--bg-primary); }

/* ── Show More Button ──────────────────────────────────────────── */

.btn-show-more {
    background: rgba(255,255,255,0.06);
    color: var(--accent);
    border: 1px solid var(--border);
    white-space: nowrap;
}
.btn-show-more:hover {
    background: rgba(255,255,255,0.1);
    color: var(--accent);
}

/* ── Catalog Load More ─────────────────────────────────────────── */

.catalog-load-more {
    display: flex;
    justify-content: center;
    padding: 24px 0;
}

/* ── Settings Page Tabs ────────────────────────────────────────── */

.settings-tabs {
    display: flex;
    gap: 2px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 3px;
    margin-bottom: 24px;
    width: fit-content;
}
.settings-tab {
    padding: 8px 22px;
    background: none;
    border: none;
    border-radius: calc(var(--radius) - 2px);
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.settings-tab:hover { color: var(--text-primary); background: rgba(255,255,255,0.04); }
.settings-tab.active {
    background: var(--accent);
    color: var(--on-accent);
}

/* ── Preferences sub-tabs ── */
.pref-subtabs {
    display: flex;
    gap: 2px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px;
    margin-bottom: 20px;
    width: fit-content;
}
.pref-subtab {
    padding: 6px 18px;
    background: none;
    border: none;
    border-radius: calc(var(--radius-sm) - 2px);
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.pref-subtab:hover { color: var(--text-primary); background: rgba(255,255,255,0.04); }
.pref-subtab.active { background: rgba(167,139,250,0.2); color: var(--accent); }

/* ── Admin Page ────────────────────────────────────────────────── */

.admin-tabs {
    display: flex;
    gap: 2px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 3px;
    margin-bottom: 24px;
    width: fit-content;
}
.admin-pulse-bar {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin: -18px 0 16px 4px;
    height: 16px;
    line-height: 16px;
}
.admin-pulse-text { transition: opacity 0.2s ease; }
.admin-pulse-text.refreshing { color: var(--accent); }
.admin-tab {
    padding: 8px 22px;
    background: none;
    border: none;
    border-radius: calc(var(--radius) - 2px);
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.admin-tab:hover { color: var(--text-primary); background: rgba(255,255,255,0.04); }
.admin-tab.active {
    background: var(--accent);
    color: var(--on-accent);
}

.sync-subtabs {
    display: flex;
    gap: 2px;
    background: rgba(255,255,255,0.025);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px;
    margin-bottom: 20px;
    width: fit-content;
}
.sync-subtab {
    padding: 6px 18px;
    background: none;
    border: none;
    border-radius: calc(var(--radius-sm) - 2px);
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.sync-subtab:hover { color: var(--text-primary); background: rgba(255,255,255,0.04); }
.sync-subtab.active {
    background: rgba(167, 139, 250, 0.2);
    color: var(--accent);
}

/* Fix select dropdowns for dark theme */
select.admin-input,
.track-select {
    background-color: var(--bg-input);
    color: var(--text-primary);
}
select.admin-input option,
.track-select option {
    background-color: #1a1625;
    color: var(--text-primary);
}

.admin-section-title {
    font-weight: 600; margin-bottom: 14px;
    color: var(--text-secondary); text-transform: uppercase;
    letter-spacing: 0.05em; font-size: 0.82rem;
}

.admin-field-label {
    display: block; font-size: 0.75rem; font-weight: 600;
    color: var(--text-secondary); margin-bottom: 4px;
    text-transform: uppercase; letter-spacing: 0.03em;
}

.admin-input {
    width: 100%; padding: 8px 12px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text-primary);
    font: inherit; font-size: 0.85rem; outline: none;
    box-sizing: border-box;
}
.admin-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }

/* ── Admin User Table ────────────────────────────────────────── */

.admin-user-table {
    width: 100%; border-collapse: separate; border-spacing: 0;
}
.admin-user-table th {
    text-align: left; padding: 8px 12px; font-size: 0.72rem; font-weight: 700;
    color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border); cursor: pointer; user-select: none;
    white-space: nowrap;
}
.admin-user-table th:hover { color: var(--accent); }
.admin-user-table th .sort-arrow { font-size: 0.6rem; margin-left: 2px; }
.admin-user-table td {
    padding: 8px 12px; font-size: 0.82rem;
    border-bottom: 1px solid rgba(255,255,255,0.02);
    vertical-align: middle;
}
.admin-user-table tr:hover td { background: var(--bg-card-hover); }
.admin-user-table tr.inactive td { opacity: 0.5; }

.admin-active-dot {
    width: 7px; height: 7px; border-radius: 50%; display: inline-block;
    margin-right: 6px; vertical-align: middle;
}
.admin-active-dot.online { background: var(--success); }
.admin-active-dot.offline { background: var(--text-muted); }

.admin-user-name { font-weight: 600; }
.admin-user-email { font-size: 0.72rem; color: var(--text-muted); font-family: var(--font-mono); }
.admin-user-meta { font-size: 0.68rem; color: var(--text-muted); }

.admin-role-badge {
    font-size: 0.66rem; padding: 2px 8px; border-radius: 10px;
    font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; display: inline-block;
}
.admin-role-badge.admin { background: rgba(167, 139, 250, 0.15); color: var(--accent); }
.admin-role-badge.user { background: rgba(255,255,255,0.06); color: var(--text-muted); }
.admin-role-badge.inactive-badge { background: rgba(248,113,113,0.12); color: var(--danger); }

.admin-invite-badge { font-size: 0.66rem; padding: 2px 6px; border-radius: 10px; display: inline-block; }
.admin-invite-badge.has { background: rgba(34,197,94,0.1); color: var(--success); }
.admin-invite-badge.none { background: rgba(255,255,255,0.04); color: var(--text-muted); }

.admin-more-btn {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    font-size: 1.1rem; padding: 2px 6px; border-radius: 4px;
    transition: all var(--transition);
}
.admin-more-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); }

.admin-checkbox { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* ── Quick filter chips ─────────────────────────────────────── */

.admin-chip {
    padding: 5px 12px; border-radius: 16px; border: 1px solid var(--border);
    background: transparent; color: var(--text-muted); font: inherit;
    font-size: 0.76rem; cursor: pointer; white-space: nowrap;
    transition: all var(--transition);
}
.admin-chip:hover { border-color: var(--accent); color: var(--accent); }
.admin-chip.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 700; }
.admin-chip.danger { border-color: rgba(239,68,68,0.3); color: var(--danger); }
.admin-chip.danger:hover { border-color: var(--danger); }
.admin-chip.danger.active { background: var(--danger); color: white; border-color: var(--danger); }

/* ── Bulk actions bar ───────────────────────────────────────── */

.admin-bulk-bar {
    display: flex; align-items: center; gap: 8px; padding: 8px 12px;
    background: rgba(167,139,250,0.08); border: 1px solid rgba(167,139,250,0.2);
    border-radius: var(--radius-sm); margin-bottom: 10px;
    font-size: 0.82rem; flex-wrap: wrap;
}
.admin-bulk-bar .bulk-count { font-weight: 700; color: var(--accent); }
.admin-bulk-btn {
    padding: 4px 10px; border-radius: 6px; border: 1px solid var(--border);
    background: transparent; color: var(--text-primary); font: inherit;
    font-size: 0.76rem; cursor: pointer; transition: all var(--transition);
}
.admin-bulk-btn:hover { border-color: var(--accent); color: var(--accent); }
.admin-bulk-btn.danger { border-color: rgba(239,68,68,0.3); color: var(--danger); }
.admin-bulk-btn.danger:hover { background: rgba(239,68,68,0.08); }
.admin-bulk-btn.danger-hard { border-color: rgba(255,107,107,0.4); color: #ff6b6b; font-weight: 700; }
.admin-bulk-btn.danger-hard:hover { background: rgba(255,107,107,0.12); }

/* ── Pagination ─────────────────────────────────────────────── */

.admin-pagination {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 0; gap: 10px; flex-wrap: wrap;
}
.admin-pagination-info { font-size: 0.76rem; color: var(--text-muted); }
.admin-pagination-btns { display: flex; gap: 3px; }
.admin-page-btn {
    padding: 4px 9px; border-radius: 6px; border: 1px solid var(--border);
    background: transparent; color: var(--text-muted); font: inherit;
    font-size: 0.76rem; cursor: pointer; min-width: 32px; text-align: center;
    transition: all var(--transition);
}
.admin-page-btn:hover { border-color: var(--accent); color: var(--accent); }
.admin-page-btn.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 700; }
.admin-page-btn:disabled { opacity: 0.3; cursor: default; }
.admin-per-page {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.76rem; color: var(--text-muted);
}
.admin-per-page select {
    padding: 3px 6px; background: var(--bg-input); border: 1px solid var(--border);
    border-radius: 6px; color: var(--text-primary); font: inherit; font-size: 0.76rem;
}

/* ── Flyout menu ────────────────────────────────────────────── */

.admin-flyout-backdrop {
    position: fixed; inset: 0; z-index: 999; background: rgba(0,0,0,0.4);
}

.admin-flyout {
    position: fixed; z-index: 1000;
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 10px 0;
    min-width: 260px; max-width: 340px;
    box-shadow: var(--shadow-lg);
}

.admin-flyout-header {
    padding: 8px 16px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px;
}
.admin-flyout-header .flyout-name { font-weight: 700; font-size: 0.88rem; }
.admin-flyout-header .flyout-email { font-size: 0.72rem; color: var(--text-muted); font-family: var(--font-mono); }
.admin-flyout-header .flyout-meta { font-size: 0.68rem; color: var(--text-muted); margin-top: 2px; }

.admin-flyout-item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 16px; cursor: pointer; font-size: 0.82rem;
    color: var(--text-primary); transition: background var(--transition);
    border: none; background: none; width: 100%; text-align: left;
    font-family: inherit;
}
.admin-flyout-item:hover { background: var(--bg-card-hover); }
.admin-flyout-item.danger { color: var(--danger); }
.admin-flyout-item.danger:hover { background: rgba(239,68,68,0.1); }
.admin-flyout-item.success { color: var(--success); }
.admin-flyout-item.success:hover { background: rgba(34,197,94,0.1); }
.admin-flyout-item.danger-hard { color: #ff6b6b; font-weight: 700; font-size: 0.78rem; }
.admin-flyout-item.danger-hard:hover { background: rgba(255,107,107,0.15); }

.admin-flyout-divider {
    height: 1px; background: var(--border); margin: 4px 0;
}

.admin-flyout-invite {
    padding: 8px 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.admin-flyout-invite label { font-size: 0.78rem; color: var(--text-secondary); font-weight: 600; }
.admin-flyout-invite input[type="number"] {
    width: 60px; padding: 3px 6px; background: var(--bg-input); border: 1px solid var(--border);
    border-radius: 6px; color: var(--text-primary); font: inherit; font-size: 0.78rem;
}
.admin-flyout-invite .invite-hint { font-size: 0.68rem; color: var(--text-muted); }

/* Invite row delete button */
.invite-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.invite-delete-btn {
    width: 24px; height: 24px; border-radius: 6px; border: none; cursor: pointer;
    background: transparent; color: var(--text-muted); font-size: 1.1rem; line-height: 1;
    display: flex; align-items: center; justify-content: center; transition: all var(--transition);
}
.invite-delete-btn:hover { background: rgba(239,68,68,0.15); color: var(--danger); }

/* Delete confirmation modal */
.delete-confirm-modal { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; }
.delete-confirm-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); }
.delete-confirm-box {
    position: relative; background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: 14px; padding: 28px; width: 420px; max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.delete-confirm-title { margin: 0 0 8px; font-size: 1.1rem; color: var(--danger); font-weight: 700; }
.delete-confirm-msg { margin: 0 0 18px; font-size: 0.85rem; color: var(--text-secondary); line-height: 1.5; }
.delete-confirm-msg strong { color: var(--text-primary); }
.delete-confirm-msg code { font-size: 0.78rem; color: var(--text-muted); font-family: var(--font-mono); }
.delete-confirm-input-wrap { margin-bottom: 18px; }
.delete-confirm-input-wrap label { display: block; font-size: 0.78rem; color: var(--text-secondary); margin-bottom: 6px; }
.delete-confirm-input-wrap label strong { color: var(--danger); font-family: var(--font-mono); letter-spacing: 1px; }
.delete-confirm-input {
    width: 100%; padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text-primary); font: inherit; font-size: 0.9rem;
    letter-spacing: 2px; text-transform: uppercase;
}
.delete-confirm-input:focus { outline: none; border-color: var(--danger); box-shadow: 0 0 0 2px rgba(239,68,68,0.2); }
.delete-confirm-actions { display: flex; justify-content: flex-end; gap: 10px; }
.delete-confirm-actions .btn-danger {
    background: var(--danger); color: #fff; border: none; padding: 8px 20px; border-radius: 8px;
    font: inherit; font-weight: 600; font-size: 0.82rem; cursor: pointer; transition: all var(--transition);
}
.delete-confirm-actions .btn-danger:hover { background: #dc2626; }
.delete-confirm-actions .btn-danger:disabled { opacity: 0.35; cursor: not-allowed; }
.delete-confirm-actions .btn-secondary {
    background: transparent; color: var(--text-secondary); border: 1px solid var(--border);
    padding: 8px 20px; border-radius: 8px; font: inherit; font-weight: 600; font-size: 0.82rem; cursor: pointer;
}
.delete-confirm-actions .btn-secondary:hover { background: rgba(255,255,255,0.05); }

/* Create user dialog fields */
.create-user-form { display: flex; flex-direction: column; gap: 12px; margin-bottom: 4px; }
.create-user-field { display: flex; flex-direction: column; gap: 4px; }
.create-user-field label { font-size: 0.78rem; color: var(--text-secondary); font-weight: 600; }
.create-user-field select { appearance: auto; }

/* ── Visitor Dashboard ───────────────────────────────────────── */

/* Sub-tabs */
.v-subtabs { display: flex; gap: 2px; margin-bottom: 18px; background: rgba(255,255,255,0.03); border-radius: 10px; padding: 3px; width: fit-content; }
.v-subtab {
    padding: 7px 18px; border-radius: 8px; border: none; cursor: pointer;
    font-family: inherit; font-size: 0.82rem; font-weight: 600;
    background: transparent; color: var(--text-muted); transition: all 0.15s;
}
.v-subtab:hover { color: var(--text-primary); }
.v-subtab.active { background: var(--accent); color: var(--on-accent); }

/* Stat cards */
.v-stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 18px; }
.v-stat-card {
    padding: 12px 14px; border-radius: 10px; background: var(--bg-card); border: 1px solid var(--border);
}
.v-stat-card .v-val { font-size: 1.5rem; font-weight: 800; line-height: 1.1; color: var(--text-primary); }
.v-stat-card .v-val.accent { color: var(--accent); }
.v-stat-card .v-val.green { color: var(--success); }
.v-stat-card .v-val.amber { color: #f0b870; }
.v-stat-card .v-lbl { font-size: 0.7rem; color: var(--text-muted); margin-top: 3px; }

/* Toolbar */
.v-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.v-date-input {
    padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border);
    background: var(--bg-input); color: var(--text-primary); font-family: inherit; font-size: 0.78rem;
}
.v-date-input:focus { outline: none; border-color: var(--accent); }
.v-date-sep { color: var(--text-muted); font-size: 0.78rem; }
.v-range-btn {
    padding: 6px 14px; border-radius: 8px; border: 1px solid var(--border);
    background: transparent; color: var(--text-secondary); font-family: inherit; font-size: 0.78rem; cursor: pointer; transition: all 0.15s;
}
.v-range-btn:hover { border-color: var(--accent); color: var(--accent); }
.v-range-btn.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* DB size pill */
.v-db-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 12px; border-radius: 20px; font-size: 0.72rem;
    background: rgba(255,255,255,0.03); color: var(--text-muted); border: 1px solid var(--border);
}
.v-db-pill .v-db-val { font-weight: 700; color: var(--text-primary); }
.v-db-pill.warn { border-color: rgba(239,68,68,0.3); background: rgba(239,68,68,0.08); }
.v-db-pill.warn .v-db-val { color: var(--danger); }

/* Tables (shared between live + raw log) */
.v-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.v-table th {
    text-align: left; padding: 8px 10px; color: var(--text-muted); font-weight: 600;
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
}
.v-table td { padding: 8px 10px; border-bottom: 1px solid rgba(255,255,255,0.025); vertical-align: middle; }
.v-table tr:hover td { background: rgba(255,255,255,0.02); }
.v-status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.v-status-dot.active { background: var(--success); }
.v-status-dot.idle { background: #f0b870; }
.v-user-badge { font-weight: 600; color: var(--accent); }
.v-guest-badge { color: var(--text-muted); font-style: italic; }
.v-page-chip { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 0.72rem; background: rgba(167,139,250,0.1); color: var(--accent); }
.v-ip { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-muted); }
.v-device { font-size: 0.75rem; color: var(--text-secondary); }
.v-ref { font-size: 0.72rem; color: var(--text-muted); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; }
.v-dur { font-size: 0.75rem; color: var(--text-muted); }
.v-empty { padding: 30px; text-align: center; color: var(--text-muted); font-size: 0.85rem; }
.v-time { font-size: 0.72rem; color: var(--text-muted); font-family: var(--font-mono); }
.v-ua { font-size: 0.7rem; color: var(--text-muted); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; }
.v-keyword { font-size: 0.72rem; color: #f0b870; font-style: italic; }

/* Pulsing dot */
@keyframes livePulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.v-live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--success); margin-right: 4px; animation: livePulse 2s infinite; }

/* Bar chart */
.v-bar-chart { display: flex; align-items: flex-end; gap: 2px; height: 120px; padding-bottom: 22px; margin: 12px 0; }
.v-bar {
    flex: 1; min-width: 4px; border-radius: 3px 3px 0 0; position: relative;
    transition: height 0.3s ease; cursor: default; background: var(--accent);
}
.v-bar:hover { opacity: 0.8; }
.v-bar-lbl { position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%); font-size: 0.58rem; color: var(--text-muted); white-space: nowrap; }
.v-bar-tip {
    position: absolute; top: -22px; left: 50%; transform: translateX(-50%);
    font-size: 0.62rem; color: var(--text-primary); background: var(--bg-elevated);
    padding: 1px 5px; border-radius: 4px; white-space: nowrap; display: none; z-index: 1;
}
.v-bar:hover .v-bar-tip { display: block; }

/* Heatmap */
.v-heatmap { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; margin: 8px 0; }
.v-heat-cell { aspect-ratio: 1; border-radius: 3px; position: relative; cursor: default; min-width: 10px; }
.v-heat-cell .v-heat-tip {
    display: none; position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%);
    font-size: 0.6rem; background: var(--bg-elevated); padding: 2px 6px; border-radius: 4px; white-space: nowrap; z-index: 1; color: var(--text-primary);
}
.v-heat-cell:hover .v-heat-tip { display: block; }
.v-heat-labels { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; }
.v-heat-labels span { font-size: 0.55rem; color: var(--text-muted); text-align: center; }

/* Top lists */
.v-top-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-top: 16px; }
.v-top-title { font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.v-top-list { list-style: none; padding: 0; }
.v-top-list li {
    display: flex; justify-content: space-between; align-items: center; padding: 5px 0;
    font-size: 0.78rem; border-bottom: 1px solid rgba(255,255,255,0.025);
}
.v-top-list li:last-child { border: none; }
.v-top-list .v-name { color: var(--text-primary); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-top-list .v-count { color: var(--text-muted); font-family: var(--font-mono); font-size: 0.72rem; }

/* Flow / journeys */
.v-flow-row { display: flex; align-items: center; gap: 4px; margin: 4px 0; font-size: 0.78rem; }
.v-flow-node { padding: 3px 10px; border-radius: 6px; background: rgba(167,139,250,0.1); color: var(--accent); font-weight: 600; }
.v-flow-arrow { color: var(--text-muted); font-size: 0.7rem; }
.v-flow-count { font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-muted); margin-left: auto; }

/* Section headings inside analytics */
.v-section-title { font-size: 0.82rem; font-weight: 700; color: var(--text-secondary); margin: 16px 0 8px; }

/* Pagination */
.v-pagination { display: flex; justify-content: center; align-items: center; gap: 4px; margin-top: 12px; }
.v-page-btn {
    min-width: 32px; padding: 5px 8px; border-radius: 6px; border: 1px solid var(--border);
    background: transparent; color: var(--text-secondary); font-family: inherit; font-size: 0.75rem; cursor: pointer;
}
.v-page-btn:hover { border-color: var(--accent); color: var(--accent); }
.v-page-btn.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.v-page-info { font-size: 0.72rem; color: var(--text-muted); margin: 0 8px; }

/* Responsive */
@media (max-width: 768px) {
    .v-table thead { display: none; }
    .v-table tr { display: flex; flex-wrap: wrap; gap: 4px 10px; padding: 10px; border-bottom: 1px solid var(--border); align-items: center; }
    .v-table td { padding: 0; border: none; }
    .v-table .v-col-hide { display: none; }
    .v-top-grid { grid-template-columns: 1fr; }
    .v-stat-row { grid-template-columns: repeat(2, 1fr); }
    .v-heatmap { grid-template-columns: repeat(12, 1fr); }
    .v-heat-labels { grid-template-columns: repeat(12, 1fr); }
    .v-toolbar { gap: 6px; }
}

/* ── Cache TTL Chips ──────────────────────────────────────────── */

.cache-ttl-chip {
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s ease;
}
.cache-ttl-chip:hover { border-color: var(--accent); color: var(--accent); }
.cache-ttl-chip.active {
    background: var(--accent);
    color: var(--on-accent);
    border-color: var(--accent);
    font-weight: 600;
}

/* ── Responsive Input Widths ───────────────────────────────────── */

.input-sm { width: 150px; }
.input-md { width: 220px; }

/* ── Responsive: Tablet (≤768px) ──────────────────────────────── */

@media (max-width: 768px) {
    /* Nav — burger menu at tablet */
    .burger-btn { display: flex; order: 3; }
    .top-bar { padding: 10px 16px; flex-wrap: wrap; }
    .logo { order: 0; }
    .user-menu { order: 2; margin-left: auto; }
    .search-wrapper { width: 100%; order: 10; }
    .nav-tabs {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        background: rgba(18, 16, 24, 0.97);
        backdrop-filter: blur(20px);
        border-bottom: 1px solid var(--border);
        padding: 8px 0;
        margin-left: 0;
        z-index: 105;
    }
    .nav-tabs.mobile-open { display: flex; }
    .nav-tab {
        padding: 14px 20px;
        font-size: 1rem;
        text-align: left;
        border-radius: 0;
    }
    .nav-tab.active { background: rgba(167, 139, 250, 0.15); }
    .nav-dropdown-group { display: none !important; }
    .nav-mobile-section { display: block; }
    .nav-dropdown-menu { display: none !important; }

    /* Main content */
    .main-content { padding: 16px; }

    /* Grids */
    .content-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
    .carousel-track .poster-card { width: 120px; }
    .addon-grid { grid-template-columns: 1fr; }

    /* Detail page */
    .detail-hero { padding: 80px 20px 24px; margin: -16px -16px 0; min-height: 280px; }
    .detail-hero-content { flex-direction: column; align-items: flex-start; gap: 16px; }
    .detail-poster { width: 120px; }
    .detail-info h1 { font-size: 1.5rem; }

    /* Streams */
    .streams-section { padding: 0; }

    /* Auth */
    .auth-container { margin: 30px auto; padding: 32px 24px; }

    /* Settings */
    .setting-row { flex-wrap: wrap; }
    .settings-form .track-select { width: 180px; }

    /* Settings & Admin tabs */
    .settings-tab { padding: 6px 14px; font-size: 0.78rem; }
    .admin-tab { padding: 6px 14px; font-size: 0.78rem; }
    .admin-flyout { left: 16px !important; right: 16px !important; min-width: auto; max-width: none; }

    /* Admin user table → pill rows */
    .admin-user-table thead { display: none; }
    .admin-user-table, .admin-user-table tbody, .admin-user-table tr, .admin-user-table td {
        display: block; width: 100%;
    }
    .admin-user-table tr {
        display: flex; align-items: center; gap: 8px;
        padding: 7px 10px; margin-bottom: 3px;
        background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
    }
    .admin-user-table td { padding: 0; border: none; }
    .admin-user-table td.col-check { order: 0; flex-shrink: 0; }
    .admin-user-table td.col-user { order: 1; flex: 1; min-width: 0; }
    .admin-user-table td.col-user .admin-user-email { display: none; }
    .admin-user-table td.col-activity { order: 2; }
    .admin-user-table td.col-activity .admin-user-meta { display: none; }
    .admin-user-table td.col-role { order: 3; }
    .admin-user-table td.col-invites { display: none; }
    .admin-user-table td.col-actions { order: 4; }
    .admin-user-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .admin-bulk-bar { font-size: 0.76rem; }

    /* Responsive inputs */
    .input-sm { width: 100%; }
    .input-md { width: 100%; }

    /* Player */
    .player-top-bar { padding: 10px 14px; gap: 8px; }
    .track-menu { min-width: 180px; right: 10px; }

    /* Continue watching */
    .cw-card { width: 160px; }
}

/* ── Responsive: Phone (≤480px) ───────────────────────────────── */

@media (max-width: 480px) {
    /* ── Base — bump font size for readability ── */
    html { font-size: 16px; }

    /* ── Phone-specific nav tweaks ── */
    .top-bar { padding: 12px 16px; gap: 10px; }
    .logo { gap: 6px; }
    .logo .logo-img { height: 24px; }
    .logo-version { font-size: 0.55rem; }

    /* Search — bigger touch targets */
    .search-input { padding: 12px 16px; font-size: 0.95rem; }

    /* ── Main Content ── */
    .main-content { padding: 14px; }

    /* ── Poster Grid — 2 columns, bigger cards ── */
    .content-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    /* Always show title overlay on touch (no hover on phones) */
    .poster-overlay { opacity: 1; }
    .poster-overlay .title { font-size: 0.9rem; }
    .poster-overlay .year { font-size: 0.8rem; }

    /* Section headers — bigger for readability */
    .section-title { font-size: 1.25rem; }
    .section-subtitle { font-size: 0.88rem; }

    /* Catalog tabs — scrollable, bigger touch targets */
    .catalog-tabs { gap: 8px; }
    .catalog-tab { padding: 10px 16px; font-size: 0.9rem; min-height: 44px; }

    /* ── Detail Page ── */
    .detail-hero { padding: 60px 14px 20px; margin: -14px -14px 0; min-height: auto; }
    .detail-poster { width: 110px; }
    .detail-info h1 { font-size: 1.4rem; }
    .detail-meta { gap: 8px; font-size: 0.88rem; }
    .detail-description { font-size: 0.92rem; line-height: 1.6; }
    .detail-actions { gap: 10px; flex-wrap: wrap; }
    .detail-actions .btn { font-size: 0.9rem; padding: 12px 16px; }

    /* ── Stream Cards ── */
    .stream-card { padding: 14px; gap: 10px; }
    .stream-play-icon { width: 42px; height: 42px; font-size: 0.95rem; }
    .stream-name { font-size: 0.9rem; }
    .stream-tags { font-size: 0.8rem; }

    /* ── Auth Pages ── */
    .auth-container { margin: 16px auto; padding: 28px 20px; }
    .auth-title { font-size: 1.3rem; }
    .auth-container .form-input { padding: 14px 16px; font-size: 0.95rem; }
    .code-inputs { gap: 8px; }
    .code-digit { width: 44px; height: 52px; font-size: 1.3rem; }

    /* ── Settings ── */
    .settings-form { max-width: 100%; }
    .settings-form .track-select { width: 100%; min-height: 44px; font-size: 0.92rem; }
    .setting-row { flex-direction: column; align-items: flex-start; gap: 8px; }
    .setting-label { font-size: 0.95rem; }

    /* ── Settings & Admin tabs ── */
    .settings-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .settings-tab { padding: 10px 16px; white-space: nowrap; font-size: 0.9rem; min-height: 44px; }
    .admin-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .admin-tab { padding: 10px 16px; white-space: nowrap; font-size: 0.9rem; min-height: 44px; }
    .admin-email-grid { grid-template-columns: 1fr !important; }

    /* ── Downloads tabs ── */
    .downloads-tab { padding: 10px 16px; font-size: 0.9rem; min-height: 44px; }

    /* ── Modals ── */
    .stream-modal-content { max-width: 96vw; }
    .stream-modal-header { padding: 14px 16px; }
    .stream-modal-body { padding: 16px; }

    /* ── Player ── */
    .player-track-btn { padding: 12px 14px; font-size: 0.85rem; }
    .player-stream-info { font-size: 0.82rem; padding: 8px 14px; }
    .track-menu { min-width: 180px; right: 8px; max-height: 50vh; }

    /* ── Continue Watching — bigger cards ── */
    .cw-card { width: 160px; }
    .cw-title { font-size: 0.88rem; }
    .cw-sub { font-size: 0.8rem; }

    /* ── Empty State ── */
    .empty-state { padding: 40px 16px; }
    .empty-state h2 { font-size: 1.2rem; }
    .empty-state p { font-size: 0.95rem; }

    /* Buttons — 44px min touch target (Apple HIG / Material) */
    .btn { padding: 12px 18px; font-size: 0.95rem; min-height: 44px; }
    .btn-sm { padding: 10px 14px; font-size: 0.88rem; min-height: 40px; }

    /* Form inputs — bigger touch targets */
    .form-input, select { min-height: 44px; font-size: 0.95rem; }

    /* Episode list — more readable */
    .episode-card { padding: 14px; min-height: 52px; }
    .ep-number { font-size: 0.88rem; }
    .ep-title { font-size: 0.95rem; }

    /* Table text — readable on small screens */
    table { font-size: 0.88rem; }
    table th, table td { padding: 10px 8px; }
}

/* ── Offline Banner ────────────────────────────────────────── */

.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2100;
    background: rgba(239, 68, 68, 0.95);
    color: #fff;
    text-align: center;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    backdrop-filter: blur(8px);
    animation: slideDown 0.3s ease;
}

/* Account access banners */
.access-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2050;
    text-align: center;
    padding: 10px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    backdrop-filter: blur(8px);
    animation: slideDown 0.3s ease;
}
.access-banner a {
    color: #fff;
    text-decoration: underline;
    font-weight: 600;
}
.access-banner-trial {
    background: rgba(167, 139, 250, 0.9);
    color: #fff;
}
.access-banner-grace {
    background: rgba(240, 184, 112, 0.95);
    color: #1a1520;
}
.access-banner-grace a { color: #1a1520; }
.access-banner-locked {
    background: rgba(239, 68, 68, 0.95);
    color: #fff;
}
/* Push main content down when banner is shown */
body:has(.access-banner) .main-content { padding-top: 50px; }
body:has(.access-banner) .site-nav { top: 42px; }

@keyframes slideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

/* ── Confirm Dialog ───────────────────────────────────────── */

.confirm-overlay {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 1500;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    align-items: center;
    justify-content: center;
    animation: fadeInFast 0.15s ease;
}

@keyframes fadeInFast {
    from { opacity: 0; }
    to { opacity: 1; }
}

.confirm-dialog {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    max-width: 380px;
    width: 90vw;
    box-shadow: var(--shadow-lg);
    animation: modal-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.confirm-dialog h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.confirm-dialog p {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ── Detail Back Button ───────────────────────────────────── */

.detail-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.85rem;
    padding: 8px 14px;
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 12px;
}

.detail-back-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.1);
}

/* ── Skeleton Loaders ─────────────────────────────────────── */

.skeleton {
    background: linear-gradient(110deg, var(--bg-card) 30%, rgba(255,255,255,0.06) 50%, var(--bg-card) 70%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

.skeleton-card {
    aspect-ratio: 2 / 3;
    border-radius: var(--radius);
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
}

.skeleton-text.short { width: 60%; }

.skeleton-carousel {
    display: flex;
    gap: 14px;
    overflow: hidden;
}

/* ── Loading States ───────────────────────────────────────── */

.loading-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.loading-state .spinner {
    width: 20px;
    height: 20px;
    margin-right: 0;
}

/* ── Form Validation ──────────────────────────────────────── */

.field-error {
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 4px;
    min-height: 18px;
    transition: opacity 0.15s ease;
}

.auth-form input.input-error {
    border-color: rgba(239, 68, 68, 0.6);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.1);
}

.auth-form input.input-valid {
    border-color: rgba(34, 197, 94, 0.5);
}

.pw-rules {
    display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px;
}
.pw-rule {
    font-size: 0.7rem; padding: 2px 8px; border-radius: 10px;
    background: rgba(255,255,255,0.04); color: var(--text-muted);
    transition: all 0.2s ease;
}
.pw-rule.pass {
    background: rgba(34, 197, 94, 0.12); color: var(--success);
}
.pw-rule.fail {
    background: rgba(239, 68, 68, 0.1); color: var(--danger);
}

/* ── Addon Install Loading ────────────────────────────────── */

.addon-install-form .btn-installing {
    opacity: 0.7;
    pointer-events: none;
}

/* ── Search Result Count ──────────────────────────────────── */

.search-result-count {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ── Version Display ──────────────────────────────────────── */
.logo-version {
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.35);
    font-weight: 400;
    letter-spacing: 0.03em;
}

/* ── Pair Device Page ─────────────────────────────────────────── */
.pair-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    padding: 40px 20px;
}
.pair-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 48px;
    max-width: 460px;
    width: 100%;
    text-align: center;
}
.pair-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.pair-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 32px;
}
.pair-code-display {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 32px;
}
.pair-code-char {
    width: 48px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--accent);
    background: var(--bg-elevated);
    border: 2px solid var(--border-focus);
    border-radius: var(--radius-sm);
}
.pair-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}
.pair-actions .btn {
    min-width: 120px;
}
.pair-input {
    width: 100%;
    padding: 14px 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.4rem;
    text-align: center;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    outline: none;
    margin-bottom: 20px;
}
.pair-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.pair-submit {
    width: 100%;
}
.pair-error-msg {
    color: var(--danger) !important;
}

/* ── Cache Admin ─────────────────────────────────────────── */

.cache-subtabs {
    display: flex; gap: 2px; margin-bottom: 20px;
    background: rgba(255,255,255,0.03); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 3px; width: fit-content;
}
.cache-subtab {
    padding: 7px 18px; border: none; background: none;
    color: var(--text-secondary); font-family: inherit;
    font-size: 0.82rem; font-weight: 600; border-radius: 6px;
    cursor: pointer; transition: var(--transition);
}
.cache-subtab:hover { background: rgba(255,255,255,0.04); }
.cache-subtab.active { background: var(--accent); color: var(--on-accent); }

.stat-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px; margin-bottom: 20px;
}
.stat-card {
    padding: 14px 16px; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.stat-val { font-size: 1.5rem; font-weight: 800; line-height: 1.2; }
.stat-val.accent { color: var(--accent); }
.stat-val.green { color: var(--success); }
.stat-val.amber { color: var(--warning); }
.stat-lbl {
    font-size: 0.7rem; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.04em; margin-top: 2px;
}

.cache-badge {
    display: inline-block; padding: 2px 8px; border-radius: 10px;
    font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.03em;
}
.cache-badge.meta { background: rgba(167,139,250,0.15); color: var(--accent); }
.cache-badge.catalog { background: rgba(34,197,94,0.1); color: var(--success); }
.cache-badge.search { background: rgba(240,184,112,0.12); color: var(--warning); }
.cache-badge.image { background: rgba(56,189,248,0.1); color: #38bdf8; }
.cache-badge.manifest { background: rgba(129,140,248,0.12); color: #818cf8; }
.cache-badge.neg { background: rgba(239,68,68,0.2); color: #ff6b6b; font-size: 0.66rem; margin-left: 6px; }
.cache-scope-badge {
    display: inline-block; padding: 1px 6px; border-radius: 8px;
    font-size: 0.62rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.04em; margin-left: 6px;
}
.cache-scope-badge.shared { background: rgba(167,139,250,0.1); color: var(--accent); }
.cache-scope-badge.user { background: rgba(240,184,112,0.1); color: var(--warning); }

.cache-help-wrap { position: relative; display: inline-flex; }
.cache-help-btn {
    width: 22px; height: 22px; border-radius: 50%;
    border: 1px solid var(--border); background: rgba(255,255,255,0.04);
    color: var(--text-muted); font-size: 0.72rem; font-weight: 700;
    cursor: pointer; display: inline-flex; align-items: center;
    justify-content: center; transition: var(--transition);
    flex-shrink: 0;
}
.cache-help-btn:hover { background: rgba(255,255,255,0.08); color: var(--text-primary); border-color: var(--accent); }

.cache-help-panel {
    display: none; position: absolute; right: 0; top: 100%; margin-top: 6px;
    width: 380px; max-height: 480px; overflow-y: auto;
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 16px 18px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5); z-index: 100;
    font-size: 0.82rem; color: var(--text-secondary); line-height: 1.55;
}
.cache-help-panel.show { display: block; }
.cache-help-panel h4 { color: var(--text-primary); font-size: 0.88rem; margin: 12px 0 6px; }
.cache-help-panel h4:first-child { margin-top: 0; }
.cache-help-panel p { margin: 4px 0 8px; }
.cache-help-panel code { background: rgba(255,255,255,0.06); padding: 1px 5px; border-radius: 3px; font-size: 0.78rem; }
.cache-help-close {
    position: absolute; top: 8px; right: 10px; cursor: pointer;
    color: var(--text-muted); font-size: 0.82rem; padding: 2px 6px;
    border-radius: 4px; transition: var(--transition);
}
.cache-help-close:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }

.cache-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.cache-table td { padding: 10px 12px; font-size: 0.82rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.cache-table tr:last-child td { border-bottom: none; }
.cache-table tr:hover td { background: rgba(255,255,255,0.02); }

.page-btn {
    padding: 4px 9px; min-width: 32px; border: 1px solid var(--border);
    background: none; color: var(--text-secondary); border-radius: 6px;
    font-family: inherit; font-size: 0.78rem; cursor: pointer; transition: var(--transition);
}
.page-btn:hover { background: rgba(255,255,255,0.04); }
.page-btn.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

.cache-stats-row {
    display: flex; gap: 12px; margin-bottom: 12px; align-items: center;
    padding: 12px 16px; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
}

@media (max-width: 768px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
