/* ============================================================================
   ReelVerse — "cinematic neon glass" theme
   ----------------------------------------------------------------------------
   Design language: deep near-black canvas with a slow aurora drift behind it,
   frosted glass surfaces, a violet→magenta→rose signature gradient used for
   every action/accent, and cinematic scrims on all artwork. Motion is used to
   make waiting states legible (shimmering skeletons, a rotating ring on every
   long fetch) and to acknowledge taps, never to decorate for its own sake.
   Everything degrades gracefully: `prefers-reduced-motion` kills the ambient
   animation, and every colour has a plain fallback.
   Class names are the contract with src/app.js — renaming one breaks the UI.
   ========================================================================== */

:root {
  --bg: #05050a;
  --bg2: #0a0a13;
  --surface: rgba(24,24,37,.72);
  --surface-solid: #16161f;
  --card: #14141f;
  --card2: #1c1c2a;
  --line: rgba(255,255,255,.085);
  --line2: rgba(255,255,255,.16);
  --text: #f6f6fb;
  --muted: #a3a3b8;
  --muted2: #6f6f87;
  --accent: #7c5cff;
  --accent2: #ff3d81;
  --accent3: #2fe6d0;
  --grad: linear-gradient(118deg, #7c5cff 0%, #a94dff 42%, #ff3d81 100%);
  --grad-soft: linear-gradient(118deg, rgba(124,92,255,.22), rgba(255,61,129,.18));
  --grad-line: linear-gradient(90deg, rgba(124,92,255,0), rgba(124,92,255,.9), rgba(255,61,129,.9), rgba(255,61,129,0));
  --good: #2ee6a8;
  --gold: #ffbf47;
  --radius: 18px;
  --radius-sm: 11px;
  --shadow: 0 18px 48px rgba(0,0,0,.55);
  --glow: 0 12px 36px rgba(124,92,255,.38);
  --glow-pink: 0 12px 36px rgba(255,61,129,.32);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Noto Kufi Arabic", sans-serif;
  --ease: cubic-bezier(.22,.68,.28,1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
html {
  color-scheme: dark;
  /* Native-app document behaviour — see the "Native app viewport" section at the
     end of this file for the reasoning. `touch-action: manipulation` keeps
     panning and momentum scrolling but drops the double-tap zoom gesture, and
     `overscroll-behavior: none` stops the document rubber-banding / pull-to-
     refresh that immediately reads as "this is a web page in a box". */
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  touch-action: manipulation;
  overscroll-behavior: none;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  text-align: left;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
/* The ambient aurora. A single GPU-composited layer (transform-only animation)
   so it costs nothing on a slow phone, but gives every glass surface something
   to refract. */
body::before {
  content: "";
  position: fixed; inset: -32% -22%; z-index: -1; pointer-events: none;
  background:
    radial-gradient(38% 40% at 20% 16%, rgba(124,92,255,.30), rgba(124,92,255,0) 70%),
    radial-gradient(32% 38% at 84% 10%, rgba(255,61,129,.22), rgba(255,61,129,0) 70%),
    radial-gradient(42% 44% at 68% 90%, rgba(47,230,208,.15), rgba(47,230,208,0) 72%),
    radial-gradient(30% 34% at 8% 82%, rgba(169,77,255,.16), rgba(169,77,255,0) 70%);
  filter: blur(28px) saturate(115%);
  animation: auroraDrift 30s ease-in-out infinite alternate;
  will-change: transform;
}
@keyframes auroraDrift {
  from { transform: translate3d(-2.5%, -1.5%, 0) scale(1); }
  to   { transform: translate3d(3.5%, 2.5%, 0) scale(1.09); }
}
[dir="rtl"] body { text-align: right; }
button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea { font-family: inherit; }
/* The app disables selection everywhere (a long press must never start a text
   selection or the iOS callout on a poster or a button), but a text field is the
   one place a finger has to be able to place the caret and select/copy. */
input:not([type="checkbox"]):not([type="radio"]), textarea {
  -webkit-user-select: text; user-select: text; -webkit-touch-callout: default;
}
.hidden { display: none !important; }
::selection { background: rgba(255,61,129,.35); }
:focus-visible { outline: 2px solid rgba(124,92,255,.85); outline-offset: 2px; }

/* Slim, themed scrollbars where the platform draws them. */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.16) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 99px; }
*::-webkit-scrollbar-track { background: transparent; }

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

/* `100dvh` is the height the *visible* viewport will have once the browser has
   settled (mobile URL bars grow and shrink as you scroll); the `100vh` line is
   the fallback for engines that don't know it yet. Using only `100vh` would make
   the layout taller than the screen for part of every scroll. */
#app { min-height: 100vh; min-height: 100dvh; padding-bottom: 76px; }
section[data-screen] { padding: 0 0 8px; animation: screenIn .32s var(--ease) both; }
@keyframes screenIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ============ Top bar ============ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 16px 12px;
  background: linear-gradient(180deg, rgba(5,5,10,.92) 0%, rgba(5,5,10,.72) 62%, rgba(5,5,10,0) 100%);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: -.2px; }
.brand #brandName, .brand > span:last-child {
  background: linear-gradient(100deg, #ffffff 8%, #d9c9ff 46%, #ff97bf 92%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand .logo {
  position: relative; width: 32px; height: 32px; border-radius: 11px; background: var(--grad);
  display: grid; place-items: center; color: #fff;
  box-shadow: var(--glow), inset 0 1px 0 rgba(255,255,255,.35);
}
.brand .logo::after {
  content: ""; position: absolute; inset: -3px; border-radius: 14px; z-index: -1;
  background: conic-gradient(from 0deg, rgba(124,92,255,.9), rgba(255,61,129,.9), rgba(47,230,208,.85), rgba(124,92,255,.9));
  filter: blur(9px); opacity: .55; animation: haloSpin 9s linear infinite;
}
@keyframes haloSpin { to { transform: rotate(360deg); } }
.brand .logo svg { width: 16px; height: 16px; }
.topbar-actions { display: flex; gap: 8px; }
.iconbtn {
  width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
  transition: transform .14s var(--ease), background .2s, border-color .2s;
}
.iconbtn:hover { border-color: var(--line2); background: rgba(36,36,54,.8); }
.iconbtn:active { transform: scale(.92); }
.iconbtn svg { width: 19px; height: 19px; }

/* ============ Home hero ============ */
.hero-wrap { padding: 2px 16px 20px; }
.hero-card {
  --cover: none;
  position: relative; isolation: isolate; overflow: hidden;
  border-radius: 24px; border: 1px solid var(--line2);
  min-height: 224px; display: flex; align-items: flex-end;
  background: var(--card);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.06);
}
.hero-bg {
  position: absolute; inset: -14%; z-index: -2;
  background-image: var(--cover);
  background-size: cover; background-position: center 26%;
  filter: blur(18px) saturate(210%) brightness(1.55);
  transform: scale(1.2);
}
.hero-scrim {
  position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(180deg, rgba(5,5,10,.30) 0%, rgba(5,5,10,.03) 40%, rgba(5,5,10,.56) 76%, rgba(5,5,10,.92) 100%),
    linear-gradient(100deg, rgba(5,5,10,.62) 0%, rgba(5,5,10,.10) 55%, rgba(124,92,255,.26) 100%);
}
.hero-ring {
  position: absolute; inset: 0; z-index: 3; pointer-events: none; border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.07), inset 0 -60px 90px rgba(5,5,10,.55);
}
/* The crisp poster chip keeps the blurred bleed honest — the user sees the real
   artwork while the ambient layer supplies the colour. */
.hero-card::after {
  content: ""; position: absolute; top: 16px; inset-inline-end: 16px; z-index: 2;
  width: 88px; aspect-ratio: 2 / 3; border-radius: 16px;
  background-image: var(--cover); background-size: cover; background-position: center;
  border: 1px solid rgba(255,255,255,.26);
  box-shadow: 0 16px 34px rgba(0,0,0,.62), 0 0 0 1px rgba(255,255,255,.06), 0 0 24px -4px rgba(124,92,255,.55);
}
.hero-body { position: relative; width: 100%; padding: 16px 16px 16px; padding-inline-end: 108px; }
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.3px;
  color: #ffd9e8; margin-bottom: 8px;
}
.hero-eyebrow .pulse-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent2);
  box-shadow: 0 0 0 0 rgba(255,61,129,.7); animation: pulse 1.9s infinite;
}
.hero-title {
  font-size: 22px; font-weight: 850; line-height: 1.18; letter-spacing: -.4px;
  text-shadow: 0 2px 20px rgba(0,0,0,.8), 0 0 44px rgba(0,0,0,.55);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.hero-meta { margin-top: 6px; font-size: 11.5px; color: rgba(255,255,255,.84); font-weight: 600; letter-spacing: .2px; text-shadow: 0 1px 12px rgba(0,0,0,.8); }
.hero-actions { display: flex; align-items: center; gap: 9px; margin-top: 16px; }
.hero-play {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 11px 18px 11px 15px; border-radius: 999px; white-space: nowrap;
  background: var(--grad); color: #fff; font-weight: 800; font-size: 13px;
  box-shadow: var(--glow), inset 0 1px 0 rgba(255,255,255,.34);
  transition: transform .14s var(--ease), box-shadow .2s;
}
.hero-play svg { width: 15px; height: 15px; flex: 0 0 auto; }
.hero-play:active { transform: scale(.95); box-shadow: var(--glow-pink); }
.hero-more {
  padding: 11px 14px; border-radius: 999px; white-space: nowrap; font-weight: 750; font-size: 12px;
  background: rgba(255,255,255,.24); border: 1px solid rgba(255,255,255,.46); color: #fff;
  text-shadow: 0 1px 8px rgba(0,0,0,.6);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.36), 0 8px 22px rgba(0,0,0,.42);
  backdrop-filter: blur(12px) saturate(150%); -webkit-backdrop-filter: blur(12px) saturate(150%);
  transition: background .2s, transform .14s var(--ease);
}
.hero-more:hover { background: rgba(255,255,255,.34); }
.hero-more:active { transform: scale(.95); }
.hero-skel .hero-body { padding-top: 26px; }
.hero-skel::after { display: none; }
.sk-line { border-radius: 8px; height: 14px; }

/* ============ Rows ============ */
.rows { display: flex; flex-direction: column; gap: 24px; padding: 4px 0 22px; }
.row-title { display: flex; align-items: center; gap: 9px; padding: 0 16px; margin-bottom: 12px; font-size: 16px; font-weight: 800; letter-spacing: -.2px; }
.row-title .dot {
  width: 4px; height: 17px; border-radius: 3px; background: var(--grad);
  box-shadow: 0 0 12px rgba(255,61,129,.6);
}
.row-title .sub { font-size: 12px; color: var(--muted2); font-weight: 600; }
.row-title .more {
  margin-inline-start: auto; font-size: 12.5px; font-weight: 800;
  color: #ffdcea; padding: 7px 13px; border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,61,129,.28), rgba(255,61,129,.13));
  border: 1px solid rgba(255,61,129,.44);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 8px 20px -8px rgba(255,61,129,.85);
  display: flex; align-items: center; gap: 3px; transition: background .2s, transform .14s var(--ease);
}
.row-title .more:hover { background: linear-gradient(180deg, rgba(255,61,129,.4), rgba(255,61,129,.22)); }
.row-title .more:active { transform: scale(.94); opacity: .9; }
.hscroll {
  display: flex; gap: 13px; padding: 2px 16px 6px; overflow-x: auto;
  scrollbar-width: none; scroll-snap-type: x proximity;
  /* Without this, `scroll-snap-align:start` snaps card 0's left edge to the
     scroller's left edge, cancelling the 16px padding and jamming the first
     poster against the screen edge. */
  scroll-padding-inline: 16px;
}
.hscroll::-webkit-scrollbar { display: none; }

/* Drama card (2:3 poster) */
.dcard { flex: 0 0 auto; width: 138px; cursor: pointer; scroll-snap-align: start; transition: transform .18s var(--ease); }
.dcard:hover { transform: translateY(-4px); }
.dcard:active { transform: scale(.96); }
.poster {
  position: relative; aspect-ratio: 2 / 3; border-radius: var(--radius); overflow: hidden;
  background: linear-gradient(160deg, var(--card2) 0%, var(--card) 58%, #101019 130%);
  /* On a near-black canvas a pure black drop shadow is invisible, so depth comes
     from three cheap layers: a dark drop shadow for separation, a 1px light edge
     to catch the "light", and a violet ambient bleed that lifts the artwork off
     the background. */
  box-shadow: 0 16px 34px rgba(0,0,0,.62), 0 0 0 1px rgba(255,255,255,.055), 0 6px 26px -9px rgba(124,92,255,.55);
  transition: box-shadow .22s var(--ease);
}
/* A hairline gradient ring instead of a flat border: reads as glass over the
   artwork rather than a box around it. */
.poster::before {
  content: ""; position: absolute; inset: 0; z-index: 4; border-radius: inherit; pointer-events: none;
  padding: 1px;
  background: linear-gradient(150deg, rgba(255,255,255,.46), rgba(255,255,255,.07) 40%, rgba(255,61,129,.34));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}
.dcard:hover .poster { box-shadow: 0 18px 40px rgba(0,0,0,.62), 0 0 0 1px rgba(124,92,255,.35), 0 0 26px rgba(124,92,255,.22); }
.poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster .shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0) 42%, rgba(5,5,10,.5) 72%, rgba(5,5,10,.92) 100%); }
.poster .playbadge {
  position: absolute; inset-inline-start: 9px; bottom: 9px; z-index: 3; width: 32px; height: 32px; border-radius: 50%;
  background: var(--grad); display: grid; place-items: center; color: #fff;
  box-shadow: 0 6px 18px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.35);
  opacity: 0; transform: translateY(6px) scale(.9); transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.dcard:hover .playbadge, .dcard:active .playbadge { opacity: 1; transform: none; }
@media (hover: none) { .poster .playbadge { opacity: 1; transform: none; } }
.poster .playbadge svg { width: 13px; height: 13px; margin-inline-start: 2px; }
.poster .epbadge, .poster .dur {
  position: absolute; z-index: 3; font-size: 10px; font-weight: 800;
  background: rgba(6,6,12,.7); color: #fff; padding: 3px 8px; border-radius: 999px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.12);
}
.poster .epbadge { top: 9px; inset-inline-end: 9px; }
.poster .dur { inset-inline-end: 9px; bottom: 9px; }
.poster .subbadge {
  position: absolute; top: 9px; inset-inline-start: 9px; z-index: 3;
  font-size: 9px; font-weight: 800; letter-spacing: .5px;
  background: var(--grad); color: #fff; padding: 3px 7px; border-radius: 999px;
  box-shadow: 0 4px 12px rgba(255,61,129,.35);
}
.dcard .dtitle { margin-top: 9px; font-size: 12.5px; font-weight: 660; line-height: 1.38; padding-bottom: 1px; color: rgba(246,246,251,.94); letter-spacing: -.1px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dcard .dmeta { margin-top: 4px; font-size: 10.5px; color: var(--muted2); font-weight: 600; display: flex; align-items: center; gap: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============ Feed / watch ============ */
#feedScreen {
  position: fixed; inset: 0; z-index: 50; background: #000;
  overflow: hidden;
  /* The feed is the app's vertical pager, so the browser must not treat a
     drag as a scroll/zoom gesture — with `touch-action: auto` a vertical swipe
     is cancelled (pointercancel) before it can be measured. */
  touch-action: none; -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#feedFrame { position: absolute; inset: 0; overflow: hidden; }
/* Real full screen (the toggle in the bottom bar): the frame becomes the screen, so
   the desktop device frame's size and radius must not survive it. */
#feedFrame:fullscreen, #feedFrame:-webkit-full-screen { width: 100vw; height: 100vh; border-radius: 0; box-shadow: none; }
#feedFrame .iframe-holder { position: absolute; inset: 0; }
#feedFrame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
/* The episode's <video> lives in here, and CSS is the ONLY thing that decides
   its geometry. The player deliberately writes no inline box and no transform:
   a transform on a <video> is what stops WebKit rendering the picture at all,
   and forcing a pixel box from JS fought a moving viewport, so both are gone. */
#playerHost { position: absolute; inset: 0; overflow: hidden; }
/* The blurred backdrop behind a `contain`ed picture. It lives behind the player
   host (which is transparent), so the bands beside a video whose shape does not
   match the phone read as the episode's own art rather than dead black. */
#feedBg {
  position: absolute; inset: -40px; background-size: cover; background-position: center;
  filter: blur(30px) saturate(1.15) brightness(.42);
  opacity: 0; transition: opacity .35s var(--ease); pointer-events: none;
}
#feedFrame.rv-contain #feedBg { opacity: 1; }
#playerHost > video, #feedFrame > video {
  position: absolute !important; top: 0 !important; left: 0 !important;
  width: 100% !important; height: 100% !important;
  /* Full-bleed: a 9:16 episode on a 19.5:9 phone must not sit between two black
     bars, so the picture fills the frame and crops the overflow. */
  object-fit: cover; background: #000; display: block;
}
/* The feed must not animate its own `transform`: a transformed ancestor is what
   pushes some Android builds onto the buggy video-surface path. An opacity
   fade-in reads the same on screen (the screen change is instant either way). */
#feedScreen { animation: backIn .28s var(--ease) both; }
#feedSpinner { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 12px; background: #000; transition: opacity .3s; }
#feedSpinner.hide { opacity: 0; pointer-events: none; }
#feedSpinPct { font: 600 13px/1 var(--font, system-ui); color: #cbd5e1; letter-spacing: .5px; min-height: 13px; }
.spinner {
  width: 46px; height: 46px; border-radius: 50%;
  background: conic-gradient(from 90deg, rgba(255,255,255,.06) 0deg, rgba(124,92,255,.2) 120deg, var(--accent) 250deg, var(--accent2) 360deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3.5px), #000 calc(100% - 3.5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3.5px), #000 calc(100% - 3.5px));
  animation: spin .85s linear infinite;
  filter: drop-shadow(0 0 10px rgba(124,92,255,.55));
}
@keyframes spin { to { transform: rotate(360deg); } }

#feedOverlay { position: absolute; inset: 0; pointer-events: none; }
#feedOverlay > * { pointer-events: auto; }
.fgrad {
  position: absolute; inset: 0; pointer-events: none !important;
  /* The bottom third of a feed video is busy artwork, so the scrim has to be
     near-opaque by the time the episode label/title/description sit on top of
     it, otherwise the type fights the picture. */
  background: linear-gradient(180deg, rgba(0,0,0,.55) 0%, rgba(0,0,0,0) 18%, rgba(0,0,0,0) 32%, rgba(0,0,0,.5) 50%, rgba(0,0,0,.86) 68%, rgba(0,0,0,.97) 86%, #000 100%);
  opacity: 1; transition: opacity .3s;
}
#feedOverlay.controls-hidden .fgrad { opacity: 0; }
#feedOverlay.controls-hidden .feed-ui { opacity: 0; pointer-events: none; }
.feed-ui { opacity: 1; transition: opacity .3s; }

#backBtn {
  position: absolute; top: calc(14px + env(safe-area-inset-top)); inset-inline-start: 14px;
  width: 42px; height: 42px; border-radius: 14px;
  background: rgba(10,10,18,.5); border: 1px solid rgba(255,255,255,.14);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  display: grid; place-items: center;
}
#backBtn:active { transform: scale(.92); }
#backBtn svg { width: 20px; height: 20px; }
#feedTopTitle {
  position: absolute; top: calc(21px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); max-width: 46%;
  font-size: 13.5px; font-weight: 700; text-shadow: 0 1px 10px rgba(0,0,0,.8);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
[dir="rtl"] #feedTopTitle { transform: translateX(50%); }
/* The feed is a full-bleed screen, so every bottom-anchored control has to clear
   the home indicator / gesture bar of a notched phone — the same
   `env(safe-area-inset-*)` the top bar and the tab bar already use. The insets
   are zero in a plain browser tab and in the editor preview, so nothing moves
   there. */
#rightRail { position: absolute; bottom: calc(132px + env(safe-area-inset-bottom)); inset-inline-end: 12px; display: flex; flex-direction: column; gap: 17px; align-items: center; }
/* Short windows (landscape phones, the editor's own preview pane): tighten the
   feed chrome. These overrides MUST live after the base rules they override
   (same specificity → source order decides), so the block is at the end of the
   feed-chrome rules below rather than here. */
.rail-btn { display: flex; flex-direction: column; align-items: center; gap: 5px; color: #fff; }
.rail-btn .rb-ic {
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(12,12,20,.44); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  display: grid; place-items: center; border: 1px solid rgba(255,255,255,.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.1);
  transition: transform .16s var(--ease), background .2s, box-shadow .2s;
}
.rail-btn:active .rb-ic { transform: scale(.9); }
.rail-btn .rb-ic svg { width: 21px; height: 21px; }
.rail-btn .rb-lbl { font-size: 10px; font-weight: 700; text-shadow: 0 1px 5px rgba(0,0,0,.85); }
.rail-btn.liked .rb-ic { background: var(--grad); border-color: transparent; box-shadow: var(--glow-pink); }
.rail-btn.saved .rb-ic { background: linear-gradient(135deg,#ffb020,#ff7a45); border-color: transparent; box-shadow: 0 10px 26px rgba(255,122,69,.4); }
.rail-btn.dim { opacity: .35; pointer-events: none; }
/* Short windows — landscape phones (≈390px of height), the editor's own preview
   pane, and any split-screen phone with the keyboard up. Six labelled buttons
   stacked above the info block need ~485px of rail; there is only ~275px above
   the info block in landscape, which used to push the top two off-screen. So:
   icon-only (the label is collapsed to zero height rather than removed, so the
   accessible name survives) and everything nudged down against the bottom.
   Rail height becomes 6×36 + 5×5 ≈ 241px, which fits the ~275px of headroom in
   landscape and the 359px desktop device frame alike. */
@media (max-height: 640px) {
  #rightRail { bottom: calc(104px + env(safe-area-inset-bottom)); gap: 5px; }
  .rail-btn { gap: 0; }
  .rail-btn .rb-ic { width: 34px; height: 34px; }
  .rail-btn .rb-ic svg { width: 16px; height: 16px; }
  .rail-btn .rb-lbl { height: 0; overflow: hidden; font-size: 0; }
}

#feedInfo { position: absolute; bottom: calc(78px + env(safe-area-inset-bottom)); inset-inline-start: 16px; inset-inline-end: 80px; display: flex; flex-direction: column; gap: 4px; }
/* Scraped titles are arbitrary: a long unbroken run (a hash, a URL, a title with
   no spaces) must wrap inside the block instead of being laid out past the
   screen edge, which is what "the text runs off the display" looks like. */
#feedEpLabel { font-size: 11px; font-weight: 800; letter-spacing: .7px; color: #ff9dc0; text-transform: uppercase; overflow-wrap: anywhere; overflow: hidden; }
#feedTitle { font-size: 18px; font-weight: 850; line-height: 1.24; letter-spacing: -.2px; text-shadow: 0 2px 14px rgba(0,0,0,.95), 0 1px 3px rgba(0,0,0,.9); overflow-wrap: anywhere; overflow: hidden; max-width: 100%; }
#feedDesc {
  font-size: 12.5px; color: rgba(255,255,255,.9); line-height: 1.45; margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  overflow-wrap: anywhere;
  text-shadow: 0 1px 6px rgba(0,0,0,.85);
}
/* Bottom chrome. It is deliberately NOT part of the fading control group: a
   player with no visible pause button, and a progress bar that disappears three
   seconds into every episode, reads as a player with no controls at all. */
#feedBottom {
  position: absolute; bottom: calc(16px + env(safe-area-inset-bottom)); left: 12px; right: 14px;
  display: flex; align-items: center; gap: 10px; z-index: 3;
}
#ppBtn {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%;
  background: rgba(10,10,18,.52); border: 1px solid rgba(255,255,255,.17);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.14);
  transition: transform .16s var(--ease);
}
#ppBtn:active { transform: scale(.9); }
#ppBtn svg { width: 17px; height: 17px; }
#ppBtn.dim { opacity: .4; pointer-events: none; }
#fsBtn {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%;
  background: rgba(10,10,18,.52); border: 1px solid rgba(255,255,255,.17);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.14);
  transition: transform .16s var(--ease);
}
#fsBtn:active { transform: scale(.9); }
#fsBtn svg { width: 17px; height: 17px; }
#seekCol { flex: 1 1 auto; min-width: 0; }
/* A 26px-tall gesture surface around a 4px bar: the bar keeps its look, the
   finger gets something it can actually grab. `touch-action: none` keeps the
   feed's own swipe recogniser from stealing the drag halfway through. */
#seekZone { position: relative; height: 26px; display: flex; align-items: center; touch-action: none; cursor: pointer; }
#progressWrap {
  position: relative; width: 100%; height: 4px; border-radius: 4px;
  background: rgba(255,255,255,.22); overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.45);
  transition: height .15s var(--ease);
}
/* Buffered-ahead range, so a slow download is legible instead of a bar that
   stops moving for no visible reason. */
#progressBuf { position: absolute; top: 0; bottom: 0; inset-inline-start: 0; width: 0%; background: rgba(255,255,255,.32); }
#progressBar { position: relative; height: 100%; width: 0%; background: var(--grad); border-radius: 4px; box-shadow: 0 0 12px rgba(255,61,129,.8); }
#seekZone.scrubbing #progressWrap { height: 7px; }
#seekZone.scrubbing #progressBar { box-shadow: 0 0 18px rgba(255,61,129,1); }
#seekBubble {
  position: absolute; bottom: 26px; transform: translateX(-50%);
  padding: 4px 9px; border-radius: 9px; white-space: nowrap;
  background: rgba(8,8,14,.9); border: 1px solid rgba(255,255,255,.18);
  font-size: 11.5px; font-weight: 800; color: #fff; letter-spacing: .2px;
  opacity: 0; transition: opacity .15s; pointer-events: none;
  box-shadow: 0 8px 22px rgba(0,0,0,.5);
}
#seekZone.scrubbing #seekBubble { opacity: 1; }
#timeRow { display: flex; justify-content: space-between; margin-top: 1px; font-size: 10.5px; font-weight: 700; color: rgba(255,255,255,.8); text-shadow: 0 1px 4px rgba(0,0,0,.8); }
#playPauseBtn {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: 78px; height: 78px; border-radius: 50%;
  background: rgba(10,10,18,.5); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  display: grid; place-items: center; border: 1px solid rgba(255,255,255,.2);
  box-shadow: 0 18px 50px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.16);
}
#playPauseBtn:active { transform: translate(-50%,-50%) scale(.93); }
#playPauseBtn svg { width: 30px; height: 30px; margin-inline-start: 3px; }

/* Transient tutorial/next-up hint. It sits in the empty band between the info
   block and the action rail, and stops short of the rail so a long line can
   never run under the buttons. */
#nextHint {
  position: absolute; bottom: calc(300px + env(safe-area-inset-bottom)); inset-inline-start: 16px; inset-inline-end: 88px;
  text-align: center; pointer-events: none;
  padding: 9px 14px; border-radius: 16px;
  background: rgba(10,10,18,.62); border: 1px solid rgba(255,255,255,.13);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 12px 36px rgba(0,0,0,.45);
  font-size: 12px; font-weight: 700; line-height: 1.4; color: #fff; overflow-wrap: anywhere;
  opacity: 0; transform: translateY(10px); transition: opacity .3s var(--ease), transform .3s var(--ease);
  text-shadow: 0 1px 8px rgba(0,0,0,.9);
}
#nextHint.show { opacity: 1; transform: translateY(0); }

@media (max-height: 640px) {
  #feedInfo { bottom: calc(62px + env(safe-area-inset-bottom)); }
  #feedBottom { bottom: calc(11px + env(safe-area-inset-bottom)); }
  #nextHint { bottom: calc(200px + env(safe-area-inset-bottom)); }
}
/* Very short viewports (an old 640×320 phone in landscape, or a phone with the
   keyboard up in a split view) — below this, the 34px-icon rail no longer fits.
   6×32 + 5×4 + 92 = 304px of rail, so even a 320px-tall viewport keeps all six
   buttons on-screen. */
@media (max-height: 380px) {
  #rightRail { bottom: calc(92px + env(safe-area-inset-bottom)); gap: 4px; }
  .rail-btn .rb-ic { width: 30px; height: 30px; }
  .rail-btn .rb-ic svg { width: 15px; height: 15px; }
  #feedInfo { bottom: calc(56px + env(safe-area-inset-bottom)); }
  #feedBottom { bottom: calc(8px + env(safe-area-inset-bottom)); }
  #nextHint { bottom: calc(170px + env(safe-area-inset-bottom)); }
}

/* Desktop: device frame. Gated on a FINE pointer as well as width: a phone held
   in landscape is ≥720px wide, and it must NOT get a phone-shaped frame inside
   its own screen — it keeps the full-bleed feed. `any-pointer: fine` still
   matches a touchscreen laptop or a tablet with a mouse attached. */
@media (min-width: 720px) and (any-pointer: fine) {
  body::before { opacity: .85; }
  #app {
    max-width: 460px; margin: 0 auto; min-height: 100vh;
    border-left: 1px solid var(--line); border-right: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(10,10,18,.6), rgba(5,5,10,.35));
    box-shadow: 0 0 120px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.03);
    backdrop-filter: blur(2px);
  }
  body #tabBar { left: 50%; right: auto; transform: translateX(-50%); width: 460px; }
  .hscroll { gap: 15px; }
  #feedScreen {
    display: flex; align-items: center; justify-content: center;
    background: radial-gradient(1200px 600px at 20% 0%, rgba(124,92,255,.18), transparent 60%),
                radial-gradient(1000px 500px at 85% 100%, rgba(255,61,129,.16), transparent 60%), #07070d;
  }
  #feedFrame { position: relative; width: min(100vw - 48px, 420px); height: min(92vh, 900px); border-radius: 32px; overflow: hidden; box-shadow: 0 40px 130px rgba(0,0,0,.75), 0 0 0 1px rgba(255,255,255,.07); }
}

/* ============ Search ============ */
.search-bar { display: flex; gap: 9px; padding: 12px 16px 10px; }
.search-bar input {
  flex: 1; height: 46px; border-radius: 15px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); padding: 0 16px; font-size: 15px; outline: none;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
  transition: border-color .2s, box-shadow .2s;
}
.search-bar input::placeholder { color: var(--muted2); }
.search-bar input:focus { border-color: rgba(124,92,255,.8); box-shadow: 0 0 0 4px rgba(124,92,255,.16), var(--glow); }
.search-bar button {
  width: 48px; height: 46px; border-radius: 15px; background: var(--grad); display: grid; place-items: center;
  box-shadow: var(--glow), inset 0 1px 0 rgba(255,255,255,.32);
}
.search-bar button:active { transform: scale(.93); }
.search-bar button svg { width: 19px; height: 19px; }
.plat-toggle { display: flex; gap: 8px; padding: 0 16px 12px; }
.plat-toggle button { flex: 1; padding: 9px; border-radius: 11px; font-size: 12.5px; font-weight: 700; background: var(--surface); color: var(--muted); border: 1px solid var(--line); }
.plat-toggle button.active { background: var(--grad); color: #fff; border-color: transparent; box-shadow: var(--glow); }
.section-hdr {
  display: flex; align-items: center; gap: 9px; padding: 16px 16px 9px;
  font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 1.1px;
}
.section-hdr::before { content: ""; width: 3px; height: 14px; border-radius: 3px; background: var(--grad); flex: 0 0 auto; }
.res-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(134px, 1fr)); gap: 15px; padding: 4px 16px 24px; }
.res-grid .dcard { width: 100%; }
.empty-msg { text-align: center; color: var(--muted2); padding: 52px 20px; font-size: 14px; line-height: 1.6; }
#searchSpinner { display: flex; justify-content: center; padding: 40px; }

/* ============ Library ============ */
.lib-tabs {
  display: flex; gap: 4px; padding: 14px 16px 16px;
}
.lib-tabs button {
  flex: 1; padding: 10px 6px; border-radius: 12px; font-size: 12.5px; font-weight: 700;
  background: transparent; color: var(--muted); border: 1px solid transparent;
  transition: background .2s, color .2s, border-color .2s;
}
.lib-tabs button.active {
  background: var(--surface); color: var(--text); border-color: var(--line2);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 6px 18px rgba(0,0,0,.35);
  position: relative;
}
.lib-tabs button.active::after {
  content: ""; position: absolute; left: 50%; transform: translateX(-50%); bottom: -7px;
  width: 26px; height: 3px; border-radius: 3px; background: var(--grad); box-shadow: 0 0 12px rgba(255,61,129,.7);
}
#libraryContent { padding-bottom: 20px; }

/* ============ Modals / sheets ============ */
.modal-back {
  position: fixed; inset: 0; z-index: 90; background: rgba(3,3,7,.68);
  backdrop-filter: blur(10px) saturate(120%); -webkit-backdrop-filter: blur(10px) saturate(120%);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0; animation: backIn .22s var(--ease) both;
}
@keyframes backIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  position: relative; width: 100%; max-width: 520px;
  background: linear-gradient(180deg, rgba(30,30,46,.96), rgba(16,16,25,.98));
  border: 1px solid var(--line2); border-bottom: none;
  border-radius: 26px 26px 0 0;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  box-shadow: 0 -24px 70px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,255,255,.07);
  max-height: 88vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  animation: sheetUp .34s var(--ease) both;
}
@keyframes sheetUp { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
/* drag handle */
.modal::before {
  content: ""; position: absolute; top: 9px; left: 50%; transform: translateX(-50%);
  width: 42px; height: 4px; border-radius: 99px; background: rgba(255,255,255,.22);
}
.modal h3 { margin: 8px 0 18px; font-size: 18px; font-weight: 850; letter-spacing: -.2px; }
.modal h3::after { content: ""; display: block; width: 34px; height: 3px; border-radius: 3px; background: var(--grad); margin-top: 9px; box-shadow: 0 0 12px rgba(255,61,129,.6); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.set-row:first-of-type { border-top: none; }
.set-row .lbl { font-size: 14px; font-weight: 700; }
.set-row .sub { font-size: 11.5px; color: var(--muted2); margin-top: 3px; line-height: 1.45; }
.seg { display: flex; gap: 4px; padding: 3px; border-radius: 12px; background: rgba(0,0,0,.35); border: 1px solid var(--line); }
.seg button { padding: 7px 14px; border-radius: 9px; font-size: 12.5px; font-weight: 700; background: transparent; color: var(--muted); transition: background .2s, color .2s; }
.seg button.active { background: var(--grad); color: #fff; box-shadow: 0 6px 16px rgba(124,92,255,.4); }
.api-row { flex-direction: column; align-items: stretch; gap: 10px; }
.api-row .api-control input {
  width: 100%; padding: 11px 13px; border-radius: 12px;
  background: rgba(0,0,0,.32); border: 1px solid var(--line); color: var(--text);
  font-size: 13px; outline: none;
}
.api-row .api-control input:focus { border-color: rgba(124,92,255,.8); box-shadow: 0 0 0 3px rgba(124,92,255,.15); }
/* ============ Recovery-email form (Settings → Account) ============ */
.set-form { display: flex; flex-direction: column; gap: 8px; padding: 2px 0 14px; }
.set-form input {
  width: 100%; padding: 11px 13px; border-radius: 12px;
  background: rgba(0,0,0,.32); border: 1px solid var(--line); color: var(--text);
  font-size: 13px; outline: none;
}
.set-form input:focus { border-color: rgba(124,92,255,.8); box-shadow: 0 0 0 3px rgba(124,92,255,.15); }
.src-list { display: flex; flex-direction: column; gap: 9px; }
.src-item {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  background: rgba(255,255,255,.035); border: 1px solid var(--line); border-radius: 14px; padding: 11px 13px;
  transition: border-color .2s, background .2s;
}
.src-item.editing { border-color: rgba(124,92,255,.7); background: rgba(124,92,255,.08); }
.src-main { min-width: 0; }
.src-main .src-n { font-size: 13.5px; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.src-main .src-h { font-size: 11px; color: var(--muted2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.src-acts { display: flex; gap: 6px; flex-shrink: 0; }
.mini {
  padding: 7px 10px; border-radius: 10px; font-size: 11px; font-weight: 750;
  background: rgba(255,255,255,.06); border: 1px solid var(--line); color: var(--muted);
  transition: background .18s, color .18s, transform .14s var(--ease);
}
.mini:active { transform: scale(.94); }
.mini.on { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 6px 16px rgba(124,92,255,.35); }
.mini.danger { color: #ff7b8a; border-color: rgba(255,123,138,.28); }
.mini:disabled { opacity: .5; }
.src-head { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.src-head .mini { padding: 8px 12px; }
.src-tag {
  display: inline-block; margin-inline-start: 6px; padding: 2px 7px; border-radius: 7px;
  background: rgba(124,92,255,.14); border: 1px solid rgba(124,92,255,.3);
  font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px;
  color: #c9b7ff; vertical-align: middle;
}
.src-note { font-size: 10.5px; color: var(--muted2); line-height: 1.5; margin-top: 3px; }
.src-presets { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 4px; }
.src-preset-lbl { font-size: 10.5px; color: var(--muted2); font-weight: 700; letter-spacing: .4px; text-transform: uppercase; }
/* The one-tap starter sources: they should read as invitations, not as the same
   grey utility chips used for record actions. */
.src-presets .mini {
  padding: 7px 12px; background: var(--grad-soft); border-color: rgba(255,255,255,.17); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12);
}
.src-presets .mini:hover { border-color: rgba(255,61,129,.4); }
.src-form { display: flex; flex-direction: column; gap: 9px; margin-top: 11px; }
.src-form input {
  width: 100%; padding: 11px 13px; border-radius: 12px;
  background: rgba(0,0,0,.32); border: 1px solid var(--line); color: var(--text);
  font-size: 13px; outline: none;
}
.src-form input:focus { border-color: rgba(124,92,255,.8); }
.src-form textarea {
  width: 100%; padding: 11px 13px; border-radius: 12px; background: rgba(0,0,0,.42);
  border: 1px solid var(--line); color: var(--text); font-family: ui-monospace, "SFMono-Regular", monospace;
  font-size: 11.5px; line-height: 1.55; outline: none; resize: vertical;
}
.src-form textarea:focus { border-color: rgba(124,92,255,.8); }
.src-row { display: flex; gap: 8px; }
.src-row button { flex: 1; }
.src-form button:not(.ghost-btn) {
  padding: 12px 14px; border-radius: 12px; background: var(--grad); color: #fff;
  font-weight: 800; font-size: 13px; box-shadow: var(--glow), inset 0 1px 0 rgba(255,255,255,.3);
}
.modal .close-row { text-align: center; margin-top: 12px; }
.modal .close-row button { padding: 13px 0; width: 100%; border-radius: 14px; background: rgba(255,255,255,.07); border: 1px solid var(--line); font-weight: 750; font-size: 14px; }
.modal .about { margin-top: 14px; font-size: 11.5px; color: var(--muted2); line-height: 1.6; }

/* ============ Bottom tab bar ============ */
#tabBar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; justify-content: space-around; align-items: center;
  background: rgba(9,9,16,.9);
  backdrop-filter: blur(22px) saturate(160%); -webkit-backdrop-filter: blur(22px) saturate(160%);
  border-top: 1px solid var(--line);
  padding: 9px 6px calc(9px + env(safe-area-inset-bottom));
  box-shadow: 0 -14px 40px rgba(0,0,0,.5);
}
#tabBar::before {
  content: ""; position: absolute; top: -1px; left: 0; right: 0; height: 1px;
  background: var(--grad-line);
}
.tab {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 7px 20px; border-radius: 15px; color: var(--muted2);
  font-size: 10.5px; font-weight: 700; transition: color .2s, transform .16s var(--ease);
}
.tab svg { width: 22px; height: 22px; transition: transform .2s var(--ease); }
.tab:active { transform: scale(.93); }
.tab.active { color: #fff; }
.tab.active svg { transform: translateY(-1px) scale(1.06); }
.tab.active::before {
  content: ""; position: absolute; inset: -1px -4px; border-radius: 16px; z-index: -1;
  background: radial-gradient(60% 80% at 50% 100%, rgba(255,61,129,.24), rgba(124,92,255,.14) 60%, transparent 75%);
}
.tab.active::after {
  content: ""; position: absolute; top: -2px; left: 50%; transform: translateX(-50%);
  width: 22px; height: 3px; border-radius: 0 0 4px 4px; background: var(--grad);
  box-shadow: 0 3px 14px rgba(255,61,129,.75);
}

/* ============ Skeletons ============ */
.skel { position: relative; overflow: hidden; background: rgba(255,255,255,.055); }
.skel::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.09), transparent);
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }

/* ============ Toast ============ */
#toast {
  position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%) translateY(10px) scale(.96);
  background: rgba(28,28,44,.9); border: 1px solid var(--line2); color: #fff;
  padding: 11px 20px; border-radius: 999px; font-size: 13px; font-weight: 650; z-index: 100;
  opacity: 0; pointer-events: none; transition: opacity .26s var(--ease), transform .26s var(--ease);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.1);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
/* A toast that carries the retry action is the only affordance for a source
   that didn't answer, so it takes taps while it's up. */
#toast.tappable { pointer-events: auto; cursor: pointer; border-color: var(--accent); }
#toast.tappable::after { content: "↻"; margin-inline-start: 8px; color: var(--accent); font-weight: 800; }
#toast.tappable:active { transform: translateX(-50%) translateY(0) scale(.97); }

/* ============ Global activity pill ============ */
/* Sits just above the tab bar, centred, so a 30-second crawl is never a still
   screen. Deliberately compact (a ring + one word) so it informs without
   blocking — the grid behind it keeps filling in. */
#busyPill {
  position: fixed; z-index: 95; left: 50%; bottom: 100px;
  transform: translateX(-50%) translateY(14px) scale(.94);
  display: flex; align-items: center; gap: 9px;
  padding: 8px 15px 8px 11px; border-radius: 999px;
  background: rgba(20,20,33,.86); border: 1px solid var(--line2); color: var(--text);
  font-size: 12px; font-weight: 700; letter-spacing: .1px;
  box-shadow: 0 16px 44px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.08);
  backdrop-filter: blur(16px) saturate(150%); -webkit-backdrop-filter: blur(16px) saturate(150%);
  opacity: 0; pointer-events: none;
  transition: opacity .24s var(--ease), transform .3s var(--ease);
}
#busyPill.show { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
#busyPill .busy-ic {
  flex: 0 0 auto; width: 16px; height: 16px; border-radius: 50%;
  background: conic-gradient(from 90deg, rgba(255,255,255,.07) 0deg, rgba(124,92,255,.25) 110deg, var(--accent) 250deg, var(--accent2) 360deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2.6px), #000 calc(100% - 2.6px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 2.6px), #000 calc(100% - 2.6px));
  animation: spin .85s linear infinite;
  filter: drop-shadow(0 0 7px rgba(124,92,255,.6));
}
#busyPill .busy-txt { white-space: nowrap; }
#busyPill::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  padding: 1px;
  background: linear-gradient(120deg, rgba(255,255,255,.28), rgba(255,255,255,.02) 45%, rgba(255,61,129,.35));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}

/* ============ Browse / categories ============ */
.filters { padding: 6px 0 4px; }
.fgroup { margin: 12px 0; }
.fgroup.libs { margin-top: 16px; }
.f-lbl {
  padding: 0 16px 9px; font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 1.5px; color: rgba(246,246,251,.66);
  display: flex; align-items: center; gap: 7px;
}
/* The same gradient tick the Home rows use, so every section header in the app
   reads as the same component. */
.f-lbl::before {
  content: ""; width: 3px; height: 11px; border-radius: 2px; background: var(--grad);
  box-shadow: 0 0 9px rgba(255,61,129,.55);
}
.chips { display: flex; gap: 8px; padding: 0 16px 4px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 8px 15px; border-radius: 999px; font-size: 12.5px; font-weight: 700;
  background: rgba(255,255,255,.05); color: var(--muted); border: 1px solid var(--line);
  white-space: nowrap; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: color .18s, background .2s, transform .14s var(--ease), box-shadow .2s, border-color .2s;
}
.chip:active { transform: scale(.95); }
.chip.active {
  background: var(--grad); color: #fff; border-color: transparent;
  box-shadow: var(--glow), inset 0 1px 0 rgba(255,255,255,.3);
}
.chip .pct { font-size: 10.5px; opacity: .78; margin-inline-start: 5px; }
.chip.sub { opacity: .88; font-size: 11.5px; padding: 7px 13px; }
.chip.sub.active { opacity: 1; box-shadow: var(--glow-pink), inset 0 1px 0 rgba(255,255,255,.3); }
.plat-info {
  margin: 12px 16px 6px; padding: 13px 15px; border-radius: 16px;
  background: var(--grad-soft); border: 1px solid var(--line2);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.plat-info .pn { font-size: 15px; font-weight: 850; letter-spacing: -.2px; }
.plat-info .ps { font-size: 12px; color: var(--muted); margin-top: 2px; }
.plat-info .cover { font-size: 12px; font-weight: 800; color: var(--good); white-space: nowrap; }
.plat-info .cover.low { color: var(--gold); }
.load-row { display: flex; justify-content: center; padding: 8px 0 30px; }
.ghost-btn {
  padding: 12px 28px; border-radius: 999px; font-size: 13.5px; font-weight: 750;
  background: rgba(255,255,255,.06); border: 1px solid var(--line2); color: var(--text);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07);
  transition: transform .14s var(--ease), background .2s;
}
.ghost-btn:hover { background: rgba(255,255,255,.11); }
.ghost-btn:active { transform: scale(.96); opacity: .9; }
#browseGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(134px, 1fr)); gap: 15px; padding: 10px 16px 4px; }
#browseGrid .dcard { width: 100%; }
/* A genre with nothing matching yet (the crawl is still walking pages) shows a
   ring in the grid itself, so the screen never looks frozen. */
#browseGrid.is-busy::before {
  content: ""; grid-column: 1 / -1; width: 52px; height: 52px; margin: 44px auto;
  border-radius: 50%;
  background: conic-gradient(from 90deg, rgba(255,255,255,.07) 0deg, rgba(124,92,255,.25) 110deg, var(--accent) 250deg, var(--accent2) 360deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 4px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 4px));
  animation: spin .85s linear infinite;
  filter: drop-shadow(0 0 12px rgba(124,92,255,.5));
}
.res-loading { display: flex; justify-content: center; padding: 26px; grid-column: 1 / -1; }

/* ============ Subtitles sheet ============ */
.sub-list { display: flex; flex-direction: column; gap: 9px; }
.sub-item {
  padding: 13px 15px; border-radius: 14px; background: rgba(255,255,255,.045); border: 1px solid var(--line);
  text-align: start; font-size: 13.5px; font-weight: 650; color: var(--text);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  transition: background .2s, border-color .2s, transform .14s var(--ease);
}
.sub-item:active { transform: scale(.98); }
.sub-item.active { background: var(--grad); border-color: transparent; color: #fff; box-shadow: var(--glow); }
.sub-item .sl { font-size: 11px; color: var(--muted); }
.sub-item.active .sl { color: rgba(255,255,255,.85); }
.sub-head { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: var(--muted2); padding: 8px 2px 0; }
.sub-note { font-size: 12px; color: var(--muted2); padding: 8px 2px 4px; line-height: 1.55; }

/* ============ Share sheet ============ */
.share-subject { font-size: 13px; font-weight: 700; color: var(--muted); margin: -6px 0 13px; overflow-wrap: anywhere; }
.share-link-row { display: flex; gap: 8px; }
.share-link-row input {
  flex: 1; min-width: 0; padding: 11px 13px; border-radius: 12px; background: rgba(0,0,0,.34);
  border: 1px solid var(--line); color: var(--text); font-size: 12.5px; outline: none;
}
.share-link-row input:focus { border-color: rgba(124,92,255,.8); }
.share-link-row button {
  padding: 11px 16px; border-radius: 12px; background: var(--grad); color: #fff;
  font-weight: 800; font-size: 12.5px; white-space: nowrap;
  box-shadow: var(--glow), inset 0 1px 0 rgba(255,255,255,.3);
}
.share-status { font-size: 11.5px; color: var(--muted2); line-height: 1.5; min-height: 16px; margin-top: 9px; }
.share-status.err { color: #ff7b8a; }
.share-native {
  width: 100%; margin-top: 11px; padding: 12px 0; border-radius: 14px;
  background: rgba(255,255,255,.06); border: 1px solid var(--line2); color: var(--text);
  font-weight: 750; font-size: 13.5px;
}
.share-native:active { transform: scale(.97); }
.share-via { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: var(--muted2); margin: 18px 0 9px; }
.share-targets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.share-target {
  display: flex; align-items: center; justify-content: center; padding: 13px 6px; border-radius: 14px;
  background: rgba(255,255,255,.05); border: 1px solid var(--line); color: var(--text);
  font-size: 12px; font-weight: 700; text-decoration: none; text-align: center;
  transition: background .2s, transform .14s var(--ease);
}
.share-target:active { transform: scale(.96); opacity: .9; }

/* ============ Admin / relay node ============ */
#relayBadge {
  position: fixed; inset-inline-end: 14px; bottom: 88px; z-index: 60;
  display: flex; align-items: center; gap: 7px; padding: 10px 15px; border-radius: 999px;
  background: rgba(24,24,38,.86); border: 1px solid var(--line2); color: var(--text);
  font-size: 12px; font-weight: 800; box-shadow: var(--shadow);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
#relayBadge .dot-live { width: 8px; height: 8px; border-radius: 50%; background: var(--good); animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(46,230,168,.55); } 70% { box-shadow: 0 0 0 9px rgba(46,230,168,0); } 100% { box-shadow: 0 0 0 0 rgba(46,230,168,0); } }
.admin-modal { max-height: 92vh; overflow-y: auto; }
.admin-modal #adminMain .close-row {
  position: sticky; bottom: -22px; margin: 14px 0 -22px; padding: 13px 0;
  background: linear-gradient(180deg, rgba(16,16,25,0), rgba(16,16,25,.96) 34%);
  display: flex; gap: 8px;
}
.admin-modal #adminMain .close-row button { flex: 1; }
.admin-modal #adminMain .close-row .ghost-btn { background: rgba(255,255,255,.07); color: var(--muted); }
.admin-stack { flex-direction: column; align-items: stretch; gap: 10px; }
.admin-stack .seg { align-self: flex-start; }
.admin-stack .admin-sub { max-width: none; }
.admin-note { font-size: 12.5px; color: var(--muted); line-height: 1.6; margin: 4px 0 13px; }
.admin-sub { font-size: 11.5px; color: var(--muted2); line-height: 1.5; margin-top: 3px; max-width: 240px; }
.admin-msg { font-size: 12px; color: var(--good); min-height: 16px; margin-top: 9px; }
.admin-msg.err { color: #ff7b8a; }
.admin-modal input[type="password"], .admin-modal input[type="text"] {
  width: 100%; padding: 11px 13px; border-radius: 12px; background: rgba(0,0,0,.34);
  border: 1px solid var(--line); color: var(--text); font-size: 13.5px; outline: none;
}
.admin-modal input:focus { border-color: rgba(124,92,255,.8); }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin: 6px 0 15px; }
.stat {
  background: rgba(255,255,255,.045); border: 1px solid var(--line); border-radius: 14px; padding: 11px 6px; text-align: center;
}
.stat .sv { font-size: 15.5px; font-weight: 850; }
.stat .sl { font-size: 10.5px; color: var(--muted2); margin-top: 3px; }
.admin-inline { display: flex; gap: 8px; align-items: center; }
.admin-inline input { flex: 1; }
.admin-inline button {
  padding: 11px 15px; border-radius: 12px; background: var(--grad); color: #fff;
  font-weight: 800; font-size: 12.5px; white-space: nowrap;
  box-shadow: var(--glow), inset 0 1px 0 rgba(255,255,255,.3);
}
.log-hdr { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: var(--muted2); margin: 15px 0 7px; }
.admin-log {
  height: 122px; overflow-y: auto; background: rgba(0,0,0,.42); border: 1px solid var(--line);
  border-radius: 12px; padding: 9px 11px; font-family: ui-monospace, "SFMono-Regular", monospace;
  font-size: 11px; color: var(--muted);
}
.admin-log .log-line { padding: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-log .log-line.err { color: #ff7b8a; }

/* ============ Sign in / register gate ============ */
.gate {
  position: fixed; inset: 0; z-index: 130;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(124,92,255,.35) 0%, rgba(124,92,255,0) 55%),
    radial-gradient(90% 60% at 100% 100%, rgba(255,61,129,.22) 0%, rgba(255,61,129,0) 60%),
    linear-gradient(180deg, #08070f, #05050a 70%);
  overflow-y: auto;
}
.gate-card {
  width: min(100%, 372px);
  /* `margin: auto` rather than the flex container's `align-items: center`: a
     centred item that is taller than the viewport (the register form with the
     recovery-email row, on a small phone) would otherwise have its top clipped
     with no way to scroll to it. Auto margins centre it when it fits and let the
     gate's `overflow-y: auto` reach the top when it doesn't. */
  margin: auto;
  background: linear-gradient(180deg, rgba(30,30,48,.86), rgba(14,14,23,.94));
  border: 1px solid var(--line2);
  border-radius: 26px; padding: 24px 22px; box-shadow: 0 30px 90px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,255,255,.08);
  display: flex; flex-direction: column; gap: 10px;
  backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
  animation: sheetUp .4s var(--ease) both;
}
.gate-brand { display: flex; align-items: center; gap: 10px; font-weight: 850; font-size: 22px; margin-bottom: 3px; letter-spacing: -.3px; }
.gate-brand > span:last-child {
  background: linear-gradient(100deg, #fff 8%, #d9c9ff 46%, #ff97bf 92%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.gate-brand .logo {
  position: relative; width: 36px; height: 36px; border-radius: 12px; background: var(--grad);
  display: grid; place-items: center; box-shadow: var(--glow), inset 0 1px 0 rgba(255,255,255,.35);
}
.gate-brand .logo::after {
  content: ""; position: absolute; inset: -3px; border-radius: 15px; z-index: -1;
  background: conic-gradient(from 0deg, rgba(124,92,255,.9), rgba(255,61,129,.9), rgba(47,230,208,.85), rgba(124,92,255,.9));
  filter: blur(10px); opacity: .6; animation: haloSpin 9s linear infinite;
}
.gate-brand .logo svg { width: 18px; height: 18px; }
.gate-sub { font-size: 12.5px; color: var(--muted2); line-height: 1.55; margin-bottom: 8px; }
.gate-tabs { display: flex; gap: 4px; margin-bottom: 6px; padding: 3px; border-radius: 13px; background: rgba(0,0,0,.34); border: 1px solid var(--line); }
.gate-tabs button {
  flex: 1; padding: 10px; border-radius: 10px; font-size: 13px; font-weight: 750;
  background: transparent; color: var(--muted); transition: background .2s, color .2s;
}
.gate-tabs button.active { background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(124,92,255,.4); }
.gate-lbl { font-size: 11.5px; font-weight: 750; color: var(--muted); margin-top: 5px; }
.gate input[type="text"], .gate input[type="password"], .gate input[type="email"] {
  width: 100%; padding: 12px 13px; border-radius: 13px; background: rgba(0,0,0,.34);
  border: 1px solid var(--line); color: var(--text); font-size: 14px; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.gate input:focus { border-color: rgba(124,92,255,.85); box-shadow: 0 0 0 4px rgba(124,92,255,.15); }
.gate-captcha { display: flex; align-items: center; gap: 8px; }
.gate-captcha canvas {
  flex: 1; height: 58px; border-radius: 13px; border: 1px solid var(--line);
  background: rgba(0,0,0,.4); -webkit-user-select: none; user-select: none;
}
.gate-captcha button {
  width: 44px; height: 58px; border-radius: 13px; background: rgba(255,255,255,.06);
  border: 1px solid var(--line); color: var(--muted); font-size: 20px; flex-shrink: 0;
}
.gate-captcha button:active { transform: scale(.94); }
/* "Keep me signed in on this device" — on by default, because re-typing a
   password every time you open a watch app is the fastest way to lose a viewer.
   The whole row is the label, so the tap target is generous on a phone. */
.gate-remember {
  display: flex; align-items: flex-start; gap: 10px; margin-top: 12px; padding: 9px 11px;
  border-radius: 13px; background: rgba(255,255,255,.035); border: 1px solid var(--line);
  cursor: pointer; transition: background .2s, border-color .2s;
}
.gate-remember:active { background: rgba(255,255,255,.07); }
.gate-remember input { width: 16px; height: 16px; margin-top: 1px; flex-shrink: 0; accent-color: var(--accent); }
.gate-remember .gr-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.gate-remember .gr-t { font-size: 12.5px; font-weight: 700; color: var(--text); }
.gate-remember .gr-s { font-size: 11px; color: var(--muted2); line-height: 1.45; }
.gate-go {
  margin-top: 12px; width: 100%; padding: 14px 0; border-radius: 15px;
  background: var(--grad); color: #fff; font-weight: 850; font-size: 15px;
  box-shadow: var(--glow), inset 0 1px 0 rgba(255,255,255,.32);
  transition: transform .14s var(--ease);
}
.gate-go:active { transform: scale(.98); }
.gate-go:disabled { opacity: .55; box-shadow: none; }
.gate-msg { min-height: 16px; font-size: 12px; color: #ff7b8a; line-height: 1.5; }
.gate-msg.ok { color: var(--good); }
.gate-foot { font-size: 11px; color: var(--muted2); line-height: 1.55; margin-top: 2px; }
/* Shown on the licence gate for a viewer who has no key yet — the way to buy
   one. An <a> styled as a button, so it behaves the same in a browser and in
   the Android/iOS WebView (target=_blank, no window.open involved). */
.lic-buy {
  display: block; margin-top: 12px; padding: 13px 0; border-radius: 15px; text-align: center;
  background: rgba(255,255,255,.06); border: 1px solid var(--line); color: var(--text);
  font-weight: 800; font-size: 14px; text-decoration: none;
}
.lic-buy:hover { background: rgba(255,255,255,.11); border-color: var(--line-2); }
.lic-buy:active { transform: scale(.98); }
.gate-bound { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }

/* ============ Forgot password (gate) ============ */
.gate-hint { font-size: 11px; color: var(--muted2); line-height: 1.5; margin-top: 4px; }
.gate-links { display: flex; flex-wrap: wrap; gap: 2px 16px; align-items: center; }
.gate-link {
  background: transparent; color: var(--muted); font-size: 12px; font-weight: 700;
  padding: 6px 2px; margin-top: 6px; text-decoration: underline; text-underline-offset: 3px;
  text-decoration-color: rgba(255,255,255,.24);
}
.gate-link:hover { color: var(--text); }
.gate-reset-note { font-size: 12px; color: var(--muted2); line-height: 1.55; margin: 6px 0 2px; }
.gate-reset-note.on { color: var(--good); }

/* ============ Account row in Settings ============ */
.acct-name { font-size: 13.5px; font-weight: 750; }
.acct-name.off { color: var(--muted2); font-weight: 600; }

/* ============ Live-search / server bits ============ */
.src-check { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--muted); padding: 7px 2px; cursor: pointer; }
.src-check input { width: 16px; height: 16px; accent-color: var(--accent); }
.src-note.hidden { display: none; }

/* ============ Admin tabs, users & settings ============ */
.admin-tabs { display: flex; gap: 4px; margin-bottom: 15px; padding: 3px; border-radius: 13px; background: rgba(0,0,0,.34); border: 1px solid var(--line); }
.admin-tabs button {
  flex: 1; padding: 10px 6px; border-radius: 10px; font-size: 12.5px; font-weight: 750;
  background: transparent; color: var(--muted); transition: background .2s, color .2s;
}
.admin-tabs button.active { background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(124,92,255,.4); }
.admin-tab { display: block; }
.admin-bound { font-size: 11.5px; color: var(--muted2); line-height: 1.55; margin: 11px 0 2px; }
.admin-bound b { color: var(--muted); }
.admin-userbar { margin-bottom: 11px; }
.admin-users { display: flex; flex-direction: column; gap: 8px; }
.admin-user {
  background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 12px; display: flex; flex-direction: column; gap: 8px;
}
.admin-user.banned { opacity: .58; }
.au-info { min-width: 0; }
.au-name { font-size: 13px; font-weight: 750; display: flex; align-items: center; gap: 6px; }
.au-name.banned { text-decoration: line-through; color: #ff7b8a; }
.au-meta { font-size: 10.5px; color: var(--muted2); margin-top: 3px; }
.au-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.au-reset { display: flex; gap: 6px; align-items: center; }
.au-reset input {
  flex: 1; min-width: 0; padding: 9px 11px; border-radius: 10px; background: rgba(0,0,0,.34);
  border: 1px solid var(--line); color: var(--text); font-size: 12.5px; outline: none;
}
.au-reset input:focus { border-color: rgba(124,92,255,.8); }

/* ============ Admin console — full-screen desktop web panel ============ */
/* NOT part of the phone app. When its route (?superadminpanelxt1) is open the
   whole app shell is hidden and this frame owns the viewport, so the same
   address opened on a laptop is an ordinary web admin dashboard. The rules
   below deliberately come LAST in the file so they win over the sheet-era admin
   styles above (equal specificity, later wins). */
body.admin-mode #app,
body.admin-mode #tabBar,
body.admin-mode #authGate,
body.admin-mode #settingsModal,
body.admin-mode #shareModal,
body.admin-mode #subModal,
body.admin-mode #relayBadge { display: none !important; }

.modal-back.admin-shell {
  align-items: stretch; justify-content: stretch; padding: 0;
  background: radial-gradient(1100px 560px at 12% -12%, rgba(124,92,255,.17), transparent 62%), var(--bg2);
  backdrop-filter: none; -webkit-backdrop-filter: none;
  z-index: 200;
}
.admin-frame { width: 100%; height: 100%; display: flex; min-height: 0; }

/* ---- sign-in ---- */
.admin-login { flex: 1; display: grid; place-items: center; padding: 32px 20px; overflow-y: auto; }
.admin-login-card {
  width: 100%; max-width: 470px; padding: 28px 26px 24px; border-radius: 20px;
  background: linear-gradient(180deg, rgba(32,32,50,.86), rgba(13,13,21,.96));
  border: 1px solid var(--line2); box-shadow: 0 34px 90px rgba(0,0,0,.62), inset 0 1px 0 rgba(255,255,255,.06);
}
.admin-login-card h3 { margin: 20px 0 12px; font-size: 20px; font-weight: 850; letter-spacing: -.3px; }
.admin-brand { display: flex; align-items: center; gap: 11px; }
.admin-logo {
  width: 30px; height: 30px; border-radius: 10px; flex-shrink: 0;
  background: var(--grad); box-shadow: 0 0 18px rgba(255,61,129,.45);
}
.admin-brand-name { font-size: 15px; font-weight: 850; letter-spacing: -.2px; }
.admin-brand-sub { font-size: 10px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted2); margin-top: 2px; }
.admin-url-note {
  display: block; margin: 0 0 16px; padding: 9px 11px; border-radius: 10px; word-break: break-all;
  background: rgba(0,0,0,.38); border: 1px solid var(--line); color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", monospace; font-size: 11.5px;
  direction: ltr; text-align: left; white-space: pre-line;
}
.admin-login-card input[type="password"] { width: 100%; margin-bottom: 10px; }
.admin-login-card .src-row button {
  padding: 13px 0; border-radius: 13px; background: var(--grad); color: #fff;
  font-weight: 800; font-size: 14px; box-shadow: 0 10px 26px rgba(124,92,255,.35);
}

/* ---- console shell ---- */
.admin-main { flex: 1; display: flex; min-height: 0; min-width: 0; }
.admin-side {
  width: 248px; flex-shrink: 0; display: flex; flex-direction: column;
  padding: 20px 14px; border-right: 1px solid var(--line); background: rgba(0,0,0,.3);
}
.admin-side .admin-brand { padding: 2px 8px 20px; }
.admin-tabs {
  display: flex; flex-direction: column; gap: 4px;
  margin: 0; padding: 0; background: none; border: none; border-radius: 0;
}
.admin-tabs button {
  display: flex; align-items: center; gap: 10px; text-align: left; flex: none;
  padding: 11px 12px; border-radius: 11px; font-size: 13.5px; font-weight: 750;
  background: transparent; color: rgba(255,255,255,.74); transition: background .18s, color .18s;
}
.admin-tabs button:hover { background: rgba(255,255,255,.08); color: #fff; }
.admin-tabs button.active { background: var(--grad); color: #fff; box-shadow: 0 8px 22px rgba(124,92,255,.35); }
.admin-tabs .at-ic { width: 16px; text-align: center; font-size: 13px; opacity: .9; }
.admin-side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 18px; }
.admin-side-foot .admin-bound { margin: 0 0 6px; color: var(--muted); }
.admin-side-foot button {
  width: 100%; padding: 11px 0; border-radius: 12px; font-weight: 750; font-size: 13px;
  background: rgba(255,255,255,.1); border: 1px solid var(--line2); color: rgba(255,255,255,.86);
}
.admin-side-foot button:hover { background: rgba(255,255,255,.16); color: #fff; }

/* `min-height: 0` on both the column and its scroller is what keeps a tall panel
   scrolling INSIDE the console instead of stretching the fixed panel past the
   viewport (matters most in the narrow/stacked layout below). */
.admin-content { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.admin-topbar {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 26px; flex-wrap: wrap;
  padding: 22px 28px 16px; border-bottom: 1px solid var(--line);
}
.admin-topbar h2 { margin: 0; font-size: 21px; font-weight: 850; letter-spacing: -.3px; }
.admin-topbar-sub { font-size: 12px; color: var(--muted); margin-top: 5px; max-width: 520px; line-height: 1.5; }
.admin-topbar .stat-grid { margin: 0; min-width: 420px; grid-template-columns: repeat(4, minmax(96px, 1fr)); gap: 10px; }
.admin-topbar .stat .sl { color: var(--muted); }
.admin-scroll { flex: 1; overflow-y: auto; padding: 20px 28px 48px; }
.admin-grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 14px; align-items: start; }
.admin-card {
  background: rgba(255,255,255,.028); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px 18px; margin-bottom: 14px;
}
.admin-grid2 .admin-card { margin-bottom: 0; }
.admin-card-h { font-size: 13.5px; font-weight: 800; margin-bottom: 5px; }
.admin-card .admin-sub { max-width: none; margin-bottom: 10px; color: var(--muted); }
.admin-card .set-row { padding: 12px 0; }
.admin-log { height: 230px; }
.admin-users { flex-direction: column; gap: 7px; display: flex; }
.admin-user {
  flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 12px; padding: 11px 14px; border-radius: 13px;
}
.admin-user .au-acts { flex-shrink: 0; }
.admin-userbar { margin-bottom: 12px; }
.admin-shell input[type="password"], .admin-shell input[type="text"], .admin-shell input[type="email"] {
  padding: 12px 14px; border-radius: 13px; background: rgba(0,0,0,.45);
  border: 1px solid var(--line2); color: var(--text); font-size: 13.5px; outline: none;
}
.admin-shell input:focus { border-color: rgba(124,92,255,.8); }
.admin-shell .admin-inline { display: flex; gap: 8px; align-items: center; }
.admin-shell .admin-inline input { flex: 1; min-width: 0; }
/* `.admin-inline button` gives the primary gradient to e.g. "Send"; a ghost
   button that happens to sit in an inline row (Refresh, …) must keep its own
   quieter look. */
.admin-shell .admin-inline .ghost-btn {
  background: rgba(255,255,255,.1); border: 1px solid var(--line2);
  color: rgba(255,255,255,.86); box-shadow: none;
}
.admin-shell .admin-inline .ghost-btn:hover { background: rgba(255,255,255,.16); color: #fff; }
/* Row metadata (joined/seen) is a supporting line, but on a desktop card the
   phone's dimmest grey is unreadable — one step up. */
.admin-shell .au-meta { color: var(--muted); }
.admin-shell .au-meta.dim { color: var(--muted2); font-style: italic; }

/* Narrow screens (or a phone opening the console): stack the sidebar on top. */
@media (max-width: 860px) {
  .admin-main { flex-direction: column; }
  .admin-side { width: 100%; flex: 0 0 auto; border-right: none; border-bottom: 1px solid var(--line); padding: 14px; }
  .admin-content { flex: 1 1 auto; min-height: 0; }
  .admin-scroll { min-height: 0; }
  .admin-side .admin-brand { padding: 2px 6px 14px; }
  .admin-tabs { flex-direction: row; overflow-x: auto; }
  .admin-tabs button { flex: none; white-space: nowrap; padding: 9px 12px; }
  .admin-side-foot { margin-top: 12px; flex-direction: row; padding-top: 0; }
  .admin-side-foot .admin-bound { display: none; }
  .admin-topbar { padding: 16px; gap: 14px; }
  .admin-topbar .stat-grid { min-width: 0; width: 100%; grid-template-columns: repeat(2, 1fr); }
  .admin-scroll { padding: 16px 16px 40px; }
}

/* ============================================================================
   Native app viewport (mobile export)
   ----------------------------------------------------------------------------
   ReelVerse ships inside a phone shell — a WebView pointed at the generator
   page — so it has to behave like an app rather than like a web page. The three
   things that give a page away are: the view zooming in when a field takes
   focus, double-tap/pinch zooming the whole view, and text that reflows when the
   device rotates.

   iOS auto-zooms whenever a focused text field renders below 16px, and every
   field in this app (search 15px, sign-in 14px, share 12.5px, the source and
   admin inputs 13px) was below that line. On touch — and at the phone breakpoint,
   where the desktop preview is driven by a mouse — text fields are pinned to
   16px so focus never zooms. Icon-sized checkboxes/radios are excluded: they
   carry no text and must keep their fixed box.

   `touch-action: manipulation` (set on `html`/`body` at the top of this file)
   drops the double-tap zoom gesture while leaving panning and momentum scrolling
   intact; `-webkit-text-size-adjust: 100%` stops the iOS landscape text
   inflation. `overscroll-behavior: none` stops document rubber-banding and
   pull-to-refresh.

   Pinch zoom of the *host* page (the top-level Perchance document our iframe
   lives in) cannot be reached from here — a subframe can't change its parent's
   viewport — so the exported shell has to be built without its own zoom:
   Android `webSettings.setSupportZoom(false)` + `setBuiltInZoomControls(false)`,
   iOS `webView.scrollView.pinchGestureRecognizer.isEnabled = false`. The app
   additionally cancels iOS's `gesturestart/change/end` (pinch/rotate) inside its
   own document — see `applyNativeViewport()` in src/app.js. Both are written up
   in src/README.md → "Exporting to a mobile app".
   ========================================================================== */
@media (pointer: coarse), (max-width: 720px) {
  /* `.src-form textarea` is named explicitly: it is the JSON rule editor, and its
     own 11.5px monospace rule would otherwise out-rank the bare `textarea` here. */
  input:not([type="checkbox"]):not([type="radio"]), textarea, select,
  .src-form textarea { font-size: 16px; }
  /* A 16px field in a 46px row keeps its proportions; the compact rows just grow
     a few pixels taller, which is the right trade on a touch screen. */
  .search-bar input, .search-bar button { height: 48px; }
}

/* ============ Boot splash ============ */
/* Painted before the app boots (see #bootSplash in index.html and
   hideBootSplash() in src/app.js). A solid background, not a translucent one:
   its whole job is to cover the unstyled document that exists for the first
   frames, so anything that could show through defeats it. */
.boot-splash {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(124,92,255,.34) 0%, rgba(124,92,255,0) 58%),
    radial-gradient(90% 60% at 50% 110%, rgba(255,61,129,.24) 0%, rgba(255,61,129,0) 62%),
    linear-gradient(180deg, #08070f, #05050a 70%);
  transition: opacity .32s ease;
}
.boot-splash[hidden] { display: none !important; }
.boot-splash.bs-out { opacity: 0; pointer-events: none; }
.bs-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 0 30px; text-align: center; }
.bs-logo {
  width: 62px; height: 62px; border-radius: 20px; display: grid; place-items: center; position: relative;
  background: var(--grad); box-shadow: 0 18px 50px rgba(124,92,255,.45), inset 0 1px 0 rgba(255,255,255,.35);
  animation: bsPop .5s var(--ease) both;
}
.bs-logo svg { width: 30px; height: 30px; }
.bs-logo::after {
  content: ""; position: absolute; inset: -3px; border-radius: 23px;
  background: conic-gradient(from 0deg, rgba(255,255,255,0), rgba(255,255,255,.55), rgba(255,255,255,0));
  animation: haloSpin 2.6s linear infinite; z-index: -1;
}
.bs-name { font-size: 23px; font-weight: 850; letter-spacing: -.4px; }
.bs-line { font-size: 12.5px; color: var(--muted2); min-height: 16px; }
.bs-bar {
  width: 128px; height: 3px; border-radius: 3px; overflow: hidden;
  background: rgba(255,255,255,.09);
}
.bs-bar span {
  display: block; width: 40%; height: 100%; border-radius: 3px; background: var(--grad);
  animation: bsSlide 1.15s ease-in-out infinite;
}
@keyframes bsSlide { 0% { transform: translateX(-105%); } 100% { transform: translateX(355%); } }
@keyframes bsPop { from { transform: scale(.86); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .bs-bar span { animation-duration: 2.4s; }
  .bs-logo, .bs-logo::after { animation: none; }
}

/* ============ Purchases: the locked episode (feed) ============
   The lock card is a direct child of #feedOverlay, but NOT a `.feed-ui` element:
   a tap on the picture hides the playback chrome, and it must not hide the one
   thing that can unlock the episode. `rv-locked` on the frame reveals the blurred
   backdrop (the drama's own art) since the player is deliberately empty. */
#feedFrame.rv-locked #feedBg { opacity: 1; }
/* Nothing behind the lock card is playable, so the playback chrome goes with it:
   a play button or a seek bar over a locked episode would only lie. */
#feedFrame.rv-locked #feedBottom,
#feedFrame.rv-locked #feedSpinner,
#feedFrame.rv-locked #playPauseBtn { display: none !important; }
#lockCard {
  position: absolute; left: 0; right: 0; bottom: 0; top: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 26px 22px calc(30px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(6,6,12,.34) 0%, rgba(6,6,12,.72) 58%, rgba(6,6,12,.9) 100%);
  text-align: center;
}
#lockCard.hidden { display: none; }
.lock-ic {
  width: 66px; height: 66px; border-radius: 24px; display: grid; place-items: center;
  background: linear-gradient(150deg, rgba(124,92,255,.9), rgba(255,61,129,.85));
  box-shadow: 0 14px 40px rgba(124,92,255,.4), inset 0 1px 0 rgba(255,255,255,.35);
  color: #fff; margin-bottom: 4px;
}
.lock-ic svg { width: 32px; height: 32px; }
.lock-title { font-size: 20px; font-weight: 850; letter-spacing: -.3px; }
.lock-sub { font-size: 13px; color: #cbd5e1; line-height: 1.55; max-width: 320px; }
.lock-btns { display: flex; flex-direction: column; gap: 9px; width: min(340px, 88vw); margin-top: 8px; }
/* The buy button borrows the app's primary button (.gate-go); only the stack
   spacing above it is this card's. */
.lock-btns button { width: 100%; margin-top: 0; }
.lock-restore { margin-top: 2px; opacity: .82; }
/* ============ Purchases: the paywall sheet ============ */
.paywall-modal { max-height: min(86vh, 700px); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.pw-sub { font-size: 13px; color: var(--muted); line-height: 1.6; margin: -6px 0 4px; }
.pw-status {
  display: inline-flex; align-items: center; gap: 6px; margin: 8px 0 14px;
  padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 750;
  background: rgba(124,92,255,.16); border: 1px solid rgba(124,92,255,.42); color: #d9d3ff;
}
.pw-status.on { background: rgba(74,222,128,.14); border-color: rgba(74,222,128,.42); color: #b6f5cc; }
.pw-products { display: flex; flex-direction: column; gap: 10px; }
.pw-item {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px;
  padding: 13px 14px; border-radius: 16px;
  background: rgba(255,255,255,.05); border: 1px solid var(--line);
}
.pw-item.pw-best { border-color: rgba(255,61,129,.5); background: rgba(255,61,129,.09); }
.pw-item-t { font-size: 14px; font-weight: 800; }
.pw-item-s { font-size: 11.5px; color: var(--muted2); line-height: 1.5; margin-top: 3px; }
.pw-item-b {
  padding: 11px 15px; border-radius: 13px; white-space: nowrap;
  font-weight: 800; font-size: 13px; color: #fff; border: 0;
  background: var(--grad); box-shadow: 0 8px 22px rgba(124,92,255,.35);
}
.pw-item-b:disabled { opacity: .55; box-shadow: none; }
.pw-item-b.busy { opacity: .8; }
.pw-credit { margin-top: 12px; }
.pw-acts { margin-top: 14px; }
.pw-foot { margin-top: 12px; font-size: 11px; color: var(--muted2); line-height: 1.55; text-align: center; }
.pw-sandbox {
  margin-top: 10px; padding: 8px 12px; border-radius: 12px; font-size: 11.5px; font-weight: 700;
  background: rgba(250,204,21,.12); border: 1px solid rgba(250,204,21,.4); color: #fde68a; text-align: center;
}
/* ---- admin console: the purchase policy card + ledger ---- */
.admin-card-h2 { margin-top: 16px; }
.pay-skus { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 10px; }
.pay-sku-hdr, .pay-sku-row { display: grid; grid-template-columns: 1fr 84px 34px; gap: 8px; align-items: center; }
.pay-sku-hdr { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .7px; color: var(--muted2); }
.pay-sku-row input.sku-in { min-width: 0; }
.pay-sku-row input.sku-n { text-align: center; }
.pay-sku-row .pay-sku-x {
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(255,255,255,.06); color: #fca5a5; font-weight: 800; cursor: pointer;
}
.pay-ledger { margin-top: 12px; }
.pay-ledger table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.pay-ledger th, .pay-ledger td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.pay-ledger th { font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted2); }
.pay-ledger td.tok { font-family: ui-monospace, monospace; font-size: 10.5px; color: var(--muted); word-break: break-all; }
.pay-ledger .st0 { color: #fde68a; }
.pay-ledger .st1 { color: #86efac; }
.pay-ledger .st2 { color: #fca5a5; }
@media (max-width: 420px) {
  .pw-item { grid-template-columns: 1fr; }
  .pw-item-b { width: 100%; }
}

/* ============ Licence gate ============ */
.lic-gate { z-index: 135; }
.lic-dev {
  margin-top: 2px; padding: 9px 11px; border-radius: 13px;
  background: rgba(0,0,0,.34); border: 1px solid var(--line);
}
.lic-dev-lbl { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .9px; color: var(--muted2); margin-bottom: 5px; }
.lic-dev-row { display: flex; align-items: center; gap: 8px; }
.lic-dev-row code {
  flex: 1; min-width: 0; font-family: ui-monospace, "SFMono-Regular", monospace;
  font-size: 13px; letter-spacing: 1.5px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lic-dev-row .ghost-btn { flex-shrink: 0; }
.lic-acts { display: flex; flex-direction: column; gap: 7px; margin-top: 4px; }
.lic-acts .ghost-btn { width: 100%; }
.lic-ok {
  display: flex; align-items: center; gap: 9px; padding: 10px 12px; border-radius: 14px;
  background: rgba(46,230,168,.1); border: 1px solid rgba(46,230,168,.35);
  font-size: 13px; font-weight: 650; color: var(--good);
}
.lic-ok-ic {
  width: 20px; height: 20px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center;
  background: var(--good); color: #062015; font-size: 12px; font-weight: 900;
}
.lic-wait { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--muted2); }
.lic-wait .spinner { width: 15px; height: 15px; border-width: 2px; }
