/* Docs: sidebar, article, "On this page". Same grey family as the app (styles.css): a #C9C9C9 page, panels a
   shade darker, near-black text, and near-black as the accent. */
:root {
  color-scheme: light;
  --bg: #c9c9c9;
  --bg-2: #bdbdbd;
  --panel: #bdbdbd;
  --panel-2: #b3b3b3;
  --line: #a1a1a1;
  --line-soft: rgba(0, 0, 0, 0.12);
  --ink: #141518;
  --ink-2: #2a2c30;
  --muted: #45484e;
  --accent: #141518;
  --ok: #15803d;
  --warn: #b45309;
  --danger: #c62828;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  --sidebar-w: 236px;
  --toc-w: 196px;
  --max: 1200px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { min-height: 100vh; background: var(--bg); color: var(--ink); border-top: 4px solid var(--ink);
  font: 15px/1.65 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: none; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink); }

.skip-link { position: absolute; top: 8px; left: -9999px; z-index: 100; padding: 8px 14px; border-radius: 4px;
  background: var(--ink); color: var(--bg); font: 600 12px var(--sans); }
.skip-link:focus { left: 8px; }

/* ------------------------------------------------------------ top bar */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--bg-2); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; gap: 16px; height: 48px; padding: 0 20px; }
.brand { display: flex; align-items: center; gap: 8px; flex-shrink: 0; font: 600 17px/1 var(--sans); letter-spacing: -0.03em;
  transition: opacity 0.12s; }
.brand:hover { opacity: 0.72; }
.brand svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.top-nav { display: flex; }
.top-nav a { padding: 2px 12px 4px; border-bottom: 2px solid transparent; color: var(--muted); font: 600 12px var(--sans);
  transition: color 0.12s, border-color 0.12s; }
.top-nav a:hover { color: var(--ink); }
.top-nav a.on { color: var(--ink); border-bottom-color: var(--ink); }

/* ------------------------------------------------------------ three columns */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w); gap: 40px; align-items: start;
  max-width: var(--max); margin: 0 auto; padding: 32px 20px 120px; }
.sidebar-col, .toc-col { position: sticky; top: 72px; max-height: calc(100vh - 92px); overflow-y: auto; }
.article-col { min-width: 0; }
.article-col:focus { outline: none; }

.sidebar-toggle { display: none; }
.sidebar-section { margin: 0 0 22px; }
.sidebar-head, .toc-head { padding: 0 12px 8px; color: var(--muted); font: 600 10px var(--sans); letter-spacing: 0.08em; text-transform: uppercase; }
.sidebar-list, .toc-list { list-style: none; }
.sidebar-list a { position: relative; display: block; padding: 6px 12px; border-radius: 3px; color: var(--ink-2);
  font: 500 13px/1.4 var(--sans); transition: color 0.12s, background 0.12s; }
.sidebar-list a:hover { color: var(--ink); background: rgba(0, 0, 0, 0.05); }
.sidebar-list a.active { color: var(--ink); background: var(--panel); font-weight: 600; }
.toc-list a { position: relative; display: block; padding: 5px 12px; color: var(--ink-2); font: 400 12.5px/1.4 var(--sans); transition: color 0.12s; }
.toc-list a:hover { color: var(--ink); }
.toc-list a.active { color: var(--ink); font-weight: 600; }
.toc-list a.h3 { padding-left: 24px; font-size: 12px; }
.sidebar-list a.active::before, .toc-list a.active::before { content: ""; position: absolute; left: 0; top: 6px; bottom: 6px;
  width: 2px; border-radius: 1px; background: var(--accent); }

/* ------------------------------------------------------------ article */
.article { max-width: 74ch; }
.article .eyebrow { display: inline-block; margin-bottom: 10px; color: var(--muted); font: 600 10px var(--sans); letter-spacing: 0.1em; text-transform: uppercase; }
.article h1 { margin: 0 0 14px; font: 700 32px/1.18 var(--sans); letter-spacing: -0.02em; }
.article .lead { max-width: 62ch; margin: 0 0 36px; color: var(--ink-2); font: 400 16.5px/1.6 var(--sans); }
.article h2 { margin: 46px 0 14px; scroll-margin-top: 72px; font: 700 22px/1.3 var(--sans); letter-spacing: -0.01em; }
.article h3 { margin: 30px 0 8px; scroll-margin-top: 72px; font: 600 16px/1.35 var(--sans); }
.article h4, .article h5, .article h6 { margin: 22px 0 6px; font: 600 14.5px/1.4 var(--sans); }
.article p { margin: 0 0 14px; }
.article ul, .article ol { margin: 0 0 16px; padding-left: 22px; }
.article li { margin-bottom: 5px; }
.article li > ul, .article li > ol { margin: 5px 0 0; }
.article li::marker { color: var(--muted); }
.article a { border-bottom: 1.5px solid var(--line); transition: border-color 0.15s; }
.article a:hover { border-bottom-color: var(--ink); }
.article strong { font-weight: 650; }
.article em { color: var(--ink-2); }
.article code { padding: 1px 5px; border: 1px solid var(--line); border-radius: 3px; background: var(--panel);
  font: 500 12.5px/1.4 var(--mono); overflow-wrap: anywhere; }
.article pre { margin: 18px 0 22px; padding: 16px 18px; overflow-x: auto; border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel); font: 400 12.5px/1.55 var(--mono); }
.article pre code { padding: 0; border: 0; background: none; overflow-wrap: normal; }
.article blockquote { margin: 18px 0; padding: 14px 18px; border-left: 3px solid var(--accent); background: rgba(0, 0, 0, 0.04); color: var(--ink-2); }
.article blockquote > :last-child, .article .callout > :last-child { margin-bottom: 0; }
.article .callout { margin: 20px 0; padding: 14px 18px; border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 4px; background: var(--panel); }
.article .callout.ok { border-left-color: var(--ok); }
.article .callout.warn { border-left-color: var(--warn); }
.article .callout.danger { border-left-color: var(--danger); }
.article .callout-head { margin-bottom: 6px; color: var(--muted); font: 600 10px var(--sans); letter-spacing: 0.1em; text-transform: uppercase; }
.article .callout p { color: var(--ink-2); }
.article table { display: block; width: 100%; margin: 18px 0 22px; overflow-x: auto; border-collapse: collapse; font-size: 13.5px; }
.article th, .article td { padding: 9px 14px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: top; }
.article th { background: rgba(0, 0, 0, 0.05); color: var(--muted); font: 600 11px var(--sans); letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; }
.article tr:nth-child(2n) td { background: rgba(0, 0, 0, 0.025); }
.article hr { margin: 36px 0; border: 0; border-top: 1px solid var(--line-soft); }

/* each page leads into the next */
.prev-next { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 74ch; margin-top: 48px; }
.prev-next a { display: block; padding: 14px 16px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel);
  transition: border-color 0.15s; }
.prev-next a:hover { border-color: var(--ink); }
.prev-next .label { margin-bottom: 6px; color: var(--muted); font: 600 10px var(--sans); letter-spacing: 0.1em; text-transform: uppercase; }
.prev-next .title { font: 600 14px/1.3 var(--sans); }
.prev-next .next { text-align: right; }
.prev-next .disabled { opacity: 0.35; pointer-events: none; }

.not-found { padding: 32px 0; }
.not-found h1 { margin: 0 0 12px; font: 700 32px/1.15 var(--sans); letter-spacing: -0.02em; }
.not-found p { max-width: 48ch; margin: 0 0 14px; color: var(--ink-2); }
.not-found a { display: inline-flex; margin-top: 8px; padding: 9px 14px; border: 1px solid var(--line); border-radius: 4px;
  background: var(--panel); font: 600 12px var(--sans); transition: border-color 0.12s; }
.not-found a:hover { border-color: var(--ink); }

/* ------------------------------------------------------------ narrower screens */
@media (max-width: 1199px) {
  .shell { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); gap: 32px; }
  .toc-col { display: none; }
}
@media (max-width: 899px) {
  .shell { grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 16px 16px 96px; }
  .sidebar-toggle { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 10px 12px;
    border: 1px solid var(--line-soft); border-radius: 6px; background: var(--panel); color: var(--ink); cursor: pointer;
    font: 600 11px var(--sans); letter-spacing: 0.08em; text-transform: uppercase; }
  .sidebar-toggle .chev { width: 8px; height: 8px; margin-bottom: 2px; border-right: 1.5px solid var(--ink-2); border-bottom: 1.5px solid var(--ink-2);
    transform: rotate(45deg); transition: transform 0.15s; }
  .sidebar-toggle[aria-expanded="true"] .chev { margin-bottom: -2px; transform: rotate(-135deg); }
  .sidebar-col { position: static; max-height: none; overflow: visible; border: 1px solid var(--line-soft); border-radius: 6px; background: var(--panel); }
  .sidebar-col.is-collapsed { display: none; }
  .sidebar-section { margin: 0; padding: 10px 6px; }
  .sidebar-section + .sidebar-section { border-top: 1px solid var(--line-soft); }
  .sidebar-list a.active { background: var(--panel-2); }
  .article h1 { font-size: 26px; }
  .article h2 { margin-top: 32px; font-size: 19px; }
  .article .lead { font-size: 15.5px; }
}
@media (max-width: 560px) {
  .topbar-inner { gap: 8px; padding: 0 16px; }
  .top-nav a { padding-left: 8px; padding-right: 8px; }
  .prev-next { grid-template-columns: 1fr; }
  .prev-next .next { text-align: left; }
}
