:root {
  --bg: #0C0D10;
  --bg-2: #17181D;
  --bg-3: #222329;
  --line: #303137;
  --fg: #FFF0D8;
  --muted: #A6A3A0;
  --accent: #D86B28;
  --accent-2: #FFA352;
  --ok: #46c37b;
  --bad: #ff6b6b;
  --radius: 8px;
  --pad: clamp(16px, 4vw, 56px);
  --card-w: clamp(118px, 13vw, 190px);
  --wide-w: clamp(220px, 24vw, 340px);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body.locked { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
img { display: block; }
[hidden] { display: none !important; }
svg { fill: currentColor; }

.muted { color: var(--muted); }
.spacer { flex: 1; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 22px; border: 0; border-radius: 6px; cursor: pointer;
  background: var(--fg); color: #000; font-weight: 650; white-space: nowrap;
  transition: background .15s, opacity .15s, transform .1s;
}
.btn:hover { background: #d8d8de; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: rgba(120, 120, 140, .32); color: var(--fg); }
.btn.ghost:hover { background: rgba(140, 140, 160, .48); }
.btn.small { padding: 6px 14px; font-size: 14px; }
.btn.danger { color: var(--bad); }
.btn svg { width: 22px; height: 22px; }

.icon-btn {
  position: relative; display: inline-grid; place-items: center;
  width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; cursor: pointer;
}
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn:hover { background: rgba(255, 255, 255, .1); }
.round-btn {
  display: inline-grid; place-items: center; width: 42px; height: 42px;
  border-radius: 50%; border: 2px solid rgba(255, 255, 255, .5);
  background: rgba(20, 20, 28, .6); cursor: pointer; font-size: 20px;
}
.round-btn:hover { border-color: var(--fg); }
.round-btn.on { border-color: var(--accent); color: var(--accent); }

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 20; height: 64px;
  display: flex; align-items: center; gap: 28px; padding: 0 var(--pad);
  background: linear-gradient(to bottom, rgba(0, 0, 0, .8), transparent);
  transition: background .3s;
}
.topbar.solid { background: rgba(12, 13, 16, .97); box-shadow: 0 1px 0 var(--line); }
.logo { display: block; flex: 0 0 auto; }
.logo img { width: auto; height: 36px; }
.nav { display: flex; align-items: center; gap: 20px; }
.nav-more { position: relative; }
.nav-more-btn {
  width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line); background: transparent;
  color: #d0d0d8; font-size: 18px; line-height: 1; cursor: pointer; transition: color .15s, border-color .15s;
}
.nav-more-btn:hover, .nav-more-btn.active { color: var(--fg); border-color: var(--fg); }
.nav-menu {
  position: absolute; top: calc(100% + 10px); left: 0; z-index: 30; min-width: 160px; padding: 6px;
  display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 6px; background: var(--bg-2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}
.nav-menu[hidden] { display: none; }
.nav-menu a { padding: 8px 12px; border-radius: 4px; }
.nav-menu a:hover { background: var(--bg-3); }
.nav a { color: #d0d0d8; font-size: 14px; white-space: nowrap; transition: color .15s; }
.nav a:hover { color: var(--fg); }
.nav a.active { color: var(--fg); font-weight: 700; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.search { display: flex; align-items: center; border: 1px solid transparent; border-radius: 4px; transition: all .2s; }
.search input {
  width: 0; padding: 0; border: 0; background: transparent; outline: none;
  transition: width .25s, padding .25s;
}
.search.open { border-color: rgba(255, 255, 255, .7); background: rgba(0, 0, 0, .75); }
.search.open input { width: min(240px, 42vw); padding: 6px 8px 6px 0; }
.search input::-webkit-search-cancel-button { filter: invert(1); }
.dot { position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-2); }

@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; height: auto; padding-top: 10px; padding-bottom: 6px; gap: 6px 16px; }
  .nav { order: 3; width: 100%; gap: 16px; padding-bottom: 4px; flex-wrap: wrap; }
  .logo img { height: 32px; }
}

main { min-height: 100vh; padding-bottom: 60px; }

/* ---------------------------------------------------------------- hero */
.hero {
  position: relative; min-height: min(82vh, 56.25vw + 120px); display: flex; align-items: flex-end;
  padding: 120px var(--pad) clamp(40px, 9vw, 110px);
  background: var(--bg-2) center 20% / cover no-repeat;
}
.hero::before {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(77deg, rgba(0, 0, 0, .85) 0%, rgba(0, 0, 0, .35) 45%, transparent 75%),
    linear-gradient(to top, var(--bg) 0%, rgba(10, 10, 15, .6) 18%, transparent 45%);
}
.hero-content { position: relative; max-width: min(620px, 92vw); }
.hero .clearlogo { max-width: min(440px, 80vw); max-height: 160px; object-fit: contain; object-position: left bottom; margin-bottom: 18px; filter: drop-shadow(0 2px 12px rgba(0, 0, 0, .6)); }
.hero h1 { font-size: clamp(30px, 5vw, 60px); line-height: 1.05; margin: 0 0 14px; text-shadow: 0 2px 16px rgba(0, 0, 0, .6); }
.hero .plot {
  font-size: clamp(14px, 1.4vw, 18px); text-shadow: 0 1px 6px rgba(0, 0, 0, .8);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.hero .row { margin-top: 20px; flex-wrap: wrap; }
.hero.slim { min-height: 0; padding-top: 110px; padding-bottom: 12px; background: none; }
.hero.slim::before { display: none; }
.hero.slim h1 { font-size: clamp(26px, 3.5vw, 40px); margin: 0; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; color: #d6d6de; font-size: 14px; margin-bottom: 10px; }
.meta .match { color: var(--ok); font-weight: 700; }
.meta .pill { border: 1px solid rgba(255, 255, 255, .45); border-radius: 3px; padding: 0 6px; font-size: 12px; }

/* ---------------------------------------------------------------- rows */
.rows { position: relative; z-index: 1; margin-top: clamp(-90px, -6vw, -20px); }
.hero.slim + .rows { margin-top: 0; }
.continue-page { padding-top: 16px; }
.row-block { margin: 0 0 clamp(20px, 3vw, 40px); }
.row-block h2 {
  margin: 0 var(--pad) 8px; font-size: clamp(16px, 1.6vw, 21px); font-weight: 700;
  display: flex; align-items: baseline; gap: 12px;
}
.row-block h2 a { font-size: 13px; color: var(--accent); font-weight: 600; opacity: 0; transition: opacity .2s; }
.row-block:hover h2 a, .row-block h2 a:focus { opacity: 1; }
@media (hover: none) { .row-block h2 a { opacity: 1; } }
.slider { position: relative; }
.track {
  display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity; scroll-behavior: smooth;
  padding: 6px var(--pad) 14px; scroll-padding: 0 var(--pad); scrollbar-width: none;
}
.track::-webkit-scrollbar { display: none; }
.track > * { scroll-snap-align: start; flex: 0 0 auto; }
.arrow {
  position: absolute; top: 6px; bottom: 14px; z-index: 3; width: calc(var(--pad) - 4px); min-width: 28px;
  border: 0; background: rgba(10, 10, 15, .6); cursor: pointer; font-size: 30px; opacity: 0; transition: opacity .2s;
}
.arrow.left { left: 0; } .arrow.right { right: 0; }
.slider:hover .arrow { opacity: 1; }
.arrow:hover { background: rgba(10, 10, 15, .85); }
@media (hover: none) { .arrow { display: none; } }
.skeleton { background: linear-gradient(90deg, var(--bg-2) 0, var(--bg-3) 50%, var(--bg-2) 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 6px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------------------------------------------------------------- cards */
.card { position: relative; width: var(--card-w); cursor: pointer; border-radius: 6px; outline: none; }
.card .art { position: relative; aspect-ratio: 2 / 3; border-radius: 6px; overflow: hidden; background: var(--bg-3); transition: transform .2s, box-shadow .2s; }
.card img { width: 100%; height: 100%; object-fit: cover; }
.card:hover .art, .card:focus-visible .art { transform: scale(1.05); box-shadow: 0 10px 28px rgba(0, 0, 0, .6); z-index: 2; }
.card .noart { display: grid; place-items: center; height: 100%; padding: 10px; text-align: center; font-weight: 700; color: var(--muted); }
.card .badge {
  position: absolute; top: 6px; left: 6px; padding: 1px 6px; border-radius: 3px;
  background: var(--accent-2); color: #fff; font-size: 11px; font-weight: 700; text-transform: uppercase;
}
.card .rate { position: absolute; top: 6px; right: 6px; padding: 1px 6px; border-radius: 3px; background: rgba(0, 0, 0, .7); font-size: 12px; font-weight: 700; color: var(--accent); }
.card .seen { position: absolute; bottom: 8px; right: 8px; width: 22px; height: 22px; border-radius: 50%; background: var(--ok); color: #000; display: grid; place-items: center; font-size: 13px; font-weight: 900; }
.card .caption { padding: 6px 2px 0; font-size: 13px; }
.card .caption b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .caption span { color: var(--muted); font-size: 12px; }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, .25); }
.progress i { display: block; height: 100%; background: var(--accent-2); }

.card.wide { width: var(--wide-w); }
.card.wide .art { aspect-ratio: 16 / 9; }
.card.wide .art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0, 0, 0, .85), transparent 55%); }
.card.wide .wide-title { position: absolute; left: 10px; right: 10px; bottom: 12px; z-index: 1; font-weight: 700; text-shadow: 0 1px 4px #000; }
.card.wide .wide-title small { display: block; font-weight: 500; font-size: 12px; color: #ddd; }
.card.wide .play-ico { position: absolute; inset: 0; z-index: 1; display: grid; place-items: center; opacity: 0; transition: opacity .2s; }
.card.wide:hover .play-ico { opacity: 1; }
.play-ico span { width: 48px; height: 48px; border-radius: 50%; border: 2px solid #fff; background: rgba(0, 0, 0, .5); display: grid; place-items: center; font-size: 20px; padding-left: 3px; }
.card .remove { position: absolute; top: 6px; right: 6px; z-index: 3; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .7); cursor: pointer; opacity: 0; }
.card:hover .remove { opacity: 1; }
@media (hover: none) { .card .remove { opacity: 1; } }

/* ---------------------------------------------------------------- grid / browse */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 0 var(--pad) 18px; }
.year-filter { display: flex; flex-wrap: wrap; gap: 8px; }
.vote-minimum { width: 175px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); }
.ratings-coverage { margin: 0; padding: 0 var(--pad) 18px; color: var(--muted); font-size: 13px; }
select {
  appearance: none; padding: 7px 30px 7px 12px; border: 1px solid var(--line); border-radius: 4px; cursor: pointer;
  background: var(--bg-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath fill='%23aaa' d='M0 0h10L5 6z'/%3E%3C/svg%3E") right 10px center / 10px no-repeat;
}
.hero.slim + .grid, .hero.slim + .empty { margin-top: 18px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.seg button { padding: 7px 12px; border: 0; background: var(--bg-2); cursor: pointer; font-size: 14px; }
.seg button.on { background: var(--fg); color: #000; font-weight: 650; }
.grid {
  display: grid; gap: 22px 10px; padding: 0 var(--pad);
  grid-template-columns: repeat(auto-fill, minmax(var(--card-w), 1fr));
}
.grid .card { width: auto; }
.empty { padding: 60px var(--pad); text-align: center; color: var(--muted); }
.sentinel { height: 1px; }
.loading-more { text-align: center; color: var(--muted); padding: 24px; }

/* ---------------------------------------------------------------- detail */
.overlay {
  position: fixed; inset: 0; z-index: 40; overflow-y: auto; overscroll-behavior: contain;
  background: rgba(0, 0, 0, .72); backdrop-filter: blur(3px);
  animation: fade .2s ease-out;
}
.overlay.center { display: grid; place-items: center; padding: 20px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }
.detail-sheet {
  position: relative; width: min(960px, 100%); margin: 32px auto; min-height: 60vh;
  background: var(--bg-2); border-radius: 10px; overflow: hidden; box-shadow: 0 20px 80px #000;
  animation: rise .25s ease-out;
}
@media (max-width: 700px) { .detail-sheet { margin: 0; border-radius: 0; min-height: 100vh; } }
.close-btn {
  position: absolute; top: 14px; right: 14px; z-index: 5; width: 38px; height: 38px;
  border: 0; border-radius: 50%; background: rgba(10, 10, 15, .8); cursor: pointer; font-size: 16px;
  transition: background .2s, transform .2s;
}
.close-btn:hover, .close-btn:focus { background: rgba(10, 10, 15, 1); transform: scale(1.1); outline: 2px solid var(--accent-2); outline-offset: 2px; }
.d-hero { position: relative; aspect-ratio: 16 / 8; min-height: 280px; background: #000 center 25% / cover no-repeat; display: flex; align-items: flex-end; }
/* Keep the synopsis and title actions in the first TV viewport. */
.tv-app .d-hero { height: min(36vh, 360px); min-height: 0; aspect-ratio: auto; }
.d-hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, var(--bg-2) 2%, rgba(20, 20, 28, .35) 45%, transparent 70%); }
.d-hero-content { position: relative; padding: 0 clamp(18px, 4vw, 44px) 22px; width: 100%; }
.d-hero .clearlogo { max-width: min(360px, 70%); max-height: 120px; object-fit: contain; object-position: left bottom; margin-bottom: 14px; }
.d-hero h1 { margin: 0 0 14px; font-size: clamp(26px, 4vw, 42px); line-height: 1.1; }
.d-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.d-resume { margin-top: 12px; display: flex; align-items: center; gap: 10px; color: #ddd; font-size: 13px; }
.d-resume .bar { width: 160px; height: 4px; background: rgba(255, 255, 255, .25); border-radius: 2px; overflow: hidden; }
.d-resume .bar i { display: block; height: 100%; background: var(--accent-2); }
.d-body { padding: 8px clamp(18px, 4vw, 44px) 36px; }
.d-main-actions {
  padding: 24px 0;
  background: linear-gradient(to bottom, rgba(20, 20, 28, .8), var(--bg-2));
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}
.d-main-actions .d-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.d-main-actions .d-actions > .btn:first-child {
  font-size: 16px;
  padding: 12px 28px;
  min-width: 200px;
}
.d-main-actions .d-actions > .btn.ghost {
  align-self: flex-start;
  margin-top: 8px;
  max-width: fit-content;
}
.d-secondary-actions {
  padding: 0;
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
  margin-bottom: 24px;
}
.d-main-actions > div:not(.d-actions) {
  margin-top: 12px;
}
.d-cols { display: grid; grid-template-columns: 2fr 1fr; gap: 28px; }
@media (max-width: 700px) { .d-cols { grid-template-columns: 1fr; gap: 10px; } }
.d-cols .plot { margin: 0; font-size: 15px; }
.d-side { font-size: 14px; color: var(--muted); }
.d-side b { color: #ccc; font-weight: 500; }
.d-side p { margin: 0 0 8px; }
.d-section { margin-top: 30px; }
.d-section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.d-section-head h3 { margin: 0; font-size: 20px; }
.d-section-head select { margin-left: auto; }

.episode {
  display: grid; grid-template-columns: 34px clamp(120px, 22%, 180px) 1fr auto; gap: 14px; align-items: center;
  padding: 16px 12px; border-bottom: 1px solid var(--line); border-radius: 6px; cursor: pointer;
  outline: none;
}
.episode:hover, .episode:focus-visible { background: var(--bg-3); }
.episode:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.episode.current { background: #262633; }
.episode .num { font-size: 22px; color: var(--muted); text-align: center; }
.episode .thumb { position: relative; aspect-ratio: 16 / 9; border-radius: 4px; overflow: hidden; background: var(--bg-3); }
.episode .thumb img { width: 100%; height: 100%; object-fit: cover; }
.episode .thumb .play-ico { position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; transition: opacity .15s; }
.episode:hover .thumb .play-ico, .episode:focus-visible .thumb .play-ico { opacity: 1; }
.episode .play-ico span { width: 38px; height: 38px; font-size: 15px; }
.episode .info h4 { margin: 0 0 4px; font-size: 15px; display: flex; gap: 10px; align-items: baseline; }
.episode .info h4 small { color: var(--muted); font-weight: 400; margin-left: auto; white-space: nowrap; }
.episode .info p { margin: 0; color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.episode .ep-actions { display: flex; flex-direction: column; gap: 6px; }
.episode .mini { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 50%; background: transparent; cursor: pointer; font-size: 14px; }
.episode .mini:hover { border-color: var(--fg); }
.episode .mini.on { background: var(--ok); color: #000; border-color: var(--ok); }
.episode .sources { grid-column: 2 / -1; }
@media (max-width: 600px) {
  .episode { grid-template-columns: 110px 1fr auto; gap: 10px; }
  .episode .num { display: none; }
}

.sources { display: grid; gap: 6px; margin-top: 6px; cursor: default; }
.source {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; font-size: 13px;
}
.source .q { font-weight: 800; color: var(--accent); min-width: 64px; }
.source .tag { padding: 1px 7px; border-radius: 3px; background: var(--bg-3); color: #ccc; font-size: 12px; }
.source .tag.warn { color: var(--accent); }
.source .msg { flex-basis: 100%; color: var(--muted); font-size: 12px; }
.source .msg.bad { color: var(--bad); }
.source .btn { padding: 5px 12px; font-size: 13px; }
.source.best { border-color: rgba(232, 163, 61, .6); }
.source.failed { opacity: .6; }
.source .tag.fail { color: var(--bad); }

/* ---------------------------------------------------------------- player */
.player { position: fixed; inset: 0; z-index: 60; background: #000; color: #fff; user-select: none; -webkit-user-select: none; }
.player video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.player video::cue { background: rgba(0, 0, 0, .6); font-size: clamp(18px, 2.6vw, 34px); line-height: 1.3; text-shadow: 0 0 4px #000; }
.player.idle { cursor: none; }
.p-ui { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; justify-content: space-between; transition: opacity .3s; pointer-events: none; }
.player.errored .p-bottom, .player.errored .p-panel { visibility: hidden; }
.player.errored .p-ui { opacity: 1; }
.p-ui > * { pointer-events: auto; }
.player.idle .p-ui { opacity: 0; }
.player.idle .p-ui > * { pointer-events: none; }
.p-top { display: flex; align-items: center; gap: 12px; padding: max(14px, env(safe-area-inset-top)) 20px 40px; background: linear-gradient(rgba(0, 0, 0, .75), transparent); }
.p-top .icon-btn svg { width: 30px; height: 30px; }
.p-title { display: flex; flex-direction: column; min-width: 0; }
.p-title strong { font-size: clamp(16px, 2vw, 22px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-title span { color: #ccc; font-size: 14px; }
.p-bottom { padding: 40px clamp(12px, 3vw, 32px) max(12px, env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(0, 0, 0, .85)); }
.p-controls { display: flex; align-items: center; gap: clamp(2px, 1vw, 10px); }
.p-controls .icon-btn { width: 44px; height: 44px; }
.p-controls .icon-btn svg { width: 28px; height: 28px; }
.p-time { font-variant-numeric: tabular-nums; font-size: 14px; color: #ddd; white-space: nowrap; }
.p-volume { display: flex; align-items: center; }
.p-volume input { width: 0; opacity: 0; transition: width .2s, opacity .2s; accent-color: var(--accent-2); }
.p-volume:hover input, .p-volume input:focus { width: 90px; opacity: 1; }
@media (hover: none) { .p-volume input { display: none; } }
@media (max-width: 560px) { #p-back10, #p-fwd10 { display: none; } .p-controls { gap: 0; } }

.p-seek { position: relative; height: 22px; display: flex; align-items: center; cursor: pointer; touch-action: none; }
.p-seek-track { position: relative; width: 100%; height: 4px; background: rgba(255, 255, 255, .22); border-radius: 2px; transition: height .12s; }
.p-seek:hover .p-seek-track, .p-seek.drag .p-seek-track { height: 7px; }
.p-seek-avail, .p-seek-buffer, .p-seek-played { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 2px; }
.p-seek-avail { background: rgba(255, 255, 255, .18); }
.p-seek-buffer { background: rgba(255, 255, 255, .42); }
.p-seek-played { background: var(--accent-2); }
.p-seek-thumb { position: absolute; top: 50%; width: 15px; height: 15px; margin: -7.5px 0 0 -7.5px; border-radius: 50%; background: var(--accent-2); transform: scale(0); transition: transform .12s; }
.p-seek:hover .p-seek-thumb, .p-seek.drag .p-seek-thumb { transform: scale(1); }
.p-seek-tip { position: absolute; bottom: 24px; transform: translateX(-50%); padding: 3px 8px; border-radius: 4px; background: rgba(0, 0, 0, .85); font-size: 13px; font-variant-numeric: tabular-nums; pointer-events: none; }

.p-spinner { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 16px; pointer-events: none; z-index: 2; }
.p-load { position: relative; width: 120px; height: 120px; display: grid; place-items: center; }
/* Lumeo comet mark before the first frame of a session, plain ring while buffering. */
.p-load .comet { display: none; width: 120px; height: 120px; overflow: visible; }
.player.starting .p-load .comet { display: block; }
.player.starting .p-spinner .ring { display: none; }
.p-spinner .ring { position: absolute; inset: 28px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, .15); border-top-color: var(--accent-2); animation: spin .9s linear infinite; }
.p-spinner span { color: #ddd; font-size: 14px; text-shadow: 0 1px 4px #000; }
@keyframes spin { to { transform: rotate(360deg); } }
/* Light trace: a glowing head draws each arc (pathLength=1), the colour fills in, then the line erases from its start. */
.comet use { animation: 2.4s linear infinite; }
.comet .c-fill { opacity: 0; animation-name: comet-fill; }
.comet .c-trail { fill: none; stroke: #FFE0AE; stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; animation-name: comet-trail; }
.comet .c-head { fill: none; stroke: #FFF; stroke-width: 16; stroke-linecap: round; stroke-dasharray: .07 2; filter: url(#pc-glow); animation-name: comet-head; }
@keyframes comet-fill {
  0%, 34% { opacity: 0; animation-timing-function: ease-in-out; }
  58%, 76% { opacity: 1; animation-timing-function: ease-in-out; }
  95%, 100% { opacity: 0; }
}
@keyframes comet-trail {
  0% { stroke-dasharray: 0 2; stroke-dashoffset: 0; opacity: 0; animation-timing-function: cubic-bezier(.33, 1, .68, 1); }
  3% { opacity: 1; }
  34% { opacity: 1; animation-timing-function: ease-in-out; }
  42% { stroke-dasharray: 1 2; }
  58% { opacity: .4; }
  76% { stroke-dasharray: 1 2; stroke-dashoffset: 0; opacity: .4; animation-timing-function: ease-in-out; }
  95%, 100% { stroke-dasharray: 0 2; stroke-dashoffset: -1; opacity: 0; }
}
@keyframes comet-head {
  0% { stroke-dashoffset: .07; opacity: 0; animation-timing-function: cubic-bezier(.33, 1, .68, 1); }
  21% { opacity: 1; }
  42%, 100% { stroke-dashoffset: -.93; opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .comet use { animation: none; }
  .comet .c-fill { opacity: 1; }
  .comet .c-trail, .comet .c-head { opacity: 0; }
}
.p-center { position: absolute; left: 50%; top: 50%; width: 84px; height: 84px; margin: -42px; border-radius: 50%; display: grid; place-items: center; background: rgba(0, 0, 0, .5); opacity: 0; pointer-events: none; z-index: 2; }
.p-center.flash { animation: flash .5s ease-out; }
.p-center svg { width: 44px; height: 44px; }
@keyframes flash { 0% { opacity: 1; transform: scale(.8); } 100% { opacity: 0; transform: scale(1.3); } }
.p-error { position: absolute; inset: 0; z-index: 4; display: grid; place-content: center; gap: 18px; padding: 24px; text-align: center; background: rgba(0, 0, 0, .8); }
.p-error p { max-width: 560px; margin: 0; font-size: 16px; }
.p-error-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.p-error-sources { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; max-width: 720px; max-height: 45vh; overflow-y: auto; }
.p-error-sources button.failed { opacity: .55; border-style: dashed; }
.p-panel {
  position: absolute; right: clamp(12px, 3vw, 32px); bottom: 96px; z-index: 5; max-height: 60vh; overflow: auto;
  padding: 16px 20px; border-radius: 8px; background: rgba(22, 22, 30, .96); box-shadow: 0 10px 40px #000;
}
#p-tracks { display: grid; grid-template-columns: repeat(2, minmax(150px, 240px)); gap: 26px; }
@media (max-width: 560px) { #p-tracks { grid-template-columns: 1fr; left: 12px; } }
.p-panel h4 { margin: 0 0 8px; font-size: 16px; }
.p-panel ul { list-style: none; margin: 0; padding: 0; }
.p-panel li { padding: 7px 10px 7px 26px; border-radius: 4px; cursor: pointer; color: #bbb; position: relative; }
.p-panel li:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.p-panel li.on { color: #fff; font-weight: 650; }
.p-panel li.on::before { content: "✓"; position: absolute; left: 6px; }
.p-panel li.off { opacity: .4; cursor: not-allowed; }
.p-more { display: grid; gap: 8px; width: min(340px, 80vw); }
.p-file { margin: 0 0 4px; font-size: 12px; color: var(--muted); word-break: break-all; }
.p-upnext { position: absolute; right: clamp(12px, 3vw, 40px); bottom: 110px; z-index: 6; display: grid; gap: 6px; padding: 16px 20px; border-radius: 8px; background: rgba(22, 22, 30, .95); max-width: 340px; }
.p-upnext .row { margin-top: 6px; }
.p-episodes { width: min(460px, 86vw); }
.p-seasons { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.p-seen { color: var(--muted); font-weight: 400; }
/* Subtitles over the TV app's native video, where <video> renders nothing. */
.p-cues {
  position: absolute; left: 50%; bottom: 8%; z-index: 3; transform: translateX(-50%); max-width: 86%;
  padding: 2px 10px; background: rgba(0, 0, 0, .6); text-align: center; white-space: pre-line;
  font-size: clamp(18px, 2.6vw, 34px); line-height: 1.3; text-shadow: 0 0 4px #000; pointer-events: none;
}
.player:not(.idle) .p-cues { bottom: 150px; }
/* TV app 12+: Media3 draws the video under the WebView. While it plays, the
   page is see-through and everything but the player (and toasts) is hidden. */
html.native-video, html.native-video body, html.native-video .player { background: transparent; }
/* The <video> element has no source there and would only cover the native video. */
html.native-video .player video { visibility: hidden; }
html.native-video body > :not(#player):not(#toast) { visibility: hidden; }
.p-skip-intro { white-space: nowrap; }
.player.errored .p-skip-intro { visibility: hidden; }
.p-intro-editor { margin-top: 16px; border-top: 1px solid var(--line, #444); padding-top: 16px; }
.p-intro-editor p { max-width: 340px; font-size: 13px; color: #ccc; white-space: normal; }
.p-intro-editor label { display: grid; gap: 4px; flex: 1; }
.p-intro-editor input { width: 100%; min-width: 0; max-width: 140px; padding: 8px; color: #fff; background: #222; border: 1px solid #777; border-radius: 4px; }
.p-intro-editor .row { gap: 12px; }

/* ---------------------------------------------------------------- drawer / pin */
.drawer { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .6); animation: fade .2s; }
.drawer-sheet {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(880px, 100%); overflow-y: auto;
  padding: 24px 26px 40px; background: var(--bg-2); box-shadow: -10px 0 40px #000; animation: slide .25s ease-out;
}
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.drawer h2 { margin: 4px 0 18px; }
.settings-layout { display: grid; grid-template-columns: minmax(180px, 220px) minmax(0, 1fr); gap: 26px; }
.settings-nav { display: flex; flex-direction: column; gap: 5px; align-self: start; }
.settings-nav button {
  width: 100%; padding: 12px 14px; text-align: left; border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.settings-nav button:hover, .settings-nav button:focus-visible { background: var(--bg-3); color: var(--fg); }
.settings-nav button.active { background: var(--bg-3); border-color: var(--accent); color: var(--fg); font-weight: 700; }
.settings-panels { min-width: 0; }
.drawer .settings-panels section { padding: 4px 0 20px; }
.drawer h3 { margin: 0 0 16px; font-size: 18px; }
.drawer h4 { margin: 24px 0 10px; color: var(--muted); font-size: 14px; }
@media (max-width: 600px) {
  .drawer-sheet { padding: 20px 18px 36px; }
  .settings-layout { grid-template-columns: 1fr; gap: 18px; }
  .settings-nav { flex-direction: row; overflow-x: auto; padding: 2px 2px 8px; }
  .settings-nav button { width: auto; flex: 0 0 auto; white-space: nowrap; }
}
.field { display: grid; gap: 6px; margin: 10px 0; font-size: 14px; }
.field input, .profile-invite input { padding: 7px 12px; border: 1px solid var(--line); border-radius: 4px; background: var(--bg-2); }
.field input:focus-visible, .profile-invite input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.profile-invite { margin: 8px 0 14px; }
.profile-invite input { flex: 1 1 220px; color: var(--fg); }
.check { display: flex; gap: 10px; align-items: center; font-size: 14px; margin: 12px 0; cursor: pointer; }
.check input { accent-color: var(--accent-2); width: 18px; height: 18px; }
.debrid { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 8px; border-radius: 6px; background: var(--bg); }
.debrid b { text-transform: capitalize; }
.debrid .st { font-size: 13px; }
.debrid .st.ok { color: var(--ok); } .debrid .st.bad { color: var(--bad); }
.debrid .btn { margin-left: auto; }
.pin-box { position: relative; width: min(420px, 100%); padding: 30px 28px; border-radius: 10px; background: var(--bg-2); text-align: center; display: grid; gap: 14px; justify-items: center; }
.pin-box h3 { margin: 0; }
.pin-code { font: 800 38px/1 ui-monospace, monospace; letter-spacing: .2em; padding: 14px 20px; border-radius: 8px; background: var(--bg); color: var(--accent); }
.ok { color: var(--ok); } .bad { color: var(--bad); }
.node-row { display: grid; gap: 6px; padding: 12px 14px; margin-bottom: 10px; border-radius: 6px; background: var(--bg); }
.node-row .node-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.node-row .node-url { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.node-row p { margin: 0; font-size: 13px; }
.node-badge { padding: 1px 8px; border-radius: 999px; border: 1px solid var(--accent); color: var(--accent); font-size: 12px; }
.node-badge.off { border-color: var(--muted); color: var(--muted); }
.node-cmd {
  margin: 8px 0; padding: 12px 14px; border-radius: 6px; background: var(--bg); color: var(--fg);
  font: 12.5px/1.5 ui-monospace, monospace; white-space: pre-wrap; overflow-wrap: anywhere; user-select: all;
}
.node-row .node-cmd { background: var(--bg-2); }
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 90; transform: translateX(-50%);
  padding: 12px 20px; border-radius: 6px; background: #f2f2f5; color: #000; font-weight: 600;
  box-shadow: 0 6px 30px rgba(0, 0, 0, .6); animation: rise .2s ease-out; max-width: 90vw;
}
.toast.bad { background: var(--bad); color: #000; }

.resume-cta {
  position: fixed; left: 50%; bottom: 28px; z-index: 50; transform: translateX(-50%);
  display: flex; gap: 8px; align-items: center; padding: 8px 8px 8px 10px; border-radius: 10px;
  background: var(--bg-3); border: 1px solid var(--line); box-shadow: 0 8px 30px rgba(0, 0, 0, .6);
  animation: rise .2s ease-out; max-width: 92vw;
}
.resume-cta .btn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 78vw; }
.resume-cta .btn b { margin-left: 4px; }
.resume-cta .close-btn { position: static; }

/* Android TV app: D-pad focus must be visible from the sofa. */
/* Default: accent ring for anything without a specific treatment below. */
.tv-app :focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
/* Nav links and buttons get a filled pill: same copper family as the accent,
   bright enough to read from the sofa. Nav links get permanent padding so the
   pill does not shift the layout when it appears. */
.tv-app .nav a { padding: 6px 10px; border-radius: 6px; }
.tv-app .nav a:focus-visible,
.tv-app .btn:focus-visible,
.tv-app .icon-btn:focus-visible,
.tv-app .round-btn:focus-visible,
.tv-app .seg button:focus-visible,
.tv-app .mini:focus-visible {
  outline: none;
  background: var(--accent);
  color: #140d05;
  box-shadow: 0 2px 12px rgba(216, 107, 40, .45);
}
.tv-app .nav a:focus-visible { font-weight: 700; }
.tv-app .nav-more-btn:focus-visible { outline: none; background: var(--accent); border-color: var(--accent); color: #140d05; }
/* Cards: ring drawn as a shadow on the poster, and the whole card raised above
   its siblings so the top edge is never covered by the row above. */
.tv-app .card:focus-visible { outline: none; z-index: 2; }
.tv-app .card:focus-visible .art {
  transform: scale(1.05);
  box-shadow: 0 0 0 3px var(--accent-2), 0 10px 28px rgba(0, 0, 0, .6);
}
/* The slider track clips overflow, so make room for the ring and the zoom. */
.tv-app .track { padding-top: 14px; }
/* Player: volume, fullscreen and PiP belong to the TV itself. */
.tv-app .p-volume, .tv-app #p-fs, .tv-app #p-pip { display: none; }
.tv-app .p-seek:focus-visible { outline: none; }
.tv-app .p-seek:focus-visible .p-seek-track { height: 8px; }
.tv-app .p-seek:focus-visible .p-seek-thumb { transform: scale(1.3); box-shadow: 0 0 0 4px rgba(216, 107, 40, .45); }
.tv-app .p-panel li:focus-visible { outline: none; background: var(--accent); color: #140d05; }

/* ---------------------------------------------------------------- login (/login, /link) */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-box { width: min(560px, 100%); min-height: 0; padding-bottom: 0; display: grid; gap: 14px; align-content: start; }
.auth-box section { display: grid; gap: 14px; justify-items: start; align-content: start; }
.auth-box h1 { margin: 6px 0 0; font-size: 24px; }
.auth-box p { margin: 0; }
.auth-logo { height: 40px; width: auto; margin-bottom: 8px; }
.auth-options { display: grid; gap: 10px; width: min(320px, 100%); }
.auth-options .btn { width: 100%; }
.auth-device { display: flex; flex-wrap: wrap; gap: 24px; align-items: center; }
.auth-device-text { display: grid; gap: 12px; justify-items: start; flex: 1 1 240px; }
.auth-qr { width: 240px; height: 240px; padding: 0; border-radius: 10px; overflow: hidden; background: #fff; }
.auth-qr svg { width: 100%; height: 100%; display: block; }
.auth-link-form { display: grid; gap: 10px; width: 100%; }
.auth-link-form input { font: 700 22px/1 ui-monospace, monospace; letter-spacing: .12em; text-transform: uppercase; }
.auth-warn { padding: 10px 12px; border-radius: 6px; background: rgba(255, 107, 107, .12); color: var(--bad); }
.auth-error { padding: 10px 12px; border-radius: 6px; background: rgba(255, 107, 107, .12); color: var(--bad); }
.auth-page .btn:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }

/* ---------------------------------------------------------------- settings: sessions, passkeys, users */
.auth-list { list-style: none; margin: 8px 0 14px; padding: 0; display: grid; gap: 8px; }
.auth-list li { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--bg-2); font-size: 14px; }
.auth-list li > div { display: grid; gap: 2px; min-width: 0; }
.auth-list li small { color: var(--muted); }
.auth-list li .tag { color: var(--accent-2); font-size: 12px; }

/* ---------------------------------------------------------------- profiles */
.avatar {
  display: inline-grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 50%;
  background: hsl(var(--hue, 24) 55% 42%); color: #fff; font-weight: 700; font-size: 14px; line-height: 1;
}
.avatar.big { width: 72px; height: 72px; border-radius: 14px; font-size: 32px; }
.auth-list li > .profile-row { display: flex; align-items: center; gap: 10px; }
.profile-row > div { display: grid; gap: 2px; min-width: 0; }
.profile-box { width: min(560px, 100%); }
.profile-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.profile-tile {
  display: grid; justify-items: center; gap: 6px; width: 120px; padding: 12px 6px; border: 2px solid transparent;
  border-radius: 10px; background: none; color: var(--fg); cursor: pointer; font: inherit;
}
.profile-tile b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-tile small { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
.profile-tile:hover, .profile-tile:focus-visible { background: var(--bg-3); outline: none; }
.profile-tile[aria-current="true"] { border-color: var(--accent); }
.tv-app .profile-tile:focus-visible { background: var(--accent); color: #140d05; box-shadow: 0 2px 12px rgba(216, 107, 40, .45); }
.tv-app .profile-tile:focus-visible small { color: #140d05; }

/* ---------------------------------------------------------------- announcements */
.notification-banner {
  position: fixed; z-index: 300; top: 78px; left: 50%; transform: translateX(-50%);
  width: min(760px, calc(100% - 32px)); padding: 18px 22px; border: 1px solid var(--accent);
  border-radius: 12px; background: var(--bg-2); color: var(--fg);
  box-shadow: 0 12px 48px #000b;
}
.notification-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.notification-heading > div { min-width: 0; }
.notification-heading h2 { margin: 4px 0 0; font-size: 20px; overflow-wrap: anywhere; }
.notification-heading small { color: var(--muted); }
.notification-heading button { flex: none; }
#notification-message { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 40vh; overflow-y: auto; }
#notification-error { color: var(--bad); margin: 0; }
@media (max-width: 500px) {
  .notification-heading { align-items: start; flex-direction: column; }
}
