:root {
  --bg: #0f1218;
  --surface: #171b24;
  --line: #262c39;
  --text: #edf0f5;
  --muted: #98a2b5;
  --amber: #ffb547;
  --radius: 10px;
  --gutter: max(24px, calc((100vw - 1400px) / 2 + 24px));
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 "Bricolage Grotesque", system-ui, sans-serif;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* ── Top bar (both pages) ────────────────────────────────── */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 28px;
  padding: 14px var(--gutter);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 20px; letter-spacing: -0.02em; color: var(--text); text-decoration: none; }
.back { margin-left: auto; color: var(--muted); text-decoration: none; padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px; }
.back:hover { color: var(--text); border-color: var(--muted); }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; }
.tabs button {
  background: none; border: 0; padding: 6px 12px; border-radius: 6px; color: var(--muted);
}
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--text); font-weight: 600; box-shadow: inset 0 -2px 0 var(--amber); border-radius: 0; }
.search { margin-left: auto; position: relative; }
.suggest {
  position: absolute; right: 0; top: calc(100% + 8px); width: min(400px, 92vw); padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, .5);
}
.sug { display: flex; align-items: center; gap: 12px; width: 100%; padding: 6px; border: 0; border-radius: 8px; background: none; color: inherit; text-align: left; text-decoration: none; }
.sug:hover, .sug.on { background: var(--bg); }
.sug img, .sug .ph { flex: none; width: 40px; height: 60px; border-radius: 5px; object-fit: cover; background: var(--bg); }
.sug .txt { min-width: 0; }
.sug strong { display: block; font-weight: 600; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sug .txt span { color: var(--muted); font-size: 14px; }
.sug.all { justify-content: center; padding: 10px; color: var(--amber); font-weight: 600; }
.search input {
  width: min(260px, 40vw); padding: 8px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
}
.search input::placeholder { color: var(--muted); }

/* ── Browse page ─────────────────────────────────────────── */
.browse, .watch { padding: 28px 24px 64px; max-width: 1400px; margin: 0 auto; }
.heading { margin: 0 0 20px; font-size: clamp(28px, 4vw, 44px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.note { color: var(--muted); margin: 0 0 20px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 22px 16px; }
.card { display: block; align-self: start; color: inherit; text-decoration: none; }
.card .art {
  position: relative; aspect-ratio: 2 / 3; overflow: hidden;
  background: var(--surface); border-radius: var(--radius);
}
.card img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s; }
.card:hover img, .card:focus-visible img { transform: scale(1.04); }
.card .rate {
  position: absolute; left: 8px; bottom: 8px; padding: 1px 8px;
  background: rgba(15, 18, 24, .85); border-radius: 999px; font-size: 13px; color: var(--amber); font-weight: 600;
}
.card .name {
  display: -webkit-box; margin-top: 8px; font-weight: 600; line-height: 1.25;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; /* long titles don't stretch the whole row */
}
.card .prog { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, .25); }
.card .prog::after { content: ""; display: block; width: var(--pct); height: 100%; background: var(--amber); }
.card .sub { display: block; color: var(--muted); font-size: 14px; }

/* Home hero: the site's Featured titles */
.hero {
  position: relative; display: flex; align-items: flex-end; min-height: clamp(320px, 52vh, 520px); margin-bottom: 40px;
  overflow: hidden; border-radius: 16px; background: var(--surface);
}
.hero-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 20%; }
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(to top, var(--bg) 2%, rgba(15, 18, 24, .55) 45%, transparent 75%),
              linear-gradient(to right, rgba(15, 18, 24, .85), transparent 65%);
}
.hero-body { position: relative; z-index: 2; max-width: 560px; padding: 40px; }
.hero-bg, .hero-body { transition: opacity .3s; }
.hero.fading .hero-bg, .hero.fading .hero-body { opacity: 0; }
.hero-kind { color: var(--amber); font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.hero h1 { margin: 6px 0 8px; font-size: clamp(30px, 4.6vw, 54px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.02; }
.hero-facts { display: flex; gap: 14px; margin: 0 0 10px; color: #d3d8e2; font-size: 15px; }
.hero-ov {
  margin: 0 0 20px; color: #d3d8e2;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.hero-play {
  display: inline-block; padding: 11px 26px; border-radius: 999px; background: var(--amber); color: #1a1205;
  font-weight: 700; text-decoration: none; transition: transform .15s;
}
.hero-play:hover { transform: translateY(-1px); }
.hero-dots { position: absolute; right: 24px; bottom: 24px; z-index: 2; display: flex; gap: 6px; }
.hero-dots button { width: 8px; height: 8px; padding: 0; border: 0; border-radius: 999px; background: rgba(255, 255, 255, .35); transition: width .2s; }
.hero-dots button.on { width: 24px; background: #fff; }

/* Home sections: a heading, arrow buttons, and one line of cards that scrolls sideways with no visible scrollbar */
.row { margin-bottom: 38px; }
.row-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.row h2 { margin: 0; font-size: clamp(20px, 2.4vw, 26px); font-weight: 800; letter-spacing: -0.02em; }
.row-nav { display: flex; gap: 6px; }
.row-nav button { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 50%; color: var(--text); }
.row-nav button:hover:not(:disabled) { border-color: var(--muted); }
.row-nav button:disabled { opacity: .35; cursor: default; }
.rail { display: flex; gap: 16px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; -ms-overflow-style: none; }
.rail::-webkit-scrollbar { display: none; }
.rail { cursor: grab; }
.rail.dragging { cursor: grabbing; scroll-snap-type: none; user-select: none; } /* snapping would fight the drag */
.rail .card { flex: 0 0 150px; scroll-snap-align: start; }
.card.wide .art { aspect-ratio: 16 / 9; }
.card.wide .rate.ep { top: 8px; bottom: auto; }
.card.wide .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail .card.wide { flex-basis: 300px; }
.row .note { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip { padding: 7px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; }
.chip:hover { border-color: var(--muted); }
.chip.on { background: var(--amber); border-color: var(--amber); color: #1a1205; font-weight: 600; }
.card .rate.ep { color: #fff; }

/* Collections: wide franchise cards, then one collection's banner + a grid per section */
.cgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.ccard {
  position: relative; display: flex; align-items: flex-end; aspect-ratio: 16 / 9; overflow: hidden;
  border-radius: var(--radius); background: var(--surface); color: inherit; text-decoration: none;
}
.ccard img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.ccard::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(10, 12, 16, .92), transparent 60%); }
.ccard:hover img, .ccard:focus-visible img { transform: scale(1.04); }
.ccard-txt { position: relative; z-index: 1; padding: 14px 16px; }
.ccard-txt strong { display: block; font-size: 18px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.2; }
.ccard-txt span { color: #c7cdd8; font-size: 14px; }
.crumb { display: inline-block; margin-bottom: 16px; color: var(--muted); text-decoration: none; }
.crumb:hover { color: var(--text); }
.chero { min-height: clamp(260px, 40vh, 420px); }
.csec { margin-bottom: 40px; }
.csec h2 { margin: 0 0 16px; font-size: clamp(20px, 2.4vw, 26px); font-weight: 800; letter-spacing: -0.02em; }

.more {
  display: block; margin: 36px auto 0; padding: 10px 28px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
}
.more:hover { border-color: var(--muted); }

/* ── Watch page ──────────────────────────────────────────── */
.watch { padding-top: 20px; }

/* Player: as wide as the page allows, but never taller than the window. */
.stage {
  display: grid; aspect-ratio: 16 / 9; width: min(100%, calc(78vh * 16 / 9)); margin: 0 auto;
  background: #000; border-radius: 12px; overflow: hidden;
}
/* position: relative keeps stacking in DOM order — the filtered backdrop would otherwise paint over the rest. */
.stage > * { grid-area: 1 / 1; min-width: 0; min-height: 0; position: relative; }
.frame { width: 100%; height: 100%; object-fit: cover; filter: brightness(.5); }
.stage video { width: 100%; height: 100%; background: #000; }
.wait {
  display: grid; place-content: center; text-align: center; gap: 4px;
  background: radial-gradient(circle at 50% 45%, #1d2330, #05070a);
}
.spinner { justify-self: center; width: 56px; height: 56px; border: 5px solid rgba(255, 255, 255, .14); border-top-color: var(--amber); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.wait p { margin: 14px 0 0; color: var(--muted); }

.play {
  place-self: center; padding: 14px 48px; background: var(--amber); color: #1a1205;
  border: 0; border-radius: 999px; font-weight: 800; font-size: 19px;
}
.play:hover { filter: brightness(1.08); }
.play:disabled { opacity: .55; cursor: wait; }
.error { color: #ff8f8f; margin: 14px 0 0; }

/* ── Player: control bar, settings menu, captions (see player.js) ─────────── */
.stage { position: relative; }
.stage:fullscreen { width: 100%; border-radius: 0; }
.stage.idle { cursor: none; }
body.pip { margin: 0; background: #000; overflow: hidden; }
.pip .stage { width: 100vw; height: 100vh; aspect-ratio: auto; border-radius: 0; }
.stage > .captions, .stage > .controls, .stage > .menu { position: absolute; }

.controls {
  left: 0; right: 0; bottom: 0; padding: 32px 14px 8px; color: #fff;
  background: linear-gradient(to top, rgba(0, 0, 0, .78), transparent); transition: opacity .2s;
}
.stage.idle > .controls { opacity: 0; pointer-events: none; }
.crow { display: flex; align-items: center; gap: 4px; }
.grow { flex: 1; }
.cbtn { display: grid; place-items: center; padding: 6px; background: none; border: 0; border-radius: 8px; color: inherit; }
.cbtn:hover { background: rgba(255, 255, 255, .16); }
.ico { display: inline-grid; }
.ico svg { width: 24px; height: 24px; display: block; }
.time { margin-left: 8px; font-size: 14px; font-variant-numeric: tabular-nums; color: #e6e9f0; }

/* Seek preview: frame + time above the pointer (player.js) */
.preview {
  position: absolute; bottom: calc(100% - 22px); transform: translateX(-50%); width: min(200px, 40%);
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.preview video { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: #000; border: 2px solid #fff; border-radius: 10px; }
.ptime { padding: 4px 12px; border-radius: 999px; background: rgba(0, 0, 0, .6); font-size: 14px; font-variant-numeric: tabular-nums; }

.seek, .vol { -webkit-appearance: none; appearance: none; margin: 0; height: 18px; background: transparent; cursor: pointer; }
.seek { display: block; width: 100%; }
.vol { width: 70px; }
.seek::-webkit-slider-runnable-track, .vol::-webkit-slider-runnable-track {
  height: 5px; border-radius: 3px;
  background: linear-gradient(to right, var(--amber) var(--pct, 0%), rgba(255, 255, 255, .28) var(--pct, 0%));
}
.seek::-moz-range-track, .vol::-moz-range-track {
  height: 5px; border-radius: 3px;
  background: linear-gradient(to right, var(--amber) var(--pct, 0%), rgba(255, 255, 255, .28) var(--pct, 0%));
}
.seek::-webkit-slider-thumb, .vol::-webkit-slider-thumb { -webkit-appearance: none; width: 13px; height: 13px; margin-top: -4px; border-radius: 50%; background: #fff; border: 0; }
.seek::-moz-range-thumb, .vol::-moz-range-thumb { width: 13px; height: 13px; border-radius: 50%; background: #fff; border: 0; }

/* Settings menu */
.menu {
  right: 12px; bottom: 70px; width: min(310px, calc(100% - 24px)); max-height: calc(100% - 90px); overflow-y: auto; padding: 6px;
  background: rgba(28, 30, 36, .97); border: 1px solid rgba(255, 255, 255, .08); border-radius: 12px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .55); color: #fff;
}
.mrow { display: flex; align-items: center; gap: 14px; width: 100%; padding: 10px 12px; background: none; border: 0; border-radius: 8px; color: inherit; text-align: left; font-size: 16px; }
.mrow:hover, .mrow:focus-visible { background: rgba(255, 255, 255, .12); }
.mrow .ico svg { width: 22px; height: 22px; }
.mrow .lbl { flex: 1; white-space: nowrap; }
.mrow .val { color: #d3d8e2; font-size: 14px; white-space: nowrap; }
.mrow > .ico:last-child svg { width: 18px; height: 18px; }
.mrow.back { margin-bottom: 4px; padding-bottom: 12px; border-bottom: 1px solid rgba(255, 255, 255, .1); border-radius: 8px 8px 0 0; font-weight: 600; }
.mrow.opt .chk { display: grid; place-items: center; width: 22px; color: var(--amber); }
.mrow.opt.on { font-weight: 600; }

/* Captions are drawn by the player, so size / position / style below are ours to control. */
.captions {
  left: 6%; right: 6%; bottom: calc(6% + var(--cap-lift, 0%)); display: flex; flex-direction: column; align-items: center;
  text-align: center; line-height: 1.35; white-space: pre-line; pointer-events: none; transition: transform .2s;
}
.stage:not(.idle) > .captions { transform: translateY(-58px); } /* clear the control bar while it's showing */
.cue { margin-top: 3px; }
.cap-default .cue { padding: .05em .4em; border-radius: .2em; background: rgba(0, 0, 0, .72); color: #fff; }
.cap-solid-box .cue { padding: .05em .4em; background: #000; color: #fff; }
.cap-yellow .cue { color: #ffe14d; text-shadow: 0 0 4px #000, 0 1px 3px #000, 1px 1px 2px #000; }
.cap-outline .cue { color: #fff; text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000, 0 0 6px #000; }

.info { display: grid; grid-template-columns: 200px 1fr; gap: 28px; margin-top: 28px; }
.poster { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: var(--radius); background: var(--surface); }
.meta h1 { margin: 0 0 8px; font-size: clamp(26px, 4vw, 38px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.facts { display: flex; flex-wrap: wrap; gap: 4px 18px; color: var(--muted); margin-bottom: 14px; }
.overview { max-width: 62ch; margin: 0 0 14px; }
.genres { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.genres span { padding: 2px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 14px; color: var(--muted); }

.picker label { color: var(--muted); }
.picker select { margin-left: 8px; padding: 6px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.eps { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.eps button { min-width: 44px; padding: 6px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.eps button:hover { border-color: var(--muted); }
.eps button.on { background: var(--amber); border-color: var(--amber); color: #1a1205; font-weight: 600; }

/* Cast + more like this */
.block { margin-top: 44px; }
.block h2 { margin: 0 0 16px; font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.cast { display: flex; flex-wrap: wrap; gap: 20px 18px; }
.person { flex: 0 0 104px; margin: 0; text-align: center; }
.person img, .person .initial { width: 104px; height: 104px; border-radius: 50%; object-fit: cover; background: var(--surface); }
.person .initial { display: grid; place-items: center; font-size: 34px; font-weight: 800; color: var(--muted); }
.person figcaption { margin-top: 8px; line-height: 1.25; }
.person strong { display: block; font-weight: 600; font-size: 15px; }
.person span { display: block; color: var(--muted); font-size: 13px; }

/* ── Skeletons: grey blocks the size of what's loading, with a soft shimmer ─── */
.skel .art, .card.skel .name, .card.skel .sub, .hero.skel, .ccard.skel,
.info.loading .poster, .info.loading h1, .info.loading .overview {
  background: linear-gradient(100deg, var(--surface) 40%, #212634 50%, var(--surface) 60%) 0 0 / 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
.card.skel .name { height: 1em; margin-top: 10px; border-radius: 4px; width: 80%; }
.card.skel .sub { height: .8em; margin-top: 6px; border-radius: 4px; width: 40%; }
.card.skel { pointer-events: none; }
.hero.skel { min-height: clamp(320px, 52vh, 520px); }
.info.loading h1 { width: min(60%, 360px); height: 1.1em; border-radius: 6px; }
.info.loading .overview { height: 4.5em; border-radius: 6px; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 720px) {
  .bar { flex-wrap: wrap; gap: 10px 16px; padding: 12px 16px; }
  .search { order: 3; margin-left: 0; flex: 1 1 100%; }
  .search input { width: 100%; }
  .suggest { left: 0; right: 0; width: auto; }
  .browse, .watch { padding: 20px 16px 48px; }
  .info { grid-template-columns: 96px 1fr; gap: 16px; margin-top: 20px; }
  .hero { border-radius: 12px; min-height: 360px; margin-bottom: 28px; }
  .hero-body { padding: 22px 18px 44px; }
  .hero-dots { left: 18px; right: auto; bottom: 18px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 18px 12px; }
  .rail .card { flex-basis: 124px; }
  .rail .card.wide { flex-basis: 240px; }
  .tabs { max-width: 100%; }
  #extra .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-right: -16px; padding-right: 16px; }
  #extra .chips .chip { flex: none; }
  .cgrid { grid-template-columns: 1fr; }
  .stage { border-radius: 8px; }
}

/* Touch screens swipe; every mouse keeps the arrows, whatever the window width. */
@media (hover: none) {
  .row-nav { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
