:root {
  --bg: #0f1115;
  --bg-soft: #171a21;
  --bg-card: #1c2028;
  --bg-hover: #242933;
  --border: #2a2f3a;
  --text: #f2f3f5;
  --text-dim: #9aa1ad;
  --text-faint: #6b7280;
  --accent: #e50914;
  --accent-hover: #ff2230;
  --accent-soft: rgba(229, 9, 20, 0.15);
  --green: #2ea043;
  --gold: #f5b301;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  --topbar-h: 60px;
  --statsbar-h: 30px;
  --mobilenav-h: 58px;
  --maxw: 1280px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* The hidden attribute must always win over display-based classes (e.g. modal overlay). */
[hidden] { display: none !important; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img { display: block; }
button { font: inherit; cursor: pointer; }
input { font: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #333a47; border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- splash ---------- */
.splash {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: radial-gradient(1200px 600px at 50% -10%, #2a0d10, var(--bg));
}
.splash-logo { font-size: 34px; font-weight: 800; letter-spacing: 4px; }
.splash-logo span { color: var(--accent); }
.splash-sub { color: var(--text-faint); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: var(--statsbar-h);
  z-index: 50;
  background: rgba(15, 17, 21, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
}
.brand { font-weight: 800; letter-spacing: 1px; font-size: 18px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--accent); color: #fff; font-size: 11px;
}
.topnav { display: flex; gap: 6px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a {
  padding: 8px 14px; border-radius: 20px; color: var(--text-dim);
  font-weight: 600; font-size: 14px; white-space: nowrap; transition: all 0.15s;
}
.topnav a:hover { color: var(--text); background: var(--bg-hover); }
.topnav a.active { color: #fff; background: var(--accent); }
/* Nav icons only appear in the mobile bottom bar. */
.topnav .nav-ic { display: none; }
.nav-ic { width: 22px; height: 22px; }
.nav-ic svg { width: 100%; height: 100%; display: block; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

/* Section switcher - the Drama/Movie dropdown in the topbar. */
.section-switch {
  background: var(--bg-card); color: var(--text);
  border: 1px solid var(--border); border-radius: 20px;
  padding: 6px 12px; font-size: 13px; font-weight: 700; cursor: pointer;
  font-family: inherit; outline: none; white-space: nowrap;
}
.section-switch:hover { border-color: var(--text-faint); }
.section-switch:focus { border-color: var(--accent); }
.badge {
  font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 20px;
  background: var(--accent-soft); color: var(--accent-hover); border: 1px solid var(--accent);
  letter-spacing: 0.5px; text-transform: uppercase; white-space: nowrap;
}
.badge.live {
  background: rgba(46, 160, 67, 0.12); color: var(--green); border-color: var(--green);
  animation: live-glow 2s ease-in-out infinite;
}
.badge.live::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); margin-right: 6px; vertical-align: middle;
  animation: live-pulse 1.2s ease-in-out infinite;
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.7); }
}
@keyframes live-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(46, 160, 67, 0); }
  50% { box-shadow: 0 0 12px 2px rgba(46, 160, 67, 0.5); }
}

/* ---------- layout ---------- */
#main { max-width: var(--maxw); margin: 0 auto; padding: 24px 20px 60px; }
.page { animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-title { font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.page-sub { color: var(--text-dim); font-size: 14px; margin-bottom: 20px; }

/* ---------- hero ---------- */
.hero {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: var(--bg-soft);
  min-height: 340px;
  display: flex;
  align-items: flex-end;
  margin-bottom: 28px;
  box-shadow: var(--shadow);
  transition: opacity 0.3s ease;
}
.hero-fade { opacity: 0; }
.hero-bg { position: absolute; inset: 0; background-size: cover; background-position: center 30%; transform: scale(1.02); }
.hero-bg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(15,17,21,0.15) 0%, rgba(15,17,21,0.55) 55%, var(--bg) 100%); }
.hero-body { position: relative; padding: 28px; max-width: 640px; z-index: 1; }
.hero-title { font-size: 34px; font-weight: 900; line-height: 1.15; margin-bottom: 8px; text-shadow: 0 2px 12px rgba(0,0,0,0.6); }
.hero-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; font-size: 13px; color: var(--text-dim); }
.hero-intro {
  font-size: 14px; color: #d5d9e0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  margin-bottom: 18px;
}
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 22px; border-radius: 24px; border: none;
  font-weight: 700; font-size: 14px; transition: all 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: rgba(255,255,255,0.12); color: #fff; }
.btn-ghost:hover { background: rgba(255,255,255,0.2); }
.btn-sm { padding: 7px 14px; font-size: 13px; }

/* ---------- rows ---------- */
.row { margin-bottom: 32px; }
.row-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.row-title { font-size: 19px; font-weight: 800; }
.row-more { color: var(--text-faint); font-size: 13px; font-weight: 600; white-space: nowrap; }
.row-more:hover { color: var(--accent-hover); }
.hscroll {
  display: flex; gap: 16px; overflow-x: auto; padding: 4px 2px 12px;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
}
.hscroll::-webkit-scrollbar { height: 6px; }
.hscroll .drama-card { flex: 0 0 150px; scroll-snap-align: start; }

/* ---------- drama card ---------- */
.drama-card { display: block; transition: transform 0.15s; }
.drama-card:hover { transform: translateY(-3px); }
.card-poster {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}
.card-poster img { width: 100%; height: 100%; object-fit: cover; }
.card-poster img.placeholder {
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint); font-size: 12px; text-transform: uppercase; letter-spacing: 1px;
}
.card-badge {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,0.65); color: var(--gold);
  font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 6px;
}
.card-badge.charge { background: var(--accent); color: #fff; }
.card-title {
  margin-top: 8px; font-size: 13.5px; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 35px;
}
.card-meta { color: var(--text-faint); font-size: 12px; margin-top: 2px; }

/* ---------- grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 18px 14px;
}
@media (min-width: 900px) { .grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); } }
.load-more { display: block; margin: 24px auto 0; }
.spinner {
  width: 34px; height: 34px; margin: 40px auto;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; color: var(--text-faint); padding: 60px 20px; }
.empty-state .big { font-size: 42px; margin-bottom: 12px; }

/* ---------- detail ---------- */
.detail-hero { display: flex; gap: 26px; margin-bottom: 30px; flex-wrap: wrap; }
.detail-poster { width: 210px; aspect-ratio: 3/4; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); flex-shrink: 0; }
.detail-poster img { width: 100%; height: 100%; object-fit: cover; }
.detail-info { flex: 1; min-width: 260px; }
.detail-title { font-size: 28px; font-weight: 900; margin-bottom: 6px; }
.detail-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { background: var(--bg-card); border: 1px solid var(--border); border-radius: 20px; padding: 3px 12px; font-size: 12px; color: var(--text-dim); }
.detail-stats { color: var(--text-faint); font-size: 13px; margin-bottom: 14px; display: flex; gap: 14px; flex-wrap: wrap; }
.detail-stats .meta-label { color: var(--text-dim); font-weight: 700; margin-right: 5px; }
.detail-desc { color: #cfd4dc; font-size: 14px; max-width: 720px; margin-bottom: 18px; }
.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.section-title { font-size: 18px; font-weight: 800; margin: 26px 0 14px; display: flex; align-items: center; gap: 8px; }
.section-title .count { color: var(--text-faint); font-size: 13px; font-weight: 600; }

/* ---------- seasons (movie) ---------- */
.season-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.season-tab {
  padding: 8px 16px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-dim); font-weight: 700; font-size: 13px;
}
.season-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.res-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.res-chip { padding: 5px 12px; border-radius: 16px; border: 1px solid var(--border); background: var(--bg-soft); color: var(--text-dim); font-size: 12px; font-weight: 600; cursor: pointer; }
.res-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.episode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}
@media (max-width: 600px) { .episode-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); } }
.ep {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 6px; border-radius: var(--radius-sm);
  background: var(--bg-card); border: 1px solid var(--border);
  transition: all 0.15s;
}
.ep:hover { background: var(--bg-hover); transform: translateY(-2px); }
.ep.ep-current { border-color: var(--accent); background: var(--accent-soft); }
.ep-num { font-weight: 800; font-size: 15px; }
.ep-lock { font-size: 12px; color: var(--gold); }
.ep:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

/* ---------- search ---------- */
.search-bar { display: flex; gap: 10px; margin-bottom: 24px; }
.search-input {
  flex: 1; padding: 13px 18px; border-radius: 24px;
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--text);
  outline: none; transition: border 0.15s;
}
.search-input:focus { border-color: var(--accent); }
.search-btn { border-radius: 24px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip.hot { background: var(--accent-soft); border-color: var(--accent); color: #ff8f96; font-weight: 600; cursor: pointer; }
.chip.hot:hover { background: var(--accent); color: #fff; }

/* ---------- player page ---------- */
.player-wrap { max-width: 1000px; margin: 0 auto; }
.player-shell {
  position: relative; background: #000; border-radius: 14px; overflow: hidden;
  aspect-ratio: 16/9; box-shadow: var(--shadow);
}
.player-shell video { width: 100%; height: 100%; display: block; background: #000; cursor: pointer; }
.player-topbar {
  position: absolute; left: 0; right: 0; top: 0; z-index: 3;
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.65), transparent);
}
.ep-picker { position: relative; max-width: 60%; min-width: 0; flex: 1; display: flex; }
.ep-picker-btn {
  flex: 1; min-width: 0; max-width: 100%;
  background: rgba(0,0,0,0.65); color: #fff; border: 1px solid rgba(255,255,255,0.3);
  border-radius: 8px; padding: 6px 8px; font-size: 12px; font-weight: 600;
  cursor: pointer; text-align: left; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; font-family: inherit;
}
.ep-picker-btn:hover { background: rgba(0,0,0,0.8); }
.ep-picker-menu {
  position: fixed; z-index: 999; max-height: 320px; overflow-y: auto;
  background: rgba(0, 0, 0, 0.72); border: 1px solid rgba(255,255,255,0.25);
  border-radius: 10px; padding: 4px; box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.ep-picker-menu::-webkit-scrollbar { width: 8px; }
.ep-picker-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.25); border-radius: 4px; }
.ep-picker-opt {
  display: block; width: 100%; text-align: left; box-sizing: border-box;
  background: transparent; color: #fff; border: none; border-radius: 6px;
  padding: 8px 10px; font-size: 13px; font-weight: 500; cursor: pointer;
  font-family: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ep-picker-opt:hover { background: var(--accent); color: #fff; }
.ep-picker-opt.ep-current { background: rgba(229,9,20,0.28); color: #fff; }

/* ---------- subtitle settings menu + overlay (movie) ---------- */
.sub-menu {
  position: fixed; z-index: 999; min-width: 180px; max-height: min(400px, 80vh); overflow-y: auto;
  background: rgba(0, 0, 0, 0.85); border: 1px solid rgba(255,255,255,0.25);
  border-radius: 10px; padding: 6px; box-shadow: 0 8px 24px rgba(0,0,0,0.65);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
.sub-menu::-webkit-scrollbar { width: 6px; }
.sub-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.3); border-radius: 3px; }

/* Hide native cues completely so our custom DOM overlay applies CC styling cleanly */
::cue, video::cue, ::cue(*) {
  color: transparent !important;
  background: transparent !important;
  background-color: transparent !important;
  text-shadow: none !important;
  opacity: 0 !important;
  font-size: 0px !important;
  line-height: 0 !important;
}
.sub-opt {
  display: block; width: 100%; text-align: left; box-sizing: border-box;
  background: transparent; color: #fff; border: none; border-radius: 6px;
  padding: 8px 10px; font-size: 13px; font-weight: 500; cursor: pointer;
  font-family: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sub-opt:hover { background: var(--accent); color: #fff; }
.sub-opt.sub-current { background: rgba(229,9,20,0.28); color: #fff; }
.sub-section {
  font-size: 11px; color: #9aa1ad; text-transform: uppercase; letter-spacing: 1px;
  padding: 10px 10px 2px; font-weight: 700;
}
.sub-hr { border: none; border-top: 1px solid rgba(255,255,255,0.15); margin: 6px 6px; }
.sub-color-row { display: flex; gap: 8px; align-items: center; padding: 6px 10px; }
.sub-swatch {
  width: 24px; height: 24px; border-radius: 50%; padding: 0; flex: none;
  border: 2px solid transparent; cursor: pointer; transition: transform 0.12s;
}
.sub-swatch:hover { transform: scale(1.15); }
.sub-swatch.sub-current { border-color: #fff; box-shadow: 0 0 0 2px rgba(0,0,0,0.6); }
.sub-swatch-custom {
  width: 28px; height: 28px; border: none; border-radius: 6px; padding: 0;
  background: none; cursor: pointer;
}
.sub-size-row, .sub-pos-row { display: flex; gap: 6px; padding: 6px 10px; }
.sub-size-btn, .sub-pos-btn {
  flex: 1; padding: 7px 0; border-radius: 8px; border: 1px solid rgba(255,255,255,0.25);
  background: transparent; color: #fff; font-size: 12px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.sub-size-btn:hover, .sub-pos-btn:hover { background: rgba(255,255,255,0.12); }
.sub-size-btn.sub-current, .sub-pos-btn.sub-current { background: var(--accent); border-color: var(--accent); color: #fff; }
/* Free subtitle placement slider (CC menu) */
.sub-pos-slider-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.sub-pos-slider { flex: 1; accent-color: var(--accent); height: 22px; background: transparent; }
.sub-pos-pct { font-size: 11px; color: #cfcfe0; min-width: 36px; text-align: right; font-variant-numeric: tabular-nums; }

/* volume boost menu (playback > 100%) */
.vol-menu { min-width: 200px; }
.vol-menu .vol-slider { width: calc(100% - 28px); margin: 8px 14px 4px; accent-color: var(--accent); }
.vol-menu .vol-row { display: flex; flex-wrap: wrap; gap: 4px; padding: 2px 8px 8px; }
.vol-menu .vol-row .sub-opt { padding: 6px 8px; font-size: 12px; text-align: center; }

/* back button row on Details pages */
.detail-back-row { margin: 0 0 12px; }

/* custom subtitle overlay (SRT rendered by the player engine) */
.sub-overlay {
  position: absolute; left: 5%; right: 5%; z-index: 2;
  text-align: center; color: #fff;
  font-size: 16px; font-weight: 600; line-height: 1.45;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95), 0 0 2px rgba(0, 0, 0, 0.85);
  white-space: pre-line; pointer-events: none;
  padding: 0 8px;
}
/* fullscreen episode controls (Narto/Dracin, Direct + iFrame).
 * Lives inside .player-frame so it rides along when the frame goes
 * fullscreen (native video fullscreen cannot paint HTML). Shown only in
 * fullscreen to stay out of the way otherwise. */
.player-frame { position: relative; }
.fs-nav {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  z-index: 30; display: none; gap: 8px; pointer-events: none;
}
.player-frame.is-fs .fs-nav { display: flex; }
.fs-nav button {
  pointer-events: auto; background: rgba(0,0,0,0.65); color: #fff;
  border: 1px solid rgba(255,255,255,0.35); border-radius: 8px;
  padding: 6px 12px; font-size: 13px; font-weight: 700; cursor: pointer;
  font-family: inherit; white-space: nowrap;
}
.fs-nav button:disabled { opacity: 0.35; cursor: default; }
.fs-nav button:not(:disabled):hover { background: rgba(229,9,20,0.85); }
.ov-ctl {
  background: rgba(0,0,0,0.65); color: #fff; border: 1px solid rgba(255,255,255,0.3);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.ov-ctl.icon {
  width: 34px; height: 34px; padding: 0; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; line-height: 1;
}
.ov-ctl:disabled { opacity: 0.4; cursor: not-allowed; }
.ov-ctl:hover { background: var(--accent); border-color: var(--accent); }
/* Exit-fullscreen rides the overlay bar but only exists in fullscreen —
 * mobile browsers have no Esc key. */
#btn-exit-fs { display: none; }
.player-shell:fullscreen #btn-exit-fs { display: inline-flex; }
.ov-ctl.active { background: var(--accent); border-color: var(--accent); }
.player-shell:fullscreen {
  width: 100vw; height: 100vh; border-radius: 0; aspect-ratio: auto;
}
.player-shell:fullscreen .player-topbar { padding-top: max(10px, env(safe-area-inset-top)); }
.player-shell:fullscreen .player-progress { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
/* Seek bar — three layers:
   light gray track = portion still downloading,
   gray = completed (downloaded/buffered) portion,
   red = current playback progress. */
.player-progress {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
  height: 5px; background: rgba(255, 255, 255, 0.22);
  cursor: pointer; touch-action: none;
  transition: height 0.15s ease;
}
.player-progress:hover { height: 9px; }
.player-progress .pb-layer {
  position: absolute; top: 0; bottom: 0; left: 0; width: 0;
  pointer-events: none; will-change: width;
}
.player-progress .pb-buffer { background: rgba(255, 255, 255, 0.55); }
.player-progress .pb-played { background: var(--accent, #e50914); }
.player-progress .pb-thumb {
  position: absolute; top: 50%; left: 0; width: 12px; height: 12px;
  transform: translate(-50%, -50%); border-radius: 50%;
  background: var(--accent, #e50914);
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.65);
  opacity: 0; pointer-events: none; transition: opacity 0.15s ease;
}
.player-progress:hover .pb-thumb,
.player-progress.dragging .pb-thumb { opacity: 1; }
.player-progress:focus-visible {
  outline: 2px solid var(--accent, #e50914); outline-offset: 2px;
}
.player-time {
  position: absolute; right: 12px; bottom: 34px; z-index: 4;
  color: #fff; font-size: 12px; font-weight: 600; text-shadow: 0 1px 2px rgba(0,0,0,0.9);
  background: rgba(0,0,0,0.5); border-radius: 8px; padding: 3px 8px;
}
.player-time-sep { opacity: 0.55; margin: 0 3px; }
.player-skip-btn {
  position: absolute; bottom: 18px; right: 18px; z-index: 5;
  background: rgba(0,0,0,0.75); border: 1px solid rgba(255,255,255,0.3);
  color: #fff; padding: 9px 16px; border-radius: 20px; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; gap: 8px;
}
.player-skip-btn:hover { background: var(--accent); border-color: var(--accent); }
.player-controls {
  display: flex; align-items: center; gap: 6px; padding: 12px 14px;
  background: var(--bg-soft); border-radius: 0 0 14px 14px; border: 1px solid var(--border); border-top: none;
  flex-wrap: wrap;
}
.ctl {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-card); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; font-size: 13px; font-weight: 600; transition: all 0.15s;
}
.ctl:hover { background: var(--bg-hover); }
.ctl:disabled { opacity: 0.4; cursor: not-allowed; }
.ctl.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.controls-right { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.player-title { font-size: 20px; font-weight: 800; margin: 18px 0 6px; }
.player-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 18px; }
.ep-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--bg-card); border: 1px solid var(--border); margin-bottom: 8px;
  transition: all 0.15s;
}
.ep-row:hover { background: var(--bg-hover); }
.ep-row.ep-current { border-color: var(--accent); background: var(--accent-soft); }
.ep-row .ep-name { font-weight: 700; }
.ep-row .ep-state { font-size: 12px; color: var(--text-faint); }

/* ---------- my list ---------- */
.mylist-item {
  display: flex; gap: 14px; align-items: center;
  padding: 10px; border-radius: var(--radius); background: var(--bg-card);
  border: 1px solid var(--border); margin-bottom: 10px;
}
.mylist-item .thumb { width: 64px; aspect-ratio: 3/4; border-radius: 6px; overflow: hidden; flex-shrink: 0; }
.mylist-item .thumb img { width: 100%; height: 100%; object-fit: cover; }
.mylist-item .info { flex: 1; min-width: 0; }
.mylist-item .name { font-weight: 700; font-size: 15px; margin-bottom: 2px; }
.mylist-item .meta { font-size: 12.5px; color: var(--text-faint); }
.progress-track { height: 5px; border-radius: 3px; background: var(--border); margin-top: 8px; overflow: hidden; max-width: 320px; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 3px; }
.btn-danger { background: transparent; color: var(--text-faint); border: 1px solid var(--border); }
.btn-danger:hover { color: #ff7a85; border-color: #ff7a85; }
.mylist-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* ---------- auth ---------- */
.auth-user {
  font-size: 13px; font-weight: 700; white-space: nowrap;
  background: linear-gradient(90deg, #ff2d55, #ff8c00, #ffee00, #00c853, #00a0ff, #7b2dff, #ff2d55);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: rgb-flow 4s linear infinite;
}
.auth-user::before { content: "👤 "; -webkit-text-fill-color: initial; color: initial; }
.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-faint); margin: 12px 0 6px; letter-spacing: 0.3px; }
.input {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.08); border: 1px solid var(--border);
  color: var(--text); font-size: 14px;
}
.input:focus { outline: none; border-color: var(--accent); }
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0, 0, 0, 0.62);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  width: min(380px, 100%); background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: 16px; padding: 22px;
  box-shadow: var(--shadow);
}
.modal h3 { font-size: 20px; margin-bottom: 6px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.modal-error, .admin-error { color: #ff7a85; font-size: 13px; margin-top: 10px; }

/* ---------- player login gate ---------- */
.player-gate {
  width: 100%; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  background: #000; color: #fff; text-align: center; padding: 24px;
}
.gate-lock { font-size: 42px; }
.gate-title { font-size: 18px; font-weight: 800; letter-spacing: 0.5px; }
.gate-sub { color: var(--text-faint); font-size: 13px; }

/* ---------- admin console ---------- */
.admin-toolbar { margin-bottom: 16px; }
.admin-form { max-width: 440px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #262c36; color: #fff; padding: 12px 22px; border-radius: 24px;
  font-weight: 600; font-size: 14px; box-shadow: var(--shadow); z-index: 100;
  animation: fadeIn 0.2s ease;
}

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--border); padding: 18px 20px; text-align: center;
  color: var(--text-faint); font-size: 12.5px; display: flex; justify-content: center; gap: 18px; flex-wrap: wrap;
}
.site-footer span {
  font-weight: 700;
  background: linear-gradient(90deg, #ff2d55, #ff8c00, #ffee00, #00c853, #00a0ff, #7b2dff, #ff2d55);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: rgb-flow 4s linear infinite;
}
@keyframes rgb-flow { to { background-position: 200% center; } }

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .brand { font-size: 15px; }
  .topbar-inner { gap: 12px; padding: 0 12px; }
  .hero { min-height: 260px; }
  .hero-title { font-size: 24px; }
  .hero-body { padding: 20px; }
  #main { padding: 16px 12px 40px; }
  .detail-hero { flex-direction: column; align-items: stretch; }
  .detail-poster { width: 100%; max-width: 220px; margin: 0 auto; }
  .detail-title { font-size: 22px; }
  .hscroll .drama-card { flex: 0 0 124px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 14px 10px; }
  .player-controls { gap: 4px; padding: 10px; }
  .ctl { padding: 7px 10px; font-size: 12px; }
}

/* ---------- Narto/Dracin: health chips + slim header ---------------------- */
.stats-dead { color: #ff8a80; font-size: 12px; font-weight: 600; white-space: nowrap; }
/* Playback-mode toggle lives in the player controls (next to CC/Reload), not
   in the top header; red source badge hidden — cleaner on mobile and desktop. */
.nd-topbar #nd-playback-mode { display: none; }
.nd-topbar #nd-source-badge { display: none; }
.player-controls .nd-mode-clone { display: inline-block; }

/* ---------- mobile header + bottom navigation (phones only) ---------- */
@media (max-width: 640px) {
  /* Header: transparent, floats over the page/hero instead of stacking above it.
     (blur lives on the ::before layer — putting backdrop-filter on .topbar
     itself would become the containing block for the fixed bottom nav.) */
  .topbar {
    position: sticky;
    top: var(--statsbar-h);
    left: 0;
    right: 0;
    background: transparent;
    border-bottom: none;
    /* MUST be reset here: any filter/backdrop-filter on .topbar turns it into
       the containing block for the fixed bottom nav and drags it to the top.
       (position:sticky itself is safe — only filters/transforms break it.)
       The blur lives safely on the ::before layer below. */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  /* Frosted scrim behind the header content: rgba(0,0,0,.8) at the top
     fading to a light frosted tint by ~30% of the header height, + blur. */
  .topbar::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8) 0%, rgba(15, 17, 21, 0.55) 30%);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    pointer-events: none;
  }
  .topbar-inner { position: relative; z-index: 1; }
  /* .topnav leaves the flow on mobile (fixed bottom bar), so without this the
     auth/section/logout controls huddle next to the brand instead of the right edge. */
  .topbar-right { margin-left: auto; }
  /* Narrow phones: let the control group wrap to a right-aligned second row
     instead of clipping the Logout/Admin buttons. */
  .topbar-inner { flex-wrap: wrap; height: auto; min-height: var(--topbar-h); row-gap: 2px; }
  .topbar-right { flex-wrap: wrap; justify-content: flex-end; row-gap: 4px; max-width: 100%; }
  .brand { color: #fff; }
  .auth-user { max-width: 92px; overflow: hidden; text-overflow: ellipsis; }

  /* Header keeps its place in the layout; only the home hero slides up
     underneath the floating transparent header. */
  .page > .hero:first-child { margin-top: calc(-1 * var(--topbar-h)); }

  /* Navigation becomes a fixed flat-black bottom tab bar. */
  .topnav {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    flex: none;
    gap: 0;
    justify-content: space-around;
    overflow: visible;
    background: #000;
    border-top: none;
    padding: 5px 0 calc(5px + env(safe-area-inset-bottom));
    z-index: 90;
  }
  .topnav a {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 5px 4px;
    border-radius: 0;
    background: none;
    color: var(--text-dim);
    font-size: 11px;
  }
  .topnav a:hover { background: none; color: var(--text-dim); }
  .topnav a.active { background: none; color: #fff; }
  .topnav .nav-ic { display: block; }

  /* Keep the footer and toasts clear of the bottom bar. */
  .site-footer { padding-bottom: calc(var(--mobilenav-h) + env(safe-area-inset-bottom) + 16px); }
  .toast { bottom: calc(var(--mobilenav-h) + env(safe-area-inset-bottom) + 16px); }
}

/* Very narrow phones: username chip is dropped so Admin/Logout always fit. */
@media (max-width: 480px) {
  .topbar .auth-user { display: none; }
}

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

/* ---------- Movie browse facet filters (All / Country / Genre / Year / Language) ---------- */
.facet-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 18px 0 22px; }
.facet-all {
  background: var(--accent); color: #fff; border: none; border-radius: 18px;
  padding: 8px 16px; font-weight: 700; font-size: 13px; cursor: pointer; font-family: inherit;
  white-space: nowrap;
}
.facet-all:hover { filter: brightness(1.1); }
.facet-select {
  background: var(--bg-card); color: var(--text); border: 1px solid var(--border);
  border-radius: 18px; padding: 8px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
  font-family: inherit; outline: none; max-width: 240px;
}
.facet-select:hover { border-color: var(--text-faint); }
.facet-select:focus { border-color: var(--accent); }
/* ============ Live stats bar (top of the app) ============ */
.stats-bar {
  position: sticky; top: 0; z-index: 51;
  display: flex; align-items: center; justify-content: center; gap: 26px;
  /* viewport-fit=cover lets the page run under the phone status bar —
   * without the inset the clock/battery icons sit on top of the stats. */
  padding: calc(6px + env(safe-area-inset-top, 0px)) 16px 6px;
  min-height: var(--statsbar-h);
  font-size: 13px; font-weight: 600; color: #e8e6f2;
  letter-spacing: .3px;
  background: linear-gradient(90deg,#120509,#240b13,#120509);
  border-bottom: 1px solid rgba(229,9,20,.4); overflow: hidden;
  box-shadow: inset 0 0 26px rgba(229,9,20,.12);
}
.stats-bar::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 70px;
  background: linear-gradient(90deg,transparent,rgba(255,255,255,.12),transparent);
  transform: translateX(-120%); pointer-events: none;
}
.stats-bar.pulse::after { animation: statsShine 1.4s ease; }
@keyframes statsShine { to { transform: translateX(420%); } }
.stats-item { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.stats-item b { font-size: 15px; font-variant-numeric: tabular-nums; color: #fff; }
.stats-extra { color: #8b8ba3; font-weight: 500; }
/* Portrait phones: one nowrap row clips the Narto/Dracin/Total figures.
 * Stack each source on its own FULL-WIDTH centered line (the "double
 * layer") so every number stays visible AND everything stays middle-
 * placed exactly like the desktop bar. */
@media (max-width: 700px) and (orientation: portrait) {
  .stats-bar { flex-wrap: wrap; row-gap: 2px; column-gap: 0; padding-left: 8px; padding-right: 8px; font-size: 12px; }
  .stats-bar:not(.collapsed) .stats-item { flex: 1 1 100%; justify-content: center; text-align: center; white-space: normal; }
}
/* Mobile collapse toggle: one compact centered line (totals only) vs full detail. */
.stats-toggle {
  display: none; position: absolute; right: 2px; top: 50%; transform: translateY(-50%);
  background: transparent; border: 0; color: #b9b9cc; padding: 8px 10px; cursor: pointer;
}
.stats-toggle svg { width: 15px; height: 15px; display: block; transition: transform .18s ease; }
.stats-toggle.open svg { transform: rotate(180deg); }
@media (max-width: 700px) {
  .stats-toggle { display: inline-flex; }
  .stats-bar.collapsed {
    flex-wrap: nowrap; justify-content: center; column-gap: 10px; font-size: 12px;
    /* symmetric side padding keeps the row optically centered under the chevron */
    padding-left: 30px; padding-right: 30px;
  }
  .stats-bar.collapsed .stats-item { flex-wrap: nowrap; }
  .stats-bar.collapsed .stats-item b { font-size: 13px; }
  .stats-bar.collapsed .stats-dead,
  .stats-bar.collapsed .stats-extra { display: none; }
}
.stats-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.stats-dot.drama { background: #e6243c; box-shadow: 0 0 8px #e6243c; }
.stats-dot.movie { background: #3e8bff; box-shadow: 0 0 8px #3e8bff; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #2ee06e;
  box-shadow: 0 0 8px #2ee06e; animation: statsLive 1.6s ease-in-out infinite; }
@keyframes statsLive { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* ---------- WebView fit: LIVE badge removed; brand title takes its look ---------- */
#data-source-badge { display: none !important; }


.topbar .brand {
  color: var(--green);
  animation: brand-live 2s ease-in-out infinite;
}
@keyframes brand-live {
  0%, 100% { opacity: 1; text-shadow: 0 0 0 rgba(46, 160, 67, 0); }
  50% { opacity: 0.55; text-shadow: 0 0 12px 2px rgba(46, 160, 67, 0.5); }
}

.ep-title {
  font-size: 10px; line-height: 1.25; color: var(--muted, #9aa);
  margin-top: 3px; max-height: 26px; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}

/* ---------- ND / Narto+Dracin specific ---------- */
/* minmax(0, 1fr) instead of plain 1fr: a 1fr track never shrinks below its
 * content's min-content width, so the poster cards forced ~320px columns and
 * the grid ran past the right edge (last column cut off, nothing centred). */
.home-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 18px 14px;
  padding: 16px;
}
.home-grid > .drama-card { min-width: 0; }
.facet-bar .page-sub { margin: 0; }
.facet-bar .facet-select + .facet-select { margin-left: 4px; }
.player {
  max-width: 1000px;
  margin: 0 auto;
}
.player-frame {
  position: relative;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
  aspect-ratio: 16/9;
  box-shadow: var(--shadow);
}
/* ND mobile only: the iframe carries a fixed 460px inline height that
   overflows the 16/9 frame on phones (cropped/oversized look). Direct video
   already fills the frame — make iframe behave exactly the same. Desktop and
   Drama/Movie (.player-shell) untouched. */
@media (max-width: 640px) {
  .player-frame iframe { height: 100% !important; }
}
.ep-nav-bar {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: #1a1a1a; padding: 6px 12px; border-radius: 0 0 6px 6px;
}
.ep-nav-btn {
  background: rgba(255,255,255,0.1); color: #fff; border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px; padding: 5px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background 0.15s;
}
.ep-nav-btn:hover { background: rgba(255,255,255,0.2); }
.ep-nav-btn:disabled { opacity: 0.35; cursor: default; }
.ep-nav-label { color: #fff; font-size: 14px; font-weight: 600; min-width: 90px; text-align: center; }
.ep-nav-spacer { flex: 1; }
@media (min-width: 900px) { .home-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@media (max-width: 640px) { .home-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 10px; padding: 12px; } }

.player-frame:fullscreen,
.player-frame:-webkit-full-screen {
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  aspect-ratio: auto !important;
  border-radius: 0 !important;
  background: #000 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}
.player-frame:fullscreen video,
.player-frame:-webkit-full-screen video {
  width: 100% !important;
  height: 100% !important;
  max-height: 100vh !important;
  object-fit: contain !important;
}
/* Iframe mode had no fullscreen sizing (only the frame + <video> did), so
 * the iframe kept its inline 460px height and fullscreen changed nothing.
 * The inner embed video already fills 100%, so it expands correctly now. */
.player-frame:fullscreen iframe,
.player-frame:-webkit-full-screen iframe {
  width: 100% !important;
  height: 100% !important;
  max-height: 100vh !important;
  min-height: 100vh !important;
}

/* ---------- TV remote focus (visible focus ring + card zoom) ---------- */
/* TV browsers often lack :focus-visible; style plain :focus too so the
 * remote-driven focus is always obvious from 3 meters away. */
a:focus, button:focus, input:focus, select:focus, textarea:focus,
[tabindex]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.drama-card:focus {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius);
  transform: scale(1.05);
  z-index: 2;
}
.ep:focus, .ep-row:focus, .season-tab:focus, .res-chip:focus,
.ctl:focus, .ov-ctl:focus, .fs-nav button:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}
