:root, [data-theme="dark"] {
  --bg: #0b0b0c;
  --bg-soft: #131315;
  --bg-code: #151517;
  --line: #26262a;
  --text: #ecebe6;
  --muted: #9b9a94;
  --faint: #6c6b66;
  --accent: #f2f0ea;
  --mark: #2a2a2f;
  --t-delim: #8f8d86;
  --t-keyword: #f2f0ea;
  --t-string: #c9b98f;
  --t-number: #c9b98f;
  --t-filter: #b5c4a8;
  --t-name: #dedcd5;
  --t-comment: #6c6b66;
  --t-text: #a9a8a1;
  --ok: #b5c4a8;
  --bad: #e0a79a;
  --symbol: #a6f87b;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #fbfbf9;
  --bg-soft: #f2f2ef;
  --bg-code: #f4f3ef;
  --line: #e2e1dc;
  --text: #19191b;
  --muted: #5e5d58;
  --faint: #8a8984;
  --accent: #0b0b0c;
  --mark: #e8e7e2;
  --t-delim: #8a8984;
  --t-keyword: #0b0b0c;
  --t-string: #7a5d1d;
  --t-number: #7a5d1d;
  --t-filter: #3f5b2d;
  --t-name: #19191b;
  --t-comment: #8a8984;
  --t-text: #5e5d58;
  --ok: #3f5b2d;
  --bad: #9a3a26;
  --symbol: #15803d;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); }
code, pre, kbd { font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 0.875em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--bg-soft); padding: 8px 12px; }
.skip:focus { left: 8px; z-index: 30; }

/* header */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  height: 60px; padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 650; font-size: 17px; letter-spacing: 0.01em; }
.logo { width: 22px; height: 22px; color: var(--symbol); }
/* The greenhouse from the original Vein page, with its sparks. */
.hero-art { position: relative; margin: -8px 0 28px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #050907; }
.hero-art .scene { position: relative; isolation: isolate; width: 100%; min-width: 620px; aspect-ratio: 1078 / 309; left: 50%; transform: translateX(-50%); pointer-events: none; user-select: none; }
.hero-art .scene::after { content: ""; position: absolute; inset: 0; z-index: 4; background: linear-gradient(#050907, transparent 8%, transparent 87%, #050907), linear-gradient(90deg, #050907, transparent 4%, transparent 96%, #050907); }
.hero-art .art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; filter: brightness(1.19) saturate(1.08); }
.hero-art .traces, .hero-art .sparks { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-art .traces { color: #62ff99; opacity: .32; }
.hero-art .traces path { fill: none; stroke: currentColor; stroke-width: .8; stroke-linecap: round; }
.hero-art .sparks { z-index: 2; image-rendering: pixelated; }
.hero-art .halo { position: absolute; left: 62.6%; top: 13%; width: 11%; height: 31%; background: radial-gradient(ellipse, #65ff5226, #53ff6610 35%, transparent 65%); mix-blend-mode: screen; opacity: .65; }
.hero-art .scene[data-animated="true"] .halo { animation: vascula-breathe 4s ease-in-out infinite; }
@keyframes vascula-breathe { 0%, 100% { opacity: .4; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .hero-art .scene[data-animated="true"] .halo { animation: none; } .hero-art .sparks { display: none; } }
.version { color: var(--faint); font-size: 13px; font-family: ui-monospace, Menlo, monospace; }
.search { position: relative; margin-left: auto; width: min(360px, 40vw); }
.search input {
  width: 100%; height: 36px; padding: 0 34px 0 12px;
  background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 14px;
}
.search kbd { position: absolute; right: 9px; top: 8px; color: var(--faint); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; font-size: 12px; line-height: 18px; }
.results {
  position: absolute; top: 42px; left: 0; right: 0; max-height: 70vh; overflow: auto;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; padding: 6px;
  box-shadow: 0 18px 50px rgba(0,0,0,.35);
}
.results a { display: block; padding: 8px 10px; border-radius: 6px; text-decoration: none; color: var(--text); }
.results a span { display: block; color: var(--muted); font-size: 13px; }
.results a[aria-selected="true"], .results a:hover { background: var(--mark); }
.results p { margin: 8px 10px; color: var(--muted); font-size: 14px; }
.theme, .menu { background: none; border: 1px solid var(--line); color: var(--text); border-radius: 8px; width: 36px; height: 36px; font-size: 16px; cursor: pointer; }
.menu { display: none; }

/* layout */
.shell { display: grid; grid-template-columns: 250px minmax(0, 1fr) 220px; max-width: 1360px; margin: 0 auto; }
.sidebar { position: sticky; top: 60px; height: calc(100vh - 60px); overflow: auto; padding: 24px 16px 40px 24px; border-right: 1px solid var(--line); }
.nav-section { margin: 22px 0 6px; color: var(--faint); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.nav-section:first-child { margin-top: 0; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar a { display: block; padding: 4px 10px; border-radius: 6px; color: var(--muted); text-decoration: none; font-size: 14.5px; }
.sidebar a:hover { color: var(--text); }
.sidebar a[aria-current="page"] { color: var(--text); background: var(--mark); font-weight: 550; }
main { min-width: 0; padding: 40px 56px 60px; }
article { max-width: 780px; }
.toc { position: sticky; top: 60px; height: calc(100vh - 60px); overflow: auto; padding: 40px 20px 40px 0; font-size: 13.5px; }
.toc p { margin: 0 0 8px; color: var(--faint); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li.l3 { padding-left: 12px; }
.toc a { display: block; padding: 3px 0; color: var(--muted); text-decoration: none; }
.toc a:hover, .toc a.active { color: var(--text); }

/* content */
h1 { font-size: 2.3rem; line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 18px; font-weight: 700; }
h2 { font-size: 1.5rem; letter-spacing: -0.01em; margin: 2.4em 0 .6em; padding-top: .4em; border-top: 1px solid var(--line); }
h3 { font-size: 1.15rem; margin: 1.8em 0 .5em; }
h4 { font-size: 1rem; margin: 1.5em 0 .4em; }
h2, h3, h4 { position: relative; scroll-margin-top: 76px; font-weight: 650; }
.anchor { position: absolute; left: -1.1em; color: var(--faint); text-decoration: none; opacity: 0; font-weight: 400; }
h2:hover .anchor, h3:hover .anchor, h4:hover .anchor { opacity: 1; }
p, ul, ol { margin: 0 0 1em; }
li { margin: .25em 0; }
article > p:first-of-type { font-size: 1.08rem; color: var(--text); }
:not(pre) > code { background: var(--bg-code); border: 1px solid var(--line); border-radius: 5px; padding: .08em .35em; white-space: nowrap; }
td :not(pre) > code, li :not(pre) > code { white-space: normal; }
strong { font-weight: 650; }
blockquote { margin: 1.2em 0; padding: .8em 1em; border-left: 3px solid var(--faint); background: var(--bg-soft); border-radius: 0 8px 8px 0; }
blockquote p { margin: 0; }

.table { overflow-x: auto; margin: 1.2em 0 1.4em; border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
th, td { text-align: left; vertical-align: top; padding: 9px 14px; border-bottom: 1px solid var(--line); }
th { background: var(--bg-soft); font-weight: 600; color: var(--muted); font-size: 13px; }
tr:last-child td { border-bottom: none; }
th.num, td.num { text-align: right; white-space: nowrap; }

/* code */
.code { position: relative; margin: 1.1em 0 1.3em; background: var(--bg-code); border: 1px solid var(--line); border-radius: 10px; }
.code pre { margin: 0; padding: 14px 16px; overflow-x: auto; line-height: 1.55; tab-size: 4; }
.code-label { display: block; padding: 7px 16px 0; color: var(--faint); font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.code-label + .copy + pre { padding-top: 6px; }
.copy { position: absolute; top: 7px; right: 8px; background: var(--bg-soft); color: var(--muted); border: 1px solid var(--line); border-radius: 6px; font-size: 12px; padding: 2px 8px; cursor: pointer; opacity: 0; transition: opacity .15s; }
.code:hover .copy, .copy:focus { opacity: 1; }
.example { margin: 1.2em 0 1.6em; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.example .code { margin: 0; border: 0; border-radius: 0; }
.example .code + .code { border-top: 1px dashed var(--line); }
.example .part-output, .example .part-error { background: var(--bg); }
.example .part-output .code-label { color: var(--ok); }
.example .part-error .code-label { color: var(--bad); }
.example .part-error pre { color: var(--bad); }
.t-delim { color: var(--t-delim); }
.t-keyword { color: var(--t-keyword); font-weight: 600; }
.t-string { color: var(--t-string); }
.t-number { color: var(--t-number); }
.t-filter { color: var(--t-filter); }
.t-name { color: var(--t-name); }
.t-comment { color: var(--t-comment); font-style: italic; }
.t-text { color: var(--t-text); }
.t-op { color: var(--t-delim); }

/* pager and footer */
.pager { display: flex; gap: 16px; max-width: 780px; margin: 56px 0 0; }
.pager a { flex: 1; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--text); font-weight: 550; }
.pager a span { display: block; color: var(--faint); font-size: 12.5px; font-weight: 400; }
.pager .next { text-align: right; }
.pager a:hover { border-color: var(--faint); }
footer { display: flex; justify-content: space-between; gap: 16px; max-width: 780px; margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--faint); font-size: 13px; }
footer a { color: var(--muted); }

/* narrow screens */
@media (max-width: 1180px) {
  .shell { grid-template-columns: 240px minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 860px) {
  .shell { display: block; }
  .menu { display: block; }
  .sidebar { display: none; position: fixed; inset: 60px 0 0 0; z-index: 15; height: auto; background: var(--bg); border-right: 0; }
  body.nav-open .sidebar { display: block; }
  main { padding: 28px 18px 48px; }
  h1 { font-size: 1.9rem; }
  .version { display: none; }
  .search { width: auto; flex: 1; }
  .search kbd { display: none; }
  .anchor { display: none; }
}
@media print {
  .top, .sidebar, .toc, .pager, .copy { display: none; }
  .shell { display: block; }
}
