/* Cabinhub News developer documentation.
 *
 * Hand-written, self-hosted: no fonts, images or scripts fetched from anywhere. Everything is
 * server-rendered — the sidebar is a plain list of links and the on-page contents is a plain
 * list of anchors, so navigation works with JavaScript disabled.
 *
 * COLOUR IS THE NEWSROOM'S, not a second palette (frontend/css/tokens.css): Ember light is the
 * default (--paper #F7F5F2, --ink #1C1714, one accent #BC3E0D at 5.0:1 on paper), and the dark
 * theme is the warm Ember dark (#15110E ground, #FA8054 accent) rather than a blue-black
 * default. Two switch points, the same two the reader site has: the stored choice
 * (html[data-theme], written by the 15-line inline bootstrap in each page from the same
 * localStorage key the newsroom uses) and the OS preference when nobody has chosen. An explicit
 * light choice always wins over a dark OS, which is the case that used to be impossible to get
 * right with a media query alone.
 *
 * Type is the platform's own face: a serif display face for headings (the newsroom's
 * --font-brand/--font-display), system UI for body and controls, and a mono for code with
 * tabular figures so a hex id and a JSON body line up.
 */

:root {
  color-scheme: light dark;

  /* Ember light: the reader site's own tokens */
  --paper: #f7f5f2;
  --paper-2: #f1ece7;
  --canvas: #ffffff;
  --rule: #d6cbc2;
  --rule-soft: #e4dcd4;
  --rule-strong: #8f7b6d;
  --ink: #1c1714;
  --ink-soft: #514942;
  --ink-faint: #6d6259;
  --accent: #bc3e0d;
  --accent-hover: #d64221;
  --accent-soft: #fce6db;
  --focus: #d64221;

  /* semantic: method badges, statuses, notes */
  --ok: #176b3a;
  --ok-soft: #e3f5e9;
  --warn: #765000;
  --warn-soft: #fff1c6;
  --bad: #b42318;
  --bad-soft: #fde7e5;
  --info: #075985;
  --info-soft: #e2f1fa;

  /* code surfaces are the page's inset well, never a second background colour */
  --bg: var(--paper);
  --bg-soft: var(--paper-2);
  --bg-raised: var(--canvas);
  --bg-code: var(--paper-2);

  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", "Helvetica Neue", Arial,
    "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --font-brand: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia,
    "Times New Roman", "Songti SC", "Noto Serif CJK SC", serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --measure: 72ch;
  --radius: 6px;
  --radius-xs: 4px;
  --shadow: 0 1px 2px rgba(28, 23, 20, 0.05), 0 6px 20px rgba(28, 23, 20, 0.06);

  --topbar-h: 60px;
  --sidebar-w: 300px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --paper: #15110e;
  --paper-2: #1e1915;
  --canvas: #1b1613;
  --rule: #3a3129;
  --rule-soft: #2a2320;
  --rule-strong: #6e6055;
  --ink: #f3eee9;
  --ink-soft: #c9bfb6;
  --ink-faint: #9f948a;
  --accent: #fa8054;
  --accent-hover: #ff9c6b;
  --accent-soft: #3b1b10;
  --focus: #ff9c6b;
  --ok: #4ade80;
  --ok-soft: #10271d;
  --warn: #fbbf24;
  --warn-soft: #2a2110;
  --bad: #ff7b72;
  --bad-soft: #2b1616;
  --info: #60a5fa;
  --info-soft: #10243a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* No stored choice and no bootstrap (scripting off): follow the OS. */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #15110e;
    --paper-2: #1e1915;
    --canvas: #1b1613;
    --rule: #3a3129;
    --rule-soft: #2a2320;
    --rule-strong: #6e6055;
    --ink: #f3eee9;
    --ink-soft: #c9bfb6;
    --ink-faint: #9f948a;
    --accent: #fa8054;
    --accent-hover: #ff9c6b;
    --accent-soft: #3b1b10;
    --focus: #ff9c6b;
    --ok: #4ade80;
    --ok-soft: #10271d;
    --warn: #fbbf24;
    --warn-soft: #2a2110;
    --bad: #ff7b72;
    --bad-soft: #2b1616;
    --info: #60a5fa;
    --info-soft: #10243a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.4);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

a:hover {
  color: var(--accent-hover);
  text-decoration-color: currentColor;
  text-decoration-thickness: 2px;
}

/* One focus ring everywhere, visible on both grounds and never clipped by a rounded box. */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

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

/* The skip link rides in on TRANSFORM, not on `top`.
   MOTION.md §3 allows only transform and opacity to animate; `top` is a layout property,
   so the old `transition: top 120ms` made the browser re-lay-out the page on every frame
   of the reveal. The link is parked at its resting position and translated out of view
   instead, which paints identically and animates nothing but the compositor. Measured by
   frontend/tools/n3_designgate.mjs (motionProps) before the fix: one violation per
   /developers/ visit, at every width and pointer type; zero after. */
.skip-link {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 30;
  padding: 10px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transform: translateY(-76px);
  transition: transform 120ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .skip-link { transition: none; }
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: var(--topbar-h);
  padding: 0 28px;
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  color: var(--ink);
  font-family: var(--font-brand);
  font-size: 1.14rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  text-decoration: none;
  white-space: nowrap;
}

.wordmark:hover {
  color: var(--ink);
}

.wordmark .mark {
  width: 9px;
  height: 9px;
  border-radius: 1px;
  background: var(--accent);
  transform: translateY(-1px);
}

.wordmark .wordmark-sub {
  color: var(--ink-faint);
  font-family: var(--font);
  font-weight: 450;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.topnav {
  display: flex;
  gap: 22px;
  margin-left: auto;
  font-size: 14px;
}

.topnav a {
  color: var(--ink-soft);
  text-decoration: none;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}

.topnav a:hover,
.topnav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

/* ---------- shell ---------- */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  align-items: start;
}

/* A grid child defaults to min-width:auto, so one long unbroken path would widen the whole
   column and push the page into horizontal scroll at 390px. */
.shell > * {
  min-width: 0;
}

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  max-height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 26px 20px 48px 26px;
  border-right: 1px solid var(--rule);
  font-size: 14px;
  min-width: 0;
  scrollbar-width: thin;
}

.side-groups,
.side-group {
  min-width: 0;
}

.side-group + .side-group {
  margin-top: 24px;
}

.side-heading {
  margin: 0 0 7px;
  color: var(--ink-faint);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar li + li {
  margin-top: 1px;
}

.sidebar a {
  display: block;
  padding: 5px 10px;
  margin-left: -10px;
  border-radius: var(--radius-xs);
  color: var(--ink-soft);
  text-decoration: none;
  line-height: 1.45;
}

.sidebar a:hover {
  background: var(--bg-soft);
  color: var(--ink);
}

/* The current page is marked by the ink going full strength and by a bar in the accent, not
   by a filled chip: a filled chip on every page reads as a control, not as a location. */
.sidebar a[aria-current="page"] {
  color: var(--ink);
  font-weight: 620;
  box-shadow: inset 2px 0 0 var(--accent);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  padding-left: 12px;
  margin-left: -2px;
  background: color-mix(in srgb, var(--accent-soft) 55%, transparent);
}

.sidebar .side-note {
  margin: 28px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  color: var(--ink-faint);
  font-size: 12.5px;
  line-height: 1.55;
}

/* Endpoint list in the sidebar: method badge in a fixed column so every path starts at the
   same x, and long paths wrap inside their own column instead of running off the edge. */
.endpoint-nav .side-sub > span {
  display: block;
  margin: 14px 0 4px;
  color: var(--ink-faint);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.endpoint-nav .side-sub:first-child > span {
  margin-top: 0;
}

.endpoint-nav a {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
  padding: 4px 8px;
  margin-left: 0;
  border-radius: var(--radius-xs);
}

.endpoint-nav a[aria-current="page"] {
  padding-left: 8px;
}

.endpoint-nav .m {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  text-align: left;
}

.endpoint-nav .m-post {
  color: var(--warn);
}

.endpoint-nav .m-delete {
  color: var(--bad);
}

.endpoint-nav .p {
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.endpoint-nav a[aria-current="page"] .p {
  color: var(--accent);
}

/* ---------- content ---------- */

.content {
  width: 100%;
  max-width: calc(var(--measure) + 104px);
  padding: 44px 52px 104px;
}

.crumbs {
  margin: 0 0 16px;
  color: var(--ink-faint);
  font-size: 13px;
}

.crumbs a {
  color: var(--ink-faint);
}

.crumbs a:hover {
  color: var(--accent);
}

h1 {
  margin: 0 0 12px;
  font-family: var(--font-brand);
  font-size: clamp(1.78rem, 1.2rem + 1.7vw, 2.3rem);
  line-height: 1.16;
  letter-spacing: -0.024em;
  font-weight: 600;
}

.lede {
  margin: 0 0 28px;
  max-width: 64ch;
  color: var(--ink-soft);
  font-size: 1.06rem;
  line-height: 1.6;
}

h2 {
  margin: 52px 0 14px;
  font-family: var(--font-brand);
  font-size: 1.42rem;
  line-height: 1.28;
  letter-spacing: -0.014em;
  font-weight: 600;
}

h3 {
  margin: 34px 0 10px;
  font-family: var(--font-brand);
  font-size: 1.14rem;
  line-height: 1.35;
  font-weight: 600;
}

h4 {
  margin: 26px 0 8px;
  font-size: 1rem;
  font-weight: 650;
}

h2,
h3,
h4 {
  scroll-margin-top: calc(var(--topbar-h) + 18px);
}

h2 + h3 {
  margin-top: 24px;
}

p {
  margin: 0 0 15px;
}

ul,
ol {
  margin: 0 0 16px;
  padding-left: 1.35em;
}

li {
  margin: 0 0 7px;
}

li > ul,
li > ol {
  margin-top: 7px;
}

hr {
  height: 1px;
  margin: 40px 0;
  border: 0;
  background: var(--rule);
}

blockquote {
  margin: 0 0 18px;
  padding: 2px 0 2px 18px;
  border-left: 2px solid var(--rule-strong);
  color: var(--ink-soft);
}

strong {
  font-weight: 650;
  color: var(--ink);
}

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

code {
  font-family: var(--mono);
  font-size: 0.875em;
  font-variant-numeric: tabular-nums;
  padding: 0.12em 0.36em;
  border-radius: var(--radius-xs);
  background: var(--bg-code);
  border: 1px solid var(--rule-soft);
  overflow-wrap: anywhere;
}

/* Inline code and definition values must break rather than widen the column: a signature
   header or a long path is one token and would otherwise force a horizontal scrollbar. */
dd,
.facts dt,
.facts dd {
  min-width: 0;
  overflow-wrap: anywhere;
}

pre {
  margin: 0 0 20px;
  padding: 16px 18px;
  overflow-x: auto;
  background: var(--bg-code);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  line-height: 1.6;
  tab-size: 2;
  scrollbar-width: thin;
}

pre code {
  padding: 0;
  border: 0;
  background: none;
  font-size: 13.4px;
  line-height: 1.6;
  white-space: pre;
}

/* A `pre` scrolls sideways rather than wrapping, because a wrapped curl or a wrapped JSON
   body is a different, wrong thing to read. That makes it a scroll region, and a scroll
   region the keyboard cannot reach is text a keyboard user cannot read past the first
   screenful: hence `tabindex="0"` on the element (emitted by the builder) and a focus ring
   that is inset so it is never clipped by the well's own border. */
pre:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
  border-color: var(--focus);
}

/* The sample's frame: a bar above the well, then the well itself. The bar exists so the copy
   control never sits on top of a character. An absolutely-positioned pill was measured
   covering the closing brace of a one-line JSON body - the sample a reader is most likely to
   copy - and no offset fixes that in general, because the sample's first line is the one that
   runs to the right edge. A bar costs one line of height and is always clear of the code.

   The control is revealed by the page's own script (`hidden` is removed only once the
   clipboard API is known to exist), never by CSS hover: a control that appears only under a
   pointer does not exist for a keyboard, and with scripting off nothing is shown at all. */
.code-block {
  margin: 0 0 20px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--bg-code);
  overflow: hidden;
}

.code-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 30px;
  padding: 2px 8px 2px 18px;
  border-bottom: 1px solid var(--rule-soft);
  background: var(--bg-soft);
}

.code-lang {
  color: var(--ink-faint);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.copy {
  padding: 2px 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  background: none;
  color: var(--ink-faint);
  font: inherit;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  line-height: 1.5;
  cursor: pointer;
}

.copy:hover {
  color: var(--ink);
  border-color: var(--rule-strong);
  background: var(--bg-raised);
}

.copy:focus-visible {
  color: var(--ink);
  border-color: var(--focus);
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.copy[data-state="done"] {
  color: var(--ok);
  border-color: var(--ok);
  background: var(--bg-raised);
}

/* The well inside the frame keeps no border or radius of its own: the frame draws them, so
   the bar and the code read as one object rather than two stacked ones. */
.code-block pre {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: none;
}

.code-figure {
  margin: 0 0 20px;
}

/* A caption and the frame's language label are different jobs and now have different shapes:
   the caption says what the sample IS ("Health check, no key"), the language says what it is
   written IN. Both were 10.5px uppercase until the frame arrived, which read as two competing
   headings over one sample; the caption is now a sentence-case line and the uppercase
   micro-label belongs to the frame alone. */
.code-figure figcaption {
  margin: 0 0 6px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.code-provenance {
  margin: 0 0 24px;
  color: var(--ink-faint);
  font-size: 12.5px;
  line-height: 1.5;
}

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

.table-wrap {
  margin: 0 0 20px;
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  line-height: 1.5;
}

/* The header row is NOT sticky, and the round-2 shots are the reason: `.table-wrap` is an
   `overflow-x: auto` box, so it is a scroll container, and a `position: sticky; top: 60px`
   header inside it is offset from THAT box's top - not the page's - which dropped the header
   thirty rows down into the body of the status table. A header that floats over the wrong
   rows is worse than one that scrolls away. */
thead th {
  background: var(--bg-soft);
}

th,
td {
  padding: 9px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--rule-soft);
}

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

th {
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
}

tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--bg-soft) 62%, transparent);
}

td code,
th code {
  white-space: nowrap;
}

/* ---------- method badges ---------- */

.method {
  display: inline-block;
  min-width: 54px;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  border: 1px solid transparent;
}

.method-get {
  color: var(--ok);
  background: var(--ok-soft);
  border-color: color-mix(in srgb, var(--ok) 26%, transparent);
}

.method-post {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 26%, transparent);
}

.path {
  font-family: var(--mono);
  font-size: 0.94em;
  word-break: break-word;
}

/* ---------- route cards ---------- */

.route-list {
  display: grid;
  gap: 10px;
  margin: 0 0 24px;
  padding: 0;
  list-style: none;
}

.route-list li {
  margin: 0;
}

.route-card {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 14px;
  align-items: baseline;
  padding: 14px 17px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--bg-raised);
  text-decoration: none;
  color: inherit;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.route-card:hover,
.route-card:focus-visible {
  border-color: var(--rule-strong);
  box-shadow: var(--shadow);
  color: inherit;
}

.route-card .route-text {
  min-width: 0;
}

.route-card .route-summary {
  display: block;
  margin-top: 4px;
  color: var(--ink-faint);
  font-size: 13.5px;
  line-height: 1.5;
}

/* ---------- endpoint head ---------- */

.endpoint-head {
  margin: 0 0 8px;
  padding: 18px 20px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--bg-soft);
}

.endpoint-head .endpoint-line {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.endpoint-head .endpoint-path {
  font-family: var(--mono);
  font-size: 1.04rem;
  font-weight: 600;
  word-break: break-word;
}

.facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 7px 20px;
  margin: 16px 0 26px;
  font-size: 14px;
}

.facts dt {
  color: var(--ink-faint);
}

.facts dd {
  margin: 0;
}

/* ---------- on-page contents ---------- */

.toc {
  margin: 0 0 34px;
  padding: 15px 20px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--bg-soft);
  font-size: 14px;
}

.toc p {
  margin: 0 0 8px;
  color: var(--ink-faint);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.toc ol {
  margin: 0;
  padding-left: 1.25em;
  columns: 2;
  column-gap: 30px;
}

.toc li {
  margin: 0 0 5px;
  break-inside: avoid;
}

.toc a {
  color: var(--ink-soft);
  text-decoration: none;
}

.toc a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* ---------- callouts ---------- */

.note {
  margin: 0 0 22px;
  padding: 14px 18px;
  border: 1px solid var(--rule);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius);
  background: var(--bg-soft);
  font-size: 14.5px;
  line-height: 1.6;
}

.note > :last-child,
.note p:last-child,
.note ol:last-child,
.note ul:last-child {
  margin-bottom: 0;
}

.note-title {
  margin: 0 0 6px;
  font-weight: 650;
  color: var(--ink);
}

.status-ok {
  color: var(--ok);
}

.status-bad {
  color: var(--bad);
}

/* ---------- footer ---------- */

.page-footer {
  margin-top: 72px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
  color: var(--ink-faint);
  font-size: 12.5px;
  line-height: 1.6;
}

.page-footer p {
  margin: 0 0 6px;
}

.page-footer .sources {
  margin: 6px 0 0;
  padding-left: 1.1em;
  font-family: var(--mono);
  font-size: 11.5px;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
  font-size: 14px;
}

.pager a {
  text-decoration: none;
}

.pager a:hover {
  text-decoration: underline;
}

/* ---------- responsive ---------- */

@media (max-width: 1040px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    max-height: none;
    overflow: visible;
    padding: 14px 18px;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }

  /* Below 1040px the section list becomes a wrapping strip of links: still plain links, still
     keyboard reachable, no disclosure widget and no JavaScript. It WRAPS rather than scrolling
     sideways, because a horizontal scroller hides the last three sections off-screen at 390px
     and nothing on the page says they are there. */
  .sidebar .side-groups {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 8px;
    padding: 0;
  }

  .sidebar .side-heading {
    display: none;
  }

  /* A flex item's default min-width is its content width, so a row of nowrap links would
     grow the item to max-content (~827px measured at 390px wide) and the strip never wrapped;
     the page then scrolled sideways by 8582px. The item has to be shrinkable for wrapping. */
  .sidebar .side-group {
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
  }

  /* Only the section lists become chips. The endpoint list keeps its column layout: as a
     wrapping row of 46 method+path chips it measured 398px wide inside a 390px viewport and
     pushed the document sideways, and it is not shown at this width anyway. */
  .sidebar .side-group:not(.side-endpoints) ul {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 8px;
    margin: 0;
  }

  .sidebar .side-group li {
    margin: 0;
  }

  .sidebar .side-group a {
    display: flex;
    align-items: baseline;
    gap: 7px;
    white-space: nowrap;
    padding: 6px 12px;
    border: 1px solid var(--rule);
    border-radius: 999px;
    font-size: 13.5px;
    margin-left: 0;
    box-shadow: none;
    background: transparent;
  }

  .sidebar .side-group a[aria-current="page"] {
    border-color: var(--accent);
    background: var(--accent-soft);
    padding-left: 12px;
    margin-left: 0;
  }

  .sidebar .side-note {
    display: none;
  }

  /* On a narrow screen the 46 endpoint links would push the article an entire screen down.
     The section list stays; the endpoint list is one link to the index page instead. */
  .side-endpoints .side-heading,
  .side-endpoints .endpoint-nav {
    display: none;
  }

  .content {
    padding: 32px 22px 80px;
  }

  .toc ol {
    columns: 1;
  }
}

/* ---------- the phone's section toggle ----------

   Eleven sections as chips is right at 700-1040px and wrong at 390px: measured on the round-1
   shots, the chip block took the first ~530px of an 844px screen and the page's own h1 began
   below the fold. So the list is a disclosure below 700px.

   The control is a plain <button> that flips one attribute on <html>. Nothing is hidden unless
   the document carries `js` (set by the head script), so with scripting off every section stays
   on the page and the button is not rendered at all - the pre-control page, unchanged. */

.side-toggle {
  display: none;
}

@media (max-width: 700px) {
  html.js .side-toggle {
    display: flex;
    align-items: baseline;
    gap: 8px;
    width: 100%;
    margin: 0 0 4px;
    padding: 9px 2px;
    border: 0;
    border-bottom: 1px solid var(--rule-soft);
    background: none;
    color: var(--ink);
    font: inherit;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
  }

  .side-toggle-label {
    color: var(--ink-faint);
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.09em;
    text-transform: uppercase;
  }

  .side-toggle-current {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 620;
  }

  /* A chevron drawn in borders: no icon font, no SVG, nothing fetched. */
  .side-toggle-chevron {
    margin-left: auto;
    width: 7px;
    height: 7px;
    border-right: 1.5px solid var(--ink-faint);
    border-bottom: 1.5px solid var(--ink-faint);
    transform: translateY(-2px) rotate(45deg);
    transition: transform 140ms ease;
  }

  html[data-side="collapsed"] .side-toggle-chevron {
    transform: translateY(1px) rotate(-135deg);
  }

  html[data-side="collapsed"] .sidebar .side-groups {
    display: none;
  }

  /* Opened, the chips sit under the toggle with the same geometry they had. */
  html[data-side="open"] .sidebar .side-groups {
    margin-top: 8px;
  }
}

@media (max-width: 620px) {
  .topbar {
    flex-wrap: wrap;
    gap: 6px 18px;
    padding: 12px 18px;
    position: static;
  }

  .topnav {
    margin-left: 0;
    gap: 16px;
    font-size: 13px;
  }

  .content {
    padding: 24px 18px 64px;
  }

  h1 {
    font-size: 1.62rem;
  }

  .route-card {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .facts {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .facts dd {
    margin-bottom: 10px;
  }

  pre {
    padding: 13px 14px;
  }

  pre code {
    font-size: 12.6px;
  }

  .toc {
    padding: 13px 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
  }

  html {
    scroll-behavior: auto;
  }
}

@media print {
  .topbar,
  .sidebar,
  .toc,
  .pager {
    display: none;
  }

  .shell {
    display: block;
  }

  .content {
    max-width: none;
    padding: 0;
  }

  pre {
    white-space: pre-wrap;
  }

  a {
    color: var(--ink);
  }
}

/* ============================================================ 12. touch targets ====
   A coarse pointer (a thumb) needs 44px; a fine one (a mouse) needs 24px (WCAG 2.5.8).
   Measured on the shipped page at 390/768/1440 with `hasTouch`, these four controls were
   under the touch floor: the wordmark (30px), the top-nav links (31-34px), the sidebar
   links (25-34px) and the sidebar toggle (42px). Each is a navigation target a reader
   reaches for first, so they get the floor rather than an exemption.

   The change is BOX ONLY: min-height grows and the content is centred inside it, so the
   type, colour, spacing and underline of the links are exactly as they were. No width is
   touched, which is what keeps the row from overflowing at 390.

   NOT exempted as "in-sentence": these are navigation chrome — a top bar, a sidebar list
   and a masthead — not links inside a running sentence, which is the only case WCAG 2.5.8
   lets a small target through. In-body prose links in the documentation keep their small
   box and their exemption. */
@media (pointer: coarse) {
  .wordmark,
  .topnav a,
  .sidebar a,
  .side-toggle {
    min-height: 44px;
  }

  .wordmark,
  .topnav a,
  .sidebar a {
    display: inline-flex;
    align-items: center;
  }

  /* The top bar's links grow symmetrically rather than only downward, so the row stays
     centred against the wordmark instead of sagging away from it. */
  .topnav a { padding-top: 0; padding-bottom: 0; }

  /* A short label ("Errors" is 36px wide) is a narrow target even at 44px tall, so the
     box gets a floor on BOTH axes and the word centres inside it. This is the WCAG 2.5.5
     target size rather than 2.5.8's 24px minimum, because a top bar is reached with a
     thumb on a phone and a near-miss there is a page change, not a stray tap. */
  .topnav a {
    min-width: 44px;
    justify-content: center;
  }

  .side-toggle { align-items: center; }
}

/* Developer workbench. The market figure is drawn from the same recorded API fixture as the response. */
.content:has(.docs-home) { max-width: none; padding: clamp(26px, 3vw, 54px) clamp(20px, 3.1vw, 66px) 70px; }
.docs-home { max-width: 1280px; margin: 0 auto; }
.docs-home [hidden], .contract-tool [hidden] { display: none; }
.docs-top { display: flex; justify-content: space-between; align-items: start; gap: 20px; padding-bottom: 22px; border-bottom: 2px solid var(--ink); }
.docs-top h1 { font-size: clamp(2.65rem, 4.3vw, 4.75rem); line-height: 1.03; letter-spacing: -.055em; margin: 0 0 12px; }
.docs-top .lede { margin: 0; max-width: 49ch; font-size: 1.03rem; }
.docs-home .crumbs { font-size: .85rem; color: var(--accent); margin-bottom: 12px; }
.console-link { display: inline-flex; align-items: center; gap: 12px; min-height: 42px; padding: 5px 12px; border: 1px solid var(--rule-strong); color: var(--ink); font-size: .82rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
.console-link:hover { border-color: var(--accent); color: var(--accent); }
.docs-mosaic { display: grid; grid-template-columns: minmax(0, 1fr) minmax(185px, .39fr); column-gap: clamp(20px, 2.7vw, 46px); margin-top: 24px; }
.docs-lesson, .docs-aside { min-width: 0; }
.docs-home h2, .contract-tool h2 { font-size: 1.6rem; margin: 22px 0 12px; }
.docs-home .docs-aside { border-left: 1px solid var(--rule); padding-left: clamp(17px, 1.8vw, 32px); font-size: .85rem; }
.docs-aside h2 { font-size: 1.28rem; margin-top: 23px; }
.docs-aside p, .schema dd { color: var(--ink-soft); line-height: 1.55; }
.docs-aside a, .contract-links a { color: var(--accent); }
.route-line { display: flex; align-items: center; gap: 12px; padding: 0 0 12px; font: 600 .95rem var(--mono); }
.route-line span { font: 700 .72rem var(--font); background: var(--accent); color: var(--paper); padding: 4px 8px; }
.market-plate { display: grid; grid-template-columns: max-content minmax(60px, 1fr); align-items: center; gap: 20px; margin: 0 0 13px; padding: 18px 20px 16px; background: var(--bg-soft); border-block: 1px solid var(--rule); }
.plate-copy { display: grid; gap: 5px; }
.plate-copy figcaption { font-weight: 650; line-height: 1.25; font-size: .87rem; }
.plate-copy figcaption span { display: block; font-weight: 400; color: var(--ink-soft); margin-top: 3px; }
.plate-copy strong { font: 600 clamp(1.7rem, 2.7vw, 2.6rem)/1 var(--font-brand); font-variant-numeric: tabular-nums; }
.plate-copy small, .plate-plot span { font-size: .72rem; color: var(--ink-soft); }
.plate-plot { text-align: right; min-width: 0; }
.plate-plot svg { width: 100%; height: 77px; display: block; overflow: visible; }
.plate-plot polyline { fill: none; stroke: var(--accent); stroke-width: 1.8; vector-effect: non-scaling-stroke; }
.plate-plot polygon { fill: var(--accent); opacity: .12; }
.plate-plot .plot-grid { fill: none; stroke: var(--rule); vector-effect: non-scaling-stroke; }
.lang-switch { display: flex; gap: 16px; }
.lang-switch button, .restore-example { border: 0; background: transparent; color: var(--ink-soft); padding: 8px 1px; font: 600 .86rem var(--font); cursor: pointer; }
.lang-switch button { border-bottom: 3px solid transparent; min-height: 42px; }
.lang-switch button[aria-pressed=true] { color: var(--accent); border-color: var(--accent); }
.docs-lesson [data-sample] .code-block { background: #252522; color: #fcf3e9; border-color: #393731; border-radius: 0; margin-bottom: 12px; }
.docs-lesson [data-sample] .code-bar { background: #30312d; border-color: #484842; }
.docs-lesson [data-sample] .code-lang, .docs-lesson [data-sample] pre code, .docs-lesson [data-sample] .copy { color: #f1ece4; }
.docs-lesson [data-sample] .copy:hover, .docs-lesson [data-sample] .copy:focus-visible { background: #44443e; }
.response-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; }
.response-head h2 { margin: 0; }
.response-head button { padding: 8px 13px; min-height: 42px; color: var(--paper); background: var(--accent); border: 0; font: 600 .84rem var(--font); cursor: pointer; }
.response-head button:disabled { opacity: .65; }
.sample-status { margin: 5px 0 10px; color: var(--ink-faint); font-size: .82rem; }
#market-response .code-block { border-radius: 0; }
.restore-example { text-decoration: underline; }
.reference-search label { display: block; font-weight: 650; margin-bottom: 6px; }
.search-line { display: flex; align-items: center; border: 1px solid var(--rule-strong); background: var(--canvas); padding: 0 7px; }
.search-line input { min-width: 0; width: 100%; border: 0; padding: 10px 2px; color: var(--ink); background: transparent; font: inherit; }
.search-line kbd { padding: 0 4px; border: 1px solid var(--rule); color: var(--ink-faint); }
.reference-search ul { padding: 0; margin: 5px 0 0; list-style: none; }
.reference-search li { margin: 0; border-top: 1px solid var(--rule); }
.reference-search li a { display: block; padding: 8px 0; overflow-wrap: anywhere; font-family: var(--mono); }
.schema { margin: 0 0 12px; }
.schema dt { display: flex; justify-content: space-between; gap: 8px; border-top: 1px solid var(--rule); padding: 8px 0 1px; font: 600 .85rem var(--mono); }
.schema dt span { color: var(--ink-faint); font: 400 .75rem var(--mono); }
.schema dd { margin: 2px 0 10px; }
.guide-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 24px; }
.guide-grid a { display: grid; border-top: 1px solid var(--rule); padding: 13px 0 16px; text-decoration: none; gap: 4px; }
.guide-grid strong { font: 600 1.11rem var(--font-brand); }
.guide-grid span { font-size: .88rem; color: var(--ink-soft); }
.guide-grid a:hover strong { color: var(--accent); }
.contract-tool { border-top: 3px solid var(--accent); padding: 18px 22px; background: var(--paper-2); margin: 20px 0 12px; }
.contract-tool h2 { margin: 0 0 12px; }
.contract-tool h3 { font-size: 1.12rem; margin: 14px 0 5px; }
.contract-tool p { margin: 0 0 5px; }
.contract-select { display: grid; justify-items: start; gap: 5px; color: var(--ink-soft); font-size: .88rem; }
.contract-select select { max-width: 100%; font: inherit; border: 1px solid var(--rule-strong); background: var(--canvas); color: var(--ink); min-height: 42px; padding: 5px 10px; }
.contract-links { display: flex; gap: 10px 20px; flex-wrap: wrap; margin: 14px 0 24px; font-size: .89rem; }
@media (min-width: 1041px) {
  body:has(.docs-home) .shell { grid-template-columns: clamp(210px, 17.2vw, 296px) minmax(0, 1fr); }
}
@media (max-width: 770px) {
  .docs-mosaic { display: flex; flex-direction: column; }
  .docs-home .docs-aside { padding: 0; border-left: 0; }
  .docs-top { display: block; }
  .console-link { margin-top: 12px; }
  .market-plate { gap: 12px; padding: 12px; }
}
@media (max-width: 470px) {
  .plate-plot span { display: block; font-size: .66rem; }
  .plate-plot svg { height: 55px; }
  .guide-grid { grid-template-columns: 1fr; }
}

.sdk-install { font-size: .84rem; color: var(--ink-soft); }
.sdk-install summary { width: fit-content; padding: 4px 0; cursor: pointer; }
.sdk-install p { margin: 5px 0 8px; }
