:root {
  --bg: #f4f3ef; --surface: #eae8e2; --card: #fbfaf7;
  --ink: #121211; --ink-2: #55534d; --ink-3: #8a877f;
  --line: #dcd9d1; --accent: #ff5a1f;
  --random: #8a877f;
  --radius: 14px;
  --sans: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0d0c; --surface: #171715; --card: #121211;
    --ink: #ecebe6; --ink-2: #a3a199; --ink-3: #6f6d67;
    --line: #262623; --accent: #ff6a33; --random: #8a877f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0d0c; --surface: #171715; --card: #121211;
  --ink: #ecebe6; --ink-2: #a3a199; --ink-3: #6f6d67;
  --line: #262623; --accent: #ff6a33; --random: #8a877f;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 16px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration-color: var(--line); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 32px; } }

.mono, .label { font-family: var(--mono); }
.label { font-size: 12px; text-transform: lowercase; letter-spacing: 0.01em; color: var(--ink-3); }

/* top bar */
.top { border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; gap: 16px; height: 56px; }
.top .name { font-family: var(--mono); font-size: 13px; font-weight: 500; }
.top nav { margin-left: auto; display: flex; align-items: center; gap: 16px; font-family: var(--mono); font-size: 13px; color: var(--ink-2); }
.top nav a { text-decoration: none; }
.top nav a:hover { color: var(--ink); }
.theme {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line);
  background: transparent; color: var(--ink-2); cursor: pointer; display: grid; place-items: center; padding: 0;
}
.theme:hover { color: var(--ink); border-color: var(--ink-3); }
.theme svg { width: 15px; height: 15px; }

/* hero */
.hero { padding-top: 56px; padding-bottom: 32px; }
.hero h1 {
  font-size: clamp(40px, 8vw, 84px); font-weight: 500; letter-spacing: -0.045em; line-height: 0.98; margin: 12px 0 20px;
}
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p { max-width: 640px; font-size: clamp(17px, 2.1vw, 20px); color: var(--ink-2); margin: 0; letter-spacing: -0.01em; }

/* demo */
.demo { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.controls { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: end; padding: 16px; border-bottom: 1px solid var(--line); }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
button.b {
  font-family: var(--mono); font-size: 13px; text-transform: lowercase;
  height: 36px; padding: 0 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
button.b:hover { border-color: var(--ink-3); }
button.b.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); min-width: 76px; }
button.b:disabled { opacity: 0.4; cursor: default; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field select, .field input {
  font-family: var(--mono); font-size: 13px; height: 36px; padding: 0 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
.field input { width: 76px; }
.field select:focus, .field input:focus, button.b:focus-visible, .theme:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.status { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--ink-3); align-self: center; }
@media (max-width: 719px) { .status { margin-left: 0; width: 100%; } }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); border-bottom: 1px solid var(--line); }
@media (min-width: 720px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { padding: 14px 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); min-width: 0; }
.tile:nth-child(2n) { border-right: 0; }
.tile:nth-last-child(-n+2) { border-bottom: 0; }
@media (min-width: 720px) {
  .tile { border-bottom: 0; }
  .tile:nth-child(2n) { border-right: 1px solid var(--line); }
  .tile:last-child { border-right: 0; }
}
.tile .v { font-size: clamp(24px, 3.4vw, 34px); font-weight: 500; letter-spacing: -0.04em; line-height: 1.15; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .v small { font-size: 14px; color: var(--ink-3); letter-spacing: 0; font-weight: 400; }
.tile .v.acc { color: var(--accent); }

.stage { display: grid; grid-template-columns: 1fr; }
@media (min-width: 900px) { .stage { grid-template-columns: minmax(0, 1fr) 300px; } }
.chartbox { padding: 16px; min-width: 0; }
.chartbox .head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.legend i { display: inline-block; width: 14px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 6px; }
.legend .la i { border-color: var(--accent); }
.legend .lr i { border-color: var(--random); }
.legend .lb i { border-color: var(--ink-3); border-top-style: dashed; }
canvas#chart { width: 100%; height: 340px; display: block; }
@media (max-width: 719px) { canvas#chart { height: 260px; } }

.queries { padding: 16px; border-top: 1px solid var(--line); }
@media (min-width: 900px) { .queries { border-top: 0; border-left: 1px solid var(--line); } }
.queries p { font-size: 13px; color: var(--ink-2); margin: 6px 0 12px; line-height: 1.45; }
.grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.cell { min-width: 0; }
.cell canvas { width: 100%; aspect-ratio: 1; display: block; border-radius: 8px; border: 1px solid var(--line); image-rendering: pixelated; background: var(--bg); }
.cell .cap { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell .cap b { color: var(--ink); font-weight: 500; }
.cell .cap .x { color: var(--accent); }

/* write-up */
.writeup { padding-top: 72px; padding-bottom: 32px; }
.sec { display: grid; grid-template-columns: 1fr; gap: 8px 32px; padding: 32px 0; border-top: 1px solid var(--line); }
@media (min-width: 900px) { .sec { grid-template-columns: 240px minmax(0, 1fr); } }
.sec h2 { font-size: 28px; font-weight: 500; letter-spacing: -0.035em; line-height: 1.1; margin: 0; }
.sec .body { max-width: 680px; color: var(--ink-2); }
.sec .body p { margin: 0 0 14px; }
.sec .body strong { color: var(--ink); font-weight: 500; }
.sec .body ul { margin: 0 0 14px; padding-left: 18px; }
.sec .body li { margin-bottom: 8px; }
.sec code { font-family: var(--mono); font-size: 0.88em; background: var(--surface); padding: 1px 5px; border-radius: 5px; color: var(--ink); }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); margin-bottom: 14px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
th { font-family: var(--mono); font-weight: 400; font-size: 12px; color: var(--ink-3); text-transform: lowercase; }
td { color: var(--ink); font-variant-numeric: tabular-nums; }
td.hl { color: var(--accent); }
.note { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }

footer { border-top: 1px solid var(--line); padding: 24px 0 40px; font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
footer .wrap { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.classes { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); }
.classes p { margin: 6px 0 10px; }
.bars { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; align-items: end; height: 72px; }
.bar { display: flex; gap: 2px; align-items: end; height: 100%; }
.bar i { flex: 1; display: block; min-height: 1px; border-radius: 2px 2px 0 0; }
.bar i.a { background: var(--accent); }
.bar i.r { background: var(--random); opacity: 0.55; }
.bars-x { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; font-family: var(--mono); font-size: 11px; color: var(--ink-3); text-align: center; margin-top: 4px; }
