  :root {
    --ground: #f2f3f6;
    --surface: #ffffff;
    --ink: #15161b;
    --ink-soft: #4b4f5c;
    --ink-faint: #6f7483;
    --rule: #d8dbe3;
    --accent: #2d4cc0;
    --accent-soft: #e4e9fb;
    --kbd-bg: #ffffff;
    --kbd-edge: #b9bec9;
    --note-bg: #fff6e6;
    --note-edge: #e8c98f;
    --note-ink: #6b4300;
    --device: #1d1e23;
    --device-edge: #0d0e11;
    --device-label: #9a9eaa;
    --device-label-dim: #626672;
    --font-display: "Chakra Petch", "Arial Narrow", system-ui, sans-serif;
    --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --ground: #101115;
      --surface: #17181d;
      --ink: #e6e7ec;
      --ink-soft: #a6aab6;
      --ink-faint: #858a98;
      --rule: #2a2c34;
      --accent: #93a7ff;
      --accent-soft: #1c2342;
      --kbd-bg: #1f2127;
      --kbd-edge: #3b3e48;
      --note-bg: #2a2214;
      --note-edge: #5c4722;
      --note-ink: #f0cf8f;
      --device: #1f2026;
      --device-edge: #34363e;
      --device-label: #8e929e;
      --device-label-dim: #5d616c;
    }
  }
  :root[data-theme="dark"] {
    --ground: #101115;
    --surface: #17181d;
    --ink: #e6e7ec;
    --ink-soft: #a6aab6;
    --ink-faint: #858a98;
    --rule: #2a2c34;
    --accent: #93a7ff;
    --accent-soft: #1c2342;
    --kbd-bg: #1f2127;
    --kbd-edge: #3b3e48;
    --note-bg: #2a2214;
    --note-edge: #5c4722;
    --note-ink: #f0cf8f;
    --device: #1f2026;
    --device-edge: #34363e;
    --device-label: #8e929e;
    --device-label-dim: #5d616c;
  }

  * { box-sizing: border-box; }
  html { scroll-behavior: smooth; }
  @media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
  body {
    margin: 0;
    background: var(--ground);
    color: var(--ink);
    font: 400 16px/1.62 var(--font-body);
    -webkit-font-smoothing: antialiased;
  }
  a { color: var(--accent); text-underline-offset: 2px; }
  a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

  .page { max-width: 1180px; margin: 0 auto; padding: 44px 28px 96px; }

  /* ---- Masthead ---- */
  .masthead {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 440px);
    gap: 56px;
    align-items: center;
    padding-bottom: 44px;
    border-bottom: 1px solid var(--rule);
  }
  .eyebrow {
    font: 500 0.78rem/1 var(--font-mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-faint);
    margin: 0 0 14px;
  }
  h1 {
    font: 600 clamp(2.3rem, 4.4vw, 3.3rem)/1.05 var(--font-display);
    letter-spacing: -0.01em;
    margin: 0 0 18px;
    text-wrap: balance;
  }
  .lede { font-size: 1.1rem; color: var(--ink-soft); max-width: 34em; margin: 0 0 22px; }
  .spec-row { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 0; padding: 0; list-style: none; }
  .spec-row li { font-size: 0.9rem; color: var(--ink-soft); }
  .spec-row b { font: 600 1rem var(--font-display); color: var(--ink); font-variant-numeric: tabular-nums; margin-right: 4px; }

  /* The one-page summary, offered in the masthead: someone who has read the manual once
     wants the reminder, not the chapter. */
  .sheet-link {
    display: inline-flex;
    flex-direction: column;
    gap: 3px;
    margin-top: 22px;
    padding: 11px 15px 12px;
    border: 1px solid var(--rule);
    border-left: 3px solid var(--accent);
    border-radius: 8px;
    text-decoration: none;
    color: var(--ink-soft);
    font-size: 0.88rem;
    max-width: 34em;
  }
  .sheet-link span {
    font: 500 0.86rem/1 var(--font-mono);
    letter-spacing: 0.04em;
    color: var(--ink);
  }
  .sheet-link:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }

  /* ---- Layout ---- */
  .layout { display: grid; grid-template-columns: 188px minmax(0, 1fr); gap: 60px; margin-top: 44px; }
  /* Sticky, so it stays beside the text - but a pinned element never scrolls, so a list
     taller than the window would have its tail permanently below the fold. Cap it to the
     window and let the list scroll inside itself instead. */
  nav.toc {
    position: sticky;
    top: 24px;
    align-self: start;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    padding-right: 4px;
  }
  .toc p { font: 500 0.72rem/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); margin: 0 0 12px; }
  .toc ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
  .toc a {
    display: block;
    padding: 5px 10px;
    border-radius: 6px;
    color: var(--ink-soft);
    text-decoration: none;
    font-size: 0.92rem;
  }
  .toc a:hover { background: var(--accent-soft); color: var(--ink); }

  main { max-width: 760px; display: flex; flex-direction: column; gap: 64px; }
  section { scroll-margin-top: 20px; }
  h2 {
    font: 600 1.7rem/1.15 var(--font-display);
    margin: 0 0 14px;
    text-wrap: balance;
  }
  h3 { font: 600 1.08rem/1.3 var(--font-body); margin: 30px 0 8px; text-wrap: balance; }
  p { margin: 0 0 14px; max-width: 66ch; }
  ul, ol { margin: 0 0 16px; padding-left: 1.25em; max-width: 66ch; }
  li { margin: 4px 0; }
  li::marker { color: var(--ink-faint); }
  .section-intro { color: var(--ink-soft); font-size: 1.04rem; }

  /* ---- Inline elements ---- */
  kbd {
    font: 500 0.8rem/1 var(--font-mono);
    display: inline-block;
    padding: 3px 6px 2px;
    min-width: 1.6em;
    text-align: center;
    background: var(--kbd-bg);
    border: 1px solid var(--kbd-edge);
    border-bottom-width: 2px;
    border-radius: 4px;
    color: var(--ink);
    white-space: nowrap;
  }
  .ctl {
    font: 600 0.8rem/1 var(--font-display);
    letter-spacing: 0.04em;
    display: inline-block;
    padding: 3px 6px 2px;
    border-radius: 4px;
    background: var(--device);
    color: #eceef3;
    white-space: nowrap;
  }
  code { font: 400 0.88em var(--font-mono); background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; }
  pre {
    font: 400 0.86rem/1.55 var(--font-mono);
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 8px;
    padding: 14px 16px;
    margin: 0 0 16px;
    overflow-x: auto;
  }
  pre code { background: none; padding: 0; }
  .led {
    display: inline-block;
    width: 0.78em;
    height: 0.78em;
    border-radius: 2px;
    background: var(--c);
    vertical-align: -0.05em;
    margin-right: 6px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
  }

  .callout {
    background: var(--note-bg);
    border: 1px solid var(--note-edge);
    color: var(--ink);
    border-radius: 8px;
    padding: 12px 16px;
    margin: 18px 0;
    max-width: 66ch;
  }
  .callout strong { color: var(--note-ink); }
  .callout p:last-child { margin-bottom: 0; }

  /* ---- Tables ---- */
  .table-wrap { overflow-x: auto; margin: 6px 0 18px; }
  table { width: 100%; border-collapse: collapse; font-size: 0.93rem; font-variant-numeric: tabular-nums; }
  th {
    font: 500 0.72rem/1.2 var(--font-mono);
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--ink-faint);
    text-align: left;
    padding: 8px 12px 8px 0;
    border-bottom: 1px solid var(--rule);
    white-space: nowrap;
  }
  td { padding: 9px 12px 9px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
  td:first-child { white-space: nowrap; }
  tr:last-child td { border-bottom: 0; }

  /* ---- Surface diagrams ---- */
  figure { margin: 22px 0 26px; }
  .fig-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin: 22px 0 26px; }
  .fig-pair figure { margin: 0; }
  figcaption { font-size: 0.86rem; color: var(--ink-faint); margin-top: 10px; max-width: 60ch; }
  .device {
    background: var(--device);
    border: 1px solid var(--device-edge);
    border-radius: 14px;
    padding: 4.5cqi;
    container-type: inline-size;
  }
  .device-frame { container-type: inline-size; }
  main figure .device-frame { max-width: 540px; }
  .surface { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)) minmax(0, 0.82fr); gap: 1.7cqi; align-items: center; }
  .surface.named { grid-template-columns: repeat(8, minmax(0, 1fr)) minmax(0, 0.82fr) auto; }
  .surface.pads-only { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .pad.tappable { cursor: pointer; }
  .pad.tappable:hover { outline: 0.6cqi solid rgba(235, 237, 242, 0.45); outline-offset: -0.6cqi; }
  .pad.tappable:focus-visible { outline: 0.6cqi solid #eef0f4; outline-offset: -0.6cqi; }
  /* The scale explorer: pick on the top device, see the keyboard it makes on the one below. */
  .explorer { display: grid; gap: 14px; margin: 22px 0 10px; }
  .explorer figure { margin: 0; }
  .explorer .device-frame { max-width: 540px; }
  .explorer h4 { margin: 0 0 8px; font-size: 0.95rem; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
  .explorer h4 .where { font: 400 0.78rem/1.3 var(--font-mono); color: var(--ink-faint); }
  .explorer .readout { font-family: var(--font-mono); color: var(--ink-soft); }
  .explorer figcaption { max-width: 540px; }
  .pad {
    aspect-ratio: 1;
    border-radius: 1.3cqi;
    background: var(--led);
    display: grid;
    place-items: center;
    font: 500 clamp(5px, 1.75cqi, 11px)/1 var(--font-mono);
    overflow: hidden;
  }
  .lit { box-shadow: 0 0 1.8cqi color-mix(in srgb, var(--led) 50%, transparent); }
  .btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.8cqi; }
  .cap { width: 64%; aspect-ratio: 1; border-radius: 1cqi; background: var(--led); }
  .held { outline: 0.5cqi solid #eef0f4; outline-offset: -0.5cqi; }
  .cap-label { font: 500 clamp(5px, 1.6cqi, 10px)/1 var(--font-mono); color: var(--device-label); height: 0; overflow: visible; white-space: nowrap; }
  .btn.below { padding-bottom: 2.4cqi; }
  .rname { display: flex; flex-direction: column; gap: 0.5cqi; padding-left: 0.6cqi; white-space: nowrap; }
  .rname span { font: 500 clamp(5px, 1.5cqi, 10px)/1 var(--font-mono); color: var(--device-label-dim); }
  .rname strong { font: 600 clamp(6px, 1.9cqi, 12px)/1 var(--font-display); letter-spacing: 0.04em; color: var(--device-label); }

  .legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 10px 0 0; padding: 0; list-style: none; font-size: 0.86rem; color: var(--ink-soft); }
  .legend li { margin: 0; }

  .swatch-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px 16px; margin: 8px 0 18px; padding: 0; list-style: none; font-size: 0.92rem; }
  .swatch-grid li { margin: 0; white-space: nowrap; }

  /* ---- Responsive / print ---- */
  @media (max-width: 920px) {
    .masthead { grid-template-columns: minmax(0, 1fr); gap: 32px; }
    .layout { grid-template-columns: minmax(0, 1fr); gap: 32px; }
    /* Not pinned any more, so it has the whole page to be as tall as it likes. */
    nav.toc { position: static; max-height: none; overflow: visible; padding-right: 0; }
    .toc ol { flex-direction: row; flex-wrap: wrap; gap: 4px; }
    .toc a { border: 1px solid var(--rule); }
  }
  @media (max-width: 620px) {
    .page { padding: 28px 18px 72px; }
    .fig-pair { grid-template-columns: minmax(0, 1fr); }
    .swatch-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }
  @media print {
    nav.toc { display: none; }
    .layout { grid-template-columns: minmax(0, 1fr); }
    body { background: #fff; }
  }

  /* ---- Multi-page nav (subpages) ---- */
  .page-narrow { max-width: 796px; margin: 0 auto; padding: 40px 28px 96px; }
  .back-link {
    display: inline-flex; align-items: center; gap: 6px;
    font: 500 0.86rem/1 var(--font-mono); color: var(--ink-faint);
    text-decoration: none; margin-bottom: 18px;
  }
  .back-link:hover { color: var(--accent); }
  .topnav { display: flex; flex-wrap: wrap; gap: 4px 6px; margin: 0 0 36px; padding-bottom: 22px; border-bottom: 1px solid var(--rule); }
  .topnav a {
    font: 500 0.86rem/1 var(--font-mono); color: var(--ink-soft); text-decoration: none;
    padding: 6px 10px; border-radius: 6px; border: 1px solid transparent;
  }
  .topnav a:hover { background: var(--accent-soft); color: var(--ink); }
  .topnav a.current { color: var(--ink); border-color: var(--rule); font-weight: 500; }
  .page-narrow main { max-width: none; }
  .topnav.subnav { margin: -28px 0 34px; padding-bottom: 0; border-bottom: 0; }
  .topnav.subnav a { font-size: 0.8rem; }

  /* ---- Mode index cards (index.html) ---- */
  .mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0 0 16px; padding: 0; list-style: none; }
  .mode-grid li { margin: 0; }
  .mode-card {
    display: block; padding: 14px 16px; border: 1px solid var(--rule); border-radius: 10px;
    text-decoration: none; color: var(--ink);
  }
  .mode-card:hover { border-color: var(--accent); background: var(--accent-soft); }
  .mode-card .ctl { margin-bottom: 8px; }
  .mode-card span.blurb { display: block; margin-top: 4px; font-size: 0.88rem; color: var(--ink-soft); }
  @media (max-width: 620px) { .mode-grid { grid-template-columns: minmax(0, 1fr); } }

  /* ---- Faders (surface diagrams) ---- */
  .fader { position: relative; height: 17cqi; margin-top: 1.4cqi; }
  .fader::before {
    content: ""; position: absolute; left: 50%; top: 1.2cqi; bottom: 1.2cqi; width: 0.8cqi;
    transform: translateX(-50%); background: #0c0d10; border-radius: 0.4cqi;
  }
  .fader .knob {
    position: absolute; left: 50%; width: 64%; height: 2.4cqi; transform: translateX(-50%);
    bottom: calc(var(--pos) * (100% - 2.4cqi)); background: #b4b6be; border-radius: 0.5cqi;
    box-shadow: inset 0 -0.2cqi 0 rgba(0, 0, 0, 0.25);
  }
