/* The sysx docs kit (sysx 001): the look every part's site shares. A datasheet: cool paper, ink,
   and an edge colour for where code runs and who vouches for it: blue = a task in user mode,
   purple = a driver holding a device, amber = trusted (machine mode, assembly, assumed), teal =
   proven. Each part has an accent of its own (html[data-part]), used for its name and its chip in
   the suite's row. Layout: a fixed rail of the site's pages, prose at reading width, figures
   allowed wider. A site's own styles go in its pages; this file is copied, never edited there. */
:root {
  --paper: #f4f6f8; --sheet: #ffffff; --ink: #16202b; --muted: #586677; --faint: #8795a5; --rule: #d3dbe4;
  --accent: #2b4c8c; --accent-bg: #e7edf8;
  --user: #2b4c8c; --user-bg: #e6edf8;
  --dev: #7a3e9d; --dev-bg: #f2e9f7;
  --trusted: #a35f08; --trusted-bg: #fbf0de;
  --proven: #0b7564; --proven-bg: #e2f2ee;
  --hw: #4d5a68; --hw-bg: #eceff3;
  --bad: #b3261e; --bad-bg: #fbe9e7;
  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --body: "Public Sans", "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0d1217; --sheet: #141b22; --ink: #dce4ed; --muted: #8e9cad; --faint: #66768a; --rule: #28323e;
    --accent: #94b3ef; --accent-bg: #18243a;
    --user: #94b3ef; --user-bg: #172238;
    --dev: #cc9fe8; --dev-bg: #2a1b35;
    --trusted: #e6a646; --trusted-bg: #33260f;
    --proven: #48c6ae; --proven-bg: #11302a;
    --hw: #a7b3c0; --hw-bg: #1d252e;
    --bad: #f2887e; --bad-bg: #3a1916;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0d1217; --sheet: #141b22; --ink: #dce4ed; --muted: #8e9cad; --faint: #66768a; --rule: #28323e;
  --accent: #94b3ef; --accent-bg: #18243a;
  --user: #94b3ef; --user-bg: #172238;
  --dev: #cc9fe8; --dev-bg: #2a1b35;
  --trusted: #e6a646; --trusted-bg: #33260f;
  --proven: #48c6ae; --proven-bg: #11302a;
  --hw: #a7b3c0; --hw-bg: #1d252e;
  --bad: #f2887e; --bad-bg: #3a1916;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.6 var(--body); }
a { color: var(--accent); text-underline-offset: 2px; }
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
code, kbd, pre { font-family: var(--mono); }
code { font-size: 0.86em; background: var(--hw-bg); padding: 0.05em 0.3em; border-radius: 3px; }
pre code { background: none; padding: 0; }
h1, h2, h3, h4 { font-family: var(--display); font-stretch: 85%; text-wrap: balance; margin: 0; line-height: 1.15; }
h1 { font-size: clamp(2rem, 4vw, 2.7rem); font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.45rem; font-weight: 650; margin-top: 2.4rem; }
h3 { font-size: 1.08rem; font-weight: 650; margin-top: 1.6rem; }
p, ul, ol { margin: 0.7rem 0 0; }
li + li { margin-top: 0.25rem; }
.prose { max-width: 70ch; }
.eyebrow { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.lede { font-size: 1.1rem; color: var(--muted); max-width: 64ch; margin-top: 0.8rem; }
.note { font-size: 0.86rem; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0; }

/* ---- frame: rail + main */
.frame { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100%; }
.rail { position: sticky; top: env(safe-area-inset-top, 0px); align-self: start; height: 100vh; overflow-y: auto;
  border-right: 1px solid var(--rule); background: var(--sheet); padding: 22px 18px 40px; }
.rail .brand { display: flex; align-items: baseline; gap: 8px; text-decoration: none; color: var(--ink); }
.rail .brand b { font-family: var(--display); font-stretch: 80%; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; }
.rail .brand span { font-family: var(--mono); font-size: 0.7rem; color: var(--muted); }
.rail nav { margin-top: 18px; display: grid; gap: 14px; }
.rail .group h4 { font-family: var(--mono); font-size: 0.68rem; font-weight: 500; letter-spacing: 0.09em; text-transform: uppercase; color: var(--faint); font-stretch: 100%; }
.rail .group ol { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 1px; }
.rail .group a { display: grid; grid-template-columns: 1.6em minmax(0, 1fr); gap: 4px; padding: 5px 8px; border-radius: 4px; text-decoration: none; color: var(--ink); font-size: 0.92rem; line-height: 1.3; }
.rail .group a .lv { font-family: var(--mono); font-size: 0.72rem; color: var(--faint); padding-top: 2px; }
.rail .group a:hover { background: var(--hw-bg); }
.rail .group a[aria-current="page"] { background: var(--accent-bg); background: color-mix(in srgb, var(--part) 13%, transparent); color: var(--part); font-weight: 600; }
.menu-toggle { display: none; }
main { padding-inline: clamp(16px, 4vw, 56px); padding-block: 36px 80px; min-width: 0; }
.page { max-width: 1040px; }
header.top { display: grid; gap: 6px; padding-bottom: 22px; border-bottom: 2px solid var(--ink); }
.crumbs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 56px; padding-top: 18px; border-top: 1px solid var(--rule); flex-wrap: wrap; }
.pager a { text-decoration: none; display: grid; gap: 2px; max-width: 48%; }
.pager a span { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.pager a b { font-family: var(--display); font-stretch: 85%; font-size: 1.1rem; }
.pager a.next { text-align: right; margin-left: auto; }
footer.site { margin-top: 28px; font-size: 0.8rem; color: var(--faint); }

@media (max-width: 860px) {
  .frame { grid-template-columns: minmax(0, 1fr); }
  .rail { position: sticky; z-index: 5; height: auto; max-height: 100vh; border-right: 0; border-bottom: 1px solid var(--rule); padding: 10px 16px; }
  .rail .bar { display: flex; justify-content: space-between; align-items: center; }
  .menu-toggle { display: inline-block; }
  .rail nav { display: none; padding-bottom: 12px; }
  .rail.open nav { display: grid; }
}

/* ---- tags for where code runs and who vouches for it */
.tag { display: inline-flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.04em;
  text-transform: uppercase; padding: 1px 7px; border: 1px solid currentColor; border-radius: 3px; white-space: nowrap; line-height: 1.6; }
.tag.user { color: var(--user); } .tag.dev { color: var(--dev); } .tag.trusted { color: var(--trusted); }
.tag.proven { color: var(--proven); } .tag.hw { color: var(--hw); } .tag.bad { color: var(--bad); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 0.82rem; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-left: 4px solid; margin-right: 6px; vertical-align: -1px; }

/* ---- figures */
figure { margin: 1.4rem 0 0; }
figcaption { font-size: 0.85rem; color: var(--muted); margin-top: 8px; max-width: 70ch; }
.panel { background: var(--sheet); border: 1px solid var(--rule); border-radius: 6px; padding: 16px; }
.wide { overflow-x: auto; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
button, .btn { font: 500 0.86rem var(--body); color: var(--ink); background: var(--sheet); border: 1px solid var(--rule);
  border-radius: 5px; padding: 6px 12px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--sheet); }
button[disabled] { opacity: 0.45; cursor: default; }
button[aria-pressed="true"] { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }
select, input[type="text"], input[type="number"] { font: 0.88rem var(--body); color: var(--ink); background: var(--sheet); border: 1px solid var(--rule); border-radius: 5px; padding: 5px 8px; }
.callout { border-left: 4px solid var(--accent); background: var(--accent-bg); padding: 10px 14px; border-radius: 0 5px 5px 0; margin-top: 1rem; max-width: 72ch; }
.callout.trusted { border-color: var(--trusted); background: var(--trusted-bg); }
.callout.proven { border-color: var(--proven); background: var(--proven-bg); }
.callout.bad { border-color: var(--bad); background: var(--bad-bg); }
.callout > :first-child { margin-top: 0; }

table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: 6px; background: var(--sheet); margin-top: 1rem; }
.table-wrap table { min-width: 560px; }
th, td { text-align: left; padding: 8px 12px; border-top: 1px solid var(--rule); vertical-align: top; }
thead th { border-top: 0; font-family: var(--mono); font-size: 0.7rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }

pre.code { background: var(--sheet); border: 1px solid var(--rule); border-radius: 6px; padding: 12px 14px; overflow-x: auto; font-size: 0.8rem; line-height: 1.6; margin: 1rem 0 0; }
pre.code .c { color: var(--faint); } pre.code .k { color: var(--trusted); } pre.code .p { color: var(--proven); } pre.code .u { color: var(--user); } pre.code .d { color: var(--dev); } pre.code .b { color: var(--bad); }
.hl { background: var(--accent-bg); border-radius: 2px; }

/* step lists that animations drive */
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; counter-reset: s; }
.steps li { display: grid; grid-template-columns: 2em minmax(0, 1fr); gap: 8px; padding: 8px 10px; border-radius: 5px; color: var(--muted); margin: 0; }
.steps li::before { counter-increment: s; content: counter(s); font-family: var(--mono); font-size: 0.78rem; padding-top: 2px; }
.steps li.on { background: var(--accent-bg); color: var(--ink); }
.steps li.done { color: var(--ink); }

/* ---- the generated reference: "In the source" */
.ref { margin-top: 3rem; border-top: 2px solid var(--ink); padding-top: 14px; }
.ref > p { max-width: 72ch; }
.ref details { border: 1px solid var(--rule); border-radius: 6px; background: var(--sheet); margin-top: 10px; }
.ref summary { cursor: pointer; padding: 10px 14px; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; }
.ref summary code { font-size: 0.86rem; background: none; padding: 0; font-weight: 500; }
.ref summary .note { font-size: 0.8rem; }
.ref .file-head { padding: 0 14px 6px; font-size: 0.9rem; color: var(--muted); max-width: 80ch; white-space: pre-line; }
.ref .defs { display: grid; border-top: 1px solid var(--rule); }
.ref .def { padding: 10px 14px; border-top: 1px solid var(--rule); display: grid; gap: 4px; min-width: 0; }
.ref .def:first-child { border-top: 0; }
.ref .def .name { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.ref .def .name code { background: none; padding: 0; font-weight: 600; font-size: 0.9rem; }
.ref .def .doc { font-size: 0.9rem; max-width: 80ch; white-space: pre-line; }
.ref .def .sig { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); overflow-x: auto; white-space: pre-wrap; word-break: break-word; }
.ref .def .sig b { color: var(--proven); font-weight: 500; }
.ref .def .line { font-family: var(--mono); font-size: 0.72rem; color: var(--faint); }
.kind { font-family: var(--mono); font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--faint); }

/* chips for facts read from data.js */
.fact { font-variant-numeric: tabular-nums; font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 1.2rem; }
.stat { background: var(--sheet); border: 1px solid var(--rule); border-radius: 6px; padding: 10px 12px; display: grid; gap: 2px; }
.stat b { font-family: var(--display); font-stretch: 85%; font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: 0.8rem; color: var(--muted); }

svg text { fill: var(--ink); font-family: var(--mono); }
svg .muted { fill: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* quoted code with line numbers; lines can be marked */
pre.codeview .ln { display: block; padding: 0 6px; margin: 0 -6px; border-radius: 3px; transition: background .2s; }
pre.codeview .lno { color: var(--faint); user-select: none; }
pre.codeview .ln.hl { background: var(--accent-bg); }
pre.codeview .ln.ok { background: var(--proven-bg); }
pre.codeview .ln.warn { background: var(--trusted-bg); }
pre.codeview .ln.bad { background: var(--bad-bg); }

/* ---- the suite: each part's accent (for figures too: var(--sysp)), the page's part's as --part,
   and the row of parts at the top of the rail */
:root { --sysx: #3d4a5c; --sysp: #b4234f; --sysi: #0f7c8c; --sysr: #9a5a12; --sysk: #2b4c8c; --sysh: #2e7d32; --syst: #6b3fa0; --sysn: #66711a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --sysx: #aebccd; --sysp: #f08aa6; --sysi: #5cc8d6; --sysr: #e5a85c; --sysk: #94b3ef; --sysh: #7cc97f; --syst: #b79be0; --sysn: #c6d16a; }
}
:root[data-theme="dark"] { --sysx: #aebccd; --sysp: #f08aa6; --sysi: #5cc8d6; --sysr: #e5a85c; --sysk: #94b3ef; --sysh: #7cc97f; --syst: #b79be0; --sysn: #c6d16a; }
:root, :root[data-part="sysx"] { --part: var(--sysx); }
:root[data-part="sysp"] { --part: var(--sysp); }
:root[data-part="sysi"] { --part: var(--sysi); }
:root[data-part="sysr"] { --part: var(--sysr); }
:root[data-part="sysk"] { --part: var(--sysk); }
:root[data-part="sysh"] { --part: var(--sysh); }
:root[data-part="syst"] { --part: var(--syst); }
:root[data-part="sysn"] { --part: var(--sysn); }
.rail .brand b { color: var(--part); }
.rail a.host { display: block; margin: -4px 0 12px; font-family: var(--mono); font-size: 0.72rem; color: var(--muted); text-decoration: none; }
.rail a.host:hover { color: var(--ink); }
.suite { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 14px; padding-bottom: 12px; border-bottom: 1px solid var(--rule); }
.suite a, .suite span { font-family: var(--mono); font-size: 0.72rem; text-decoration: none; padding: 2px 7px; border-radius: 10px;
  border: 1px solid var(--rule); color: var(--muted); line-height: 1.5; }
.suite a:hover { border-color: var(--part); color: var(--ink); }
.suite [aria-current="page"] { background: var(--part); border-color: var(--part); color: var(--sheet); font-weight: 500; }
.suite span.none { color: var(--faint); border-style: dashed; }
@media (max-width: 860px) {
  .suite { margin: 8px 0 0; padding-bottom: 8px; border-bottom: 0; }
}
.rail nav.suite { display: flex; margin-top: 0; gap: 4px; }
