/* ── Tokens: light is the bare :root so the un-stamped (system) state resolves ── */
:root {
  --ground:   #f6f8f7;
  --surface:  #ffffff;
  --surface-2:#eef2f0;
  --ink:      #14201e;
  --ink-2:    #354643;
  --muted:    #5a6b68;
  --line:     #dfe6e3;
  --line-2:   #c9d5d1;
  --accent:   #0b6e5e;
  --accent-ink:#ffffff;
  --accent-wash:#e4f0ec;
  --ok:       #1f7a4d;
  --ok-wash:  #e3f2e9;
  --warn:     #8a5710;
  --warn-wash:#f8eeda;
  --bad:      #a3342b;
  --bad-wash: #f8e6e3;
  --code-bg:  #121a19;
  --code-ink: #dbe7e3;
  --shadow:   0 1px 2px rgba(20,32,30,.05), 0 8px 24px -12px rgba(20,32,30,.18);

  --sans: "Source Sans 3", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Archivo", var(--sans);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground:   #0d1312;
    --surface:  #141c1b;
    --surface-2:#1a2423;
    --ink:      #e4edea;
    --ink-2:    #b8c8c4;
    --muted:    #8da09c;
    --line:     #24312f;
    --line-2:   #354441;
    --accent:   #48d2b6;
    --accent-ink:#062420;
    --accent-wash:#12302b;
    --ok:       #63c98d;
    --ok-wash:  #14301f;
    --warn:     #d9a44b;
    --warn-wash:#33280f;
    --bad:      #e88a7d;
    --bad-wash: #3a1d19;
    --code-bg:  #0a100f;
    --code-ink: #cfdedb;
    --shadow:   0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  --ground:   #0d1312;
  --surface:  #141c1b;
  --surface-2:#1a2423;
  --ink:      #e4edea;
  --ink-2:    #b8c8c4;
  --muted:    #8da09c;
  --line:     #24312f;
  --line-2:   #354441;
  --accent:   #48d2b6;
  --accent-ink:#062420;
  --accent-wash:#12302b;
  --ok:       #63c98d;
  --ok-wash:  #14301f;
  --warn:     #d9a44b;
  --warn-wash:#33280f;
  --bad:      #e88a7d;
  --bad-wash: #3a1d19;
  --code-bg:  #0a100f;
  --code-ink: #cfdedb;
  --shadow:   0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
}

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

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

/* ── Shell ───────────────────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: 0; max-width: 1180px; margin: 0 auto; }

.rail {
  position: sticky; top: 0; align-self: start; height: 100vh; overflow-y: auto;
  border-right: 1px solid var(--line); padding: 30px 24px 40px; background: var(--ground);
}
.brand { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.brand-mark {
  font-family: var(--display); font-weight: 700; font-size: 15px; letter-spacing: -.01em;
  color: var(--ink);
}
.brand-sub {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
}
.rail-version {
  display: inline-flex; align-items: center; gap: 6px; margin: 14px 0 22px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .04em;
  color: var(--accent); background: var(--accent-wash);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  border-radius: 999px; padding: 3px 10px;
}
.nav-group { margin-bottom: 20px; }
.nav-label {
  font-family: var(--mono); font-size: 10px; letter-spacing: .13em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 8px; padding-left: 11px;
}
.rail a {
  display: block; padding: 4px 11px; margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--ink-2); text-decoration: none; font-size: 14.5px; line-height: 1.45;
  transition: color .12s ease, border-color .12s ease;
}
.rail a:hover { color: var(--accent); }
.rail a.is-active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.rail a code {
  font-family: var(--mono); font-size: 12.5px; background: none; padding: 0; color: inherit; border: 0;
}

main { padding: 46px 52px 120px; min-width: 0; }

/* ── Masthead ────────────────────────────────────────────────────────── */
.masthead { border-bottom: 1px solid var(--line); padding-bottom: 30px; margin-bottom: 38px; }
h1 {
  font-family: var(--display); font-weight: 700; font-size: clamp(30px, 4.4vw, 40px);
  line-height: 1.1; letter-spacing: -.022em; margin: 0 0 12px; text-wrap: balance;
}
.lede { font-size: 18px; color: var(--ink-2); max-width: 62ch; margin: 0 0 4px; }

/* Environment strip — reads like a manifest header, and the values are the
   two things a partner actually needs before writing any code. */
.envs {
  margin-top: 26px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); overflow: hidden; box-shadow: var(--shadow);
}
.env {
  display: grid; grid-template-columns: 96px minmax(0,1fr) auto; align-items: center; gap: 16px;
  padding: 13px 18px;
}
.env + .env { border-top: 1px solid var(--line); }
.env-name {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
}
.env-url { font-family: var(--mono); font-size: 13.5px; color: var(--ink); overflow-wrap: anywhere; }
.env-note { font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ── Type ────────────────────────────────────────────────────────────── */
h2 {
  font-family: var(--display); font-weight: 600; font-size: 25px; letter-spacing: -.015em;
  margin: 58px 0 14px; padding-top: 10px; text-wrap: balance;
}
h3 {
  font-family: var(--display); font-weight: 600; font-size: 17.5px; letter-spacing: -.008em;
  margin: 34px 0 10px;
}
p { margin: 0 0 15px; max-width: 68ch; }
main a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
strong { font-weight: 600; color: var(--ink); }
ul { max-width: 68ch; padding-left: 20px; margin: 0 0 15px; }
li { margin-bottom: 5px; }

/* Inline code: tinted, not boxed-in-grey, so it sits in the sentence. */
code {
  font-family: var(--mono); font-size: .875em;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 4px; padding: .08em .34em; overflow-wrap: anywhere;
}

/* ── Endpoint headers ────────────────────────────────────────────────── */
.endpoint {
  display: flex; align-items: center; gap: 11px; flex-wrap: wrap;
  margin: 58px 0 16px; padding: 13px 16px;
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 8px; background: var(--surface); box-shadow: var(--shadow);
}
.endpoint h2 { margin: 0; padding: 0; font-size: 0; }
.method {
  font-family: var(--mono); font-weight: 600; font-size: 11.5px; letter-spacing: .07em;
  background: var(--accent); color: var(--accent-ink);
  border-radius: 4px; padding: 3px 8px;
}
.path { font-family: var(--mono); font-size: 15px; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.scope {
  margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--muted);
  border: 1px dashed var(--line-2); border-radius: 999px; padding: 2px 9px; white-space: nowrap;
}

/* ── Tables ──────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin: 0 0 20px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
th, td { text-align: left; padding: 9px 15px; border-bottom: 1px solid var(--line); vertical-align: top; }
th {
  font-family: var(--mono); font-weight: 600; font-size: 10.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted); background: var(--surface-2); white-space: nowrap;
}
tr:last-child td { border-bottom: 0; }
td:first-child { white-space: nowrap; }
td code { background: none; border: 0; padding: 0; color: var(--ink); }
.num { font-variant-numeric: tabular-nums; }

/* Status pills — semantic colour, deliberately not the accent hue. */
.st { font-family: var(--mono); font-weight: 600; font-size: 12px; border-radius: 4px; padding: 2px 7px; }
.st-ok   { background: var(--ok-wash);   color: var(--ok); }
.st-warn { background: var(--warn-wash); color: var(--warn); }
.st-bad  { background: var(--bad-wash);  color: var(--bad); }

/* ── Code blocks ─────────────────────────────────────────────────────── */
.code {
  position: relative; margin: 0 0 20px;
  background: var(--code-bg); border: 1px solid var(--line); border-radius: 9px; overflow: hidden;
}
.code-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 7px 12px 7px 15px; border-bottom: 1px solid rgba(255,255,255,.07);
}
.code-lang {
  font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: #7f938e;
}
.copy {
  font-family: var(--mono); font-size: 11px; color: #9fb3ae; cursor: pointer;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1);
  border-radius: 5px; padding: 3px 9px; transition: background .12s ease, color .12s ease;
}
.copy:hover { background: rgba(255,255,255,.12); color: #d7e5e1; }
.copy.copied { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.code pre {
  margin: 0; padding: 14px 15px; overflow-x: auto;
  font-family: var(--mono); font-size: 13px; line-height: 1.62; color: var(--code-ink);
}
/* The inline-code rule above paints a LIGHT chip background, which is right
   in a sentence and catastrophic inside a dark <pre> — light text on a light
   chip is invisible. Reset every inherited box property here so a block's
   <code> is purely a semantic wrapper. */
.code pre code {
  background: none; border: 0; border-radius: 0; padding: 0;
  font-size: inherit; color: inherit;
}
.tok-key { color: #7fd3bd; }
.tok-str { color: #d8c48a; }
.tok-num { color: #9fc4e8; }
.tok-com { color: #6b7f7a; }

/* ── Callouts ────────────────────────────────────────────────────────── */
.note {
  border: 1px solid var(--line); border-left: 3px solid var(--muted);
  background: var(--surface); border-radius: 8px; padding: 13px 17px; margin: 0 0 20px; max-width: 68ch;
}
.note p:last-child { margin-bottom: 0; }
.note-warn { border-left-color: var(--warn); background: var(--warn-wash); }
.note-warn code { background: rgba(255,255,255,.35); }
.note-key { font-family: var(--mono); font-size: 10.5px; letter-spacing: .11em; text-transform: uppercase; color: var(--muted); display: block; margin-bottom: 5px; }

hr { border: 0; border-top: 1px solid var(--line); margin: 54px 0 0; }

footer { margin-top: 40px; color: var(--muted); font-size: 14px; }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line);
    padding: 22px 24px 18px;
  }
  .rail nav { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0 18px; }
  main { padding: 32px 24px 90px; }
  .env { grid-template-columns: 1fr; gap: 3px; }
  .env-note { white-space: normal; }
  .scope { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
html { scroll-behavior: smooth; }
[id] { scroll-margin-top: 22px; }

/* ── Sidebar nesting ──────────────────────────────────────────────────────
   Generated nav is flat; the heading level is what conveys nesting, so the
   indent is derived from it rather than hand-placed. */
.rail a.lvl-3 { padding-left: 24px; font-size: 13.5px; color: var(--muted); }
.rail a.lvl-3:hover, .rail a.lvl-3.is-active { color: var(--accent); }

/* Markdown emits <hr> between sections; the headings already separate them,
   so these would just add noise at generated density. */
main hr { display: none; }

/* marked wraps loose list items in <p>; without this every bullet gains a
   paragraph's bottom margin and the list falls apart. */
li > p { margin: 0 0 4px; }
li > p:last-child { margin-bottom: 0; }


/* ── Language tabs ────────────────────────────────────────────────────────
   One request shown seven ways. The strip lives in the code block's own
   header so it reads as part of the block rather than a control floating
   above it. */
.code-tabbed .code-head { padding-left: 6px; gap: 8px; }

.lang-tabs {
  display: flex; align-items: center; gap: 2px;
  overflow-x: auto; scrollbar-width: none; min-width: 0;
}
.lang-tabs::-webkit-scrollbar { display: none; }

.lang-tab {
  flex: 0 0 auto;
  font-family: var(--mono); font-size: 11px; letter-spacing: .02em;
  color: #7f938e; background: none; border: 0; border-radius: 5px;
  padding: 4px 9px; cursor: pointer; white-space: nowrap;
  transition: color .12s ease, background .12s ease;
}
.lang-tab:hover { color: #cfdedb; background: rgba(255,255,255,.06); }
.lang-tab.is-active { color: var(--code-bg); background: var(--accent); font-weight: 600; }
/* The strip sits on the dark code header in both themes, so its focus ring
   is defined against that surface rather than the page ground. */
.lang-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.lang-panel { margin: 0; }

/* ── Masthead actions ─────────────────────────────────────────────────── */
.masthead-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 20px; }

.btn-download {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--sans); font-size: 14px; font-weight: 600;
  color: var(--accent-ink); background: var(--accent);
  border: 1px solid var(--accent); border-radius: 8px;
  padding: 8px 14px; text-decoration: none; cursor: pointer;
  transition: filter .12s ease;
}
.btn-download:hover { filter: brightness(1.08); }
.masthead-hint { font-size: 13px; color: var(--muted); }
.masthead-hint code { font-size: 12px; }
