:root {
  --bg: #fbfaf8;
  --surface: #ffffff;
  --surface-2: #f3f1ed;
  --text: #1d1b18;
  --muted: #6b665e;
  --border: #e4e0d8;
  --accent: #e5532d;
  --accent-soft: #fde9e3;
  --code-bg: #f6f4f0;
  --code-text: #2b2823;
  --cmt: #8a847a;
  --ok: #2f7d4f;
  --warn: #b25b00;
  --warn-soft: #fff3e3;
  --err: #b4232c;
  --err-soft: #fdecec;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141311;
    --surface: #1c1b18;
    --surface-2: #24221f;
    --text: #ece8e1;
    --muted: #a39d93;
    --border: #33302b;
    --accent: #ff7a55;
    --accent-soft: #3a2119;
    --code-bg: #1f1d1a;
    --code-text: #e6e1d8;
    --cmt: #8c867c;
    --ok: #6cc28f;
    --warn: #f0a050;
    --warn-soft: #2e2214;
    --err: #ff8a8a;
    --err-soft: #2f1a1a;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #141311;
  --surface: #1c1b18;
  --surface-2: #24221f;
  --text: #ece8e1;
  --muted: #a39d93;
  --border: #33302b;
  --accent: #ff7a55;
  --accent-soft: #3a2119;
  --code-bg: #1f1d1a;
  --code-text: #e6e1d8;
  --cmt: #8c867c;
  --ok: #6cc28f;
  --warn: #f0a050;
  --warn-soft: #2e2214;
  --err: #ff8a8a;
  --err-soft: #2f1a1a;
  --shadow: none;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace; }
:not(pre) > code {
  background: var(--surface-2);
  padding: .1em .38em;
  border-radius: 4px;
  font-size: .88em;
}

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--text); white-space: nowrap; }
.brand svg { width: 26px; height: 26px; }
.search { flex: 1; max-width: 460px; position: relative; }
.search input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit; font-size: 14px;
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.search kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font: 12px "JetBrains Mono", monospace; color: var(--muted);
  border: 1px solid var(--border); border-radius: 4px; padding: 0 5px;
}
.spacer { flex: 1; }
.icon-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  width: 36px; height: 36px; border-radius: 8px; cursor: pointer;
  display: grid; place-items: center;
}
.icon-btn svg { width: 18px; height: 18px; }
.menu-btn { display: none; }

/* Layout */
.layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); max-width: 1280px; margin: 0 auto; }
nav.side {
  position: sticky; top: 61px; height: calc(100vh - 61px); overflow-y: auto;
  padding: 24px 16px 40px 24px;
  border-right: 1px solid var(--border);
}
nav.side h4 { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 20px 0 6px 8px; }
nav.side h4:first-child { margin-top: 0; }
nav.side a {
  display: block; padding: 5px 8px; border-radius: 6px;
  color: var(--text); font-size: 14px;
}
nav.side a:hover { background: var(--surface-2); text-decoration: none; }
nav.side a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
main { padding: 40px 48px 120px; min-width: 0; }

/* Hero */
.hero { padding: 8px 0 32px; border-bottom: 1px solid var(--border); margin-bottom: 40px; }
.hero h1 { font-size: clamp(32px, 5vw, 48px); line-height: 1.1; margin: 0 0 12px; letter-spacing: -.02em; }
.hero h1 span { color: var(--accent); }
.hero p { color: var(--muted); font-size: 18px; max-width: 640px; margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.chip { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }

/* Sections */
section { margin-bottom: 64px; }
section > h2 {
  font-size: 28px; letter-spacing: -.01em; margin: 0 0 8px;
  display: flex; align-items: baseline; gap: 10px;
}
section > h2 .num { font: 500 14px "JetBrains Mono", monospace; color: var(--accent); }
section > p.lead { color: var(--muted); margin: 0 0 24px; max-width: 720px; }
h3 { font-size: 18px; margin: 32px 0 10px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px 18px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 4px; font-size: 15px; }
.card p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }

/* Code */
.code { position: relative; }
pre {
  margin: 0; padding: 12px 14px; border-radius: 8px;
  background: var(--code-bg); color: var(--code-text);
  font-size: 13px; line-height: 1.65; overflow-x: auto;
  border: 1px solid var(--border);
}
pre .c { color: var(--cmt); }
pre .p { color: var(--accent); user-select: none; }
.copy {
  position: absolute; top: 6px; right: 6px;
  font: 500 11px Inter, sans-serif; padding: 3px 8px; border-radius: 5px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  cursor: pointer; opacity: 0; transition: opacity .15s;
}
.code:hover .copy, .copy:focus { opacity: 1; }
.copy.done { color: var(--ok); }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 8px 0 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; font-size: 13px; }
tr:last-child td { border-bottom: none; }
td code { white-space: nowrap; }
.table-wrap { overflow-x: auto; }

/* Callouts */
.note, .warn {
  border-left: 3px solid var(--accent); background: var(--accent-soft);
  padding: 12px 16px; border-radius: 0 8px 8px 0; margin: 16px 0; font-size: 14.5px;
}
.warn { border-color: var(--warn); background: var(--warn-soft); }
.note strong, .warn strong { display: block; margin-bottom: 2px; }

/* Diagrams */
.diagram { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 20px; margin: 16px 0 24px; overflow-x: auto; }
.diagram svg { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.diagram text { font-family: Inter, sans-serif; fill: var(--text); }
.diagram .lbl { font-size: 13px; font-weight: 600; }
.diagram .sub { font-size: 11px; fill: var(--muted); }
.diagram .box { fill: var(--surface-2); stroke: var(--border); }
.diagram .arrow { stroke: var(--accent); stroke-width: 1.6; fill: none; }
.diagram .arrow-t { font-family: "JetBrains Mono", monospace; font-size: 11px; fill: var(--accent); }
.diagram .commit { fill: var(--surface); stroke: var(--text); stroke-width: 2; }
.diagram .commit.alt { stroke: var(--accent); }
.diagram .line { stroke: var(--text); stroke-width: 2; fill: none; }
.diagram .line.alt { stroke: var(--accent); }
.diagram .tag { font-family: "JetBrains Mono", monospace; font-size: 11px; }
.diagram-caption { text-align: center; font-size: 13px; color: var(--muted); margin-top: 10px; }

.hidden { display: none !important; }
/* Troubleshooting */
.group-h { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 32px 0 12px; }
.group-h:first-of-type { margin-top: 8px; }
.err {
  font: 12.5px/1.5 "JetBrains Mono", monospace;
  color: var(--err); background: var(--err-soft);
  padding: 7px 10px; border-radius: 6px; margin: 6px 0 10px;
  overflow-wrap: anywhere;
}
.card .why { font-size: 13.5px; }
.card .why b { color: var(--text); font-weight: 600; }
.no-results { display: none; padding: 40px; text-align: center; color: var(--muted); }
mark { background: var(--accent-soft); color: inherit; padding: 0 2px; border-radius: 2px; }

footer { border-top: 1px solid var(--border); padding-top: 24px; color: var(--muted); font-size: 14px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  nav.side {
    position: fixed; top: 61px; left: 0; bottom: 0; width: 280px; z-index: 15;
    background: var(--bg); transform: translateX(-100%); transition: transform .2s;
    height: auto;
  }
  nav.side.open { transform: none; box-shadow: 4px 0 24px rgba(0,0,0,.15); }
  .menu-btn { display: grid; }
  main { padding: 28px 16px 80px; }
  .grid { grid-template-columns: 1fr; }
  .topbar { padding: 12px 16px; gap: 10px; }
  .brand span { display: none; }
  .search kbd { display: none; }
}

/* ---- multi-page additions ---- */
.pager{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-top:40px}
.pager a{display:grid;gap:2px;padding:14px 16px;border:1px solid var(--border);border-radius:8px;text-decoration:none;background:var(--surface);min-width:0}
.pager a:hover{border-color:var(--accent)}
.pager a.next{text-align:right;grid-column:2}
.pager small{font-size:.75rem;letter-spacing:.06em;text-transform:uppercase;opacity:.7}
.crumbs{font-size:.85rem;margin-bottom:12px;opacity:.8}
.crumbs a{text-decoration:none}
.toc-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:12px;margin-top:8px}
.toc-grid a{display:grid;gap:4px;align-content:start;padding:14px 16px;border:1px solid var(--border);border-radius:8px;background:var(--surface);text-decoration:none;color:inherit;min-width:0}
.toc-grid a:hover{border-color:var(--accent)}
.toc-grid b{color:var(--accent)}
.toc-grid span{font-size:.9rem;opacity:.75}
.toc-group{margin:28px 0 4px;font-size:.8rem;letter-spacing:.08em;text-transform:uppercase;opacity:.7}
.search-results{position:absolute;z-index:50;left:0;right:0;top:calc(100% + 4px);background:var(--surface);border:1px solid var(--border);border-radius:8px;max-height:60vh;overflow:auto;box-shadow:0 8px 24px rgba(0,0,0,.18)}
.search-results a{display:block;padding:10px 14px;border-bottom:1px solid var(--border);text-decoration:none;color:inherit}
.search-results a:last-child{border-bottom:0}
.search-results a:hover,.search-results a.sel{background:var(--accent-soft)}
.search-results b{color:var(--accent)}
.search-results span{display:block;font-size:.85rem;opacity:.75}
.search-results .none{padding:10px 14px;opacity:.7}
@media (max-width:640px){.pager{grid-template-columns:1fr}.pager a.next{grid-column:1}}
code,kbd,pre,samp{font-variant-ligatures:none;font-feature-settings:"liga" 0,"calt" 0}
