:root {
  --bg: #fbfbfd;
  --surface: #ffffff;
  --surface-alt: #f4f5f8;
  --text: #14161a;
  --muted: #61656e;
  --border: #e3e6ec;
  --accent: #2f6feb;
  --accent-soft: #e8f0fe;
  --green: #1a7f47;
  --green-soft: #e4f5ea;
  --amber: #9a6400;
  --amber-soft: #fdf0d8;
  --red: #c0392b;
  --code-bg: #f6f7f9;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --surface: #151a21;
    --surface-alt: #1b212a;
    --text: #e6e9ef;
    --muted: #9aa2ae;
    --border: #262d36;
    --accent: #589bff;
    --accent-soft: #16243c;
    --green: #56d364;
    --green-soft: #12261a;
    --amber: #e3b341;
    --amber-soft: #2b2313;
    --red: #f85149;
    --code-bg: #10151c;
  }
}

* { box-sizing: border-box; }

html {
  /* Stop iOS inflating text in landscape. */
  -webkit-text-size-adjust: 100%;
}

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: 13px; }

pre {
  margin: 0;
  padding: 16px;
  background: var(--code-bg);
  overflow-x: auto;
  line-height: 1.55;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px; }

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }

.brand-mark {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 7px;
  padding: 3px 8px;
  font-size: 14px;
}

.brand-name { font-weight: 650; letter-spacing: -0.01em; }

.topbar-meta { display: flex; gap: 8px; align-items: center; }

.chip {
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 11px;
  white-space: nowrap;
}

.chip-link { color: var(--accent); }
.chip-link:hover { text-decoration: none; border-color: var(--accent); }

/* ---------- hero ---------- */

.hero { padding: 64px 0 48px; border-bottom: 1px solid var(--border); }

.hero h1 {
  margin: 0 0 16px;
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1.12;
  letter-spacing: -0.028em;
  font-weight: 680;
}

.lede {
  margin: 0 0 32px;
  max-width: 62ch;
  font-size: 17px;
  color: var(--muted);
}

.lede strong { color: var(--text); font-weight: 600; }

.quickstart {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  max-width: 720px;
}

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}

.facts {
  list-style: none;
  margin: 32px 0 0;
  padding: 0;
  display: grid;
  gap: 20px 32px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  max-width: 900px;
}

/* Not a flex column: these items mix text and <code>, and flex would make an
   anonymous item of every text node, breaking one sentence onto three lines. */
.facts li { font-size: 13.5px; color: var(--muted); line-height: 1.5; }

.facts strong {
  display: block;
  margin-bottom: 3px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text);
}

.facts code { font-size: 12.5px; word-break: break-all; }

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

.layout {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 48px;
  align-items: start;
  padding-top: 48px;
  padding-bottom: 80px;
}

.sidenav { position: sticky; top: 90px; max-height: calc(100vh - 120px); overflow-y: auto; }
.nav-group { margin-bottom: 22px; }

.nav-title {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 7px;
  font-weight: 600;
}

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

.sidenav a {
  display: block;
  padding: 4px 10px;
  border-radius: 6px;
  color: var(--muted);
  border-left: 2px solid transparent;
}

.sidenav a:hover { background: var(--surface-alt); color: var(--text); text-decoration: none; }
.sidenav a.active { color: var(--accent); border-left-color: var(--accent); background: var(--accent-soft); }
.nav-path { font-family: var(--mono); font-size: 12px; }

/* ---------- endpoints ---------- */

.group { margin-bottom: 56px; scroll-margin-top: 80px; }

.group h2 {
  margin: 0 0 20px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  font-weight: 650;
}

.endpoint {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
  scroll-margin-top: 80px;
}

.endpoint-head { padding: 20px 20px 16px; }

.route { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }

.method {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 5px;
}

.method-get { color: var(--green); background: var(--green-soft); }
.method-post { color: var(--amber); background: var(--amber-soft); }

.path { font-size: 14.5px; font-weight: 600; word-break: break-all; }

.summary { margin: 0; font-weight: 550; }
.description { margin: 8px 0 0; color: var(--muted); font-size: 14px; max-width: 72ch; }

.params { border-top: 1px solid var(--border); overflow-x: auto; }

.params table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.params th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  padding: 10px 20px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.params td { padding: 11px 20px; border-bottom: 1px solid var(--border); vertical-align: top; }
.params tr:last-child td { border-bottom: none; }
.params .type { color: var(--muted); font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }

.tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 5px;
  vertical-align: middle;
}

.tag-req { color: var(--red); border-color: currentColor; }
.default { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.params input {
  width: 100%;
  min-width: 120px;
  padding: 6px 9px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

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

/* ---------- request body ---------- */

.body-field { padding: 14px 20px 0; border-top: 1px solid var(--border); }

.body-field label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 6px;
}

.body-hint {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  font-family: var(--mono);
  font-size: 11px;
  margin-left: 6px;
}

.request-body {
  display: block;
  width: 100%;
  padding: 9px 11px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  resize: vertical;
}

.request-body:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

/* ---------- actions ---------- */

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
}

button {
  font-family: inherit;
  font-size: 13px;
  font-weight: 550;
  padding: 6px 14px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

button:hover { border-color: var(--accent); color: var(--accent); }

.run { background: var(--accent); border-color: var(--accent); color: #fff; }
.run:hover { color: #fff; filter: brightness(1.08); }
.run[disabled] { opacity: 0.6; cursor: progress; }

.copy { font-size: 11px; padding: 3px 9px; border-radius: 5px; }

.request-url {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
  flex: 1 1 240px;
}

.result { border-top: 1px solid var(--border); }
.result-label { font-weight: 600; }

.result-status { font-family: var(--mono); font-size: 12px; }
.result-status.ok { color: var(--green); }
.result-status.err { color: var(--red); }

.result-body { display: block; white-space: pre; }

.result-image {
  display: flex;
  justify-content: center;
  padding: 20px;
  background: var(--code-bg);
  /* A light chequerboard so transparent PNGs and SVGs read correctly. */
  background-image:
    linear-gradient(45deg, var(--border) 25%, transparent 25%),
    linear-gradient(-45deg, var(--border) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--border) 75%),
    linear-gradient(-45deg, transparent 75%, var(--border) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.result-image img { max-width: 100%; height: auto; }

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

.footer {
  border-top: 1px solid var(--border);
  padding: 32px 0 56px;
  color: var(--muted);
  font-size: 13px;
}

.footer p { margin: 0 0 8px; }
.attribution { font-size: 12px; }

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

/* Tablet and below: one column, and the endpoint index becomes a strip.
   minmax(0, 1fr) is load-bearing — a bare 1fr takes its minimum size from
   content, so a single wide table stretches the column and scrolls the whole
   page sideways. */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding-top: 0;
    padding-bottom: 56px;
  }

  /* Stacking 61 endpoint links would push the first card most of a screen
     down the page. Show group links only, as a scrollable strip that stays
     put under the header. */
  .sidenav {
    position: sticky;
    top: 57px;
    z-index: 10;
    display: flex;
    gap: 8px;
    max-height: none;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin: 0 -24px;
    padding: 10px 24px;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
  }

  .sidenav::-webkit-scrollbar { display: none; }
  .nav-group { margin: 0; }
  .nav-group ul { display: none; }

  .nav-title {
    display: flex;
    align-items: center;
    min-height: 40px;
    margin: 0;
    padding: 0 14px;
    white-space: nowrap;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-size: 12.5px;
    font-weight: 550;
    text-transform: none;
    letter-spacing: 0;
  }

  .nav-title:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }

  main { padding-top: 28px; }
  .group { scroll-margin-top: 108px; }
  .endpoint { scroll-margin-top: 108px; }
  .hero { padding: 44px 0 36px; }
}

/* Phones. The parameter table is the main offender: four columns, nowrap
   cells and a min-width input cannot fit, so it becomes a stack of labelled
   fields instead of something to scroll sideways. */
@media (max-width: 700px) {
  .wrap { padding: 0 16px; }
  .sidenav { margin: 0 -16px; padding: 10px 16px; }

  .hero { padding: 32px 0 28px; }
  .lede { font-size: 16px; margin-bottom: 24px; }
  .facts { gap: 16px 20px; margin-top: 24px; }

  .endpoint-head { padding: 16px 16px 14px; }
  .actions { padding: 12px 16px; }
  .body-field { padding: 12px 16px 0; }
  pre { padding: 14px 16px; }
  .code-head { padding: 9px 16px; }

  /* The quick-start command wraps rather than scrolls: it is one line people
     need to read in full, unlike a JSON body where wrapping destroys the
     indentation that makes it readable. */
  .quickstart pre { white-space: pre-wrap; overflow-wrap: anywhere; }

  .params { overflow-x: visible; }
  .params thead { display: none; }
  .params table, .params tbody, .params tr, .params td { display: block; width: 100%; }

  .params tr { padding: 14px 16px; border-bottom: 1px solid var(--border); }
  .params tr:last-child { border-bottom: none; }
  .params td { padding: 0; border: none; }
  .params td + td { margin-top: 10px; }

  .params td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
  }

  /* The parameter name heads its own card, so a label above it is noise. */
  .params td:first-child::before { display: none; }
  .params td:first-child code { font-size: 14px; font-weight: 600; }
  .params .type { white-space: normal; }

  /* 16px exactly: iOS Safari zooms the viewport when a focused field is
     smaller, which leaves the page scrolled off-centre. */
  .params input,
  .request-body {
    width: 100%;
    min-width: 0;
    padding: 10px 12px;
    font-size: 16px;
  }

  /* Comfortable touch targets. */
  button { min-height: 44px; padding: 10px 18px; font-size: 14px; }
  .copy { min-height: 40px; padding: 8px 14px; font-size: 12px; }
  .actions .run, .actions .copy-curl { flex: 1 1 auto; }
  .request-url { flex: 1 1 100%; order: 3; }

  .chip { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; }
  .topbar-meta { gap: 6px; }
  .topbar-meta .chip:not(.chip-link) { display: none; }

  .footer { padding: 24px 0 40px; }
}

/* Very small phones: drop the endpoint-count chip and tighten type further. */
@media (max-width: 380px) {
  .wrap { padding: 0 12px; }
  .sidenav { margin: 0 -12px; padding: 10px 12px; }
  .brand-name { font-size: 14px; }
  .path { font-size: 13px; }
  code, pre { font-size: 12px; }
}
