  :root {
    color-scheme: light dark;

    --ground: #eceff1;
    --surface: #ffffff;
    --surface-2: #f4f7f8;
    --ink: #0e1518;
    --ink-2: #37484f;
    --muted: #6b7f88;
    --rule: #d2dade;
    --rule-2: #e2e8ea;
    --accent: #00778f;
    --accent-2: #00a8c8;
    --mag: #ab1259;
    --shadow: 0 1px 2px rgba(14, 21, 24, .06), 0 8px 24px -12px rgba(14, 21, 24, .18);

    --tok-key: var(--accent);
    --tok-str: #97295a;
    --tok-com: #86999f;
    --tok-num: #2f5f6d;

    --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, "DejaVu Sans Mono", Consolas, monospace;
    --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;

    --step: 0.5rem;
    --measure: 68ch;
  }

  @media (prefers-color-scheme: dark) {
    :root {
      --ground: #0a1013;
      --surface: #101a1e;
      --surface-2: #16232a;
      --ink: #e3ecef;
      --ink-2: #b3c4cb;
      --muted: #82979f;
      --rule: #22333a;
      --rule-2: #1a282e;
      --accent: #3fd0e8;
      --accent-2: #83e4f3;
      --mag: #ff6fa8;
      --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 10px 30px -14px rgba(0, 0, 0, .8);

      --tok-str: #ff8fbc;
      --tok-com: #6d848c;
      --tok-num: #9fd7e4;
    }
  }

  :root[data-theme="light"] {
    --ground: #eceff1;
    --surface: #ffffff;
    --surface-2: #f4f7f8;
    --ink: #0e1518;
    --ink-2: #37484f;
    --muted: #6b7f88;
    --rule: #d2dade;
    --rule-2: #e2e8ea;
    --accent: #00778f;
    --accent-2: #00a8c8;
    --mag: #ab1259;
    --shadow: 0 1px 2px rgba(14, 21, 24, .06), 0 8px 24px -12px rgba(14, 21, 24, .18);
    --tok-str: #97295a;
    --tok-com: #86999f;
    --tok-num: #2f5f6d;
  }

  :root[data-theme="dark"] {
    --ground: #0a1013;
    --surface: #101a1e;
    --surface-2: #16232a;
    --ink: #e3ecef;
    --ink-2: #b3c4cb;
    --muted: #82979f;
    --rule: #22333a;
    --rule-2: #1a282e;
    --accent: #3fd0e8;
    --accent-2: #83e4f3;
    --mag: #ff6fa8;
    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 10px 30px -14px rgba(0, 0, 0, .8);
    --tok-str: #ff8fbc;
    --tok-com: #6d848c;
    --tok-num: #9fd7e4;
  }

  html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

  [id] { scroll-margin-top: 2rem; }

  body {
    margin: 0;
    background: var(--ground);
    color: var(--ink);
    font-family: var(--serif);
    font-size: 17px;
    line-height: 1.65;
  }

  ::selection { background: var(--accent); color: var(--surface); }

  :focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 2px;
  }

  .page {
    max-width: 1140px;
    margin-inline: auto;
    padding: 0 clamp(1rem, 4vw, 3rem) 6rem;
  }

  /* ---- masthead ---------------------------------------------------- */

  .masthead {
    display: grid;
    gap: 1.25rem;
    padding: clamp(3rem, 8vw, 5.5rem) 0 clamp(2rem, 5vw, 3rem);
    border-bottom: 1px solid var(--rule);
  }

  .eyebrow {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    align-items: baseline;
  }

  .eyebrow b { color: var(--accent); font-weight: 500; }

  h1 {
    font-family: var(--mono);
    font-weight: 500;
    font-size: clamp(2rem, 6.5vw, 3.4rem);
    letter-spacing: -.02em;
    line-height: 1.05;
    margin: 0;
    text-wrap: balance;
  }

  h1 span { color: var(--muted); }

  .lede {
    margin: 0;
    max-width: var(--measure);
    font-size: clamp(1.05rem, 2.2vw, 1.25rem);
    color: var(--ink-2);
  }

  .facts {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1.75rem;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--muted);
    margin-top: .25rem;
  }

  .facts span { display: inline-flex; gap: .5rem; }
  .facts span i { font-style: normal; color: var(--ink); }

  /* ---- section scaffold -------------------------------------------- */

  .sec {
    display: grid;
    grid-template-columns: 9.5rem minmax(0, 1fr);
    gap: 0 2.5rem;
    padding: clamp(2.5rem, 6vw, 4rem) 0;
    border-bottom: 1px solid var(--rule);
    align-items: start;
  }

  .sec-label {
    position: sticky;
    top: 1.5rem;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--muted);
    display: grid;
    gap: .35rem;
  }

  .sec-label em {
    font-style: normal;
    letter-spacing: .02em;
    text-transform: none;
    color: var(--muted);
    opacity: .65;
  }

  .sec-body { display: grid; gap: 1.5rem; min-width: 0; }
  .sec-body > p { margin: 0; max-width: var(--measure); color: var(--ink-2); }

  h2 {
    font-family: var(--serif);
    font-weight: 600;
    font-size: 1.35rem;
    line-height: 1.25;
    margin: 0;
    letter-spacing: -.01em;
  }

  h3 {
    font-family: var(--mono);
    font-weight: 500;
    font-size: 11.5px;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--ink);
    margin: 1rem 0 0;
  }

  h3:first-child { margin-top: 0; }

  @media (max-width: 820px) {
    .sec { grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
    .sec-label { position: static; }
  }

  /* ---- on-this-page rail -------------------------------------------- */

  /* Parked outside the 1140px measure when the viewport can afford it; below
     that it collapses to bare ticks and only opens over the text on demand. */

  .toc {
    position: fixed;
    z-index: 5;
    top: 50%;
    right: 1rem;
    transform: translateY(-50%);
    max-height: 84vh;
    overflow: auto;
    overscroll-behavior: contain;
    padding: .8rem .9rem;
    border: 1px solid transparent;
    border-radius: 3px;
    font-family: var(--mono);
    font-size: 11px;
    line-height: 1.5;
    transition: background-color .18s, border-color .18s, box-shadow .18s;
  }

  .toc-title {
    margin: 0 0 .7rem;
    font-size: 10px;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
  }

  .toc ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: .3rem;
  }

  .toc a {
    display: flex;
    align-items: center;
    gap: .6rem;
    text-decoration: none;
    color: var(--muted);
    letter-spacing: .04em;
    transition: color .15s;
  }

  /* The tick doubles as the whole affordance once the labels are collapsed. */
  .toc a::before {
    content: "";
    flex: none;
    width: .85rem;
    height: 1px;
    background: currentColor;
    opacity: .6;
    transition: width .18s, background-color .15s, opacity .15s;
  }

  .toc li.sub a { font-size: 10.5px; }
  .toc li.sub a::before { width: .45rem; margin-left: .4rem; }

  .toc a:hover { color: var(--ink); }
  .toc a:hover::before { opacity: 1; }

  .toc a[aria-current] { color: var(--accent); }
  .toc a[aria-current]::before { width: 1.6rem; background: var(--accent); opacity: 1; }
  .toc li.sub a[aria-current]::before { width: 1.2rem; }

  .toc-label { white-space: nowrap; }

  @media (min-width: 1500px) {
    .toc { right: calc(50vw - 570px - 13rem); }
  }

  /* Not enough gutter to sit beside the text: ticks only until asked. */
  @media (max-width: 1499px) {
    .toc-title,
    .toc-label {
      max-width: 0;
      overflow: hidden;
      opacity: 0;
      transition: max-width .2s, opacity .2s;
    }

    .toc:hover,
    .toc:focus-within {
      background: var(--surface);
      border-color: var(--rule);
      box-shadow: var(--shadow);
    }

    .toc:hover .toc-title,
    .toc:hover .toc-label,
    .toc:focus-within .toc-title,
    .toc:focus-within .toc-label {
      max-width: 12rem;
      opacity: 1;
    }
  }

  @media (max-width: 1023px) {
    .toc { display: none; }
  }

  /* ---- plate (demo frame with registration ticks) ------------------- */

  .plate { position: relative; padding: 13px; }

  .plate::before,
  .plate::after {
    content: "";
    position: absolute;
    width: 13px;
    height: 13px;
    border: 1px solid var(--muted);
    opacity: .55;
    pointer-events: none;
  }

  .plate::before { top: 0; left: 0; border-right: 0; border-bottom: 0; }
  .plate::after { right: 0; bottom: 0; border-left: 0; border-top: 0; }

  .plate-cap {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: .5rem 1.5rem;
    font-family: var(--mono);
    font-size: 11.5px;
    letter-spacing: .04em;
    color: var(--muted);
    padding: .75rem 13px 0;
  }

  .readout { color: var(--ink); font-variant-numeric: tabular-nums; }
  .readout b { color: var(--accent); font-weight: 500; }

  .hero-demo { padding-top: clamp(2rem, 5vw, 3rem); }

  before-after {
    box-shadow: var(--shadow);
    --ba-radius: 3px;
  }

  .demo-grid {
    display: grid;
    gap: 2rem;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 21rem), 1fr));
    align-items: start;
  }

  /* ---- code -------------------------------------------------------- */

  pre, code, kbd { font-family: var(--mono); }

  .code {
    margin: 0;
    background: var(--surface-2);
    border: 1px solid var(--rule);
    border-radius: 3px;
    padding: 1rem 1.1rem;
    font-size: 13px;
    line-height: 1.75;
    overflow-x: auto;
    tab-size: 2;
    color: var(--ink);
  }

  .code .t { color: var(--accent); }
  .code .a { color: var(--ink-2); }
  .code .v { color: var(--tok-str); }
  .code .c { color: var(--tok-com); }
  .code .k { color: var(--tok-key); }
  .code .s { color: var(--tok-str); }
  .code .tpl { color: var(--ink-2); }
  .code .n { color: var(--tok-num); }

  p code, td code, li code {
    background: var(--surface-2);
    border: 1px solid var(--rule-2);
    border-radius: 3px;
    padding: .08em .38em;
    font-size: .82em;
  }

  kbd {
    display: inline-block;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-bottom-width: 2px;
    border-radius: 4px;
    padding: .05em .45em;
    font-size: 11.5px;
    color: var(--ink);
    white-space: nowrap;
  }

  /* ---- tables ------------------------------------------------------ */

  .table-wrap {
    overflow-x: auto;
    border: 1px solid var(--rule);
    border-radius: 3px;
    background: var(--surface);
  }

  table {
    border-collapse: collapse;
    width: 100%;
    font-size: 14px;
    font-family: var(--serif);
  }

  th, td {
    text-align: left;
    padding: .7rem .9rem;
    border-bottom: 1px solid var(--rule-2);
    vertical-align: baseline;
  }

  tbody tr:last-child td { border-bottom: 0; }

  th {
    font-family: var(--mono);
    font-size: 10.5px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 500;
    background: var(--surface-2);
    white-space: nowrap;
  }

  td:first-child { white-space: nowrap; }
  td .name { font-family: var(--mono); font-size: 12.5px; color: var(--ink); }
  td .type { font-family: var(--mono); font-size: 12px; color: var(--mag); }
  td .def { font-family: var(--mono); font-size: 12px; color: var(--muted); }

  /* ---- lists ------------------------------------------------------- */

  ul.notes {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: .85rem;
    max-width: var(--measure);
  }

  ul.notes li {
    padding-left: 1.15rem;
    position: relative;
    color: var(--ink-2);
  }

  ul.notes li::before {
    content: "";
    position: absolute;
    left: 0;
    top: .72em;
    width: .5rem;
    height: 1px;
    background: var(--accent);
  }

  /* ---- download ---------------------------------------------------- */

  .dl {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem .9rem;
    margin: 0;
  }

  .dl-main {
    font-family: var(--mono);
    font-size: 12.5px;
    color: var(--accent);
    text-decoration: none;
    border: 1px solid var(--accent);
    border-radius: 3px;
    padding: .45rem .9rem;
    transition: background .15s, color .15s;
  }

  .dl-main:hover { background: var(--accent); color: var(--ground); }

  .dl-meta { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
  .dl-meta a { color: var(--ink-2); }

  /* ---- source block ------------------------------------------------ */

  .source-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    font-family: var(--mono);
    font-size: 11.5px;
    letter-spacing: .06em;
    color: var(--muted);
    border: 1px solid var(--rule);
    border-bottom: 0;
    border-radius: 3px 3px 0 0;
    background: var(--surface-2);
    padding: .55rem .9rem;
  }

  .source-head + .code {
    border-radius: 0 0 3px 3px;
    max-height: 32rem;
    overflow: auto;
    background: var(--surface);
  }

  .source-actions { display: inline-flex; gap: .4rem; }

  /* Shared by the Copy button and the Download link beside it. */
  .copy {
    font: inherit;
    font-family: var(--mono);
    letter-spacing: .1em;
    text-transform: uppercase;
    font-size: 10.5px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 3px;
    padding: .3rem .7rem;
    cursor: pointer;
    transition: border-color .15s, color .15s;
  }

  a.copy { text-decoration: none; }

  .copy:hover { border-color: var(--accent); color: var(--accent); }
  .copy[data-done="1"] { color: var(--accent); border-color: var(--accent); }

  footer.foot {
    padding: 2.5rem 0 0;
    font-family: var(--mono);
    font-size: 11.5px;
    letter-spacing: .06em;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1.5rem;
  }

  /* ---- demo content: code panes ------------------------------------ */

  .pane-code {
    margin: 0;
    height: 100%;
    box-sizing: border-box;
    padding: 2.9rem clamp(.55rem, 2.4vw, 1.25rem) 1.4rem;
    font-size: clamp(9px, 1.55vw, 13px);
    line-height: 1.7;
    white-space: pre;
    overflow: hidden;
    background: var(--surface);
    color: var(--ink);
  }

  .pane-code.is-before { background: var(--surface-2); }

  @media (prefers-reduced-motion: reduce) {
    * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
    html { scroll-behavior: auto; }
  }

  .ribbon {
  background-color: #a00;
  overflow: hidden;
  white-space: nowrap;
  position: absolute;
  right: -50px;
  top: 40px;
  /* 45 deg ccw rotation */
  -webkit-transform: rotate(45deg);
     -moz-transform: rotate(45deg);
      -ms-transform: rotate(45deg);
       -o-transform: rotate(45deg);
          transform: rotate(45deg);
  /* shadow */
  -webkit-box-shadow: 0 0 10px #888;
      -moz-box-shadow: 0 0 10px #888;
          box-shadow: 0 0 10px #888;
}
.ribbon a {
  border: 1px solid #faa;
  color: #fff;
  display: block;
  font: bold 81.25% "Helvetica Neue", Helvetica, Arial, sans-serif;
  margin: 1px 0;
  padding: 10px 50px;
  text-align: center;
  text-decoration: none;
  /* shadow */
  text-shadow: 0 0 5px #444;
}
