:root {
  --bg: #000000;
  --panel: #110a1c;
  --border: #2a1d3f;
  --border-strong: #3d2c58;
  --text: #ece6f5;
  --text-dim: #b3a8c5;
  --text-mute: #756a8a;
  --accent: #b78bff;
  --accent-2: #d6a8ff;
  --card: rgba(5, 2, 10, 0.55);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  --measure: 84ch;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body { background: none; min-height: 100vh; }

/* Fixed grid background layer */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: url('grid-bg.svg') center / cover no-repeat;
  pointer-events: none;
  z-index: -1;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
.ext { margin-left: 0.3em; font-size: 0.85em; vertical-align: 0.12em; }
a:hover .ext { text-decoration: none; display: inline-block; }

code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 0.05em 0.4em;
  color: var(--text);
}

/* ===== Masthead ===== */
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 600;
}
.brand:hover { text-decoration: none; }
.brand-mark { display: block; }
.brand-name { font-family: var(--mono); font-size: 16px; letter-spacing: 0; }
.masthead-gh {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-mute);
}
.masthead-gh:hover { color: var(--text); text-decoration: none; }

/* ===== Document layout ===== */
.doc {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 28px 96px;
}

/* ===== Body / reading column ===== */
.body { min-width: 0; padding-top: 72px; }
.body p { color: var(--text); }

/* Breadcrumb */
.crumb {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-mute);
  margin: 0 0 28px;
}
.crumb a { color: var(--text-dim); }
.crumb a:hover { color: var(--accent-2); }

/* Library page lede meta */
.abstract .lede .sep { color: var(--border-strong); margin: 0 0.5em; }

/* Library header: repo artwork to the left of the title */
.lib-head {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 26px;
}
.lib-mark {
  flex: none;
  height: 132px;
  width: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.lib-head-text { min-width: 0; }
.lib-head-text h1 { margin: 0 0 8px; }
.lib-head-text .lede { margin: 0; }
@media (max-width: 560px) {
  .lib-head { flex-direction: column; align-items: flex-start; gap: 16px; }
  .lib-mark { height: 104px; }
}

/* Abstract / title block */
.abstract { padding-bottom: 8px; margin-bottom: 24px; }
.abstract h1 {
  font-size: clamp(38px, 6vw, 60px);
  line-height: 1.02;
  letter-spacing: -0.03em;
  font-weight: 600;
  margin: 0 0 6px;
}
.abstract .lede {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text-mute);
  margin: 0 0 24px;
  letter-spacing: 0.01em;
}
.abstract > p {
  font-size: 19px;
  color: var(--text-dim);
  line-height: 1.55;
  margin: 0 0 22px;
}
.abstract > p a { color: var(--accent-2); }

/* Terminal block */
.term {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.75;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--card);
  padding: 16px 18px;
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text-dim);
}
.term .prompt { color: var(--text-mute); user-select: none; }
.term .cmd { color: var(--text); }
.term .comment { color: var(--text-mute); }

/* Syntax highlighting (baked-in highlight.js tokens), scoped to code blocks */
.term.code { color: var(--text); }
.term.code .hljs-comment,
.term.code .hljs-quote { color: var(--text-mute); font-style: italic; }
.term.code .hljs-keyword,
.term.code .hljs-selector-tag,
.term.code .hljs-literal { color: var(--accent); }
.term.code .hljs-string,
.term.code .hljs-regexp,
.term.code .hljs-meta .hljs-string { color: #8fd6a8; }
.term.code .hljs-number,
.term.code .hljs-symbol,
.term.code .hljs-bullet { color: var(--accent-2); }
.term.code .hljs-title,
.term.code .hljs-title.function_,
.term.code .hljs-section { color: #8ab6ff; }
.term.code .hljs-built_in,
.term.code .hljs-type,
.term.code .hljs-title.class_,
.term.code .hljs-class .hljs-title { color: var(--accent-2); }
.term.code .hljs-attr,
.term.code .hljs-property,
.term.code .hljs-variable,
.term.code .hljs-template-variable { color: #cbb8e8; }
.term.code .hljs-params { color: var(--text-dim); }
.term.code .hljs-meta,
.term.code .hljs-comment .hljs-doctag { color: var(--text-mute); }

/* ===== Section headers ===== */
.body section { padding: 60px 0 8px; scroll-margin-top: 80px; }
.body section h2 {
  display: flex;
  align-items: baseline;
  gap: 14px;
  font-size: 27px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 26px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.sec-no {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 500;
  color: var(--accent);
}
.body section h3 {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0;
  margin: 40px 0 16px;
}
.body section h3 + table { margin-top: 0; }
.body p + p { margin-top: 19px; }

/* ===== Lists (en-dash markers) ===== */
.body ul {
  margin: 20px 0;
  padding: 0;
  list-style: none;
  max-width: var(--measure);
}
.body ul li {
  position: relative;
  padding-left: 22px;
  margin-top: 12px;
  color: var(--text-dim);
  font-size: 15px;
}
.body ul li:first-child { margin-top: 0; }
.body ul li::before {
  content: "\2013";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--accent);
}
.body ul strong { color: var(--text); font-weight: 600; }

/* ===== Tables ===== */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0 8px;
  font-size: 14.5px;
}
table th {
  font-family: var(--mono);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-mute);
  font-weight: 500;
  text-align: right;
  padding: 0 16px 10px;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
table th:first-child, table td:first-child { text-align: left; }
table td {
  padding: 11px 16px;
  text-align: right;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
table td:first-child { color: var(--text); white-space: nowrap; }
table tr:last-child td { border-bottom: none; }

/* Comparison tables: highlight our row */
table.cmp td { white-space: nowrap; }
table.cmp tr.ours td {
  background: rgba(183, 139, 255, 0.08);
  color: var(--text);
  border-bottom-color: var(--border-strong);
}
table.cmp tr.ours td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
table.cmp tr.ours strong { color: var(--accent-2); }
table.cmp sup { color: var(--text-mute); font-size: 0.7em; }

/* Per-category latency heat map (fast -> slow), plus unsupported */
table.cmp .h1 { background: rgba( 74, 222, 128, 0.16); }
table.cmp .h2 { background: rgba(163, 222,  90, 0.13); }
table.cmp .h3 { background: rgba(230, 200,  90, 0.13); }
table.cmp .h4 { background: rgba(240, 150,  70, 0.15); }
table.cmp .h5 { background: rgba(240, 100,  90, 0.17); }
table.cmp .hx { background: rgba(240,  90,  90, 0.10); color: var(--text-mute); }

/* Libraries table */
table.libs td:nth-child(2) {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-mute);
  text-align: left;
  white-space: nowrap;
}
table.libs td:last-child { text-align: left; color: var(--text-dim); white-space: normal; }
table.libs td:first-child a { font-family: var(--mono); font-weight: 600; }
table.libs td.lib-cat {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-mute);
  padding: 22px 0 8px;
  border-bottom: 1px solid var(--border-strong);
}
table.libs tr:first-child td.lib-cat { padding-top: 4px; }

/* ===== Hero banner ===== */
.hero-banner { margin: 0 0 40px; }
.hero-banner img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

/* ===== Figures / diagrams ===== */
.diagram { margin: 36px 0 12px; overflow-x: auto; }
.diagram img {
  display: block;
  width: 100%;
  height: auto;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: #070608;
  padding: 10px 12px;
}
.diagram-bare img {
  border: none;
  border-radius: 0;
  background: none;
  padding: 0;
}
.diagram figcaption {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-mute);
  line-height: 1.5;
  margin-top: 12px;
}

/* ===== Notes & inline link rows ===== */
.bench-chart { display: block; width: 100%; max-width: 520px; height: auto; margin: 22px 0; }
.bench-chart-wide { max-width: 100%; border: 1px solid var(--border); border-radius: 6px; background: var(--card); padding: 14px 10px; }
.bench-note { color: var(--text-dim); font-size: 14.5px; margin-top: 22px; }
.body .footnote { color: var(--text-mute); font-size: 13px; margin-top: 10px; }
.body .footnote sup { color: var(--text-mute); }
.more {
  font-family: var(--mono);
  font-size: 13px;
  margin-top: 24px;
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
}

/* ===== Footer ===== */
.doc-footer {
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  color: var(--text-mute);
  font-size: 13px;
}
.footer-links {
  display: flex;
  gap: 22px;
  font-family: var(--mono);
  margin-bottom: 18px;
}
.footer-links a { color: var(--text-dim); }
.footer-links a:hover { color: var(--accent-2); }

/* ===== Responsive ===== */
@media (max-width: 720px) {
  .doc { padding: 0 24px 72px; }
  .body { padding-top: 44px; }
  .diagram img { min-width: 0; }
}

@media (max-width: 560px) {
  .masthead { padding: 12px 18px; }
  .doc { padding: 0 18px 56px; }
  .abstract h1 { font-size: 34px; }
  .abstract > p { font-size: 17px; }
  .abstract > p.lede { font-size: 13px; }
  .term { font-size: 12px; }
  .diagram { margin-left: -18px; margin-right: -18px; }
  .diagram img { border-radius: 0; border-left: none; border-right: none; }
}
