/* Theme resolution: with no data-theme attribute the palette follows the
   system, which also keeps working without JavaScript. The menu sets
   data-theme on <html> to override, and the two attribute rules below outrank
   the media query because an attribute selector adds specificity. */

:root {
  /* native UI (scrollbars, form controls) follows the system by default */
  color-scheme: light dark;

  --bg: #fdfdfc;
  --panel: #ffffff;
  --sunk: #f6f6f4;
  --text: #1b1b19;
  --muted: #6d6d68;
  --faint: #93938c;
  --line: #e5e4e0;
  --line-soft: #efeeea;
  --accent: #2f6f4e;
  --accent-soft: #eaf3ee;

  --get: #2f6f4e;
  --post: #2c5d99;
  --put: #8a5a1f;
  --patch: #7a5296;
  --delete: #a63a3a;
  --other: #6d6d68;

  --radius: 7px;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sidebar-w: 19rem;
  --topbar-h: 3.5rem;
}

:root[data-theme="light"] { color-scheme: light; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131314;
    --panel: #171718;
    --sunk: #1d1d1f;
    --text: #e8e8e4;
    --muted: #9a9a94;
    --faint: #74746e;
    --line: #2b2b2d;
    --line-soft: #232325;
    --accent: #6cc08b;
    --accent-soft: #1a2a20;

    --get: #6cc08b;
    --post: #74a9e8;
    --put: #d3a05a;
    --patch: #b795d6;
    --delete: #e08585;
    --other: #9a9a94;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #131314;
  --panel: #171718;
  --sunk: #1d1d1f;
  --text: #e8e8e4;
  --muted: #9a9a94;
  --faint: #74746e;
  --line: #2b2b2d;
  --line-soft: #232325;
  --accent: #6cc08b;
  --accent-soft: #1a2a20;

  --get: #6cc08b;
  --post: #74a9e8;
  --put: #d3a05a;
  --patch: #b795d6;
  --delete: #e08585;
  --other: #9a9a94;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

code, pre { font-family: var(--mono); font-size: 0.86em; }

h1, h2, h3, h4 { line-height: 1.25; font-weight: 600; margin: 0; letter-spacing: -0.01em; }

.muted { color: var(--muted); }

/* ---------- landing ---------- */

.landing {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 2rem 1.5rem 6rem;
}

/* the landing page has no topbar, so the menu is pinned to the coordinates it
   would occupy inside one: vertically centred in the bar (less its bottom
   border), 1.25rem from the edge, matching the topbar's padding */
.landing > .menu {
  position: fixed;
  top: calc((var(--topbar-h) - 1px - 2rem) / 2);
  right: 1.25rem;
  z-index: 20;
}

.landing-inner { width: 100%; max-width: 34rem; }

.landing h1 { font-size: 1.9rem; margin-bottom: 0.4rem; }

.lede { color: var(--muted); margin: 0 0 1.5rem; }

.hint { color: var(--muted); font-size: 0.9rem; margin: 1rem 0 0; }

.foot {
  color: var(--faint);
  font-size: 0.8rem;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line-soft);
}

/* ---------- catalog ---------- */

/* The landing list of archived specs. Rows deliberately mirror the archive
   dropdown's shape so the two lists read as one thing in two places. */
.catalog { margin-top: 2rem; }

.catalog .menu-label { margin-left: 0; margin-right: 0; }

/* No max-height here, unlike the archive dropdown: that one is a floating
   panel that has to stay inside the viewport, while this is page content. A
   scroll box would hide entries behind an overlay scrollbar that macOS does
   not draw until you scroll, so a long list grows the page instead. */
.catalog ul {
  list-style: none;
  /* the rows bleed past the text column so a hover reads as a target, while
     the labels stay aligned with the form above them */
  margin: 0 -0.5rem;
  padding: 0;
}

.catalog-item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.45rem 0.5rem;
  border-radius: 5px;
  color: var(--text);
  text-decoration: none;
}

.catalog-item:hover { background: var(--sunk); }
.catalog-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.catalog-title { font-size: 0.9rem; font-weight: 500; }
.catalog-meta { font-size: 0.72rem; color: var(--faint); }

/* ---------- url form ---------- */

.urlform { display: flex; gap: 0.5rem; }

.urlform input {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.75rem;
  font: inherit;
  font-size: 0.92rem;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.urlform input:focus-visible,
.filter:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: transparent;
}

.urlform button {
  padding: 0.6rem 1.05rem;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--bg);
  background: var(--text);
  border: 1px solid var(--text);
  border-radius: var(--radius);
  cursor: pointer;
}

.urlform button:hover { opacity: 0.85; }
.urlform button:disabled { opacity: 0.5; cursor: progress; }

/* ---------- loading indicator ---------- */

.progress {
  display: none;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.9rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.progress.htmx-request { display: flex; }

.progress-bar {
  position: relative;
  flex: 1;
  height: 2px;
  overflow: hidden;
  background: var(--line);
  border-radius: 2px;
}

.progress-bar::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 35%;
  background: var(--accent);
  animation: slide 1.1s ease-in-out infinite;
}

@keyframes slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(340%); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .progress-bar::after { animation: none; width: 100%; opacity: 0.4; }
}

/* topbar variant sits full width under the header */
.topbar + .progress { margin: 0; padding: 0 1.25rem 0.6rem; }

/* ---------- topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  height: var(--topbar-h);
  padding: 0 1.25rem;
  /* opaque: content scrolls underneath and must not read through */
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.brand { font-weight: 600; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; color: var(--accent); }

.topbar .urlform { flex: 1; max-width: 34rem; margin-left: auto; }
.topbar .urlform input { padding: 0.4rem 0.6rem; font-size: 0.85rem; }
.topbar .urlform button { padding: 0.4rem 0.8rem; font-size: 0.85rem; }

/* ---------- menu ---------- */

.menu { position: relative; flex: none; }

.menu-button {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  color: var(--muted);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
}

.menu-button:hover,
.menu-button[aria-expanded="true"] {
  color: var(--text);
  background: var(--sunk);
}

.menu-button[aria-expanded="true"] { border-color: var(--line); }
.menu-button svg { width: 1.05rem; height: 1.05rem; }

.menu-panel {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  z-index: 30;
  min-width: 10rem;
  padding: 0.4rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.12);
}

.menu-panel[hidden] { display: none; }

.menu-label {
  margin: 0.15rem 0.5rem 0.3rem;
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--faint);
}

.menu-choice {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.35rem 0.5rem;
  font: inherit;
  font-size: 0.88rem;
  text-align: left;
  color: var(--text);
  background: none;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
}

.menu-choice:hover { background: var(--sunk); }
.menu-choice[aria-checked="true"] { color: var(--accent); }

.menu-check {
  width: 0.8rem;
  flex: none;
  color: var(--accent);
  /* reserve the space so the labels do not shift when the choice changes */
  visibility: hidden;
}

.menu-choice[aria-checked="true"] .menu-check { visibility: visible; }

.menu-button:focus-visible,
.menu-choice:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

/* ---------- layout ---------- */

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

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100dvh - var(--topbar-h));
  display: flex;
  flex-direction: column;
  padding: 1rem 0.5rem 0 1.25rem;
  border-right: 1px solid var(--line);
}

.filter {
  width: 100%;
  padding: 0.4rem 0.6rem;
  margin-bottom: 0.75rem;
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--sunk);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.nav-scroll { overflow-y: auto; padding-bottom: 3rem; scrollbar-width: thin; }

.nav-group { margin-bottom: 1.25rem; }

.nav-group h2 {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--faint);
  margin-bottom: 0.35rem;
}

.nav-group h2 a { color: inherit; }

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

.nav-group li a {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.2rem 0.5rem;
  border-radius: 5px;
  color: var(--muted);
  font-size: 0.86rem;
}

.nav-group li a:hover { background: var(--sunk); color: var(--text); text-decoration: none; }
.nav-group li.active a { background: var(--accent-soft); color: var(--text); }

.nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-empty { color: var(--faint); font-size: 0.85rem; padding: 0.5rem; }

/* wide enough for the reference column plus the payload panel beside it; the
   prose blocks inside set their own measure so nothing runs to 80rem of text */
.content {
  min-width: 0;
  max-width: 78rem;
  padding: 2.25rem 2rem 60vh;
}

.doc-head, .content > .notice, .servers { max-width: 46rem; }
.op-main .prose { max-width: 64ch; }

/* ---------- document head ---------- */

.doc-head { padding-bottom: 2rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.doc-head h1 { font-size: 1.75rem; }

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin: 0.65rem 0 0;
  font-size: 0.78rem;
}

.pill {
  padding: 0.1rem 0.5rem;
  color: var(--muted);
  background: var(--sunk);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
}

.source { font-size: 0.78rem; }

/* Archive dropdown. <details> carries the open/close state so this keeps
   working without JavaScript, the same way the schema subtrees do. */
.versions { position: relative; }

.versions summary {
  padding: 0.1rem 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--sunk);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.versions summary::-webkit-details-marker { display: none; }
.versions summary::after { content: " \25be"; }
.versions summary:hover { color: var(--text); border-color: var(--line); }
.versions summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.versions-panel {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  z-index: 30;
  min-width: 14rem;
  max-height: 20rem;
  overflow-y: auto;
  padding: 0.4rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.12);
}

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

.version {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.35rem 0.5rem;
  border-radius: 5px;
  color: var(--text);
  text-decoration: none;
}

.version:hover { background: var(--sunk); }
.version.is-latest .version-name { color: var(--accent); }
.version-name { font-size: 0.8rem; font-weight: 500; }
.version-name code { font-family: var(--mono); font-size: 0.74rem; }
.version-meta { font-size: 0.7rem; color: var(--faint); }
.version-from {
  display: block;
  max-width: 18rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 0.66rem;
}

.archived-note {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.servers { margin-top: 1.5rem; }
.servers h3 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--faint); }
.servers ul { list-style: none; margin: 0.4rem 0 0; padding: 0; }
.servers li { padding: 0.25rem 0; font-size: 0.9rem; }
.servers code { background: var(--sunk); padding: 0.1rem 0.35rem; border-radius: 4px; }

/* ---------- groups and operations ---------- */

.group { padding-top: 2.5rem; }

.group > h2 {
  font-size: 1.25rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--line);
}

.op {
  padding: 2.5rem 0 3rem;
  border-bottom: 1px solid var(--line-soft);
  scroll-margin-top: calc(var(--topbar-h) + 1rem);
}

.op.deprecated .op-head h3 { text-decoration: line-through; text-decoration-color: var(--faint); }

.op-collapsed { padding-bottom: 2rem; }

.op-expand {
  margin-top: 0.9rem;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
}

.op-expand:hover { color: var(--accent); }
.op-expand:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.op-expand.htmx-request { color: var(--faint); }

.op-head h3 { font-size: 1.35rem; letter-spacing: -0.02em; }
.op-head h3 a { color: var(--text); }

.endpoint {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.9rem;
  padding: 0.55rem 0.75rem;
  background: var(--sunk);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
}

.path { white-space: nowrap; font-family: var(--mono); font-size: 0.88rem; color: var(--text); }

/* The verb is a label, not the first word of the path, so it gets a tinted
   plate of its own. The sidebar keeps the bare .method text: at that size a
   plate on every row would be noise. */
.mchip {
  flex: none;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.16rem 0.45rem;
  border-radius: 4px;
  color: var(--other);
  background: color-mix(in srgb, var(--other) 14%, transparent);
}

.mchip-get { color: var(--get); background: color-mix(in srgb, var(--get) 14%, transparent); }
.mchip-post { color: var(--post); background: color-mix(in srgb, var(--post) 14%, transparent); }
.mchip-put { color: var(--put); background: color-mix(in srgb, var(--put) 14%, transparent); }
.mchip-patch { color: var(--patch); background: color-mix(in srgb, var(--patch) 14%, transparent); }
.mchip-delete { color: var(--delete); background: color-mix(in srgb, var(--delete) 14%, transparent); }

.method {
  flex: none;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--other);
}

.method-get { color: var(--get); }
.method-post { color: var(--post); }
.method-put { color: var(--put); }
.method-patch { color: var(--patch); }
.method-delete { color: var(--delete); }

/* A requirement should say how to satisfy it. "Requires apiKey" alone leaves
   the reader with the question they actually have, so the scheme's mechanism
   rides along. */
.authline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.7rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.authline svg { width: 0.85rem; height: 0.85rem; flex: none; color: var(--faint); }
.authline code {
  padding: 0.05rem 0.3rem;
  font-size: 0.78rem;
  background: var(--sunk);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
}
.authline .where { color: var(--faint); }

/* ---------- operation layout ---------- */

.op-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0 2.5rem;
  align-items: start;
}

/* the second column only exists when there is a payload to put in it */
.op.has-payload .op-split { grid-template-columns: minmax(0, 1fr) minmax(17rem, 23rem); }

.op-main { min-width: 0; }

.op-aside {
  position: sticky;
  top: calc(var(--topbar-h) + 1.25rem);
  min-width: 0;
}

/* below this the reference column cannot give up any more width, so the
   payload drops underneath it and stops trying to stay in view */
@media (max-width: 1360px) {
  .op.has-payload .op-split { grid-template-columns: minmax(0, 1fr); }
  .op-aside { position: static; margin-top: 1.75rem; max-width: 34rem; }
}

/* ---------- sections ---------- */

/* These are the page's landmarks and they used to be the faintest text on it,
   which inverted the hierarchy: a reader's eye landed on REQUIRED badges
   before it found the block boundaries. */
.sect { margin-top: 2.5rem; }

.sect > h4 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  padding-bottom: 0.5rem;
  margin-bottom: 0.25rem;
  border-bottom: 1px solid var(--line);
}

.chips { display: inline-flex; align-items: baseline; flex-wrap: wrap; gap: 0.45rem; }

.schema-chip {
  font-family: var(--mono);
  font-size: 0.73rem;
  font-weight: 400;
  padding: 0.08rem 0.4rem;
  color: var(--muted);
  background: var(--sunk);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  white-space: nowrap;
}

.usage { font-size: 0.73rem; font-weight: 400; color: var(--faint); }

/* Printed only when the body is not JSON, which is rare per operation but
   universal in the specs where it happens -- Stripe is entirely form-encoded.
   Warm, because it is the case a reader must not skim past. */
.mtype {
  font-family: var(--mono);
  font-size: 0.73rem;
  font-weight: 400;
  padding: 0.08rem 0.4rem;
  color: var(--put);
  background: color-mix(in srgb, var(--put) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--put) 30%, transparent);
  border-radius: 5px;
  white-space: nowrap;
}

/* ---------- fields ---------- */

/* Name in a fixed gutter with its type stacked beneath, everything else
   alongside. Names line up in one column the eye can run down, and a long
   description cannot push the next name out of alignment. */
.field, .node {
  display: grid;
  grid-template-columns: 13rem minmax(0, 1fr);
  gap: 0 1.5rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line-soft);
}

.fields > .field:last-child,
.fields > .node:last-child { border-bottom: none; }

.field-head, .node-key { min-width: 0; }

.field-name {
  font-family: var(--mono);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
}

.node-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
}

.field-head .type, .node-key .type { display: block; margin-top: 0.1rem; }

.type { font-family: var(--mono); font-size: 0.74rem; color: var(--muted); }

.field-body, .node-val { min-width: 0; font-size: 0.9rem; color: var(--muted); }
.field-body > :first-child, .node-val > :first-child { margin-top: 0; }

.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.2rem; }

/* Was REQUIRED in red on every row, which made the loudest thing on the page
   the one carrying the least information. */
.req-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  flex: none;
  border-radius: 50%;
  background: var(--delete);
  vertical-align: 0.25em;
}

.badge {
  font-size: 0.68rem;
  padding: 0 0.35rem;
  color: var(--muted);
  background: var(--sunk);
  border-radius: 4px;
}

.tag-deprecated {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--put);
}

/* ---------- schema tree ---------- */

.tree {
  margin-top: 0.6rem;
  padding-left: 0.85rem;
  border-left: 1px solid var(--line);
}

.tree .node { grid-template-columns: 10rem minmax(0, 1fr); gap: 0 1.25rem; padding: 0.55rem 0; }
.tree > .node:last-child { border-bottom: none; padding-bottom: 0; }

.fact {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem;
  margin-top: 0.3rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.fact-key {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
}

.fact code {
  padding: 0.05rem 0.3rem;
  background: var(--sunk);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
}

.note { margin: 0.35rem 0 0; font-size: 0.8rem; font-style: italic; color: var(--faint); }

.subtree > summary {
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.subtree > summary:hover { color: var(--accent); }
.subtree[open] > summary { margin-bottom: 0.1rem; }

/* ---------- responses ---------- */

/* Radios drive the tabs so this works with JavaScript off, matching the
   schema subtrees and the theme menu. They stay focusable -- visually hidden,
   not display:none -- so the tab strip is still keyboard reachable. */
.rtab {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.stabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0.9rem 0 0.2rem -0.55rem;
}

.stab {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.22rem 0.55rem;
  font-size: 0.82rem;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  user-select: none;
}

.stab:hover { background: var(--sunk); color: var(--text); }
.stab .n { font-family: var(--mono); font-size: 0.78rem; font-weight: 700; color: var(--muted); }
.stab.status-success .n { color: var(--get); }
.stab.status-redirect .n { color: var(--put); }
.stab.status-client-error .n, .stab.status-server-error .n { color: var(--delete); }

.rpanel { padding-top: 0.5rem; }
.resp-lead { margin-bottom: 0.4rem; }
.resp-code { font-family: var(--mono); font-weight: 700; font-size: 0.82rem; }

/* One response at a time. Everything below is mechanical: radio N reveals
   panel N in both columns. A browser without :has() shows every panel
   stacked, which is the old layout and still correct.

   Both selectors below are deliberately three classes deep, matching the
   reveal rules that follow: any heavier and hiding would outrank revealing on
   specificity and the panel could never come back. */
.op-split:has(.rtab) .rpanel,
.op-split:has(.rtab) .resp { display: none; }

.rt-0:checked ~ * .rp-0,
.rt-1:checked ~ * .rp-1,
.rt-2:checked ~ * .rp-2,
.rt-3:checked ~ * .rp-3,
.rt-4:checked ~ * .rp-4,
.rt-5:checked ~ * .rp-5,
.rt-6:checked ~ * .rp-6,
.rt-7:checked ~ * .rp-7,
.rt-8:checked ~ * .rp-8,
.rt-9:checked ~ * .rp-9,
.rt-10:checked ~ * .rp-10,
.rt-11:checked ~ * .rp-11 { display: block; }

.rt-0:checked ~ * .sl-0,
.rt-1:checked ~ * .sl-1,
.rt-2:checked ~ * .sl-2,
.rt-3:checked ~ * .sl-3,
.rt-4:checked ~ * .sl-4,
.rt-5:checked ~ * .sl-5,
.rt-6:checked ~ * .sl-6,
.rt-7:checked ~ * .sl-7,
.rt-8:checked ~ * .sl-8,
.rt-9:checked ~ * .sl-9,
.rt-10:checked ~ * .sl-10,
.rt-11:checked ~ * .sl-11 {
  background: var(--sunk);
  border-color: var(--line);
  color: var(--text);
}

.rt-0:focus-visible ~ * .sl-0,
.rt-1:focus-visible ~ * .sl-1,
.rt-2:focus-visible ~ * .sl-2,
.rt-3:focus-visible ~ * .sl-3,
.rt-4:focus-visible ~ * .sl-4,
.rt-5:focus-visible ~ * .sl-5,
.rt-6:focus-visible ~ * .sl-6,
.rt-7:focus-visible ~ * .sl-7,
.rt-8:focus-visible ~ * .sl-8,
.rt-9:focus-visible ~ * .sl-9,
.rt-10:focus-visible ~ * .sl-10,
.rt-11:focus-visible ~ * .sl-11 {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ---------- payload panel ---------- */

.op-aside .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 1rem;
}

/* left of the bar names the content, right of it would act on the content --
   the rule that keeps stray labels from collecting at the right edge */
.card-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.7rem;
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--sunk);
  border-bottom: 1px solid var(--line);
}

.card-bar .ident { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.card-bar code { font-size: 0.72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Wrapping beats a horizontal scrollbar in a column this narrow: these bodies
   carry long markup strings, and a reader should be able to see one without
   dragging. */
.payload {
  margin: 0;
  padding: 0.8rem;
  max-height: 26rem;
  overflow-y: auto;
  font-size: 0.74rem;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.payload .hdr { color: var(--faint); }

/* an invented example is labelled as invented; it is not the publisher's */
.synthetic {
  margin: 0;
  padding: 0.35rem 0.7rem;
  font-size: 0.7rem;
  color: var(--faint);
  background: var(--sunk);
  border-top: 1px solid var(--line-soft);
}

.status {
  flex: none;
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
  background: var(--bg);
  color: var(--muted);
}

.status-success { color: var(--get); }
.status-redirect { color: var(--put); }
.status-client-error { color: var(--delete); }
.status-server-error { color: var(--delete); }

/* ---------- prose ---------- */

.prose { margin-top: 0.4rem; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p { margin: 0.5rem 0; }
.prose.small { font-size: 0.88rem; color: var(--muted); }
.prose.inline { margin-top: 0; }
.prose.inline p { margin: 0; }
.prose code { padding: 0.05rem 0.3rem; background: var(--sunk); border-radius: 4px; }
.prose pre { padding: 0.7rem 0.85rem; overflow-x: auto; background: var(--sunk); border-radius: var(--radius); }
.prose pre code { padding: 0; background: none; }
.prose ul, .prose ol { margin: 0.5rem 0; padding-left: 1.25rem; }
.prose table { border-collapse: collapse; font-size: 0.88rem; }
.prose th, .prose td { padding: 0.3rem 0.6rem; border: 1px solid var(--line); text-align: left; }
.prose img { max-width: 100%; }

/* ---------- notices ---------- */

.notice { max-width: 34rem; margin: 5rem auto; padding: 0 1.5rem; }
.notice h1 { font-size: 1.3rem; margin-bottom: 0.5rem; }
.notice p { color: var(--muted); }

.details { margin-top: 1rem; font-size: 0.85rem; }
.details summary { cursor: pointer; color: var(--muted); }
.details ul { margin: 0.5rem 0 0; padding-left: 1.1rem; color: var(--muted); }
.details.warn summary { color: var(--put); }

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

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

  .sidebar {
    position: static;
    height: auto;
    max-height: 55vh;
    padding: 1rem 1.25rem;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .content { padding: 1.5rem 1.25rem 40vh; }

  /* the name gutter costs more than it returns once the description column
     drops under about 20rem, so names and descriptions stack instead */
  .field, .node, .tree .node {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.15rem 0;
  }

  .field-head .type, .node-key .type { display: inline; margin-top: 0; }

  .topbar { flex-wrap: wrap; height: auto; padding: 0.6rem 1.25rem; }
  /* drop the form to its own row, keeping the menu beside the brand */
  .topbar .urlform { order: 3; flex-basis: 100%; margin-left: 0; }
  .topbar .menu { margin-left: auto; }
  :root { --topbar-h: 0px; }
}
