:root {
  --bg: #fbfaf7;
  --bg-alt: #f3f1ec;
  --card: #ffffff;
  --ink: #1d1d1f;
  --muted: #5d5d66;
  --line: #e2dfd8;
  --accent: #2f4fb3;
  --accent-ink: #ffffff;
  --v1: #1f6fb5;
  --v4: #e0a000;
  --c-mono: #1f6fb5;
  --c-low: #7aa6d6;
  --c-peak: #c0392b;
  --code-bg: #f0eee8;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 24px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121316;
      --bg-alt: #17191d;
      --card: #1d2025;
      --ink: #eceae6;
      --muted: #a3a3ad;
      --line: #2c3037;
      --accent: #8ea6ff;
      --accent-ink: #0e1120;
      --c-mono: #6aa8ea;
      --c-low: #a9c8ec;
      --c-peak: #f07a6a;
      --code-bg: #23262c;
      --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 24px rgba(0,0,0,.35);
  }
}
:root[data-theme="dark"] {
    --bg: #121316;
    --bg-alt: #17191d;
    --card: #1d2025;
    --ink: #eceae6;
    --muted: #a3a3ad;
    --line: #2c3037;
    --accent: #8ea6ff;
    --accent-ink: #0e1120;
    --c-mono: #6aa8ea;
    --c-low: #a9c8ec;
    --c-peak: #f07a6a;
    --code-bg: #23262c;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 24px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 Inter, system-ui, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
h1, h2, h3 { font-family: "Source Serif 4", Georgia, serif; font-weight: 600; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(1.7rem, 3.2vw, 2.5rem); letter-spacing: -.01em; }
h2 { font-size: clamp(1.4rem, 2.4vw, 1.9rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
code, pre, .mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .88em; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }

/* nav */
.topnav { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 52px; }
.brand { font-weight: 700; color: var(--ink); letter-spacing: .01em; }
.nav-links a { color: var(--muted); margin-left: 22px; font-size: .93rem; }
.nav-links a:hover { color: var(--ink); text-decoration: none; }
.nav-right { display: flex; align-items: center; }
.theme { margin-left: 18px; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 99px;
  padding: 3px 10px; font: inherit; font-size: .82rem; cursor: pointer; }
.theme:hover { border-color: var(--accent); }

/* hero */
.hero { padding: 48px 0 36px; }
.hero-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 40px; align-items: center; }
.badge { display: inline-block; background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: .8rem;
  letter-spacing: .06em; text-transform: uppercase; padding: 5px 12px; border-radius: 99px; margin-bottom: 18px; }
.claim { font-size: 1.12rem; color: var(--muted); margin: 14px 0 18px; }
.claim em { color: var(--ink); font-style: normal; font-weight: 600; }
.authors { font-weight: 500; }
.authors span { margin-right: 14px; white-space: nowrap; }
.affil { color: var(--muted); font-size: .88rem; margin-top: 4px; }
.buttons { margin-top: 22px; display: flex; flex-wrap: wrap; gap: 8px; }
.btn { border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 8px 14px; border-radius: 9px;
  font-weight: 500; font-size: .93rem; }
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.hero-demo { padding: 18px; }
.demo-head { display: flex; flex-direction: column; margin-bottom: 10px; }
.demo-title { font-weight: 600; }
.demo-sub { color: var(--muted); font-size: .85rem; }
.teaser-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tcell canvas { width: 100%; aspect-ratio: 1; image-rendering: pixelated; border-radius: 8px; display: block; background: #888; }
.tlabel { font-size: .78rem; color: var(--muted); margin-bottom: 4px; }
.controls { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.controls.wide { flex-wrap: wrap; }
.controls input[type=range] { flex: 1; accent-color: var(--accent); min-width: 120px; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 8px; padding: 4px 10px;
  cursor: pointer; font: inherit; font-size: .85rem; }
.img-nav { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 12px; font-size: .85rem; color: var(--muted); }
.img-nav[hidden] { display: none; }
#w-metric { margin-left: auto; }
.seg-wrap { display: flex; flex-direction: column; align-items: center; }
.seg-wrap .tlabel { margin-bottom: 2px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--card); color: var(--muted); padding: 4px 10px; cursor: pointer; font: inherit;
  font-size: .85rem; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.demo-note { color: var(--muted); font-size: .88rem; margin: 12px 0 0; }

/* tldr */
.tldr { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--bg-alt); padding: 30px 0; }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; }
.three p { color: var(--muted); font-size: .95rem; margin: 0; }

/* sections */
.section { padding: 64px 0; }
.section.alt { background: var(--bg-alt); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.lead { font-size: 1.08rem; color: var(--muted); max-width: 820px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }

/* widget */
.widget { padding: 18px; margin: 18px 0 22px; }
.wgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; align-items: start; }
.wfig { margin: 0; }
.wfig { border-radius: 8px; }
.wfig.hl { outline: 2px solid var(--accent); outline-offset: 5px; }
.pref { font-weight: 700; color: var(--accent); cursor: help; border-bottom: 1px dotted var(--accent); }
.pref:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.wfig figcaption { font-size: .8rem; color: var(--muted); margin-bottom: 4px; min-height: 2.4em; }
canvas.plot { width: 100%; aspect-ratio: 1.15; display: block; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 18px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }

/* results */
.rcard { display: grid; grid-template-columns: 1fr 1.6fr; gap: 28px; align-items: center; padding: 22px 0;
  border-bottom: 1px solid var(--line); }
.rcard:last-of-type { border-bottom: 0; }
.rcard img, .rcard video, .more img { width: 100%; border-radius: 10px; background: #fff; }
.rcard img.narrowfig { max-width: 380px; justify-self: center; }
.rtext p { color: var(--muted); }
details.more { margin-top: 18px; }
details summary { cursor: pointer; font-weight: 600; }
.more figure { margin: 18px 0; }
.more figcaption { color: var(--muted); font-size: .88rem; }

/* explorer */
.explorer { display: grid; grid-template-columns: 260px 1fr; gap: 20px; padding: 18px; margin-top: 18px; }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; align-content: start; }
.thumbs img { width: 100%; image-rendering: pixelated; border-radius: 6px; cursor: pointer; border: 2px solid transparent; }
.thumbs img.on { border-color: var(--accent); }
.xview { overflow-x: auto; }
.xcols { display: grid; grid-template-columns: 150px repeat(5, 1fr); font-size: .78rem; color: var(--muted); text-align: center; }
.xcols span:first-child { grid-column: 2; }
.xbody { display: grid; grid-template-columns: 150px 1fr; }
.xrows { display: grid; font-size: .78rem; color: var(--muted); }
.xrows div { display: flex; align-items: center; justify-content: flex-end; padding-right: 10px; text-align: right; }
.xrows div.sep { border-top: 1px dashed var(--line); }
#x-sprite { width: 100%; image-rendering: pixelated; display: block; }
.swrap { position: relative; }

/* code */
pre.code, .bib pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px;
  overflow-x: auto; margin: 0 0 12px; }
.nbcards { display: grid; gap: 10px; align-content: center; }
.nb { display: flex; gap: 14px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; color: var(--ink); }
.nb:hover { border-color: var(--accent); text-decoration: none; }
.nb b { font-family: "JetBrains Mono", monospace; color: var(--accent); min-width: 34px; }

/* cite */
details.abstract { max-width: 880px; margin-bottom: 30px; }
details.abstract p { color: var(--muted); margin-top: 12px; }
.bib { position: relative; }
.bib .copy { position: absolute; right: 10px; top: 10px; }
.foot { padding: 30px 0 40px; color: var(--muted); font-size: .85rem; }

/* responsive */
@media (max-width: 900px) {
  .hero-grid, .two, .rcard, .explorer { grid-template-columns: 1fr; }
  .three { grid-template-columns: 1fr; gap: 16px; }
  .wgrid { grid-template-columns: 1fr 1fr; }
  .nav-links a { margin-left: 12px; }
  .thumbs { grid-template-columns: repeat(6, 1fr); }
}
@media (max-width: 520px) {
  .nav-links { display: none; }
  .theme { margin-left: 0; }
  .wgrid { grid-template-columns: 1fr; }
  .xcols, .xbody { grid-template-columns: 96px 1fr; }
  .thumbs { grid-template-columns: repeat(4, 1fr); }
}
