/* ═══════════════════════════════════════════════════════════
   LibreTV v3 — Modern Streaming Design System
   "Netflix meets glassmorphism" aesthetic
   ═══════════════════════════════════════════════════════════ */

/* ── Design Tokens ─────────────────────────────────────── */
:root {
    --bg-deep: #08090d;
    --bg-primary: #0d1117;
    --bg-surface: #131820;
    --bg-card: #181f2c;
    --bg-card-hover: #1e2738;
    --bg-glass: rgba(20, 28, 45, 0.75);

    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-tertiary: #ec4899;
    --accent-glow: rgba(99, 102, 241, 0.35);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-card: rgba(255, 255, 255, 0.08);
    --border-active: rgba(99, 102, 241, 0.4);

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    --shadow-card: 0 1px 2px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.3);
    --shadow-card-hover: 0 4px 8px rgba(0,0,0,0.5), 0 8px 32px rgba(0,0,0,0.4);
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.15);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;

    --transition-fast: 0.15s ease;
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* Subtle grain overlay for depth */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 50% -10%, rgba(99,102,241,0.08), transparent),
        radial-gradient(ellipse 60% 50% at 90% 50%, rgba(236,72,153,0.04), transparent),
        radial-gradient(ellipse 60% 50% at 10% 80%, rgba(139,92,246,0.04), transparent);
    pointer-events: none;
    z-index: 0;
}

/* ── Typography ────────────────────────────────────────── */
.gradient-text {
    background: linear-gradient(135deg, #818cf8 0%, #c084fc 40%, #f472b6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gradient-text-warm {
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 50%, #ec4899 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── Layout ───────────────────────────────────────────── */
.page-wrapper {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Header ────────────────────────────────────────────── */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    padding: 12px 24px;
    background: linear-gradient(180deg, rgba(8,9,13,0.95) 60%, rgba(8,9,13,0) 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 0 20px var(--accent-glow);
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.settings-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--bg-surface);
    border: 1px solid var(--border-card);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-smooth);
    font-size: 18px;
}

.settings-btn:hover {
    background: var(--bg-card);
    border-color: var(--border-active);
    color: var(--text-primary);
    box-shadow: var(--shadow-glow);
}

/* ── Hero Search Section ───────────────────────────────── */
.hero-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 120px 24px 80px;
    position: relative;
    min-height: 60vh;
}

.hero-section.compact {
    min-height: auto;
    padding: 100px 24px 40px;
    justify-content: flex-start;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-card);
    border-radius: 100px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
    animation: fadeInUp 0.6s ease;
}

.hero-badge .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34,197,94,0.5);
    animation: pulse-dot 2s infinite;
}

.hero-title {
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 900;
    letter-spacing: -1px;
    text-align: center;
    margin-bottom: 12px;
    animation: fadeInUp 0.6s ease 0.1s both;
}

.hero-subtitle {
    font-size: 1.05rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 40px;
    animation: fadeInUp 0.6s ease 0.2s both;
}

/* Search bar */
.search-wrapper {
    width: 100%;
    max-width: 640px;
    animation: fadeInUp 0.6s ease 0.3s both;
}

.search-box {
    display: flex;
    background: var(--bg-surface);
    border: 1.5px solid var(--border-card);
    border-radius: var(--radius-xl);
    overflow: hidden;
    transition: all var(--transition-smooth);
    box-shadow: var(--shadow-card);
}

.search-box:focus-within {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-card), var(--shadow-glow);
    transform: translateY(-1px);
}

.search-box input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 16px 24px;
    font-size: 1rem;
    color: var(--text-primary);
    outline: none;
    font-family: var(--font-sans);
}

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

.search-box button {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    border: none;
    padding: 0 28px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-smooth);
    font-family: var(--font-sans);
    white-space: nowrap;
}

.search-box button:hover {
    background: linear-gradient(135deg, #818cf8, #a78bfa);
    box-shadow: 0 0 30px var(--accent-glow);
}

/* ── Search History Tags ───────────────────────────────── */
.search-tags-area {
    width: 100%;
    max-width: 640px;
    margin-top: 20px;
}

.search-tags-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
}

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

.search-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 100px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font-sans);
}

.search-tag:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.search-tag .tag-icon {
    font-size: 0.7rem;
    opacity: 0.6;
}

/* ── Watch History Section ─────────────────────────────── */
.history-section {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px 24px;
    animation: fadeInUp 0.6s ease 0.4s both;
}

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

.history-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.history-title .icon {
    font-size: 1.3rem;
}

.history-clear-btn {
    font-size: 0.78rem;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 100px;
    transition: all var(--transition-fast);
    font-family: var(--font-sans);
}

.history-clear-btn:hover {
    color: #f87171;
    background: rgba(248,113,113,0.1);
}

.history-scroll {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding-bottom: 12px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.history-scroll::-webkit-scrollbar { display: none; }

/* History card */
.history-card {
    flex: 0 0 200px;
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--transition-smooth);
    scroll-snap-align: start;
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
}

.history-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-active);
    box-shadow: var(--shadow-card-hover);
}

.history-card .poster {
    width: 100%;
    aspect-ratio: 16/10;
    background: var(--bg-surface);
    position: relative;
    overflow: hidden;
}

.history-card .poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.history-card:hover .poster img {
    transform: scale(1.08);
}

.history-card .poster .placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--bg-surface), var(--bg-card));
}

.history-card .card-body {
    padding: 12px 14px;
}

.history-card .card-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 6px;
}

.history-card .card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.history-card .ep-badge {
    padding: 2px 8px;
    background: rgba(99,102,241,0.15);
    color: #a5b4fc;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 500;
}

/* ── Results Section ───────────────────────────────────── */
.results-section {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px 60px;
    animation: fadeIn 0.4s ease;
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.results-count {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.results-count strong {
    color: var(--text-primary);
    font-weight: 700;
}

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

/* ── Movie Card ────────────────────────────────────────── */
.movie-card {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.movie-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(99,102,241,0.03) 0%, transparent 50%);
    opacity: 0;
    transition: opacity var(--transition-smooth);
}

.movie-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-active);
    box-shadow: var(--shadow-card-hover);
}

.movie-card:hover::before {
    opacity: 1;
}

.movie-card .poster-wrap {
    width: 80px;
    height: 112px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-surface);
    position: relative;
}

.movie-card .poster-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.movie-card:hover .poster-wrap img {
    transform: scale(1.1);
}

.movie-card .poster-wrap .no-poster {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    background: linear-gradient(135deg, var(--bg-surface), var(--bg-card));
}

.movie-card .info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
}

.movie-card .title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.movie-card .title .ep-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}

.movie-card .meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.movie-card .meta-row .dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--text-muted);
    opacity: 0.4;
}

.movie-card .rating {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 700;
    color: #fbbf24;
    font-size: 0.85rem;
}

.movie-card .badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

.movie-card .badge.hd {
    background: rgba(99,102,241,0.15);
    color: #a5b4fc;
}

.movie-card .badge.new {
    background: rgba(236,72,153,0.15);
    color: #f9a8d4;
}

.movie-card .desc-row {
    font-size: 0.78rem;
    color: var(--text-muted);
    opacity: 0.7;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Skeleton Loading ──────────────────────────────────── */
.skeleton-card {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
}

.skeleton-card .sk-poster {
    width: 80px;
    height: 112px;
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-card-hover) 50%, var(--bg-surface) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    flex-shrink: 0;
}

.skeleton-card .sk-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    justify-content: center;
}

.sk-line {
    height: 14px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-card-hover) 50%, var(--bg-surface) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.sk-line.w60 { width: 60%; }
.sk-line.w80 { width: 80%; }
.sk-line.w40 { width: 40%; }

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.hidden { display: none; }

.modal-panel {
    width: 100%;
    max-width: 800px;
    max-height: 85vh;
    background: var(--bg-primary);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: scaleIn 0.3s ease;
}

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

.modal-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-surface);
    border: 1px solid var(--border-card);
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* Video info summary in modal */
.video-summary {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    padding: 16px;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.video-summary .thumb {
    width: 80px;
    height: 112px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg-card);
}

.video-summary .meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Episode grid */
.episode-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
}

.episode-sort-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    border: none;
    border-radius: 100px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-smooth);
    font-family: var(--font-sans);
    box-shadow: 0 2px 12px rgba(99,102,241,0.3);
}

.episode-sort-btn:hover {
    box-shadow: 0 4px 20px rgba(99,102,241,0.5);
    transform: translateY(-1px);
}

.episode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
}

.episode-btn {
    padding: 10px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
    font-family: var(--font-sans);
    white-space: nowrap;
}

.episode-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.episode-btn.episode-active {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-color: transparent;
    color: white;
    font-weight: 700;
    box-shadow: 0 0 16px var(--accent-glow);
}

/* ── Settings Panel ────────────────────────────────────── */
.settings-panel {
    position: fixed;
    right: 0;
    top: 0;
    height: 100%;
    width: 340px;
    z-index: 200;
    background: var(--bg-primary);
    border-left: 1px solid var(--border-card);
    padding: 28px 24px;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -10px 0 40px rgba(0,0,0,0.5);
    overflow-y: auto;
}

.settings-panel.show {
    transform: translateX(0);
}

.settings-panel h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 24px;
}

.settings-panel label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.settings-panel select,
.settings-panel input {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: var(--font-sans);
    outline: none;
    transition: all var(--transition-fast);
    margin-bottom: 16px;
}

.settings-panel select:focus,
.settings-panel input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

.settings-panel .status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    padding-top: 8px;
    border-top: 1px solid var(--border-subtle);
}

.status-dot { font-size: 0.7rem; }
.status-dot.online { color: #22c55e; }
.status-dot.offline { color: #ef4444; }
.status-dot.testing { color: #f59e0b; }

/* ── Toast ──────────────────────────────────────────────── */
.toast-bar {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-120%);
    z-index: 300;
    padding: 12px 24px;
    border-radius: 100px;
    font-size: 0.88rem;
    font-weight: 600;
    color: white;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 90vw;
    text-align: center;
}

.toast-bar.show {
    transform: translateX(-50%) translateY(0);
}

.toast-bar.error { background: #dc2626; }
.toast-bar.success { background: #16a34a; }
.toast-bar.info { background: #2563eb; }
.toast-bar.warning { background: #d97706; }

/* ── Loading Overlay ───────────────────────────────────── */
.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 250;
    background: rgba(8,9,13,0.8);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
}

.loading-spinner-ring {
    width: 44px;
    height: 44px;
    border: 3px solid var(--border-card);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ── Footer ─────────────────────────────────────────────── */
.site-footer {
    border-top: 1px solid var(--border-subtle);
    padding: 24px;
    background: var(--bg-primary);
}

.footer-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    flex-wrap: wrap;
    gap: 12px;
}

.footer-inner a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition-fast);
    margin-left: 16px;
}

.footer-inner a:hover {
    color: var(--text-primary);
}

/* ── Player Page ────────────────────────────────────────── */
.player-page {
    background: #000 !important;
}

.player-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.player-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    background: rgba(0,0,0,0.9);
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.player-header .back-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.06);
    transition: all var(--transition-fast);
    white-space: nowrap;
    font-family: var(--font-sans);
}

.player-header .back-link:hover {
    background: rgba(255,255,255,0.12);
    color: var(--text-primary);
}

.player-header .video-title-display {
    flex: 1;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: 16px;
}

.video-container {
    position: relative;
    width: 100%;
    background: #000;
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 16px;
}

#player {
    width: 100%;
    height: 55vh;
    min-height: 360px;
}

.player-loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    background: rgba(0,0,0,0.8);
    z-index: 10;
}

.player-error-overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    background: rgba(0,0,0,0.85);
    z-index: 10;
    text-align: center;
    padding: 24px;
}

.player-error-overlay .error-icon-display {
    font-size: 3rem;
    margin-bottom: 8px;
}

.player-error-overlay .error-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
    max-width: 400px;
}

/* Episode nav bar */
.episode-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 12px;
}

.nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border-card);
    border-radius: 100px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font-sans);
}

.nav-btn:hover:not(:disabled) {
    background: var(--bg-card);
    border-color: var(--accent-primary);
}

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

.episode-info-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.episode-list-scroll {
    max-height: 28vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-card) transparent;
}

.episode-list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 8px;
    padding: 8px 0;
}

/* ── Animations ────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

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

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

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
    .hero-title { font-size: 2rem; }
    .hero-section { padding: 100px 16px 40px; }
    .results-grid { grid-template-columns: 1fr; }
    .settings-panel { width: 100%; }
    .history-card { flex: 0 0 160px; }
    .modal-panel { max-width: 100%; margin: 0; border-radius: var(--radius-md); }
    .footer-inner { flex-direction: column; text-align: center; }
    #player { height: 35vh; min-height: 240px; }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .results-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── TV Mode ───────────────────────────────────────────── */
.tv-mode {
    font-size: 20px;
}

.tv-mode .results-grid {
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 24px;
}

.tv-mode .movie-card {
    padding: 24px;
    gap: 24px;
}

.tv-mode .movie-card .poster-wrap {
    width: 120px;
    height: 168px;
}

.tv-mode .movie-card .title {
    font-size: 1.25rem;
}

.tv-mode .search-box input {
    padding: 22px 32px;
    font-size: 1.2rem;
}

.tv-mode .search-box button {
    padding: 0 36px;
    font-size: 1.1rem;
}

.tv-mode .episode-btn {
    padding: 16px 20px;
    font-size: 1rem;
}

.tv-mode *:focus-visible {
    outline: 3px solid var(--accent-primary) !important;
    outline-offset: 4px !important;
}

/* ── Utility ───────────────────────────────────────────── */
.hidden { display: none !important; }
.text-center { text-align: center; }
