/*!*********************************************************************************************************************************************************************************************************************************************************************!*\
  !*** css ../../node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[14].oneOf[10].use[2]!../../node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[14].oneOf[10].use[3]!./app/globals.css ***!
  \*********************************************************************************************************************************************************************************************************************************************************************/
* {
  box-sizing: border-box;
}

/* ---------- design tokens ---------- */

:root {
  /* surfaces */
  --bg: #0b0e14;
  --bg-soft: #0f1219;
  --surface: #141824;
  --surface-2: #1a1f2d;
  --elevated: #222839;
  --hover: rgba(255, 255, 255, 0.06);

  /* borders */
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);

  /* text */
  --text: #e9ecf2;
  --text-muted: #97a0b3;
  --text-faint: #6b7385;

  /* accents — warm amber-gold primary, cool blue secondary */
  --accent: #f0a43c;
  --accent-hover: #f7b45a;
  --accent-contrast: #1a1206;
  --accent-2: #5b9dff;
  --accent-2-soft: rgba(91, 157, 255, 0.14);

  /* status */
  --success: #4ade80;
  --warning: #f5c04a;
  --error: #f87171;
  --error-soft: rgba(248, 113, 113, 0.14);

  /* radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;

  /* shadows */
  --shadow-1: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-2: 0 8px 28px rgba(0, 0, 0, 0.5);
  --shadow-3: 0 18px 56px rgba(0, 0, 0, 0.6);

  /* motion */
  --dur-fast: 0.15s;
  --dur: 0.25s;

  /* layout */
  --topnav-h: 60px;
  --sidebar-w: 248px;
  --sidebar-w-collapsed: 66px;
  --content-max: 1600px;

  /* safe-area insets (notch/gesture zones — 0 where unsupported) */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);

  /* fluid responsive tokens — scale with the viewport inside bounds so
     layouts adapt continuously instead of snapping at breakpoints */
  --page-x: clamp(16px, 3vw, 72px);
  --page-y: clamp(20px, 4vh, 48px);
  --card-poster-w: clamp(112px, 32vw, 190px);
  --card-landscape-w: clamp(200px, 38vw, 340px);
  --card-gap: clamp(10px, 1.1vw, 20px);
  --row-gap: clamp(18px, 3vh, 32px);
  --hero-h: clamp(240px, 44vh, 520px);
  --fs-display: clamp(28px, 4.5vw, 64px);

  /* type scale */
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;
  --fs-2xl: 26px;
  --fs-3xl: 36px;
}

/* ---------- scrollbars — slim, dark, unobtrusive ---------- */
/* Thin translucent thumbs over transparent tracks; they brighten only
   while being dragged/hovered so shelves and panels stay clean. */
:root {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border: 2px solid transparent;
  border-radius: 8px;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.32);
  background-clip: padding-box;
}
::-webkit-scrollbar-corner { background: transparent; }

/* Shelf strips: slimmer thumb, hidden until the strip is hovered —
   remote/TV surfaces keep scrollbars fully hidden below. */
.row-scroll {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}
.row-scroll::-webkit-scrollbar { height: 8px; }
.row-scroll::-webkit-scrollbar-thumb { background: transparent; }
.row-scroll:hover {
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}
.row-scroll:hover::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  background-clip: padding-box;
}

/* Content-density variants (localStorage katandika.density → data-density).
   Only card sizing and gaps shift — type stays readable. */
:root[data-density="compact"] {
  --card-poster-w: clamp(96px, 26vw, 140px);
  --card-landscape-w: clamp(168px, 30vw, 260px);
  --card-gap: clamp(8px, 0.9vw, 14px);
}
:root[data-density="large"] {
  --card-poster-w: clamp(140px, 38vw, 250px);
  --card-landscape-w: clamp(260px, 46vw, 420px);
  --card-gap: clamp(14px, 1.4vw, 28px);
}

/* Landscape phones / short viewports: shrink the hero so the first row
   still peeks above the fold. */
@media (orientation: landscape) and (max-height: 560px) {
  :root { --hero-h: clamp(160px, 62vh, 320px); }
}

/* ---------- interface-mode tokens ---------- */
/* data-ui-mode is set by lib/interface/mode-provider. Shared tokens the
   mode-aware surfaces consume — components should reference these rather
   than hard-coded px so each device class can retune once here. */
:root {
  /* focus */
  --focus-ring: var(--accent);
  --focus-ring-w: 2px;
  --focus-glow: transparent;
  --focus-scale: 1.03;
  /* input affordances */
  --touch-target: 40px;
  --dialog-w: min(560px, 92vw);
  /* OSD / player chrome */
  --osd-px: 14px;
  --osd-py: 10px;
}
:root[data-ui-mode="mobile-touch"],
:root[data-ui-mode="tablet-touch"] {
  --touch-target: 48px;
}
:root[data-ui-mode="tv-remote"] {
  /* Remote viewing distance: wider margins, larger focus treatment, and
     no reliance on hover. Sizes stay bounded — 4K doesn't double px. */
  --page-x: clamp(40px, 4.5vw, 96px);
  --focus-ring-w: 3px;
  --focus-glow: color-mix(in srgb, var(--accent) 40%, transparent);
  --focus-scale: 1.06;
  --touch-target: 56px;
  --osd-px: 4rem;
  --osd-py: 2.5rem;
  /* Cards and type scale up for 10-foot readability. */
  --card-poster-w: clamp(150px, 11vw, 230px);
  --card-landscape-w: clamp(260px, 18vw, 400px);
  --row-gap: clamp(28px, 4.5vh, 56px);
  --hero-h: clamp(300px, 52vh, 620px);
}
/* Visible focus under remote/keyboard operation — pointer-only surfaces
   keep their existing hover styles. */
:root[data-ui-mode="tv-remote"] :focus-visible {
  outline: var(--focus-ring-w) solid var(--focus-ring);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px var(--focus-glow);
}
/* Pointer-only affordances don't apply when the remote is driving. */
:root[data-ui-mode="tv-remote"] .search-box kbd { display: none; }
:root[data-ui-mode="tv-remote"] .row h2 { font-size: var(--fs-2xl); }
:root[data-ui-mode="tv-remote"] .chip {
  font-size: var(--fs-md);
  padding: 8px 20px;
}
/* 4K TVs: modest root-type bump (rem scales layout proportionally),
   not a naive 2x of every element. */
@media (min-width: 2560px) {
  :root[data-ui-mode="tv-remote"] { font-size: 22px; }
}

html {
  /* iOS inflates body text in landscape when it thinks the layout is
     desktop-scale; we handle responsiveness ourselves. */
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  /* No gray flash on tap. */
  -webkit-tap-highlight-color: transparent;
}

/* Touch devices: drop the 300ms double-tap-zoom delay everywhere and keep
   iOS from zooming the page on field focus (it zooms under 16px). */
@media (pointer: coarse) {
  a,
  button,
  label,
  select,
  summary,
  .chip,
  .title-card,
  .ep-thumb-link,
  .tv-ep {
    touch-action: manipulation;
  }
  input,
  select,
  textarea {
    font-size: 16px;
  }
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--page-y) var(--page-x);
}

.card {
  background: #181b24;
  border: 1px solid #2a2f3d;
  border-radius: 8px;
  padding: 20px 24px;
  margin-top: 24px;
}

/* Ambient library wallpaper: rotating catalog backdrops behind every
   surface. Fixed + negative z-index keeps it above the body background
   but below all content; the shade gradient keeps text readable. */
.app-wallpaper {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.wp-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  animation: wp-fade 1.1s ease-out forwards;
}
.wp-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(9, 12, 18, 0.62),
    rgba(9, 12, 18, 0.88) 45%,
    rgba(9, 12, 18, 0.96)
  );
}
@keyframes wp-fade {
  to { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .wp-img { animation: none; opacity: 1; }
}

.status-ok {
  color: #4ade80;
}

.status-error {
  color: #f87171;
}

.muted {
  color: #9aa1b2;
  font-size: 14px;
}

code {
  background: #232836;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

a {
  color: #7cb3ff;
}

label {
  display: block;
  margin: 12px 0 4px;
  font-size: 14px;
}

input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #2a2f3d;
  background: #0f1117;
  color: #e6e8ee;
  font-size: 14px;
}

button {
  margin-top: 16px;
  padding: 8px 18px;
  border-radius: 6px;
  border: 1px solid #3a4152;
  background: #232836;
  color: #e6e8ee;
  font-size: 14px;
  cursor: pointer;
}

button:disabled {
  opacity: 0.6;
  cursor: default;
}

select,
textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #2a2f3d;
  background: #0f1117;
  color: #e6e8ee;
  font-size: 14px;
  font-family: inherit;
}

fieldset {
  border: 1px solid #2a2f3d;
  border-radius: 6px;
  margin-top: 12px;
}

label.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 16px;
}

label.checkbox input {
  display: inline;
  width: auto;
  margin: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #2a2f3d;
}

.badge-ok,
.badge-draft {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
}

.badge-ok {
  background: #14532d;
  color: #4ade80;
}

.badge-draft {
  background: #3b3f4d;
  color: #c3c8d4;
}

.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

.inline-form input {
  width: auto;
  margin-top: 0;
  flex: 1 1 140px;
}

.inline-form button {
  margin-top: 0;
}

.season-block {
  border-top: 1px solid #2a2f3d;
  padding-top: 8px;
  margin-top: 8px;
}

/* ---------- streaming UI ---------- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid #232836;
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  background: rgba(15, 17, 23, 0.92);
  -webkit-backdrop-filter: blur(6px);
          backdrop-filter: blur(6px);
  z-index: 10;
  flex-wrap: wrap;
}

.site-nav nav {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.site-nav a {
  color: #c3c8d4;
  text-decoration: none;
}

.site-nav a:hover {
  color: #fff;
}

.brand {
  font-weight: 700;
  font-size: 20px;
  color: #fff !important;
  letter-spacing: 0.5px;
}

.nav-user {
  font-size: 13px;
}

.nav-cta,
.btn-secondary {
  display: inline-block;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 14px;
  text-decoration: none;
}

.nav-cta {
  background: #e50914;
  color: #fff !important;
}

.btn-secondary {
  border: 1px solid #3a4152;
  color: #e6e8ee !important;
}

.site-nav button {
  margin-top: 0;
  padding: 6px 12px;
  font-size: 13px;
}

/* Landing */

.landing {
  text-align: center;
  padding-top: 15vh;
}

.landing h1 {
  font-size: clamp(36px, 8vw, 72px);
  margin-bottom: 8px;
}

.landing-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 24px;
}

/* Hero */

.hero {
  position: relative;
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: var(--row-gap);
  min-height: var(--hero-h);
  display: flex;
  align-items: flex-end;
  box-shadow: var(--shadow-2);
}

.hero .art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Layered cinematic scrim: a left-to-right veil behind the metadata plus a
   bottom fade that dissolves the artwork into the page background, so the
   hero reads as part of the page rather than a framed rectangle. */
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      to right,
      rgba(11, 14, 20, 0.78) 0%,
      rgba(11, 14, 20, 0.3) 45%,
      transparent 72%
    ),
    linear-gradient(
      to top,
      var(--bg) 0%,
      rgba(15, 17, 23, 0.5) 30%,
      transparent 62%
    );
  pointer-events: none;
}

.hero-copy {
  position: relative;
  z-index: 1;
  padding: clamp(20px, 3.5vw, 44px);
  padding-top: 110px;
  max-width: 640px;
  width: 100%;
}

/* Rotating hero: slides stack absolutely inside .hero and crossfade.
   Inactive slides are visibility:hidden — out of the tab order and AT —
   with a delayed visibility swap so the fade completes first. */
.hero-rotator { display: block; }
.hero-slide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.9s ease,
    visibility 0s linear 0.9s;
}
.hero-slide-on {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.9s ease;
  /* No z-index here — staying in the .hero stacking context keeps the
     layered ::after scrim over the artwork (z-index:1 on .hero-copy
     still lifts the text above it). */
}
.hero-slide .hero-copy { padding-top: 110px; }
@media (prefers-reduced-motion: reduce) {
  .hero-slide,
  .hero-slide-on { transition: none; }
}

.hero-copy h1 {
  margin: 0 0 8px;
  font-size: var(--fs-display);
  line-height: 1.04;
  letter-spacing: -0.015em;
}

.hero-copy .muted {
  font-size: var(--fs-lg);
  color: rgba(233, 236, 242, 0.85);
}

/* Meta pill for content rating inside the hero. */
.hero-rating {
  display: inline-block;
  padding: 1px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

/* Primary/secondary hero actions — sit on top of artwork, so they carry
   their own surfaces instead of relying on page chrome. */
.hero-play {
  display: inline-block;
  padding: 12px 26px;
  border-radius: var(--r-md);
  background: var(--accent);
  color: var(--accent-contrast) !important;
  font-weight: 700;
  font-size: var(--fs-lg);
  text-decoration: none;
}
.hero-play:hover { background: var(--accent-hover); }
.hero-more {
  display: inline-block;
  padding: 12px 22px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  background: rgba(15, 18, 25, 0.5);
  -webkit-backdrop-filter: blur(8px);
          backdrop-filter: blur(8px);
  color: var(--text) !important;
  font: inherit;
  font-weight: 600;
  font-size: var(--fs-lg);
  text-decoration: none;
  cursor: pointer;
}
.hero-more:hover { background: rgba(30, 36, 50, 0.7); }

/* Title-detail hero runs taller so the backdrop has room to breathe. */
.hero-detail {
  min-height: clamp(320px, 52vh, 640px);
}

/* Plex-inspired movie detail: dimmed backdrop behind a poster-left /
   info-right head, then a compact Media info card. */
.movie-hero {
  position: relative;
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: var(--row-gap);
  background: var(--surface);
}
.movie-hero-bg {
  position: absolute;
  inset: 0;
}
.movie-hero-bg .art-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
}
.movie-hero-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      180deg,
      rgba(11, 14, 20, 0.35) 0%,
      rgba(11, 14, 20, 0.82) 58%,
      var(--bg) 100%
    ),
    linear-gradient(
      90deg,
      rgba(11, 14, 20, 0.55) 0%,
      transparent 60%
    );
}
.movie-head {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: clamp(18px, 2.6vw, 34px);
  padding: clamp(20px, 4vw, 48px);
  min-height: clamp(340px, 48vh, 560px);
}
.movie-poster {
  width: clamp(140px, 15vw, 220px);
  flex-shrink: 0;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-3);
}
.movie-poster .art-poster {
  border-radius: 0;
}
.movie-info {
  min-width: 0;
  padding-bottom: 4px;
}
.movie-info h1 {
  font-size: clamp(26px, 3.4vw, 46px);
  letter-spacing: -0.02em;
  margin: 0 0 6px;
  text-wrap: balance;
}
.movie-meta {
  font-size: var(--fs-lg);
  color: var(--text-muted);
  margin: 0 0 10px;
}
.mi-res {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: var(--r-sm);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent);
  vertical-align: 2px;
}
.movie-desc {
  max-width: 62ch;
  color: var(--text-muted);
}
@media (max-width: 640px) {
  .movie-head {
    align-items: flex-start;
    flex-direction: column;
    min-height: 0;
    padding-top: 60px;
  }
  .movie-poster {
    width: 132px;
  }
}

.media-info ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-gap: 10px;
  gap: 10px;
}
.mi-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.mi-ver {
  font-size: var(--fs-sm);
  min-width: 68px;
}
.mi-chip {
  background: var(--elevated);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.mi-chip-res {
  color: var(--accent);
  font-weight: 700;
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}

/* Poster/backdrop placeholders */

.art {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #232836;
  color: rgba(255, 255, 255, 0.75);
  object-fit: cover;
}

.art-poster {
  aspect-ratio: 2 / 3;
  width: 100%;
  border-radius: 8px;
}

.art-backdrop {
  aspect-ratio: 16 / 7;
  width: 100%;
}

.art-letter {
  font-size: clamp(40px, 8vw, 96px);
  font-weight: 700;
  opacity: 0.5;
}

/* Rows & cards */

.catalog {
  max-width: var(--content-max);
}

.row {
  margin-bottom: var(--row-gap);
}

.row h2 {
  font-size: var(--fs-xl);
  letter-spacing: -0.01em;
  margin: 0 0 10px;
}

.row-shell {
  position: relative;
}

/* Translucent edge buttons — revealed while the row is hovered or a
   card inside has focus; hidden entirely when there's nothing to
   scroll to in that direction. */
.row-nav {
  position: absolute;
  /* Span the card strip exactly: the scroller's negative margins pull
     its box 10px above the shell top and 6px past its bottom, so the
     card area inside runs 0 → shell-bottom−8px. */
  top: 0;
  bottom: 8px;
  width: 56px;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--r-md);
  /* Arrow only — no pill. A soft edge scrim keeps the chevron readable
     over bright artwork without boxing it in. */
  background: linear-gradient(
    to var(--nav-fade-dir, left),
    transparent,
    rgba(12, 15, 22, 0.4)
  );
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transition:
    opacity var(--dur-fast),
    transform var(--dur-fast);
}
.row-nav:hover {
  transform: scale(1.12);
}
.row-nav svg {
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.8));
}
.row-nav-l {
  left: 0;
  --nav-fade-dir: left;
}
.row-nav-r {
  right: 0;
  --nav-fade-dir: right;
}
.row-shell:hover .row-nav,
.row-shell:focus-within .row-nav {
  opacity: 1;
}
/* Touch surfaces scroll by swiping — the buttons would just overlay art. */
@media (hover: none) {
  .row-nav {
    display: none;
  }
}

.row-scroll {
  display: flex;
  gap: var(--card-gap);
  overflow-x: auto;
  /* Vertical headroom so a focused/hovered card's lift + shadow never
     clips against the scroll container's edges. */
  padding: 10px 4px 14px;
  margin: -10px -4px -6px;
  scroll-snap-type: x proximity;
  /* Sideways shelf swipes shouldn't bubble into browser back/forward —
     x-axis only: vertical wheel/touch must chain to the page scroll. */
  overscroll-behavior-x: contain;
  /* Soft edge fade hints more content without a scrollbar. */
  mask-image: linear-gradient(to right, transparent, #000 2%, #000 97%, transparent);
  -webkit-mask-image: linear-gradient(to right, transparent, #000 2%, #000 97%, transparent);
}

/* Deferred row skeleton — same footprint as a real poster strip so cards
   mounting don't shift the page. */
.deferred-skel {
  display: flex;
  gap: var(--card-gap);
  overflow: hidden;
  padding: 10px 4px 14px;
}
.deferred-skel-card {
  flex: 0 0 var(--card-poster-w);
  aspect-ratio: 2 / 3;
}

/* Bottom sentinel for progressively rendered poster grids/lists. */
.grid-sentinel {
  padding: 24px;
  text-align: center;
}

/* Tail sentinel for progressive shelf mounting — reserves a card slot so
   the strip hints at more content before the next batch renders. */
.row-sentinel {
  flex: 0 0 var(--card-poster-w);
  aspect-ratio: 2 / 3;
  border-radius: var(--r-md);
}

/* Trailing "See all" tile on capped shelves — same footprint as a card. */
.see-all-card {
  flex: 0 0 var(--card-poster-w);
  aspect-ratio: 2 / 3;
  scroll-snap-align: start;
  border-radius: var(--r-md);
  border: 1px dashed color-mix(in srgb, var(--surface-2) 55%, #fff0);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  color: inherit;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition:
    border-color var(--dur-fast) ease,
    background var(--dur-fast) ease;
}
.see-all-label {
  font-weight: 600;
  font-size: 0.95em;
}
.see-all-count {
  font-size: 0.8em;
}
@media (hover: hover) {
  .see-all-card:hover {
    border-color: var(--accent, #4a9eff);
    background: var(--surface-2);
  }
}
.see-all-card:focus-visible {
  outline: var(--focus-ring-w) solid var(--focus-ring);
  outline-offset: 3px;
}

.title-card {
  flex: 0 0 var(--card-poster-w);
  scroll-snap-align: start;
  text-decoration: none;
  color: inherit;
  border-radius: var(--r-md);
}

.title-card .art {
  box-shadow: var(--shadow-1);
  transition:
    transform var(--dur-fast) ease,
    box-shadow var(--dur-fast) ease;
}

/* Controlled lift — scale is a token so tv-remote focuses grow slightly
   more than pointer hovers. Hover-gated: on touch a tap would leave the
   "hovered" state stuck on the card. */
@media (hover: hover) {
  .title-card:hover .art {
    transform: scale(1.04);
    box-shadow: var(--shadow-2);
  }
}
.title-card:focus-visible {
  outline: var(--focus-ring-w) solid var(--focus-ring);
  outline-offset: 3px;
}
.title-card:focus-visible .art {
  transform: scale(var(--focus-scale));
  box-shadow: var(--shadow-3);
}

.title-card-name {
  display: block;
  margin-top: 8px;
  font-size: 14px;
}

.title-card-meta {
  font-size: 12px;
}

/* Watched marker — a small green dot overlaid on the artwork's corner. */
.title-card-art {
  position: relative;
  display: block;
}

.watched-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #34c759;
  box-shadow: 0 0 0 2px rgb(0 0 0 / 55%);
}

.watched-dot-inline {
  position: static;
  display: inline-block;
  margin-left: 10px;
  vertical-align: middle;
}

/* Partial-watch pie — background is an inline conic-gradient set to the
   percentage; the base circle keeps it readable over any artwork. */
.watch-pie {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow:
    0 0 0 2px rgb(0 0 0 / 55%),
    inset 0 0 0 1.5px rgb(255 255 255 / 35%);
}

/* Chips */

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.chip {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  -webkit-backdrop-filter: blur(6px);
          backdrop-filter: blur(6px);
  color: #c3c8d4;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  transition: border-color var(--dur-fast) ease, color var(--dur-fast) ease;
}

.chip:hover {
  border-color: var(--accent-2);
  color: var(--text);
}

.chip-active {
  background: #e6e8ee;
  color: #0f1117;
  border-color: #e6e8ee;
}

.genre-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Search */

.search-input {
  font-size: 16px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-poster-w), 1fr));
  grid-gap: var(--card-gap);
  gap: var(--card-gap);
}

/* Episodes — Apple TV-inspired landscape rows: a 16:9 art tile with
   the episode number, play overlay and progress bar beside title,
   duration and a clamped synopsis. */

.ep-list {
  display: grid;
  grid-gap: 14px;
  gap: 14px;
  margin-top: 6px;
}

.ep-row {
  position: relative;
  display: flex;
  gap: 18px;
  align-items: flex-start;
  padding: 10px;
  margin: -10px;
  /* Skip rendering off-screen rows in long episode lists (mobile). */
  content-visibility: auto;
  contain-intrinsic-size: auto 160px;
  border-radius: var(--r-lg);
  transition: background var(--dur-fast);
}

.ep-row:hover,
.ep-row:focus-within {
  background: var(--surface);
}

.ep-thumb-link {
  flex-shrink: 0;
  border-radius: var(--r-md);
}

/* Stretched link — taps anywhere on the row (title, meta, description)
   trigger the episode link, not just the thumbnail. */
.ep-thumb-link::after {
  content: "";
  position: absolute;
  inset: 0;
}

.ep-thumb-link:focus-visible {
  outline: var(--focus-ring-w) solid var(--focus-ring);
  outline-offset: 3px;
  box-shadow: 0 0 0 4px var(--focus-glow);
}

.ep-thumb {
  position: relative;
  width: clamp(200px, 22vw, 300px);
  aspect-ratio: 16 / 9;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
  transition:
    transform var(--dur),
    box-shadow var(--dur);
}

@media (hover: hover) {
  .ep-thumb-link:hover .ep-thumb {
    transform: scale(1.03);
    box-shadow: var(--shadow-2);
  }
}
.ep-thumb-link:focus-visible .ep-thumb {
  transform: scale(1.03);
  box-shadow: var(--shadow-2);
}

/* Poster renders .art-backdrop — stretch it to fill the 16:9 tile. */
.ep-thumb .art-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
}

.ep-num {
  position: absolute;
  left: 8px;
  top: 8px;
  min-width: 24px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--r-sm);
  background: rgba(0, 0, 0, 0.72);
  color: var(--text);
}

.ep-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  color: #fff;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity var(--dur-fast);
}

@media (hover: hover) {
  .ep-thumb-link:hover .ep-play {
    opacity: 1;
  }
}
.ep-thumb-link:focus-visible .ep-play {
  opacity: 1;
}

.ep-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.22);
}

.ep-progress span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.ep-info {
  min-width: 0;
  padding-top: 2px;
}

.ep-info h3 {
  margin: 0 0 4px;
  font-size: var(--fs-lg);
}

.ep-idx {
  font-weight: 600;
}

.ep-desc {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  margin: 8px 0 0;
}

@media (max-width: 560px) {
  .ep-row {
    flex-direction: column;
    gap: 10px;
  }

  .ep-thumb {
    width: 100%;
  }
}

/* States */

.empty-state {
  text-align: center;
  padding: 48px 24px;
}

.skeleton {
  background: linear-gradient(90deg, #181b24 25%, #232836 50%, #181b24 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 8px;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

.hero-skeleton {
  height: 320px;
  margin-bottom: 28px;
}

.skeleton-line {
  height: 20px;
  width: 200px;
  margin-bottom: 14px;
}

.row-skeleton {
  display: flex;
  gap: 14px;
  overflow: hidden;
}

.skeleton-card {
  flex: 0 0 160px;
  aspect-ratio: 2 / 3;
}

/* Focus & responsiveness */

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid #7cb3ff;
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .site-nav {
    padding: 12px 16px;
  }

  .site-nav nav {
    gap: 12px;
    font-size: 14px;
  }

  .hero-copy {
    padding: 20px;
  }
}

/* ---------- video ingestion & playback ---------- */

/* Immersive playback page: full content width, tight top — the player
   carries all context (back button + title scrim), no breadcrumb above. */
.watch-page {
  max-width: var(--content-max);
  padding-top: clamp(10px, 2vh, 24px);
}
.watch-page h1 { margin-bottom: 12px; }

/* "Now playing" context strip under the player. */
.watch-now {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  margin-top: 18px;
}
.watch-now-art {
  width: clamp(90px, 10vw, 140px); /* 50% of the original strip */
  flex-shrink: 0;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
}
.watch-now-art .art-backdrop {
  aspect-ratio: 16 / 9;
}
.watch-now-info {
  min-width: 0;
}
.watch-now-eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}
.watch-now-info h1 {
  font-size: var(--fs-2xl);
  margin: 4px 0 6px;
  letter-spacing: -0.01em;
}
.watch-now-desc {
  max-width: 70ch;
  color: var(--text-muted);
  margin: 10px 0 0;
}
@media (max-width: 560px) {
  .watch-now {
    flex-direction: column;
  }
  .watch-now-art {
    width: 50%; /* half the row — a fractional width so it can't stay full */
  }
}

.player-wrap {
  background: #000;
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-2);
}
/* Mobile: pin the player under the topnav so it stays visible while
   scrolling the episode list — Netflix/YouTube-style. */
@media (max-width: 720px) {
  .watch-page .player-wrap {
    position: -webkit-sticky;
    position: sticky;
    top: calc(var(--topnav-h) + var(--safe-t));
    z-index: 40;
  }
}
/* Phone landscape (Android): the player owns the whole viewport height —
   rotating the phone is the fullscreen gesture. Episode list scrolls
   below it; sticky pin is overridden since it would cover everything. */
@media (orientation: landscape) and (max-height: 540px) and (pointer: coarse) {
  .watch-page { padding-top: 0; }
  .watch-page .player-wrap {
    position: relative;
    top: auto;
    height: calc(100vh - var(--topnav-h) - var(--safe-t));
    height: calc(100dvh - var(--topnav-h) - var(--safe-t));
    border-radius: 0;
  }
  .watch-page .player {
    height: 100%;
    aspect-ratio: auto;
  }
}
.player {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}
.player-unavailable {
  padding: 48px 24px;
  text-align: center;
}

.episode-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.episode-list li {
  padding: 8px 10px;
  border-radius: 6px;
}
.episode-list li.episode-current {
  background: rgba(124, 179, 255, 0.12);
}
.episode-list a { color: #7cb3ff; }

.asset-target {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 14px 0;
}
.asset-target h3 { margin: 0 0 8px; font-size: 15px; }
.asset-list {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  font-size: 14px;
}
.asset-list li { padding: 4px 0; }
.upload-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.upload-row input[type="file"] { font-size: 13px; }
.link-button {
  background: none;
  border: none;
  color: #7cb3ff;
  cursor: pointer;
  font-size: 13px;
  padding: 0 4px;
  text-decoration: underline;
}
.status-error-text { color: #ff8a8a; }

/* ---------- viewing progress ---------- */

.progress-track {
  display: block;
  height: 4px;
  margin-top: 6px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
}
.progress-fill {
  display: block;
  height: 100%;
  background: var(--accent);
}

/* ---------- admin: libraries, scans, review, categories ---------- */

.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 20px;
  font-size: 14px;
}
.admin-table th,
.admin-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  vertical-align: top;
}
.admin-table th {
  color: #9aa4b2;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.admin-table code {
  font-size: 12px;
  word-break: break-all;
}
.catalog-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 8px;
}
.catalog-tab {
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 12px;
  color: #c6cdd8;
  font-size: 13px;
  cursor: pointer;
}
.catalog-tab:hover {
  background: rgba(255, 255, 255, 0.06);
}
.catalog-tab.active {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  font-weight: 600;
}
.bulk-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 10px;
  margin: 8px 0 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  background: var(--bg, #10141c);
  z-index: 5;
}
.bulk-bar input[type="checkbox"] {
  margin: 0;
}
.admin-table th input[type="checkbox"],
.admin-table td input[type="checkbox"] {
  margin: 0;
}
.sort-head {
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
}
.sort-head:hover { color: #e2e8f0; }
.sort-idle { opacity: 0.35; }
.sort-head:hover .sort-idle { opacity: 0.8; }
.actions-cell { white-space: nowrap; }
.actions-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin: 10px 0;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
  font-size: 13px;
  color: #9aa4b2;
}
.field input,
.field select,
.field textarea,
.actions-row input,
.actions-row select {
  background: #14181f;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  color: #e8ecf1;
  padding: 8px 10px;
  font-size: 14px;
}
.field textarea { min-height: 90px; resize: vertical; }
.field-check {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 14px;
  margin-bottom: 8px;
}

.scan-progress {
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
  margin: 12px 0;
}
.scan-progress-fill {
  height: 100%;
  background: #4da3ff;
  transition: width 0.4s ease;
}
.scan-counts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  grid-gap: 8px;
  gap: 8px;
  margin: 12px 0;
}
.scan-counts dt {
  font-size: 11px;
  color: #9aa4b2;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.scan-counts dd {
  margin: 2px 0 0;
  font-size: 20px;
  font-weight: 600;
}
.scan-events {
  list-style: none;
  padding: 0;
  margin: 8px 0;
  font-size: 13px;
  max-height: 320px;
  overflow-y: auto;
}
.scan-events li { padding: 3px 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
.scan-event-warn { color: #ffcf7a; }
.scan-event-error { color: #ff8a8a; }
.rule-json { font-size: 12px; word-break: break-all; }
.meta-edit { margin: 10px 0; }

/* ---------- application shell ---------- */

.shell {
  min-height: 100vh;
}

.topnav {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 50;
  height: calc(var(--topnav-h) + var(--safe-t));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: var(--safe-t) calc(16px + var(--safe-r)) 0 calc(16px + var(--safe-l));
  background: rgba(11, 14, 20, 0.88);
  -webkit-backdrop-filter: blur(10px);
          backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topnav .brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.brand-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #d9822b);
  color: var(--accent-contrast);
}

.topnav-spacer { flex: 1 1; }

@media (min-width: 901px) {
  .drawer-btn { display: none; }
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }

.icon-btn .badge-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* topnav search */
.search-box {
  position: relative;
  flex: 0 1 420px;
  min-width: 120px;
}
.search-box input {
  width: 100%;
  margin: 0;
  padding: 8px 12px 8px 36px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-md);
}
.search-box input::placeholder { color: var(--text-faint); }
.search-box .search-glyph {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
  display: inline-flex;
}
.search-box kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--text-faint);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 1px 5px;
  background: var(--bg-soft);
}

/* user menu */
.user-menu { position: relative; }
.avatar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--accent-2-soft);
  color: var(--accent-2);
  font-weight: 700;
  font-size: var(--fs-md);
  cursor: pointer;
}
.avatar-mono {
  flex-direction: column;
  gap: 1px;
  line-height: 1;
}
.avatar-initials {
  font-size: 13px;
  letter-spacing: 0.02em;
}
.avatar-sign {
  font-size: 3.3px;
  font-weight: 600;
  letter-spacing: 0.06em;
  max-width: 26px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.8;
}
.menu-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 210px;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
  padding: 6px;
  z-index: 60;
}
.menu-pop a,
.menu-pop button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 9px 10px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text);
  font-size: var(--fs-md);
  text-decoration: none;
  cursor: pointer;
  text-align: left;
}
.menu-pop a:hover,
.menu-pop button:hover { background: var(--hover); }
.menu-pop .menu-head {
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.menu-pop .menu-head strong { display: block; font-size: var(--fs-md); }
.menu-pop .menu-head span { font-size: var(--fs-xs); color: var(--text-muted); }

/* profile gate */
.profile-gate {
  max-width: 720px;
  margin: 8vh auto 0;
  padding: 0 20px;
  text-align: center;
}
.profile-gate h1 { font-size: 28px; font-weight: 600; margin-bottom: 32px; }
.profile-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 24px;
}
.profile-card-wrap { position: relative; }
.profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 132px;
  padding: 8px;
  border: 2px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.profile-card:hover .profile-avatar { outline: 3px solid var(--text); }
.profile-card:disabled { opacity: 0.5; cursor: wait; }
.profile-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 108px;
  height: 108px;
  border-radius: var(--r-md);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.profile-avatar-add {
  background: var(--hover);
  color: var(--text-muted);
}
.profile-name {
  font-size: var(--fs-md);
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}
.profile-card:hover .profile-name { color: var(--text); }
.kids-badge,
.active-badge {
  font-style: normal;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--text-muted);
}
.active-badge { color: var(--accent-2); border-color: var(--accent-2); }
.lock-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-muted);
}
.pin-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
}
.pin-dialog { margin: 0; }
.pin-dialog h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pin-dialog input[type="password"] {
  width: 100%;
  margin-bottom: 12px;
}
.profile-form input[type="password"] {
  width: 100%;
  margin-top: 4px;
}
.profile-delete {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: var(--elevated);
  color: var(--text-muted);
  cursor: pointer;
}
.profile-delete:hover { color: #f87171; }
/* Interests badge — sparkle on the card's top-left; an accent dot marks
   profiles that haven't picked genres yet (the "notification"). */
.interests-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  opacity: 1;
  transition: transform 0.15s ease;
}
.interests-wand-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.55));
}
.interests-badge:hover,
.interests-badge:focus-visible {
  transform: scale(1.15);
}
.interests-badge-new { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.interests-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--error);
  box-shadow: 0 0 0 2px var(--bg);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.35); }
}
/* Same cue on the header avatar — dot on the button, item in the menu. */
.avatar-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--bg);
  animation: pulse 2s ease-in-out infinite;
}
.avatar-btn { position: relative; }
/* Uploaded profile pictures */
.profile-avatar-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--r-md);
}
.avatar-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.avatar-btn { overflow: hidden; }
.avatar-edit {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 14px;
}
.avatar-preview {
  width: 64px;
  height: 64px;
  font-size: 20px;
  flex-shrink: 0;
}
.avatar-preview .profile-avatar-img { border-radius: var(--r-md); }
.avatar-edit-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.avatar-file { cursor: pointer; }

/* Audience demand board (/admin/audience) */
.demand-board { margin: 16px 0 24px; }
.demand-board h2 { font-size: var(--fs-lg); margin: 0 0 14px; }
.demand-row {
  display: grid;
  grid-template-columns: 150px 1fr 100px 110px auto;
  align-items: center;
  grid-gap: 12px;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.demand-row:last-of-type { border-bottom: none; }
.demand-name {
  font-weight: 600;
  font-size: var(--fs-md);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.demand-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--hover);
  overflow: hidden;
}
.demand-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}
.demand-count { font-size: var(--fs-sm); white-space: nowrap; }
.demand-have { font-size: var(--fs-sm); white-space: nowrap; }
.demand-gap {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--warning);
  border: 1px solid var(--warning);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}
.demand-none {
  margin: 14px 0 0;
  font-size: var(--fs-sm);
  border-top: 1px dashed var(--border);
  padding-top: 12px;
}
@media (max-width: 760px) {
  .demand-row { grid-template-columns: 110px 1fr auto; }
  .demand-bar { grid-column: 1 / -1; order: 2; }
  .demand-have { display: none; }
}
.aud-account { vertical-align: top; }
.aud-role { text-transform: capitalize; }
.aud-prof {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.aud-prof i {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  flex-shrink: 0;
}
.aud-chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}
.aud-chip {
  font-size: var(--fs-sm);
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--hover);
  color: var(--text);
  border: 1px solid var(--border);
  white-space: nowrap;
}

/* Analytics — Emby-dashboard / Apple-inspired layout */
.ana-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.ana-head h1 { display: flex; align-items: center; gap: 8px; margin: 0; }
.ana-head p { margin: 4px 0 0; }
.ana-range {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
}
.ana-range-item {
  padding: 5px 14px;
  border-radius: 7px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-muted);
}
.ana-range-item:hover { color: var(--text); }
.ana-range-item.on {
  background: var(--accent);
  color: #101318;
}
.ana-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  grid-gap: 12px;
  gap: 12px;
  margin: 20px 0;
}
.ana-stat {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}
.ana-stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  flex-shrink: 0;
}
.ana-stat-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ana-stat .stat-value { font-size: var(--fs-xl); }
.ana-stat .stat-label { font-size: 11px; }
.ana-card { margin-bottom: 18px; }
.ana-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.ana-card-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-lg);
  margin: 0;
}
.ana-legend { display: flex; gap: 14px; }
.ana-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}
.ana-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}
.ana-dot-plays { background: var(--accent); }
.ana-dot-viewers { background: var(--accent-2); }
.ana-chart { width: 100%; height: 220px; display: block; }
.ana-grid { stroke: var(--border); stroke-width: 1; opacity: 0.5; }
.ana-grid-base { opacity: 1; }
.ana-line { fill: none; stroke-width: 2.5; stroke-linecap: round; }
.ana-line-plays { stroke: var(--accent); }
.ana-line-viewers {
  stroke: var(--accent-2);
  stroke-width: 1.8;
  stroke-dasharray: 5 4;
  opacity: 0.85;
}
.ana-point { fill: var(--accent); opacity: 0; }
.ana-point:hover { opacity: 1; }
.ana-grid2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  grid-gap: 18px;
  gap: 18px;
}
.ana-ranklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.ana-rankrow {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  grid-gap: 10px;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.ana-rankrow:last-child { border-bottom: none; }
.ana-ranknum {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}
.ana-device-num { color: var(--text-muted); }
.ana-rank-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ana-rank-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-md);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ana-type {
  font-style: normal;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}
.ana-share {
  height: 4px;
  border-radius: 2px;
  background: var(--hover);
  overflow: hidden;
}
.ana-share i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.ana-rank-meta { font-size: var(--fs-sm); white-space: nowrap; }
@media (max-width: 640px) {
  .ana-rankrow { grid-template-columns: 20px 1fr; }
  .ana-rank-meta { grid-column: 2; }
  .ana-stats { grid-template-columns: repeat(2, 1fr); }
}
/* Transcoding — Plex-inspired server/transcoder layout */
.tc-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--card);
  margin: 18px 0;
}
.tc-banner-icon {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.tc-banner.tc-off .tc-banner-icon {
  color: var(--error);
  background: color-mix(in srgb, var(--error) 14%, transparent);
}
.tc-banner-body {
  flex: 1 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tc-banner-body strong { font-size: var(--fs-lg); }
.tc-state {
  flex: none;
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: 999px;
}
.tc-state.on {
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.tc-state.off {
  color: var(--muted);
  border: 1px solid var(--line);
  background: var(--hover);
}
.tc-caps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-gap: 14px;
  gap: 14px;
  margin-bottom: 18px;
}
.tc-cap {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
}
.tc-cap-icon {
  width: 32px;
  height: 32px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.tc-cap-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.tc-cap-sub {
  font-size: var(--fs-sm);
  overflow: hidden;
  text-overflow: ellipsis;
}
.tc-meter {
  height: 5px;
  border-radius: 3px;
  background: var(--hover);
  overflow: hidden;
}
.tc-meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.tc-encs { display: flex; flex-wrap: wrap; gap: 5px; }
.tc-enc {
  font-size: var(--fs-xs);
  font-weight: 600;
  font-family: var(--font-mono, monospace);
  padding: 3px 8px;
  border-radius: 6px;
  color: var(--muted);
  background: var(--hover);
  border: 1px solid var(--line);
}
.tc-enc.ok {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.tc-groups {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-gap: 22px;
  gap: 22px;
}
.tc-group h3 {
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 12px;
}
.tc-toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  margin-bottom: 8px;
}
.tc-toggle-text {
  flex: 1 1;
  min-width: 0;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.tc-toggle-text small { font-weight: 400; }
.tc-toggle {
  flex: none;
  width: 44px;
  height: 25px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--hover);
  padding: 2px;
  cursor: pointer;
  position: relative;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.tc-toggle i {
  display: block;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.18s ease, background 0.15s ease;
}
.tc-toggle.on {
  background: var(--accent);
  border-color: var(--accent);
}
.tc-toggle.on i {
  transform: translateX(19px);
  background: #fff;
}
.tc-jobs { list-style: none; margin: 0; padding: 0; }
.tc-job {
  display: grid;
  grid-template-columns: auto minmax(70px, max-content) 1fr auto;
  align-items: center;
  grid-gap: 12px;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.tc-job:last-child { border-bottom: none; }
.tc-job-state {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 9px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--hover);
  border: 1px solid var(--line);
}
.tc-job-state.running {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.tc-job-state.done,
.tc-job-state.completed {
  color: #5ec98a;
  border-color: color-mix(in srgb, #5ec98a 45%, transparent);
  background: color-mix(in srgb, #5ec98a 12%, transparent);
}
.tc-job-state.failed {
  color: var(--error);
  border-color: color-mix(in srgb, var(--error) 45%, transparent);
  background: color-mix(in srgb, var(--error) 12%, transparent);
}
.tc-job-id { font-size: var(--fs-sm); color: var(--muted); }
.tc-job-track {
  height: 6px;
  border-radius: 3px;
  background: var(--hover);
  overflow: hidden;
}
.tc-job-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.5s ease;
}
.tc-job-state.failed ~ .tc-job-track i { background: var(--error); }
.tc-job-pct {
  font-size: var(--fs-sm);
  font-weight: 600;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
  min-width: 38px;
  text-align: right;
}
.tc-job-err { grid-column: 2 / -1; font-size: var(--fs-sm); }
.tc-empty {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 4px;
  color: var(--muted);
}
.tc-empty p {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tc-empty strong { color: var(--fg); }
@media (max-width: 860px) {
  .tc-caps { grid-template-columns: 1fr; }
  .tc-groups { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .tc-banner { align-items: flex-start; }
  .tc-state { display: none; }
  .tc-job { grid-template-columns: auto 1fr auto; }
  .tc-job-id { display: none; }
}
.menu-notice {
  color: var(--accent) !important;
  font-weight: 600;
}
.interests-dialog { max-width: 460px; }
.interests-dialog h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}
.interests-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 16px;
}
.interests-chips .chip {
  border: none;
  cursor: pointer;
  font: inherit;
}
.interests-field {
  border: none;
  padding: 0;
  margin: 0 0 12px;
}
.interests-field legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
  padding: 0;
}
.interests-field > p { margin: 2px 0 0; font-size: var(--fs-sm); }
.profile-form {
  max-width: 380px;
  margin: 32px auto 0;
  text-align: left;
}
.profile-form h2 { font-size: var(--fs-lg); margin: 0 0 12px; }
.profile-form label { display: block; margin-bottom: 12px; font-size: var(--fs-sm); }
.profile-form input[type="text"],
.profile-form input:not([type]) {
  width: 100%;
  margin-top: 4px;
}
.color-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}
.color-dot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
}
.check-row {
  display: flex !important;
  align-items: center;
  gap: 8px;
}
.transcode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  grid-gap: 14px 20px;
  gap: 14px 20px;
  align-items: end;
}
.transcode-grid label { display: flex; flex-direction: column; gap: 4px; }
.transcode-grid label.check-row { flex-direction: row; align-items: center; }
.transcode-grid .muted { font-size: 0.8rem; }
.form-row { display: flex; gap: 10px; margin-top: 16px; }
.manage-btn {
  margin-top: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* sidebar */
.sidebar {
  position: fixed;
  top: calc(var(--topnav-h) + var(--safe-t));
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  /* Translucent navigation surface — dynamic artwork backgrounds show
     faintly through instead of a solid wall beside cinematic content. */
  background: color-mix(in srgb, var(--bg-soft) 82%, transparent);
  -webkit-backdrop-filter: blur(14px);
          backdrop-filter: blur(14px);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 10px 20px;
  transition: width var(--dur) ease, transform var(--dur) ease;
  z-index: 40;
}
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }

.sidebar-section { margin-bottom: 18px; }
.sidebar-label {
  display: block;
  padding: 0 12px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.collapsed .sidebar-label { visibility: hidden; height: 10px; padding: 0; }

.side-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 12px;
  margin: 1px 0;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--fs-md);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
}
.side-item:hover { background: var(--hover); color: var(--text); }
.side-item.active {
  background: var(--accent-2-soft);
  color: var(--text);
  font-weight: 600;
}
.side-item.active svg { color: var(--accent-2); }
.side-item .side-text {
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1;
  text-align: left;
}
.collapsed .side-item .side-text { display: none; }
.collapsed .side-item { justify-content: center; padding: 10px; }

.side-count {
  font-size: var(--fs-xs);
  color: var(--text-faint);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 1px 7px;
}
.collapsed .side-count { display: none; }

.collapse-btn {
  width: 100%;
  margin-top: 4px;
}

/* main content */
.shell-main {
  margin-left: var(--sidebar-w);
  min-height: calc(100vh - var(--topnav-h) - var(--safe-t));
  transition: margin-left var(--dur) ease;
}
.shell.no-sidebar .shell-main,
.shell.collapsed .shell-main { margin-left: var(--sidebar-w-collapsed); }
.shell.no-sidebar .shell-main { margin-left: 0; }
.shell.no-sidebar .sidebar { display: none; }

.shell-main > main,
.shell-main .page {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--page-y) var(--page-x)
    calc(96px + var(--safe-b));
}

/* mobile drawer + bottom nav */
.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 45;
}
.mobile-nav { display: none; }

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-105%);
    width: var(--sidebar-w) !important;
    box-shadow: var(--shadow-3);
  }
  .sidebar.drawer-open {
    transform: translateX(0);
    /* sit above the backdrop (z 45) — otherwise the overlay swallows
       every tap and the drawer closes without navigating */
    z-index: 46;
  }
  .drawer-backdrop.show { display: block; }
  .shell-main { margin-left: 0 !important; }
  .shell-main > main,
  .shell-main .page { padding: 20px 16px 120px; }

  .mobile-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    background: rgba(15, 18, 25, 0.94);
    -webkit-backdrop-filter: blur(10px);
            backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    padding: 6px max(4px, var(--safe-r)) calc(6px + var(--safe-b)) max(4px, var(--safe-l));
    justify-content: space-around;
  }
  .mobile-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 4px 10px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 10px;
  }
  .mobile-nav a.active { color: var(--accent); }
  .collapsed .side-item .side-text,
  .collapsed .side-count { display: inline; }
  .sidebar .side-text { display: inline; }
  .sidebar .side-item { justify-content: flex-start; padding: 8px 12px; }
  .sidebar .sidebar-label { visibility: visible; height: auto; padding: 0 12px 6px; }
  .search-box kbd { display: none; }
}

/* Tablet band (600–899px, incl. landscape phones and split-screen):
   persistent icon rail instead of bottom navigation — tablets have the
   width for it, and rail keeps library/admin sections reachable. The
   hamburger still expands it into a full overlay drawer. */
@media (min-width: 600px) and (max-width: 899px) {
  .sidebar {
    transform: none;
    width: var(--sidebar-w-collapsed) !important;
    box-shadow: none;
  }
  .sidebar .side-text,
  .sidebar .side-count { display: none; }
  .sidebar .side-item { justify-content: center; padding: 10px; }
  .sidebar .sidebar-label { visibility: hidden; height: 10px; padding: 0; }
  .sidebar .collapse-btn { display: none; }

  /* Expanded drawer state: full width + labels, over the content. */
  .sidebar.drawer-open {
    width: var(--sidebar-w) !important;
    box-shadow: var(--shadow-3);
  }
  .sidebar.drawer-open .side-text,
  .sidebar.drawer-open .side-count { display: inline; }
  .sidebar.drawer-open .side-item { justify-content: flex-start; padding: 8px 12px; }
  .sidebar.drawer-open .sidebar-label {
    visibility: visible;
    height: auto;
    padding: 0 12px 6px;
  }

  .shell-main { margin-left: var(--sidebar-w-collapsed) !important; }
  .shell-main > main,
  .shell-main .page {
    padding: var(--page-y) var(--page-x) calc(96px + var(--safe-b));
  }
  .mobile-nav { display: none; }
}

@media (max-width: 560px) {
  .search-box { display: none; }
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- library browse ---------- */

.browse-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.browse-head h1 { margin: 0 0 4px; font-size: var(--fs-2xl); }
.browse-meta { color: var(--text-muted); font-size: var(--fs-sm); }

.browse-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.browse-toolbar select,
.browse-toolbar input[type="search"] {
  width: auto;
  margin: 0;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-sm);
}
.view-toggle {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.view-toggle button {
  margin: 0;
  padding: 7px 10px;
  border: none;
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 0;
}
.view-toggle button.active { background: var(--surface-2); color: var(--accent); }

.poster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-poster-w), 1fr));
  grid-gap: var(--row-gap) var(--card-gap);
  gap: var(--row-gap) var(--card-gap);
}
@media (max-width: 720px) {
  .poster-grid { gap: 14px 10px; }
}
.poster-grid.compact { grid-template-columns: repeat(auto-fill, minmax(min(110px, var(--card-poster-w)), 1fr)); gap: 12px 10px; }

.list-view { display: flex; flex-direction: column; gap: 4px; }
.list-row {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  grid-gap: 14px;
  gap: 14px;
  align-items: center;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  text-decoration: none;
  color: var(--text);
}
.list-row:hover { background: var(--hover); }
.list-row .thumb {
  width: 46px;
  aspect-ratio: 2/3;
  border-radius: 4px;
  overflow: hidden;
  font-size: 14px;
}
.list-row .thumb .art { border-radius: 4px; font-size: 14px; }
.list-row-meta { color: var(--text-muted); font-size: var(--fs-sm); }

/* badges */
.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}
.badge-quality {
  background: rgba(240, 164, 60, 0.16);
  color: var(--accent);
}
.badge-warn,
.badge-error {
  background: var(--error-soft);
  color: var(--error);
}
.badge-active {
  background: var(--accent-soft, rgba(240, 164, 60, 0.16));
  color: var(--accent);
}

/* vertical stack of panels */
.stack { display: grid; grid-gap: 14px; gap: 14px; }

/* generic page header */
.page-head { margin-bottom: 20px; }
.page-head h1 { margin: 0 0 4px; font-size: var(--fs-2xl); }
.page-head .muted { font-size: var(--fs-md); }

/* buttons */
.btn-accent {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  margin: 0;
  border: none;
  border-radius: var(--r-sm);
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 700;
  font-size: var(--fs-md);
  text-decoration: none;
  cursor: pointer;
}
.btn-accent:hover { background: var(--accent-hover); }
.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  margin: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text);
  font-size: var(--fs-md);
  text-decoration: none;
  cursor: pointer;
}
.btn-ghost:hover { background: var(--hover); }

/* ---------- admin library: files/covers panels & preview player ---------- */
.panel-loading { color: var(--text-muted); padding: 4px 0; }
/* Plex-style content grid — compact posters, chips for state. */
.lib-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.lib-filter {
  width: 200px;
  max-width: 40vw;
  flex-shrink: 0;
}
.lib-titles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  grid-gap: 14px 12px;
  gap: 14px 12px;
}
.lt-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0;
  border: none;
  background: none;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.lt-poster {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 8px;
  overflow: hidden;
  background: var(--elevated);
  border: 1px solid var(--border);
}
.lt-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.lt-card:hover .lt-poster,
.lt-card:focus-visible .lt-poster {
  border-color: var(--accent);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
.lt-poster-empty {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.75);
}
.lt-chip {
  position: absolute;
  left: 6px;
  bottom: 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(10, 12, 18, 0.82);
}
.lt-chip-draft { color: var(--text-muted); }
.lt-chip-review { color: var(--warning); }
.lt-chip-unmatched { color: var(--warning); bottom: auto; top: 6px; }
.lt-chip ~ .lt-chip { bottom: 24px; }
.lt-edit {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 18, 0.85);
  color: var(--accent);
  font-size: 13px;
  opacity: 0;
  transition: opacity var(--dur-fast);
}
.lt-card:hover .lt-edit,
.lt-card:focus-visible .lt-edit { opacity: 1; }
.lt-name {
  font-size: 12.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lt-sub { font-size: 11px; }

/* Layout switcher + tile (list) view. */
.lib-panel-tools { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.view-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.view-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.view-btn + .view-btn { border-left: 1px solid var(--border); }
.view-btn:hover { color: var(--text); background: var(--hover); }
.view-btn.view-on {
  color: var(--accent);
  background: var(--accent-2-soft);
}
.lib-titles-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  grid-gap: 12px;
  gap: 12px;
}
/* Media-manager tile — poster + info on top, action toolbar below,
   matching the library card shape. */
.lt-row {
  display: flex;
  flex-direction: column;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  -webkit-user-select: none;
     -moz-user-select: none;
          user-select: none;
  overflow: hidden;
}
.lt-row:hover,
.lt-row:focus-visible {
  border-color: var(--accent);
}
.lt-row-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 12px 10px;
}
.lt-row-poster {
  width: 52px;
  aspect-ratio: 2 / 3;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--elevated);
}
.lt-row-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.lt-row-main { flex: 1 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.lt-row-badges { display: flex; gap: 6px; flex-wrap: wrap; }
/* Bottom action toolbar — labeled buttons on a divider, Emby-style. */
.lt-row-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--elevated) 45%, transparent);
}
.lt-act {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 2px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: color var(--dur-fast), background var(--dur-fast);
}
.lt-act:hover,
.lt-act:focus-visible {
  color: var(--accent);
}
.lt-act:disabled { opacity: 0.35; cursor: default; }

/* Files panel — poster tiles per scanned file. */
.file-tile { cursor: default; }
.file-tile-poster {
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  font: inherit;
  text-align: inherit;
}
.file-tile-poster:disabled { cursor: default; opacity: 0.6; }
.file-tile-poster:enabled:hover,
.file-tile-poster:enabled:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
.file-tile-poster .lt-edit { opacity: 0; }
.file-tile-poster:enabled:hover .lt-edit,
.file-tile-poster:enabled:focus-visible .lt-edit { opacity: 1; }
.file-tile-actions {
  display: flex;
  gap: 10px;
  margin-top: 2px;
  min-height: 18px;
}
.file-tile-actions .link-button { font-size: 11.5px; padding: 0; }

/* Plex-style title editor modal. */
.title-editor {
  width: min(880px, 100%);
  max-height: min(88vh, 900px);
  overflow-y: auto;
}
.te-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.te-head-poster {
  width: 44px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 6px;
  background: var(--elevated);
  flex-shrink: 0;
}
.te-head-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.te-head-meta { flex: 1 1; min-width: 0; }
.te-head-meta strong { display: block; }
.te-head-meta span { font-size: 12px; }
.te-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-gap: 16px 24px;
  gap: 16px 24px;
  padding-top: 12px;
}
.te-section h4 {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}
.te-section:first-child { grid-row: span 2; }
.te-thumbs { display: flex; gap: 8px; }
.te-thumbs img {
  width: 76px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 6px;
  background: var(--elevated);
}
.te-thumbs .te-thumb-wide {
  width: 136px;
  aspect-ratio: 16 / 9;
}
.te-thumb-empty {
  width: 76px;
  aspect-ratio: 2 / 3;
  border: 1px dashed var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 11px;
}
.te-thumb-empty.te-thumb-wide {
  width: 136px;
  aspect-ratio: 16 / 9;
}
.te-section .cover-art-pick { margin-top: 8px; }
.te-section .btn-row { margin-top: 8px; }
.te-form .field { margin-bottom: 8px; }
.te-field-row { display: flex; gap: 10px; }
.te-field-row .field { flex: 1 1; }
.te-form textarea {
  width: 100%;
  resize: vertical;
  font: inherit;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 6px);
  color: var(--text);
  padding: 8px 10px;
}
.te-candidates { margin-top: 6px; max-height: 240px; overflow-y: auto; }
@media (max-width: 720px) {
  .te-body { grid-template-columns: 1fr; }
  .te-section:first-child { grid-row: auto; }
}

.cover-upload { cursor: pointer; }
.cover-art-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.cover-art-pick img {
  width: 44px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 4px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  background: var(--elevated);
}
.cover-art-pick img:hover,
.cover-art-pick img:focus-visible { border-color: var(--accent); }
.cover-search { display: flex; gap: 6px; }
.cover-search input { flex: 1 1; min-width: 0; }
.match-candidate {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.match-candidate img {
  width: 30px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 3px;
  background: var(--elevated);
}
.player-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.85);
  -webkit-backdrop-filter: blur(4px);
          backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
  padding: 24px;
}
.player-modal {
  width: min(960px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 14px);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.player-modal video {
  width: 100%;
  max-height: 70vh;
  border-radius: 8px;
  background: #000;
}
.player-modal-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.player-modal-bar code {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-edit-modal {
  width: min(560px, 100%);
}
.file-edit-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 8px 8px;
}
.file-edit-row {
  display: flex;
  gap: 12px;
}
.file-edit-row .field {
  flex: 1 1;
}
.file-edit-form .form-actions {
  display: flex;
  justify-content: flex-end;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.folder-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.folder-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-alt, rgba(255, 255, 255, 0.03));
}
.folder-chip code {
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------- admin libraries: card grid, detail tabs, wizard ---------- */
/* ===== Emby-style library manager =====
   "Manage Libraries" header with inline tools + Add Media Library,
   flat cards: icon/name header, folder-path list, stats, and a bottom
   action toolbar — no artwork collage, utilitarian dashboard look. */
.emb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.emb-head h2 { margin: 0; font-size: 22px; }
.emb-head p { margin: 4px 0 0; }
.emb-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.emb-tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
}
.emb-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

/* ⋯ overflow menu — shared by the header and every card. */
.libm-menu-wrap { position: relative; }
.libm-dots {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}
.libm-dots:hover,
.libm-dots:focus-visible {
  color: var(--text);
  border-color: var(--border-strong);
}
.libm-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 200px;
  background: var(--elevated);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: var(--shadow-2, 0 12px 32px rgba(0, 0, 0, 0.5));
  padding: 5px;
  z-index: 60;
}
.libm-menu-up { top: auto; bottom: calc(100% + 6px); }
.libm-menu button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.libm-menu button:hover:not(:disabled) { background: var(--hover); }
.libm-menu button:disabled { opacity: 0.4; cursor: default; }

/* Scan health dot on the card's last-scan line. */
.scan-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
  background: var(--text-faint, #6b7280);
}
.scan-dot-ok { background: var(--success, #4ade80); }
.scan-dot-fail { background: var(--error, #f87171); }
.scan-dot-idle { background: var(--text-faint, #6b7280); }
.scan-dot-run {
  background: var(--accent);
  animation: scan-pulse 1.2s ease-in-out infinite;
}
@keyframes scan-pulse {
  50% { opacity: 0.35; }
}

/* Emby library card — flat tile: head, folder list + stats, toolbar. */
.emb-grid {
  display: grid;
  /* Tile layout: exactly 4 per row on desktop, stepping down on
     narrower widths so tiles never collapse into a list. */
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-gap: 14px;
  gap: 14px;
}
@media (max-width: 1500px) {
  .emb-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .emb-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .emb-grid { grid-template-columns: 1fr; }
}
.emb-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: border-color 0.15s ease;
}
.emb-card:hover { border-color: var(--border-strong); }
.emb-card-off { opacity: 0.6; }

.emb-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 10px;
}
.emb-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--elevated);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}
.emb-card-id {
  flex: 1 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.emb-card-id a { color: var(--text); text-decoration: none; }
.emb-card-id a:hover { text-decoration: underline; }
.emb-card-id strong { font-size: 14.5px; }
.emb-card-id .muted { font-size: 11.5px; }
.emb-card-head .scan-dot { margin-right: 0; }

.emb-card-body {
  padding: 0 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1;
}
.emb-dirs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.emb-dirs li {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--text-muted);
  overflow: hidden;
  white-space: nowrap;
}
.emb-dirs li span {
  overflow: hidden;
  text-overflow: ellipsis;
  direction: rtl; /* keep the filename end visible on long paths */
}
.emb-dirs-empty { margin: 0; font-size: 11.5px; }
.emb-stats {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--text-muted);
}
.emb-stats strong { color: var(--text); font-weight: 600; }
.emb-ok { color: var(--text-faint, #6b7280); }
.emb-strip {
  display: flex;
  gap: 4px;
  margin-top: auto;
}
.emb-strip img {
  flex: 1 1;
  min-width: 0;
  aspect-ratio: 2 / 3;
  max-height: 72px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.emb-card-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--elevated) 45%, transparent);
}
.emb-card-tools .emb-tool { padding: 3px 0; }
.emb-card-tools .libm-menu-wrap { margin-left: auto; }
.emb-dots-sm {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border-color: transparent;
  background: transparent;
}
.emb-dots-sm:hover { background: var(--hover); }

.emb-card-add {
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 140px;
  padding: 16px;
  gap: 8px;
  text-decoration: none;
  color: var(--text-muted);
  border-style: dashed;
}
.emb-card-add:hover { color: var(--accent); border-color: var(--accent); }

.lib-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--elevated);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 22px;
  flex-shrink: 0;
}
.lib-card-stats {
  display: flex;
  gap: 18px;
  margin: 0;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.lib-card-stats dt { font-size: 11px; color: var(--text-muted); }
.lib-card-stats dd { margin: 0; font-size: 13px; }
/* Library section header inside the catalog — Plex-style management
   strip shown while a library tab is active. */
.lib-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  margin: 8px 0 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.lib-strip-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 16%, var(--elevated));
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.lib-strip-info { flex: 1 1; min-width: 0; }
.lib-strip-info strong { display: block; }
.lib-strip-info .muted { font-size: 12px; }
.lib-strip-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.lib-strip-actions .btn-secondary,
.lib-strip-manage {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

/* Plex-style catalog management: library rail on the left, toolbar on
   top, poster grid or detail table as the content. */
.catalog-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.catalog-rail {
  width: 208px;
  flex-shrink: 0;
  position: -webkit-sticky;
  position: sticky;
  top: calc(var(--topnav-h) + 12px);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rail-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: var(--fs-sm);
  cursor: pointer;
  text-align: left;
  transition:
    background var(--dur-fast),
    color var(--dur-fast);
}
.rail-item:hover {
  background: var(--surface);
  color: var(--text);
}
.rail-item.active {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  box-shadow: inset 3px 0 0 var(--accent);
}
.rail-name {
  flex: 1 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rail-count {
  font-size: var(--fs-xs);
  color: var(--text-faint);
}
.catalog-main {
  flex: 1 1;
  min-width: 0;
}

.catalog-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 12px;
  margin: 4px 0 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.catalog-toolbar input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
}
.ct-spacer {
  flex: 1 1;
}
.ct-sort,
.ct-dir {
  background: var(--elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: var(--fs-sm);
  padding: 6px 9px;
}
.ct-dir {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.ct-dir:hover,
.ct-sort:hover {
  border-color: var(--border-strong);
}
.ct-view {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.ct-view button {
  display: inline-flex;
  align-items: center;
  padding: 6px 9px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}
.ct-view button:hover {
  color: var(--text);
}
.ct-view button.active {
  background: var(--elevated);
  color: var(--accent);
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  grid-gap: 18px 14px;
  gap: 18px 14px;
  margin-top: 14px;
}
.cg-card {
  position: relative;
  min-width: 0;
}
.cg-poster {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
  transition:
    transform var(--dur),
    box-shadow var(--dur);
}
.cg-card:hover .cg-poster,
.cg-card:focus-within .cg-poster {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
}
.cg-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cg-poster-empty {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-faint);
  font-size: var(--fs-xs);
}
.cg-check {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  opacity: 0;
  transition: opacity var(--dur-fast);
}
.cg-card:hover .cg-check,
.cg-card:focus-within .cg-check,
.cg-selected .cg-check {
  opacity: 1;
}
.cg-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
.cg-selected .cg-poster {
  box-shadow: 0 0 0 2px var(--accent);
}
.cg-status {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 1;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
}
.cg-pub {
  background: color-mix(in srgb, var(--success) 30%, rgba(0, 0, 0, 0.75));
  color: #d8ffe4;
}
.cg-draft {
  background: rgba(0, 0, 0, 0.7);
  color: var(--warning);
}
.cg-alert {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--error-soft);
  color: var(--error);
}
.cg-actions {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  z-index: 1;
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 30px 8px 10px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
  opacity: 0;
  transition: opacity var(--dur-fast);
}
.cg-card:hover .cg-actions,
.cg-card:focus-within .cg-actions {
  opacity: 1;
}
.cg-action {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: var(--fs-sm);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
}
.cg-action:hover {
  color: var(--accent-hover);
}
.cg-danger:hover {
  color: var(--error);
}
.cg-meta {
  padding: 8px 2px 0;
}
.cg-title {
  display: block;
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cg-title:hover {
  color: var(--accent-hover);
}
.cg-sub {
  display: block;
  font-size: var(--fs-xs);
  margin-top: 2px;
}
.cg-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}
.cg-badges .badge-ok,
.cg-badges .badge-draft {
  font-size: 9px;
}
@media (max-width: 900px) {
  .catalog-layout {
    flex-direction: column;
  }
  .catalog-rail {
    position: static;
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .rail-item {
    flex-shrink: 0;
    width: auto;
  }
  .rail-count {
    display: none;
  }
  .catalog-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px 10px;
  }
}

.lib-detail-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
}
.tab-bar {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin: 12px 0 16px;
  overflow-x: auto;
}
.tab {
  position: relative;
  background: none;
  border: 0;
  color: var(--text-muted);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 16px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: color var(--dur-fast) ease;
}
/* Rounded indicator bar under the active tab — the signature look. */
.tab::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 0;
  height: 3px;
  border-radius: 3px;
  background: transparent;
  transition: background var(--dur-fast) ease;
}
.tab:hover { color: var(--text); }
.tab:focus-visible {
  outline: var(--focus-ring-w) solid var(--focus-ring);
  outline-offset: -2px;
}
.tab-active {
  color: var(--text);
  font-weight: 600;
}
.tab-active::after {
  background: var(--accent);
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  grid-gap: 10px;
  gap: 10px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 10px);
  padding: 12px 14px;
}
.stat-card dt { font-size: 11px; color: var(--text-muted); }
.stat-card dd { margin: 4px 0 0; font-size: 18px; font-weight: 600; }
.danger-zone {
  border-color: var(--error, #f87171);
  margin-top: 20px;
}
.btn-danger {
  background: rgba(248, 113, 113, 0.14);
  color: var(--error, #f87171);
  border: 1px solid var(--error, #f87171);
  border-radius: var(--radius-sm, 8px);
  padding: 7px 14px;
  font: inherit;
  cursor: pointer;
}
.btn-danger:hover:not(:disabled) { background: rgba(248, 113, 113, 0.25); }
.btn-danger:disabled { opacity: 0.5; cursor: not-allowed; }
.wizard-steps {
  display: flex;
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
  counter-reset: step;
}
.wizard-step {
  counter-increment: step;
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.wizard-step::before { content: counter(step) " · "; }
.wizard-step-active {
  color: var(--accent);
  border-color: var(--accent);
}
.wizard-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  grid-gap: 10px;
  gap: 10px;
  margin-bottom: 14px;
}
.wizard-type {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 14px;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 10px);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.wizard-type:hover { border-color: var(--accent); }
.wizard-type-active { border-color: var(--accent); background: rgba(240, 164, 60, 0.08); }
.wizard-type .muted { font-size: 12px; }

/* ---------- admin catalog: file paths ---------- */
.file-path-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 460px;
}
.file-path-list code {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-button.danger { color: var(--error, #f87171); }

/* ---------- billing ---------- */
.plan-option {
  margin: 10px 0;
}
.plan-option button {
  min-width: 220px;
}
.sub-editor {
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--border, #333);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 340px;
}
.sub-editor label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  color: var(--text-muted);
}
.sub-editor input,
.sub-editor select {
  font-size: 13px;
  padding: 5px 7px;
}
.sub-editor .checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.subtitle-editor {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.subtitle-editor .form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.subtitle-editor input[type="text"],
.subtitle-editor input:not([type]) {
  font-size: 13px;
  padding: 5px 7px;
}
.subtitle-editor .checkbox {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 5px;
  font-size: 12px;
}

/* ---------- admin dashboard tiles ---------- */

/* Plex-settings shell: grouped rail + content. Pages render their own
   <main>, so the shell takes over the content column's spacing and the
   nested mains are neutralized. */
.shell-main > .admin-shell {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--page-y) var(--page-x) calc(96px + var(--safe-b));
  display: flex;
  gap: 26px;
  align-items: flex-start;
}
.admin-shell .admin-body {
  flex: 1 1;
  min-width: 0;
}
.admin-body > main,
.admin-body > .page {
  max-width: none;
  margin: 0;
  padding: 0;
}
.admin-rail {
  width: 200px;
}
.rail-group + .rail-group {
  margin-top: 16px;
}
.rail-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 10px 6px;
}
.admin-group {
  margin-top: 26px;
}
.admin-group-label {
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 10px;
}
.admin-tile-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--accent) 14%, var(--elevated));
  color: var(--accent);
  margin-bottom: 4px;
}
@media (max-width: 900px) {
  .admin-shell {
    flex-direction: column;
    padding: 20px 16px 120px;
  }
  .rail-group {
    display: flex;
    align-items: center;
    flex-shrink: 0;
  }
  .rail-label {
    padding: 0 10px 0 4px;
  }
  .rail-group + .rail-group {
    margin-top: 0;
    margin-left: 10px;
  }
}

.admin-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  grid-gap: 14px;
  gap: 14px;
  margin-top: 18px;
}
.admin-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 18px;
  padding-right: 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s;
}
.admin-tile:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.admin-tile-title {
  font-weight: 600;
  font-size: 15px;
}
.admin-tile-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}
.admin-tile-arrow {
  position: absolute;
  right: 16px;
  top: 16px;
  color: var(--text-muted);
  transition: color 0.15s, transform 0.15s;
}
.admin-tile:hover .admin-tile-arrow {
  color: var(--accent);
  transform: translateX(3px);
}

.danger-zone {
  border-color: rgba(248, 113, 113, 0.35);
}
.danger-zone h2 {
  color: var(--error, #f87171);
}

/* ---------- admin analytics ---------- */
.stat-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 16px 0;
}
.card.stat {
  min-width: 130px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-value {
  font-size: 26px;
  font-weight: 700;
}
.stat-label {
  font-size: 12px;
  color: var(--text-muted);
}
.analytics-chart {
  width: 100%;
  height: auto;
  display: block;
}
.analytics-chart .chart-bar {
  fill: var(--accent, #e50914);
}
.analytics-chart .chart-tick {
  fill: var(--text-muted);
  font-size: 9px;
}
.analytics-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-gap: 24px;
  gap: 24px;
}
@media (max-width: 720px) {
  .analytics-split {
    grid-template-columns: 1fr;
  }
}

/* ---------- mobile money ---------- */
.mm-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}
.mm-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--text-muted);
}
.mm-form input,
.mm-form select {
  font-size: 14px;
  padding: 8px 10px;
}
.mm-form button { margin-top: 4px; }
.mm-reference { font-size: 18px; }

/* ---------- TV (10-foot) surface ---------- */
.tv-shell .shell-main { padding: 0; }
.tv-app {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  /* Rendered as <main> — the global main{} rule caps it at 720px
     centered; the TV surface is the full viewport. */
  max-width: none;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 20px; /* base scales the whole 10-foot UI */

  /* TV design tokens — overscan-safe geometry, distance-readable type,
     and a focus treatment that's unmistakable at 3 metres. Derived from
     the app palette so dynamic theming reaches the TV too. */
  --tv-safe-x: 4rem;
  --tv-safe-y: 3rem;
  --tv-surface: var(--surface);
  --tv-elevated: var(--surface-2);
  --tv-accent: var(--accent);
  --tv-focus-ring: var(--accent);
  --tv-focus-glow: color-mix(in srgb, var(--accent) 45%, transparent);
  /* em-based so the ring scales with the calibration font-size — stays
     visible at 720p→4K and under a larger interface scale. */
  --tv-focus-w: 0.2em;
  --tv-card-poster-w: 11rem;
  --tv-card-landscape-w: 20rem;
  --tv-row-gap: 1.2rem;
  --tv-rail-w: 5rem;
  --tv-anim: 140ms;
}
.tv-boot { padding: 4rem; }

/* 4K panels: a 2160p TV renders the same layout but everything should be
   ~1.4× — the base font bump scales every rem-based rule at once. */
@media (min-width: 2560px) {
  .tv-app { font-size: 28px; }
}

/* focus ring — bright ring + soft glow + modest scale; never overlaps
   neighbours because strips pad around the transform. */
[data-tv-focus] { outline: none; }
[data-tv-focus]:focus,
[data-tv-focus]:focus-visible {
  outline: var(--tv-focus-w) solid var(--tv-focus-ring);
  outline-offset: 3px;
  border-radius: 8px;
  box-shadow:
    0 0 0 6px var(--tv-focus-glow),
    0 14px 32px rgba(0, 0, 0, 0.55);
  transform: scale(1.05);
  transition: transform var(--tv-anim) ease, box-shadow var(--tv-anim) ease;
  z-index: 2;
  position: relative;
}

/* High-contrast mode (localStorage katandika.tv.highContrast=1 → .tv-hc):
   pure-white ring, heavier weight, no reliance on the accent hue. */
.tv-app.tv-hc {
  --tv-focus-ring: #ffffff;
  --tv-focus-w: 0.25em;
  --tv-focus-glow: rgba(255, 255, 255, 0.35);
}
.tv-app.tv-hc .muted { color: #cfd4dc; }

/* Reduced motion: focus still moves instantly — only animation stops. */
@media (prefers-reduced-motion: reduce) {
  .tv-app *,
  .tv-app *::before,
  .tv-app *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* ---------- Fused cinematic background ---------- */
/* Views must paint above the fixed background layers. */
.tv-home,
.tv-title,
.tv-profiles,
.tv-pair,
.tv-player { position: relative; z-index: 1; }

.tv-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.tv-bg > * { position: absolute; inset: 0; }
.tv-bg-base { background: var(--bg); }

/* Generated gradient when no authorized artwork exists. */
.tv-bg-fallback { opacity: 1; }

.tv-bg-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 60% 20%; /* focal bias: subjects sit right, text sits left */
}
.tv-bg-in { animation: tv-bg-in 450ms ease-out both; }
.tv-bg-out { animation: tv-bg-out 450ms ease-out both; }
@keyframes tv-bg-in {
  from { opacity: 0; transform: scale(1.015); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes tv-bg-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* Artwork-derived ambient light — capped low so it reads as atmosphere. */
.tv-bg-tint { opacity: 0.22; }
.tv-bg-ambient { mix-blend-mode: screen; }

/* Semantic text-protection gradients — the only gradients the TV bg uses. */
.tv-bg-grad-text {
  background: linear-gradient(
    to right,
    rgba(8, 10, 14, 0.92) 0%,
    rgba(8, 10, 14, 0.62) 38%,
    rgba(8, 10, 14, 0.15) 68%,
    transparent 82%
  );
}
.tv-bg-grad-nav {
  background: linear-gradient(
    to bottom,
    rgba(8, 10, 14, 0.72) 0%,
    transparent 22%
  );
}
.tv-bg-grad-blend {
  background: linear-gradient(
    to top,
    var(--bg) 0%,
    var(--bg) 30%,
    rgba(11, 14, 20, 0.55) 55%,
    transparent 78%
  );
}
.tv-bg-grad-vignette {
  background: radial-gradient(
    120% 90% at 50% 45%,
    transparent 60%,
    rgba(0, 0, 0, 0.32) 100%
  );
}

/* Information region — the focused card's title/meta above the rows. */
.tv-info {
  position: fixed;
  left: calc(var(--tv-safe-x) + var(--tv-rail-w));
  right: 45%;
  top: 12vh;
  z-index: 1;
  pointer-events: none;
  transition: opacity 240ms ease;
}
.tv-info-faded { opacity: 0; }
.tv-info-title {
  font-size: 2.8rem;
  margin: 0 0 0.5rem;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.65);
}
.tv-info-meta {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin: 0 0 0.8rem;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.6);
}
.tv-info-summary {
  font-size: 1.1rem;
  line-height: 1.45;
  margin: 0 0 0.9rem;
  max-width: 46rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.6);
}
.tv-info-progress {
  width: 22rem;
  max-width: 60%;
  height: 0.4rem;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.22);
  overflow: hidden;
  margin-bottom: 0.5rem;
}
.tv-info-progress-bar {
  height: 100%;
  background: var(--tv-accent);
  border-radius: 99px;
}
.tv-info-resume { font-size: 0.95rem; margin: 0; }

/* ---------- Left navigation rail ----------
   Collapsed icon strip; expands over the content while it has focus so
   labels appear exactly when the user needs them. Sits left inside the
   calibration-safe zone. */
.tv-rail {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: calc(var(--tv-safe-x) * 0.5 + var(--tv-rail-w));
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: calc(var(--tv-safe-y) * 0.6 + 1rem) 0.8rem 1rem;
  background: linear-gradient(
    90deg,
    rgba(8, 10, 15, 0.94) 0%,
    rgba(8, 10, 15, 0.7) 78%,
    transparent
  );
  transition: width var(--dur) ease;
  overflow: hidden;
}
.tv-rail:focus-within,
.tv-rail:hover {
  width: calc(var(--tv-safe-x) * 0.5 + 16rem);
}
.tv-rail-mark {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--accent);
  text-align: center;
  margin: 0 0 1.4rem;
  padding-left: calc(var(--tv-safe-x) * 0.5);
}
.tv-rail-item {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  background: none;
  border: none;
  border-radius: 12px;
  color: var(--text-muted);
  padding: 0.9rem 0.9rem 0.9rem calc(0.9rem + var(--tv-safe-x) * 0.5);
  font-size: 1.1rem;
  font-weight: 600;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}
.tv-rail-item svg {
  width: 1.7rem;
  height: 1.7rem;
  flex: 0 0 auto;
}
.tv-rail-item:focus,
.tv-rail-item:focus-visible {
  color: var(--text);
}
.tv-rail-label {
  opacity: 0;
  transition: opacity 160ms ease;
}
.tv-rail:focus-within .tv-rail-label,
.tv-rail:hover .tv-rail-label {
  opacity: 1;
}
.tv-rail-exit { margin-top: auto; }
/* Section divider between primary nav and the dynamic library list. */
.tv-rail-section {
  margin: 0.6rem 0 0.2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 0.5rem;
  min-height: 0.5rem;
}
.tv-rail-section .tv-rail-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
/* Many libraries → the rail scrolls vertically instead of pushing the
   exit item off-screen. */
.tv-rail { overflow-y: auto; scrollbar-width: none; }
.tv-rail::-webkit-scrollbar { display: none; }

.tv-row-count {
  font-size: 0.85rem;
  font-weight: 400;
  margin-left: 0.4rem;
}

/* Performance tier: no crossfade animation, no ambient layers (they're
   already not rendered), single static image. */
.tv-bg-performance .tv-bg-in,
.tv-bg-performance .tv-bg-out { animation: none; }
.tv-bg-performance .tv-bg-fallback { opacity: 1; }

/* High contrast: deepen all protection gradients, mute the art itself. */
.tv-app.tv-hc .tv-bg-img { opacity: 0.55; }
.tv-app.tv-hc .tv-bg-tint,
.tv-app.tv-hc .tv-bg-ambient { display: none; }
.tv-app.tv-hc .tv-bg-grad-text {
  background: linear-gradient(
    to right,
    rgba(5, 6, 9, 0.97) 0%,
    rgba(5, 6, 9, 0.85) 55%,
    rgba(5, 6, 9, 0.4) 85%
  );
}
.tv-app.tv-hc .tv-bg-grad-blend {
  background: linear-gradient(
    to top,
    var(--bg) 0%,
    var(--bg) 55%,
    transparent 85%
  );
}

/* pairing */
.tv-pair {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 4rem;
}
.tv-pair h1 { font-size: 3rem; }
.tv-pair-hint { color: var(--text-muted); margin: 0; }
.tv-pair-url { font-size: 1.6rem; color: var(--accent); margin: 0; }
.tv-code {
  font-size: 4.5rem;
  letter-spacing: 0.15em;
  font-weight: 700;
  margin: 1rem 0 0;
  padding: 0.4em 0.8em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
}

/* profiles */
.tv-profiles {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 4rem 4rem 4rem
    calc(var(--tv-safe-x) + var(--tv-rail-w) + 1rem);
}
.tv-profile-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  justify-content: center;
}
.tv-profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0.8rem;
}
.tv-avatar {
  width: 7rem;
  height: 7rem;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  font-weight: 700;
  color: #fff;
}
.tv-profile-name { font-size: 1.2rem; }
.tv-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.6rem 1rem;
}
.tv-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
}
.tv-pin-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem 4rem;
  text-align: center;
}
.tv-pin-dots {
  font-size: 2.4rem;
  letter-spacing: 0.4em;
  min-height: 3rem;
  margin: 1rem 0;
}

/* home rows — top pad reserves the hero/info region; left pad clears the
   collapsed rail so D-pad movement stays purely vertical/horizontal. */
.tv-home {
  padding: 1rem var(--tv-safe-x) 3rem
    calc(var(--tv-safe-x) + var(--tv-rail-w) + 0.5rem);
}

/* Featured banner — same shape as the web catalog .hero: a framed,
   rounded backdrop panel with the layered scrim and bottom-left copy.
   Slides stack and crossfade like the web HeroCarousel. */
.tv-banner {
  position: relative;
  height: max(52vh, 20rem);
  margin-bottom: var(--tv-row-gap);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
}
.tv-banner-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.9s ease, visibility 0s linear 0.9s;
}
.tv-banner-on {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.9s ease;
}
.tv-banner-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 60% 20%;
}
.tv-banner-empty {
  background: linear-gradient(135deg, #1a2130, #0d1017);
}
.tv-banner::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      to right,
      rgba(8, 10, 14, 0.82) 0%,
      rgba(8, 10, 14, 0.32) 45%,
      transparent 72%
    ),
    linear-gradient(
      to top,
      var(--bg) 0%,
      rgba(8, 10, 14, 0.45) 32%,
      transparent 64%
    );
  pointer-events: none;
}
.tv-banner-copy {
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: 1;
  padding: 2.4rem 3rem;
  max-width: 46rem;
}
.tv-banner-copy h1 {
  margin: 0 0 0.6rem;
  font-size: 2.6rem;
  line-height: 1.04;
  letter-spacing: -0.015em;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.65);
}
.tv-banner-meta {
  font-size: 1.05rem;
  color: rgba(233, 236, 242, 0.85);
  margin: 0 0 0.7rem;
}
.tv-banner-desc {
  font-size: 1.05rem;
  line-height: 1.45;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text-muted);
}
.tv-banner-actions {
  display: flex;
  gap: 0.9rem;
  margin-top: 1.3rem;
  padding: 0.9rem 0.3rem;
}
.tv-banner-play,
.tv-banner-more {
  border: none;
  border-radius: 12px;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 0.8rem 1.8rem;
  cursor: pointer;
}
.tv-banner-play {
  background: var(--tv-accent);
  color: #fff;
}
.tv-banner-more {
  background: rgba(15, 18, 25, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: var(--text);
  font-weight: 600;
}
@media (prefers-reduced-motion: reduce) {
  .tv-banner-slide,
  .tv-banner-on { transition: none; }
}
.tv-row { margin-bottom: var(--tv-row-gap); }
.tv-row h2 { font-size: 1.4rem; margin: 0 0 1rem; }
.tv-row-strip {
  display: flex;
  gap: 1.2rem;
  overflow-x: auto;
  /* Contain sideways overscroll only — vertical must chain to the page. */
  overscroll-behavior-x: contain;
  /* overflow-x:auto forces overflow-y to clip too — pad enough that the
     focused card's scale(1.05) + ring + glow stay inside the strip. */
  padding: 1.4rem 0.5rem;
  scrollbar-width: none;
}
.tv-row-strip::-webkit-scrollbar { display: none; }
.tv-tile {
  position: relative;
  flex: 0 0 auto;
  width: var(--tv-card-poster-w);
  /* Skip rendering offscreen cards — large catalog rows stay cheap on
     low-power TV SoCs. contain-intrinsic-size keeps the strip's scroll
     geometry stable while contents are skipped. */
  content-visibility: auto;
  contain-intrinsic-size: auto var(--tv-card-poster-w)
    calc(var(--tv-card-poster-w) * 1.45);
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  padding: 0;
}
.tv-tile .art-poster {
  width: var(--tv-card-poster-w);
  height: calc(var(--tv-card-poster-w) * 1.45);
  border-radius: 10px;
}
/* Landscape tile — continue-watching / episode-style 16:9 cards. */
.tv-tile-land {
  width: var(--tv-card-landscape-w);
  contain-intrinsic-size: auto var(--tv-card-landscape-w)
    calc(var(--tv-card-landscape-w) * 0.5625);
}
.tv-tile-land .art-backdrop {
  width: var(--tv-card-landscape-w);
  aspect-ratio: 16 / 9;
  height: auto;
  border-radius: 10px;
}
/* Resume progress bar pinned to the bottom edge of the artwork. */
.tv-prog {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--tv-card-landscape-w) * 0.5625 - 5px);
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.3);
  overflow: hidden;
}
.tv-prog i {
  display: block;
  height: 100%;
  background: var(--accent);
}
.tv-tile-name {
  display: block;
  font-size: 1rem;
  margin-top: 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tv-tile-meta { font-size: 0.85rem; }

/* title detail */
.tv-title {
  padding: 3rem var(--tv-safe-x) 3rem
    calc(var(--tv-safe-x) + var(--tv-rail-w) + 0.5rem);
}
.tv-hero {
  display: flex;
  gap: 2.5rem;
  align-items: flex-end;
  margin-bottom: 2rem;
}
.tv-hero .art-backdrop {
  width: 34rem;
  height: 19rem;
  border-radius: 14px;
  flex: 0 0 auto;
}
.tv-hero-copy h1 { font-size: 2.6rem; margin: 0 0 0.6rem; }
.tv-title-actions { margin-bottom: 2rem; }
.tv-btn {
  font-size: 1.3rem;
  font-weight: 600;
  padding: 0.8em 2.4em;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: var(--accent-contrast);
  cursor: pointer;
}
.tv-btn:disabled { opacity: 0.45; cursor: default; }
.tv-ep {
  position: relative;
  flex: 0 0 auto;
  width: 17rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  text-align: left;
  padding: 1rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.tv-ep-off { opacity: 0.45; cursor: default; }
.tv-ep-num { font-size: 0.85rem; color: var(--accent); font-weight: 600; }
.tv-ep-name { font-size: 1.05rem; }
.tv-ep-meta { font-size: 0.85rem; }

/* player + OSD */
.tv-player {
  position: fixed;
  inset: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Kill engine-drawn transport UI — Tizen/webOS/Android WebView render
   native controls inside the video shadow root regardless of the
   controls attribute once the element gets focus or media keys. Our OSD
   is the only control layer. */
.tv-video::-webkit-media-controls,
.tv-video::-webkit-media-controls-enclosure,
.tv-video::-webkit-media-controls-panel,
.tv-video::-webkit-media-controls-overlay-enclosure,
.tv-video::-webkit-media-controls-overlay-play-button,
.tv-video::-webkit-media-controls-start-playback-button {
  display: none !important;
}
.tv-player-error {
  flex-direction: column;
  gap: 1rem;
}
.tv-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.tv-osd {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 2.5rem 4rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
  transition: opacity 0.3s ease;
}
.tv-osd-hidden { opacity: 0; pointer-events: none; }
.tv-osd-title { font-size: 1.3rem; font-weight: 600; margin: 0 0 1rem; }
.tv-osd-bar {
  display: flex;
  align-items: center;
  gap: 1.2rem;
}
.tv-osd-time { font-feature-settings: "tnum"; font-variant-numeric: tabular-nums; font-size: 1rem; }
.tv-seekbar {
  flex: 1 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  overflow: hidden;
}
.tv-seekbar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  /* timeupdate fires at ~4Hz on most engines — a short linear ease turns
     the stepped ticks into a smooth sweep. */
  transition: width 200ms linear;
}
.tv-osd-hint { font-size: 0.9rem; margin: 0.8rem 0 0; }

/* ---------- buffering / stream health ---------- */
.spinner {
  width: 1.4em;
  height: 1.4em;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.player-wrap { position: relative; }
.player-buffering {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 0.95rem;
  pointer-events: none; /* never block the native controls */
}

.tv-buffering {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  font-size: 1.3rem;
  pointer-events: none;
}
.tv-buffering .spinner { width: 3rem; height: 3rem; border-width: 5px; }

/* buffered amount — lighter strip behind the played fill */
.tv-seekbar { position: relative; }
.tv-seekbar-buffered {
  position: absolute;
  inset: 0 auto 0 0;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 4px;
}
.tv-seekbar-fill { position: relative; }

/* ---------- custom player UI ---------- */
.player-custom {
  position: relative;
  -moz-user-select: none;
       user-select: none;
  -webkit-user-select: none;
}
.player-custom .player { cursor: pointer; }
.player-idle { cursor: none; }
.player-idle .player { cursor: none; }
.player-custom:-webkit-full-screen {
  display: flex;
  align-items: center;
  border-radius: 0;
}
.player-custom:fullscreen,
.player-custom:-webkit-full-screen {
  display: flex;
  align-items: center;
  border-radius: 0;
}
.player-custom:-webkit-full-screen .player {
  aspect-ratio: auto;
  height: 100%;
  object-fit: contain;
}
.player-custom:fullscreen .player,
.player-custom:-webkit-full-screen .player {
  aspect-ratio: auto;
  height: 100%;
  object-fit: contain;
}

/* Persistent center play affordance while paused — frosted circle,
   the Plex/Apple paused-state pattern. */
.player-center-play {
  position: absolute;
  inset: 0;
  z-index: 2;
  margin: auto;
  width: 84px;
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  background: rgba(12, 15, 22, 0.55);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition:
    transform var(--dur-fast),
    background var(--dur-fast);
}
.player-center-play:hover {
  transform: scale(1.07);
  background: rgba(12, 15, 22, 0.75);
}
.player-center-play svg {
  margin-left: 4px; /* optical centering for the play triangle */
}

/* center flash feedback (play/pause/seek) */
.player-flash {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  color: #fff;
  animation: player-flash 0.5s ease forwards;
}
.player-flash svg {
  filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.7));
  background: rgba(0, 0, 0, 0.45);
  border-radius: 50%;
  padding: 14px;
  width: 64px;
  height: 64px;
}
@keyframes player-flash {
  from { opacity: 0.9; transform: scale(1); }
  to { opacity: 0; transform: scale(1.25); }
}

/* bottom control bar */
.player-ui {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3; /* above the <video> layer — some browsers composite it */
  padding: 0 14px 10px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.player-ui-hidden {
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
}

/* Top scrim — Apple-player-style "now watching" context, mirrored with
   the bottom chrome's auto-hide. */
.player-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 20px 44px;
  background: linear-gradient(rgba(0, 0, 0, 0.68), transparent);
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
  pointer-events: none;
}
/* Circular glass close affordance — pinned to the top-right corner;
   the only clickable piece of the top scrim. */
.player-back {
  position: absolute;
  top: 16px;
  right: 18px;
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(12, 15, 22, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition:
    background var(--dur-fast),
    transform var(--dur-fast);
}
.player-back:hover {
  background: rgba(12, 15, 22, 0.75);
  transform: scale(1.06);
}

/* Up-next countdown card — Plex-style bottom-right auto-advance. */
.upnext {
  position: absolute;
  right: 20px;
  bottom: 96px;
  z-index: 4;
  width: min(320px, 80%);
  padding: 16px 18px 14px;
  border-radius: var(--r-md);
  background: rgba(15, 18, 25, 0.92);
  border: 1px solid var(--border-strong);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-2);
}
.upnext-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}
.upnext-title {
  display: block;
  font-size: 15px;
  color: #fff;
  margin-bottom: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.upnext-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}
.upnext-play {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}
.upnext-play:hover {
  color: var(--accent-hover);
}
.upnext-stay {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}
.upnext-stay:hover {
  color: var(--text);
}
.upnext-bar {
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.16);
  margin-top: 12px;
  overflow: hidden;
}
.upnext-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 1s linear;
}
.player-top.player-ui-hidden {
  transform: translateY(-6px);
}
.player-top-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1;
  min-width: 0;
  max-width: 70%;
  /* clear the corner ✕ button */
  padding-right: 52px;
}
.player-eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
}
.player-headline {
  font-size: clamp(18px, 2.4vw, 26px);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-top-meta {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
}

/* Series episode panel on the watch page — same tile rows as the
   title page, grouped per season with a current-episode highlight. */
.ep-season + .ep-season {
  margin-top: 22px;
}
.ep-season-name {
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0 0 8px;
}
.ep-current {
  background: var(--surface);
  box-shadow: inset 3px 0 0 var(--accent);
}
.ep-now {
  position: absolute;
  right: 8px;
  bottom: 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 30%, rgba(0, 0, 0, 0.75));
  color: var(--accent-hover);
}

/* seekbar */
.player-seek {
  position: relative;
  height: 18px;
  display: flex;
  align-items: center;
  cursor: pointer;
}
.player-seek::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.22);
  transition: height 0.12s ease;
}
.player-seek:hover::before { height: 7px; }
.player-seek-buffered,
.player-seek-fill {
  position: absolute;
  left: 0;
  height: 4px;
  border-radius: 2px;
  transition: height 0.12s ease;
}
.player-seek:hover .player-seek-buffered,
.player-seek:hover .player-seek-fill { height: 7px; }
.player-seek-buffered { background: rgba(255, 255, 255, 0.35); }
.player-seek-fill { background: var(--accent); }
.player-seek-fill::after {
  /* scrub head */
  content: "";
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%) scale(0);
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform 0.12s ease;
}
.player-seek:hover .player-seek-fill::after { transform: translateY(-50%) scale(1); }
.player-seek-tip {
  position: absolute;
  bottom: 22px;
  transform: translateX(-50%);
  background: rgba(10, 12, 18, 0.92);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  white-space: nowrap;
}

/* button row */
.player-bar {
  display: flex;
  align-items: center;
  gap: 4px;
}
.player-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.player-btn:hover { background: rgba(255, 255, 255, 0.12); }
.player-btn:disabled { opacity: 0.4; cursor: default; }
.player-btn svg {
  color: #fff;
  stroke: currentColor;
  fill: none;
  flex: none;
}
.player-btn-on { color: var(--accent); }
.player-btn-on svg { color: var(--accent); }

/* Plex-style volume cluster — icon always visible, slider slides open
   on hover/focus. Custom track: accent-filled up to --vol, dim white
   beyond, round white thumb. */
.player-vol {
  display: inline-flex;
  align-items: center;
}
.player-volume {
  -webkit-appearance: none;
  -moz-appearance: none;
       appearance: none;
  width: 0;
  opacity: 0;
  overflow: hidden;
  /* Match .player-btn height — engines center the track in the box, so
     the slider's centerline lands exactly on the buttons' centerline.
     translateY nudges it onto the row's optical center. */
  align-self: stretch;
  transform: translateY(6px);
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  transition:
    width var(--dur-fast),
    opacity var(--dur-fast);
}
.player-volume::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(
    90deg,
    var(--accent) var(--vol, 100%),
    rgba(255, 255, 255, 0.3) var(--vol, 100%)
  );
}
.player-volume::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -4.5px; /* center thumb on the 4px track */
  border: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
  -webkit-transition: transform var(--dur-fast);
  transition: transform var(--dur-fast);
}
.player-volume::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.3);
}
.player-volume::-moz-range-progress {
  height: 4px;
  border-radius: 2px;
  background: var(--accent);
}
.player-volume::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
}
.player-vol:hover .player-volume::-webkit-slider-thumb,
.player-volume:focus-visible::-webkit-slider-thumb {
  transform: scale(1.2);
}
.player-vol:hover .player-volume,
.player-vol:focus-within .player-volume {
  width: 88px;
  opacity: 1;
  /* let the range thumb reach the true 0% / 100% edges — hidden overflow
     clips it halfway at the extremes */
  overflow: visible;
}
.player-time {
  font-size: 13px;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  margin-left: 8px;
  white-space: nowrap;
  /* Same nudge as .player-volume — keeps the time on the slider's line. */
  transform: translateY(6px);
}
.player-remaining {
  color: var(--text-faint);
}
.player-spacer { flex: 1 1; }
.player-title {
  font-size: 13px;
  max-width: 40%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 8px;
}

/* subtitle menu */
.player-cc { position: relative; }
.player-cc-menu {
  position: absolute;
  right: 0;
  bottom: 44px;
  min-width: 160px;
  background: rgba(15, 18, 25, 0.97);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  z-index: 5;
}
.player-cc-menu button {
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
}
.player-cc-menu button:hover { background: rgba(255, 255, 255, 0.1); }
.player-cc-menu .player-cc-active { color: var(--accent); font-weight: 600; }
.player-cc-head {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 6px 12px 4px;
}

@media (max-width: 640px) {
  .player-volume, .player-remaining { display: none; }
  .player-title { display: none; }
  .player-top-info { max-width: 100%; }
  .player-headline { font-size: 16px; }
}

/* Landscape phones / short fullscreen viewports: menus must scroll
   instead of overflowing above the visible area. */
@media (max-height: 520px) {
  .player-cc-menu {
    max-height: calc(100vh - 72px);
    overflow-y: auto;
  }
}

/* Touch devices: bigger hit targets, persistent scrub head, no
   double-tap-zoom delay — hover-expansion doesn't exist on touch. */
@media (pointer: coarse) {
  .player-btn { width: 44px; height: 44px; }
  .player-seek {
    height: 26px;
    touch-action: none;
  }
  .player-seek::before { height: 5px; }
  .player-seek-buffered,
  .player-seek-fill { height: 5px; }
  .player-seek-fill::after {
    transform: translateY(-50%) scale(1);
  }
  .player-cc-menu button {
    min-height: 44px;
    display: flex;
    align-items: center;
    font-size: 15px;
  }
  .menu-pop a,
  .menu-pop button { min-height: 44px; }
  .player,
  .player-btn,
  .player-back,
  .player-center-play,
  .upnext a,
  .upnext button,
  .player-cc-menu button {
    touch-action: manipulation;
  }
}

/* Fullscreen on notched phones: keep chrome inside the safe area —
   landscape sensors otherwise overlap the corners. */
.player-custom:-webkit-full-screen .player-top {
  padding-top: calc(18px + var(--safe-t));
  padding-left: calc(20px + var(--safe-l));
  padding-right: calc(20px + var(--safe-r));
}
.player-custom:fullscreen .player-top,
.player-custom:-webkit-full-screen .player-top {
  padding-top: calc(18px + var(--safe-t));
  padding-left: calc(20px + var(--safe-l));
  padding-right: calc(20px + var(--safe-r));
}
.player-custom:-webkit-full-screen .player-back {
  top: calc(16px + var(--safe-t));
  right: calc(18px + var(--safe-r));
}
.player-custom:fullscreen .player-back,
.player-custom:-webkit-full-screen .player-back {
  top: calc(16px + var(--safe-t));
  right: calc(18px + var(--safe-r));
}
.player-custom:-webkit-full-screen .player-ui {
  padding-left: calc(14px + var(--safe-l));
  padding-right: calc(14px + var(--safe-r));
  padding-bottom: calc(10px + var(--safe-b));
}
.player-custom:fullscreen .player-ui,
.player-custom:-webkit-full-screen .player-ui {
  padding-left: calc(14px + var(--safe-l));
  padding-right: calc(14px + var(--safe-r));
  padding-bottom: calc(10px + var(--safe-b));
}
.player-custom:-webkit-full-screen .upnext, .player-custom:-webkit-full-screen .player-pill {
  right: calc(20px + var(--safe-r));
  bottom: calc(96px + var(--safe-b));
}
.player-custom:fullscreen .upnext,
.player-custom:-webkit-full-screen .upnext,
.player-custom:fullscreen .player-pill,
.player-custom:-webkit-full-screen .player-pill {
  right: calc(20px + var(--safe-r));
  bottom: calc(96px + var(--safe-b));
}

/* Floating episode pills — skip intro / next episode, bottom-right
   above the control bar (Netflix/Plex affordance). */
.player-pill {
  position: absolute;
  right: 20px;
  bottom: 96px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(12, 15, 22, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition:
    background var(--dur-fast),
    color var(--dur-fast),
    transform var(--dur-fast);
}
.player-pill:hover {
  background: rgba(255, 255, 255, 0.92);
  color: #0c0f16;
  transform: translateY(-1px);
}

/* In-app mini player — video element is DOM-moved into .mini-player-slot
   so playback survives navigation (YouTube-style continue-while-browsing). */
.mini-player {
  display: none;
  position: fixed;
  right: calc(16px + var(--safe-r));
  bottom: calc(16px + var(--safe-b));
  z-index: 70;
  width: min(340px, 42vw);
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-2);
  /* Draggable — pointer capture handles the move, so the page must not
     scroll underneath the gesture on touch devices. */
  touch-action: none;
}
.mini-player.show { display: block; }
/* Title/swap/close chrome overlays the top of the video and only
   appears on hover/focus — touch devices keep it always visible. */
.mini-player-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 20px 10px;
  background: linear-gradient(rgba(8, 10, 15, 0.85), transparent);
  cursor: -webkit-grab;
  cursor: grab;
  opacity: 0;
  transform: translateY(-4px);
  transition:
    opacity var(--dur-fast),
    transform var(--dur-fast);
}
.mini-player-bar:active { cursor: -webkit-grabbing; cursor: grabbing; }
.mini-player:hover .mini-player-bar,
.mini-player:focus-within .mini-player-bar {
  opacity: 1;
  transform: none;
}
@media (hover: none) {
  .mini-player-bar {
    opacity: 1;
    transform: none;
  }
}
.mini-player-swap {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
  cursor: pointer;
}
.mini-player-swap:hover {
  background: var(--accent);
  color: var(--accent-contrast, #0b0e14);
}
.mini-player-title {
  flex: 1 1;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  padding: 2px 0;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.mini-player-title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mini-player-title:hover { color: var(--accent); }
.mini-player-close {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.mini-player-close:hover {
  background: var(--hover);
  color: var(--text);
}
.mini-player-slot video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  background: #000;
}
@media (max-width: 900px) {
  .mini-player {
    /* clear the fixed mobile nav */
    bottom: calc(72px + var(--safe-b));
    width: min(300px, 48vw);
  }
}

/* --- Dynamic media theme ----------------------------------------------- */
/* Brief, one-shot color interpolation while DynamicThemeProvider swaps the
   :root tokens on a deliberate context change (page/title/genre open).
   Scoped to the data attribute — the attribute is only present while a
   transition is active, and never under prefers-reduced-motion. */
html[data-theme-transition="on"] body,
html[data-theme-transition="on"] body * {
  transition:
    background-color 0.35s ease,
    color 0.35s ease,
    border-color 0.35s ease,
    fill 0.35s ease,
    stroke 0.35s ease;
}

@media (prefers-reduced-motion: reduce) {
  html[data-theme-transition="on"] body,
  html[data-theme-transition="on"] body * {
    transition: none;
  }
}

