:root {
  --ink: #06090d;
  --ink-2: #0b1116;
  --panel: #10171f;
  --panel-2: #151f2a;
  --panel-3: #1a2532;
  --line: rgba(150, 180, 208, 0.13);
  --line-2: rgba(150, 180, 208, 0.22);
  --line-3: rgba(150, 180, 208, 0.34);
  --text: #e8eff6;
  --muted: #93a7bb;
  --faint: #63788c;
  --dim: #4a5c6e;
  --teal: #2ec4a6;
  --teal-2: #7fe0cb;
  --teal-dim: rgba(46, 196, 166, 0.12);
  --amber: #d4a24c;
  --amber-dim: rgba(212, 162, 76, 0.12);
  --danger: #e06b6b;
  --danger-dim: rgba(224, 107, 107, 0.11);
  --violet: #8b6bd8;
  --ok: #5ecf8a;
  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", "Consolas", monospace;
  --max: 1180px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 5rem; }
body {
  margin: 0;
  color: var(--text);
  background: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(46, 196, 166, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(46, 196, 166, 0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 85% 55% at 50% 0%, #000 15%, transparent 72%);
  -webkit-mask-image: radial-gradient(ellipse 85% 55% at 50% 0%, #000 15%, transparent 72%);
}
a { color: var(--teal); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--teal-2); }
h1, h2, h3, h4 { text-wrap: balance; }
p { text-wrap: pretty; }

.wrap { position: relative; z-index: 1; width: min(100% - 2.5rem, var(--max)); margin-inline: auto; }

/* ---------- scroll progress ---------- */
.progress {
  position: fixed; top: 0; left: 0; height: 2px; width: 0;
  background: linear-gradient(90deg, #1a8f78, var(--teal), var(--teal-2));
  z-index: 60; transition: width 0.1s linear;
}

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  background: rgba(6, 9, 13, 0.82);
  border-bottom: 1px solid var(--line);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.7rem 0; }
.brand {
  display: flex; align-items: baseline; gap: 0.6rem; flex: 0 0 auto;
  font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text); text-decoration: none;
}
.brand span { color: var(--teal); }
.brand small { color: var(--dim); letter-spacing: 0.1em; }
.nav-links {
  display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 0 0.95rem;
  font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.07em;
  text-transform: uppercase; scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a {
  color: var(--faint); text-decoration: none; white-space: nowrap;
  padding: 0.3rem 0; border-bottom: 1px solid transparent; transition: color 0.2s var(--ease);
}
.nav-links a:hover { color: var(--text); }
.nav-links a.active { color: var(--teal); border-bottom-color: var(--teal); }

/* ---------- hero ---------- */
.hero { position: relative; padding: 4rem 0 3rem; overflow: hidden; }
.hero-grid { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 3rem; align-items: end; }
.hero-kicker {
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--teal); margin: 0 0 1.1rem;
  display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap;
}
.hero-kicker::before { content: ""; width: 2rem; height: 1px; background: var(--teal); }
.hero h1 {
  font-family: var(--serif); font-weight: 500;
  font-size: clamp(2.4rem, 5.4vw, 4.1rem); line-height: 1.04;
  letter-spacing: -0.022em; margin: 0 0 1.15rem;
}
.hero-lede { color: var(--muted); font-size: 1.05rem; margin: 0 0 1.9rem; max-width: 40rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; }
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.68rem 1.1rem; border-radius: 2px; border: 1px solid var(--line-3);
  font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.09em;
  text-transform: uppercase; text-decoration: none;
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease), color 0.25s var(--ease);
}
.btn-primary { background: var(--teal); border-color: var(--teal); color: #03110d; }
.btn-primary:hover { background: var(--teal-2); color: #03110d; }
.btn-ghost { color: var(--text); background: transparent; }
.btn-ghost:hover { border-color: var(--teal); color: var(--teal); }

/* specimen sheet */
.specsheet { border: 1px solid var(--line-2); background: linear-gradient(180deg, var(--panel), var(--ink-2)); }
.specsheet-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  padding: 0.7rem 1rem; border-bottom: 1px solid var(--line-2); background: var(--panel-2);
  font-family: var(--mono); font-size: 0.65rem; letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--faint);
}
.specsheet-head b { color: var(--teal); font-weight: 500; }
.specrow {
  display: grid; grid-template-columns: 8.5rem 1fr; gap: 0.75rem;
  padding: 0.5rem 1rem; border-bottom: 1px dashed var(--line);
  font-family: var(--mono); font-size: 0.75rem;
}
.specrow:last-child { border-bottom: 0; }
.specrow dt { color: var(--faint); letter-spacing: 0.05em; text-transform: uppercase; font-size: 0.66rem; padding-top: 0.15rem; }
.specrow dd { margin: 0; color: var(--text); word-break: break-word; }
.specsheet dl { margin: 0; }
.chip {
  display: inline-block; font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.08em;
  text-transform: uppercase; padding: 0.12rem 0.4rem; border: 1px solid var(--line-2);
  color: var(--muted); border-radius: 2px; background: rgba(255,255,255,0.02);
}
.chip.ok { color: var(--ok); border-color: rgba(94, 207, 138, 0.4); }
.chip.warn { color: var(--amber); border-color: rgba(212, 162, 76, 0.4); }
.chip.bad { color: var(--danger); border-color: rgba(224, 107, 107, 0.4); }
.chip.teal { color: var(--teal); border-color: rgba(46, 196, 166, 0.4); }

.meta-strip { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); margin-top: 2.5rem; }
.meta-cell { background: var(--panel); padding: 0.9rem 1rem; }
.meta-cell .label { font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); margin-bottom: 0.3rem; }
.meta-cell .value { font-family: var(--mono); font-size: 0.84rem; color: var(--text); }

/* ---------- contents ---------- */
.toc { border-top: 1px solid var(--line); border-left: 1px solid var(--line); display: grid; grid-template-columns: repeat(3, 1fr); }
.toc a {
  display: flex; gap: 0.8rem; align-items: baseline; text-decoration: none;
  padding: 0.85rem 1rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  transition: background 0.2s var(--ease);
}
.toc a:hover { background: var(--panel); }
.toc .n { font-family: var(--mono); font-size: 0.66rem; color: var(--teal); letter-spacing: 0.1em; flex: 0 0 auto; }
.toc .t { color: var(--muted); font-size: 0.9rem; }
.toc a:hover .t { color: var(--text); }

/* ---------- sections ---------- */
.section { padding: 4.5rem 0 0.5rem; }
.section-head {
  display: grid; grid-template-columns: auto 1fr auto; gap: 1.2rem; align-items: end;
  margin-bottom: 1.6rem; padding-bottom: 0.9rem; border-bottom: 1px solid var(--line-2);
}
.sec-num { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.16em; color: var(--teal); }
.section-head h2 { font-family: var(--serif); font-weight: 500; font-size: clamp(1.7rem, 3.1vw, 2.3rem); margin: 0; letter-spacing: -0.02em; }
.sec-meta { font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); text-align: right; }
.lede { color: var(--muted); max-width: 48rem; margin: 0 0 1.5rem; }
.sub {
  font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--teal); margin: 2.2rem 0 0.85rem; display: flex; align-items: center; gap: 0.7rem;
}
.sub::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.8rem; margin: 1.4rem 0 2rem; }
.stats.five { grid-template-columns: repeat(5, 1fr); }
.stat { background: var(--panel); border: 1px solid var(--line); padding: 1.05rem 1.1rem; position: relative; overflow: hidden; }
.stat::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--teal); }
.stat.amber::after { background: var(--amber); }
.stat.red::after { background: var(--danger); }
.stat.green::after { background: var(--ok); }
.stat .n { font-family: var(--serif); font-size: 1.95rem; line-height: 1; margin-bottom: 0.4rem; font-variant-numeric: tabular-nums; }
.stat .n.sm { font-size: 1.25rem; font-family: var(--mono); letter-spacing: -0.01em; }
.stat .n.warn { color: var(--amber); }
.stat .n.ok { color: var(--ok); }
.stat .n.bad { color: var(--danger); }
.stat .l { font-family: var(--mono); font-size: 0.63rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.stat .u { font-size: 0.55em; color: var(--faint); margin-left: 0.15em; }

/* ---------- callouts ---------- */
.callout {
  border: 1px solid var(--line-3); background: var(--panel); padding: 1.05rem 1.2rem;
  margin: 1.4rem 0; display: grid; grid-template-columns: auto 1fr; gap: 0.9rem;
}
.callout.warn { border-color: rgba(212, 162, 76, 0.42); background: var(--amber-dim); }
.callout.danger { border-color: rgba(224, 107, 107, 0.4); background: var(--danger-dim); }
.callout.info { border-color: rgba(46, 196, 166, 0.38); background: var(--teal-dim); }
.callout .tag { font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--amber); padding-top: 0.25rem; white-space: nowrap; }
.callout.danger .tag { color: var(--danger); }
.callout.info .tag { color: var(--teal); }
.callout p { margin: 0; color: var(--text); font-size: 0.95rem; }
.callout p + p { margin-top: 0.6rem; }

/* ---------- cards ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.9rem; }
.card { background: var(--panel); border: 1px solid var(--line); padding: 1.15rem 1.2rem; }
.card h3 { font-family: var(--serif); font-weight: 500; font-size: 1.18rem; margin: 0 0 0.6rem; }
.card h3 .chip { vertical-align: middle; margin-left: 0.4rem; }
.card p { margin: 0; color: var(--muted); font-size: 0.94rem; }
.card p + p { margin-top: 0.65rem; }
.card ul { margin: 0.6rem 0 0; padding-left: 1.1rem; color: var(--muted); font-size: 0.9rem; }
.card li + li { margin-top: 0.3rem; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); margin: 1.1rem 0 1.6rem; background: var(--ink-2); }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 0.62rem 0.85rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th {
  font-family: var(--mono); font-size: 0.63rem; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--faint); background: var(--panel-2); font-weight: 500; white-space: nowrap;
  position: sticky; top: 0;
}
tbody tr:nth-child(odd) { background: rgba(255, 255, 255, 0.012); }
tbody tr:hover { background: rgba(46, 196, 166, 0.045); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
td.mono { font-family: var(--mono); font-size: 0.8rem; }
table.dense td, table.dense th { padding: 0.45rem 0.75rem; font-size: 0.82rem; }
code {
  font-family: var(--mono); font-size: 0.85em; background: rgba(46, 196, 166, 0.09);
  padding: 0.1em 0.34em; border-radius: 2px; color: #b7f0e2;
}
td code { background: rgba(46, 196, 166, 0.07); }
.tbl-cap {
  font-family: var(--mono); font-size: 0.63rem; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--dim); margin: -1.1rem 0 1.6rem;
}

/* ---------- figures ---------- */
.figure { background: var(--panel); border: 1px solid var(--line); padding: 1.3rem; margin: 1.2rem 0 1.8rem; }
.figure svg { width: 100%; height: auto; display: block; }
.fig-cap {
  margin-top: 0.85rem; padding-top: 0.7rem; border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 0.65rem; letter-spacing: 0.06em;
  color: var(--faint); display: flex; gap: 0.6rem; flex-wrap: wrap;
}
.fig-cap b { color: var(--teal); font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; }

/* ---------- code / hex ---------- */
pre {
  font-family: var(--mono); font-size: 0.79rem; line-height: 1.65; background: var(--ink-2);
  border: 1px solid var(--line); padding: 1.05rem 1.2rem; overflow-x: auto;
  color: #b8c9d8; margin: 1rem 0 1.6rem; white-space: pre;
}
pre .c { color: var(--dim); }
pre .k { color: var(--teal); }
pre .s { color: var(--amber); }
pre .r { color: var(--danger); }
.codeblock { position: relative; }
.codeblock .lbl {
  position: absolute; top: 0; right: 0; font-family: var(--mono); font-size: 0.58rem;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim);
  background: var(--panel-2); border-left: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 0.2rem 0.55rem;
}
.hex { display: grid; gap: 0; margin: 1rem 0 1.6rem; border: 1px solid var(--line); background: var(--ink-2); font-family: var(--mono); font-size: 0.76rem; }
.hex-row { display: grid; grid-template-columns: 5.5rem 1fr; border-bottom: 1px solid var(--line); }
.hex-row:last-child { border-bottom: 0; }
.hex-row .off { color: var(--dim); padding: 0.4rem 0.7rem; border-right: 1px solid var(--line); background: rgba(255,255,255,0.015); }
.hex-row .bytes { padding: 0.4rem 0.7rem; color: #b8c9d8; letter-spacing: 0.06em; }
.hex-row .bytes em { font-style: normal; color: var(--teal); background: rgba(46,196,166,0.13); padding: 0 0.15em; }

/* ---------- dex composition ---------- */
.dexbar { display: flex; height: 42px; border: 1px solid var(--line-2); overflow: hidden; margin: 1.1rem 0 0.6rem; background: var(--ink-2); }
.dexseg { position: relative; display: flex; align-items: center; justify-content: center; border-right: 1px solid rgba(6,9,13,0.6); transition: filter 0.25s var(--ease); }
.dexseg:last-child { border-right: 0; }
.dexseg span { font-family: var(--mono); font-size: 0.63rem; letter-spacing: 0.05em; color: #04110e; white-space: nowrap; }
.dexseg:hover { filter: brightness(1.18); }
.dexlegend { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; font-family: var(--mono); font-size: 0.66rem; color: var(--muted); margin-bottom: 1.6rem; }
.dexlegend i { display: inline-block; width: 9px; height: 9px; margin-right: 0.4rem; }

/* ---------- bars ---------- */
.bars { display: grid; gap: 0.55rem; margin: 1.1rem 0 1.8rem; }
.bar-row { display: grid; grid-template-columns: 12.5rem 1fr 3.2rem; gap: 0.75rem; align-items: center; }
.bar-row > span:first-child { font-family: var(--mono); font-size: 0.7rem; color: var(--muted); }
.bar-track { height: 7px; background: var(--panel-2); border: 1px solid var(--line); overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, #16745f, var(--teal)); transition: width 1.2s var(--ease); }
.bar-row .pct { text-align: right; color: var(--text); font-family: var(--mono); font-size: 0.72rem; font-variant-numeric: tabular-nums; }

/* ---------- steps ---------- */
.steps { counter-reset: st; list-style: none; margin: 1.1rem 0 1.6rem; padding: 0; border-left: 1px solid var(--line-2); }
.steps li { counter-increment: st; position: relative; padding: 0.55rem 0 0.55rem 2.6rem; }
.steps li::before {
  content: counter(st, decimal-leading-zero);
  position: absolute; left: -0.05rem; top: 0.6rem; transform: translateX(-50%);
  font-family: var(--mono); font-size: 0.6rem; color: var(--teal);
  background: var(--ink); border: 1px solid var(--line-2); padding: 0.05rem 0.3rem;
}
.steps li b { font-weight: 500; color: var(--text); }
.steps li p { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.9rem; }
.steps li.gate::before { color: var(--danger); border-color: rgba(224,107,107,0.5); }
.steps li.gate b { color: var(--danger); }

/* ---------- timeline ---------- */
.timeline { display: grid; gap: 0; margin: 1.2rem 0 1.8rem; border-left: 1px solid var(--line-2); }
.tl-item { position: relative; padding: 0.85rem 0 0.85rem 1.4rem; }
.tl-item::before {
  content: ""; position: absolute; left: -4px; top: 1.3rem; width: 7px; height: 7px;
  border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 3px var(--ink);
}
.tl-item .phase { font-family: var(--mono); font-size: 0.65rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--teal); margin-bottom: 0.2rem; display: flex; gap: 0.7rem; }
.tl-item .phase i { font-style: normal; color: var(--dim); }
.tl-item h3 { font-family: var(--serif); font-size: 1.1rem; font-weight: 500; margin: 0 0 0.3rem; }
.tl-item p { margin: 0; color: var(--muted); font-size: 0.92rem; }

/* ---------- ledger / kv ---------- */
.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); margin: 1.1rem 0 1.7rem; }
.kv > div { background: var(--panel); padding: 0.7rem 0.9rem; display: grid; grid-template-columns: 1fr auto; gap: 0.75rem; align-items: baseline; }
.kv .k { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--faint); }
.kv .v { font-family: var(--mono); font-size: 0.82rem; color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }
.kv .v.ok { color: var(--ok); }
.kv .v.warn { color: var(--amber); }
.kv .v.bad { color: var(--danger); }

/* ---------- footnote ---------- */
.note { font-size: 0.83rem; color: var(--faint); border-left: 1px solid var(--line-2); padding-left: 0.9rem; margin: 1.1rem 0 1.6rem; }
.note b { color: var(--muted); font-weight: 500; }

/* ---------- appendix ---------- */
.appendix { background: var(--ink-2); border: 1px solid var(--line); padding: 1.4rem 1.5rem; margin: 1.2rem 0 1.6rem; }
.appendix h3 { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.13em; text-transform: uppercase; color: var(--teal); margin: 0 0 0.9rem; font-weight: 500; }
.appendix h3 + pre { margin-top: 0; }
.cmdlist { margin: 0; padding: 0; list-style: none; font-family: var(--mono); font-size: 0.76rem; }
.cmdlist li { padding: 0.32rem 0; border-bottom: 1px dashed var(--line); color: #b8c9d8; overflow-x: auto; white-space: nowrap; }
.cmdlist li:last-child { border-bottom: 0; }
.cmdlist li::before { content: "$ "; color: var(--dim); }

.footer {
  margin-top: 4rem; padding: 2rem 0 3rem; border-top: 1px solid var(--line);
  color: var(--dim); font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.06em;
  text-transform: uppercase; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.75rem;
}

/* ---------- reveal ---------- */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .hero-grid { grid-template-columns: 1fr; gap: 2rem; }
  .meta-strip { grid-template-columns: repeat(3, 1fr); }
  .toc { grid-template-columns: repeat(2, 1fr); }
  .stats, .stats.five { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .grid-2 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 1fr; gap: 0.25rem; }
  .bar-row .pct { text-align: left; }
  .section-head { grid-template-columns: auto 1fr; }
  .sec-meta { display: none; }
  .nav-links { display: none; }
  .toc { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .stats, .stats.five, .meta-strip { grid-template-columns: 1fr; }
  .wrap { width: min(100% - 1.5rem, var(--max)); }
  .specrow { grid-template-columns: 1fr; gap: 0.1rem; }
}
