  :root{
    --bg:#faf9f6;
    --surface:#ffffff;
    --surface-2:#f2f0ea;
    --border:#e2ddd0;
    --border-strong:#cfc8b8;
    --text:#211f1a;
    --text-muted:#6e6757;
    --accent:#0d7a68;
    --accent-strong:#095c4f;
    --accent-ink:#ffffff;
    --accent-soft:rgba(13,122,104,.10);
    --accent-soft-strong:rgba(13,122,104,.18);
    --badge-api-bg:rgba(13,122,104,.12);
    --badge-api-text:#0d7a68;
    --badge-config-bg:rgba(163,116,26,.14);
    --badge-config-text:#8a6314;
    --badge-none-bg:rgba(120,113,98,.14);
    --badge-none-text:#6e6757;
    --badge-always-bg:rgba(92,74,168,.14);
    --badge-always-text:#5c4aa8;
    --badge-alpha-bg:rgba(193,80,46,.14);
    --badge-alpha-text:#963c22;
    --code-bg:#1c1a16;
    --code-bg-head:#242019;
    --code-text:#dcd6c6;
    --code-border:#33301f;
    --shadow:0 1px 2px rgba(30,25,15,.04), 0 8px 24px rgba(30,25,15,.05);
  }
  /* Defaults to light regardless of system preference - only an
     explicit toggle click (data-theme="dark") switches it. */
  :root[data-theme="dark"]{
    --bg:#17150f;
    --surface:#1e1c16;
    --surface-2:#262218;
    --border:#37321f;
    --border-strong:#4a4327;
    --text:#eee9db;
    --text-muted:#a29a83;
    --accent:#39c9ab;
    --accent-strong:#6ee0c8;
    --accent-ink:#0b1512;
    --accent-soft:rgba(57,201,171,.14);
    --accent-soft-strong:rgba(57,201,171,.24);
    --badge-api-bg:rgba(57,201,171,.16);
    --badge-api-text:#5fe2c7;
    --badge-config-bg:rgba(224,168,60,.18);
    --badge-config-text:#e8bd6f;
    --badge-none-bg:rgba(160,153,131,.16);
    --badge-none-text:#b8b09a;
    --badge-always-bg:rgba(150,131,224,.18);
    --badge-always-text:#b6a4ec;
    --badge-alpha-bg:rgba(224,124,84,.18);
    --badge-alpha-text:#e8a082;
    --code-bg:#15130f;
    --code-bg-head:#1c1912;
    --code-text:#ded7c4;
    --code-border:#2c2818;
    --shadow:0 1px 2px rgba(0,0,0,.2), 0 8px 28px rgba(0,0,0,.32);
  }

  *{ box-sizing:border-box; }
  html{ scroll-behavior:smooth; }
  body{
    margin:0;
    background:var(--bg);
    color:var(--text);
    font-family:"Public Sans",system-ui,-apple-system,sans-serif;
    font-size:16px;
    line-height:1.6;
  }
  ::selection{ background:var(--accent-soft-strong); color:var(--text); }
  a{ color:var(--accent-strong); text-decoration:none; }
  a:hover{ text-decoration:underline; }
  code{
    font-family:"JetBrains Mono",ui-monospace,monospace;
    font-size:.86em;
    background:var(--surface-2);
    border:1px solid var(--border);
    padding:.08em .35em;
    border-radius:4px;
    color:var(--accent-strong);
  }
  h1,h2,h3{
    font-family:"Public Sans",system-ui,sans-serif;
    font-weight:700;
    line-height:1.2;
    text-wrap:balance;
    margin:0;
    color:var(--text);
  }

  .skip-link{
    position:absolute; left:-999px; top:0;
    background:var(--accent); color:var(--accent-ink);
    padding:.6rem 1rem; z-index:100; border-radius:0 0 6px 0;
  }
  .skip-link:focus{ left:0; }

  .layout{
    display:grid;
    grid-template-columns:280px minmax(0,1fr);
    max-width:1240px;
    margin:0 auto;
  }
  @media (max-width:960px){
    .layout{ grid-template-columns:1fr; }
  }

  .sidebar{
    position:sticky; top:0;
    align-self:start;
    height:100vh;
    overflow-y:auto;
    padding:1.6rem 1.1rem 2rem;
    border-right:1px solid var(--border);
    display:flex; flex-direction:column; gap:1.2rem;
  }
  .sidebar-header{ display:flex; align-items:flex-start; justify-content:space-between; gap:.8rem; }
  .sidebar-panel{ display:flex; flex-direction:column; gap:1.2rem; min-height:0; }
  .menu-toggle{ display:none; }
  @media (max-width:960px){
    .sidebar{
      position:sticky; top:0; z-index:20;
      height:auto; border-right:none;
      border-bottom:1px solid var(--border);
      padding:1.1rem 1.1rem 1.2rem;
      background:var(--bg);
    }
    .menu-toggle{
      display:inline-flex; align-items:center; justify-content:center;
      background:var(--surface); border:1px solid var(--border); color:var(--text-muted);
      width:2.3rem; height:2.3rem; flex-shrink:0; cursor:pointer; border-radius:6px;
      transition:border-color .15s ease, color .15s ease;
    }
    .menu-toggle:hover{ border-color:var(--border-strong); color:var(--text); }
    .sidebar-panel{ display:none; margin-top:1.1rem; max-height:70vh; overflow-y:auto; }
    .sidebar-panel.is-open{ display:flex; }
  }

  .brand{ display:flex; flex-direction:column; gap:.35rem; }
  .brand-kicker{
    font-family:"JetBrains Mono",monospace;
    font-size:.68rem; letter-spacing:.09em; text-transform:uppercase;
    color:var(--accent-strong);
  }
  .brand h1{ font-size:1.28rem; letter-spacing:-.01em; }
  .brand p{ margin:0; color:var(--text-muted); font-size:.86rem; line-height:1.5; }

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

  .theme-toggle{
    display:inline-flex; align-items:center; justify-content:center;
    background:var(--surface); border:1px solid var(--border); color:var(--text-muted);
    width:2.1rem; height:2.1rem; flex-shrink:0; cursor:pointer; border-radius:6px; align-self:flex-start;
    transition:border-color .15s ease, color .15s ease;
  }
  .theme-toggle:hover{ border-color:var(--border-strong); color:var(--text); }

  .sidebar-actions{ display:flex; gap:.5rem; flex-shrink:0; }
  .btn{
    display:inline-flex; align-items:center; justify-content:center;
    background:var(--surface); border:1px solid var(--border); color:var(--text-muted);
    height:2.1rem; padding:0 .5rem; cursor:pointer; border-radius:6px; flex:1;
    transition:border-color .15s ease, color .15s ease;
  }
  .btn:hover{ border-color:var(--accent); color:var(--accent-strong); }
  .btn:focus-visible, a:focus-visible, summary:focus-visible, .copy-btn:focus-visible{
    outline:2px solid var(--accent); outline-offset:2px;
  }

  .legend{
    display:flex; flex-wrap:wrap; gap:.4rem;
    font-size:.72rem; color:var(--text-muted);
  }

  .toc{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:.15rem; }
  .toc a{
    display:flex; align-items:center; justify-content:space-between; gap:.5rem;
    color:var(--text); text-decoration:none;
    padding:.42rem .55rem .42rem 1.2rem; border-radius:6px; font-size:.86rem;
    border-left:2px solid transparent;
  }
  .toc a:hover{ background:var(--surface-2); }
  .toc a.is-active{
    background:var(--accent-soft);
    border-left-color:var(--accent);
    color:var(--accent-strong);
    font-weight:600;
  }
  .toc-num{ font-family:"JetBrains Mono",monospace; color:var(--text-muted); font-size:.78em; }

  .toc-group summary{
    position:relative;
    list-style:none;
    cursor:pointer;
    border-radius:6px;
  }
  .toc-group summary::-webkit-details-marker{ display:none; }

  .toc-chevron{
    position:absolute;
    left:0; top:0;
    width:1.2rem; height:100%;
    display:flex; align-items:center; justify-content:center;
    cursor:pointer;
  }
  .toc-chevron::before{
    content:"";
    width:6px; height:6px;
    border-right:1.5px solid var(--text-muted);
    border-bottom:1.5px solid var(--text-muted);
    transform:rotate(-45deg);
    transition:transform .15s ease;
  }
  .toc-group[open] .toc-chevron::before{ transform:rotate(45deg); }
  .toc-sub{
    list-style:none; margin:.1rem 0 .3rem; padding:0 0 0 1.4rem;
    display:flex; flex-direction:column; gap:.05rem;
  }
  .toc-sub a{
    display:block;
    color:var(--text-muted); text-decoration:none;
    padding:.32rem .55rem; border-radius:6px; font-size:.8rem;
  }
  .toc-sub a:hover{ background:var(--surface-2); color:var(--text); }
  .toc-sub a.is-active{
    background:var(--accent-soft); color:var(--accent-strong); font-weight:600;
  }

  .sidebar-foot{
    margin-top:auto;
    padding-top:1rem;
    border-top:1px dashed var(--border);
    font-size:.78rem;
    color:var(--text-muted);
    line-height:1.55;
  }
  .sidebar-foot a{ color:var(--text-muted); text-decoration:underline; text-underline-offset:2px; }

  .badge{
    display:inline-flex; align-items:center;
    font-family:"JetBrains Mono",monospace; font-size:.64rem; letter-spacing:.05em; text-transform:uppercase;
    padding:.2rem .5rem; border-radius:999px; white-space:nowrap; flex:none;
  }
  .badge-api{ background:var(--badge-api-bg); color:var(--badge-api-text); }
  .badge-config{ background:var(--badge-config-bg); color:var(--badge-config-text); }
  .badge-none{ background:var(--badge-none-bg); color:var(--badge-none-text); }
  .badge-always{ background:var(--badge-always-bg); color:var(--badge-always-text); }
  .badge-alpha{ background:var(--badge-alpha-bg); color:var(--badge-alpha-text); }

  .toc-badge-alpha{
    display:inline-block; margin-left:.4rem;
    font-family:"JetBrains Mono",monospace; font-size:.6rem; letter-spacing:.05em; text-transform:uppercase;
    padding:.05rem .35rem; border-radius:999px; flex:none;
    background:var(--badge-alpha-bg); color:var(--badge-alpha-text);
  }

  .content{ padding:2.4rem clamp(1.2rem, 4vw, 3.2rem) 6rem; min-width:0; }

  .intro{ max-width:74ch; margin-bottom:2.6rem; }
  .intro .eyebrow{
    font-family:"JetBrains Mono",monospace; font-size:.74rem; letter-spacing:.08em; text-transform:uppercase;
    color:var(--accent-strong); margin-bottom:.7rem; display:block;
  }
  .intro h1{ font-size:clamp(1.7rem, 2vw + 1.1rem, 2.3rem); margin-bottom:1rem; }
  .intro p{ color:var(--text); margin:0 0 1rem; }
  .intro p.muted{ color:var(--text-muted); }
  .intro strong{ color:var(--text); }

  .table-scroll{ overflow-x:auto; }
  .overview-table{ width:100%; border-collapse:collapse; margin:1.6rem 0 2rem; font-size:.88rem; }
  .overview-table caption{ text-align:left; font-size:.78rem; color:var(--text-muted); margin-bottom:.5rem; }
  .overview-table th{
    text-align:left; font-size:.7rem; letter-spacing:.05em; text-transform:uppercase;
    color:var(--text-muted); padding:.5rem .7rem; border-bottom:1px solid var(--border-strong);
  }
  .overview-table td{ padding:.55rem .7rem; border-bottom:1px solid var(--border); vertical-align:top; }
  .overview-table tr:hover td{ background:var(--surface-2); }
  .overview-table td:first-child{ font-variant-numeric:tabular-nums; color:var(--text-muted); width:1%; white-space:nowrap; }
  .overview-table a{ color:var(--text); font-weight:600; }
  .cfgref-table td:first-child{ font-weight:600; }
  @media (max-width:960px){
    .cfgref-table tr{ display:flex; flex-wrap:wrap; justify-content:space-between; row-gap:.25rem; }
    .cfgref-table td, .cfgref-table th{ border-bottom:none; }
    .cfgref-table tbody tr{ border-bottom:1px solid var(--border); }
    .cfgref-table thead tr{ border-bottom:1px solid var(--border-strong); }
    .cfgref-table tbody tr:hover td{ background:none; }
    .cfgref-table tbody tr:hover{ background:var(--surface-2); }
    .cfgref-table td:nth-last-child(2), .cfgref-table th:nth-last-child(2){ text-align:right; }
    .cfgref-table td:first-child, .cfgref-table th:first-child{ text-align:left; }
    .cfgref-table td:last-child{ flex-basis:100%; }
    .cfgref-table th:last-child{ display:none; }
  }

  .wiring{
    background:var(--surface); border:1px solid var(--border); border-radius:10px;
    padding:1.2rem 1.3rem; margin-top:1.6rem; box-shadow:var(--shadow);
  }
  .wiring h2{ font-size:.98rem; margin-bottom:.5rem; }
  .wiring p{ color:var(--text-muted); font-size:.9rem; margin:0 0 .9rem; }

  main :is(.content) > section{ scroll-margin-top:1.2rem; }

  .doc-section{ margin-bottom:1rem; }
  .doc-section > details{
    background:var(--surface);
    border:1px solid var(--border);
    border-radius:12px;
    box-shadow:var(--shadow);
    overflow:hidden;
  }
  .doc-section summary{
    list-style:none; cursor:pointer;
    display:flex; align-items:center; gap:.8rem;
    padding:1.1rem 1.4rem;
  }
  .doc-section summary::-webkit-details-marker{ display:none; }
  .doc-section summary::before{
    content:"";
    width:9px; height:9px; flex:none;
    border-right:2px solid var(--text-muted);
    border-bottom:2px solid var(--text-muted);
    transform:rotate(-45deg);
    transition:transform .18s ease;
    margin-right:.2rem;
  }
  .doc-section > details[open] summary::before{ transform:rotate(45deg); }
  .doc-section summary h2{ font-size:1.05rem; flex:1; }
  .doc-section summary .toc-num{ font-family:"JetBrains Mono",monospace; color:var(--text-muted); font-size:.82em; flex:none; }
  .doc-section summary:hover{ background:var(--surface-2); }

  .section-body{ padding:0 1.4rem 1.5rem; border-top:1px solid var(--border); }
  .section-body > p, .section-body > ul{ max-width:72ch; }
  .section-body > p{ margin:1.1rem 0; }
  .section-body h3{ font-size:.92rem; margin:1.4rem 0 .6rem; color:var(--text); }
  .section-body h3:first-child{ margin-top:1.1rem; }
  .section-body h4{
    font-family:"JetBrains Mono",ui-monospace,monospace;
    font-size:.82rem; font-weight:600; margin:1.2rem 0 .5rem; color:var(--accent-strong);
  }
  .section-body h4:first-of-type{ margin-top:.9rem; }

  .config-link{
    display:inline-flex; align-items:center; gap:.4rem;
    font-size:.84rem; color:var(--text-muted);
    background:var(--surface-2); border:1px solid var(--border);
    padding:.35rem .7rem; border-radius:7px; margin:.9rem 0 .3rem;
  }
  .config-link a{ color:var(--accent-strong); font-weight:600; }

  .cfgref{ margin:1.1rem 0 1.4rem; }
  .cfgref-tabs{ display:flex; gap:.4rem; margin-bottom:.7rem; }
  .cfgref-tab{
    font-family:"JetBrains Mono",monospace; font-size:.72rem; letter-spacing:.04em; text-transform:uppercase;
    background:var(--surface-2); border:1px solid var(--border); color:var(--text-muted);
    padding:.32rem .8rem; cursor:pointer; border-radius:6px;
    transition:border-color .15s ease, color .15s ease, background .15s ease;
  }
  .cfgref-tab:hover{ color:var(--text); }
  .cfgref-tab.is-active{ background:var(--accent-soft); border-color:var(--accent); color:var(--accent-strong); }
  .cfgref-pane .overview-table{ margin:0 0 1rem; }
  .cfgref-pane .code-block{ margin:0; }

  .code-block{
    background:var(--code-bg);
    border:1px solid var(--code-border);
    border-radius:9px;
    margin:1rem 0 1.3rem;
    overflow:hidden;
  }
  .code-head{
    display:flex; align-items:center; justify-content:space-between; gap:.6rem;
    padding:.5rem .8rem;
    background:var(--code-bg-head);
    border-bottom:1px solid var(--code-border);
  }
  .code-lang{
    font-family:"JetBrains Mono",monospace; font-size:.66rem; letter-spacing:.06em; text-transform:uppercase;
    color:#9a9280;
  }
  .copy-btn{
    font-family:"JetBrains Mono",monospace; font-size:.64rem; letter-spacing:.04em; text-transform:uppercase;
    background:transparent; border:1px solid var(--code-border); color:#9a9280;
    padding:.22rem .55rem; cursor:pointer; border-radius:5px;
    transition:border-color .15s ease, color .15s ease;
  }
  .copy-btn:hover{ border-color:var(--accent); color:var(--accent-strong); }
  .copy-btn.copied{ border-color:var(--accent); color:var(--accent-strong); }
  .code-block pre{ margin:0; padding:.9rem 1.1rem 1.05rem; overflow-x:auto; }
  .code-block code{
    background:none; border:none; padding:0; border-radius:0;
    font-size:.85rem; line-height:1.65; color:var(--code-text);
    white-space:pre;
  }
  .code-note{
    font-family:"JetBrains Mono",monospace; font-size:.78rem; color:var(--text-muted);
    background:var(--surface-2); border:1px solid var(--border); border-left:3px solid var(--accent);
    padding:.5rem .8rem; margin:-.4rem 0 1.2rem; border-radius:0 6px 6px 0;
  }

  footer{
    max-width:74ch; margin-top:3rem; padding-top:1.6rem; border-top:1px solid var(--border);
    color:var(--text-muted); font-size:.86rem;
  }

  .hljs-keyword,.hljs-built_in,.hljs-type{ color:#7fd6c0; }
  .hljs-string{ color:#e3c07b; }
  .hljs-number,.hljs-literal{ color:#d99a7c; }
  .hljs-comment{ color:#7c7566; font-style:italic; }
  .hljs-title.function_,.hljs-title.class_{ color:#a7c8f0; }
  .hljs-attr,.hljs-property{ color:#8fd4e8; }
  .hljs-punctuation,.hljs-operator{ color:#bcb6a4; }
