/* ==========================================================================
   Codex System Handbook — static site stylesheet
   --------------------------------------------------------------------------
   Design system shared with the Harness Handbook research blog:
   warm paper background, Source Serif 4 display + body, Inter for UI,
   IBM Plex Mono for code, hairline borders, handbook blue accent,
   sienna as a secondary editorial accent. Dark theme via html.dark.
   ========================================================================== */

/* ============================ 0. TOKENS ================================= */
:root {
  /* Ink & surfaces (light — warm paper) */
  --bg:        #faf9f6;
  --surface:   #fdfcfa;
  --ink:       #201d18;
  --ink-soft:  #4a463f;
  --muted:     #6f6a61;
  --faint:     #8d887e;
  --line:      #e6e2d8;
  --line-soft: #efece4;
  --code-bg:   #f2f0e9;

  /* Accent: handbook blue */
  --accent:      #2a78d6;
  --accent-ink:  #1c5cab;
  --accent-wash: #eaf1fb;

  /* Secondary: sienna */
  --sienna:      #bd5f16;
  --sienna-ink:  #9a4a0b;
  --sienna-wash: #f9efe3;

  --graphite:      #57534a;
  --graphite-wash: #f0eee7;

  /* Type — one serif voice for both languages:
     Latin renders in Source Serif 4, CJK falls through to Noto Serif SC / Songti */
  --font-serif: "Source Serif 4", "Noto Serif SC", "Songti SC", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --font-sans:  "Inter", "Noto Sans SC", "PingFang SC", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono:  "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --text-body: 17px;
  --lh-body:   1.72;

  --radius:    10px;
  --radius-sm: 7px;
  color-scheme: light;
}

html.dark {
  --bg:        #131311;
  --surface:   #1a1a18;
  --ink:       #eae8e1;
  --ink-soft:  #c3c0b6;
  --muted:     #9b968b;
  --faint:     #7c786e;
  --line:      #2b2a26;
  --line-soft: #23221f;
  --code-bg:   #22211d;

  --accent:      #4e92e6;
  --accent-ink:  #86b6ef;
  --accent-wash: #1a2434;

  --sienna:      #d17c40;
  --sienna-ink:  #dd9a62;
  --sienna-wash: #2d2115;

  --graphite:      #a29d92;
  --graphite-wash: #24231f;
  color-scheme: dark;
}

/* ============================ 1. BASE =================================== */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: var(--text-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background .25s ease, color .25s ease;
}
h1, h2, h3, h4 { font-family: var(--font-serif); color: var(--ink); line-height: 1.22; margin: 0; font-weight: 600; }
p { margin: 0 0 1.25em; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
em, i { font-style: italic; }
b, strong { font-weight: 600; }
code {
  font-family: var(--font-mono);
  font-size: .8em;
  background: var(--code-bg);
  padding: .1em .35em;
  border-radius: 4px;
  color: var(--ink-soft);
}
pre {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 18px;
  overflow-x: auto;
  margin: 1.1em 0;
}
pre code { background: none; padding: 0; font-size: 12.5px; line-height: 1.6; color: var(--ink-soft); }
hr { border: none; border-top: 1px solid var(--line); margin: 2.2rem 0; }
::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }

/* ============================ 2. CHROME ================================= */
.progress-bar {
  position: fixed; top: 0; left: 0; height: 2px; width: 0%;
  background: var(--accent);
  z-index: 100;
}

.topbar {
  position: sticky; top: 0; z-index: 60;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar__inner {
  max-width: 1360px; margin: 0 auto; padding: 10px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.topbar__brand {
  display: flex; align-items: center; gap: 9px;
  color: var(--ink); font-family: var(--font-serif); font-weight: 600; font-size: 16px;
}
.topbar__brand:hover { text-decoration: none; }
.brand-mark svg .bm-cover { fill: var(--accent); opacity: .16; }
.brand-mark svg .bm-page  { fill: var(--surface); stroke: var(--accent-ink); stroke-width: 1.6; }
.brand-mark svg .bm-line  { stroke: var(--accent-ink); stroke-width: 1.6; stroke-linecap: round; }
.topbar__nav { display: flex; align-items: center; gap: 18px; }
.topbar__link { font-family: var(--font-sans); font-size: 13.5px; font-weight: 500; color: var(--muted); }
.topbar__link:hover { color: var(--ink); text-decoration: none; }
.topbar__link.on { color: var(--accent-ink); font-weight: 600; }

.icon-btn {
  display: grid; place-items: center; width: 34px; height: 34px;
  border: 1px solid var(--line); border-radius: 9px; background: transparent;
  color: var(--ink-soft); cursor: pointer; transition: background .2s;
}
.icon-btn:hover { background: var(--line-soft); }
.icon-btn svg { stroke: currentColor; stroke-width: 1.7; fill: none; stroke-linecap: round; }
.icon-moon { display: none; }
html.dark .icon-sun  { display: none; }
html.dark .icon-moon { display: block; }

/* Segmented control */
.seg { display: inline-flex; background: var(--line-soft); border: 1px solid var(--line); border-radius: 9px; padding: 2px; gap: 2px; }
.seg button {
  font-family: var(--font-sans); font-size: 12.5px; font-weight: 500; color: var(--muted);
  background: none; border: none; padding: 5px 11px; border-radius: 7px; cursor: pointer;
  transition: color .15s, background .15s;
}
.seg button:hover { color: var(--ink); }
.seg button.on { color: var(--ink); background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.07); }

/* ============================ 3. LAYOUT ================================= */
.layout {
  max-width: 1360px; margin: 0 auto; padding: 0 28px;
  display: grid; grid-template-columns: 264px minmax(0, 1fr);
  gap: 48px; align-items: start;
}
.sidebar {
  position: sticky; top: 56px;
  max-height: calc(100vh - 56px);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 40px 4px 60px 0;
  scrollbar-width: thin;
}
.content {
  min-width: 0;
  padding: 44px 0 90px;
  max-width: 860px;
}
.landing { margin: 0 auto; padding: 48px 28px 90px; max-width: 880px; }
@media (max-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .sidebar { display: none; }
  .content { padding-top: 30px; }
}
@media (max-width: 720px) {
  body { font-size: 16px; }
  .layout, .landing { padding-left: 18px; padding-right: 18px; }
}

/* ============================ 4. SIDEBAR TREE =========================== */
.side-tree {
  font-family: var(--font-sans); font-size: 13px; line-height: 1.5;
  border-left: 1px solid var(--line);
}
.s-node, .s-leaf { margin: 0; }
.s-node > summary {
  list-style: none; cursor: pointer; display: flex; align-items: baseline;
  padding: 5px 10px 5px 12px; margin-left: -1px; border-left: 2px solid transparent;
}
.s-node > summary::-webkit-details-marker { display: none; }
.s-node > summary:hover { color: var(--ink); }
.s-leaf { padding: 5px 10px 5px 30px; margin-left: -1px; border-left: 2px solid transparent; }
.s-leaf:has(.cur), .s-node > summary:has(.cur) { border-left-color: var(--accent); background: color-mix(in srgb, var(--accent-wash) 55%, transparent); }
.s-kids { margin-left: 18px; border-left: 1px solid var(--line-soft); }
.s-link { color: var(--muted); }
.s-link:hover { color: var(--ink); text-decoration: none; }
.s-link.cur { color: var(--accent-ink); font-weight: 600; }
.s-num {
  font-size: 11px; font-weight: 600; color: var(--faint);
  font-variant-numeric: tabular-nums;
  margin-right: 7px; min-width: 2ch; display: inline-block;
}
.s-link.cur .s-num { color: var(--accent-ink); }

/* chevron shared by all disclosure summaries */
.chev { flex: none; width: 13px; height: 13px; margin-right: 7px; display: inline-block; align-self: center; position: relative; }
.chev::before {
  content: ""; position: absolute; left: 3px; top: 2.5px;
  width: 7px; height: 7px;
  border-right: 1.6px solid var(--muted); border-bottom: 1.6px solid var(--muted);
  transform: rotate(-45deg); transition: transform .2s;
}
details[open] > summary > .chev::before { transform: rotate(45deg); }
summary { user-select: none; }

/* ============================ 5. STAGE PAGE ============================= */
.crumbs {
  font-family: var(--font-sans); font-size: 12.5px; color: var(--faint);
  margin-bottom: 18px;
}
.crumbs .sep { margin: 0 8px; color: var(--line); }
.crumbs a { color: var(--muted); font-weight: 500; }
.crumbs a:hover { color: var(--accent-ink); text-decoration: none; }

.stage-head h1 {
  font-size: clamp(27px, 3.4vw, 36px); font-weight: 600;
  letter-spacing: -.015em; line-height: 1.18; margin: 0 0 14px;
}
.meta { display: flex; gap: 8px; align-items: center; margin-bottom: 30px; flex-wrap: wrap; }
.chip {
  font-family: var(--font-sans); font-size: 11.5px; font-weight: 650;
  letter-spacing: .1em; text-transform: uppercase; color: var(--accent-ink);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
  padding: 3px 10px; border-radius: 999px; white-space: nowrap;
}
.chip.mono { font-family: var(--font-mono); text-transform: none; letter-spacing: .02em; }
.badge-x {
  font-family: var(--font-sans); font-size: 11.5px; font-weight: 650;
  letter-spacing: .1em; text-transform: uppercase; color: var(--sienna-ink);
  border: 1px solid color-mix(in srgb, var(--sienna) 40%, var(--line));
  background: var(--sienna-wash);
  padding: 3px 10px; border-radius: 999px;
}
.intro { margin-bottom: 1.8rem; }
.intro p { margin: 0 0 1.25em; color: var(--ink-soft); }
.intro p:first-child { color: var(--ink); }

h2.sec {
  font-size: clamp(21px, 2.6vw, 25px); font-weight: 600; letter-spacing: -.012em;
  margin: 2.6rem 0 1rem; padding-top: 1.6rem; border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
}
.pill {
  font-family: var(--font-sans); font-size: 11.5px; font-weight: 650;
  color: var(--muted); background: var(--line-soft);
  border-radius: 999px; padding: 3px 10px;
  font-variant-numeric: tabular-nums;
}

/* sub-stage cards */
.sub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.sub-card {
  display: flex; flex-direction: column; gap: 3px;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 17px; background: var(--surface);
  box-shadow: 0 1px 2px rgba(20,18,12,.04);
  transition: border-color .18s, box-shadow .18s;
}
.sub-card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: 0 4px 16px rgba(20,18,12,.07);
  text-decoration: none;
}
.sub-num {
  font-family: var(--font-sans); font-size: 10.5px; font-weight: 650;
  letter-spacing: .1em; text-transform: uppercase; color: var(--accent-ink);
}
.sub-title { font-weight: 600; font-size: 15.5px; line-height: 1.45; color: var(--ink); }
.sub-count { font-family: var(--font-sans); font-size: 12px; color: var(--faint); }

/* registers */
details.registers {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); margin: 1.8rem 0; overflow: hidden;
}
details.registers > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  font-family: var(--font-sans); font-weight: 600; font-size: 14.5px; color: var(--ink);
}
details.registers > summary::-webkit-details-marker { display: none; }
details.registers > summary:hover { background: var(--line-soft); }
.reg-list { margin: 0; padding: 6px 20px 16px 24px; list-style: none; }
.reg-list li { margin: 10px 0; font-size: 15px; }
.reg-list .reg-desc { display: block; color: var(--ink-soft); margin-top: 1px; font-size: 14.5px; line-height: 1.6; }
a.reg code { color: var(--accent-ink); background: var(--accent-wash); }
a.reg:hover { text-decoration: none; }
a.reg:hover code { background: var(--accent); color: #fff; }
code.reg-def { background: var(--accent-wash); color: var(--accent-ink); scroll-margin-top: 90px; }

/* files bar */
.files-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.files-bar h2 { flex: none; }
.files-bar .spacer { flex: 1; }
.tool {
  font-family: var(--font-sans); font-size: 12.5px; font-weight: 600; color: var(--accent-ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 4px 11px; cursor: pointer;
}
.tool:hover { background: var(--accent-wash); }

/* group heading */
h3.group {
  font-family: var(--font-sans); font-size: 11.5px; font-weight: 650;
  letter-spacing: .11em; text-transform: uppercase; color: var(--faint);
  margin: 2.4rem 0 .4rem;
}
h3.group + .group-desc { margin: 0 0 1rem; }
.group-desc p { margin: .2em 0; color: var(--muted); font-size: 15px; line-height: 1.6; }

/* file cards — blog "aside" pattern */
details.file {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); margin: 9px 0;
  scroll-margin-top: 80px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(20,18,12,.04);
}
details.file[open] { box-shadow: 0 4px 18px rgba(20,18,12,.06); }
details.file > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center;
  padding: 12px 18px;
}
details.file > summary::-webkit-details-marker { display: none; }
details.file > summary:hover { background: var(--line-soft); }
details.file[open] > summary { border-bottom: 1px solid var(--line); }
code.fpath { background: none; padding: 0; font-size: 13px; color: var(--ink); font-weight: 500; }
.file-body { padding: 16px 22px 20px; }
.file-body > p { margin: .9em 0; color: var(--ink-soft); font-size: 16px; line-height: 1.68; }
.tags { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 12px; }
.tag {
  font-family: var(--font-sans); font-size: 12px; color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: 6px; padding: 3px 9px;
  background: var(--bg); white-space: nowrap;
}

/* function details */
.fns { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.fns-head {
  font-family: var(--font-sans); font-size: 11px; font-weight: 650;
  letter-spacing: .11em; text-transform: uppercase; color: var(--faint);
  margin-bottom: 10px; display: flex; gap: 8px; align-items: center;
}
details.fn {
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  margin: 5px 0; background: var(--bg);
}
details.fn > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
}
details.fn > summary::-webkit-details-marker { display: none; }
details.fn > summary:hover { background: var(--line-soft); }
details.fn > summary code { background: none; padding: 0; font-size: 13px; color: var(--accent-ink); font-weight: 500; }
.fn-range {
  margin-left: auto; font-family: var(--font-sans); font-size: 11.5px;
  color: var(--faint); font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 10px;
}
.fn-body { padding: 4px 16px 13px; }
.fn-body p { margin: .65em 0; color: var(--ink-soft); font-size: 15px; line-height: 1.65; }
.fn-body em { color: var(--muted); font-size: 13.5px; font-family: var(--font-sans); font-style: normal; }
.fn-body pre { margin: .6em 0; }

/* prev / next */
.pn {
  display: flex; justify-content: space-between; gap: 16px;
  margin-top: 3.6rem; padding-top: 1.6rem; border-top: 1px solid var(--line);
}
.pn a { display: flex; flex-direction: column; gap: 3px; max-width: 46%; }
.pn a span {
  font-family: var(--font-sans); font-size: 11.5px; font-weight: 650;
  letter-spacing: .1em; text-transform: uppercase; color: var(--faint);
}
.pn a strong { color: var(--ink); font-size: 15.5px; line-height: 1.4; font-weight: 600; }
.pn a:hover { text-decoration: none; }
.pn a:hover strong { color: var(--accent-ink); }
.pn a:hover span { color: var(--accent-ink); }
.pn-next { text-align: right; margin-left: auto; }

/* ============================ 6. LANDING ================================ */
.hero { padding: 8px 0 4px; }
.hero__kicker {
  font-family: var(--font-sans); font-size: 12px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--sienna-ink);
  margin: 0 0 18px;
}
.hero h1 {
  font-size: clamp(34px, 5vw, 48px); font-weight: 600;
  letter-spacing: -.018em; line-height: 1.08; margin: 0 0 14px;
}
.hero-sub {
  font-family: var(--font-sans); font-size: 14px; color: var(--muted);
  display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 13px 0; margin: 22px 0 0;
}
.hero-sub .dot { color: var(--line); }
.stat strong { font-family: var(--font-serif); font-size: 17px; color: var(--ink); font-weight: 600; }

details.overview {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); margin: 2rem 0 2.6rem; overflow: hidden;
}
details.overview > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  font-family: var(--font-sans); font-weight: 600; font-size: 14.5px; color: var(--ink);
}
details.overview > summary::-webkit-details-marker { display: none; }
details.overview > summary:hover { background: var(--line-soft); }
.overview-body { padding: 2px 22px 16px; }
.overview-body p { margin: 0 0 1.1em; color: var(--ink-soft); font-size: 16px; line-height: 1.7; }

.tree-bar { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; flex-wrap: wrap; }
.tree-bar h2 { font-size: 23px; font-weight: 600; letter-spacing: -.012em; margin: 0; flex: none; }
.filter {
  flex: 1; min-width: 160px; max-width: 300px; margin-left: auto;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  padding: 6px 12px; font-family: var(--font-sans); font-size: 13px;
}
.filter::placeholder { color: var(--faint); }
.filter:focus { outline: none; border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); box-shadow: 0 0 0 3px var(--accent-wash); }

/* landing tree */
details.t-node {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); margin: 9px 0; overflow: hidden;
  box-shadow: 0 1px 2px rgba(20,18,12,.04);
}
details.t-node[open] { box-shadow: 0 4px 18px rgba(20,18,12,.06); }
details.t-node > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: baseline; gap: 11px;
  padding: 13px 17px;
}
details.t-node > summary::-webkit-details-marker { display: none; }
details.t-node > summary:hover { background: var(--line-soft); }
details.t-node[open] > summary { border-bottom: 1px solid var(--line); }
details.t-node > summary .chev { align-self: center; }
.t-num {
  font-family: var(--font-sans); font-size: 11px; font-weight: 650;
  letter-spacing: .06em; color: var(--accent-ink);
  background: var(--accent-wash); border-radius: 6px; padding: 3px 8px;
  flex: none; font-variant-numeric: tabular-nums;
}
.t-link { font-weight: 600; font-size: 16px; color: var(--ink); line-height: 1.45; }
.t-link:hover { color: var(--accent-ink); text-decoration: none; }
.t-count {
  margin-left: auto; flex: none; padding-left: 10px;
  font-family: var(--font-sans); font-size: 12px; color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.t-body { padding: 12px 20px 15px; }
.t-body > p { margin: 0 0 .8em; color: var(--ink-soft); font-size: 15.5px; line-height: 1.66; }
.t-kids { margin-top: 10px; }
.t-kids details.t-node { box-shadow: none; }
.d1 .t-num, .d2 .t-num, .d3 .t-num { background: var(--line-soft); color: var(--muted); }
.d1 .t-link, .d2 .t-link, .d3 .t-link { font-size: 15px; }
.t-node .badge-x { font-size: 10px; padding: 2px 8px; align-self: center; }
.t-node.dim { display: none; }

/* ============================ 7. TABLES ================================= */
.table-wrap {
  overflow-x: auto; margin: 1.4em 0;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface);
}
table { border-collapse: collapse; font-family: var(--font-sans); font-size: 13px; min-width: 100%; }
thead th {
  text-align: left; font-size: 10.5px; font-weight: 650; letter-spacing: .09em;
  text-transform: uppercase; color: var(--faint);
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  background: var(--surface); white-space: nowrap;
}
thead th:first-child, td:first-child { padding-left: 20px; }
thead th:last-child, td:last-child { padding-right: 20px; }
td { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: top; color: var(--ink-soft); line-height: 1.55; }
tbody tr:last-child td { border-bottom: none; }

/* register page */
.content > h1 { font-size: clamp(27px, 3.4vw, 36px); letter-spacing: -.015em; margin-bottom: .6em; }
.content > h2 { font-size: 23px; margin: 1.8em 0 .7em; }

/* ============================ 8. CODE PAGES ============================= */
/* handbook -> code links */
.src-link {
  margin-left: auto; padding-left: 12px; flex: none;
  font-family: var(--font-sans); font-size: 12px; font-weight: 600;
  color: var(--accent-ink); white-space: nowrap;
}
.src-link:hover { text-decoration: underline; }
a.fn-range { text-decoration: none; }
a.fn-range:hover { color: var(--accent-ink); text-decoration: underline; }
a.code-link code { color: var(--accent-ink); }
a.code-link:hover { text-decoration: none; }
a.code-link:hover code { background: var(--accent-wash); }

/* code page layout */
.codepage { max-width: 1160px; margin: 0 auto; padding: 26px 28px 80px; }
.code-head {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
  padding: 4px 2px 12px;
}
.code-head .fpath {
  background: none; padding: 0;
  font-size: 14.5px; font-weight: 500; color: var(--ink);
}
.code-meta { font-family: var(--font-sans); font-size: 12px; color: var(--faint); }
.code-langtag { cursor: default; }

.codebox {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); overflow: hidden;
  box-shadow: 0 1px 2px rgba(20,18,12,.04);
}
#codepre {
  margin: 0; padding: 14px 0 18px;
  background: none; border: none; border-radius: 0;
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6;
  overflow-x: auto;
  counter-reset: L;
}
#codepre > i {
  display: block; font-style: normal; white-space: pre;
  min-height: 1.6em;
  counter-increment: L;
  padding: 0 20px 0 72px; position: relative;
}
#codepre > i::before {
  content: counter(L);
  position: absolute; left: 0; top: 0; width: 52px;
  text-align: right; color: var(--faint);
  font-size: 11px; line-height: 1.82;
  cursor: pointer; user-select: none;
}
#codepre > i:hover::before { color: var(--accent-ink); }
#codepre > i.hl { background: var(--accent-wash); box-shadow: inset 2px 0 0 var(--accent); }

/* token colors */
#codepre b { font-weight: 400; }
#codepre b.k { color: var(--accent-ink); font-weight: 500; }
#codepre b.s { color: var(--sienna-ink); }
#codepre b.c { color: var(--faint); font-style: italic; }
#codepre b.n { color: var(--graphite); font-weight: 500; }
#codepre b.m { color: var(--muted); }
html.dark #codepre b.n { color: var(--graphite); }

/* ============================ 9. SPLIT PANE ============================= */
/* stage layout grows a third column when code is open */
.layout.code-open {
  max-width: none;
  padding-right: 0;
  grid-template-columns: 264px minmax(0, 1fr) var(--pane-w, 46%);
  gap: 0 36px;
}
.layout.code-open .content { padding-right: 4px; }

.codepane {
  position: sticky; top: 56px;
  height: calc(100vh - 56px);
  display: flex; flex-direction: column;
  border-left: 1px solid var(--line);
  background: var(--surface);
  min-width: 0;
}
.codepane__bar {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.codepane__path {
  flex: 1; min-width: 0;
  background: none; padding: 0;
  font-size: 12px; color: var(--ink); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.codepane__act {
  flex: none; display: grid; place-items: center;
  width: 26px; height: 26px;
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--surface); color: var(--muted);
  font-family: var(--font-sans); font-size: 12px; line-height: 1;
  cursor: pointer; text-decoration: none;
}
.codepane__act:hover { color: var(--accent-ink); background: var(--accent-wash); text-decoration: none; }
.codepane__body { position: relative; flex: 1; min-height: 0; display: flex; }
.codepane__frame { border: 0; width: 100%; height: 100%; background: var(--surface); }
.codepane__resize {
  position: absolute; left: -3px; top: 0; bottom: 0; width: 7px;
  cursor: col-resize; z-index: 5;
  touch-action: none;
}
.codepane__resize:hover, .codepane__resize:active { background: color-mix(in srgb, var(--accent) 25%, transparent); }

/* narrower screens: pane replaces the nav sidebar */
@media (max-width: 1380px) {
  .layout.code-open { grid-template-columns: minmax(0, 1fr) var(--pane-w, 48%); }
  .layout.code-open .sidebar { display: none; }
}
/* mobile: pane becomes a full overlay */
@media (max-width: 760px) {
  .layout.code-open { grid-template-columns: minmax(0, 1fr); }
  .codepane {
    position: fixed; inset: 56px 0 0 0; height: auto; z-index: 70;
    border-left: none;
  }
  .codepane__resize { display: none; }
}

/* code page rendered inside the pane iframe */
html.embed .topbar { display: none; }
html.embed .codepage { padding: 0 0 30px; max-width: none; }
html.embed .code-head { display: none; } /* the pane bar already shows the path */
html.embed .codebox { border: none; border-radius: 0; box-shadow: none; }
html.embed .progress-bar { display: none; }

/* icon + text topbar links (home / back) */
.topbar__link--icon {
  display: inline-flex; align-items: center; gap: 6px;
}
.topbar__link--icon svg { flex: none; opacity: .75; }
.topbar__link--icon:hover svg { opacity: 1; }

/* filter hit counter */
.filter-count {
  font-family: var(--font-sans); font-size: 12px; color: var(--faint);
  white-space: nowrap; min-width: 56px;
  font-variant-numeric: tabular-nums;
}

/* keyword highlight (landing filter + ?hl= on stage pages) */
mark.hlt {
  background: color-mix(in srgb, var(--sienna) 26%, transparent);
  color: inherit;
  border-radius: 3px;
  padding: 0 .08em;
}
html.dark mark.hlt { background: color-mix(in srgb, var(--sienna) 38%, transparent); }

/* call-graph fn links: mono, quiet until hover */
.fn-body p a[href^="#"] {
  font-family: var(--font-mono);
  font-size: .84em;
  color: var(--accent-ink);
  border-bottom: 1px dotted color-mix(in srgb, var(--accent) 45%, transparent);
}
.fn-body p a[href^="#"]:hover { text-decoration: none; border-bottom-style: solid; }

/* author display:flex would defeat the hidden attribute — restore it */
.codepane[hidden] { display: none; }

/* function disambiguation index */
.fni-note { color: var(--muted); font-size: 15px; margin-bottom: 2rem; }
section.fni { border-top: 1px solid var(--line-soft); padding: 14px 0 6px; scroll-margin-top: 80px; }
section.fni:target { background: color-mix(in srgb, var(--accent-wash) 55%, transparent); border-radius: var(--radius-sm); padding-left: 12px; padding-right: 12px; }
section.fni h3 { display: flex; align-items: center; gap: 10px; font-size: 16px; margin: 0 0 8px; }
section.fni h3 code { background: none; padding: 0; font-size: 14px; }
section.fni ul { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
section.fni li { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; font-size: 14px; }
.fni-path code { background: none; padding: 0; font-size: 12px; color: var(--muted); }
.fni-stage { font-family: var(--font-sans); font-size: 12px; color: var(--faint); }

.fni-filter { display: block; margin: 0 0 1.6rem; max-width: 340px; }

/* external doc links (std / docs.rs) */
a.ext::after {
  content: "↗"; font-size: .72em; margin-left: 2px;
  color: var(--faint); vertical-align: text-top;
}
.fn-body p a.ext { color: var(--graphite); border-bottom-color: color-mix(in srgb, var(--graphite) 40%, transparent); }
.fn-body p a.ext:hover { color: var(--accent-ink); }

/* any handbook page inside the split pane: strip chrome, single column */
html.embed .topbar, html.embed .sidebar, html.embed .progress-bar, html.embed .crumbs { display: none; }
html.embed .layout { display: block; max-width: none; padding: 0 18px; }
html.embed .content { max-width: none; padding: 16px 0 46px; }
html.embed .codepane { display: none; }


/* terminus: function chips + fn card subtitle + blockquote/ol */
.fnchips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.fnchip { font-size: 12px; }
.fnchip code { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; }
a.fnchip:hover code { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.fn-sub { color: var(--muted); font-family: var(--font-sans); font-size: 13px; margin: 2px 0 10px; }
blockquote { margin: 1em 0; padding: 4px 0 4px 18px; border-left: 2px solid var(--accent); color: var(--ink-soft); }
blockquote p { font-size: 15px; }
ol { padding-left: 1.4em; }
ol > li { margin: .6em 0; }
.fni-note { color: var(--muted); font-size: 15px; margin-bottom: 2rem; }

/* register-interaction blocks inside fn cards */
.reg-ops { margin: .7em 0 1em; }
.reg-ops__label {
  display: block;
  font-family: var(--font-sans); font-size: 11px; font-weight: 650;
  letter-spacing: .1em; text-transform: uppercase; color: var(--faint);
  margin-bottom: 6px;
}
.reg-ops ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.reg-ops li { font-size: 14.5px; color: var(--ink-soft); line-height: 1.6; }
.reg-ops .op {
  display: inline-block; margin-right: 7px;
  font-family: var(--font-sans); font-size: 11.5px; font-weight: 600;
  color: var(--sienna-ink); background: var(--sienna-wash);
  border-radius: 6px; padding: 1px 8px; vertical-align: 1px;
}
