/* Polylute docs. Every colour lives in :root below: change them here and nowhere else. */
@font-face {
  font-family: "Manrope";
  src: url("/assets/fonts/manrope_variable.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/fonts/jetbrains_mono_variable.woff2") format("woff2");
  font-weight: 400 500;
  font-style: normal;
  font-display: swap;
}

:root {
  /* palette */
  --bg: #0B0A0F;
  --surface: #14111C;
  --surface-2: #1C1827;
  --line: #2A2439;            /* decorative dividers only (1.3:1) */
  --line-strong: #6F6788;     /* borders of controls and diagram strokes (3.3:1 or more) */
  --accent: #FFB23F;
  --on-accent: #1A1206;
  --text: #F2F0F7;
  --text-2: #A39DB3;
  /* callout kinds: never amber, so amber does not read as "everything is a warning" */
  --c-note: #B9AAFF;
  --c-warn: #FF8F7E;
  --c-ok: #5FD9AE;
  --c-observed: #E2A9F5;

  /* type and layout */
  --sans: Manrope, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --header-h: 60px;
  --side-w: 288px;
  --toc-w: 232px;
  --read-w: 46rem;
  --radius: 12px;
}

* { box-sizing: border-box; }
html { color-scheme: dark; -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 20px); }
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.7;
  overflow-x: clip;
}
h1, h2, h3, p, ul, ol, dl, dd, figure, pre { margin: 0; }
img, svg { display: block; max-width: 100%; }

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

a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }

.skip-link {
  position: absolute; left: 12px; top: -80px; z-index: 50;
  background: var(--accent); color: var(--on-accent); font-weight: 700;
  padding: 10px 16px; border-radius: 999px; text-decoration: none;
}
.skip-link:focus { top: 10px; outline-color: var(--text); }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- header ---------- */
.docs-header {
  position: sticky; top: 0; z-index: 30;
  height: var(--header-h);
  background: rgba(11, 10, 15, 0.94);
  border-bottom: 1px solid var(--line);
}
@supports (backdrop-filter: blur(8px)) {
  .docs-header { background: rgba(11, 10, 15, 0.82); backdrop-filter: blur(10px); }
}
.header-row {
  height: 100%; max-width: 1560px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 14px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand img { height: 26px; width: auto; }
.brand-docs {
  font: 500 0.75rem/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-2); border: 1px solid var(--line-strong); border-radius: 999px; padding: 5px 9px;
}
.header-spacer { flex: 1; }
.site-link {
  display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 15px 0 12px;
  border-radius: 999px; background: var(--text); color: var(--bg);
  font-size: 0.875rem; font-weight: 700; text-decoration: none; white-space: nowrap;
}
.site-link svg { width: 15px; height: 15px; flex: none; }
.site-link:hover, .site-link:focus-visible { background: #FFFFFF; color: var(--bg); }
@media (prefers-reduced-motion: no-preference) {
  .site-link { transition: background-color 0.15s; }
  .site-link svg { transition: transform 0.15s; }
  .site-link:hover svg { transform: translateX(-2px); }
}
.menu-btn {
  display: none; align-items: center; gap: 8px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line-strong);
  border-radius: 999px; padding: 8px 14px; font: 600 0.875rem/1 var(--sans); cursor: pointer;
}
.menu-btn:hover { border-color: var(--accent); }
.menu-btn svg { width: 16px; height: 16px; }

/* ---------- layout ---------- */
.docs-layout {
  max-width: 1560px; margin: 0 auto;
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr) var(--toc-w);
  column-gap: 0;
}
.sidebar {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto; overscroll-behavior: contain;
  padding: 24px 12px 48px 20px;
  border-right: 1px solid var(--line);
  font-size: 0.9375rem; line-height: 1.4;
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
.doc-main { min-width: 0; padding: 0 clamp(20px, 4vw, 56px) 96px; overflow-x: clip; }
.toc-rail {
  position: sticky; top: var(--header-h);
  align-self: start; max-height: calc(100vh - var(--header-h));
  overflow-y: auto; padding: 40px 20px 40px 8px; font-size: 0.875rem; line-height: 1.4;
}

/* ---------- sidebar ---------- */
.nav-home { display: block; padding: 8px 10px; margin-bottom: 8px; border-radius: 8px; color: var(--text); font-weight: 700; text-decoration: none; }
.nav-home:hover { background: var(--surface); }
.nav-home[aria-current="page"] { background: var(--surface); color: var(--accent); box-shadow: inset 2px 0 0 var(--accent); }
.nav-site { display: none; }
.nav-section { border-top: 1px solid var(--line); padding: 6px 0; }
.nav-section > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: 8px; font-weight: 700; color: var(--text);
}
.nav-section > summary::-webkit-details-marker { display: none; }
.nav-section > summary:hover { background: var(--surface); }
.nav-section > summary::after {
  content: ""; width: 7px; height: 7px; margin-right: 4px;
  border-right: 2px solid var(--text-2); border-bottom: 2px solid var(--text-2);
  transform: rotate(-45deg); transition: transform 0.15s;
}
.nav-section[open] > summary::after { transform: rotate(45deg); }
@media (prefers-reduced-motion: reduce) { .nav-section > summary::after { transition: none; } }
.nav-group-title {
  margin: 14px 10px 4px; font: 500 0.6875rem/1.2 var(--mono); letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--text-2);
}
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-list li { margin: 1px 0; }
.nav-list a, .nav-list .soon {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  padding: 6px 10px; border-radius: 8px;
}
.nav-list a { color: var(--text); text-decoration: none; }
.nav-list a:hover { background: var(--surface); }
.nav-list a[aria-current="page"] { background: var(--surface); color: var(--accent); font-weight: 700; box-shadow: inset 2px 0 0 var(--accent); }
.nav-list .soon { color: var(--text-2); cursor: default; }
.tag-soon {
  flex: none; font: 500 0.625rem/1 var(--mono); letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-2); border: 1px solid var(--line-strong); border-radius: 999px; padding: 3px 6px;
}

/* ---------- "On this page" ---------- */
.toc-title { font: 500 0.6875rem/1.2 var(--mono); letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-2); margin-bottom: 10px; }
.toc-list { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc-list a {
  display: block; padding: 5px 0 5px 14px; margin-left: -1px; border-left: 2px solid transparent;
  color: var(--text-2); text-decoration: none;
}
.toc-list a:hover { color: var(--text); }
.toc-list a.is-active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.toc-inline { display: none; margin: 0 0 32px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); }
.toc-inline > summary { cursor: pointer; padding: 12px 16px; font-weight: 700; list-style: none; display: flex; justify-content: space-between; }
.toc-inline > summary::-webkit-details-marker { display: none; }
.toc-inline > summary::after { content: "+"; color: var(--text-2); font-family: var(--mono); }
.toc-inline[open] > summary::after { content: "\2212"; }
.toc-inline .toc-list { border-left: 0; padding: 0 16px 12px; }
.toc-inline .toc-list a { padding-left: 0; border-left: 0; }

/* ---------- article ---------- */
.article { max-width: var(--read-w); margin: 0 auto; }
.page-head { padding: 44px 0 26px; }
.crumbs { font: 500 0.75rem/1.4 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-2); margin-bottom: 14px; }
.crumbs a { color: var(--text-2); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs .sep { margin: 0 6px; }
h1 { font-size: clamp(1.9rem, 1.3rem + 2.6vw, 2.6rem); line-height: 1.12; font-weight: 800; letter-spacing: -0.025em; }
.lede { margin-top: 14px; font-size: 1.1875rem; line-height: 1.6; color: var(--text-2); max-width: 40rem; }

.prose > * + * { margin-top: 1.1em; }
.prose h2 {
  margin-top: 2.6em; padding-top: 1.1em; border-top: 1px solid var(--line);
  font-size: 1.55rem; line-height: 1.25; font-weight: 800; letter-spacing: -0.015em;
}
.prose h2:first-child { margin-top: 1.4em; border-top: 0; padding-top: 0; }
.prose h3 { margin-top: 1.9em; font-size: 1.2rem; line-height: 1.3; font-weight: 700; }
.prose h2 + *, .prose h3 + * { margin-top: 0.7em; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: 0.4em; }
.prose li::marker { color: var(--text-2); }
.prose strong { font-weight: 700; }
.prose kbd, .prose code {
  font-family: var(--mono); font-size: 0.86em; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 6px; padding: 0.12em 0.4em; overflow-wrap: anywhere;
}
.ui { font-weight: 600; color: var(--text); }

/* In short */
.in-short {
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius); padding: 20px 22px 20px 24px;
}
.in-short-label { font: 500 0.75rem/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; }
.in-short ul { margin: 0; padding-left: 1.2em; }
.in-short li + li { margin-top: 0.5em; }

/* callouts: border + icon + label, colour is only a reinforcement */
.callout {
  --k: var(--c-note);
  display: grid; grid-template-columns: 24px minmax(0, 1fr); column-gap: 12px;
  background: var(--surface); border: 1px solid var(--k); border-left-width: 4px; border-radius: var(--radius);
  padding: 14px 18px 14px 14px;
}
.callout-note { --k: var(--c-note); }
.callout-warning { --k: var(--c-warn); }
.callout-tested { --k: var(--c-ok); }
.callout-observed { --k: var(--c-observed); border-style: dashed; border-left-style: solid; }
.callout-icon { width: 22px; height: 22px; margin-top: 2px; color: var(--k); }
.callout-label { font: 500 0.75rem/1.3 var(--mono); letter-spacing: 0.09em; text-transform: uppercase; color: var(--k); margin-bottom: 4px; align-self: center; }
.callout-body { grid-column: 2; }
.callout-body > * + * { margin-top: 0.6em; }
.callout-body a { overflow-wrap: anywhere; }
.callout-body ul, .callout-body ol { padding-left: 1.2em; }

/* disclosure: "For the curious" */
.curious { background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); }
.curious > summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 18px; font-weight: 700;
}
.curious > summary::-webkit-details-marker { display: none; }
.curious > summary .k { font: 500 0.75rem/1 var(--mono); letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-2); margin-right: 10px; }
.curious > summary::after { content: "+"; font: 500 1.25rem/1 var(--mono); color: var(--accent); }
.curious[open] > summary::after { content: "\2212"; }
.curious-body { padding: 4px 18px 18px; border-top: 1px solid var(--line); }
.curious-body > * + * { margin-top: 0.8em; }
.curious-body > :first-child { margin-top: 14px; }

/* numbered steps */
.steps { list-style: none; padding: 0; counter-reset: step; }
.steps > li { counter-increment: step; position: relative; padding-left: 52px; margin-top: 1.5em; min-height: 36px; }
.steps > li:first-child { margin-top: 0.6em; }
.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--line-strong);
  font: 600 0.9rem/32px var(--mono); text-align: center; color: var(--text);
}
.steps > li > .step-title { font-weight: 700; display: block; line-height: 1.5; padding-top: 3px; }
.steps > li > * + * { margin-top: 0.7em; }

/* code block */
.code-block { background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; }
.code-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--line); }
.code-label { font: 500 0.75rem/1.3 var(--mono); letter-spacing: 0.04em; color: var(--text-2); }
.copy-btn {
  display: none; align-items: center; gap: 6px; flex: none;
  background: var(--surface); color: var(--text); border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 6px 11px; font: 600 0.8125rem/1 var(--sans); cursor: pointer;
}
html.js .copy-btn { display: inline-flex; }
.copy-btn:hover { border-color: var(--accent); }
.copy-btn svg { width: 14px; height: 14px; }
.copy-btn.is-done { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.code-block pre {
  padding: 14px 16px; font: 400 0.875rem/1.65 var(--mono); color: var(--text);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.code-block code { background: none; border: 0; padding: 0; font: inherit; }
.code-prompt { color: var(--text-2); user-select: none; }

/* table */
.table-wrap { border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 0.96rem; line-height: 1.5; }
caption { text-align: left; padding: 12px 16px; color: var(--text-2); font-size: 0.875rem; border-bottom: 1px solid var(--line); caption-side: top; }
th, td { text-align: left; vertical-align: top; padding: 12px 16px; border-bottom: 1px solid var(--line); }
thead th { font: 500 0.6875rem/1.3 var(--mono); letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-2); background: var(--surface-2); }
tbody tr:last-child > * { border-bottom: 0; }
tbody th { font-weight: 700; white-space: nowrap; }
/* a long row header (marked by build.py) wraps instead of being cut by the table frame */
tbody th.wrap { white-space: normal; overflow-wrap: break-word; min-width: 9rem; }
tbody th.wrap code { overflow-wrap: anywhere; }
tr.is-key th { color: var(--accent); }

/* figure + diagram */
.figure { background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 18px 16px 8px; overflow: hidden; }
.figure figcaption { font-size: 0.9rem; line-height: 1.5; color: var(--text-2); padding: 4px 4px 12px; }
.figure figcaption strong { color: var(--text); }
.dg-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr)); gap: 24px 20px; justify-items: center; }
.dg { width: 100%; max-width: 360px; height: auto; margin: 0 auto; }
.dg-box { fill: var(--surface-2); stroke: var(--line-strong); stroke-width: 1.25; }
.dg-key { fill: var(--surface-2); stroke: var(--accent); stroke-width: 2; }
.dg-end { fill: var(--accent); stroke: var(--accent); }
.dg-dash { fill: none; stroke: var(--line-strong); stroke-width: 1.25; stroke-dasharray: 5 4; }
.dg-line { fill: none; stroke: var(--line-strong); stroke-width: 1.5; }
.dg-line-key { fill: none; stroke: var(--accent); stroke-width: 2; }
.dg-head { fill: var(--line-strong); }
.dg-head-key { fill: var(--accent); }
.dg-t { fill: var(--text); font: 600 13px/1 var(--sans); }
.dg-t2 { fill: var(--text-2); font: 500 12px/1 var(--sans); }
.dg-t-end { fill: var(--on-accent); font: 700 13px/1 var(--sans); }
.dg-lane { fill: var(--text-2); font: 500 11px/1 var(--mono); letter-spacing: 1px; text-transform: uppercase; }
.dg-lane-key { fill: var(--accent); font: 500 11px/1 var(--mono); letter-spacing: 1px; text-transform: uppercase; }
.dg-pill { fill: var(--bg); stroke: var(--line-strong); stroke-width: 1; }
.in-words { margin: 6px 4px 14px; padding: 14px 16px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; font-size: 0.9375rem; line-height: 1.6; }
.in-words-label { font: 500 0.6875rem/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-2); margin-bottom: 8px; }
.in-words ol, .in-words ul { margin: 0; padding-left: 1.3em; }
.in-words li + li { margin-top: 0.25em; }
.in-words p + p, .in-words p + ol, .in-words ol + p, .in-words ol + ol, .in-words p + ul { margin-top: 0.6em; }

/* page links: "If something goes wrong", "Why" */
.link-list { list-style: none; padding: 0; display: grid; gap: 10px; }
.link-list > li { margin: 0; }
.link-list > li + li { margin-top: 0; }
.link-card {
  display: block; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 12px 16px; color: var(--text); text-decoration: none;
}
a.link-card:hover { border-color: var(--accent); }
a.link-card:hover .link-title { text-decoration: underline; text-decoration-thickness: 1px; }
.link-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-weight: 700; color: var(--accent); }
.link-card.is-soon .link-title { color: var(--text); }
.link-desc { display: block; margin-top: 2px; font-size: 0.9375rem; line-height: 1.5; color: var(--text-2); font-weight: 400; }
.inline-soon { color: var(--text); }
.inline-soon .tag-soon { margin-left: 6px; vertical-align: 2px; }

/* pager */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 56px; }
.pager-item { display: block; padding: 14px 16px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); text-decoration: none; color: var(--text); }
a.pager-item:hover { border-color: var(--accent); }
.pager-next { text-align: right; grid-column: 2; }
.pager-dir { display: block; font: 500 0.6875rem/1.2 var(--mono); letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-2); }
.pager-title { display: block; margin-top: 4px; font-weight: 700; color: var(--accent); }
.pager-item.is-soon .pager-title { color: var(--text); }

/* page foot */
.page-foot { margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: 0.875rem; line-height: 1.5; color: var(--text-2); }
.page-foot strong { color: var(--text); font-weight: 600; }

/* docs home */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 14px; margin-top: 8px; }
.card { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 18px 18px 16px; color: var(--text); text-decoration: none; }
a.card:hover { border-color: var(--accent); }
.card-k { font: 500 0.6875rem/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-2); }
.card-title { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.01em; color: var(--text); }
a.card .card-title { color: var(--accent); }
.card-desc { font-size: 0.9375rem; line-height: 1.55; color: var(--text-2); }
.card-meta { margin-top: auto; padding-top: 8px; font: 500 0.75rem/1.3 var(--mono); color: var(--text-2); }

/* footer */
.site-foot { border-top: 1px solid var(--line); padding: 28px 20px 40px; }
.site-foot-row { max-width: 1560px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 8px 28px; align-items: center; font-size: 0.9rem; color: var(--text-2); }
.site-foot a { color: var(--text-2); }
.site-foot a:hover { color: var(--accent); }
.site-foot .ver { color: var(--text); font-weight: 600; }

/* ---------- responsive ---------- */
@media (max-width: 1239px) {
  .docs-layout { grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .toc-rail { display: none; }
  .toc-inline { display: block; }
}
@media (max-width: 899px) {
  .docs-layout { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: inline-flex; }
  /* no JavaScript: the menu is simply the first thing on the page */
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 16px 20px; }
  html.js .sidebar {
    position: fixed; z-index: 40; top: var(--header-h); left: 0; bottom: 0; width: min(88vw, 340px);
    height: auto; background: var(--bg); border-right: 1px solid var(--line-strong); border-bottom: 0;
    padding: 20px 12px 40px 16px; transform: translateX(-102%); visibility: hidden;
    transition: transform 0.2s ease, visibility 0s linear 0.2s;
  }
  html.js body.nav-open .sidebar { transform: none; visibility: visible; transition: transform 0.2s ease; }
  html.js .scrim { position: fixed; z-index: 35; inset: var(--header-h) 0 0 0; background: rgba(5, 4, 8, 0.7); }
  html.js body:not(.nav-open) .scrim { display: none; }
  html.js body.nav-open { overflow: hidden; }
  .site-link { display: none; }
  .nav-site {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    margin: 18px 6px 0; padding: 10px 16px; border-radius: 999px;
    background: var(--text); color: var(--bg);
    font-size: 0.9375rem; font-weight: 700; text-decoration: none;
  }
  .nav-site svg { width: 16px; height: 16px; flex: none; }
  .nav-site:hover, .nav-site:focus-visible { background: #FFFFFF; color: var(--bg); }
  .header-row { padding: 0 14px; }
  .page-head { padding-top: 28px; }
}
@media (min-width: 900px) { .scrim { display: none; } }
@media (prefers-reduced-motion: reduce) {
  html.js .sidebar, html.js body.nav-open .sidebar { transition: none; }
}
@media (max-width: 640px) {
  body { font-size: 1rem; }
  .steps > li { padding-left: 46px; }
  .steps > li::before { width: 30px; height: 30px; font-size: 0.8125rem; line-height: 28px; }
  .pager { grid-template-columns: 1fr; }
  .pager-next { grid-column: 1; }
  /* the levels table becomes a stack of cards: no horizontal scroll at 360 px */
  .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack th, .table-stack td { display: block; width: 100%; }
  .table-stack tr { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .table-stack tbody tr:last-child { border-bottom: 0; }
  .table-stack th, .table-stack td { border: 0; padding: 4px 16px; }
  /* the caption is a block of its own: left as a table-caption it shrinks to a narrow column inside the card */
  .table-stack caption { display: block; width: 100%; }
  /* in a card every row header has the full width, so it may always wrap */
  .table-stack tbody th { white-space: normal; overflow-wrap: break-word; }
  .table-stack tbody th code { overflow-wrap: anywhere; }
  .table-stack td[data-label]::before { content: attr(data-label); display: block; font: 500 0.6875rem/1.3 var(--mono); letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-2); margin-bottom: 1px; }
  .callout { padding-right: 14px; }
}
@media (max-width: 400px) {
  .doc-main { padding-left: 16px; padding-right: 16px; }
  .brand-docs { display: none; }
  .figure { padding-left: 10px; padding-right: 10px; }
}
@media print {
  .docs-header, .sidebar, .toc-rail, .pager, .copy-btn, .menu-btn, .search, .search-btn { display: none !important; }
}
/* ---------- images: {{figure}} and {{screen}} ---------- */
.media { margin: 0; }
.media img { width: auto; max-width: 100%; height: auto; border-radius: var(--radius); background: var(--surface); }
.media:not(.media-phone) img { border: 1px solid var(--line-strong); }
.media figcaption { margin-top: 10px; font-size: 0.9rem; line-height: 1.5; color: var(--text-2); }
.media figcaption strong { color: var(--text); }
.media-phone { display: flex; flex-direction: column; align-items: center; }
.media-phone img {
  max-width: min(100%, 320px);
  border: 1px solid var(--line-strong); border-radius: 30px; padding: 6px; background: var(--surface-2);
  box-shadow: 0 0 0 1px var(--bg), 0 18px 40px -18px rgba(0, 0, 0, 0.7);
}
.media-phone figcaption { max-width: 320px; text-align: center; }
.media-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; gap: 28px 24px; }
.media-row > .media-phone { flex: 0 1 250px; min-width: 0; }
.media-row > .media-phone img { max-width: 100%; }
.missing-image { color: var(--c-warn); font-family: var(--mono); }

/* ---------- search (the box is hidden without JavaScript) ---------- */
.search, .search-btn { display: none; }
html.js .search { display: block; position: relative; width: min(340px, 34vw); }
.search-icon { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; margin-top: -8px; color: var(--text-2); pointer-events: none; }
.search-input {
  width: 100%; height: 38px; padding: 0 12px 0 36px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); border-radius: 999px;
  font: 500 0.9375rem/1 var(--sans);
}
.search-input::placeholder { color: var(--text-2); opacity: 1; }
.search-input:hover { border-color: var(--text-2); }
.search-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-color: var(--accent); }
.search-input::-webkit-search-cancel-button { filter: invert(0.8); }
.search-panel {
  position: absolute; z-index: 60; top: calc(100% + 10px); right: 0; width: min(520px, calc(100vw - 28px));
  max-height: min(70vh, 520px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.8);
}
.search-panel[hidden] { display: none; }
.search-status { padding: 12px 16px; font-size: 0.875rem; line-height: 1.4; color: var(--text-2); }
.search-status:empty { display: none; }
.search-results { list-style: none; margin: 0; padding: 0 6px 6px; }
.search-results a { display: block; padding: 10px 12px; border-radius: 8px; color: var(--text); text-decoration: none; }
.search-results a:hover, .search-results a:focus-visible { background: var(--surface-2); }
.search-results a:focus-visible { outline-offset: -2px; }
.sr-section { display: block; font: 500 0.6875rem/1.2 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-2); }
.sr-title { display: block; margin-top: 2px; font-weight: 700; color: var(--accent); line-height: 1.35; }
.sr-heading { display: block; font-size: 0.875rem; line-height: 1.4; color: var(--text); }
.sr-excerpt { display: block; margin-top: 2px; font-size: 0.875rem; line-height: 1.45; color: var(--text-2); }
.search-results mark { background: transparent; color: var(--text); font-weight: 800; text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 0.18em; }
@media (max-width: 899px) {
  html.js .search-btn {
    display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px;
    background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); border-radius: 999px; cursor: pointer;
  }
  .search-btn:hover { border-color: var(--accent); }
  .search-btn svg { width: 17px; height: 17px; }
  html.js .search {
    display: none; position: absolute; left: 0; right: 0; top: var(--header-h); width: auto;
    padding: 10px 14px 12px; background: var(--bg); border-bottom: 1px solid var(--line);
  }
  html.js body.search-open .search { display: block; }
  .search-icon { left: 26px; top: 23px; margin-top: 0; }
  .search-input { padding-left: 38px; height: 42px; font-size: 1rem; }
  .search-panel { left: 14px; right: 14px; width: auto; top: calc(100% - 2px); }
}
@media (prefers-reduced-motion: no-preference) {
  .search-input { transition: border-color 0.15s; }
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
