:root {
  --bg: #fafaf9; --surface: #ffffff; --line: #e7e5e4; --text: #1c1917; --muted: #78716c;
  --accent: #e5484d; --chip: #f0efed; --chip-on: #1c1917; --chip-on-text: #fafaf9;
  --radius: 14px; --side: 220px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f0f; --surface: #181818; --line: #2a2a2a; --text: #f1f1f1; --muted: #9a9a9a;
    --chip: #262626; --chip-on: #f1f1f1; --chip-on-text: #0f0f0f;
  }
}
* { box-sizing: border-box; }
html, body { overflow-x: clip; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }

/* Header + nav */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px;
  height: 64px; padding: 0 24px; background: var(--bg); border-bottom: 1px solid var(--line); }
.logo { font-size: 21px; letter-spacing: -.3px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.logo b { font-weight: 800; }
.mark { width: 26px; height: 18px; border-radius: 5px; background: var(--accent); position: relative; }
.mark::after { content: ""; position: absolute; left: 10px; top: 5px; border: 4px solid transparent; border-left: 7px solid #fff; }
.search { flex: 1; max-width: 560px; margin: 0 auto; }
.search input { width: 100%; height: 42px; padding: 0 16px; border-radius: 20px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; outline: none; }
.search input:focus { border-color: var(--muted); }
.about-link { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--line); color: var(--muted); font-weight: 600; }
.side { position: fixed; top: 64px; left: 0; width: var(--side); padding: 16px 12px 16px 16px; display: flex; flex-direction: column; gap: 2px; }
.side a { padding: 10px 14px; border-radius: 10px; color: var(--muted); font-size: 16px; }
.side a:hover { background: var(--chip); }
.side a.on { background: var(--chip); color: var(--text); font-weight: 600; }
main { margin-left: var(--side); padding: 24px 40px 96px 24px; min-width: 0; max-width: 2200px; }

/* Rows, chips, grid */
h1 { font-size: 26px; margin: 4px 0 18px; letter-spacing: -.3px; }
h2 { font-size: 21px; margin: 40px 0 16px; letter-spacing: -.2px; }
main > h2:first-child { margin-top: 8px; }
.sub { color: var(--muted); margin: -10px 0 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chips:last-of-type { margin-bottom: 24px; }
.chip { padding: 8px 14px; border-radius: 10px; background: var(--chip); border: 0; font-size: 15px; white-space: nowrap; }
.chip.on { background: var(--chip-on); color: var(--chip-on-text); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 36px 20px; }
.row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(320px, 380px); gap: 20px; overflow-x: auto; padding-bottom: 8px; max-width: 100%; scrollbar-width: thin; }
.card { display: block; }
.thumb { position: relative; aspect-ratio: 16/9; border-radius: var(--radius); overflow: hidden; background: var(--chip); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dur { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.8); color: #fff; font-size: 13px;
  padding: 1px 5px; border-radius: 4px; font-weight: 600; }
.prog { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); }
.card h3 { font-size: 17px; line-height: 1.35; margin: 12px 0 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta { color: var(--muted); font-size: 14px; }
.why { font-size: 14px; margin-top: 3px; color: var(--text); opacity: .85; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.recs { color: var(--accent); font-weight: 600; }
.empty { color: var(--muted); padding: 40px 0; }

/* Watch page */
.watch { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 32px; max-width: 1800px; }
.player { aspect-ratio: 16/9; background: #000; border-radius: var(--radius); overflow: hidden; }
.player iframe, .player > div { width: 100%; height: 100%; border: 0; }
.watch h1 { margin: 14px 0 6px; font-size: 20px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 18px; }
.btn { padding: 7px 14px; border-radius: 18px; background: var(--chip); border: 0; font-size: 14px; font-weight: 500; }
.btn.on { background: var(--chip-on); color: var(--chip-on-text); }
.box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; }
.box h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.context .age { font-weight: 700; }
.context ul, .ideas { margin: 6px 0 0; padding-left: 18px; }
.context li { margin: 3px 0; }
.context a.src { color: var(--muted); font-size: 12px; margin-left: 4px; }
.tldr { font-size: 16px; margin: 0; }
.chapters { list-style: none; margin: 0; padding: 0; }
.chapters li { display: flex; gap: 12px; padding: 6px 0; border-top: 1px solid var(--line); }
.chapters li:first-child { border-top: 0; }
.ts { color: var(--accent); font-variant-numeric: tabular-nums; font-weight: 600; background: none; border: 0; padding: 0; min-width: 52px; text-align: left; }
blockquote { margin: 10px 0; padding-left: 14px; border-left: 3px solid var(--accent); font-size: 16px; }
blockquote .ts { font-size: 13px; display: block; margin-top: 2px; }
.related .card { display: grid; grid-template-columns: 180px 1fr; gap: 12px; margin-bottom: 14px; }
.related .card h3 { margin-top: 0; font-size: 15px; }
.related .why { display: none; }
.reading .player { display: none; }

/* Search */
.hit { display: grid; grid-template-columns: 200px 1fr; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.hit .moments a { display: block; padding: 4px 0; }
.hit mark { background: none; color: var(--accent); font-weight: 600; }
.prose { max-width: 680px; }
.prose p { margin: 0 0 14px; }

@media (max-width: 1000px) { .watch { grid-template-columns: 1fr; } }
@media (max-width: 720px) {
  :root { --side: 0px; }
  .side { top: auto; bottom: 0; width: 100%; flex-direction: row; overflow-x: auto; padding: 6px 8px;
    background: var(--bg); border-top: 1px solid var(--line); z-index: 10; }
  .side a { padding: 8px 10px; white-space: nowrap; font-size: 14px; }
  main { padding: 16px 16px 90px; }
  .grid { grid-template-columns: 1fr; gap: 28px; }
  .row { grid-auto-columns: 82%; }
  .logo { font-size: 0; } .logo .mark { font-size: 0; }
  .hit { grid-template-columns: 1fr; }
  .related .card { grid-template-columns: 140px 1fr; }
}
.comment { padding: 10px 0; border-top: 1px solid var(--line); }
.comment:first-of-type { border-top: 0; padding-top: 0; }
.comment p { margin: 0 0 4px; white-space: pre-line; }
.donate { padding: 7px 14px; border-radius: 18px; background: var(--accent); color: #fff; font-size: 14px; font-weight: 600; white-space: nowrap; }
@media (max-width: 720px) { .donate { padding: 6px 10px; font-size: 13px; } }
.ask .chips { margin-bottom: 10px; }
.ask .actions { margin: 0; }
.themes { margin: 10px 0 0; }
.moment { padding: 14px 0; border-top: 1px solid var(--line); }
.moment:first-of-type { border-top: 0; }
.moment blockquote { margin: 6px 0; font-size: 18px; }
.moment a.ts { display: inline; }
.theme .ask { margin-top: 24px; }
.people .split { display: flex; height: 6px; border-radius: 3px; overflow: hidden; margin: 10px 0 6px; background: var(--chip); }
.people .split .r { background: #30a46c; } .people .split .n { background: var(--line); } .people .split .c { background: var(--accent); }
.people .meta a { text-decoration: underline; }
