:root {
  --bg: #000000;
  --bg-2: #0d1320;
  --surface: #121a28;
  --surface-2: #192436;
  --line: #22304a;
  --text: #eaf0f7;
  --text-dim: #8a97a8;
  --text-faint: #5d6b7e;
  --accent: #1e90ff;
  --accent-2: #5eb3ff;
  --accent-ink: #04244a;
  --gold: #f5c518;
  --danger: #ff5c6a;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-card: 0 18px 40px -18px rgba(0, 0, 0, 0.8);
  --glow: 0 0 0 1px rgba(94, 179, 255, 0.5), 0 22px 48px -16px rgba(30, 144, 255, 0.55);
  --maxw: 1600px;
  --gutter: clamp(16px, 4vw, 56px);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Montserrat", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  background: var(--bg);
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
::selection { background: rgba(30, 144, 255, 0.35); }

:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 3px;
  border-radius: 6px;
}

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- top bar ---------- */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 16px var(--gutter);
  transition: background 0.3s var(--ease), backdrop-filter 0.3s var(--ease), border-color 0.3s var(--ease);
  border-bottom: 1px solid transparent;
}
.topbar.scrolled {
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: saturate(1.4) blur(16px);
  border-bottom-color: var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: "Montserrat", sans-serif;
  font-weight: 700;
  font-size: 23px;
  letter-spacing: -0.02em;
}
.brand .dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--accent-2), var(--accent));
  box-shadow: 0 0 14px 1px rgba(30, 144, 255, 0.8);
}
.brand b {
  background: linear-gradient(100deg, #fff 10%, var(--accent-2) 60%, var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.nav { display: flex; gap: 22px; }
.nav a {
  color: var(--text-dim);
  font-weight: 500;
  font-size: 15px;
  padding: 6px 2px;
  position: relative;
  transition: color 0.2s var(--ease);
}
.nav a:hover, .nav a.active { color: var(--text); }
.nav a.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 2px;
}
.topbar .spacer { flex: 1; }
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: rgba(18, 26, 40, 0.8);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  width: 42px;
  overflow: hidden;
  transition: width 0.32s var(--ease), border-color 0.2s var(--ease);
}
.search-box:focus-within, .search-box.open { width: min(320px, 46vw); border-color: var(--accent); }
.search-box svg { flex: none; width: 18px; height: 18px; color: var(--text-dim); }
.search-box input {
  flex: 1; min-width: 0; background: none; border: none; color: var(--text);
  font-size: 15px; outline: none;
}
.search-box input::placeholder { color: var(--text-faint); }
.avatar {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  background: linear-gradient(135deg, var(--accent), #0b63c4);
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.14);
}
.icon-btn { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: var(--text-dim); transition: color .2s, background .2s; }
.icon-btn:hover { color: var(--text); background: var(--surface); }

/* ---------- hero ---------- */
.hero { position: relative; height: min(84vh, 760px); min-height: 520px; isolation: isolate; }
.hero-slide {
  position: absolute; inset: 0;
  background-size: cover; background-position: center top;
  opacity: 0; transition: opacity 0.9s var(--ease);
}
.hero-slide.active { opacity: 1; }
.hero::after {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(0, 0, 0,0.95) 0%, rgba(0, 0, 0,0.55) 38%, rgba(0, 0, 0,0) 70%),
    linear-gradient(0deg, var(--bg) 2%, rgba(0, 0, 0,0.2) 42%, rgba(0, 0, 0,0.35) 100%);
}
.hero-inner {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; justify-content: flex-end;
  max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter) clamp(44px, 9vh, 96px);
}
.hero-tag { font-family: "Montserrat"; color: var(--accent-2); font-weight: 600; letter-spacing: 0.02em; margin-bottom: 14px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.hero-title {
  font-family: "Montserrat", sans-serif;
  font-weight: 700; letter-spacing: -0.03em; line-height: 0.98;
  font-size: clamp(38px, 6.5vw, 86px);
  max-width: 15ch; margin: 0 0 18px;
  text-shadow: 0 6px 40px rgba(0,0,0,0.5);
}
.hero-meta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; color: var(--text-dim); font-weight: 500; margin-bottom: 16px; }
.hero-overview { max-width: 54ch; color: #cdd7e4; line-height: 1.55; font-size: clamp(15px, 1.3vw, 17px); margin-bottom: 26px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; }

.pill { display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px; border-radius: 999px; font-size: 13px; font-weight: 600; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.1); }
.pill.rating { color: var(--gold); }
.chip { color: var(--text-dim); font-size: 14px; }
.chip + .chip::before { content: "•"; margin-right: 14px; color: var(--text-faint); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 13px 26px; border-radius: 11px; font-weight: 600; font-size: 16px;
  transition: transform 0.14s var(--ease), box-shadow 0.2s var(--ease), background 0.2s var(--ease);
}
.btn svg { width: 20px; height: 20px; }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn-primary { background: linear-gradient(180deg, #ffffff, #e6eef7); color: #0a0e14; box-shadow: 0 10px 30px -12px rgba(255,255,255,0.4); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 16px 36px -12px rgba(255,255,255,0.55); }
.btn-ghost { background: rgba(26,36,54,0.72); color: var(--text); border: 1px solid var(--line); backdrop-filter: blur(6px); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--accent); }
.btn-accent { background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: #fff; box-shadow: 0 14px 34px -14px rgba(30,144,255,0.8); }
.btn-accent:hover { transform: translateY(-1px); }

/* ---------- rows ---------- */
.rows { position: relative; z-index: 3; margin-top: -8vh; padding-bottom: 80px; display: flex; flex-direction: column; gap: 36px; }
.row-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 0 14px; padding: 0 var(--gutter); max-width: var(--maxw); margin-inline: auto; }
.row-title { font-family: "Montserrat", sans-serif; font-weight: 600; font-size: clamp(18px, 2vw, 23px); letter-spacing: -0.01em; }
.row-wrap { position: relative; }
.track {
  display: flex; gap: 14px; overflow-x: auto; scroll-behavior: smooth;
  padding: 10px var(--gutter) 22px; max-width: var(--maxw); margin: 0 auto;
  scrollbar-width: none;
}
.track::-webkit-scrollbar { display: none; }
.rail-btn {
  position: absolute; top: 0; bottom: 32px; width: 56px; z-index: 5;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(90deg, rgba(0, 0, 0,0.9), transparent);
  opacity: 0; transition: opacity 0.2s var(--ease);
}
.rail-btn.right { right: 0; transform: scaleX(-1); }
.row-wrap:hover .rail-btn { opacity: 1; }
.rail-btn svg { width: 30px; height: 30px; }

.card {
  position: relative; flex: 0 0 auto; width: clamp(130px, 15vw, 176px);
  border-radius: var(--radius); overflow: hidden; cursor: pointer;
  background: var(--surface); box-shadow: var(--shadow-card);
  transition: transform 0.26s var(--ease), box-shadow 0.26s var(--ease);
  aspect-ratio: 2 / 3;
}
.card.wide { width: clamp(240px, 26vw, 320px); aspect-ratio: 16 / 9; }
.card img { width: 100%; height: 100%; object-fit: cover; }
.card:hover { transform: translateY(-6px) scale(1.05); box-shadow: var(--glow); z-index: 4; }
.card .fallback { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 14px; gap: 8px; background: linear-gradient(160deg, var(--surface-2), var(--surface)); }
.card .fallback span { font-family: "Montserrat"; font-weight: 600; font-size: 15px; line-height: 1.2; }
.card .fallback small { color: var(--text-faint); }
.card-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end;
  padding: 12px; gap: 6px; opacity: 0;
  background: linear-gradient(0deg, rgba(0, 0, 0,0.94) 6%, rgba(0, 0, 0,0.2) 48%, transparent);
  transition: opacity 0.24s var(--ease);
}
.card:hover .card-overlay { opacity: 1; }
.card-overlay .t { font-weight: 600; font-size: 14px; line-height: 1.2; }
.card-overlay .m { font-size: 12px; color: var(--text-dim); display: flex; gap: 8px; align-items: center; }
.card .play-badge { align-self: flex-start; width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,0.95); color: #0a0e14; display: grid; place-items: center; margin-bottom: 4px; }
.card .play-badge svg { width: 16px; height: 16px; }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255,255,255,0.18); z-index: 3; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.resume-badge { position: absolute; top: 10px; left: 10px; z-index: 3; background: rgba(0, 0, 0,0.8); border: 1px solid var(--line); padding: 3px 8px; border-radius: 7px; font-size: 11px; font-weight: 600; }

/* ---------- detail ---------- */
.detail-hero { position: relative; min-height: 70vh; padding-top: 0; }
.detail-bg { position: absolute; inset: 0; background-size: cover; background-position: center; }
.detail-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0, 0, 0,0.95), rgba(0, 0, 0,0.5) 55%, rgba(0, 0, 0,0.2)), linear-gradient(0deg, var(--bg), transparent 55%); }
.detail-inner { position: relative; z-index: 2; display: flex; gap: 40px; align-items: flex-end; padding: 150px var(--gutter) 40px; max-width: var(--maxw); margin: 0 auto; }
.detail-poster { flex: 0 0 auto; width: 240px; aspect-ratio: 2/3; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-card); border: 1px solid var(--line); }
.detail-body { flex: 1; min-width: 0; }
.detail-body h1 { font-family: "Montserrat"; font-weight: 700; letter-spacing: -0.03em; font-size: clamp(32px, 4.6vw, 60px); margin: 0 0 8px; line-height: 1; }
.detail-tagline { color: var(--accent-2); font-style: italic; margin-bottom: 16px; }
.detail-overview { max-width: 70ch; line-height: 1.65; color: #cdd7e4; margin: 18px 0 26px; }
.genres { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

.section { padding: 10px var(--gutter) 0; max-width: var(--maxw); margin: 0 auto; }
.section h2 { font-family: "Montserrat"; font-weight: 600; font-size: 22px; margin: 36px 0 16px; }
.cast { display: grid; grid-auto-flow: column; grid-auto-columns: 128px; gap: 16px; overflow-x: auto; padding-bottom: 12px; scrollbar-width: none; }
.cast::-webkit-scrollbar { display: none; }
.cast figure { margin: 0; text-align: center; }
.cast img, .cast .noface { width: 108px; height: 108px; border-radius: 50%; object-fit: cover; margin: 0 auto 10px; border: 1px solid var(--line); }
.cast .noface { display: grid; place-items: center; background: var(--surface-2); color: var(--text-faint); font-family: "Montserrat"; font-size: 28px; }
.cast .nm { font-weight: 600; font-size: 13px; }
.cast .ch { color: var(--text-dim); font-size: 12px; }

.season-tabs { display: flex; gap: 8px; margin: 10px 0 20px; flex-wrap: wrap; }
.season-tabs button { padding: 8px 16px; border-radius: 9px; background: var(--surface); border: 1px solid var(--line); color: var(--text-dim); font-weight: 600; transition: all .2s; }
.season-tabs button.active { color: #fff; border-color: var(--accent); background: var(--surface-2); }
.ep-list { display: flex; flex-direction: column; gap: 10px; }
.ep {
  display: grid; grid-template-columns: 180px 1fr auto; gap: 18px; align-items: center;
  padding: 12px; border-radius: 12px; border: 1px solid transparent; background: var(--surface);
  transition: border-color .2s, background .2s; cursor: pointer;
}
.ep:hover { border-color: var(--accent); background: var(--surface-2); }
.ep-thumb { position: relative; aspect-ratio: 16/9; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.ep-thumb .num { position: absolute; inset: 0; display: grid; place-items: center; font-family: "Montserrat"; font-size: 30px; color: var(--text-faint); }
.ep-thumb .pbar { position: absolute; bottom: 0; left: 0; right: 0; height: 4px; background: rgba(255,255,255,0.2); }
.ep-thumb .pbar > i { display: block; height: 100%; background: var(--accent); }
.ep-info h4 { margin: 0 0 4px; font-size: 16px; }
.ep-info p { margin: 0; color: var(--text-dim); font-size: 14px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ep .go { color: var(--text-dim); }
.ep:hover .go { color: var(--accent-2); }

/* ---------- player ---------- */
.player { position: fixed; inset: 0; z-index: 200; background: #000; display: flex; }
.player video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.player-ui { position: absolute; inset: 0; opacity: 1; transition: opacity 0.4s var(--ease); }
.player-ui.hidden { opacity: 0; cursor: none; }
.player-top { position: absolute; top: 0; left: 0; right: 0; padding: 22px var(--gutter); display: flex; align-items: center; gap: 16px; background: linear-gradient(180deg, rgba(0,0,0,0.75), transparent); }
.player-top .title { font-family: "Montserrat"; font-weight: 600; font-size: 19px; }
.player-top .sub { color: var(--text-dim); font-size: 14px; }
.player-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 var(--gutter) 24px; background: linear-gradient(0deg, rgba(0,0,0,0.85), transparent); }
.seek { position: relative; height: 18px; display: flex; align-items: center; cursor: pointer; margin-bottom: 8px; }
.seek .bar { position: relative; height: 5px; width: 100%; border-radius: 999px; background: rgba(255,255,255,0.22); overflow: hidden; }
.seek .buffered { position: absolute; inset: 0; background: rgba(255,255,255,0.28); width: 0; }
.seek .played { position: absolute; inset: 0; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.seek .knob { position: absolute; top: 50%; width: 15px; height: 15px; border-radius: 50%; background: #fff; transform: translate(-50%, -50%) scale(0); transition: transform .15s; box-shadow: 0 0 10px rgba(30,144,255,0.8); }
.seek:hover .bar { height: 7px; }
.seek:hover .knob { transform: translate(-50%, -50%) scale(1); }
.controls { display: flex; align-items: center; gap: 18px; }
.controls .time { font-variant-numeric: tabular-nums; color: var(--text-dim); font-size: 14px; }
.controls .grow { flex: 1; }
.pbtn { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; color: #fff; transition: background .2s, transform .15s; }
.pbtn:hover { background: rgba(255,255,255,0.14); }
.pbtn.big { width: 52px; height: 52px; }
.pbtn svg { width: 24px; height: 24px; }
.pbtn.big svg { width: 30px; height: 30px; }
.vol { display: flex; align-items: center; gap: 8px; }
.vol input { width: 0; opacity: 0; transition: width .25s, opacity .25s; accent-color: var(--accent); }
.vol:hover input { width: 92px; opacity: 1; }
.resume-toast { position: absolute; bottom: 120px; left: var(--gutter); background: rgba(13,19,32,0.95); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; display: flex; gap: 14px; align-items: center; box-shadow: var(--shadow-card); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(410px, 100%); background: rgba(13,19,32,0.7); border: 1px solid var(--line); border-radius: 20px; padding: 40px 34px; backdrop-filter: blur(18px); box-shadow: 0 40px 90px -30px rgba(0,0,0,0.9); }
.login-card .brand { font-size: 30px; justify-content: center; margin-bottom: 8px; }
.login-card p { text-align: center; color: var(--text-dim); margin: 0 0 26px; }
.field { position: relative; margin-bottom: 16px; }
.field input { width: 100%; padding: 15px 16px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); color: var(--text); font-size: 16px; outline: none; transition: border-color .2s, box-shadow .2s; }
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(30,144,255,0.14); }
.login .btn-accent { width: 100%; }
.login .err { color: var(--danger); font-size: 14px; text-align: center; min-height: 20px; margin-top: 12px; }

/* ---------- misc ---------- */
.content { padding-top: 90px; min-height: 60vh; }
.empty { display: grid; place-items: center; text-align: center; min-height: 60vh; padding: 40px; gap: 14px; }
.empty .ic { width: 68px; height: 68px; border-radius: 20px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); color: var(--accent-2); }
.empty h2 { font-family: "Montserrat"; margin: 6px 0 0; }
.empty p { color: var(--text-dim); max-width: 44ch; line-height: 1.6; margin: 0; }
.empty code { background: var(--surface); padding: 2px 7px; border-radius: 6px; border: 1px solid var(--line); font-size: 13px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; padding: 10px var(--gutter) 60px; max-width: var(--maxw); margin: 0 auto; }
.grid .card { width: 100%; }

.skeleton { background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%); background-size: 220% 100%; animation: shimmer 1.4s infinite linear; border-radius: var(--radius); }
.sk-card { flex: 0 0 auto; width: clamp(130px, 15vw, 176px); aspect-ratio: 2/3; }
@keyframes shimmer { to { background-position: -220% 0; } }

.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px); z-index: 300; background: var(--surface-2); border: 1px solid var(--line); border-left: 3px solid var(--accent); padding: 13px 18px; border-radius: 12px; box-shadow: var(--shadow-card); opacity: 0; transition: all .3s var(--ease); font-weight: 500; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-left-color: var(--danger); }

.spin { width: 42px; height: 42px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: rot 0.8s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
.center { display: grid; place-items: center; min-height: 70vh; }

@media (max-width: 860px) {
  .nav { display: none; }
  .detail-inner { flex-direction: column; align-items: flex-start; gap: 22px; padding-top: 120px; }
  .detail-poster { width: 150px; }
  .ep { grid-template-columns: 130px 1fr; }
  .ep .go { display: none; }
  .hero { min-height: 72vh; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
  .card:hover { transform: none; }
}
