/* Kestrel Docs. Colours, type and spacing are tokens here, with a light set and a dark set that match the Kestrel site.
   The drawings read the --illos-* roles, so they follow the theme switch. */

:root {
  --bg: #fafaf8;
  --card: #ffffff;
  --bg-2: #f3f3ef;
  --bg-3: #ebebe6;
  --fg: #141414;
  --fg-2: #4f4f4c;
  --fg-3: #6e6e69;
  --line: #e6e5df;
  --line-2: #d6d5ce;
  --accent: #178c7d;
  --accent-text: #0f6e62;
  --accent-soft: #edf7f4;
  --accent-line: #bfe3dc;
  --accent-btn: #178c7d;
  --accent-btn-fg: #ffffff;
  --warn: #8a5300;
  --warn-soft: #fdf6e9;
  --warn-line: #efd7a6;
  --hl: rgb(23 140 125 / 0.09);
  --pop: 0 0 0 1px rgb(20 20 20 / 0.07), 0 12px 32px -12px rgb(20 20 20 / 0.18), 0 4px 10px -4px rgb(20 20 20 / 0.06);
  --scrim: rgb(16 17 18 / 0.32);

  --illos-ground: var(--card);
  --illos-ink: #2a2a2a;
  --illos-ramp-1: #16645a;
  --illos-ramp-2: #1daf9c;
  --illos-ramp-3: #3fdec9;
  --illos-ramp-4: #c9efe9;
  --illos-mark: #178c7d;
  --illos-spark: #0b463e;

  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* type scale, by role */
  --t-label: 0.75rem;   /* 12, mono labels */
  --t-cap: 0.8125rem;   /* 13 */
  --t-ui: 0.875rem;     /* 14 */
  --t-body: 1rem;       /* 16 */
  --t-lede: 1.0625rem;  /* 17 */
  --t-h3: 1.0625rem;    /* 17 */
  --t-h2: 1.375rem;     /* 22 */
  --t-h1: 2rem;         /* 32 */

  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;

  --r: 6px;        /* cards, code, figures, callouts */
  --r-sm: 4px;     /* buttons, fields, keys */
  --row-h: 64px;
  --tabs-h: 46px;
  --hdr-h: calc(var(--row-h) + var(--tabs-h));
  --control: 34px;
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  interpolate-size: allow-keywords;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #101112;
  --card: #151718;
  --bg-2: #18191b;
  --bg-3: #1f2123;
  --fg: #ededea;
  --fg-2: #b3b3ad;
  --fg-3: #8a8a84;
  --line: #232527;
  --line-2: #303336;
  --accent: #3fdec9;
  --accent-text: #63e4d1;
  --accent-soft: #0f2522;
  --accent-line: #1d4741;
  --accent-btn: #3fdec9;
  --accent-btn-fg: #0b1110;
  --warn: #f0c46c;
  --warn-soft: #1d180d;
  --warn-line: #4a3c1c;
  --hl: rgb(63 222 201 / 0.08);
  --pop: 0 0 0 1px rgb(255 255 255 / 0.09), 0 18px 44px -12px rgb(0 0 0 / 0.7);
  --scrim: rgb(0 0 0 / 0.56);
  --illos-ink: #dadadc;
  --illos-ramp-1: #84ebdd;
  --illos-ramp-2: #3fdec9;
  --illos-ramp-3: #1daf9c;
  --illos-ramp-4: #1a7569;
  --illos-mark: #3fdec9;
  --illos-spark: #ffffff;
  color-scheme: dark;
}

@media (pointer: coarse) { :root { --control: 44px; } }

/* base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--hdr-h) + var(--s-5)); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 var(--t-body)/1.7 var(--sans);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.theme-switching *, .theme-switching *::before, .theme-switching *::after { transition: none !important; }
a { color: inherit; }
p, ul, ol, figure { margin: 0; }
button { font: inherit; color: inherit; }
button, a, input, summary { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; border-radius: 2px; }
::selection { background: color-mix(in oklch, var(--accent) 24%, transparent); }
kbd { font: 500 11px/1 var(--mono); }
.i { flex: none; display: block; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: var(--s-3); top: -60px; z-index: 40; background: var(--fg); color: var(--bg); padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); text-decoration: none; font-size: var(--t-ui); }
.skip:focus { top: var(--s-3); }
.wrap { width: 100%; max-width: 1312px; margin: 0 auto; padding: 0 var(--s-6); }

/* controls */
.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: var(--control); height: var(--control);
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--fg-2); cursor: pointer;
  transition: background-color 150ms var(--ease), color 150ms var(--ease), transform 120ms var(--ease);
}
.icon-btn:active { transform: scale(0.96); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--control); padding: 0 var(--s-4);
  border: 0; border-radius: var(--r-sm); cursor: pointer; white-space: nowrap; text-decoration: none;
  font: 500 var(--t-label)/1 var(--mono); letter-spacing: 0.04em; text-transform: uppercase;
  transition: background-color 150ms var(--ease), color 150ms var(--ease), transform 120ms var(--ease);
}
.btn:active { transform: scale(0.96); }
.btn--accent { background: var(--accent-btn); color: var(--accent-btn-fg); }
.sbtn {
  display: inline-flex; align-items: center; gap: var(--s-2); height: 32px; padding: 0 var(--s-3);
  border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--card); color: var(--fg-2); cursor: pointer;
  font: 500 var(--t-label)/1 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap;
  transition: background-color 150ms var(--ease), color 150ms var(--ease), border-color 150ms var(--ease), transform 120ms var(--ease);
}
.sbtn:active { transform: scale(0.96); }
@media (pointer: coarse) { .sbtn { height: 44px; } }
@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover { background: var(--bg-3); color: var(--fg); }
  .btn--accent:hover { background: color-mix(in oklch, var(--accent-btn) 88%, var(--fg)); }
  .sbtn:hover { background: var(--bg-2); color: var(--fg); border-color: color-mix(in oklch, var(--line-2) 70%, var(--fg-3)); }
}
.i-sun { display: none; }
[data-theme="dark"] .i-sun { display: block; }
[data-theme="dark"] .i-moon { display: none; }

/* header: brand, search and ask, then the section tabs */
.hdr {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in oklch, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.hdr__row { position: relative; display: flex; align-items: center; gap: var(--s-4); height: var(--row-h); }
.hdr__row::after { content: ""; position: absolute; left: var(--s-6); right: var(--s-6); bottom: 0; height: 1px; background: var(--line); }
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--fg); flex: none; }
.brand b { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.brand__mark { width: 22px; height: 22px; fill: var(--fg); flex: none; }
.brand__mark circle { fill: var(--accent); }
.brand__docs { margin-inline-start: 2px; padding: 3px 6px; border: 1px solid var(--line-2); border-radius: var(--r-sm); font: 500 11px/1 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; color: var(--fg-3); }
.hdr__mid { position: absolute; left: 50%; transform: translateX(-50%); display: flex; gap: var(--s-2); }
.field {
  display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 var(--s-3);
  border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--card); color: var(--fg-3); cursor: pointer;
  font-size: var(--t-ui); text-align: start;
  transition: border-color 150ms var(--ease), color 150ms var(--ease);
}
.field[data-open-search] { width: 252px; }
.field[data-open-search] span { flex: 1; }
.field kbd { color: var(--fg-3); letter-spacing: 0.02em; }
.field--ask { color: var(--fg-2); }
@media (hover: hover) and (pointer: fine) { .field:hover { color: var(--fg); border-color: color-mix(in oklch, var(--line-2) 60%, var(--fg-3)); } }
.ask { position: relative; }
.hdr__end { margin-inline-start: auto; display: flex; align-items: center; gap: var(--s-3); }
.hdr__link { font-size: var(--t-ui); color: var(--fg-2); text-decoration: none; padding: 0 var(--s-2); transition: color 150ms var(--ease); }
@media (hover: hover) and (pointer: fine) { .hdr__link:hover { color: var(--fg); } }
.hdr__search { display: none !important; }

.tabs { display: flex; align-items: stretch; gap: var(--s-6); height: var(--tabs-h); overflow-x: auto; scrollbar-width: none; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: var(--s-2); flex: none;
  font-size: var(--t-ui); font-weight: 500; color: var(--fg-3); text-decoration: none;
  transition: color 150ms var(--ease);
}
.tab::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--fg); transform: scaleX(0); transition: transform 220ms var(--ease); }
.tab[aria-current] { color: var(--fg); }
.tab[aria-current]::after { transform: none; }
@media (hover: hover) and (pointer: fine) { .tab:hover { color: var(--fg); } }
.crumbbar { display: none; }

/* the body: sidebar, page, on this page */
.body { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: var(--s-6); }
.side { position: sticky; top: var(--hdr-h); height: calc(100dvh - var(--hdr-h)); overflow-y: auto; overscroll-behavior: contain; padding: var(--s-6) var(--s-2) var(--s-7) 0; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.nav { display: grid; align-content: start; gap: var(--s-5); }
.nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.nav__title { margin-bottom: var(--s-2); font-size: var(--t-ui); font-weight: 600; color: var(--fg); }
.nav a {
  position: relative; display: flex; align-items: center; gap: 10px; min-height: 32px; padding: 0;
  text-decoration: none; font-size: var(--t-ui); color: var(--fg-2);
  transition: color 150ms var(--ease);
}
.nav a .i { color: var(--fg-3); transition: color 150ms var(--ease); }
.nav a[aria-current="page"] { color: var(--fg); font-weight: 500; }
.nav a[aria-current="page"] .i { color: var(--accent); }
@media (hover: hover) and (pointer: fine) { .nav a:not([aria-current]):hover { color: var(--fg); } .nav a:hover .i { color: var(--fg-2); } }
.nav__group:not(.nav__group--flat) { margin-top: calc(var(--s-5) * -1 + 2px); }
.nav__group--flat + .nav__group:not(.nav__group--flat) { margin-top: var(--s-1); }
.nav summary {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px;
  list-style: none; cursor: pointer; user-select: none;
  font-size: var(--t-ui); font-weight: 500; color: var(--fg-2);
  transition: color 150ms var(--ease);
}
.nav summary::-webkit-details-marker { display: none; }
.nav summary .i { color: var(--fg-3); transition: transform 200ms var(--ease); }
.nav details[open] > summary { color: var(--fg); }
.nav details[open] > summary .i { transform: rotate(90deg); }
@media (hover: hover) and (pointer: fine) { .nav summary:hover { color: var(--fg); } }
.nav details::details-content { height: 0; overflow: clip; transition: height 240ms var(--ease), content-visibility 240ms allow-discrete; }
.nav details[open]::details-content { height: auto; }
.nav__sub { margin: 2px 0 var(--s-2) 3px !important; border-inline-start: 1px solid var(--line); }
.nav__sub a { padding-inline-start: var(--s-4); }
.nav__sub a[aria-current="page"]::before { content: ""; position: absolute; left: -1px; top: 6px; bottom: 6px; width: 1px; background: var(--fg); }
@media (pointer: coarse) { .nav a, .nav summary { min-height: 44px; } }

.main { display: grid; grid-template-columns: minmax(0, 704px) 216px; gap: var(--s-8); justify-content: space-between; padding: var(--s-6) 0 var(--s-8); min-width: 0; }
.doc { min-width: 0; }
.doc__head { margin-bottom: var(--s-6); }
.eyebrow { margin-bottom: var(--s-3); font: 400 var(--t-label)/1.2 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; color: var(--fg-3); }
.doc__title { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-5); }
.doc h1 { margin: 0; font-size: var(--t-h1); line-height: 1.15; font-weight: 600; letter-spacing: -0.03em; text-wrap: balance; }
.lede { margin-top: var(--s-4); max-width: 64ch; font-size: var(--t-lede); line-height: 1.6; color: var(--fg-2); text-wrap: pretty; }

/* Copy page, with a menu of other ways to use the page */
.split { position: relative; display: inline-flex; flex: none; margin-top: 2px; }
.split > .sbtn:first-child { border-start-end-radius: 0; border-end-end-radius: 0; }
.split__more { width: 32px; padding: 0; justify-content: center; border-inline-start: 0; border-start-start-radius: 0; border-end-start-radius: 0; }
@media (pointer: coarse) { .split__more { width: 44px; } }
.split__label { display: inline-grid; }
.split__label > span { grid-area: 1 / 1; transition: opacity 150ms var(--ease), filter 150ms var(--ease), transform 150ms var(--ease); }
.split__label .when-done { opacity: 0; filter: blur(2px); transform: scale(0.96); }
[data-copy-page].is-done .when-idle { opacity: 0; filter: blur(2px); transform: scale(0.96); }
[data-copy-page].is-done .when-done { opacity: 1; filter: none; transform: none; color: var(--accent-text); }
.menu {
  position: absolute; top: calc(100% + 6px); z-index: 30;
  width: 280px; padding: 5px; border-radius: var(--r); background: var(--card); box-shadow: var(--pop);
}
.menu--page { right: 0; transform-origin: top right; }
.menu--ask { left: 0; transform-origin: top left; }
.menu:not([hidden]) { animation: menu-in 160ms var(--ease); }
@keyframes menu-in { from { opacity: 0; transform: scale(0.96) translateY(-3px); } }
.menu a { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) 10px; border-radius: var(--r-sm); text-decoration: none; color: var(--fg-3); }
.menu a > span { flex: 1; display: grid; }
.menu b { font-size: var(--t-ui); font-weight: 500; color: var(--fg); }
.menu small { font-size: 12px; color: var(--fg-3); line-height: 1.4; }
.menu a:focus-visible { outline-offset: -2px; }
@media (hover: hover) and (pointer: fine) { .menu a:hover { background: var(--bg-2); } }

/* prose */
.prose > * + * { margin-top: var(--s-4); }
.prose p, .prose li { color: var(--fg-2); text-wrap: pretty; }
.prose p { max-width: 70ch; }
.prose strong { color: var(--fg); font-weight: 600; }
.prose h2, .prose h3 { color: var(--fg); }
.prose h2 { margin: var(--s-7) 0 0; font-size: var(--t-h2); line-height: 1.3; font-weight: 600; letter-spacing: -0.02em; text-wrap: balance; }
.prose h3 { margin: var(--s-6) 0 0; font-size: var(--t-h3); line-height: 1.45; font-weight: 600; letter-spacing: -0.01em; }
.prose h2 + *, .prose h3 + * { margin-top: var(--s-3); }
.anchor { text-decoration: none; }
.anchor::after { content: "#"; margin-inline-start: 0.4em; color: var(--fg-3); font-weight: 400; opacity: 0; transition: opacity 150ms var(--ease); }
@media (hover: hover) and (pointer: fine) { .anchor:hover::after { opacity: 1; } }
.prose a:not(.anchor, .card) {
  color: var(--fg); text-decoration: underline;
  text-decoration-thickness: 1px; text-underline-offset: 0.22em; text-decoration-color: var(--line-2);
  transition: text-decoration-color 150ms var(--ease);
}
@media (hover: hover) and (pointer: fine) { .prose a:not(.anchor, .card):hover { text-decoration-color: var(--fg); } }
.prose ul, .prose ol:not(.steps) { padding-inline-start: 1.3em; display: grid; gap: var(--s-2); }
.prose li::marker { color: var(--fg-3); }
.prose :not(pre) > code {
  font: 400 0.84em/1 var(--mono); color: var(--fg);
  padding: 0.18em 0.38em; border-radius: var(--r-sm); background: var(--bg-2); border: 1px solid var(--line);
  overflow-wrap: break-word;
}
.prose hr { border: 0; height: 1px; background: var(--line); margin: var(--s-7) 0; }

/* numbered steps on a rail */
.steps { list-style: none; padding: 0; counter-reset: step; }
.steps > .step + .step { margin-top: 0; }
.step { position: relative; counter-increment: step; padding: 0 0 var(--s-6) 46px; }
.step::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  display: grid; place-items: center; width: 28px; height: 28px;
  border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--card);
  font: 500 var(--t-label)/1 var(--mono); color: var(--fg); font-variant-numeric: tabular-nums;
}
.step::after { content: ""; position: absolute; left: 14px; top: 36px; bottom: 8px; width: 1px; background: var(--line); }
.step:last-child { padding-bottom: 0; }
.step:last-child::after { display: none; }
.step > h3 { margin: 2px 0 0; font-size: 1rem; }
.step > * + * { margin-top: var(--s-3); }

/* cards */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
.card {
  display: grid; align-content: start; gap: 6px; min-height: 148px; padding: var(--s-5) var(--s-5) var(--s-5);
  border: 1px solid var(--line); border-radius: var(--r); background: var(--card); text-decoration: none;
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease), transform 120ms var(--ease);
}
.card:active { transform: scale(0.99); }
.card__icon { display: grid; place-items: center; width: 34px; height: 34px; margin-bottom: var(--s-4); border: 1px solid var(--accent-line); border-radius: var(--r-sm); background: var(--accent-soft); color: var(--accent-text); }
.card b { font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; color: var(--fg); }
.card > span:last-child { font-size: var(--t-ui); line-height: 1.55; color: var(--fg-2); text-wrap: pretty; }
@media (hover: hover) and (pointer: fine) { .card:hover { border-color: var(--line-2); background: var(--bg-2); } }

/* figures: one Shader drawing per page, on a plate with a label bar */
.art { margin: var(--s-6) 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); overflow: hidden; }
.prose > .art:first-child { margin-top: 0; }
.art__bar { display: flex; align-items: center; gap: var(--s-3); height: 38px; padding: 0 6px 0 var(--s-4); border-bottom: 1px solid var(--line); font: 400 11px/1 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-3); }
.art__no { color: var(--accent-text); }
.art__title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.art__replay {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 var(--s-2);
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--fg-3); cursor: pointer;
  font: inherit; letter-spacing: inherit; text-transform: inherit;
  transition: color 150ms var(--ease), background-color 150ms var(--ease), transform 120ms var(--ease);
}
.art__replay:active { transform: scale(0.96); }
.art__replay .i { transition: transform 360ms var(--ease); }
.art__replay.is-spun .i { transform: rotate(360deg); }
@media (pointer: coarse) { .art__replay { height: 36px; } }
@media (hover: hover) and (pointer: fine) { .art__replay:hover { color: var(--fg); background: var(--bg-2); } }
.art__frame { aspect-ratio: 720 / 460; background: var(--illos-ground); container-type: inline-size; }
.art__frame > svg, .art__frame .illos-live > svg { display: block; width: 100%; height: 100%; }
@container (max-width: 440px) { .art__frame .lab { display: none; } }
.art figcaption { padding: var(--s-3) var(--s-4); border-top: 1px solid var(--line); font-size: var(--t-ui); line-height: 1.6; color: var(--fg-2); text-wrap: pretty; }
.art__missing { height: 100%; display: grid; place-items: center; font: var(--t-cap) var(--mono); color: var(--fg-3); }
.illos-live { position: relative; height: 100%; }
.illos-live > svg { position: relative; }
.illos-live .sh-still { visibility: hidden; }
.illos-field-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }

/* callouts */
.callout { padding: var(--s-4) var(--s-5); border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-2); }
.callout__label { display: block; margin-bottom: 6px; font: 500 var(--t-label)/1.2 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; color: var(--fg-3); }
.callout p { font-size: 0.9375rem; line-height: 1.7; }
.callout > * + * { margin-top: var(--s-2); }
.callout--note { background: var(--accent-soft); border-color: var(--accent-line); }
.callout--note .callout__label, .callout--note p { color: var(--accent-text); }
.callout--note a { color: inherit !important; text-decoration-color: currentColor !important; }
.callout--note :not(pre) > code { background: color-mix(in oklch, var(--accent-line) 40%, transparent); border-color: var(--accent-line); color: inherit; }
.callout--warning { background: var(--warn-soft); border-color: var(--warn-line); }
.callout--warning .callout__label { color: var(--warn); }

/* code: a card with tabs on top, line numbers and marked lines */
.code { border: 1px solid var(--line); border-radius: var(--r); background: var(--card); overflow: hidden; }
.code__bar { position: relative; display: flex; align-items: stretch; gap: var(--s-2); height: 42px; padding: 0 6px 0 var(--s-4); }
.code__name { display: flex; align-items: center; font-size: var(--t-cap); font-weight: 500; color: var(--fg); }
.code [role="tablist"] { position: relative; display: flex; gap: var(--s-4); }
.code [role="tab"] {
  height: 100%; padding: 0; border: 0; background: transparent; cursor: pointer;
  font: 500 var(--t-cap)/1 var(--sans); color: var(--fg-3);
  transition: color 150ms var(--ease);
}
.code [role="tab"][aria-selected="true"] { color: var(--fg); }
.code__ind { position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; background: var(--fg); transform-origin: left; transform: translateX(var(--x, 0)) scaleX(var(--w, 0)); }
.code__ind.is-ready { transition: transform 260ms var(--ease); }
@media (hover: hover) and (pointer: fine) { .code [role="tab"][aria-selected="false"]:hover { color: var(--fg); } }
.code__btn { margin: auto 0 auto auto; display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--fg-3); cursor: pointer; transition: color 150ms var(--ease), background-color 150ms var(--ease), transform 120ms var(--ease); }
.code__btn:active { transform: scale(0.96); }
@media (pointer: coarse) { .code__btn { width: 40px; height: 40px; } }
@media (hover: hover) and (pointer: fine) { .code__btn:hover { color: var(--fg); background: var(--bg-2); } }
.code__btn { position: relative; }
.code__btn .i { grid-area: 1 / 1; transition: opacity 150ms var(--ease), filter 150ms var(--ease), transform 150ms var(--ease); }
.code__btn .i:last-child { opacity: 0; filter: blur(2px); transform: scale(0.6); color: var(--accent-text); }
.code__btn.is-done .i:first-child { opacity: 0; filter: blur(2px); transform: scale(0.6); }
.code__btn.is-done .i:last-child { opacity: 1; filter: none; transform: none; }
.code pre {
  margin: 0; padding: 2px 0 var(--s-4); overflow-x: auto;
  background: transparent !important;
  font: 400 0.8125rem/1.7 var(--mono); tab-size: 2;
}
.code pre code { display: grid; min-width: max-content; font: inherit; counter-reset: ln; }
.code .line { display: block; min-height: 1.7em; padding: 0 var(--s-4) 0 0; }
.code .line::before {
  counter-increment: ln; content: counter(ln);
  display: inline-block; width: 2.6em; margin-inline-end: var(--s-3); padding-inline-end: 2px; text-align: end; color: var(--fg-3); opacity: 0.6; user-select: none;
}
.code .line.hl { background: var(--hl); box-shadow: inset 2px 0 var(--accent); }
.shiki span { color: var(--shiki-light); }
[data-theme="dark"] .shiki span { color: var(--shiki-dark); }
.code pre::-webkit-scrollbar { height: 8px; }
.code pre::-webkit-scrollbar-thumb { background: rgb(0 0 0 / 0.16); border-radius: 4px; }
[data-theme="dark"] .code pre::-webkit-scrollbar-thumb { background: rgb(255 255 255 / 0.14); }

/* tables */
.table { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); }
.prose table { width: 100%; border-collapse: collapse; font-size: var(--t-ui); line-height: 1.55; }
.prose th { padding: 10px var(--s-4); text-align: start; font: 500 11px/1.2 var(--mono); letter-spacing: 0.05em; text-transform: uppercase; color: var(--fg-3); border-bottom: 1px solid var(--line); white-space: nowrap; }
.prose td { padding: 11px var(--s-4); vertical-align: top; color: var(--fg-2); font-variant-numeric: tabular-nums; }
.prose tbody tr + tr td { border-top: 1px solid var(--line); }
.prose td:first-child { white-space: nowrap; color: var(--fg); }
.prose td:first-child code { background: none; border: 0; padding: 0; }

/* on this page: a rail with a marker that slides to the section being read */
.rail { position: relative; }
.toc { position: sticky; top: calc(var(--hdr-h) + var(--s-6)); max-height: calc(100dvh - var(--hdr-h) - var(--s-8)); overflow-y: auto; scrollbar-width: none; }
.toc__title { display: flex; align-items: center; gap: var(--s-2); margin: 0 0 var(--s-3); font-size: var(--t-ui); font-weight: 500; color: var(--fg); }
.toc ul { position: relative; list-style: none; margin: 0; padding: 0; display: grid; border-inline-start: 1px solid var(--line); }
.toc a { display: block; padding: 5px 0 5px var(--s-4); font-size: var(--t-cap); line-height: 1.45; color: var(--fg-3); text-decoration: none; transition: color 150ms var(--ease); }
.toc .toc__d3 a { padding-inline-start: 28px; }
.toc a.is-active { color: var(--fg); }
.toc__ind { position: absolute; left: -1px; top: 0; width: 1px; height: 1px; background: var(--fg); transform-origin: top; transform: translateY(var(--y, 0)) scaleY(var(--h, 0)); }
.toc__ind.is-ready { transition: transform 260ms var(--ease); }
@media (hover: hover) and (pointer: fine) { .toc a:hover { color: var(--fg); } }

/* helpful, previous and next, footer */
.helpful { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3); margin-top: var(--s-8); font-size: var(--t-ui); color: var(--fg-2); }
.helpful__btns { display: flex; gap: var(--s-2); }
.helpful__thanks { flex-basis: 100%; min-height: 1.5em; font-size: var(--t-cap); color: var(--fg-3); }
.helpful [aria-pressed="true"] { color: var(--fg); border-color: var(--fg-3); background: var(--bg-2); }
.pager { display: flex; justify-content: space-between; gap: var(--s-3); margin-top: var(--s-5); }
.pager a { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; font-size: var(--t-ui); color: var(--fg-2); text-decoration: none; transition: color 150ms var(--ease); }
.pager a .i { transition: transform 200ms var(--ease); }
@media (hover: hover) and (pointer: fine) {
  .pager a:hover { color: var(--fg); }
  .pager__next:hover .i { transform: translateX(2px); }
  .pager__prev:hover .i { transform: translateX(-2px); }
}
.foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3); margin-top: var(--s-6); padding-top: var(--s-5); border-top: 1px solid var(--line); font-size: var(--t-cap); color: var(--fg-3); }
.brand--sm b { font-size: 15px; }
.brand--sm .brand__mark { width: 18px; height: 18px; }
.foot__links { display: flex; flex-wrap: wrap; gap: var(--s-5); }
.foot__links a { color: var(--fg-2); text-decoration: none; transition: color 150ms var(--ease); }
.foot__illos { display: inline-flex; align-items: center; gap: 6px; }
.foot__illos svg { width: 13px; height: 13px; fill: var(--fg); }
@media (hover: hover) and (pointer: fine) { .foot__links a:hover { color: var(--fg); } }

/* dialogs */
dialog { border: 0; padding: 0; color: var(--fg); background: var(--card); }
dialog::backdrop { background: var(--scrim); }
.search {
  width: min(620px, calc(100vw - 32px)); max-height: min(560px, 76dvh);
  margin: 12dvh auto auto; border-radius: var(--r); box-shadow: var(--pop);
  display: none; flex-direction: column; overflow: hidden;
}
.search[open] { display: flex; } /* opens from a shortcut, so it appears at once */
.search__field { display: flex; align-items: center; gap: var(--s-3); padding: 0 var(--s-3) 0 var(--s-4); border-bottom: 1px solid var(--line); color: var(--fg-3); }
.search__field input { flex: 1; min-width: 0; height: 54px; border: 0; outline: 0; background: transparent; color: var(--fg); font: 400 16px/1 var(--sans); }
.search__field input::-webkit-search-cancel-button { display: none; }
.search__esc { border: 0; background: none; padding: var(--s-2); cursor: pointer; }
.search kbd { display: inline-block; padding: 4px 6px; border-radius: var(--r-sm); border: 1px solid var(--line-2); color: var(--fg-3); }
.search__results { list-style: none; margin: 0; padding: 6px; overflow-y: auto; overscroll-behavior: contain; }
.search__results:empty { display: none; }
.search__results a { display: grid; gap: 2px; padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); text-decoration: none; }
.search__results .r-title { font-size: var(--t-ui); font-weight: 500; color: var(--fg); }
.search__results .r-path { display: block; font: 400 11px/1.6 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; color: var(--fg-3); }
.search__results .r-snip { font-size: var(--t-cap); color: var(--fg-3); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.search__results mark { background: none; color: var(--accent-text); font-weight: 500; }
.search__results [aria-selected="true"] a { background: var(--bg-2); box-shadow: inset 2px 0 var(--accent); }
.search__empty { margin: 0; padding: var(--s-6) var(--s-5); font-size: var(--t-ui); color: var(--fg-3); text-align: center; }
.search__hint { display: flex; gap: var(--s-5); padding: 10px var(--s-4); border-top: 1px solid var(--line); font-size: 12px; color: var(--fg-3); }
.search__hint kbd { margin-inline-end: 4px; padding: 2px 5px; }

.mnav {
  margin: 0; width: min(320px, 86vw); max-width: none; height: 100dvh; max-height: none;
  padding: 0 var(--s-5) var(--s-6); overflow-y: auto; background: var(--bg); box-shadow: var(--pop);
  transform: translateX(-100%); transition: transform 280ms var(--ease-drawer), display 280ms allow-discrete, overlay 280ms allow-discrete;
}
.mnav[open] { transform: none; }
@starting-style { .mnav[open] { transform: translateX(-100%); } }
.mnav::backdrop { background: var(--scrim); opacity: 0; transition: opacity 280ms var(--ease-drawer), display 280ms allow-discrete, overlay 280ms allow-discrete; }
.mnav[open]::backdrop { opacity: 1; }
@starting-style { .mnav[open]::backdrop { opacity: 0; } }
.mnav__head { display: flex; align-items: center; justify-content: space-between; height: var(--row-h); }
.mnav__tabs { display: grid; gap: 1px; margin-bottom: var(--s-5); padding-bottom: var(--s-4); border-bottom: 1px solid var(--line); }
.mnav__tabs .tab { min-height: 40px; }
.mnav__tabs .tab::after { display: none; }
.mnav__cta { width: 100%; margin-top: var(--s-6); height: 44px; }

/* narrower screens */
@media (max-width: 1240px) {
  .main { grid-template-columns: minmax(0, 704px); justify-content: start; }
  .rail { display: none; }
}
@media (max-width: 1000px) {
  :root { --tabs-h: 0px; --row-h: 56px; }
  .wrap { padding: 0 var(--s-4); }
  .hdr__row::after { left: var(--s-4); right: var(--s-4); }
  .hdr__mid, .hdr__link, .tabs, .side { display: none; }
  .hdr__search { display: inline-grid !important; }
  .hdr__end { gap: var(--s-1); }
  .hdr__end .btn--accent { height: 32px; padding: 0 var(--s-3); }
  .crumbbar { display: flex; align-items: center; gap: var(--s-2); height: 48px; }
  .crumbbar .icon-btn { margin-inline-start: -8px; }
  .crumb { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: var(--t-ui); color: var(--fg-3); white-space: nowrap; }
  .crumb .i { color: var(--fg-3); }
  .crumb [aria-current] { color: var(--fg); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
  html { scroll-padding-top: calc(var(--row-h) + 48px + var(--s-4)); }
  .body { display: block; }
  .main { padding: var(--s-6) 0 var(--s-7); }
}
@media (max-width: 640px) {
  :root { --t-h1: 1.75rem; }
  .hdr__end .btn--accent { display: none; }
  .doc__title { flex-direction: column; gap: var(--s-4); }
  .doc__head { display: flex; flex-direction: column; }
  .cards { grid-template-columns: minmax(0, 1fr); }
  .card { min-height: 0; }
  .step { padding-left: 40px; }
  .code .line::before { width: 2em; margin-inline-end: var(--s-2); }
}
@media (prefers-reduced-motion: reduce) {
  .mnav, .mnav::backdrop, .nav details::details-content { transition: none; }
  .menu:not([hidden]) { animation: none; }
  .nav summary .i, .art__replay .i, .tab::after { transition: none; }
  .code__ind.is-ready, .toc__ind.is-ready { transition: none; }
}

/* endpoints: a method badge and the path */
.endpoints { display: grid; gap: 1px; border: 1px solid var(--line); border-radius: var(--r); background: var(--line); overflow: hidden; }
.endpoint { display: flex; align-items: center; gap: var(--s-3); min-height: 44px; padding: 0 var(--s-4); background: var(--card); max-width: none !important; }
.endpoint code { font: 400 var(--t-cap)/1.4 var(--mono) !important; color: var(--fg) !important; background: none !important; border: 0 !important; padding: 0 !important; overflow-wrap: anywhere; }
.method { flex: none; display: inline-grid; place-items: center; min-width: 54px; height: 22px; padding: 0 6px; border-radius: var(--r-sm); font: 500 11px/1 var(--mono); letter-spacing: 0.04em; border: 1px solid; }
.method--get { color: var(--accent-text); background: var(--accent-soft); border-color: var(--accent-line); }
.method--post, .method--put, .method--patch { color: var(--fg); background: var(--bg-2); border-color: var(--line-2); }
.method--delete { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-line); }

/* touch: every control reaches 44px */
@media (pointer: coarse) {
  .code__bar { height: 44px; }
  .code__btn, .art__replay { height: 44px; min-width: 44px; justify-content: center; }
  .pager a { min-height: 44px; }
  .foot__links a { display: inline-flex; align-items: center; min-height: 44px; }
}
