/*
 * LibChain Docs (docs.libchain.tech), in the Lib Wallet design system shared with the Hub:
 * paper-grey canvas, near-white cards, ink text, Geist Sans + Mono, soft layered shadows.
 * Code blocks are the one dark surface, like the Lib Card.
 */
@font-face { font-family: 'Geist'; src: url('/assets/geist.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Geist Mono'; src: url('/assets/geist-mono.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }

:root {
  color-scheme: light;
  --canvas: #f2f1ee; --surface: #fdfdfc; --surface-2: #f7f6f3; --surface-3: #ebeae6;
  --line: rgba(28, 27, 22, 0.075); --line-2: rgba(28, 27, 22, 0.13);
  --ink: #1c1c1e; --ink-hover: #2e2e31; --ink-2: #5f5f66; --ink-3: #96959b;
  --ink-soft: rgba(28, 28, 30, 0.055); --ink-softer: rgba(28, 28, 30, 0.035); --on-ink: #fafaf8; --focus: rgba(28, 28, 30, 0.09);
  --ok: #1d8656; --ok-soft: rgba(29, 134, 86, 0.09); --ok-line: rgba(29, 134, 86, 0.22);
  --warning: #9c5a06; --warning-soft: rgba(214, 141, 0, 0.1); --warning-line: rgba(214, 141, 0, 0.28);
  --danger: #c2383a; --danger-soft: rgba(214, 52, 52, 0.07); --danger-line: rgba(214, 52, 52, 0.22);
  --shadow-xs: 0 1px 2px rgba(28, 27, 22, 0.1);
  --shadow-1: 0 1px 2px rgba(28, 27, 22, 0.06), 0 4px 10px -2px rgba(28, 27, 22, 0.08);
  --shadow-2: 0 2px 4px rgba(28, 27, 22, 0.06), 0 14px 30px -10px rgba(28, 27, 22, 0.2);
  --shadow-3: 0 2px 6px rgba(28, 27, 22, 0.06), 0 18px 48px -12px rgba(28, 27, 22, 0.22);
  --shadow-btn: 0 1px 2px rgba(0, 0, 0, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  --font: 'Geist', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --r-sm: 10px; --r: 12px; --r-lg: 16px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1); --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --top: 64px; --side: 268px;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
/* Pinch-zoom stays; double-tap zoom (and its tap delay) goes. */
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--top) + 20px); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body { margin: 0; background: var(--canvas); color: var(--ink); font: 400 15px/1.65 var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; overflow-x: clip; }
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; transition: text-decoration-color 0.15s, color 0.15s; }
a:hover { text-decoration-color: var(--ink-2); }
:focus-visible { outline: 2px solid rgba(28, 28, 30, 0.35); outline-offset: 2px; border-radius: 6px; }
::selection { background: rgba(28, 28, 30, 0.12); }
.num { font-variant-numeric: tabular-nums; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; padding: 8px 12px; border-radius: 10px; background: var(--ink); color: var(--on-ink); }
.skip:focus { left: 8px; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
@keyframes ping { 0% { transform: scale(1); opacity: 0.55; } 80%, 100% { transform: scale(3); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toast-in { from { transform: translateY(12px) scale(0.96); opacity: 0; } }
@keyframes mark-in { from { transform: rotate(-120deg) scale(0.7); opacity: 0; } }

/* ---------- top bar ---------- */
.top { position: sticky; top: 0; z-index: 40; height: var(--top); display: flex; align-items: center; gap: 12px; padding: 0 20px; background: rgba(242, 241, 238, 0.94); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 700; letter-spacing: -0.025em; text-decoration: none; flex: none; }
.brand small { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; padding: 2px 7px; border-radius: 6px; background: var(--ink-soft); color: var(--ink-2); }
.side-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: #111; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 6px 14px -6px rgba(0, 0, 0, 0.45); flex: none; }
.mark { display: block; width: 20px; height: 20px; background: #fff; -webkit-mask: url('/assets/wheel.png') center / contain no-repeat; mask: url('/assets/wheel.png') center / contain no-repeat; animation: mark-in 0.7s var(--ease) both; transition: transform 0.9s var(--spring); }
.brand:hover .mark { transform: rotate(144deg); }
.search-btn { display: flex; align-items: center; gap: 10px; width: min(360px, 100%); height: 38px; margin-left: 28px; padding: 0 8px 0 12px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow-1); color: var(--ink-3); font-size: 14px; text-align: left; transition: border-color 0.15s; }
.search-btn:hover { border-color: rgba(28, 27, 22, 0.22); }
.search-btn span { flex: 1; }
kbd { font: 500 11.5px/1 var(--mono); padding: 4px 7px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line-2); color: var(--ink-2); }
.top-links { display: flex; gap: 2px; margin-left: auto; }
.top-links a { padding: 7px 11px; border-radius: 10px; color: var(--ink-2); font-size: 14px; font-weight: 500; text-decoration: none; }
.top-links a:hover { background: var(--ink-soft); color: var(--ink); }
.net-pill { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px 0 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-1); font-size: 12.5px; font-weight: 500; white-space: nowrap; flex: none; }
.net-dot { position: relative; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); flex: none; }
.net-dot.live { background: var(--ok); }
.net-dot.beat::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: inherit; animation: ping 2.6s var(--ease); opacity: 0; }
.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 10px; color: var(--ink-2); flex: none; transition: background 0.15s; }
.icon-btn:hover { background: var(--ink-soft); color: var(--ink); }
.burger { display: none; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); max-width: 1440px; margin: 0 auto; }
.side { position: sticky; top: var(--top); height: calc(100vh - var(--top)); overflow-y: auto; padding: 24px 14px 32px 20px; display: flex; flex-direction: column; gap: 18px; scrollbar-width: thin; }
.nav-group h6 { margin: 0 0 6px 10px; font-size: 12px; font-weight: 600; color: var(--ink-3); letter-spacing: 0.01em; }
.nav-group a { display: flex; align-items: center; height: 34px; padding: 0 10px; border-radius: 10px; color: var(--ink-2); font-size: 14px; font-weight: 500; text-decoration: none; transition: background 0.15s, color 0.15s, box-shadow 0.2s; }
.nav-group a:hover { background: var(--ink-soft); color: var(--ink); }
.nav-group a.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }
.side-foot { margin-top: auto; padding: 12px 10px 0; font-size: 12px; line-height: 17px; color: var(--ink-3); }
main { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 48px; padding: 36px 40px 80px 32px; min-width: 0; }
.doc { min-width: 0; max-width: 760px; animation: rise 0.42s var(--ease) backwards; }
.toc { position: sticky; top: calc(var(--top) + 32px); align-self: start; max-height: calc(100vh - var(--top) - 48px); overflow-y: auto; font-size: 13px; }
.toc h6 { margin: 0 0 10px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.toc a { display: block; padding: 4px 0 4px 12px; border-left: 2px solid var(--line); color: var(--ink-3); text-decoration: none; line-height: 18px; transition: color 0.15s, border-color 0.15s; }
.toc a.l3 { padding-left: 24px; }
.toc a:hover { color: var(--ink); }
.toc a.on { color: var(--ink); border-left-color: var(--ink); font-weight: 500; }
.scrim { display: none; }

/* ---------- article typography ---------- */
.crumb { margin: 0 0 8px; font-size: 13px; font-weight: 500; color: var(--ink-3); }
.doc h1 { margin: 0; font-size: 34px; line-height: 40px; font-weight: 650; letter-spacing: -0.035em; }
.lede { margin: 12px 0 28px; font-size: 17px; line-height: 27px; color: var(--ink-2); max-width: 64ch; }
.doc h2 { position: relative; margin: 44px 0 12px; padding-top: 24px; border-top: 1px solid var(--line); font-size: 22px; line-height: 30px; font-weight: 650; letter-spacing: -0.025em; }
.doc h3 { position: relative; margin: 30px 0 8px; font-size: 17px; line-height: 25px; font-weight: 600; letter-spacing: -0.015em; }
.anchor { position: absolute; left: -22px; color: var(--ink-3); text-decoration: none; opacity: 0; transition: opacity 0.15s; font-weight: 400; }
h2 .anchor { top: 24px; }
.doc h2:hover .anchor, .doc h3:hover .anchor, .anchor:focus { opacity: 1; }
.doc p, .doc li { color: #2c2c30; }
.doc p { margin: 0 0 14px; }
.doc ul, .doc ol { margin: 0 0 16px; padding-left: 22px; }
.doc li { margin: 4px 0; }
.doc li::marker { color: var(--ink-3); }
.doc strong { font-weight: 600; color: var(--ink); }
.doc code { font: 500 0.86em/1.4 var(--mono); padding: 2px 6px; border-radius: 6px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); overflow-wrap: anywhere; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.doc a code { text-decoration: none; }
.doc hr { border: 0; height: 1px; background: var(--line); margin: 32px 0; }

/* ---------- code blocks ---------- */
.code { margin: 16px 0 22px; border-radius: var(--r-lg); background: #19191c; box-shadow: 0 1px 1px rgba(0, 0, 0, 0.18), 0 14px 28px -16px rgba(20, 19, 15, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.06); overflow: hidden; }
.code figcaption { display: flex; align-items: center; justify-content: space-between; gap: 10px; height: 40px; padding: 0 8px 0 16px; border-bottom: 1px solid rgba(255, 255, 255, 0.07); font: 500 12px/1 var(--mono); color: rgba(244, 243, 240, 0.55); }
.code pre { margin: 0; padding: 16px 18px 18px; overflow-x: auto; font: 13px/1.7 var(--mono); color: #e7e6e2; tab-size: 2; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.2) transparent; }
.code code { font: inherit; padding: 0; border: 0; background: none; color: inherit; }
.code .c { color: #77767f; font-style: italic; } .code .s { color: #f0c987; } .code .k { color: #d7a6f7; } .code .n { color: #8fd3c5; } .code .t { color: #8fb1ff; } .code .f { color: #9fd6ff; }
.copy { position: relative; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: rgba(244, 243, 240, 0.6); transition: background 0.15s, color 0.15s; }
.copy::before { content: ''; width: 15px; height: 15px; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='9' width='12' height='12' rx='2.5'/%3E%3Cpath d='M5 15V5.5A2.5 2.5 0 0 1 7.5 3H15'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='9' width='12' height='12' rx='2.5'/%3E%3Cpath d='M5 15V5.5A2.5 2.5 0 0 1 7.5 3H15'/%3E%3C/svg%3E") center / contain no-repeat; }
.copy:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.copy.done { color: #7fd7a8; }
.copy.done::before { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E"); }

/* tabs: a group of code blocks with one visible */
.tabs { margin: 16px 0 22px; }
.tabs > .code { margin: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
.tab-bar { position: relative; display: flex; gap: 2px; padding: 5px 5px 0; border-radius: var(--r-lg) var(--r-lg) 0 0; background: #232327; overflow-x: auto; scrollbar-width: none; }
.tab-bar button { padding: 8px 14px 9px; border-radius: 10px 10px 0 0; font-size: 13px; font-weight: 500; color: rgba(244, 243, 240, 0.55); white-space: nowrap; transition: color 0.15s, background 0.15s; }
.tab-bar button:hover { color: #fff; }
.tab-bar button[aria-selected='true'] { background: #19191c; color: #fff; }

/* ---------- callouts, cards, steps, tables ---------- */
.callout { display: flex; gap: 12px; margin: 18px 0 22px; padding: 13px 16px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); font-size: 14.5px; line-height: 23px; }
.callout::before { content: ''; flex: none; width: 18px; height: 18px; margin-top: 2.5px; background: var(--ink-3); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5M12 8h.01'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5M12 8h.01'/%3E%3C/svg%3E") center / contain no-repeat; }
.callout > div > :last-child { margin-bottom: 0; }
.callout p { color: inherit; }
.callout.tip { background: #edf6f0; border-color: var(--ok-line); color: #17543a; } .callout.tip::before { background: var(--ok); }
.callout.warn { background: #fbf3e4; border-color: var(--warning-line); color: #6d4209; } .callout.warn::before { background: var(--warning); }
.callout.danger { background: #fcf0ef; border-color: var(--danger-line); color: #85262a; } .callout.danger::before { background: var(--danger); }
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 18px 0 26px; }
.cards.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cardlink { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); text-decoration: none; transition: transform 0.3s var(--spring), box-shadow 0.2s, border-color 0.2s; }
.cardlink:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--line-2); }
.cardlink b { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.cardlink span { font-size: 13.5px; line-height: 20px; color: var(--ink-2); }
.cardlink .ic { width: 34px; height: 34px; margin-bottom: 8px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--on-ink); font: 600 13px/1 var(--mono); box-shadow: var(--shadow-btn), 0 6px 14px -6px rgba(0, 0, 0, 0.45); }
.cardlink::after { content: '→'; position: absolute; right: 16px; top: 14px; color: var(--ink-3); transition: transform 0.3s var(--spring), color 0.2s; }
.cardlink:hover::after { transform: translateX(3px); color: var(--ink); }
ol.steps { list-style: none; counter-reset: s; padding: 0; margin: 20px 0 26px; }
ol.steps > li { position: relative; counter-increment: s; margin: 0; padding: 0 0 22px 46px; }
ol.steps > li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow-1); font: 600 13px/1 var(--font); color: var(--ink); }
ol.steps > li::after { content: ''; position: absolute; left: 14.5px; top: 36px; bottom: 6px; width: 1px; background: var(--line-2); }
ol.steps > li:last-child::after { display: none; }
ol.steps > li > b:first-child { display: block; margin: 3px 0 6px; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.table { margin: 16px 0 24px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); overflow-x: auto; }
.table table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 21px; }
.table th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--ink-3); padding: 11px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: top; color: #2c2c30; }
.table tr:last-child td { border-bottom: 0; }
.table td code { white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
.table td:first-child { min-width: 120px; }
.table table.kv td:first-child { width: 34%; }
@media (max-width: 700px) {
  /* Phones: every table becomes a stack of rows; each value carries its column name. */
  .table { overflow: visible; }
  .table table, .table tbody, .table tr, .table td { display: block; width: 100% !important; }
  .table thead { display: none; }
  .table tr { padding: 12px 16px 13px; border-bottom: 1px solid var(--line); }
  .table tr:last-child { border-bottom: 0; }
  .table td { padding: 0; border: 0; min-width: 0; }
  .table td + td { margin-top: 6px; }
  .table td:empty { display: none; }
  .table td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 2px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.01em; color: var(--ink-3); }
  .table td:first-child[data-label]::before { display: none; }
  .table td:first-child { font-weight: 600; color: var(--ink); }
  .table table.kv td:first-child:has(> strong) { font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
  .table table.kv td:first-child strong { font-weight: 600; color: inherit; }
  .table table.kv td:first-child:has(> code) { font-weight: 500; }
  .table table.kv td + td { margin-top: 3px; }
}
.pill { display: inline-flex; align-items: center; gap: 5px; height: 21px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 500; white-space: nowrap; background: var(--ink-soft); color: var(--ink-2); }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: var(--ok-soft); } .pill.no { color: var(--danger); background: var(--danger-soft); } .pill.soon { color: var(--warning); background: var(--warning-soft); }
dl.defs { margin: 16px 0 24px; }
dl.defs dt { font-weight: 600; margin-top: 16px; }
dl.defs dd { margin: 4px 0 0; color: #2c2c30; }

/* ---------- widgets ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: var(--r); border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); font-size: 14px; font-weight: 500; white-space: nowrap; text-decoration: none; transition: background 0.15s, transform 0.12s var(--ease); }
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:active:not(:disabled) { transform: scale(0.975); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); box-shadow: var(--shadow-btn); }
.btn-primary:hover:not(:disabled) { background: var(--ink-hover); }
.widget { margin: 18px 0 26px; padding: 18px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); animation: rise 0.4s var(--ease) backwards; }
.widget h4 { margin: 0 0 12px; display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.widget .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.widget input, .widget select, .widget textarea { width: 100%; min-height: 40px; padding: 0 12px; border-radius: var(--r); border: 1px solid var(--line-2); background: var(--surface); box-shadow: var(--shadow-1); outline: none; font-size: 14px; transition: border-color 0.15s, box-shadow 0.2s; }
.widget textarea { padding: 10px 12px; min-height: 64px; resize: vertical; font: 13px/1.5 var(--mono); }
.widget input:focus, .widget select:focus, .widget textarea:focus { border-color: rgba(28, 27, 22, 0.42); box-shadow: 0 0 0 4px var(--focus); }
.widget input.mono { font: 13px var(--mono); }
.widget .hint { margin-top: 6px; font-size: 12.5px; color: var(--ink-3); min-height: 18px; overflow-wrap: anywhere; }
.widget .hint.ok { color: var(--ok); } .widget .hint.bad { color: var(--danger); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.stat { padding: 12px 14px; border-radius: var(--r); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.stat small { display: block; font-size: 12px; color: var(--ink-3); font-weight: 500; }
.stat b { display: block; margin-top: 2px; font-size: 20px; line-height: 26px; font-weight: 650; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat b.bump { animation: rise 0.5s var(--ease); }
.out { margin-top: 12px; border-radius: var(--r); background: #19191c; color: #e7e6e2; font: 12.5px/1.6 var(--mono); padding: 12px 14px; max-height: 320px; overflow: auto; white-space: pre-wrap; word-break: break-all; }
.out.err { color: #ffb1a8; }
.conv-out { display: grid; gap: 8px; margin-top: 10px; }
.conv-out div { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.conv-out small { flex: none; width: 34px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.conv-out code { flex: 1; min-width: 0; border: 0 !important; background: none !important; padding: 0 !important; word-break: break-all; }
.conv-out button { flex: none; }
.spin { width: 15px; height: 15px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; }

/* previous / next, footer */
.pn { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 56px; }
.pn a { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); text-decoration: none; font-weight: 600; transition: transform 0.3s var(--spring), box-shadow 0.2s; }
.pn a:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.pn a span { display: flex; flex-direction: column; min-width: 0; }
.pn small { font-size: 12px; font-weight: 500; color: var(--ink-3); }
.pn .next { justify-content: flex-end; text-align: right; }
.pn .next span { align-items: flex-end; }
.doc-foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-3); }

/* ---------- search ---------- */
.search { position: fixed; inset: 0; z-index: 80; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; background: rgba(28, 27, 22, 0.32); animation: fade 0.18s var(--ease); }
.search-box { width: min(620px, 100%); max-height: 72vh; display: flex; flex-direction: column; border-radius: 20px; background: var(--canvas); border: 1px solid var(--line); box-shadow: var(--shadow-3); overflow: hidden; animation: dialog-in 0.25s var(--ease); }
.search-input { display: flex; align-items: center; gap: 10px; padding: 0 14px; height: 56px; background: var(--surface); border-bottom: 1px solid var(--line); color: var(--ink-3); }
.search-input input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: none; font-size: 16px; color: var(--ink); }
.search-input input::-webkit-search-cancel-button { display: none; }
.search-results { overflow-y: auto; padding: 8px; }
.search-results a { display: block; padding: 10px 12px; border-radius: var(--r); text-decoration: none; }
.search-results a[aria-selected='true'], .search-results a:hover { background: var(--surface); box-shadow: var(--shadow-1); }
.search-results b { display: block; font-size: 14px; font-weight: 600; }
.search-results small { display: block; font-size: 12px; color: var(--ink-3); }
.search-results p { margin: 3px 0 0; font-size: 13px; line-height: 19px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.search-results mark { background: rgba(214, 141, 0, 0.18); color: inherit; border-radius: 3px; padding: 0 1px; }
.search-empty { padding: 28px 12px; text-align: center; font-size: 14px; color: var(--ink-3); }

.toasts { position: fixed; left: 0; right: 0; bottom: 24px; z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; background: var(--ink); color: var(--on-ink); font-size: 13px; font-weight: 500; box-shadow: var(--shadow-3); animation: toast-in 0.3s var(--spring); }

/* ---------- responsive ---------- */
@media (max-width: 1180px) { main { grid-template-columns: minmax(0, 1fr); } .toc { display: none; } }
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; z-index: 60; top: 0; left: 0; bottom: 0; width: min(300px, 86vw); height: 100%; padding-top: 24px; background: var(--canvas); border-right: 1px solid var(--line); transform: translateX(-100%); transition: transform 0.4s var(--ease); }
  .side.open { transform: none; box-shadow: var(--shadow-3); }
  .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(28, 27, 22, 0.3); opacity: 0; visibility: hidden; transition: opacity 0.3s, visibility 0s linear 0.3s; }
  .scrim.open { opacity: 1; visibility: visible; transition: opacity 0.3s; }
  .burger { display: inline-grid; }
  .top { padding: 0 12px; gap: 8px; }
  .top-links { display: none; }
  .search-btn { margin-left: auto; width: 38px; padding: 0; justify-content: center; }
  .search-btn span, .search-btn kbd { display: none; }
  main { padding: 24px 18px 64px; }
  .doc h1 { font-size: 28px; line-height: 34px; }
  .anchor { display: none; }
  .cards, .cards.three { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pn { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 420px) { .brand small { display: none; } .net-pill .num { display: none; } .net-pill { padding: 0 10px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; } }
