/* CLI Principles: specification site. Dark only. */

:root {
  --ink-0: #0a0c11;
  --ink-1: #0d1016;
  --ink-2: #12161e;
  --ink-3: #181d27;
  --ink-4: #222836;
  --line: #262c39;
  --line-soft: #1c212c;

  --text: #ebe3d4;
  --text-2: #c9c0b1;
  --muted: #9a9284;
  --faint: #6f6a62;

  --accent: #e3b26a;
  --accent-2: #f1c98a;
  --accent-ink: #1a1408;
  --accent-wash: rgba(227, 178, 106, 0.08);
  --accent-line: rgba(227, 178, 106, 0.32);

  --ok: #8fc6a1;
  --ok-wash: rgba(143, 198, 161, 0.1);
  --warn: #e69a7c;
  --warn-wash: rgba(230, 154, 124, 0.1);
  --info: #9db8e0;
  --info-wash: rgba(157, 184, 224, 0.1);

  --serif: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --side-w: 17.5rem;
  --rail-w: 14.5rem;
  --measure: 100ch;
  --radius: 10px;
  --top-h: 3.5rem;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  color-scheme: dark;
  scroll-padding-top: 1.5rem;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--ink-1);
  background-image:
    radial-gradient(1200px 520px at 72% -180px, rgba(227, 178, 106, 0.075), transparent 70%),
    radial-gradient(900px 600px at -10% 110%, rgba(110, 140, 200, 0.05), transparent 70%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.68;
  font-optical-sizing: auto;
  font-kerning: normal;
  font-variant-numeric: oldstyle-nums proportional-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

::selection { background: rgba(227, 178, 106, 0.3); color: #fff8ec; }

a { color: var(--accent-2); text-decoration-color: var(--accent-line); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: #ffe0ad; text-decoration-color: currentColor; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

code, kbd, samp, pre { font-family: var(--mono); font-variant-numeric: normal; font-variant-ligatures: none; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- skip link ---------- */
.skip {
  position: fixed; left: 1rem; top: -4rem; z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--accent); color: var(--accent-ink);
  font: 600 0.8rem/1 var(--mono); text-decoration: none;
  border-radius: 6px;
}
.skip:focus { top: 1rem; }

/* ---------- shell ---------- */
.shell {
  display: grid;
  /* side | gutter | reading column | rail | gutter: spare width on big screens goes to the gutters */
  grid-template-columns: var(--side-w) minmax(0, 0.4fr) minmax(0, calc(var(--measure) + 10rem)) var(--rail-w) minmax(0, 0.6fr);
  min-height: 100vh;
}
.main { min-width: 0; outline: none; grid-column: 3; }
.main:focus { outline: none; }

.topbar, .nav-toggle, .scrim { display: none; }

/* ---------- brand ---------- */
.brand {
  display: flex; align-items: center; gap: 0.75rem;
  color: var(--text); text-decoration: none;
}
.brand:hover { color: var(--text); }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 2.1rem; height: 2.1rem; flex: none;
  border-radius: 8px;
  font: 600 0.8rem/1 var(--mono);
  color: var(--accent);
  background: linear-gradient(160deg, var(--ink-4), var(--ink-2));
  border: 1px solid var(--accent-line);
  box-shadow: 0 0 0 4px rgba(227, 178, 106, 0.04), 0 6px 18px -8px rgba(227, 178, 106, 0.45);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-weight: 600; font-size: 1.05rem; letter-spacing: 0.005em; }
.brand-meta { font: 400 0.68rem/1.4 var(--mono); color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }

/* ---------- sidebar ---------- */
.sidebar {
  grid-column: 1;
  position: sticky; top: 0;
  height: 100vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.6rem 1rem 1.5rem 1.4rem;
  border-right: 1px solid var(--line-soft);
  background: linear-gradient(180deg, rgba(10, 12, 17, 0.75), rgba(10, 12, 17, 0.35));
  display: flex; flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-4) transparent;
}
.brand-side { padding: 0 0.4rem 1.4rem; margin-bottom: 1rem; border-bottom: 1px solid var(--line-soft); }

.toc-nav ol { list-style: none; margin: 0; padding: 0; }
.toc-nav li { margin: 1px 0; }
.toc-nav li.nav-extra { margin-top: 0.8rem; padding-top: 0.8rem; border-top: 1px solid var(--line-soft); }
.toc-nav a {
  position: relative;
  display: grid; grid-template-columns: 2.1rem 1fr; align-items: baseline;
  padding: 0.34rem 0.6rem 0.34rem 0.45rem;
  border-radius: 7px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 0.93rem; line-height: 1.35;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.toc-nav a:hover { background: var(--ink-3); color: var(--text); }
.nav-num {
  font: 500 0.72rem/1 var(--mono);
  color: var(--faint);
  letter-spacing: 0.02em;
}
.toc-nav a:hover .nav-num { color: var(--muted); }
.toc-nav a[aria-current="page"] {
  background: linear-gradient(90deg, var(--accent-wash), rgba(227, 178, 106, 0.02));
  color: #fff6e6;
  box-shadow: inset 0 0 0 1px rgba(227, 178, 106, 0.14);
}
.toc-nav a[aria-current="page"]::before {
  content: ""; position: absolute; left: -1.4rem; top: 0.45rem; bottom: 0.45rem;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(227, 178, 106, 0.7);
}
.toc-nav a[aria-current="page"] .nav-num { color: var(--accent); }

.sidebar-foot {
  margin: auto 0 0; padding: 1.5rem 0.45rem 0;
  font: 400 0.66rem/1.7 var(--mono); color: var(--faint);
  letter-spacing: 0.06em; text-transform: uppercase;
}

/* ---------- document ---------- */
.doc {
  width: 100%;
  max-width: calc(var(--measure) + 6rem);
  margin: 0 auto;
  padding: 3.5rem 3rem 2rem;
}

.doc-head { margin-bottom: 2.6rem; padding-bottom: 2rem; border-bottom: 1px solid var(--line); position: relative; }
.doc-head::after {
  content: ""; position: absolute; left: 0; bottom: -1px; width: 5.5rem; height: 1px;
  background: linear-gradient(90deg, var(--accent), transparent);
}

.doc-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.55rem;
  font: 500 0.7rem/1 var(--mono); color: var(--muted);
  letter-spacing: 0.08em; text-transform: uppercase;
  margin-bottom: 1.6rem;
}
.doc-meta .sep { color: var(--faint); }
.status-pill {
  margin-left: auto;
  padding: 0.32rem 0.55rem 0.3rem;
  border: 1px solid var(--accent-line); border-radius: 999px;
  color: var(--accent); background: var(--accent-wash);
  letter-spacing: 0.1em;
}

.doc-title-row { display: flex; align-items: flex-end; gap: 1.4rem; }
.doc-num {
  font-family: var(--serif);
  font-size: clamp(4rem, 9vw, 6.5rem);
  font-weight: 300;
  font-variation-settings: "opsz" 60;
  line-height: 0.82;
  letter-spacing: -0.04em;
  font-variant-numeric: lining-nums;
  background: linear-gradient(175deg, #ffe2b0 0%, var(--accent) 45%, #8a6331 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  text-shadow: 0 0 40px rgba(227, 178, 106, 0.18);
  flex: none;
}
.doc-title {
  margin: 0;
  font-size: clamp(1.9rem, 3.6vw, 2.6rem);
  font-weight: 500;
  font-variation-settings: "opsz" 60;
  line-height: 1.12;
  letter-spacing: -0.012em;
  color: #fbf4e8;
  text-wrap: balance;
}
.doc-title-row .doc-title { padding-bottom: 0.15rem; }

.doc-kicker {
  margin: 0 0 0.6rem;
  font: 500 0.72rem/1 var(--mono); color: var(--accent);
  letter-spacing: 0.22em; text-transform: uppercase;
}
.doc-title-home {
  font-size: clamp(2.6rem, 6vw, 4.2rem);
  font-weight: 400;
  letter-spacing: -0.025em;
  background: linear-gradient(180deg, #fff8ec 30%, #d6c7ad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.doc-sub { margin: 0.8rem 0 0; font-size: 1.15rem; font-style: italic; color: var(--text-2); }

.doc-facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 0; margin: 1.8rem 0 0;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: rgba(18, 22, 30, 0.6);
  overflow: hidden;
}
.doc-facts div { padding: 0.8rem 1rem; border-right: 1px solid var(--line-soft); }
.doc-facts div:last-child { border-right: 0; }
.doc-facts dt { font: 500 0.64rem/1 var(--mono); color: var(--faint); letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 0.45rem; }
.doc-facts dd { margin: 0; font-size: 0.98rem; color: var(--text); }

.doc-source {
  margin: 1.2rem 0 0;
  font: 400 0.7rem/1 var(--mono); color: var(--faint); letter-spacing: 0.04em;
}
.doc-source code { color: var(--muted); }

/* ---------- prose ---------- */
.prose { max-width: var(--measure); }
.prose > :first-child { margin-top: 0; }
.prose > p:first-child:has(> a[href="/"]:only-child) { display: none; }
.prose > p:first-child:has(> a[href="/"]:only-child) + * { margin-top: 0; }

.prose p, .prose ul, .prose ol, .prose pre, .prose table, .prose blockquote, .prose .table-wrap, .prose .code-block { margin: 0 0 1.15em; }

.prose h2, .prose h3, .prose h4 {
  position: relative;
  color: #fbf4e8;
  font-variation-settings: "opsz" 40;
  line-height: 1.25;
  text-wrap: balance;
  scroll-margin-top: 1.5rem;
}
.prose h2 {
  margin: 2.8em 0 0.9em;
  padding-top: 1.1em;
  border-top: 1px solid var(--line);
  font-size: 1.6rem; font-weight: 500; letter-spacing: -0.008em;
}
.prose h2::before {
  content: ""; position: absolute; top: -1px; left: 0; width: 2.5rem; height: 1px;
  background: var(--accent);
}
.prose h3 { margin: 2.1em 0 0.6em; font-size: 1.22rem; font-weight: 600; }
.prose h4 { margin: 1.8em 0 0.5em; font-size: 1.02rem; font-weight: 600; color: var(--text); }

.heading-anchor {
  position: absolute; left: -1.4em;
  width: 1.1em; text-align: center;
  font-family: var(--mono); font-weight: 500; font-size: 0.85em;
  color: var(--faint); text-decoration: none;
  opacity: 0; transition: opacity 0.15s ease, color 0.15s ease;
}
.prose h2:hover .heading-anchor, .prose h3:hover .heading-anchor, .heading-anchor:focus-visible { opacity: 1; }
.heading-anchor:hover { color: var(--accent); }

.prose strong { color: #fff4e2; font-weight: 600; }
.prose em { color: var(--text); }

.prose ul, .prose ol { padding-left: 1.35em; }
.prose li { margin: 0.32em 0; padding-left: 0.2em; }
.prose li > ul, .prose li > ol { margin: 0.35em 0 0.5em; }
.prose ul > li::marker { color: var(--accent); font-size: 0.85em; }
.prose ul ul > li::marker { color: var(--faint); }
.prose ol > li::marker { color: var(--muted); font-family: var(--mono); font-size: 0.82em; }
.prose li > p { margin: 0.35em 0; }

.prose hr { border: 0; height: 1px; margin: 2.6em 0; background: linear-gradient(90deg, transparent, var(--line) 20%, var(--line) 80%, transparent); }

/* inline code */
.prose :not(pre) > code {
  padding: 0.12em 0.36em 0.1em;
  font-size: 0.82em;
  color: #f0d6a8;
  background: rgba(227, 178, 106, 0.07);
  border: 1px solid rgba(227, 178, 106, 0.13);
  border-radius: 5px;
  overflow-wrap: anywhere;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.prose a > code { color: inherit; }

/* code blocks */
.code-block { position: relative; }
.prose pre {
  position: relative;
  max-width: 100%;
  overflow-x: auto;
  padding: 1.05rem 1.2rem;
  font-size: 0.8rem; line-height: 1.65;
  color: #ddd6c8;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 3rem),
    var(--ink-0);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03), 0 10px 30px -18px rgba(0, 0, 0, 0.8);
  tab-size: 2;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-4) transparent;
}
.prose pre code { background: none; border: 0; padding: 0; font-size: inherit; color: inherit; white-space: pre; }
.code-block[data-lang] pre { padding-top: 2.1rem; }
.code-lang {
  position: absolute; top: 0.6rem; left: 1.2rem; z-index: 1;
  font: 500 0.62rem/1 var(--mono); color: var(--faint);
  letter-spacing: 0.12em; text-transform: uppercase;
  pointer-events: none;
}
.copy-btn {
  position: absolute; top: 0.45rem; right: 0.45rem; z-index: 1;
  padding: 0.32rem 0.55rem;
  font: 500 0.66rem/1 var(--mono); letter-spacing: 0.06em;
  color: var(--muted);
  background: var(--ink-3);
  border: 1px solid var(--line); border-radius: 6px;
  cursor: pointer;
  opacity: 0; transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.code-block:hover .copy-btn, .copy-btn:focus-visible, .copy-btn[data-state] { opacity: 1; }
.copy-btn:hover { color: var(--text); border-color: var(--accent-line); }
.copy-btn[data-state="done"] { color: var(--ok); border-color: rgba(143, 198, 161, 0.4); }
@media (hover: none) { .copy-btn { opacity: 1; } }

/* tables */
.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(13, 16, 22, 0.6);
  scrollbar-width: thin;
  scrollbar-color: var(--ink-4) transparent;
}
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem; line-height: 1.5;
  font-variant-numeric: lining-nums tabular-nums;
}
/* without JS the table scrolls itself */
.prose > table { display: block; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.table-wrap > table { margin: 0; display: table; border: 0; }
.prose th, .prose td {
  padding: 0.6rem 0.9rem;
  text-align: left; vertical-align: top;
  border-bottom: 1px solid var(--line-soft);
}
.prose th {
  font: 600 0.68rem/1.3 var(--mono);
  color: var(--accent);
  letter-spacing: 0.08em; text-transform: uppercase;
  background: var(--ink-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.prose th code { padding: 0; background: none; border: 0; color: inherit; font-size: inherit; }
.prose tbody tr:last-child td { border-bottom: 0; }
.prose tbody tr:nth-child(even) td { background: rgba(255, 255, 255, 0.012); }
.prose tbody tr:hover td { background: rgba(227, 178, 106, 0.035); }
.prose td code { white-space: nowrap; }

/* blockquote / callout */
.prose blockquote {
  position: relative;
  margin-left: 0; margin-right: 0;
  padding: 0.9rem 1.2rem 0.9rem 1.35rem;
  color: var(--text-2);
  background: linear-gradient(90deg, var(--accent-wash), rgba(227, 178, 106, 0.015) 70%);
  border: 1px solid rgba(227, 178, 106, 0.14);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: italic;
}
.prose blockquote > :last-child { margin-bottom: 0; }
.prose blockquote code, .prose blockquote strong { font-style: normal; }

/* status badges (added by site.js) */
.badge {
  display: inline-block;
  padding: 0.18em 0.5em 0.14em;
  font: 600 0.64em/1.2 var(--mono);
  letter-spacing: 0.08em; text-transform: uppercase;
  border-radius: 999px;
  vertical-align: 0.14em;
  white-space: nowrap;
}
.badge-decided { color: var(--ok); background: var(--ok-wash); border: 1px solid rgba(143, 198, 161, 0.32); }
.badge-proposed { color: var(--info); background: var(--info-wash); border: 1px solid rgba(157, 184, 224, 0.3); }
.badge-open { color: var(--warn); background: var(--warn-wash); border: 1px solid rgba(230, 154, 124, 0.34); }
.nav-label .badge { font-size: 0.56rem; vertical-align: 0.15em; margin-left: 0.25em; }

/* ---------- home contents ---------- */
.is-home .prose h2#contents,
.is-home .prose h2#contents + ul,
.is-home .prose h2#open-questions,
.is-home .prose h2#open-questions + p { display: none; }

.contents { margin: 2.6rem 0 1rem; }
.contents-title {
  margin: 0 0 1rem;
  font: 500 0.72rem/1 var(--mono); color: var(--accent);
  letter-spacing: 0.22em; text-transform: uppercase;
}
.contents-list {
  list-style: none; margin: 0; padding: 0;
  border-top: 1px solid var(--line);
  counter-reset: none;
}
.contents-list li { border-bottom: 1px solid var(--line-soft); }
.contents-list li.c-extra { margin-top: 1.4rem; border-top: 1px solid var(--line); }
.contents-list a {
  position: relative;
  display: grid; grid-template-columns: 3.4rem 1fr auto; align-items: baseline; gap: 0.5rem;
  padding: 0.85rem 0.8rem 0.85rem 0.4rem;
  color: var(--text); text-decoration: none;
  transition: background-color 0.2s ease, padding-left 0.2s ease;
}
.contents-list a::after {
  content: "\2192"; position: absolute; right: 0.8rem; top: 50%; transform: translate(-0.4rem, -50%);
  color: var(--accent); opacity: 0; font-family: var(--mono); font-size: 0.85rem;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.contents-list a:hover, .contents-list a:focus-visible {
  background: linear-gradient(90deg, var(--accent-wash), transparent 85%);
  padding-left: 0.9rem;
}
.contents-list a:hover::after, .contents-list a:focus-visible::after { opacity: 1; transform: translate(0, -50%); }
.contents-list a:hover .c-count, .contents-list a:focus-visible .c-count { opacity: 0; }
.c-n {
  font: 500 0.95rem/1 var(--mono); color: var(--accent);
  letter-spacing: -0.01em;
}
.c-extra .c-n { color: var(--warn); }
.c-label { font-size: 1.15rem; line-height: 1.35; font-variation-settings: "opsz" 24; }
.c-count {
  font: 400 0.68rem/1 var(--mono); color: var(--faint); letter-spacing: 0.05em;
  transition: opacity 0.2s ease;
}

/* ---------- pager ---------- */
.pager {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
  max-width: var(--measure);
  margin: 4rem 0 0; padding-top: 2rem;
  border-top: 1px solid var(--line);
}
.pager-link {
  display: flex; flex-direction: column; gap: 0.45rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: linear-gradient(160deg, var(--ink-2), rgba(13, 16, 22, 0.4));
  color: var(--text); text-decoration: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.pager-link.next { text-align: right; grid-column: 2; }
.pager-link:hover {
  color: var(--text);
  border-color: var(--accent-line);
  box-shadow: 0 10px 30px -16px rgba(227, 178, 106, 0.35);
}
@media (prefers-reduced-motion: no-preference) {
  .pager-link:hover { transform: translateY(-1px); }
}
.pager-dir { font: 500 0.66rem/1 var(--mono); color: var(--muted); letter-spacing: 0.12em; text-transform: uppercase; }
.pager-title { font-size: 1.06rem; line-height: 1.3; }
.pager-num { font: 500 0.82rem/1 var(--mono); color: var(--accent); margin-right: 0.55rem; }

/* ---------- footer ---------- */
.site-foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1.5rem;
  max-width: calc(var(--measure) + 6rem);
  margin: 0 auto; padding: 1.5rem 3rem 2.5rem;
  font: 400 0.68rem/1.6 var(--mono); color: var(--faint); letter-spacing: 0.03em;
}
.site-foot code { color: var(--muted); }

/* ---------- right rail ---------- */
.rail {
  grid-column: 4;
  position: sticky; top: 0;
  height: 100vh; overflow-y: auto;
  padding: 3.9rem 1.4rem 2rem 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-4) transparent;
}
.rail-title {
  margin: 0 0 0.9rem;
  font: 500 0.66rem/1 var(--mono); color: var(--muted);
  letter-spacing: 0.16em; text-transform: uppercase;
}
.rail-list { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.rail-list a {
  display: block;
  margin-left: -1px;
  padding: 0.28rem 0 0.28rem 0.9rem;
  border-left: 1px solid transparent;
  color: var(--muted); text-decoration: none;
  font-size: 0.84rem; line-height: 1.4;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.rail-list .lvl-3 a { padding-left: 1.75rem; font-size: 0.8rem; color: var(--faint); }
.rail-list a:hover { color: var(--text); }
.rail-list a.is-active {
  color: var(--accent-2);
  border-left-color: var(--accent);
  box-shadow: -6px 0 12px -8px rgba(227, 178, 106, 0.8);
}
.rail-top {
  display: inline-block; margin-top: 1.2rem;
  font: 400 0.68rem/1 var(--mono); color: var(--faint); text-decoration: none; letter-spacing: 0.04em;
}
.rail-top:hover { color: var(--accent); }

/* ---------- responsive ---------- */
@media (max-width: 1500px) {
  .shell { grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .main { grid-column: 2; }
  .rail { display: none; }
}

@media (max-width: 900px) {
  :root { --side-w: min(20rem, 86vw); }
  html { scroll-padding-top: calc(var(--top-h) + 1rem); }
  .prose h2, .prose h3, .prose h4 { scroll-margin-top: calc(var(--top-h) + 1rem); }

  .shell { display: block; }

  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 30;
    height: var(--top-h);
    padding: 0 1rem;
    background: rgba(13, 16, 22, 0.86);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line-soft);
  }
  .topbar .brand-mark { width: 1.8rem; height: 1.8rem; font-size: 0.7rem; }
  .menu-btn {
    display: inline-flex; align-items: center; gap: 0.6rem;
    padding: 0.45rem 0.75rem;
    font: 500 0.72rem/1 var(--mono); color: var(--text-2); letter-spacing: 0.06em; text-transform: uppercase;
    border: 1px solid var(--line); border-radius: 8px;
    background: var(--ink-2);
    cursor: pointer;
    user-select: none;
  }
  .menu-icon, .menu-icon::before, .menu-icon::after {
    display: block; width: 14px; height: 1.5px; background: currentColor; border-radius: 1px;
  }
  .menu-icon { position: relative; }
  .menu-icon::before, .menu-icon::after { content: ""; position: absolute; left: 0; }
  .menu-icon::before { top: -4.5px; }
  .menu-icon::after { top: 4.5px; }

  .nav-toggle {
    display: block;
    position: fixed; top: 0.6rem; right: 1rem; z-index: 29;
    width: 1px; height: 1px; opacity: 0; margin: 0;
  }
  .nav-toggle:focus-visible ~ .topbar .menu-btn { outline: 2px solid var(--accent); outline-offset: 2px; }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
    width: var(--side-w); height: 100%;
    background: var(--ink-1);
    border-right: 1px solid var(--line);
    box-shadow: 20px 0 60px -20px rgba(0, 0, 0, 0.8);
    transform: translateX(-102%);
    visibility: hidden;
    transition: transform 0.25s ease, visibility 0s linear 0.25s;
  }
  .toc-nav a[aria-current="page"]::before { left: -1.4rem; }
  .nav-toggle:checked ~ .shell .sidebar {
    transform: none; visibility: visible;
    transition: transform 0.25s ease, visibility 0s;
  }
  .scrim {
    position: fixed; inset: 0; z-index: 40;
    background: rgba(5, 6, 9, 0.6);
    -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  }
  .nav-toggle:checked ~ .scrim { display: block; }

  .doc { padding: 2.2rem 1rem 1.5rem; }
  .site-foot { padding: 1.2rem 1rem 2rem; }
  .doc-title-row { gap: 1rem; }
  .doc-meta { margin-bottom: 1.2rem; }
  .heading-anchor { display: none; }
}

@media (max-width: 560px) {
  body { font-size: 1rem; }
  .doc-title-row { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .doc-num { font-size: 4.2rem; }
  .doc-facts div { border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .pager { grid-template-columns: 1fr; }
  .pager-link.next { grid-column: 1; }
  .contents-list a { grid-template-columns: 2.6rem 1fr; }
  .c-count { display: none; }
  .prose h2 { font-size: 1.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- print ---------- */
@media print {
  :root { --text: #111; --text-2: #222; --muted: #555; --faint: #777; --line: #ccc; --line-soft: #ddd; }
  body { background: #fff; color: #111; font-size: 11pt; }
  .sidebar, .rail, .topbar, .pager, .copy-btn, .skip, .scrim, .heading-anchor, .site-foot { display: none !important; }
  .shell { display: block; }
  .doc { max-width: none; padding: 0; }
  .prose h2, .prose h3, .doc-title, .prose strong { color: #000; }
  .doc-num, .doc-title-home { color: #000; background: none; -webkit-text-fill-color: #000; text-shadow: none; }
  .prose pre, .prose :not(pre) > code { background: #f6f6f6; color: #111; border-color: #ccc; box-shadow: none; }
  .prose pre { white-space: pre-wrap; }
  .prose th { background: #eee; color: #000; }
  a { color: #000; }
}
