  body { display: grid; grid-template-columns: 17rem 1fr; min-height: 100vh; }
  @media (max-width: 900px) { body { grid-template-columns: 1fr; } .toc { position: static; height: auto; } }

  .toc {
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    background: var(--bg-1); border-right: 1px solid var(--line); padding: 1.6rem 1.2rem;
  }
  .toc h2 { font-family: var(--font-display); font-size: 1rem; font-weight: 500; margin: 0 0 .3rem; }
  .toc .ver { font-size: .72rem; color: var(--ink-3); margin-bottom: 1.4rem; }
  .toc a {
    display: block; padding: .38rem .5rem; border-radius: var(--r-sm);
    color: var(--ink-2); text-decoration: none; font-size: .84rem;
  }
  .toc a:hover { background: var(--bg-2); color: var(--ink-0); }
  .toc a.sub { padding-left: 1.4rem; font-size: .8rem; color: var(--ink-3); }
  .toc .back { margin-top: 1.4rem; color: var(--accent-text); font-size: .82rem; }

  main { padding: 2.6rem clamp(1.2rem, 4vw, 4rem); max-width: 62rem; }
  h1 { font-family: var(--font-display); font-weight: 500; font-size: clamp(1.8rem, 3.4vw, 2.6rem); margin: 0 0 .4rem; }
  .lede { color: var(--ink-2); font-size: 1rem; margin: 0 0 2.6rem; max-width: 46rem; line-height: 1.6; }
  section { margin-bottom: 3.2rem; scroll-margin-top: 1.5rem; }
  h2 {
    font-family: var(--font-display); font-weight: 500; font-size: 1.5rem;
    margin: 0 0 1rem; padding-bottom: .5rem; border-bottom: 1px solid var(--line);
  }
  h3 { font-size: 1rem; font-weight: 600; margin: 1.8rem 0 .6rem; color: var(--ink-0); }
  h4 { font-size: .82rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
       margin: 1.6rem 0 .6rem; color: var(--ink-2); }
  ol li { margin-bottom: .8rem; }
  li pre { margin: .6rem 0; }
  p, li { color: var(--ink-1); line-height: 1.68; font-size: .92rem; }
  ul, ol { padding-left: 1.3rem; }
  li { margin-bottom: .4rem; }
  strong { color: var(--ink-0); }
  code {
    font-family: var(--font-mono); font-size: .85em;
    background: var(--bg-2); border: 1px solid var(--line);
    border-radius: 4px; padding: .1rem .35rem; color: var(--ink-0);
  }
  pre {
    background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-md);
    padding: 1rem 1.1rem; overflow-x: auto; margin: 1rem 0;
  }
  pre code { background: none; border: 0; padding: 0; font-size: .82rem; line-height: 1.65; }
  table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: .88rem; }
  th, td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
  th { color: var(--ink-2); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
  td code { white-space: nowrap; }
  .note, .warn {
    border-left: 3px solid var(--accent); background: var(--bg-2);
    padding: .9rem 1.1rem; border-radius: 0 var(--r-md) var(--r-md) 0; margin: 1.2rem 0;
    font-size: .88rem; color: var(--ink-1); line-height: 1.6;
  }
  .warn { border-left-color: var(--err); }
  .path { color: var(--ink-3); font-family: var(--font-mono); font-size: .78rem; }
  .pill {
    display: inline-block; font-size: .7rem; letter-spacing: .06em; text-transform: uppercase;
    background: var(--bg-3); color: var(--ink-2); border-radius: 999px; padding: .15rem .55rem; margin-left: .4rem;
  }

  /* ---- mobile friendliness ---- */
  main { min-width: 0; }                 /* let grid track shrink so tables scroll, not the page */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 1rem 0; }
  .table-wrap table { margin: 0; }
  .toc summary { display: none; }        /* desktop: no toggle, sidebar always open */
  @media (min-width: 901px) {
    .toc-links { display: block !important; }   /* force <details> content open on desktop */
  }
  @media (max-width: 900px) {
    body { display: block; }
    .toc {
      position: sticky; top: 0; z-index: 20; height: auto;
      padding: .55rem 1rem; border-right: 0; border-bottom: 1px solid var(--line);
    }
    .toc h2 { display: none; }            /* summary label replaces the heading */
    .toc .ver { display: none; }
    .toc summary {
      display: block; cursor: pointer; list-style: none;
      font-family: var(--font-display); font-size: 1.05rem; color: var(--ink-0);
      padding: .5rem .2rem;
    }
    .toc summary::-webkit-details-marker { display: none; }
    .toc summary::after { content: "▾"; float: right; color: var(--ink-3); }
    .toc[open] summary::after { content: "▴"; }
    .toc-links { padding: .3rem 0 .6rem; max-height: 70vh; overflow-y: auto; }
    .toc a { padding: .6rem .5rem; }      /* bigger touch targets */
    main { padding: 1.6rem 1.1rem 3rem; }
    section { margin-bottom: 2.4rem; }
    pre, .table-wrap { margin-left: 0; margin-right: 0; }
    code { word-break: break-word; }
  }

/* ---- server-rendered pages (lib/docs.js) ---- */
.toc a.here { background: var(--bg-2); color: var(--ink-0); font-weight: 600; }
.toc h2 a { color: inherit; text-decoration: none; background: none; }
.crumbs { font-size: .8rem; color: var(--ink-3); margin: 0 0 1rem; }
.crumbs a { color: var(--accent-text); text-decoration: none; }
.lede { color: var(--ink-2); font-size: 1rem; margin: 0 0 2rem; max-width: 46rem; line-height: 1.6; }
.lede p { font-size: 1rem; color: var(--ink-2); }
.cards { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.card {
  display: block; text-decoration: none; background: var(--bg-1); border: 1px solid var(--line);
  border-radius: 10px; padding: 1rem 1.1rem;
}
.card:hover { border-color: var(--accent); }
.card h2 { font-size: 1.05rem; border: 0; margin: 0 0 .35rem; padding: 0; color: var(--ink-0); }
.card p { margin: 0; font-size: .84rem; color: var(--ink-2); line-height: 1.5; }
article h2 { margin-top: 2.2rem; }
.pager { display: flex; justify-content: space-between; gap: 1rem; margin: 3rem 0 1rem; font-size: .88rem; }
.pager a { color: var(--accent-text); text-decoration: none; }
.updated { color: var(--ink-3); font-size: .78rem; }
