/* ============================================================================
   Dracinkita — design system
   ============================================================================
   Mobile-first. No build step, no framework, no utility classes.

   The world: a late-night cinema on your phone. Poster art is the content and
   the chrome recedes. One accent, expressed as a gradient, used only for
   brand, primary actions, rank numerals and progress — never as decoration.

   Contrast is checked, not assumed: --accent on --bg is 5.7:1, the action
   gradient carries white text at 4.7–5.2:1, --fg-3 (the lightest label) is
   5.9:1. The vivid pink/orange (#ff3d5a → #ff7a3d) is kept for glows and
   gradients WITHOUT text; anything white-on-fill uses the deeper --grad.
   ========================================================================= */

:root {
  /* surfaces — near-black, warmed a touch toward the accent */
  --bg:        #060609;
  --surface:   #0f0f15;
  --surface-2: #17171e;
  --surface-3: #22222b;

  /* lines */
  --line:      #23232c;
  --line-soft: #1a1a21;

  /* text */
  --fg:        #f3f3f6;
  --fg-2:      #b6b6c2;
  --fg-3:      #8b8b98;

  /* one accent family */
  --accent:     #ff3d5a;
  --accent-2:   #ff7a3d;
  --accent-ink: #ffffff;
  --accent-bg:  rgba(255, 61, 90, .13);
  --accent-line: rgba(255, 122, 61, .34);
  --grad:      linear-gradient(135deg, #e11d48, #c2410c);   /* text-bearing  */
  --grad-hot:  linear-gradient(135deg, #ff3d5a, #ff7a3d);   /* decoration    */

  /* geometry */
  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;
  --r-full: 999px;

  /* the player's ad strip; 0px until a 320x50 creative actually renders */
  --pl-ad-h: 0px;

  /* rhythm */
  --gutter: 16px;
  --hdr-h: 56px;

  --ease: cubic-bezier(.4, 0, .2, 1);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }

/* --- browser surfaces belong to the design too -------------------------- */
::selection { background: rgba(255, 61, 90, .32); color: #fff; }
* { caret-color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* page scrollbar */
html { scrollbar-color: #2a2a34 transparent; scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a2a34; border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #39394a; }

/* accessible-but-invisible */
.sr {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ============================================================================
   HEADER
   ========================================================================= */

.hdr {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s var(--ease), background .2s var(--ease);
  padding-top: var(--safe-t);
}
.hdr.scrolled { border-bottom-color: var(--line-soft); }

.hdr-in {
  display: flex; flex-direction: column; gap: 10px;
  padding: 10px var(--gutter) 12px;
  max-width: 1400px; margin: 0 auto;
}
.hdr-top {
  display: flex; align-items: center; gap: 12px;
  height: 36px;
}

.logo {
  display: inline-flex; align-items: center; gap: 7px;
  min-width: 0; flex-shrink: 1;
}
.logo-mark {
  width: 28px; height: 28px; flex-shrink: 0;
  border-radius: 9px;
  background: var(--grad);
  display: grid; place-items: center;
  box-shadow: 0 4px 14px rgba(255, 61, 90, .42);
}
.logo-mark svg { width: 13px; height: 13px; fill: #fff; transform: translateX(1px); }
.logo-word {
  font-size: 17px; font-weight: 800; letter-spacing: -.035em;
  white-space: nowrap;
  min-width: 0; overflow: hidden; text-overflow: ellipsis;
}
.logo-word em { font-style: normal; color: var(--accent); }

.hdr-nav { display: flex; gap: 0; margin-left: auto; flex-shrink: 0; }
.hdr-nav a {
  padding: 7px 9px; border-radius: var(--r-full);
  font-size: 13px; font-weight: 600; color: var(--fg-2);
  white-space: nowrap;
  transition: color .15s var(--ease), background .15s var(--ease);
}
.hdr-nav a:hover { color: var(--fg); background: var(--surface); }
.hdr-nav a.active { color: var(--fg); background: var(--surface-2); }

.searchwrap { position: relative; width: 100%; }

.searchbox {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  height: 42px; padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-full);
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.searchbox:focus-within {
  background: var(--surface-2);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}
.searchbox .ico {
  width: 18px; height: 18px; flex-shrink: 0;
  fill: none; stroke: var(--fg-3); stroke-width: 2;
  stroke-linecap: round;
}
.searchbox input {
  flex: 1; min-width: 0;
  background: none; border: 0; outline: 0;
  color: var(--fg); font-size: 16px; /* 16px stops iOS zoom-on-focus */
}
.searchbox input::placeholder { color: var(--fg-3); }
.searchbox input::-webkit-search-cancel-button { display: none; }
.searchbox .clr {
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; flex-shrink: 0;
  background: var(--surface-3); border: 0; border-radius: var(--r-full);
  cursor: pointer; padding: 0;
}
.searchbox .clr svg {
  width: 12px; height: 12px;
  fill: none; stroke: var(--fg-2); stroke-width: 2.5; stroke-linecap: round;
}

/* ---------- recent searches dropdown ---------- */
.recent {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 60;
  background: var(--surface-2);
  border-radius: var(--r);
  box-shadow: 0 16px 40px rgba(0,0,0,.55);
  overflow: hidden;
  padding: 6px;
}
.recent[hidden] { display: none; }
.recent-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px 8px;
  font-size: 12px; font-weight: 600; color: var(--fg-3);
  text-transform: uppercase; letter-spacing: .05em;
}
.recent-hd button {
  background: none; border: 0; padding: 2px 4px; cursor: pointer;
  color: var(--accent); font-size: 12px; font-weight: 600;
  text-transform: none; letter-spacing: 0;
}
.recent-row {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px;
  background: none; border: 0; border-radius: var(--r-sm);
  color: var(--fg); font-size: 14px; text-align: left; cursor: pointer;
}
.recent-row:hover { background: var(--surface-3); }
.recent-row svg {
  width: 15px; height: 15px; flex-shrink: 0;
  fill: none; stroke: var(--fg-3); stroke-width: 2; stroke-linecap: round;
}
.recent-row .q { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-row .x {
  width: 24px; height: 24px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-full); color: var(--fg-3);
}
.recent-row .x:hover { background: var(--surface); color: var(--fg); }
.recent-row .x svg { width: 11px; height: 11px; stroke-width: 2.5; }

/* ============================================================================
   LAYOUT
   ========================================================================= */

.app { padding-bottom: 40px; min-height: 60vh; outline: none; }
.wrap { max-width: 1400px; margin: 0 auto; padding: 0 var(--gutter); }

/* ============================================================================
   BUTTONS
   ========================================================================= */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 20px;
  border: 0; border-radius: var(--r);
  background: var(--grad); color: var(--accent-ink);
  font-size: 15px; font-weight: 700; letter-spacing: -.01em;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(225, 29, 72, .35);
  transition: transform .12s var(--ease), filter .15s var(--ease);
}
.btn:hover  { filter: brightness(1.08); }
.btn:active { transform: scale(.97); }
.btn svg { width: 18px; height: 18px; fill: currentColor; }

.btn--ghost {
  background: rgba(255, 255, 255, .07); color: var(--fg);
  border: 1px solid var(--surface-3);
  box-shadow: none;
}
.btn--ghost:hover { background: rgba(255, 255, 255, .11); filter: none; }
.btn--ghost svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.btn--icon { width: 46px; padding: 0; flex-shrink: 0; }
.btn--sm { min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: var(--r-sm); }

.btn--on {
  color: var(--accent); border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: var(--accent-bg);
}
.btn--on svg { fill: var(--accent); stroke: var(--accent); }
/* stroke-only icons (the hero add/check) never take the fill */
.btn--on svg.icon-stroke { fill: none; }

/* ============================================================================
   SECTION HEADERS
   ========================================================================= */

.sec { margin-top: 30px; }
.sec:first-child { margin-top: 8px; }

.sec-hd {
  display: flex; align-items: baseline; gap: 10px;
  margin-bottom: 14px;
}
.sec-hd h2 {
  margin: 0; font-size: 16.5px; font-weight: 750; letter-spacing: -.02em;
}
.sec-hd .meta {
  font-size: 13px; color: var(--fg-3); margin-left: auto;
  white-space: nowrap;
}
.sec-hd .sec-more {
  font-size: 13px; font-weight: 650; color: var(--accent);
  white-space: nowrap; padding: 2px 0; margin-left: auto;
}
.sec-hd .meta + .sec-more { margin-left: 12px; }
.sec-hd .sec-more:hover { text-decoration: underline; text-underline-offset: 3px; }

/* horizontal rail — bleeds to the viewport edge */
.hrow {
  display: flex; gap: 12px;
  overflow-x: auto; scroll-snap-type: x proximity;
  padding: 4px var(--gutter) 10px;
  margin: 0 calc(var(--gutter) * -1);
  scrollbar-width: none;
}
.hrow::-webkit-scrollbar { display: none; }
.hrow > * { scroll-snap-align: start; }
/* grid-style poster tiles get a fixed rail width (wide/rank cards set their own) */
.hrow .card { flex: 0 0 116px; }

/* ============================================================================
   POSTER CARD  (grid + rail)
   ----------------------------------------------------------------------------
   Titles sit BELOW the artwork, never over it: the upstream posters carry
   their own baked-in title art, so overlaying ours would fight it.
   ========================================================================= */

.grid {
  display: grid; gap: 14px 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card { display: block; min-width: 0; }

.card-poster, .poster {
  position: relative;
  aspect-ratio: 9 / 16;
  border-radius: var(--r);
  overflow: hidden;
  background: var(--surface);
  transition: transform .18s var(--ease);
}
.card:active .card-poster { transform: scale(.97); }

.card-poster img, .poster img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform .4s var(--ease);
}
@media (hover: hover) {
  .card:hover .card-poster img { transform: scale(1.05); }
}

/* a soft base so the badge and any edge reads against busy art */
.card-poster::after, .poster::after {
  content: "";
  position: absolute; inset: auto 0 0 0; height: 40%;
  background: linear-gradient(to top, rgba(4, 4, 8, .68), transparent);
  pointer-events: none;
}

.card-ep, .poster-ep {
  position: absolute; left: 6px; bottom: 6px; z-index: 1;
  padding: 2px 7px; border-radius: var(--r-full);
  background: rgba(5, 5, 10, .72);
  border: 1px solid rgba(255, 255, 255, .14);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  font-size: 10px; font-weight: 700; letter-spacing: .01em;
  color: #ffd9de;
}
.poster-ep { left: auto; right: 6px; top: 6px; bottom: auto; }

.card-src-badge {
  position: absolute; top: 6px; left: 6px; z-index: 1;
  padding: 2px 7px; border-radius: var(--r-full);
  background: rgba(5, 5, 10, .66);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, .12);
  font-size: 9.5px; font-weight: 700; letter-spacing: .02em;
  color: rgba(255, 255, 255, .94);
  text-transform: capitalize;
}

.card-title {
  margin: 8px 2px 0;
  font-size: 13px; font-weight: 600; line-height: 1.35;
  letter-spacing: -.01em; color: var(--fg);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.7em;
}
.card-src {
  margin: 3px 2px 0;
  font-size: 11px; color: var(--fg-3);
  text-transform: capitalize;
}

/* ============================================================================
   CONTINUE-WATCHING — wide 16:9 cards with a real progress bar
   ========================================================================= */

.wcard { flex: 0 0 208px; display: block; }
.wcard-thumb {
  position: relative; aspect-ratio: 16 / 9;
  border-radius: 14px; overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface);
}
.wcard-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; }
.wcard-play { position: absolute; inset: 0; display: grid; place-items: center; }
.wcard-play i {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(8, 8, 12, .55);
  border: 1.5px solid rgba(255, 255, 255, .8);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: grid; place-items: center;
}
.wcard-play svg { width: 14px; height: 14px; fill: #fff; transform: translateX(1px); }
.wcard-bar {
  height: 4px; border-radius: 3px; background: var(--surface-3);
  margin-top: 9px; overflow: hidden;
}
.wcard-bar i { display: block; height: 100%; border-radius: 3px; background: var(--grad-hot); }
.wcard-cap { margin-top: 8px; font-size: 12px; color: var(--fg-2); line-height: 1.45; }
.wcard-cap b {
  display: block; color: var(--fg); font-weight: 650; font-size: 12.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ============================================================================
   RANK CARD — the trending chart
   ========================================================================= */

.rcard { flex: 0 0 auto; }
.rcard-top { display: flex; align-items: flex-end; }
.rcard .rank {
  font-size: 58px; font-weight: 900; font-style: italic;
  line-height: .78; letter-spacing: -.04em;
  /* Fixed-width box, right-aligned: single- and double-digit ranks occupy
     the same space, so the poster (and the captions below it) start at a
     uniform offset on every card. Without this, "10"/"11"/"12" push their
     posters right and the captions underneath drift out of alignment. */
  width: 72px; text-align: right;
  margin: 0 -12px 3px 0;
  color: transparent;
  -webkit-text-stroke: 2px #5c5c72;
  z-index: 0; flex-shrink: 0;
}
.rcard .poster { width: 118px; z-index: 1; flex-shrink: 0; }
.rcard-cap {
  margin: 8px 0 0 62px;
  font-size: 11.5px; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.rcard-sub { font-size: 10px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--accent); margin: 3px 0 0 62px; }

/* ============================================================================
   HERO
   ========================================================================= */

.hero {
  position: relative;
  margin: 6px var(--gutter) 0;
  height: clamp(340px, 60vh, 500px);
  border-radius: 22px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
}
.hero img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
}
/* warm accent vignette — ties the brand to the art without washing it out */
.hero::before {
  content: "";
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(120% 75% at 88% 12%, rgba(255, 122, 61, .20), transparent 55%);
  mix-blend-mode: screen;
}
.hero::after {
  content: "";
  position: absolute; inset: 0; z-index: 1;
  background:
    linear-gradient(to top, var(--bg) 1%, rgba(6,6,9,.82) 26%, rgba(6,6,9,.30) 52%, transparent 76%),
    linear-gradient(105deg, rgba(6,6,9,.55), transparent 55%);
}
.hero-body {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  padding: 18px;
}

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; margin-bottom: 10px;
  border-radius: var(--r-full);
  background: rgba(255, 90, 60, .14);
  border: 1px solid var(--accent-line);
  color: #ffb199;
  font-size: 11px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase;
}
.badge svg { width: 11px; height: 11px; fill: currentColor; }

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(26px, 6.4vw, 44px);
  font-weight: 800; line-height: 1.1; letter-spacing: -.035em;
  max-width: 18ch;
  text-shadow: 0 2px 22px rgba(0, 0, 0, .55);
}
.hero .sub {
  margin: 0 0 12px;
  font-size: 12.5px; color: #cfcfda;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.hero .sub i { width: 3px; height: 3px; border-radius: 50%; background: var(--fg-3); font-style: normal; }

/* genre chips — filled from real /api/detail tags only */
.hero-chips { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 14px; }
.hero-chips:empty { display: none; }
.hero-chips span {
  font-size: 11px; color: #d7d7e0;
  border: 1px solid var(--surface-3);
  background: rgba(20, 20, 28, .6);
  padding: 4px 10px; border-radius: 14px;
}

.hero .row { display: flex; align-items: center; gap: 10px; }
.hero .row .btn { flex: 1.4; }
.hero .row .btn--ghost { flex: 1; }

/* ============================================================================
   CHIPS
   ========================================================================= */

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips--scroll {
  overflow-x: auto; flex-wrap: nowrap;
  padding-bottom: 2px;
  margin: 0 calc(var(--gutter) * -1);
  padding-inline: var(--gutter);
  scrollbar-width: none;
}
.chips--scroll::-webkit-scrollbar { display: none; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; flex-shrink: 0;
  border-radius: var(--r-full);
  background: var(--surface); border: 1px solid var(--line-soft);
  font-size: 13px; font-weight: 500; color: var(--fg-2);
  white-space: nowrap;
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
a.chip:hover { background: var(--surface-2); color: var(--fg); }
.chip.active {
  background: var(--grad); border-color: transparent;
  color: var(--accent-ink); font-weight: 650;
}
.chip .n { color: var(--fg-3); font-size: 12px; }
.chip.active .n { color: rgba(255, 255, 255, .78); }

/* ============================================================================
   DETAIL
   ========================================================================= */

.dtl { position: relative; padding-top: 20px; }
.dtl-bg {
  position: absolute; top: -60px; left: 0; right: 0; height: 340px; z-index: -1;
  overflow: hidden;
}
.dtl-bg img {
  width: 100%; height: 100%; object-fit: cover;
  filter: blur(40px) saturate(160%);
  transform: scale(1.3);
  opacity: .32;
}
.dtl-bg::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(6,6,9,.35), var(--bg) 88%);
}

.dtl-top { display: flex; gap: 16px; align-items: flex-start; }
.dtl-poster {
  width: 116px; flex-shrink: 0;
  aspect-ratio: 9 / 16;
  border-radius: var(--r);
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .6);
}
.dtl-poster img { width: 100%; height: 100%; object-fit: cover; }

.dtl-info { flex: 1; min-width: 0; padding-top: 2px; }
.dtl-info h1 {
  margin: 0 0 10px;
  font-size: clamp(20px, 5.4vw, 28px);
  font-weight: 800; line-height: 1.15; letter-spacing: -.03em;
}
.dtl-meta {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  font-size: 13px; color: var(--fg-2); margin-bottom: 12px;
}
.dtl-meta i { width: 3px; height: 3px; border-radius: 50%; background: var(--fg-3); font-style: normal; }
.dtl-chips { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 14px; }
.dtl-actions { display: flex; gap: 9px; flex-wrap: wrap; }

.syn { margin-top: 22px; }
.syn p { margin: 0; font-size: 14px; line-height: 1.65; color: var(--fg-2); }
.syn p.clamped {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}
.syn-more {
  margin-top: 8px; padding: 0;
  background: none; border: 0; cursor: pointer;
  color: var(--accent); font-size: 13px; font-weight: 650;
}

/* ============================================================================
   EPISODE PICKER
   ========================================================================= */

.eps { display: grid; gap: 8px; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.ep {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  min-height: 46px;
  border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--line-soft);
  font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums;
  color: var(--fg-2);
  transition: background .14s var(--ease), color .14s var(--ease), border-color .14s var(--ease);
}
.ep:hover { background: var(--surface-2); color: var(--fg); }
.ep:active { transform: scale(.95); }
.ep--now { background: var(--grad); border-color: transparent; color: var(--accent-ink); }
.ep--seen { color: var(--fg); }
.ep--seen::after {
  content: ""; position: absolute; bottom: 7px;
  width: 4px; height: 4px; border-radius: 50%; background: var(--accent);
}
.ep--locked { color: var(--fg-3); }

.eps-foot { margin-top: 14px; display: flex; justify-content: center; }

/* ============================================================================
   AD SLOTS — Adsterra units
   ----------------------------------------------------------------------------
   An empty slot reserves nothing: the label stays hidden until ads.js marks the
   unit filled, so a blocked or unfilled ad costs zero layout.

   html.ad-banner-on is set by ads.js when a 320x50 creative has rendered AND the
   viewer has not closed it. It reveals the floating player card and lifts the
   transient pills (sound prompt, next-episode countdown) clear of it.
   ========================================================================= */

html.ad-banner-on { --pl-ad-h: 70px; }

.ad-slot { display: block; }
.ad-wrap { display: flex; justify-content: center; align-items: center; }

.ad-slot-label {
  display: none;
  font-size: 9px; font-weight: 700; letter-spacing: .16em;
  text-transform: uppercase; color: var(--fg-3);
}
.ad-wrap[data-filled="1"] .ad-slot-label { display: block; }

/* in-content native unit */
.ad-slot--native {
  max-width: 720px; margin: 30px auto 0;
  padding: 0 var(--gutter);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.ad-slot--native .ad-wrap { width: 100%; flex-direction: column; gap: 6px; }

/* ============================================================================
   PLAYER — our own controls, full-screen and reel-shaped
   ----------------------------------------------------------------------------
   The player is not a card in the page; it IS the page. It fills the viewport
   (fixed, so it ignores the sticky header and any scroll), the video is
   object-fit: contain so a 9:16 drama fills the width of a phone exactly and
   letterboxes only where the source aspect disagrees, and every control is
   ours. Chrome auto-hides while playing; a tap brings it back.
   ========================================================================= */

body.player-open { overflow: hidden; }

.pl {
  position: fixed; inset: 0; z-index: 100;
  background: #000; overflow: hidden;
  user-select: none; -webkit-user-select: none;
  /* manipulation keeps double-tap-zoom off while still letting the episode
     sheet scroll; the player is fixed with overflow:hidden, so a pan over the
     video has nothing to move. */
  touch-action: manipulation;
  overscroll-behavior: none;
}
.pl video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;             /* 9:16 content → exact phone width */
  background: #000; display: block;
}

/* ---- legibility scrims, tied to the chrome ------------------------------- */
.pl-scrim {
  position: absolute; left: 0; right: 0; height: 28%;
  pointer-events: none; z-index: 1;
  transition: opacity .25s var(--ease);
}
.pl-scrim--top { top: 0; background: linear-gradient(to bottom, rgba(0,0,0,.6), transparent); }
.pl-scrim--bot { bottom: 0; background: linear-gradient(to top, rgba(0,0,0,.74), transparent); }

.pl-ui { position: absolute; inset: 0; z-index: 2; }
/* Only the top bar fades. The transport and the episode rail stay put: a tap
   now pauses/resumes, so there is no "tap to reveal the controls" gesture left,
   and hiding the scrub bar behind one would strand the viewer. */
.pl-top { transition: opacity .25s var(--ease); }
.pl.chrome-hidden .pl-top { opacity: 0; pointer-events: none; }
.pl.chrome-hidden .pl-scrim--top { opacity: 0; }

/* ---- buttons + icon set -------------------------------------------------- */
.pl-btn {
  width: 40px; height: 40px; flex-shrink: 0;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: rgba(0,0,0,.42); color: #fff;
  cursor: pointer;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: background .15s var(--ease);
}
.pl-btn:hover { background: rgba(0,0,0,.62); }
.pl-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pl-ic { width: 20px; height: 20px; }
.pl-ic--play, .pl-ic--pause { fill: currentColor; stroke: none; }
.pl-ic:not(.pl-ic--play):not(.pl-ic--pause) {
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
/* state-driven icon swaps */
.pl-ic--pause, .pl-ic--muted { display: none; }
.pl.playing .pl-ic--play  { display: none; }
.pl.playing .pl-ic--pause { display: block; }
.pl.muted  .pl-ic--vol    { display: none; }
.pl.muted  .pl-ic--muted  { display: block; }

/* ---- top bar ------------------------------------------------------------- */
.pl-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 14px 12px;
}
.pl-head { flex: 1; min-width: 0; }
.pl-title {
  font-size: 14px; font-weight: 650; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 1px 8px rgba(0,0,0,.6);
}
.pl-ep { font-size: 12px; color: rgba(255,255,255,.72); font-variant-numeric: tabular-nums; }

/* ---- centre play / pause ------------------------------------------------- */
.pl-center {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 74px; height: 74px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.85);
  background: rgba(0,0,0,.42); color: #fff;
  display: grid; place-items: center; cursor: pointer;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  transition: opacity .2s var(--ease), transform .12s var(--ease);
}
.pl-center .pl-ic { width: 30px; height: 30px; }
.pl-center:active { transform: translate(-50%, -50%) scale(.94); }
.pl.playing .pl-center { opacity: 0; pointer-events: none; }
/* while the stream is resolving the centre button means nothing yet */
.pl.loading .pl-center { opacity: 0; pointer-events: none; }

/* ---- reel-style episode rail --------------------------------------------- */
.pl-rail {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 10px;
}
.pl-nav {
  width: 46px; height: 46px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.42); color: #fff;
  display: grid; place-items: center; cursor: pointer;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: background .15s var(--ease);
}
.pl-nav:hover { background: rgba(0,0,0,.62); }
.pl-nav[hidden] { display: none; }
.pl-nav svg {
  width: 22px; height: 22px;
  fill: none; stroke: currentColor; stroke-width: 2.2;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ---- bottom transport ---------------------------------------------------- */
.pl-bottom {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 0 14px calc(env(safe-area-inset-bottom, 0px) + 12px);
}
.pl-seek { padding: 14px 0; cursor: pointer; touch-action: none; }
.pl-seek:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }
.pl-seek-track {
  position: relative; height: 4px; border-radius: 2px;
  background: rgba(255,255,255,.28);
}
.pl-seek-buf, .pl-seek-fill {
  position: absolute; top: 0; bottom: 0; left: 0; width: 0;
  border-radius: 2px;
}
.pl-seek-buf  { background: rgba(255,255,255,.34); }
.pl-seek-fill { background: var(--grad-hot); }
.pl-seek-knob {
  position: absolute; top: 50%; left: 0;
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; transform: translate(-50%, -50%);
  box-shadow: 0 1px 5px rgba(0,0,0,.65);
  transition: transform .12s var(--ease);
}
.pl-seek:active .pl-seek-knob { transform: translate(-50%, -50%) scale(1.25); }

.pl-ctrls { display: flex; align-items: center; gap: 8px; }
.pl-time {
  font-size: 12px; color: rgba(255,255,255,.82);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.pl-time b { color: #fff; font-weight: 600; }
.pl-grow { flex: 1; }

/* ---- double-tap seek feedback -------------------------------------------- */
.pl-flash {
  position: absolute; top: 50%; transform: translateY(-50%);
  padding: 10px 16px; border-radius: var(--r-full);
  background: rgba(0,0,0,.6); color: #fff;
  font-size: 13px; font-weight: 600; white-space: nowrap;
  opacity: 0; pointer-events: none;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  transition: opacity .2s var(--ease);
}
.pl-flash.show { opacity: 1; }
#pl-flash-l { left: 7%; }
#pl-flash-r { right: 7%; }

/* ---- next-episode prompt ------------------------------------------------- */
.pl-nextup {
  position: absolute; right: 16px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 96px + var(--pl-ad-h));
  z-index: 3;
  padding: 11px 16px; border: 0; border-radius: var(--r-full);
  background: var(--grad); color: var(--accent-ink);
  font-size: 13px; font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 18px rgba(225, 29, 72, .35);
}
.pl-nextup[hidden] { display: none; }

/* ---- "tap for sound" prompt (shown after an autoplay-policy mute) --------- */
.pl-unmute {
  position: absolute; left: 14px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 104px + var(--pl-ad-h));
  z-index: 3;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 14px; border: 0; border-radius: var(--r-full);
  background: rgba(0,0,0,.66); color: #fff;
  font-size: 13px; font-weight: 650; cursor: pointer;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.pl-unmute[hidden] { display: none; }
.pl-unmute svg {
  width: 16px; height: 16px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ---- episode picker (bottom sheet) --------------------------------------- */
/* Above the loading overlay (so it is not dimmed while the stream resolves) but
   below the error state (so a failure is never hidden behind it). */
.pl-sheet {
  position: absolute; inset: 0; z-index: 7;
  display: flex; align-items: flex-end;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.pl-sheet[hidden] { display: none; }
.pl-sheet-panel {
  width: 100%; max-height: 64%;
  display: flex; flex-direction: column;
  background: var(--surface-2);
  border-top: 1px solid var(--line);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: 0 -18px 40px rgba(0,0,0,.5);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  animation: sheet-up .22s var(--ease);
}
@keyframes sheet-up { from { transform: translateY(16px); opacity: .5; } }
.pl-sheet-hd {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line-soft);
}
.pl-sheet-title { flex: 1; font-size: 15px; font-weight: 700; }
.pl-sheet-meta { font-size: 12px; color: var(--fg-3); }
.pl-sheet-close {
  width: 34px; height: 34px; flex-shrink: 0;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: var(--surface-3); color: var(--fg-2); cursor: pointer;
}
.pl-sheet-close svg {
  width: 14px; height: 14px;
  fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round;
}
.pl-sheet-body {
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 14px 16px 18px;
  display: grid; gap: 8px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.pl-sheet-empty { grid-column: 1 / -1; margin: 6px 0; font-size: 13px; color: var(--fg-3); }
/* Named .pl-epick, never .pl-ep: the top bar's episode label is .pl-ep, and a
   shared name skinned the label as a 46px button (a dark rounded block across
   the top of the player). */
.pl-epick {
  min-height: 46px;
  border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--line-soft);
  color: var(--fg-2);
  font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background .14s var(--ease), color .14s var(--ease);
}
.pl-epick:hover { background: var(--surface-3); color: var(--fg); }
.pl-epick.is-now { background: var(--grad); border-color: transparent; color: var(--accent-ink); }
.pl-epick.is-locked { color: var(--fg-3); }

/* ---- 320x50 floating card, clear of the transport and dismissible -------- */
.pl-ad {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 92px);
  z-index: 4;
  /* visibility (not display:none): the ad iframe must be measurable while
     hidden, otherwise the fill check can never pass and the card never shows */
  display: flex;
  visibility: hidden;
  align-items: center; justify-content: center;
  max-width: calc(100vw - 20px);
  padding: 4px;
  background: rgba(0,0,0,.72);
  border: 1px solid var(--line);
  border-radius: var(--r);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
html.ad-banner-on .pl-ad { visibility: visible; }
.pl-ad .ad-slot { display: flex; justify-content: center; }

.pl-ad-close {
  position: absolute; top: -10px; right: -10px;
  width: 24px; height: 24px; flex-shrink: 0;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-3); color: var(--fg);
  cursor: pointer;
}
.pl-ad-close svg {
  width: 11px; height: 11px;
  fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round;
}

/* ---- status overlay (loading / error) ------------------------------------ */
.pl-status {
  position: absolute; inset: 0; z-index: 6;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px;
  background: rgba(0,0,0,.86);
  text-align: center; padding: 24px;
  pointer-events: none;            /* loading must not swallow the back button */
}
.pl-status[hidden] { display: none; }
/* only the error state needs to be interactive (it carries a back link) */
.pl-status.err { pointer-events: auto; z-index: 8; }
.pl-status p { margin: 0; font-size: 14px; color: var(--fg-2); max-width: 30ch; }
.pl-status.err p { color: var(--accent); }

.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.15);
  border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================================
   EMPTY / ERROR STATES
   ========================================================================= */

.state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; text-align: center;
  padding: 72px 24px;
}
.state svg { width: 40px; height: 40px; fill: none; stroke: var(--fg-3); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.state h3 { margin: 6px 0 0; font-size: 16px; font-weight: 650; }
.state p { margin: 0; font-size: 14px; color: var(--fg-3); max-width: 34ch; line-height: 1.6; }
.state .btn { margin-top: 10px; }

/* ============================================================================
   SKELETONS
   ========================================================================= */

@keyframes shimmer { to { background-position: -200% 0; } }
.sk {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 37%, var(--surface) 63%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
  border-radius: var(--r);
}
.sk-poster { aspect-ratio: 9/16; }
.sk-line { height: 12px; margin-top: 9px; border-radius: 4px; }
.sk-line.short { width: 55%; }

/* ============================================================================
   TOAST
   ========================================================================= */

.toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translate(-50%, 8px);
  z-index: 60;
  padding: 11px 18px;
  border-radius: var(--r-full);
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--fg);
  font-size: 13.5px; font-weight: 550;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.toast[hidden] { display: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============================================================================
   FOOTER NOTE
   ========================================================================= */

.note {
  margin: 36px 0 8px;
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
  text-align: center;
  font-size: 12px; color: var(--fg-3); line-height: 1.6;
}

/* ============================================================================
   RESPONSIVE
   ========================================================================= */

@media (min-width: 560px) {
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px 12px; }
  .eps  { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .card-title { font-size: 13.5px; }
  .hero { height: clamp(400px, 62vh, 560px); }

  /* room to breathe: the three nav items and the full wordmark */
  .logo { gap: 8px; }
  .logo-mark { width: 30px; height: 30px; border-radius: 9px; }
  .logo-mark svg { width: 14px; height: 14px; }
  .hdr-nav { gap: 2px; }
  .hdr-nav a { padding: 7px 12px; font-size: 14px; font-weight: 550; }
  .logo-word { font-size: 19px; }
}

@media (min-width: 720px) {
  .hdr-in {
    flex-direction: row; align-items: center; gap: 20px;
    padding: 12px var(--gutter);
  }
  .hdr-top { display: contents; }
  .hdr-nav { order: 1; margin-left: 0; gap: 4px; }
  .hdr-nav a { padding: 8px 14px; }
  .searchwrap { order: 2; width: auto; flex: 1; max-width: 420px; margin-left: auto; }

  .hero-body { padding: 24px 26px; }
  .hero .row { max-width: 460px; }
}

@media (min-width: 900px) {
  :root { --gutter: 28px; }

  .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 22px 16px; }
  .eps  { grid-template-columns: repeat(10, minmax(0, 1fr)); }
  .app { padding-bottom: 56px; }

  .hero { height: min(64vh, 560px); border-radius: 26px; }
  .hero-body { padding: 30px 34px; }

  .dtl-poster { width: 172px; }
  .dtl-top { gap: 24px; }
  .dtl-actions .btn { min-height: 48px; padding: 0 26px; }

  .wcard { flex: 0 0 244px; }
}

@media (min-width: 1200px) {
  .grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
