/* ── Tokens ── */
:root {
  --bg:      oklch(4% 0.002 280);
  --surface: oklch(12% 0.002 280);
  --border:  oklch(19% 0.002 280);
  --fg:      oklch(99% 0.002 280);
  --muted:   oklch(55% 0.005 280);
  --accent:  oklch(55% 0.20 290);
  --accent-glow: oklch(55% 0.20 290 / 0.15);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --font-display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
  --nav-h: 64px;
  --mobile-nav-h: 64px;
  --transition: 350ms cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="light"] {
  --bg:      oklch(99% 0.002 280);
  --surface: oklch(94% 0.002 280);
  --border:  oklch(88% 0.003 280);
  --fg:      oklch(8% 0.002 280);
  --muted:   oklch(48% 0.005 280);
  --accent:  oklch(52% 0.22 290);
  --accent-glow: oklch(52% 0.22 290 / 0.12);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--fg);
  min-height: 100dvh;
  overflow-x: hidden;
  transition: background var(--transition), color var(--transition);
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
ul, ol { list-style: none; }
input { font: inherit; color: inherit; }

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

/* ── Top Navigation ── */
#top-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 48px;
  background: oklch(4% 0.002 280 / 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
  transition: background var(--transition), border-color var(--transition);
}
[data-theme="light"] #top-nav { background: oklch(99% 0.002 280 / 0.85); }
.nav-brand {
  font-family: var(--font-display); font-size: 22px; font-weight: 700;
  letter-spacing: -0.02em; display: flex; align-items: center; gap: 8px;
}
.nav-brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.nav-links { display: flex; gap: 32px; }
.nav-links a {
  font-size: 14px; font-weight: 500; color: var(--muted);
  transition: color 200ms; position: relative;
}
.nav-links a:hover, .nav-links a.active { color: var(--fg); }
.nav-links a.active::after {
  content: ''; position: absolute; bottom: -4px; left: 0; right: 0;
  height: 2px; background: var(--accent); border-radius: 1px;
}
.nav-actions { display: flex; align-items: center; gap: 12px; }
.nav-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); transition: all 200ms;
}
.nav-btn:hover { color: var(--fg); background: var(--surface); }
.nav-btn svg { width: 20px; height: 20px; }
.theme-toggle { position: relative; }
.theme-toggle .sun, .theme-toggle .moon {
  position: absolute; transition: opacity 300ms, transform 300ms;
}
[data-theme="dark"] .theme-toggle .sun { opacity: 1; transform: scale(1); }
[data-theme="dark"] .theme-toggle .moon { opacity: 0; transform: scale(0.5); }
[data-theme="light"] .theme-toggle .sun { opacity: 0; transform: scale(0.5); }
[data-theme="light"] .theme-toggle .moon { opacity: 1; transform: scale(1); }
.profile-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: box-shadow 200ms;
}
.profile-avatar:hover { box-shadow: 0 0 0 3px var(--accent-glow); }

/* ── Mobile bottom nav ── */
#mobile-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: var(--mobile-nav-h);
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 0 16px; justify-content: space-around; align-items: center;
  transition: background var(--transition), border-color var(--transition);
}
#mobile-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 500; color: var(--muted); transition: color 200ms;
}
#mobile-nav a.active { color: var(--accent); }
#mobile-nav a svg { width: 22px; height: 22px; }

/* ── Main content ── */
#app { padding-top: var(--nav-h); min-height: 100dvh; }

.section-header {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 0 48px; margin-bottom: 20px;
}
.section-header h2 { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
.section-header a { font-size: 14px; color: var(--muted); font-weight: 500; transition: color 200ms; }
.section-header a:hover { color: var(--accent); }

.hscroll {
  display: flex; gap: 16px; overflow-x: auto; scroll-snap-type: x mandatory;
  padding: 0 48px 8px; scrollbar-width: none;
}
.hscroll::-webkit-scrollbar { display: none; }
.hscroll > * { scroll-snap-align: start; flex-shrink: 0; }

/* ── Content card ── */
.content-card {
  width: 200px; cursor: pointer; transition: transform 300ms, box-shadow 300ms;
  border-radius: var(--radius);
}
.content-card:hover { transform: translateY(-6px); }
.content-card .poster {
  aspect-ratio: 2 / 3; border-radius: var(--radius); overflow: hidden;
  background: var(--surface); position: relative;
  box-shadow: 0 4px 24px oklch(0% 0 0 / 0.4);
}
.content-card .poster .gradient-fill {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, var(--surface), var(--border));
}
.content-card .poster .overlay-play {
  position: absolute; inset: 0;
  background: oklch(0% 0 0 / 0.5);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 250ms;
}
.content-card:hover .poster .overlay-play { opacity: 1; }
.overlay-play svg {
  width: 48px; height: 48px; fill: #fff;
  filter: drop-shadow(0 2px 8px #000);
}
.content-card .meta { padding: 10px 4px 0; }
.content-card .meta .title { font-size: 14px; font-weight: 600; line-height: 1.3; }
.content-card .meta .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.content-card.wide { width: 280px; }
.content-card.wide .poster { aspect-ratio: 16 / 9; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 100px; font-size: 12px; font-weight: 600;
  background: var(--accent); color: #fff;
}
.rating { color: oklch(80% 0.14 100); font-weight: 600; }

/* ── HOME ── */
.hero {
  position: relative; height: 80vh; min-height: 560px;
  display: flex; align-items: flex-end; padding: 80px 48px 64px; overflow: hidden;
}
.hero-bg {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, oklch(30% 0.15 290), oklch(8% 0.02 280), oklch(2% 0.01 280));
  z-index: -1;
}
.hero-bg::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(to top, var(--bg) 0%, transparent 50%, oklch(0% 0 0 / 0.3) 100%);
}
.hero-content { max-width: 600px; position: relative; z-index: 1; }
.hero-eyebrow {
  font-size: 13px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--accent); margin-bottom: 12px;
}
.hero-content h1 {
  font-family: var(--font-display);
  font-size: clamp(36px, 5vw, 64px); font-weight: 800;
  letter-spacing: -0.03em; line-height: 1.05; margin-bottom: 16px;
}
.hero-content p {
  font-size: 16px; line-height: 1.6; color: var(--muted);
  margin-bottom: 24px; max-width: 480px;
}
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 24px; border-radius: 100px;
  font-size: 15px; font-weight: 600; transition: all 250ms;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover {
  background: oklch(60% 0.22 290); transform: translateY(-1px);
  box-shadow: 0 8px 24px var(--accent-glow);
}
.btn-secondary {
  background: var(--surface); color: var(--fg);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.row-section { margin: 48px 0; }
.row-section.first { margin-top: 32px; }

/* ── BROWSE ── */
.browse-header {
  padding: 32px 48px 24px; position: sticky; top: var(--nav-h); z-index: 10;
  background: var(--bg); transition: background var(--transition);
}
.search-bar {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 100px; padding: 12px 20px; max-width: 520px;
  transition: border-color 200ms;
}
.search-bar:focus-within { border-color: var(--accent); }
.search-bar svg { width: 20px; height: 20px; color: var(--muted); flex-shrink: 0; }
.search-bar input {
  flex: 1; border: none; background: none; outline: none;
  font-size: 15px; color: var(--fg);
}
.search-bar input::placeholder { color: var(--muted); }
.filter-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.chip {
  padding: 8px 18px; border-radius: 100px; font-size: 13px; font-weight: 500;
  background: var(--surface); color: var(--muted);
  border: 1px solid var(--border); transition: all 200ms; cursor: pointer;
}
.chip:hover { color: var(--fg); border-color: var(--muted); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px; padding: 8px 48px 48px;
}
.content-grid .content-card { width: 100%; }

/* ── DETAIL ── */
.detail-backdrop {
  position: relative; height: 50vh; min-height: 400px;
  display: flex; align-items: flex-end; padding: 48px; overflow: hidden;
}
.detail-backdrop .backdrop-bg {
  position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(160deg, oklch(35% 0.18 290), oklch(10% 0.03 280));
}
.detail-backdrop .backdrop-bg::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(to top, var(--bg) 0%, transparent 50%);
}
.detail-summary { position: relative; z-index: 1; display: flex; gap: 32px; align-items: flex-end; }
.backdrop-poster {
  width: 220px; aspect-ratio: 2/3; border-radius: var(--radius);
  background: var(--surface); box-shadow: 0 8px 40px oklch(0% 0 0 / 0.6);
  flex-shrink: 0; overflow: hidden;
}
.backdrop-poster .gradient-fill { width: 100%; height: 100%; }
.detail-info h1 { font-size: clamp(28px, 4vw, 48px); font-weight: 800; letter-spacing: -0.02em; }
.detail-meta { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; margin: 8px 0 12px; font-size: 14px; color: var(--muted); }
.detail-meta .sep { width: 4px; height: 4px; border-radius: 50%; background: var(--muted); }
.detail-info .desc { font-size: 15px; line-height: 1.6; color: var(--muted); max-width: 560px; margin-bottom: 16px; }
.detail-body { padding: 32px 48px 64px; }
.season-selector { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.season-btn {
  padding: 10px 20px; border-radius: 100px; font-size: 14px; font-weight: 500;
  background: var(--surface); color: var(--muted); border: 1px solid var(--border);
  transition: all 200ms;
}
.season-btn:hover { color: var(--fg); }
.season-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.episode-list { display: flex; flex-direction: column; gap: 2px; max-width: 800px; }
.episode-row {
  display: flex; gap: 16px; padding: 16px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background 200ms; align-items: flex-start;
}
.episode-row:hover { background: var(--surface); }
.episode-thumb { width: 160px; aspect-ratio: 16/9; border-radius: 6px; flex-shrink: 0; background: var(--border); }
.episode-info { flex: 1; min-width: 0; }
.episode-info .ep-num { font-size: 12px; color: var(--accent); font-weight: 600; margin-bottom: 4px; }
.episode-info .ep-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.episode-info .ep-dur { font-size: 12px; color: var(--muted); }
.episode-info .ep-desc { font-size: 13px; color: var(--muted); line-height: 1.5; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cast-row { display: flex; gap: 20px; overflow-x: auto; padding-bottom: 8px; }
.cast-card { text-align: center; flex-shrink: 0; width: 100px; }
.cast-avatar { width: 80px; height: 80px; border-radius: 50%; margin: 0 auto 8px; background: var(--surface); display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 700; color: var(--accent); }
.cast-card .cast-name { font-size: 13px; font-weight: 600; }
.cast-card .cast-role { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── PLAYER ── */
.player-container { display: flex; flex-direction: column; height: calc(100vh - var(--nav-h)); }
.player-main { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; background: #000; min-height: 0; }
.player-placeholder {
  position: absolute; inset: 0;
  background: linear-gradient(160deg, oklch(15% 0.02 280), oklch(4% 0.01 280));
  display: flex; align-items: center; justify-content: center;
}
.player-placeholder .play-btn {
  width: 80px; height: 80px; border-radius: 50%;
  background: var(--accent); display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform 200ms, box-shadow 200ms;
  box-shadow: 0 0 40px var(--accent-glow);
}
.player-placeholder .play-btn:hover { transform: scale(1.08); }
.player-placeholder .play-btn svg { width: 32px; height: 32px; fill: #fff; margin-left: 4px; }
.player-controls-bar {
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 16px 48px; display: flex; flex-direction: column; gap: 8px;
}
.progress-row { display: flex; align-items: center; gap: 12px; }
.progress-row .time { font-size: 12px; color: var(--muted); font-family: var(--font-mono); min-width: 40px; }
.progress-track { flex: 1; height: 4px; border-radius: 2px; background: var(--border); cursor: pointer; position: relative; }
.progress-fill { height: 100%; border-radius: 2px; background: var(--accent); width: 34%; position: relative; }
.progress-fill::after { content: ''; position: absolute; right: -6px; top: -4px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); opacity: 0; transition: opacity 200ms; }
.progress-track:hover .progress-fill::after { opacity: 1; }
.ctrl-row { display: flex; align-items: center; justify-content: space-between; }
.ctrl-left, .ctrl-right { display: flex; align-items: center; gap: 16px; }
.ctrl-btn { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; color: var(--fg); transition: color 200ms; }
.ctrl-btn:hover { color: var(--accent); }
.ctrl-btn svg { width: 20px; height: 20px; }
.volume-row { display: flex; align-items: center; gap: 8px; }
.volume-slider { width: 80px; height: 3px; -webkit-appearance: none; appearance: none; background: var(--border); border-radius: 2px; cursor: pointer; }
.volume-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: var(--fg); cursor: pointer; }
.player-episode-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 48px; background: var(--bg); border-top: 1px solid var(--border);
}
.player-ep-info h4 { font-size: 14px; font-weight: 600; }
.player-ep-info span { font-size: 12px; color: var(--muted); }

/* ── Search overlay ── */
#search-overlay {
  position: fixed; inset: 0; z-index: 200; background: var(--bg);
  display: flex; flex-direction: column;
}
.search-overlay-header {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 48px; border-bottom: 1px solid var(--border);
}
.search-overlay-header .search-bar { flex: 1; max-width: none; }
.search-close {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 20px; transition: all 200ms;
}
.search-close:hover { color: var(--fg); background: var(--surface); }
.search-results { padding: 24px 48px; overflow-y: auto; flex: 1; }
.search-results .content-grid { padding: 0; }

/* ── Profile dropdown ── */
#profile-menu {
  display: none;
  position: fixed; top: calc(var(--nav-h) + 8px); right: 48px; z-index: 150;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px; min-width: 220px;
  box-shadow: 0 16px 48px oklch(0% 0 0 / 0.5);
}
#profile-menu.open {
  display: block;
}
.profile-menu-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; color: var(--fg);
  cursor: pointer; transition: background 150ms; width: 100%; text-align: left;
}
.profile-menu-item:hover { background: var(--border); }
.profile-menu-item svg { width: 18px; height: 18px; color: var(--muted); }
.profile-menu-divider { height: 1px; background: var(--border); margin: 6px 0; }

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 64px 24px; text-align: center;
}
.empty-state svg { width: 48px; height: 48px; color: var(--border); margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.empty-state p { font-size: 14px; color: var(--muted); }

/* ── Animations ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 20px var(--accent-glow); }
  50% { box-shadow: 0 0 40px var(--accent-glow), 0 0 60px var(--accent-glow); }
}
.hero-content { animation: fadeUp 800ms cubic-bezier(0.22, 1, 0.36, 1) both; }
.hero-content h1 { animation: fadeUp 800ms 100ms cubic-bezier(0.22, 1, 0.36, 1) both; }
.hero-content p { animation: fadeUp 800ms 200ms cubic-bezier(0.22, 1, 0.36, 1) both; }
.hero-actions { animation: fadeUp 800ms 300ms cubic-bezier(0.22, 1, 0.36, 1) both; }
.player-placeholder .play-btn { animation: pulse 2.5s infinite; }

/* ── Responsive ── */
@media (max-width: 1024px) {
  #top-nav { padding: 0 24px; }
  .section-header { padding: 0 24px; }
  .hscroll { padding: 0 24px 8px; }
  .hero { padding: 60px 24px 48px; }
  .content-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; padding: 8px 24px 48px; }
  .browse-header { padding: 24px 24px 20px; }
  .detail-backdrop { padding: 32px 24px; }
  .detail-summary { gap: 20px; }
  .backdrop-poster { width: 160px; }
  .detail-body { padding: 24px 24px 48px; }
  .player-controls-bar { padding: 16px 24px; }
  .player-episode-bar { padding: 16px 24px; }
  .search-overlay-header { padding: 20px 24px; }
  .search-results { padding: 24px; }
  #profile-menu { right: 24px; }
}
@media (max-width: 768px) {
  :root { --nav-h: 56px; }
  #top-nav { padding: 0 16px; }
  .nav-links { display: none; }
  #mobile-nav { display: flex; }
  #app { padding-bottom: var(--mobile-nav-h); }
  .section-header { padding: 0 16px; }
  .section-header h2 { font-size: 20px; }
  .hscroll { padding: 0 16px 8px; gap: 12px; }
  .content-card { width: 150px; }
  .content-card.wide { width: 240px; }
  .hero { height: 60vh; min-height: 400px; padding: 40px 16px 32px; }
  .hero-content h1 { font-size: clamp(28px, 7vw, 40px); }
  .hero-content p { font-size: 14px; }
  .btn { padding: 10px 20px; font-size: 14px; }
  .content-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; padding: 8px 16px 48px; }
  .browse-header { padding: 20px 16px 16px; top: var(--nav-h); }
  .detail-backdrop { height: auto; min-height: 0; padding: 24px 16px; }
  .detail-summary { flex-direction: column; align-items: flex-start; gap: 16px; }
  .backdrop-poster { width: 120px; }
  .detail-info h1 { font-size: 24px; }
  .detail-body { padding: 20px 16px 48px; }
  .episode-row { gap: 12px; }
  .episode-thumb { width: 120px; }
  .player-controls-bar { padding: 12px 16px; }
  .player-episode-bar { padding: 12px 16px; flex-direction: column; gap: 8px; align-items: flex-start; }
  .volume-row { display: none; }
  #profile-menu { right: 8px; top: calc(var(--nav-h) + 8px); min-width: 200px; }
  .search-overlay-header { padding: 16px; }
  .search-results { padding: 16px; }
  .cast-card { width: 80px; }
  .cast-avatar { width: 64px; height: 64px; font-size: 18px; }
}
@media (max-width: 480px) {
  .content-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .content-card { width: 100%; }
  .content-card .meta .title { font-size: 12px; }
  .hero-actions { flex-direction: column; }
  .btn { width: 100%; justify-content: center; }
  .filter-chips { gap: 6px; }
  .chip { padding: 6px 14px; font-size: 12px; }
}
