/* Flux developer docs. Colours and fonts come from tokens.css. */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 88px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
  overflow-x: hidden;
}

img, svg { max-width: 100%; }

a { color: var(--link); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--link-hover); }

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

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--fx-white);
  color: var(--fx-navy);
  border-radius: var(--radius-sm);
  font-weight: 600;
}
.skip-link:focus { top: 12px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--header-bg);
  color: var(--header-text);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.site-header__inner {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 64px;
  padding: 0 24px;
  max-width: 1440px;
  margin: 0 auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--header-text);
  text-decoration: none;
  line-height: 0;
  flex-shrink: 0;
}
.brand img { height: 28px; width: auto; display: block; }
.brand__label {
  font: 600 12px/1 var(--font-sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--header-mute);
  line-height: 1;
  padding-left: 12px;
  border-left: 1px solid rgba(255, 255, 255, 0.24);
}
.brand:hover { color: var(--header-text); }

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  margin-left: -8px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: var(--radius-sm);
  color: var(--header-text);
  cursor: pointer;
}
.menu-toggle svg { width: 20px; height: 20px; }

.search {
  position: relative;
  flex: 1 1 auto;
  max-width: 420px;
  margin-left: auto;
}
.site-header .search__input {
  width: 100%;
  height: 40px;
  padding: 0 40px 0 38px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--header-text);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-sm);
  font: 400 15px/1 var(--font-sans);
}
.site-header .search__input::placeholder { color: var(--header-mute); }
.site-header .search__input:focus { border-color: var(--fx-blue-500); outline: none; box-shadow: 0 0 0 3px rgba(8, 120, 248, 0.4); }
.search__icon {
  position: absolute;
  left: 12px; top: 50%;
  width: 16px; height: 16px;
  transform: translateY(-50%);
  color: var(--header-mute);
  pointer-events: none;
}
.search__key {
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  font: 500 12px/1 var(--font-mono);
  color: var(--header-mute);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 5px;
  padding: 3px 6px;
  pointer-events: none;
}
.search__results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  z-index: 50;
  max-height: min(70vh, 480px);
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 40px rgba(16, 25, 36, 0.28);
}
.search__results[hidden] { display: none; }
.search__results a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  line-height: 1.35;
}
.search__results a .r-page { display: block; font-size: 12px; color: var(--text-mute); margin-bottom: 2px; }
.search__results a .r-title { font-weight: 500; }
.search__results a[aria-selected="true"],
.search__results a:hover { background: var(--callout-bg); }
.search__empty { padding: 10px; color: var(--text-mute); font-size: var(--fs-small); }

.header-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  background: var(--btn-bg);
  color: var(--fx-white);
  font: 600 14px/1 var(--font-sans);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.header-cta:hover { background: var(--fx-blue-500); color: var(--fx-white); transform: translateY(-1px); }

/* ---------- Layout ---------- */

.layout {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr) 232px;
  grid-template-areas: "nav main toc";
  max-width: 1440px;
  margin: 0 auto;
}

.sidebar {
  grid-area: nav;
  position: sticky;
  top: 64px;
  align-self: start;
  height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 28px 16px 40px 24px;
  border-right: 1px solid var(--rule);
}
.sidebar__group { margin: 0 0 22px; }
.sidebar__heading {
  margin: 0 0 6px;
  padding: 0 10px;
  font: 600 var(--fs-kicker)/1.4 var(--font-sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li { margin: 0; }
.sidebar a {
  display: block;
  padding: 6px 10px;
  border-left: 2px solid transparent;
  border-radius: 0 8px 8px 0;
  color: var(--text);
  text-decoration: none;
  font-size: var(--fs-small);
  line-height: 1.4;
}
.sidebar a:hover { background: var(--bg-subtle); color: var(--heading); }
.sidebar a[aria-current="page"] {
  border-left-color: var(--accent);
  background: var(--callout-bg);
  color: var(--accent-ink);
  font-weight: 600;
}

.content {
  grid-area: main;
  min-width: 0;
  padding: 40px 56px 64px;
}
.article { max-width: 800px; }

.toc {
  grid-area: toc;
  position: sticky;
  top: 64px;
  align-self: start;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 40px 24px 40px 8px;
  font-size: 14px;
}
.toc summary {
  list-style: none;
  margin-bottom: 8px;
  font: 600 var(--fs-kicker)/1.4 var(--font-sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-mute);
  cursor: default;
}
.toc summary::-webkit-details-marker { display: none; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 0; }
.toc a {
  display: block;
  padding: 4px 0 4px 12px;
  border-left: 1px solid var(--rule);
  color: var(--text-mute);
  text-decoration: none;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.toc a:hover { color: var(--heading); }
.toc a.is-active { color: var(--accent-ink); border-left-color: var(--accent); }
.toc .toc-h3 a { padding-left: 24px; font-size: 13px; }

/* ---------- Typography ---------- */

.kicker {
  margin: 0 0 10px;
  font: 700 12px/1.4 var(--font-sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-ink);
}
h1, h2, h3, h4 {
  color: var(--heading);
  font-weight: var(--w-head);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
h1 { margin: 0 0 16px; font-size: clamp(1.9rem, 4vw, 2.5rem); letter-spacing: -0.03em; line-height: 1.1; }
h2 { margin: 56px 0 14px; font-size: clamp(1.4rem, 2.4vw, 1.65rem); }
h3 { margin: 36px 0 10px; font-size: var(--fs-h4); font-weight: 600; letter-spacing: -0.012em; }
h4 { margin: 24px 0 8px; font-size: 1rem; font-weight: 600; letter-spacing: 0; }
h2 + h3 { margin-top: 18px; }
.lead { font-size: clamp(1.04rem, 1.6vw, 1.12rem); color: var(--text-mute); margin: 0 0 28px; }
p, ul, ol, dl { margin: 0 0 16px; }
li { margin-bottom: 6px; }
li > ul, li > ol { margin-top: 6px; }
strong { font-weight: var(--w-strong); }
hr { border: 0; border-top: 1px solid var(--rule); margin: 40px 0; }

.anchor-heading { position: relative; }
.anchor-heading .anchor {
  margin-left: 8px;
  color: var(--text-mute);
  text-decoration: none;
  font-weight: 400;
  opacity: 0;
  transition: opacity 0.15s;
}
.anchor-heading:hover .anchor,
.anchor-heading .anchor:focus-visible { opacity: 1; }

code, kbd, samp, pre { font-family: var(--font-mono); font-size: 0.875em; }
:not(pre) > code {
  padding: 0.12em 0.36em;
  background: var(--inline-code-bg);
  color: var(--inline-code-text);
  border-radius: 5px;
  overflow-wrap: anywhere;
}
a > code { color: inherit; }
kbd {
  padding: 0.1em 0.4em;
  border: 1px solid var(--rule-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  font-size: 0.8em;
}

/* ---------- Tables ---------- */

.table-wrap {
  margin: 0 0 24px;
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-small);
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}
th, td {
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--rule);
}
th {
  background: var(--bg-subtle);
  color: var(--heading);
  font-weight: 600;
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
td code { white-space: nowrap; }
td.wrap code, td .wrap { white-space: normal; }
.field-name { font-family: var(--font-mono); font-size: 0.875em; font-weight: 600; color: var(--heading); white-space: nowrap; }
.field-type { display: block; margin-top: 2px; font: 400 12px/1.3 var(--font-mono); color: var(--text-mute); white-space: nowrap; }

/* ---------- Badges, chips and pills ---------- */

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font: 600 12px/1.6 var(--font-sans);
  vertical-align: 0.1em;
  white-space: nowrap;
}
.badge--required { background: var(--btn-bg); color: var(--fx-white); }
.badge--optional { background: transparent; color: var(--text-mute); border: 1px dashed var(--rule-strong); }
.badge--scope { background: var(--chip-bg); color: var(--chip-text); font-family: var(--font-mono); font-weight: 500; }
.badge--idem { background: var(--ok-bg); color: var(--ok); }

.needs-input {
  display: inline-block;
  padding: 0 7px;
  border: 1px dashed var(--warn);
  border-radius: 6px;
  background: var(--warn-bg);
  color: var(--warn);
  font: 600 0.82em/1.6 var(--font-sans);
}
.needs-input::before { content: "Needs input: "; }

.pill {
  display: inline-block;
  padding: 1px 9px;
  border-radius: 999px;
  font: 600 12px/1.6 var(--font-mono);
  white-space: nowrap;
}
.pill--ok { background: var(--ok-bg); color: var(--ok); }
.pill--bad { background: var(--bad-bg); color: var(--bad); }
.pill--warn { background: var(--warn-bg); color: var(--warn); }
.pill--info { background: var(--chip-bg); color: var(--chip-text); }
.pill--neutral { background: var(--bg-subtle); color: var(--text-mute); border: 1px solid var(--rule); }

/* ---------- Callouts ---------- */

.callout {
  margin: 0 0 24px;
  padding: 14px 18px;
  background: var(--callout-bg);
  border: 1px solid var(--callout-rule);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
}
.callout > :last-child { margin-bottom: 0; }
.callout__title { display: block; margin-bottom: 4px; font-weight: 600; color: var(--heading); }
.callout--warn { background: var(--warn-bg); border-color: var(--warn); border-left-color: var(--warn); }
.callout--neutral { background: var(--bg-subtle); border-color: var(--rule); border-left-color: var(--text-mute); }

/* ---------- Endpoint header ---------- */

.endpoint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 0 0 18px;
  padding: 10px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
}
.endpoint__path { font: 600 14.5px/1.4 var(--font-mono); color: var(--heading); overflow-wrap: anywhere; }
.endpoint__path code { background: none; padding: 0; color: inherit; }
.endpoint__meta { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.method {
  display: inline-block;
  min-width: 58px;
  padding: 2px 8px;
  border-radius: 6px;
  font: 700 12px/1.6 var(--font-mono);
  text-align: center;
  letter-spacing: 0.04em;
}
.method--get { background: var(--ok-bg); color: var(--ok); }
.method--post { background: var(--chip-bg); color: var(--chip-text); }
.method--patch { background: var(--warn-bg); color: var(--warn); }
.method--delete { background: var(--bad-bg); color: var(--bad); }

.endpoint-index { margin: 0 0 28px; }
.endpoint-index td:first-child { white-space: nowrap; width: 1%; }
.endpoint-index .method { min-width: 54px; }

/* ---------- Code ---------- */

.code {
  position: relative;
  margin: 0 0 24px;
  background: var(--code-bg);
  color: var(--code-text);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.code__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 42px;
  padding: 0 8px 0 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.code__label {
  font: 500 12px/1 var(--font-mono);
  letter-spacing: 0.04em;
  color: var(--code-mute);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.code pre {
  margin: 0;
  padding: 14px 16px 16px;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.6;
  tab-size: 2;
}
.code pre code { font-size: inherit; color: inherit; background: none; padding: 0; white-space: pre; }
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  background: transparent;
  color: var(--code-text);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 7px;
  font: 500 12px/1 var(--font-sans);
  cursor: pointer;
  flex-shrink: 0;
}
.copy-btn:hover { border-color: var(--fx-blue-500); }
.copy-btn svg { width: 14px; height: 14px; }
.copy-btn.is-copied { border-color: #5fd39a; color: #5fd39a; }

.tabs__list {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.tabs__tab {
  flex-shrink: 0;
  height: 42px;
  padding: 0 11px;
  background: transparent;
  color: var(--code-mute);
  border: 0;
  border-bottom: 2px solid transparent;
  font: 500 13px/1 var(--font-sans);
  cursor: pointer;
}
.tabs__tab:hover { color: var(--code-text); }
.tabs__tab[aria-selected="true"] { color: var(--fx-white); border-bottom-color: var(--fx-blue-500); }
.tabs__tab:focus-visible { outline-offset: -3px; }
.tabs__panel[hidden] { display: none; }

.tok-key { color: var(--code-key); }
.tok-str { color: var(--code-str); }
.tok-num { color: var(--code-num); }
.tok-lit { color: var(--code-lit); }
.tok-com { color: var(--code-mute); font-style: italic; }

details.response {
  margin: 0 0 16px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
}
details.response > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  font-size: var(--fs-small);
}
details.response[open] > summary { border-bottom: 1px solid var(--rule); }
details.response .code { margin: 12px; }
details.response > p { margin: 12px 14px 0; font-size: var(--fs-small); }

/* ---------- Flow cards ---------- */

.flow {
  display: grid;
  grid-template-columns: repeat(var(--flow-cols, 3), minmax(0, 1fr));
  gap: 28px;
  margin: 8px 0 32px;
  padding: 0;
  list-style: none;
  counter-reset: flow;
}
.flow--4 { --flow-cols: 4; gap: 24px; }
.flow__step {
  position: relative;
  margin: 0;
  padding: 18px 16px 16px;
  background: var(--fx-rail);
  color: var(--fx-white);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-card);
  counter-increment: flow;
}
.flow__step::before {
  content: counter(flow, decimal-leading-zero);
  display: block;
  margin-bottom: 6px;
  font: 700 26px/1 var(--font-sans);
  letter-spacing: -0.03em;
  color: var(--fx-blue-400);
}
.flow__step h3 { margin: 0 0 6px; color: var(--fx-white); font-size: 1rem; }
.flow__step p { margin: 0; font-size: 14px; line-height: 1.5; color: #c9d2de; }
.flow__step code { background: rgba(255, 255, 255, 0.1); color: #cfe0ff; }
.flow__who {
  display: inline-block;
  margin-bottom: 10px;
  font: 600 11px/1 var(--font-sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #9cc3ff;
}
.flow__step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -19px;
  width: 12px; height: 12px;
  border-top: 2px solid var(--accent);
  border-right: 2px solid var(--accent);
  transform: translateY(-50%) rotate(45deg);
}
.flow-note {
  margin: -16px 0 32px;
  font-size: var(--fs-small);
  color: var(--text-mute);
  text-align: center;
}

/* ---------- Diagrams ---------- */

.diagram {
  margin: 8px 0 28px;
  padding: 16px;
  background: var(--bg-subtle);
  border: 1px solid var(--rule);
  border-radius: var(--radius-card);
}
.diagram svg { display: block; width: 100%; height: auto; }
.diagram figcaption { margin-top: 10px; font-size: 13.5px; color: var(--text-mute); }
.diagram__scroll { overflow-x: auto; }
.diagram__scroll svg { min-width: 640px; }
.dg-box { fill: var(--bg-raised); stroke: var(--rule-strong); stroke-width: 1.25; }
.dg-box--ok { fill: var(--ok-bg); stroke: var(--ok); }
.dg-box--accent { fill: var(--callout-bg); stroke: var(--accent); }
.dg-box--bad { fill: var(--bad-bg); stroke: var(--bad); stroke-dasharray: 5 4; }
.dg-box--warn { fill: var(--warn-bg); stroke: var(--warn); }
.dg-state { font: 600 13.5px var(--font-mono); fill: var(--heading); }
.dg-label { font: 500 12px var(--font-sans); fill: var(--text); }
.dg-event { font: 500 11.5px var(--font-mono); fill: var(--accent-ink); }
.dg-mute { font: 400 11.5px var(--font-sans); fill: var(--text-mute); }
.dg-line { fill: none; stroke: var(--text-mute); stroke-width: 1.5; }
.dg-line--dash { stroke-dasharray: 5 4; }
.dg-arrow { fill: var(--text-mute); }
.dg-start { fill: var(--heading); }

/* ---------- Checklist (overview) ---------- */

.req-list { list-style: none; margin: 0 0 32px; padding: 0; display: grid; gap: 12px; }
.req {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 16px;
  padding: 14px 18px;
  background: var(--bg-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  margin: 0;
}
.req__check { grid-row: span 2; display: flex; align-items: flex-start; padding-top: 3px; }
.req__check input { width: 20px; height: 20px; margin: 0; accent-color: var(--fx-blue-600); }
.req__title { margin: 0; font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; }
.req__id { font: 600 13px/1 var(--font-mono); color: var(--accent-ink); margin-right: 6px; }
.req__body { margin: 0; font-size: var(--fs-small); color: var(--text-mute); }
.req__body a { font-weight: 500; }

/* ---------- Steps (quick start, guides) ---------- */

.steps { list-style: none; counter-reset: step; margin: 0 0 24px; padding: 0; }
.steps > li { position: relative; counter-increment: step; margin: 0 0 8px; padding-left: 52px; }
.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: 0;
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--fx-rail);
  color: #9cc3ff;
  font: 700 16px/1 var(--font-sans);
}
.steps > li > h2 { margin-top: 4px; font-size: 1.3rem; }
.steps > li + li { margin-top: 40px; }

/* ---------- Cards (overview, guides index) ---------- */

.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 0 0 28px; padding: 0; list-style: none; }
.card {
  margin: 0;
  padding: 16px 18px;
  background: var(--bg-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 4px; font-size: 1rem; }
.card h3 a { color: var(--heading); text-decoration: none; }
.card h3 a::after { content: " \2192"; color: var(--accent-ink); }
.card h3 a:hover { color: var(--accent-ink); }
.card p { margin: 0; font-size: var(--fs-small); color: var(--text-mute); }

/* ---------- Prev / next ---------- */

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 64px 0 0;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
}
.pager a {
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--heading);
  font-weight: 600;
}
.pager a:hover { border-color: var(--accent); color: var(--heading); }
.pager small {
  display: block;
  margin-bottom: 2px;
  font: 500 12px/1.4 var(--font-sans);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.pager__next { text-align: right; grid-column: 2; }

.site-footer {
  margin-top: 40px;
  font-size: 14px;
  color: var(--text-mute);
}
.site-footer p { margin: 0 0 6px; }

/* ---------- Tool (signature checker) ---------- */

.tool {
  margin: 0 0 32px;
  padding: 20px;
  background: var(--bg-subtle);
  border: 1px solid var(--rule);
  border-radius: var(--radius-card);
}
.tool > h3:first-child { margin-top: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 14px; font-weight: 500; }
.field .hint { font-size: 12.5px; color: var(--text-mute); line-height: 1.4; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--fx-blue-600); }
input[type="text"], input[type="password"], textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  background: var(--bg-raised);
  color: var(--text);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  font: 400 14px/1.4 var(--font-sans);
}
textarea { font-family: var(--font-mono); font-size: 13px; min-height: 110px; resize: vertical; }
.field input.mono { font-family: var(--font-mono); font-size: 13px; }
input:focus, textarea:focus { border-color: var(--fx-blue-500); outline: none; box-shadow: 0 0 0 3px rgba(8, 120, 248, 0.3); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--btn-h);
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  font: 600 14.5px/1 var(--font-sans);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.btn--primary { background: var(--btn-bg); color: var(--fx-white); }
.btn--primary:hover { background: var(--btn-bg-hover); color: var(--fx-white); }
.btn--secondary { background: transparent; color: var(--heading); border-color: var(--rule-strong); }
.btn--secondary:hover { border-color: var(--accent); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }

.result-box {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--rule);
  background: var(--bg-raised);
  font-size: 14px;
}
.result-box[hidden] { display: none; }
.result-box--ok { border-color: var(--ok); background: var(--ok-bg); }
.result-box--bad { border-color: var(--bad); background: var(--bad-bg); }
.result-box strong { display: block; margin-bottom: 4px; }
.result-box ul { margin: 6px 0 0; padding-left: 18px; }
.result-box pre { margin: 8px 0 0; white-space: pre-wrap; word-break: break-all; font-size: 12.5px; }

/* ---------- Responsive ---------- */

@media (max-width: 1200px) {
  .layout {
    grid-template-columns: 248px minmax(0, 1fr);
    grid-template-areas: "nav toc" "nav main";
    grid-template-rows: auto 1fr;
  }
  .toc {
    position: static;
    max-height: none;
    padding: 24px 40px 0;
  }
  .toc details {
    max-width: 800px;
    border: 1px solid var(--rule);
    border-radius: var(--radius-md);
    padding: 10px 14px;
  }
  .toc summary { cursor: pointer; margin: 0; }
  .toc summary::after { content: " +"; }
  .toc details[open] summary::after { content: " \2212"; }
  .toc details[open] summary { margin-bottom: 8px; }
  .content { padding: 24px 40px 56px; }
  .flow--4 { --flow-cols: 2; gap: 28px; }
  .flow--4 .flow__step:nth-child(2)::after { display: none; }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "toc" "main"; }
  .menu-toggle { display: inline-flex; }
  .sidebar {
    position: fixed;
    top: 64px; left: 0; bottom: 0;
    z-index: 35;
    width: min(320px, 86vw);
    height: auto;
    background: var(--bg);
    border-right: 1px solid var(--rule);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.25s ease, visibility 0.25s;
  }
  body.nav-open .sidebar { transform: none; visibility: visible; box-shadow: 0 0 60px rgba(16, 25, 36, 0.4); }
  .nav-scrim {
    position: fixed;
    inset: 64px 0 0 0;
    z-index: 30;
    background: rgba(16, 25, 36, 0.5);
  }
  .nav-scrim[hidden] { display: none; }
  .flow, .flow--4 { --flow-cols: 1; gap: 28px; }
  .flow__step:not(:last-child)::after,
  .flow--4 .flow__step:nth-child(2)::after {
    display: block;
    top: auto; bottom: -21px; right: auto; left: 50%;
    transform: translateX(-50%) rotate(135deg);
  }
  .cards { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
  .site-header__inner { gap: 10px; padding: 0 16px; }
  .brand__label { display: none; }
  .brand img { height: 24px; }
  .search__key { display: none; }
  .site-header .search__input { padding-right: 10px; }
  .header-cta { padding: 0 12px; }
  .header-cta .long { display: none; }
  .content { padding: 20px 16px 48px; }
  .toc { padding: 16px 16px 0; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .pager { grid-template-columns: minmax(0, 1fr); }
  .pager__next { grid-column: 1; }
  .tool { padding: 16px; border-radius: var(--radius-md); }
  th, td { padding: 8px 10px; }
  .steps > li { padding-left: 46px; }
  td code { white-space: normal; overflow-wrap: anywhere; }
  .endpoint__meta { margin-left: 0; }
  /* Field tables stack on phones: name and type above the description. */
  table.fields thead { display: none; }
  table.fields tr { display: block; border-bottom: 1px solid var(--rule); }
  table.fields tbody tr:last-child { border-bottom: 0; }
  table.fields td { display: block; border: 0; padding: 4px 12px; }
  table.fields td:first-child { padding-top: 12px; }
  table.fields td:last-child { padding-bottom: 12px; }
}

@media (min-width: 641px) {
  .header-cta .short { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

@media print {
  .site-header, .sidebar, .toc, .pager, .copy-btn { display: none !important; }
  .layout { display: block; }
  .tabs__panel[hidden] { display: block; }
}

/* ---------- Downloads ---------- */

.schema-list {
  columns: 2 240px;
  column-gap: 24px;
  padding-left: 18px;
  font-size: var(--fs-small);
}
.schema-list li { break-inside: avoid; }
