:root {
  --bg: #0c0c0e;
  --bg-grad-top: #161410;
  --surface: #1a1a1d;
  --surface-2: #242428;
  --line: #2a2a2e;
  --text: #ededee;
  --muted: #8a8a90;
  --dim: #65656b;
  --accent: #e0913b;       /* warm amber */
  --accent-soft: #f0b878;
  --good: #5ec27a;
  --warn: #e0913b;
  --radius: 8px;
  /* themeable surfaces */
  --logo: #d7d7da;
  --tile: #1d1d20;
  --tile-fg: #3a3a40;
  --tile-fg2: #55555c;
  --nav-1: rgba(8,8,9,0.92);
  --nav-0: rgba(8,8,9,0);
  --row-fade: rgba(12,12,14,0.85);
  --backdrop: rgba(4,4,6,0.82);
  --modal-bg: #141416;
}

:root[data-theme="light"] {
  --bg: #f3ebdd;
  --bg-grad-top: #f7d9b6;
  --surface: #fbf6ee;
  --surface-2: #ece1cf;
  --line: #e2d6c2;
  --text: #221c14;
  --muted: #6f6555;
  --dim: #9a8d77;
  --accent: #d97a2b;
  --accent-soft: #b9611c;
  --good: #3f9d5d;
  --logo: #2a2118;
  --tile: #e8ddca;
  --tile-fg: #c3b69d;
  --tile-fg2: #b0a288;
  --nav-1: rgba(247,228,201,0.94);
  --nav-0: rgba(247,228,201,0);
  --row-fade: rgba(243,235,221,0.9);
  --backdrop: rgba(40,30,18,0.5);
  --modal-bg: #fbf6ee;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background:
    linear-gradient(180deg, var(--bg-grad-top) 0%, var(--bg) 420px),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  transition: background-color 0.25s, color 0.25s;
}
a { color: inherit; text-decoration: none; cursor: pointer; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; font-size: 0.85em; }
.muted { color: var(--muted); }
img { -webkit-user-drag: none; }

/* ---------------- Nav ---------------- */
.nav {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 44px;
  background: linear-gradient(180deg, var(--nav-1), var(--nav-0));
  backdrop-filter: blur(2px);
}
.nav-left { display: flex; align-items: center; gap: 38px; }
.brand { display: flex; align-items: center; gap: 11px; cursor: pointer; user-select: none; }
.brand-icon {
  height: 38px; width: auto; display: block; border-radius: 8px;
  background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}
.logo-text {
  font-size: 22px; font-weight: 800; letter-spacing: 1.5px; color: var(--logo);
}
.logo-text span { color: var(--accent); }
.menu { display: flex; gap: 26px; }
.menu-item {
  font-size: 15px; font-weight: 500; color: var(--muted);
  padding-bottom: 4px; position: relative; transition: color 0.15s;
}
.menu-item:hover { color: var(--text); }
.menu-item.is-active { color: var(--text); }
.menu-item.is-active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px;
  height: 2px; background: var(--accent); border-radius: 2px;
}
.nav-right { display: flex; align-items: center; gap: 18px; }
.icon-btn {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  padding: 6px; display: grid; place-items: center; border-radius: 50%;
  transition: color 0.15s, background 0.15s;
}
.icon-btn:hover { color: var(--text); background: var(--surface); }
#themeToggle { font-size: 17px; line-height: 1; width: 32px; height: 32px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #3a3a40, #232327);
  border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
  color: var(--accent-soft); cursor: pointer;
}
.avatar:hover { border-color: var(--accent); }

/* ---------------- Stage / rows ---------------- */
.stage { padding: 8px 0 80px; }
.view { animation: fade 0.3s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------------- Hero billboard ---------------- */
.hero {
  position: relative; margin: 0 0 30px; min-height: 440px;
  background-size: cover; background-position: center 18%;
  display: flex; align-items: flex-end;
}
.hero-shade { position: absolute; inset: 0; background:
  linear-gradient(90deg, rgba(12,12,14,0.92) 0%, rgba(12,12,14,0.55) 42%, rgba(12,12,14,0.15) 100%),
  linear-gradient(0deg, var(--bg) 2%, rgba(12,12,14,0) 55%); }
:root[data-theme="light"] .hero-shade { background:
  linear-gradient(90deg, rgba(243,235,221,0.94) 0%, rgba(243,235,221,0.6) 42%, rgba(243,235,221,0.1) 100%),
  linear-gradient(0deg, var(--bg) 2%, rgba(243,235,221,0) 55%); }
.hero-body { position: relative; padding: 0 44px 30px; max-width: 620px; }
.hero-badge { display: inline-block; font-size: 12px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); padding: 4px 10px; border-radius: 6px; }
.hero-title { font-size: clamp(30px, 5vw, 52px); font-weight: 900; line-height: 1.04; margin: 12px 0 8px; letter-spacing: -0.5px; }
.hero-meta { color: var(--muted); font-size: 14px; font-weight: 600; margin-bottom: 18px; }
.hero-actions { display: flex; gap: 12px; }
.hero-play, .hero-info { font-size: 15px; padding: 12px 26px; }
@media (max-width: 760px) { .hero { min-height: 360px; } .hero-body { padding: 0 18px 22px; } }

.row { position: relative; margin: 0 0 36px; }
.row-head {
  display: flex; align-items: baseline; gap: 12px;
  padding: 0 44px; margin-bottom: 14px;
}
.row-title {
  font-size: 13px; font-weight: 700; letter-spacing: 1.4px;
  text-transform: uppercase; color: #cfcfd3;
}
.row-count { font-size: 12px; color: var(--dim); }

.track {
  display: flex; gap: 14px;
  padding: 6px 44px 10px;
  overflow-x: auto; overflow-y: hidden;
  scroll-behavior: smooth;
  scrollbar-width: none;
}
.track::-webkit-scrollbar { height: 0; display: none; }

.row-nav {
  position: absolute; top: 0; bottom: 18px;
  width: 52px; display: grid; place-items: center;
  background: linear-gradient(90deg, var(--row-fade), transparent);
  border: 0; color: var(--text); font-size: 26px; cursor: pointer;
  opacity: 0; transition: opacity 0.18s; z-index: 5;
}
.row-nav.next { right: 0; transform: scaleX(-1); }
.row-nav.prev { left: 0; }
.row:hover .row-nav { opacity: 0.9; }
.row-nav:hover { opacity: 1; }

/* split band (watchlist + recommended side by side) */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.split .row { margin-bottom: 0; min-width: 0; }
.split .track { min-width: 0; }
.split .track { padding-left: 44px; padding-right: 24px; }
.split .row + .row .track { padding-left: 24px; }
.split .row + .row .row-head { padding-left: 24px; }

/* ---------------- Poster card ---------------- */
.pcard {
  flex: 0 0 auto; width: 150px; cursor: pointer;
  outline: none; border-radius: var(--radius);
  transition: transform 0.16s ease;
}
.pcard:hover, .pcard:focus-visible { transform: scale(1.06); }
.pcard-art {
  position: relative; width: 100%; aspect-ratio: 2/3;
  border-radius: var(--radius); overflow: hidden;
  background: var(--tile); border: 1px solid transparent;
  transition: border-color 0.16s, box-shadow 0.16s;
}
.pcard:hover .pcard-art, .pcard:focus-visible .pcard-art {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(224,145,59,0.28), 0 10px 26px rgba(0,0,0,0.55);
}
.pcard-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fallback {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 34px; font-weight: 800; color: var(--tile-fg); text-align: center; padding: 8px;
}
.fallback small { display: block; font-size: 11px; color: var(--tile-fg2); margin-top: 6px; }
.rating-tag {
  position: absolute; top: 6px; left: 6px;
  background: rgba(0,0,0,0.72); color: var(--accent-soft);
  font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 5px;
}
.fav {
  position: absolute; top: 6px; right: 6px;
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(0,0,0,0.55); border: 0; color: #fff; cursor: pointer;
  font-size: 14px; display: grid; place-items: center;
  opacity: 0; transform: scale(0.85); transition: all 0.15s;
}
.pcard:hover .fav, .pcard:focus-visible .fav { opacity: 1; transform: scale(1); }
.fav.on { color: var(--accent); opacity: 1; transform: scale(1); }
.mini-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255,255,255,0.2); }
.mini-progress i { display: block; height: 100%; background: var(--accent); }
.pcard-title {
  margin-top: 8px; font-size: 13px; font-weight: 600; color: #e6e6e8;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pcard-meta { margin-top: 2px; font-size: 11.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------- Landscape (continue/featured) card ---------------- */
.lcard {
  flex: 0 0 auto; width: 340px; cursor: pointer; outline: none;
  border-radius: 10px; transition: transform 0.16s;
}
.lcard:hover, .lcard:focus-visible { transform: scale(1.025); }
.lcard-art {
  position: relative; width: 100%; aspect-ratio: 16/9;
  border-radius: 10px; overflow: hidden;
  background-size: cover; background-position: center top;
  background-color: var(--tile);
  border: 1px solid var(--line);
  transition: border-color 0.16s, box-shadow 0.16s;
}
.lcard:hover .lcard-art, .lcard:focus-visible .lcard-art {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(224,145,59,0.3), 0 14px 34px rgba(0,0,0,0.6);
}
.lcard-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0.05) 30%, rgba(0,0,0,0.85)); }
.lcard-body { position: absolute; left: 16px; right: 16px; bottom: 12px; }
.lcard-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.lcard-title { font-size: 18px; font-weight: 700; text-shadow: 0 2px 8px rgba(0,0,0,0.7); line-height: 1.15;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lcard-sub { font-size: 12px; color: #c9c9cd; margin-top: 2px; }
.lcard-left { font-size: 12px; font-weight: 600; color: #dcdce0; white-space: nowrap; }
.lcard-prog { margin-top: 9px; height: 4px; background: rgba(255,255,255,0.22); border-radius: 3px; overflow: hidden; }
.lcard-prog i { display: block; height: 100%; background: var(--accent); }
.lcard-play {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%) scale(0.8);
  width: 52px; height: 52px; border-radius: 50%; background: rgba(0,0,0,0.55);
  border: 2px solid rgba(255,255,255,0.85); color: #fff; display: grid; place-items: center;
  font-size: 18px; opacity: 0; transition: all 0.16s;
}
.lcard:hover .lcard-play, .lcard:focus-visible .lcard-play { opacity: 1; transform: translate(-50%,-50%) scale(1); }
.lcard-x {
  position: absolute; top: 8px; right: 8px; z-index: 3;
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(0,0,0,0.6); border: 0; color: #fff; cursor: pointer;
  font-size: 13px; display: grid; place-items: center;
  opacity: 0; transform: scale(0.85); transition: all .15s;
}
.lcard:hover .lcard-x, .lcard:focus-within .lcard-x { opacity: 1; transform: scale(1); }
.lcard-x:hover { background: var(--danger, #ff5d6c); }

/* ---------------- Grid view ---------------- */
.view-head { padding: 24px 44px 6px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.grid-sort { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.grid-sort select { background: var(--surface); border: 1px solid var(--line); color: var(--text); font: inherit; font-size: 13px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.grid-sort[hidden] { display: none; }
.view-head h1 { margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -0.3px; }
.view-sub { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.cat-bar { display: flex; gap: 8px; flex-wrap: wrap; padding: 6px 44px 4px; }
.cat {
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 600; padding: 7px 14px;
  border-radius: 999px; cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.cat:hover { color: var(--text); border-color: #3a3a40; }
.cat.is-active { background: var(--accent); color: #1a1207; border-color: transparent; }

.poster-grid {
  display: grid; gap: 28px 18px; padding: 18px 44px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.poster-grid .pcard { width: auto; }
.grid-loader { display: flex; align-items: center; justify-content: center; gap: 9px; padding: 8px 0 30px; color: var(--muted); font-size: 14px; }
.grid-loader[hidden] { display: none; }
#gridSentinel { height: 1px; }

.state { text-align: center; padding: 70px 20px; color: var(--muted); }
.state h3 { color: var(--text); margin: 0 0 8px; font-size: 18px; }

.pager { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 10px 0 30px; flex-wrap: wrap; }
.pager-info { color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 7px; }
.pager-info input { width: 62px; text-align: center; background: var(--surface); border: 1px solid var(--line); color: var(--text); font: inherit; padding: 7px; border-radius: 7px; }

/* ---------------- Buttons ---------------- */
.solid-btn, .ghost-btn {
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  padding: 10px 16px; border-radius: 7px; transition: background 0.15s, border-color 0.15s, transform 0.05s;
  text-align: center;
}
.solid-btn { background: var(--accent); color: #1a1207; border: 1px solid var(--accent); }
.solid-btn:hover { background: var(--accent-soft); border-color: var(--accent-soft); }
.ghost-btn { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.ghost-btn:hover { background: var(--surface-2); border-color: #3a3a40; }
.solid-btn:active, .ghost-btn:active { transform: translateY(1px); }
.block { width: 100%; margin-top: 16px; }

/* ---------------- Search ---------------- */
.search-bar {
  display: flex; align-items: center; gap: 12px;
  margin: 8px 44px 6px; padding: 4px 4px 4px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  max-width: 720px; color: var(--muted);
}
.search-bar input {
  flex: 1; background: none; border: 0; color: var(--text); font: inherit; font-size: 16px; padding: 12px 0;
}
.search-bar input:focus { outline: none; }
.search-meta { margin: 4px 44px 0; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.search-meta .spin { width: 13px; height: 13px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.search-meta a { color: var(--accent); font-weight: 600; }

/* ---------------- Modal ---------------- */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; }
[hidden] { display: none !important; }
.modal-backdrop { position: absolute; inset: 0; background: var(--backdrop); backdrop-filter: blur(5px); }
.modal-panel { position: relative; background: var(--modal-bg); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,0.6); max-height: calc(100vh - 48px); animation: pop 0.2s ease; }
@keyframes pop { from { opacity: 0; transform: scale(0.97) translateY(8px); } to { opacity: 1; transform: none; } }
.modal-close { position: absolute; top: 12px; right: 12px; z-index: 5; width: 32px; height: 32px; border-radius: 50%; background: rgba(0,0,0,0.5); border: 1px solid var(--line); color: #fff; cursor: pointer; }
.modal-close:hover { background: rgba(0,0,0,0.85); }

/* ---------------- Mini player (picture-in-picture) ---------------- */
.pl-minibar { display: none; }
.player-modal.is-mini {
  inset: auto; top: auto; left: auto;
  right: 20px; bottom: 20px;
  width: min(380px, 92vw); height: auto; padding: 0;
  border-radius: 12px; overflow: hidden; border: 1px solid #2a313c;
  background: #11151c; box-shadow: 0 18px 50px rgba(0,0,0,0.6);
  animation: none;
}
.player-modal.is-mini .pl-top,
.player-modal.is-mini .pl-scrub,
.player-modal.is-mini .pl-controls,
.player-modal.is-mini .pl-eppanel,
.player-modal.is-mini .pl-pop,
.player-modal.is-mini .pl-center,
.player-modal.is-mini .pl-upnext { display: none !important; }
.player-modal.is-mini .pl-minibar {
  display: flex; align-items: center; gap: 9px; padding: 9px 8px 9px 12px;
  background: #161b22; cursor: grab; user-select: none;
}
.player-modal.is-mini .pl-minibar:active { cursor: grabbing; }
.pl-mini-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good, #5ec27a); flex-shrink: 0; box-shadow: 0 0 0 3px rgba(94,194,122,0.18); }
.pl-mini-title { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; color: #e7eaef; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-modal.is-mini .pl-minibar .pl-iconbtn { width: 30px; height: 30px; }
.player-modal.is-mini .pl-stage { flex: none; padding: 0; }
.player-modal.is-mini .player-frame { width: 100%; aspect-ratio: 16/9; border-radius: 0; box-shadow: none; }
.player-modal.is-mini .pl-stage:fullscreen .player-frame { aspect-ratio: auto; }

/* ---------------- Episode picker + Up Next ---------------- */
.pl-eppanel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(380px, 92vw);
  background: #14181f; border-left: 1px solid #2a313c; z-index: 8;
  display: flex; flex-direction: column; padding: 20px 18px;
  box-shadow: -16px 0 48px rgba(0,0,0,0.55); animation: epSlide .26s cubic-bezier(.16,1,.3,1);
}
.pl-eppanel[hidden] { display: none; }
@keyframes epSlide { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.ep-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.ep-head span { color: #fff; font-weight: 800; font-size: 17px; }
.ep-seasons { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.ep-season {
  background: #20262f; border: 1px solid #2a313c; color: #c4cad4; font: inherit;
  font-weight: 600; font-size: 13px; padding: 7px 13px; border-radius: 8px; cursor: pointer; transition: all .12s;
}
.ep-season:hover { color: #fff; border-color: #3a4350; }
.ep-season.is-active { background: var(--accent); color: #1a1207; border-color: transparent; }
.ep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 9px; overflow-y: auto; align-content: start; padding-right: 4px; }
.ep-cell {
  aspect-ratio: 1; background: #20262f; border: 1px solid #2a313c; color: #e7eaef;
  font: inherit; font-weight: 700; font-size: 15px; border-radius: 9px; cursor: pointer;
  display: grid; place-items: center; transition: all .12s;
}
.ep-cell:hover { background: #2a313c; transform: translateY(-1px); }
.ep-cell.is-playing { background: var(--accent); color: #1a1207; border-color: transparent; }
.ep-more { grid-column: 1 / -1; aspect-ratio: auto; padding: 10px; font-size: 13px; font-weight: 600; color: var(--accent); background: none; }
.ep-more:hover { background: rgba(224,145,59,0.1); }

.pl-upnext { position: absolute; right: 24px; bottom: 24px; z-index: 7; }
.pl-upnext[hidden] { display: none; }
.upnext-card {
  background: rgba(18,22,29,0.96); border: 1px solid #2a313c; border-radius: 14px;
  padding: 16px 18px; width: 290px; box-shadow: 0 18px 48px rgba(0,0,0,0.6);
  animation: epSlide .3s ease;
}
.upnext-label { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: #8c93a0; font-weight: 700; }
.upnext-title { color: #fff; font-weight: 700; font-size: 15px; margin: 5px 0 13px; }
.upnext-actions { display: flex; gap: 8px; }
.upnext-actions .solid-btn { flex: 1; }
.upnext-actions .ghost-btn { background: rgba(255,255,255,0.06); border-color: #2a313c; color: #c4cad4; }

/* ---------------- Details modal ---------------- */
.details-panel { width: min(780px, 96vw); max-height: calc(100vh - 48px); overflow-y: auto; overflow-x: hidden; }
.dt-hero { position: relative; background: #181c24 center 20% / cover no-repeat; min-height: 200px; display: flex; align-items: flex-end; }
.dt-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10,12,16,0.25) 0%, rgba(20,20,22,0.96) 96%); }
.dt-head { position: relative; display: flex; gap: 20px; align-items: flex-end; padding: 56px 26px 18px; width: 100%; }
.dt-poster { width: 120px; aspect-ratio: 2/3; object-fit: cover; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.6); flex-shrink: 0; }
.dt-info { min-width: 0; }
.dt-title { margin: 0 0 6px; font-size: 26px; font-weight: 800; line-height: 1.15; color: #fff; }
.dt-meta { color: #b9bec8; font-size: 13.5px; display: flex; gap: 7px; flex-wrap: wrap; }
.dt-meta .dot::before { content: "•"; margin-right: 7px; color: #6a7180; }
.dt-actions { display: flex; gap: 10px; margin-top: 14px; }
.dt-body { padding: 18px 26px 26px; }
.dt-summary { margin: 0 0 6px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.dt-seasonbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.dt-eplist { display: flex; flex-direction: column; gap: 6px; }
.dt-ep {
  display: grid; grid-template-columns: 34px 130px 1fr auto; gap: 14px; align-items: center;
  background: none; border: 0; border-radius: 10px; padding: 8px 10px; cursor: pointer;
  text-align: left; font: inherit; color: var(--text); transition: background .12s;
}
.dt-ep:hover { background: var(--surface); }
.dt-ep.is-watched { opacity: 0.62; }
.dt-ep-num { color: var(--dim); font-weight: 700; font-size: 15px; text-align: center; }
.dt-ep-thumb { position: relative; width: 130px; aspect-ratio: 16/9; border-radius: 7px; background: var(--tile) center/cover no-repeat; overflow: hidden; flex-shrink: 0; }
.dt-ep-thumb .ep-prog { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255,255,255,0.25); }
.dt-ep-thumb .ep-prog i { display: block; height: 100%; background: var(--accent); }
.dt-ep-info { min-width: 0; }
.dt-ep-name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dt-ep-sub { color: var(--muted); font-size: 12px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dt-ep-len { color: var(--dim); font-size: 12.5px; white-space: nowrap; }
.dt-loading { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; padding: 14px 4px; }
.dt-secttl { font-size: 14px; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase; color: #cfcfd3; margin: 18px 0 12px; }
.dt-cast .cast-row { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.dt-cast .cast-row::-webkit-scrollbar { display: none; }
.cast-card { flex: 0 0 auto; width: 84px; text-align: center; }
.cast-pic { display: grid; place-items: center; width: 84px; height: 84px; border-radius: 50%; background: var(--tile) center/cover no-repeat; color: var(--tile-fg); font-size: 26px; font-weight: 800; margin: 0 auto 7px; }
.cast-name { display: block; font-size: 12.5px; font-weight: 600; color: var(--text); line-height: 1.25; }
.cast-role { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.dt-similar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 16px 12px; }
.dt-similar-grid .pcard { width: auto; }
@media (max-width: 560px) {
  .dt-ep { grid-template-columns: 24px 96px 1fr; }
  .dt-ep-len { display: none; }
  .dt-ep-thumb { width: 96px; }
  .dt-poster { width: 88px; }
  .dt-title { font-size: 20px; }
}

.id-panel { width: min(440px, 96vw); padding: 30px 28px; overflow-y: auto; }
.id-panel h2 { margin: 0 0 6px; }
.seg { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 4px; margin: 18px 0; }
.seg-btn { flex: 1; background: transparent; border: 0; color: var(--muted); font: inherit; font-weight: 600; padding: 9px; border-radius: 7px; cursor: pointer; }
.seg-btn.is-active { background: var(--accent); color: #1a1207; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 13px; color: var(--muted); font-weight: 600; min-width: 0; }
.field input { background: var(--surface); border: 1px solid var(--line); color: var(--text); font: inherit; font-size: 15px; padding: 11px 12px; border-radius: 8px; width: 100%; min-width: 0; }
.field input:focus { outline: none; border-color: var(--accent); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------------- Toast ---------------- */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--surface-2); border: 1px solid var(--line); color: var(--text); padding: 12px 20px; border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,0.5); z-index: 200; font-size: 14px; font-weight: 600; opacity: 0; transition: opacity 0.25s, transform 0.25s; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast[hidden] { display: block; }

/* skeleton */
.sk { background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: var(--radius); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------------- Mobile bottom tab bar ---------------- */
.tabbar { display: none; }
@media (max-width: 760px) {
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
    background: rgba(10,10,12,0.96); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  }
  :root[data-theme="light"] .tabbar { background: rgba(247,238,225,0.97); }
  .tab-item {
    flex: 1; min-width: 0; background: none; border: 0; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    color: var(--dim); font: inherit; font-size: 10px; font-weight: 600; padding: 5px 2px;
  }
  .tab-item svg { width: 23px; height: 23px; }
  .tab-item span { white-space: nowrap; }
  .tab-item.is-active { color: var(--accent); }
}

@media (max-width: 760px) {
  .nav { padding: 12px 16px; }
  .nav-left { gap: 0; flex: 1; }
  .menu { display: none; }                 /* replaced by the bottom tab bar */
  .brand-icon { height: 32px; }
  .logo-text { font-size: 19px; }
  .stage { padding-bottom: 78px; }         /* clear the fixed tab bar */
  .row-head, .track, .view-head, .poster-grid, .cat-bar { padding-left: 16px; padding-right: 16px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)) !important; }
  .poster-grid { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 18px 12px; }
  .view-head { padding-top: 18px; }
  .view-head h1 { font-size: 22px; }
  .lcard { width: 270px; }
  .modal { padding: 0; }
  .details-panel { width: 100vw; max-height: 100vh; border-radius: 0; }
  .id-panel { width: 100vw; min-height: 100vh; border-radius: 0; }
  .search-bar { margin: 8px 16px 6px; }
  .search-meta { margin: 4px 16px 0; }
  .pl-top { padding: 12px 16px; }
  .pl-title { display: none; }
  .pl-scrub { padding: 6px 16px 2px; gap: 10px; }
  .pl-controls { padding: 8px 12px 18px; gap: 6px; }
  .pl-mid { gap: 2px; }
  .pl-grp.pl-left, .pl-grp.pl-right { min-width: 0; }
  .pl-iconbtn { width: 36px; height: 36px; }
  .pl-vol { display: none; }                /* volume is in-video on mobile anyway */
  .pl-next-label { display: none; }
  .pl-next-thumb { width: 56px; height: 34px; }
  .pl-eppanel { width: 100vw; }
  .pl-pop { right: 12px; left: 12px; bottom: 78px; }
  .player-modal.is-mini { right: 10px; bottom: 10px; width: min(280px, 70vw); }
  /* hero + cards */
  .hero-actions .ghost-btn { padding: 12px 16px; }
  .cast-card { width: 72px; }
  .cast-pic { width: 72px; height: 72px; }
  .dt-similar-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
}

/* ---------------- Premium Video Player Modal ---------------- */
.player-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #0b0c0e; /* Cinematic pure black/dark slate background */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 0; /* Remove horizontal padding so the stage stretches edge-to-edge */
  animation: modalFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(1.015); }
  to { opacity: 1; transform: scale(1); }
}

/* Header bar */
.pl-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 24px;
  box-sizing: border-box;
  z-index: 10;
}
.pl-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}
.pl-brand img {
  height: 34px;
  width: auto;
  border-radius: 6px;
  background: #fff;
  padding: 2px;
}
.pl-brand span {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 1.2px;
  color: var(--logo);
}
.pl-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #ededee;
  text-align: center;
  flex: 1;
  max-width: 60%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pl-topright {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Video Stage */
.pl-stage {
  position: relative;
  width: 100%;
  height: calc(100vh - 190px); /* Fill height while keeping room for top/bottom bars */
  max-width: 100%; /* Theater mode stretches edge-to-edge */
  margin: 10px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  border-radius: 0; /* Flat edge-to-edge edges */
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}
.player-frame {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.player-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* Center HUD control overlays */
.pl-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: rgba(24, 26, 30, 0.72);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 10;
}
.pl-center.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.pl-center svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}
.pl-center .ic {
  display: none;
}
.pl-stage[data-state="paused"] .pl-center .ic-play {
  display: block;
}
.pl-stage[data-state="playing"] .pl-center .ic-pause {
  display: block;
}
.pl-stage[data-state="loading"] .pl-center .pl-spin {
  display: block;
}

/* Spinner */
.pl-spin {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}

/* Timeline scrubber section */
.pl-scrub {
  display: flex;
  align-items: center;
  gap: 18px;
  width: 100%;
  max-width: 1200px;
  margin: 12px auto 6px;
  padding: 0 24px;
  box-sizing: border-box;
}
.pl-time {
  font-size: 13.5px;
  font-weight: 600;
  color: rgba(237, 237, 238, 0.75);
  font-family: system-ui, -apple-system, sans-serif;
  min-width: 48px;
  text-align: center;
}
.pl-track {
  position: relative;
  flex: 1;
  height: 5px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: height 0.18s ease;
}
.pl-track:hover {
  height: 7px;
}
.pl-fill {
  position: absolute;
  left: 0;
  height: 100%;
  background: #fff;
  border-radius: 3px;
  width: 0%;
  pointer-events: none;
}
.pl-head {
  position: absolute;
  left: 0%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.pl-knob {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1.5px 5px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}
.pl-track:hover .pl-knob {
  transform: scale(1.3);
}

/* Controls row */
.pl-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 6px 24px 15px;
  box-sizing: border-box;
}
.pl-grp {
  display: flex;
  align-items: center;
}
.pl-grp.pl-left {
  gap: 16px;
  min-width: 140px;
}
.pl-grp.pl-mid {
  gap: 22px;
}
.pl-grp.pl-right {
  justify-content: flex-end;
  min-width: 200px;
}

/* Play & Pause button state toggle details */
.pl-play-btn, .pl-pause-btn {
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
  display: grid;
  place-items: center;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* State: Paused - Play button is a white circle, Pause is a flat grey icon */
.player-modal[data-playing="false"] .pl-play-btn {
  background: #fff;
  color: #121417;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}
.player-modal[data-playing="false"] .pl-play-btn:hover {
  transform: scale(1.08);
  background: #f4f4f5;
}
.player-modal[data-playing="false"] .pl-pause-btn {
  color: rgba(255, 255, 255, 0.35);
  width: 32px;
  height: 32px;
}
.player-modal[data-playing="false"] .pl-pause-btn:hover {
  color: rgba(255, 255, 255, 0.6);
}

/* State: Playing - Play button is flat grey, Pause is a white circle */
.player-modal[data-playing="true"] .pl-play-btn {
  color: rgba(255, 255, 255, 0.35);
  width: 32px;
  height: 32px;
}
.player-modal[data-playing="true"] .pl-play-btn:hover {
  color: rgba(255, 255, 255, 0.6);
}
.player-modal[data-playing="true"] .pl-pause-btn {
  background: #fff;
  color: #121417;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}
.player-modal[data-playing="true"] .pl-pause-btn:hover {
  transform: scale(1.08);
  background: #f4f4f5;
}

/* Icon Buttons general */
.pl-iconbtn {
  background: none;
  border: 0;
  color: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  padding: 6px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  transition: all 0.15s ease;
}
.pl-iconbtn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  transform: scale(1.08);
}
.pl-iconbtn svg {
  display: block;
}

/* Volume Slider */
.pl-vol {
  display: flex;
  align-items: center;
  gap: 10px;
}
.pl-volrange {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 4px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
.pl-volrange::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  transition: transform 0.12s ease;
}
.pl-volrange::-webkit-slider-thumb:hover {
  transform: scale(1.3);
}

/* Next Episode card */
.pl-next {
  display: flex;
  align-items: center;
  gap: 14px;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
  color: #fff;
  text-align: left;
}
.pl-next-label {
  font-size: 13.5px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.78);
  transition: color 0.2s ease;
}
.pl-next:hover .pl-next-label {
  color: #fff;
}
.pl-next-thumb {
  width: 88px;
  height: 50px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background-size: cover;
  background-position: center;
  background-color: var(--surface);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}
.pl-next:hover .pl-next-thumb {
  border-color: #fff;
  transform: scale(1.06);
}

/* Settings Popover */
.pl-pop {
  position: fixed;
  bottom: 80px;
  right: 50%;
  margin-right: -240px; /* roughly near the settings button */
  background: rgba(22, 24, 29, 0.94);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 1010;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.65);
  width: 200px;
  animation: popUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes popUp {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.pl-popitem {
  background: none;
  border: 0;
  color: rgba(255, 255, 255, 0.78);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: block;
  width: 100%;
  transition: all 0.15s ease;
}
.pl-popitem:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
a.pl-popitem {
  box-sizing: border-box;
}
.pl-popmeta {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.36);
  padding: 6px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin-top: 4px;
}

/* Responsive adjustment for player modal — kept LAST so it wins source-order */
@media (max-width: 760px) {
  .player-modal { padding: 0; }
  .pl-top { padding: 12px 14px; }
  .pl-scrub { padding: 6px 14px 2px; gap: 10px; }
  .pl-controls { padding: 8px 10px calc(16px + env(safe-area-inset-bottom, 0px)); gap: 4px; }
  .pl-title { display: none; }
  .pl-grp.pl-left, .pl-grp.pl-right { min-width: 0; }
  .pl-grp.pl-mid { gap: 4px; }
  .pl-iconbtn { width: 34px; height: 34px; }
  .pl-iconbtn svg { width: 20px; height: 20px; }
  .pl-vol { display: none; }                 /* volume is in-video on mobile */
  .pl-play-btn, .pl-pause-btn { transform: scale(0.92); }
  .pl-next-label { display: none; }
  .pl-next-thumb { width: 54px; height: 32px; }
  .pl-eppanel { width: 100vw; top: 0; }
  .pl-pop { right: 12px; left: 12px; margin-right: 0; width: auto; bottom: 76px; }
  .player-modal.is-mini { right: 10px; bottom: 10px; width: min(260px, 72vw); }

  /* full-screen modals on phones */
  .modal { padding: 0; }
  .details-panel { width: 100vw; max-width: 100vw; max-height: 100vh; border-radius: 0; }
  .id-panel { width: 100vw; min-height: 100vh; border-radius: 0; }
  .dt-head { padding: 50px 16px 16px; gap: 14px; }
  .dt-body { padding: 16px 16px 30px; }
  .dt-cast .cast-card { width: 70px; }
  .cast-pic { width: 70px; height: 70px; }
  .dt-similar-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
}

