:root {
  --bg: #000;
  --s1: #0d0d0d;
  --s2: #161616;
  --s3: #1f1f1f;
  --s4: #2a2a2a;
  --line: #262626;
  --text: #ececec;
  --text2: #b4b4b4;
  --muted: #969696;
  --line-hi: #3a3a3a;
  --focus: #ffffff;
  --danger: #ff9c9c;
  --danger-line: #6b2b2b;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --hi: #fff;
  --radius: 14px;
  --side: 232px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-synthesis: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-variant-numeric: tabular-nums;
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
img { display: block; }
svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--side); background: var(--s1);
  border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 12px; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -.2px; padding: 4px 10px 18px; }
.brand img { width: 28px; height: 28px; border-radius: 7px; }
#nav-side a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--text2); font-weight: 500;
}
#nav-side a:hover { background: var(--s2); color: var(--text); }
#nav-side a.on { background: var(--s3); color: var(--hi); }
#nav-side .badge { margin-left: auto; }
.side-foot { margin-top: auto; font-size: 12px; color: var(--muted); padding: 10px 12px; }
.main { margin-left: var(--side); min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 15; display: flex; align-items: center; gap: 12px;
  padding: 12px 28px; background: rgba(0,0,0,.82); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.search { flex: 1; min-width: 0; max-width: 560px; display: flex; align-items: center; gap: 8px; background: var(--s2);
  border: 1px solid var(--line); border-radius: 999px; padding: 0 14px; height: 40px; color: var(--muted); }
.search:focus-within { border-color: #555; }
.search input { flex: 1; background: none; border: 0; outline: 0; height: 100%; min-width: 0; color: var(--text); }
.search input::-webkit-search-cancel-button { filter: invert(1) grayscale(1); }
.icon-btn { flex: none; margin-left: auto; width: 40px; height: 40px; border-radius: 999px; display: grid; place-items: center; color: var(--text2); background: var(--s2); border: 1px solid var(--line); cursor: pointer; }
.icon-btn:hover { color: var(--hi); background: var(--s3); }
#view { padding: 24px 28px 60px; max-width: 1400px; outline: none; }
.mobile-only { display: none; }
.bottombar { display: none; }

@media (max-width: 899px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .mobile-only { display: flex; }
  .topbar { padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
  .topbar .brand { padding: 0; }
  .topbar .brand span { display: none; }
  #view { padding: 16px 14px calc(90px + var(--safe-b)); }
  .bottombar {
    display: flex; position: fixed; inset: auto 0 0 0; z-index: 20; background: rgba(10,10,10,.94);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
  }
  .bottombar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 0 8px; font-size: 11px; color: var(--muted); position: relative; }
  .bottombar a.on { color: var(--hi); }
  .bottombar svg { width: 22px; height: 22px; }
  .bottombar .badge { position: absolute; top: 4px; left: calc(50% + 6px); }
}

/* ---------- common ---------- */
h1 { font-size: 26px; letter-spacing: -.4px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 30px 0 12px; display: flex; align-items: center; gap: 10px; }
h2 .count { color: var(--muted); font-weight: 500; font-size: 14px; }
.sub { color: var(--muted); margin: 0 0 18px; }
.muted { color: var(--muted); }
.badge { background: var(--hi); color: #000; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; min-width: 18px; text-align: center; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 16px;
  border-radius: 999px; border: 1px solid var(--s4); background: var(--s2); color: var(--text); font-weight: 600; font-size: 14px;
  cursor: pointer; white-space: nowrap; transition: background .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease);
}
.btn:hover { background: var(--s3); border-color: var(--line-hi); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--hi); color: #000; border-color: var(--hi); }
.btn.primary:hover { background: #d9d9d9; }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.ghost { background: transparent; }
.btn.danger:hover { border-color: var(--danger-line); color: var(--danger); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn svg { width: 17px; height: 17px; }

.tabs { display: inline-flex; background: var(--s2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; color: var(--text2); padding: 6px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 13px; }
.tabs button.on { background: var(--s4); color: var(--hi); }
.tabs button .n { color: var(--muted); font-weight: 500; margin-left: 4px; }

.card { background: var(--s1); border: 1px solid var(--line); border-radius: var(--radius); }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty h3 { color: var(--text); margin: 0 0 6px; font-size: 18px; }
.empty .btn { margin-top: 16px; }

/* posters */
.poster { aspect-ratio: 2/3; background: var(--s3) center/cover; border-radius: 10px; overflow: hidden; position: relative; }
.poster img { width: 100%; height: 100%; object-fit: cover; }
.poster.none { display: grid; place-items: center; color: var(--muted); font-size: 12px; text-align: center; padding: 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px 14px; }
@media (max-width: 520px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 14px 10px; } }
.tile { display: flex; flex-direction: column; gap: 7px; cursor: pointer; min-width: 0; }
.tile .t { font-weight: 600; font-size: 14px; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tile .m { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile:hover .poster { outline: 2px solid #555; outline-offset: 2px; }
.bar { height: 4px; background: var(--s4); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--hi); border-radius: 4px; }
.poster .bar { position: absolute; left: 6px; right: 6px; bottom: 6px; background: rgba(0,0,0,.6); }
.pill { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.78); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; }
.pill.l { right: auto; left: 6px; }

/* up next */
.upnext { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
@media (max-width: 520px) { .upnext { grid-template-columns: 1fr; } }
.un { display: flex; gap: 14px; padding: 12px; align-items: stretch; }
.un .poster { width: 74px; flex: none; }
.un .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.un .show { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.un .ep { color: var(--text2); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.un .meta { color: var(--muted); font-size: 12px; }
.un .actions { margin-top: auto; display: flex; gap: 8px; align-items: center; padding-top: 6px; }
.check {
  width: 42px; height: 42px; border-radius: 999px; border: 2px solid #4a4a4a; background: transparent; color: var(--text2);
  display: grid; place-items: center; cursor: pointer; flex: none; align-self: center; transition: all .15s;
}
.check:hover { border-color: var(--hi); color: var(--hi); }
.check.on { background: var(--hi); border-color: var(--hi); color: #000; }
.check svg { width: 20px; height: 20px; }

/* list rows (upcoming / search) */
.list { display: flex; flex-direction: column; gap: 8px; }
.li { display: flex; gap: 12px; align-items: center; padding: 10px; }
.li .poster { width: 52px; flex: none; border-radius: 8px; }
.li .body { flex: 1; min-width: 0; }
.li .t { font-weight: 600; }
.li .s { color: var(--text2); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li .m { color: var(--muted); font-size: 12px; }
.li .desc { color: var(--muted); font-size: 13px; margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.li .act { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 600px) { .li { flex-wrap: wrap; } .li .act { width: 100%; justify-content: flex-start; padding-left: 64px; } }
.day { font-size: 13px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: .6px; margin: 22px 0 8px; }
.day.today { color: var(--hi); }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--s3); color: var(--text2); border: 1px solid var(--s4); }
.tag.hi { background: var(--hi); color: #000; border-color: var(--hi); }

/* detail */
.hero { position: relative; margin: -24px -28px 0; padding: 120px 28px 24px; background: var(--s1) center 20%/cover; }
.hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.35) 0%, rgba(0,0,0,.75) 55%, #000 100%); }
.hero > * { position: relative; }
.hero-in { display: flex; gap: 24px; align-items: flex-end; }
.hero .poster { width: 170px; flex: none; box-shadow: 0 10px 40px rgba(0,0,0,.6); }
.hero h1 { font-size: 32px; }
.hero .meta { color: var(--text2); font-size: 14px; display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 6px 0 14px; }
@media (max-width: 899px) { .hero { margin: -16px -14px 0; padding: 90px 14px 18px; } }
@media (max-width: 600px) {
  .hero-in { flex-direction: column; align-items: flex-start; }
  .hero .poster { width: 120px; }
  .hero h1 { font-size: 24px; }
}
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; margin-top: 24px; }
@media (max-width: 1000px) { .detail-grid { grid-template-columns: minmax(0, 1fr); } }
.panel { padding: 16px; }
.panel h3 { margin: 0 0 10px; font-size: 14px; color: var(--text2); text-transform: uppercase; letter-spacing: .6px; }
.overview { color: var(--text2); margin: 0 0 6px; max-width: 75ch; }
.providers { display: flex; flex-direction: column; gap: 12px; }
.providers .grp { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.providers .logos { display: flex; gap: 8px; flex-wrap: wrap; }
.providers img { width: 42px; height: 42px; border-radius: 10px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.facts dt { color: var(--muted); } .facts dd { margin: 0; }
.stars { display: inline-flex; gap: 2px; }
.stars button { background: none; border: 0; padding: 2px; cursor: pointer; color: #444; }
.stars button.on { color: var(--hi); }
.stars svg { width: 24px; height: 24px; }
.progress-line { display: flex; align-items: center; gap: 12px; margin: 4px 0 2px; max-width: 520px; }
.progress-line .bar { flex: 1; height: 6px; }

.season { margin-bottom: 10px; overflow: hidden; }
.season > summary { list-style: none; display: flex; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer; user-select: none; }
.season > summary::-webkit-details-marker { display: none; }
.season > summary .chev { transition: transform .2s; color: var(--muted); }
.season[open] > summary .chev { transform: rotate(90deg); }
.season > summary .nm { font-weight: 700; white-space: nowrap; }
@media (max-width: 600px) { .season > summary .bar { display: none; } .season > summary { padding: 12px; gap: 8px; } .ep-row { padding: 10px 12px; gap: 8px; } .ep-row .no { width: 22px; } }
.season > summary .bar { width: 110px; }
.season .eps { border-top: 1px solid var(--line); }
.ep-row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.ep-row:last-child { border-bottom: 0; }
.ep-row .no { color: var(--muted); font-variant-numeric: tabular-nums; width: 34px; flex: none; font-size: 13px; }
.ep-row .body { flex: 1; min-width: 0; }
.ep-row .nm { font-weight: 500; }
.ep-row .d { font-size: 12px; color: var(--muted); }
.ep-row.future .nm { color: var(--muted); }
.ep-row.watched .nm { color: var(--text2); }
.ep-row .check { width: 34px; height: 34px; }
.ep-row .check svg { width: 16px; height: 16px; }
.ep-row .upto { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px; font-size: 12px; white-space: nowrap; }
.ep-row .upto:hover { color: var(--hi); background: var(--s3); }
.ep-row .sum { font-size: 13px; color: var(--muted); margin-top: 4px; display: none; }
.ep-row.open .sum { display: block; }

/* discover */
.rec .because { font-size: 12px; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.rec .btns { display: flex; gap: 6px; }
.rec .btns .btn { flex: 1; height: 30px; padding: 0 8px; font-size: 12px; }

/* settings */
.form { display: flex; flex-direction: column; gap: 16px; max-width: 640px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.field .hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.field .hint a { text-decoration: underline; color: var(--text2); }
.input, select.input { width: 100%; height: 42px; background: var(--s2); border: 1px solid var(--s4); border-radius: 10px; padding: 0 12px; outline: 0; }
.input:focus { border-color: #666; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.stat { padding: 14px; }
.stat b { display: block; font-size: 24px; letter-spacing: -.5px; }
.stat span { color: var(--muted); font-size: 13px; }
.notice { padding: 14px 16px; display: flex; gap: 12px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.notice p { margin: 0; flex: 1; min-width: 220px; color: var(--text2); }

/* toasts & loading */
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + var(--safe-b)); z-index: 50; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
@media (max-width: 899px) { #toasts { bottom: calc(84px + var(--safe-b)); } }
.toast { background: var(--s3); border: 1px solid var(--line-hi); color: var(--text); padding: 10px 16px; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.6); pointer-events: auto; display: flex; gap: 12px; align-items: center; animation: tin .2s ease; font-size: 14px; }
.toast button { background: none; border: 0; color: var(--hi); font-weight: 700; cursor: pointer; padding: 0; }
.toast.err { border-color: var(--danger-line); }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }
.loading { display: grid; place-items: center; padding: 70px 0; }
.spin { width: 28px; height: 28px; border: 3px solid var(--s4); border-top-color: var(--hi); border-radius: 50%; animation: sp .8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.skel { background: linear-gradient(90deg, var(--s2), var(--s3), var(--s2)); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

/* play on TV */
.btncol { display: flex; gap: 8px; align-items: center; flex: none; align-self: center; }
.check.play { border-color: #4a4a4a; }
.check.play svg { width: 18px; height: 18px; margin-left: 2px; }
.check.busy { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .4; } }

/* ---------- polish pass ---------- */
::selection { background: #e6e6e6; color: #000; }
input, select { caret-color: var(--hi); accent-color: var(--hi); }
::placeholder { color: var(--muted); opacity: 1; }
html { scrollbar-color: #3a3a3a #000; color-scheme: dark; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #000; }
::-webkit-scrollbar-thumb { background: #2e2e2e; border-radius: 10px; border: 2px solid #000; }
::-webkit-scrollbar-thumb:hover { background: #444; }

/* visible keyboard focus everywhere */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.search:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; border-color: transparent; }
.search input:focus-visible { outline: none; }
.input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
h1:focus { outline: none; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--hi); color: #000; padding: 8px 14px; border-radius: 8px; font-weight: 700; }
.skip:focus { top: 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* small inline icons replacing glyphs */
.ico-s { width: 13px; height: 13px; vertical-align: -2px; margin-right: 3px; }
.pill { display: inline-flex; align-items: center; }
.pill .ico-s { margin-right: 2px; }
.ok { color: var(--hi); display: inline-flex; align-items: center; gap: 2px; }

/* type rhythm */
h1, h2, .tile .t { text-wrap: balance; }
p, .hint, .desc, .overview, .sum { text-wrap: pretty; }
.field .hint { max-width: 68ch; }
.panel h2.ph { margin: 0 0 10px; font-size: 13px; color: var(--text2); text-transform: uppercase; letter-spacing: .06em; display: block; }

/* episode rows */
.ep-btn { all: unset; display: flex; flex-direction: column; cursor: pointer; border-radius: 6px; width: 100%; }
.ep-btn[disabled] { cursor: default; }
.ep-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.ep-btn .nm, .ep-btn .d { display: block; }
.ep-row .upto { display: inline-flex; align-items: center; gap: 2px; min-height: 34px; padding: 0 10px; }
.check.future { opacity: .35; }
.check.future:hover, .check.future:focus-visible { opacity: 1; }
@media (hover: hover) and (min-width: 900px) {
  .ep-row .upto { opacity: 0; transition: opacity .15s var(--ease); }
  .ep-row:hover .upto, .ep-row .upto:focus-visible { opacity: 1; }
}

/* hero without artwork shouldn't leave a hole */
.hero.plain { padding-top: 32px; background: none; }
.hero.plain::before { display: none; }

/* skeleton loading */
.skel-h { height: 28px; width: 180px; border-radius: 8px; margin-bottom: 24px; }
.skel-t { height: 12px; border-radius: 6px; width: 80%; margin-top: 4px; }

/* bigger touch targets on touch screens */
@media (pointer: coarse) {
  .tabs button { min-height: 40px; padding: 8px 16px; }
  .btn.small { height: 40px; }
  .stars button { padding: 8px; }
  .check { width: 46px; height: 46px; }
  .ep-row .check { width: 42px; height: 42px; }
}

/* calmer motion for people who ask for it */
@media (prefers-reduced-motion: reduce) {
  .skel, .spin, .check.busy { animation: none; }
  .toast { animation: none; }
  .season > summary .chev, .btn, .ep-row .upto { transition: none; }
}

/* filter/status tabs scroll sideways on phones instead of wrapping */
@media (max-width: 600px) {
  .tabs { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { flex: none; }
}

/* version + what's new */
.side-foot { display: flex; flex-direction: column; gap: 4px; }
.ver { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; width: fit-content; border-radius: 4px; }
.ver:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.changelog { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 18px; }
.changelog > li + li { border-top: 1px solid var(--line); padding-top: 16px; }
.cl-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cl-head time { font-size: 13px; }
.changelog ul { margin: 8px 0 0; padding-left: 18px; color: var(--text2); font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
.ver-inline { color: var(--text2); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-hi); }
.ver-inline:hover { color: var(--hi); }
