/* ---------- Tokens ---------- */
:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efeee9;
  --ink: #121316;
  --muted: #5d6068;
  --line: #e3e1db;
  --accent: #f2b400;
  --accent-ink: #121316;
  --accent-soft: #fdf3d3;
  --ok: #1d8a4a;
  --ok-soft: #e3f4ea;
  --shadow: 0 1px 2px rgb(18 19 22 / .06), 0 8px 24px -12px rgb(18 19 22 / .18);
  --shadow-lg: 0 2px 4px rgb(18 19 22 / .06), 0 22px 44px -18px rgb(18 19 22 / .32);
  --radius: 14px;
  --radius-sm: 10px;
  --maxw: 1240px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Noto Sans Ethiopic", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0e10;
    --surface: #16171a;
    --surface-2: #1d1f23;
    --ink: #f1f0ec;
    --muted: #a2a5ad;
    --line: #2a2c31;
    --accent: #f5c12f;
    --accent-ink: #121316;
    --accent-soft: #2e2710;
    --ok: #41c97b;
    --ok-soft: #13291c;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 8px 24px -12px rgb(0 0 0 / .6);
    --shadow-lg: 0 2px 4px rgb(0 0 0 / .4), 0 22px 44px -18px rgb(0 0 0 / .8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0e10;
  --surface: #16171a;
  --surface-2: #1d1f23;
  --ink: #f1f0ec;
  --muted: #a2a5ad;
  --line: #2a2c31;
  --accent: #f5c12f;
  --accent-ink: #121316;
  --accent-soft: #2e2710;
  --ok: #41c97b;
  --ok-soft: #13291c;
  --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 8px 24px -12px rgb(0 0 0 / .6);
  --shadow-lg: 0 2px 4px rgb(0 0 0 / .4), 0 22px 44px -18px rgb(0 0 0 / .8);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
main { flex: 1; }
main:focus, main:focus-visible { outline: none; }
img, video { display: block; max-width: 100%; }
a { color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.015em; text-wrap: balance; }
p { margin: 0; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); }

.skip {
  position: absolute; left: 16px; top: -48px; z-index: 50;
  background: var(--ink); color: var(--bg); padding: 8px 12px; border-radius: 8px; text-decoration: none;
}
.skip:focus { top: 12px; }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

.eyebrow {
  font-size: 12.5px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}


/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0 24px; height: 64px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; min-width: 0; }
.logo { height: 30px; width: auto; }
/* The logo PNGs sit on a solid box; blend it into the page background. */
.logo-dark { mix-blend-mode: multiply; }
.logo-light { mix-blend-mode: screen; display: none; }
:root[data-theme="dark"] .logo-dark { display: none; }
:root[data-theme="dark"] .logo-light { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-dark { display: none; }
  :root:not([data-theme="light"]) .logo-light { display: block; }
}
.brand-sep { width: 1px; height: 24px; background: var(--line); }
.brand-label { font-weight: 650; font-size: 15px; white-space: nowrap; }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 10px; border: 1px solid transparent;
  font-size: 15px; font-weight: 620; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn.ghost { background: var(--surface); border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-2); }

/* ---------- Watched status ---------- */
.status { display: inline-flex; align-items: center; gap: 5px; font-size: 13.5px; color: var(--muted); }
.status.watched { color: var(--ok); font-weight: 600; }
.status svg { width: 14px; height: 14px; }

/* ---------- Thumbnails ---------- */
.thumb { position: relative; aspect-ratio: 16 / 10; background: #0d0e10; overflow: hidden; border-radius: var(--radius-sm); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.chip {
  position: absolute; right: 8px; bottom: 8px; z-index: 2;
  font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums;
  padding: 2px 7px; border-radius: 6px; background: rgb(0 0 0 / .75); color: #fff;
}
.play-badge {
  position: absolute; left: 50%; top: 50%; z-index: 2;
  width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 6px 18px rgb(0 0 0 / .3);
  opacity: 0; transition: opacity .15s ease;
}
.play-badge svg { width: 18px; height: 18px; margin-left: 2px; }

/* ---------- Video list ---------- */
.list { padding: 32px 24px 64px; max-width: 880px; }
.page-title { font-size: 26px; font-weight: 720; margin-bottom: 20px; }
.playlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.row {
  display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: center;
  padding: 10px; border-radius: var(--radius); text-decoration: none;
  background: var(--surface); border: 1px solid var(--line);
  transition: border-color .15s ease, background-color .15s ease;
}
.row:hover { border-color: color-mix(in srgb, var(--ink) 22%, var(--line)); }
.row:hover .play-badge, .row:focus-visible .play-badge { opacity: 1; }
.row-body { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.row-body h2 { font-size: 17px; font-weight: 650; letter-spacing: -.01em; }

/* ---------- Watch page ---------- */
.watch { padding: 24px 0 64px; }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); margin-bottom: 16px; }
.crumbs a { text-decoration: none; font-weight: 550; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.crumbs svg { width: 14px; height: 14px; }

.watch-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }

.player { position: relative; aspect-ratio: 16 / 10; background: #000; border-radius: var(--radius); overflow: hidden; }
.player video { width: 100%; height: 100%; object-fit: contain; background: #000; }

.upnext {
  position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; padding: 20px;
  background: rgb(8 9 10 / .82); color: #fff; text-align: center;
}
.upnext[hidden] { display: none; }
.upnext-card { display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 420px; }
.upnext .eyebrow { color: rgb(255 255 255 / .7); }
.upnext h3 { font-size: clamp(18px, 2.4vw, 24px); }
.upnext img { width: min(280px, 60vw); aspect-ratio: 16 / 10; object-fit: cover; border-radius: 10px; border: 1px solid rgb(255 255 255 / .15); }
.upnext .btn.ghost { background: transparent; color: #fff; border-color: rgb(255 255 255 / .3); }
.upnext .btn.ghost:hover { background: rgb(255 255 255 / .1); }
.upnext-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.countdown { font-variant-numeric: tabular-nums; }

.video-head { margin: 20px 0 6px; }
.video-head h1 { font-size: clamp(22px, 2.6vw, 28px); font-weight: 740; margin-top: 6px; }
.resume-note { font-size: 14px; color: var(--muted); min-height: 1.5em; margin-bottom: 16px; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pager a {
  display: flex; align-items: center; gap: 14px; padding: 12px 16px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.pager a:hover { border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); background: var(--surface-2); }
.pager a.next { justify-content: flex-end; text-align: right; grid-column: 2; }
.pager .dir { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.pager .t { font-weight: 650; font-size: 15px; }
.pager svg { width: 20px; height: 20px; flex: none; color: var(--muted); }

.sidebar {
  position: sticky; top: 88px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.sidebar h2 { font-size: 15px; font-weight: 700; padding: 16px 20px 12px; border-bottom: 1px solid var(--line); }
.sidebar ol { list-style: none; margin: 0; padding: 8px; max-height: calc(100vh - 230px); overflow: auto; }
.sidebar li a {
  display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: 10px; text-decoration: none; font-size: 14.5px;
}
.sidebar li a:hover { background: var(--surface-2); }
.sidebar li a[aria-current="page"] { background: var(--accent-soft); font-weight: 650; }
.sidebar .dot {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; border: 1.5px solid var(--line); color: var(--muted); font-variant-numeric: tabular-nums;
}
.sidebar .dot svg { width: 14px; height: 14px; }
.sidebar a[aria-current="page"] .dot { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.sidebar .is-watched .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.sidebar .d { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sidebar-foot { padding: 12px 20px; border-top: 1px solid var(--line); font-size: 14px; }

/* Toggle switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 38px; height: 22px; border-radius: 99px; background: var(--line); position: relative; transition: background-color .2s ease; }
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .3); transition: transform .2s ease;
}
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- Empty / 404 ---------- */
.empty { padding: 96px 24px; text-align: center; }
.empty h1 { font-size: 28px; margin-bottom: 10px; }
.empty p { color: var(--muted); margin-bottom: 24px; }
.empty code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line); }
.footer-inner { max-width: var(--maxw); margin: 0 auto; padding: 20px 24px; font-size: 13.5px; color: var(--muted); }

/* ---------- View transition ---------- */
.view { animation: rise .25s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1040px) {
  .watch-grid { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .sidebar ol { max-height: none; }
}
@media (max-width: 640px) {
  .wrap, .topbar-inner, .footer-inner { padding-left: 16px; padding-right: 16px; }
  .list { padding: 20px 16px 48px; }
  .logo { height: 24px; }
  .brand { gap: 10px; }
  .brand-label { font-size: 14px; }
  .row { grid-template-columns: 128px 1fr; gap: 14px; padding: 8px; }
  .row-body h2 { font-size: 15.5px; }
  .play-badge { display: none; }
  .watch { padding-top: 16px; }
  .player { border-radius: 10px; }
  .pager { grid-template-columns: 1fr; }
  .pager a.next { grid-column: auto; justify-content: space-between; text-align: left; }
}
