/* =============================================================================
   CrawlHQ — API Reference design system (shared)
   Powers the API hub (/docs/api) and every scraper reference
   (/docs/<id>/api/references). Bespoke, dependency-free, theme-aware.
   ========================================================================== */

/* ---------------------------------------------------------------- tokens -- */
:root {
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  --topbar-h: 60px;
  --sidebar-w: 300px;
  --content-max: 1160px;
  --shell-max: 1600px;

  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-pill: 999px;

  --sp: 4px;
  --ease: cubic-bezier(.4, 0, .2, 1);
  --t-fast: .12s var(--ease);
  --t: .2s var(--ease);

  --brand-1: #1d9bf0;
  --brand-2: #7c5cff;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f7fb;
  --bg-grad-1: #eef3fb;
  --bg-grad-2: #f7f5ff;
  --panel: #ffffff;
  --panel-2: #f7f9fc;
  --panel-3: #eef2f8;
  --ink: #0e1726;
  --ink-2: #45566f;
  --ink-3: #74849c;
  --border: #e4e9f1;
  --border-2: #eef1f7;
  --border-strong: #d4dce8;

  --accent: #1877d4;
  --accent-2: #7c5cff;
  --accent-ink: #0f5fb0;
  --accent-soft: #e9f2fe;
  --accent-ring: rgba(24, 119, 212, .22);

  --shadow-sm: 0 1px 2px rgba(16, 30, 54, .06);
  --shadow: 0 2px 8px rgba(16, 30, 54, .06), 0 1px 2px rgba(16, 30, 54, .05);
  --shadow-lg: 0 16px 40px -12px rgba(16, 30, 54, .22);
  --shadow-pop: 0 8px 28px -6px rgba(16, 30, 54, .2);

  /* code surface */
  --code-bg: #f4f7fb;
  --code-head: #eef2f8;
  --code-ink: #26324a;
  --code-border: #e2e8f2;
  --tok-key: #1a56c4;
  --tok-str: #0a7d40;
  --tok-num: #b4571d;
  --tok-bool: #7c3aed;
  --tok-punc: #6b7a92;
  --tok-kw: #c0357a;
  --tok-fn: #0f6fc7;

  --ok: #1a7f37;
  --warn: #9a6700;
  --err: #cf222e;
  --scrollthumb: #cdd6e4;
}

html[data-theme="dark"] {
  color-scheme: dark;
  /* Premium "soft dark" — a lifted slate canvas with clear elevation steps
     (panels sit above the canvas), not a flat near-black. */
  --bg: #0f141c;
  --bg-grad-1: #141b27;
  --bg-grad-2: #171526;
  --panel: #181f2b;
  --panel-2: #1e2633;
  --panel-3: #26303f;
  --ink: #e9eef6;
  --ink-2: #b2bed0;
  --ink-3: #8390a6;
  --border: #2b3546;
  --border-2: #232c3a;
  --border-strong: #3b485c;

  --accent: #5aa9ff;
  --accent-2: #a78bfa;
  --accent-ink: #93c2ff;
  --accent-soft: #17294a;
  --accent-ring: rgba(90, 169, 255, .30);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow: 0 4px 16px -4px rgba(0, 0, 0, .5);
  --shadow-lg: 0 20px 48px -16px rgba(0, 0, 0, .65);
  --shadow-pop: 0 10px 30px -6px rgba(0, 0, 0, .55);

  --code-bg: #121925;
  --code-head: #1a222f;
  --code-ink: #cfd9ea;
  --code-border: #2a3444;
  --tok-key: #79c0ff;
  --tok-str: #7ee787;
  --tok-num: #f0a45b;
  --tok-bool: #d2a8ff;
  --tok-punc: #8b98ac;
  --tok-kw: #ff7bbf;
  --tok-fn: #79c0ff;

  --ok: #3fb950;
  --warn: #d29922;
  --err: #f85149;
  --scrollthumb: #384457;
}

/* method palette (both themes read these) */
html[data-theme="light"] {
  --m-get: #1a7f37;      --m-get-bg: #e7f6ec;
  --m-post: #1868db;     --m-post-bg: #e8f0fe;
  --m-put: #9a6700;      --m-put-bg: #fbf1dc;
  --m-patch: #7c3aed;    --m-patch-bg: #f1eafe;
  --m-delete: #cf222e;   --m-delete-bg: #fdeceb;
}
html[data-theme="dark"] {
  --m-get: #3fb950;      --m-get-bg: #102217;
  --m-post: #58a6ff;     --m-post-bg: #10233f;
  --m-put: #d29922;      --m-put-bg: #29230f;
  --m-patch: #d2a8ff;    --m-patch-bg: #221a38;
  --m-delete: #f85149;   --m-delete-bg: #2c1518;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-h) + 20px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg); /* flat, calm field — no competing gradient blobs */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

::selection { background: var(--accent-ring); }

:where(button, a, input, textarea, select, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

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

.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: 200;
  background: var(--accent); color: #fff; padding: 9px 15px; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 600; transform: translateY(-160%); transition: transform var(--t);
}
.skip-link:focus { transform: translateY(0); text-decoration: none; }

/* custom scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--scrollthumb) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--scrollthumb); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------------- topbar -- */
.topbar {
  position: sticky; top: 0; z-index: 60;
  height: var(--topbar-h);
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--shell-max); margin: 0 auto; height: 100%;
  padding: 0 22px; display: flex; align-items: center; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; flex-shrink: 0; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  color: #fff; font-weight: 800; font-size: 17px; letter-spacing: -.02em;
  box-shadow: 0 4px 12px -2px rgba(29, 155, 240, .5);
}
.brand-name { font-weight: 800; font-size: 17px; letter-spacing: -.02em; line-height: 1; }
.brand-name b { background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.brand-sub {
  font-size: 12px; font-weight: 600; color: var(--ink-3); padding-left: 12px; margin-left: 2px;
  border-left: 1px solid var(--border-strong); line-height: 1;
}

.topbar-tags { display: flex; align-items: center; gap: 7px; }
.tag {
  font-size: 11px; font-weight: 600; color: var(--ink-2); line-height: 1;
  border: 1px solid var(--border); border-radius: var(--r-pill); padding: 5px 11px; white-space: nowrap;
  background: var(--panel-2);
}

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topbar-actions .nav-link {
  color: var(--ink-2); font-size: 13.5px; font-weight: 600; padding: 7px 10px; border-radius: var(--r-sm);
  white-space: nowrap; transition: color var(--t-fast), background var(--t-fast);
}
.topbar-actions .nav-link:hover { color: var(--ink); background: var(--panel-2); text-decoration: none; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: inherit; font-size: 13.5px; font-weight: 600; line-height: 1;
  padding: 9px 15px; border-radius: var(--r-sm); border: 1px solid transparent; cursor: pointer;
  white-space: nowrap; transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 4px 14px -4px var(--accent-ring); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: var(--panel-2); color: var(--ink-2); border-color: var(--border); }
.btn-ghost:hover { background: var(--panel-3); color: var(--ink); }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--panel-2);
  color: var(--ink-2); cursor: pointer; transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.icon-btn:hover { background: var(--panel-3); color: var(--ink); border-color: var(--border-strong); }
.icon-btn svg { width: 18px; height: 18px; }

/* Action group. A divider fences the in-page ACTION (Authorize) off from the
   "navigate elsewhere" links, so the row reads as two groups, not one line of
   look-alike chips. Authorize is a filled pill with a LOCK ICON — its role and its
   locked/unlocked state read by shape + icon, not colour alone (ADHD / colour-blind
   friendly). This is the ONE definition; pages don't restyle it inline. */
.topbar-divider { width: 1px; height: 22px; flex-shrink: 0; background: var(--border-strong); margin: 0 5px; }
.topbar-auth {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: inherit; font-size: 13.5px; font-weight: 600; line-height: 1;
  padding: 9px 15px; border-radius: var(--r-sm); border: 1px solid var(--accent);
  background: var(--accent); color: #fff; cursor: pointer; white-space: nowrap;
  box-shadow: 0 4px 14px -4px var(--accent-ring);
  transition: background var(--t-fast), border-color var(--t-fast), filter var(--t-fast), transform var(--t-fast);
}
.topbar-auth svg { width: 15px; height: 15px; }
.topbar-auth:hover { filter: brightness(1.06); }
.topbar-auth:active { transform: translateY(1px); }
/* Secondary form — quieter outline pill when the page already has a primary CTA. */
.topbar-auth.is-ghost { background: var(--panel-2); color: var(--ink); border-color: var(--border-strong); box-shadow: none; }
.topbar-auth.is-ghost:hover { background: var(--panel-3); filter: none; }
/* Authorized: the hasp opens (icon) AND the pill turns green (colour) — two signals. */
.topbar-auth.is-authed { background: var(--ok); border-color: var(--ok); color: #fff; box-shadow: none; }
.topbar-auth.is-ghost.is-authed { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); border-color: var(--ok); }
/* Key saved → the pill shows the PARTIAL KEY (mono) instead of a word, with a copy
   button beside it: see the key, copy the key, click the pill to change it. */
.topbar-auth .tb-key { font-family: var(--font-mono); font-size: 12.5px; }
.topbar-key-copy {
  display: inline-grid; place-items: center; width: 35px; height: 35px; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--panel-2);
  color: var(--ink-2); cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.topbar-key-copy:hover { background: var(--panel-3); color: var(--ink); border-color: var(--border-strong); }
.topbar-key-copy svg { width: 15px; height: 15px; }
.topbar-key-copy[hidden] { display: none; }

/* Caret shows only on the authorized (key) pill — signals the manage-key menu. */
.topbar-auth .tb-caret { width: 13px; height: 13px; margin-left: -1px; opacity: .6; transition: transform var(--t-fast); }
.topbar-auth:not(.is-authed) .tb-caret { display: none; }
.topbar-auth[aria-expanded="true"] .tb-caret { transform: rotate(180deg); }

/* Manage-key popover (Copy / Replace / Delete), fixed-positioned under the pill in JS. */
.topbar-key-menu {
  position: fixed; z-index: 120; min-width: 178px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-pop); padding: 5px;
}
.topbar-key-menu[hidden] { display: none; }
.topbar-key-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 0; background: none; border-radius: var(--r-sm);
  font-family: inherit; font-size: 13px; font-weight: 600; color: var(--ink-2);
  text-align: left; cursor: pointer; transition: background var(--t-fast), color var(--t-fast);
}
.topbar-key-menu button svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--ink-3); }
.topbar-key-menu button:hover { background: var(--panel-2); color: var(--ink); }
.topbar-key-menu button:hover svg { color: var(--ink-2); }
.topbar-key-menu button.is-danger:hover { background: color-mix(in srgb, var(--err) 12%, transparent); color: var(--err); }
.topbar-key-menu button.is-danger:hover svg { color: var(--err); }
html[data-theme="dark"] .icon-sun, html[data-theme="light"] .icon-moon { display: none; }

.menu-btn { display: none; }

/* --------------------------------------------------------------- layout --- */
.shell { max-width: var(--shell-max); margin: 0 auto; display: flex; align-items: flex-start; }

/* sidebar */
.sidebar {
  position: sticky; top: var(--topbar-h);
  width: var(--sidebar-w); flex-shrink: 0;
  height: calc(100vh - var(--topbar-h));
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel) 40%, transparent);
}
.sidebar-head { padding: 16px 16px 12px; flex-shrink: 0; }

.search {
  position: relative; display: flex; align-items: center;
}
.search svg.search-ico { position: absolute; left: 11px; width: 16px; height: 16px; color: var(--ink-3); pointer-events: none; }
.search input {
  width: 100%; font-family: inherit; font-size: 13.5px; color: var(--ink);
  padding: 9px 30px 9px 34px; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--panel); outline: none; transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.search input::placeholder { color: var(--ink-3); }
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.search .kbd {
  position: absolute; right: 8px; font-size: 10.5px; font-weight: 600; color: var(--ink-3);
  border: 1px solid var(--border); border-radius: 5px; padding: 2px 6px; background: var(--panel-2); pointer-events: none;
}
.search .clear-search {
  position: absolute; right: 7px; display: none; place-items: center; width: 22px; height: 22px;
  border: 0; background: transparent; color: var(--ink-3); cursor: pointer; border-radius: 5px;
}
.search .clear-search:hover { color: var(--ink); background: var(--panel-2); }
.search.has-value .kbd { display: none; }
.search.has-value .clear-search { display: grid; }

.sidebar-nav { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 4px 10px 40px; }

.nav-category { margin: 14px 0 6px; }
.nav-category:first-child { margin-top: 4px; }
.nav-category.hidden { display: none; }
.nav-category-label {
  padding: 6px 10px 4px;
  font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-3); opacity: .85;
}
.nav-group { margin-bottom: 2px; }
.nav-group-btn {
  width: 100%; display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 8px 10px; border: 0; background: transparent; color: var(--ink-3);
  font-family: inherit; font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  border-radius: var(--r-sm); transition: color var(--t-fast), background var(--t-fast);
}
.nav-group-btn:hover { color: var(--ink-2); background: var(--panel-2); }
.nav-group-btn .chev { margin-left: auto; width: 14px; height: 14px; transition: transform var(--t); color: var(--ink-3); }
.nav-group.collapsed .chev { transform: rotate(-90deg); }
.nav-group-items { display: grid; grid-template-rows: 1fr; transition: grid-template-rows var(--t); }
.nav-group.collapsed .nav-group-items { grid-template-rows: 0fr; }
.nav-group-items > div { overflow: hidden; min-height: 0; }

.nav-link-item {
  position: relative; display: flex; align-items: center; gap: 8px;
  padding: 6px 10px 6px 12px; margin: 1px 0; border-radius: var(--r-sm);
  font-size: 13.5px; color: var(--ink-2); text-decoration: none; line-height: 1.35;
  transition: color var(--t-fast), background var(--t-fast);
}
.nav-link-item:hover { color: var(--ink); background: var(--panel-2); text-decoration: none; }
.nav-link-item.active { color: var(--accent-ink); background: var(--accent-soft); font-weight: 600; }
.nav-link-item.active::before {
  content: ""; position: absolute; left: -10px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 17px; border-radius: 3px; background: var(--accent);
}
.nav-link-item.hidden, .nav-group.hidden { display: none; }
.nav-method {
  font-family: var(--font-mono); font-size: 9px; font-weight: 700; letter-spacing: .02em;
  padding: 2px 4px; border-radius: 4px; flex-shrink: 0; min-width: 34px; text-align: center; line-height: 1.3;
}
/* one calm neutral badge for every method — the GET/POST label still reads,
   without 40+ competing colours down the rail */
.nav-method.get, .nav-method.post, .nav-method.put,
.nav-method.patch, .nav-method.delete { color: var(--ink-3); background: var(--panel-3); }
.nav-method.doc { color: var(--ink-3); background: var(--panel-3); font-size: 8px; }
.nav-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Admin / ops endpoints stay hidden until an admin (write-scope) key is authorized. */
html:not([data-scope="write"]) .nav-link-item[data-admin="1"] { display: none !important; }
html:not([data-scope="write"]) .opblock.is-admin { display: none !important; }
/* Hide tag groups / categories that only contained admin ops (now empty). */
html:not([data-scope="write"]) .nav-group:not(:has(.nav-link-item:not([data-admin="1"]))) { display: none; }
html:not([data-scope="write"]) .nav-category:not(:has(.nav-link-item:not([data-admin="1"]))) { display: none; }
/* admin-key-only endpoints: compact red pill on the right of the nav row */
.nav-admin {
  margin-left: auto; flex-shrink: 0;
  font-size: 8.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; line-height: 1.5;
  color: var(--err); background: color-mix(in srgb, var(--err) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--err) 32%, transparent);
  padding: 1px 5px; border-radius: var(--r-pill);
}
/* admin key authorized → drop the sidebar ADMIN pill */
html[data-scope="write"] .nav-admin { display: none; }
.nav-empty { padding: 20px 12px; font-size: 13px; color: var(--ink-3); text-align: center; display: none; }

/* --------------------------------------------------------------- content -- */
.main { flex: 1; min-width: 0; }

/* universal access notice — permanent, shown to non-admin visitors only.
   Aligns with the swagger content column (matches #swagger-ui padding).
   Hidden once an admin (write-scope) key is authorized. */
.access-note-wrap { max-width: var(--content-max); margin: 0 auto; padding: 22px 44px 0; }
html[data-scope="write"] .access-note-wrap { display: none; }
.access-note {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 15px; border-radius: var(--r-md);
  font-size: 13px; line-height: 1.5; color: var(--ink-2);
  background: color-mix(in srgb, var(--warn) 11%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--warn) 34%, var(--border));
}
.access-note svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--warn); }
.access-note b { color: var(--ink); font-weight: 700; }
.access-note code {
  font-family: var(--font-mono); font-size: .84em; padding: 1px 5px;
  border-radius: var(--r-xs); color: var(--ink);
  background: color-mix(in srgb, var(--warn) 17%, transparent);
}
@media (max-width: 1080px) { .access-note-wrap { padding: 20px 28px 0; } }
@media (max-width: 560px) {
  .access-note-wrap { padding: 16px 16px 0; }
  .access-note { align-items: flex-start; font-size: 12.5px; }
}
.content {
  max-width: var(--content-max); margin: 0 auto;
  padding: 26px 44px 120px;
}

.breadcrumb {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--ink-3); margin: 0 0 22px;
}
.breadcrumb a { color: var(--ink-3); font-weight: 500; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { color: var(--border-strong); }
.breadcrumb .current { color: var(--ink-2); font-weight: 600; }

/* hero */
.hero { margin: 0 0 26px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 7px; margin: 0 0 12px;
  font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent);
}
.eyebrow::before { content: ""; width: 18px; height: 2px; border-radius: 2px; background: linear-gradient(90deg, var(--brand-1), var(--brand-2)); }
.hero h1 { margin: 0 0 12px; font-size: clamp(28px, 4vw, 40px); font-weight: 800; letter-spacing: -.03em; line-height: 1.08; }
.hero .lead { margin: 0; font-size: 16.5px; color: var(--ink-2); max-width: 760px; line-height: 1.6; }
.hero .lead code { font-family: var(--font-mono); font-size: .85em; background: var(--panel-3); color: var(--accent-ink); padding: 2px 6px; border-radius: 5px; }

/* quick facts — one calm panel, not four floating cards */
.facts {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin: 26px 0 8px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.fact {
  padding: 14px 18px; min-width: 0;
}
.fact + .fact { border-left: 1px solid var(--border-2); }
.fact .k { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.fact .k svg { width: 13px; height: 13px; color: var(--accent); }
.fact .v { font-size: 14px; font-weight: 600; color: var(--ink); line-height: 1.4; word-break: break-word; }
.fact .v code { font-family: var(--font-mono); font-size: 13px; color: var(--accent-ink); }

/* ------------------------------------------------------------- sections --- */
.section { margin: 40px 0 0; scroll-margin-top: calc(var(--topbar-h) + 22px); }
.section.hidden, .endpoint.hidden { display: none; }
.section > h2 {
  font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 14px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border); scroll-margin-top: calc(var(--topbar-h) + 22px);
}

/* category divider + guide subtitle */
.cat-header {
  font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3);
  margin: 52px 0 4px; padding-bottom: 12px; border-bottom: 1px solid var(--border);
  scroll-margin-top: calc(var(--topbar-h) + 22px);
}
.cat-header:first-of-type { margin-top: 40px; }
.sub-title { font-size: 20px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 12px; }

/* prose (guides) */
.prose { color: var(--ink-2); }
.prose > *:first-child { margin-top: 0; }
.prose p { margin: 0 0 14px; }
.prose h3 { color: var(--ink); font-size: 16px; font-weight: 700; margin: 26px 0 10px; }
.prose ul, .prose ol { margin: 0 0 16px; padding-left: 22px; }
.prose li { margin: 5px 0; }
.prose li::marker { color: var(--ink-3); }
.prose a { font-weight: 600; }
.prose strong { color: var(--ink); font-weight: 700; }
.prose code {
  font-family: var(--font-mono); font-size: .86em; background: var(--panel-3);
  border: 1px solid var(--border-2); color: var(--accent-ink); padding: 1.5px 6px; border-radius: 5px;
}
.prose pre {
  margin: 14px 0; padding: 15px 16px; background: var(--code-bg); border: 1px solid var(--code-border);
  border-radius: var(--r-md); overflow-x: auto; box-shadow: var(--shadow-sm);
}
.prose pre code { background: none; border: 0; padding: 0; color: var(--code-ink); font-size: 13px; line-height: 1.6; }
.prose dl.faq { margin: 0; }
.prose dl.faq dt { font-weight: 700; color: var(--ink); margin-top: 18px; }
.prose dl.faq dd { margin: 5px 0 0; color: var(--ink-2); }

/* tables (shared: prose + params) */
.prose table, .param-table {
  width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px;
  margin: 14px 0 18px; border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden;
}
.prose th, .param-table th {
  text-align: left; font-weight: 700; color: var(--ink-2); background: var(--panel-2);
  padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
}
.prose td, .param-table td { padding: 10px 14px; border-bottom: 1px solid var(--border-2); color: var(--ink-2); vertical-align: top; }
.prose tr:last-child td, .param-table tbody tr:last-child td { border-bottom: 0; }
.param-table .col-name { white-space: nowrap; }
.param-table code { font-family: var(--font-mono); font-size: 12.5px; color: var(--accent-ink); }
.param-table .ptype { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.req-pill {
  display: inline-block; margin-left: 7px; font-size: 10px; font-weight: 700; letter-spacing: .03em;
  color: var(--err); text-transform: uppercase; vertical-align: middle;
}
.opt-pill { display: inline-block; margin-left: 7px; font-size: 10px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--r-md); }
.table-scroll > table, .table-scroll > .param-table { margin: 0; }

/* --------------------------------------------------------- endpoint card -- */
.endpoint {
  margin: 18px 0; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm); overflow: hidden;
  scroll-margin-top: calc(var(--topbar-h) + 22px);
  transition: box-shadow var(--t), border-color var(--t);
}
.endpoint:hover { box-shadow: var(--shadow); }
.endpoint.open { box-shadow: var(--shadow); }

.ep-head {
  width: 100%; display: flex; align-items: center; gap: 13px; text-align: left;
  padding: 15px 18px; background: transparent; border: 0; cursor: pointer; font-family: inherit;
  transition: background var(--t-fast);
}
.ep-head:hover { background: var(--panel-2); }
.method {
  font-family: var(--font-mono); font-size: 11px; font-weight: 700; letter-spacing: .03em;
  padding: 5px 9px; border-radius: var(--r-xs); min-width: 62px; text-align: center; flex-shrink: 0; line-height: 1.3;
}
/* single accent for all methods — calm and consistent (label carries meaning) */
.method.get, .method.post, .method.put,
.method.patch, .method.delete { color: var(--accent-ink); background: var(--accent-soft); }

.ep-head-main { min-width: 0; flex: 1; }
.ep-title { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.ep-title h3 { margin: 0; font-size: 15.5px; font-weight: 700; color: var(--ink); letter-spacing: -.01em; }
.ep-path { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-3); margin-top: 3px; word-break: break-all; }
.ep-path .verb { color: var(--ink-3); }

.lock {
  display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 700; letter-spacing: .02em;
  color: var(--m-delete); background: var(--m-delete-bg); border-radius: var(--r-pill); padding: 3px 9px;
}
.lock svg { width: 11px; height: 11px; }

.ep-chevron { width: 18px; height: 18px; color: var(--ink-3); flex-shrink: 0; transition: transform var(--t); }
.endpoint.open .ep-chevron { transform: rotate(180deg); }

.ep-body { display: none; padding: 4px 18px 22px; border-top: 1px solid var(--border); }
.endpoint.open .ep-body { display: block; }
.ep-desc { color: var(--ink-2); margin: 16px 0 4px; font-size: 15px; }
.ep-when { color: var(--ink-2); margin: 8px 0 0; font-size: 14px; }
.ep-when strong { color: var(--ink); }

.ep-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 0; margin: 14px 0 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; color: var(--ink-2);
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--r-pill); padding: 4px 11px;
}
.chip svg { width: 12px; height: 12px; color: var(--ink-3); }
.chip.ok { color: var(--ok); } .chip.ok svg { color: var(--ok); }
/* endpoint meta reads as one quiet line, not a scatter of bordered pills */
.ep-meta .chip { border: 0; background: transparent; border-radius: 0; padding: 0; font-weight: 500; font-size: 12.5px; color: var(--ink-3); }
.ep-meta .chip svg { display: none; }
.ep-meta .chip.ok { color: var(--ink-3); }
.ep-meta .chip:not(:last-child)::after { content: "·"; margin: 0 10px; opacity: .5; }

/* content grid inside an endpoint */
.ep-grid { display: block; }
.block { margin-top: 22px; }
.block-title {
  display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-3); margin: 0 0 10px;
}
.block-title svg { width: 14px; height: 14px; color: var(--accent); }

/* ----------------------------------------------------------- code block --- */
.code {
  border: 1px solid var(--code-border); border-radius: var(--r-md); overflow: hidden;
  background: var(--code-bg); box-shadow: var(--shadow-sm);
}
.code-tabs {
  display: flex; align-items: center; gap: 2px; padding: 6px 8px; overflow-x: auto;
  background: var(--code-head); border-bottom: 1px solid var(--code-border); scrollbar-width: none;
}
.code-tabs::-webkit-scrollbar { display: none; }
.code-tab {
  font-family: inherit; font-size: 12.5px; font-weight: 600; color: var(--ink-3);
  padding: 6px 12px; border: 0; background: transparent; border-radius: var(--r-xs); cursor: pointer;
  white-space: nowrap; transition: color var(--t-fast), background var(--t-fast);
}
.code-tab:hover { color: var(--ink); }
.code-tab.active { color: var(--ink); background: var(--panel); box-shadow: var(--shadow-sm); }
.code-copy { margin-left: auto; flex-shrink: 0; }
.copy-btn {
  display: inline-flex; align-items: center; gap: 6px; font-family: inherit; font-size: 11.5px; font-weight: 600;
  color: var(--ink-2); background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-xs);
  padding: 5px 10px; cursor: pointer; transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}
.copy-btn:hover { color: var(--ink); border-color: var(--border-strong); }
.copy-btn svg { width: 13px; height: 13px; }
.copy-btn.copied { color: var(--ok); border-color: var(--ok); }
.copy-btn .ic-check { display: none; }
.copy-btn.copied .ic-copy { display: none; }
.copy-btn.copied .ic-check { display: inline; }

.code-pane { display: none; }
.code-pane.active { display: block; }
.code pre { margin: 0; padding: 16px 18px; overflow-x: auto; }
.code code {
  font-family: var(--font-mono); font-size: 12.75px; line-height: 1.7; color: var(--code-ink);
  white-space: pre; tab-size: 2;
}

/* single (non-tabbed) code / json viewer */
.codeblock {
  position: relative; border: 1px solid var(--code-border); border-radius: var(--r-md);
  background: var(--code-bg); box-shadow: var(--shadow-sm); overflow: hidden;
}
.codeblock .codeblock-copy { position: absolute; top: 9px; right: 9px; z-index: 2; }
.codeblock pre { margin: 0; padding: 16px 18px; overflow-x: auto; }
.codeblock code { font-family: var(--font-mono); font-size: 12.75px; line-height: 1.7; color: var(--code-ink); white-space: pre; }

/* syntax tokens */
.tok-key { color: var(--tok-key); }
.tok-str { color: var(--tok-str); }
.tok-num { color: var(--tok-num); }
.tok-bool { color: var(--tok-bool); }
.tok-null { color: var(--tok-bool); }
.tok-punc { color: var(--tok-punc); }
.tok-kw { color: var(--tok-kw); font-weight: 600; }
.tok-fn { color: var(--tok-fn); }
.tok-cmt { color: var(--ink-3); font-style: italic; }

/* response status header */
.resp-head { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; }
.status-pill {
  display: inline-flex; align-items: center; gap: 7px; font-family: var(--font-mono); font-size: 12px; font-weight: 700;
  padding: 4px 10px; border-radius: var(--r-pill);
}
.status-pill .dot { width: 7px; height: 7px; border-radius: 999px; background: currentColor; }
.status-2xx { color: var(--ok); background: var(--m-get-bg); }
.status-4xx { color: var(--warn); background: var(--m-put-bg); }
.status-5xx, .status-401, .status-403 { color: var(--err); background: var(--m-delete-bg); }
.resp-label { font-size: 13px; color: var(--ink-3); }

/* ----------------------------------------------------------- try it out --- */
.tryit { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--panel-2); overflow: hidden; }
.tryit-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer; border: 0; width: 100%;
  background: transparent; font-family: inherit; text-align: left; transition: background var(--t-fast);
}
.tryit-head:hover { background: var(--panel-3); }
.tryit-head .bolt { width: 16px; height: 16px; color: var(--accent); }
.tryit-head .t { font-size: 13.5px; font-weight: 700; color: var(--ink); }
.tryit-head .hint { font-size: 12px; color: var(--ink-3); margin-left: 2px; }
.tryit-head .ep-chevron { margin-left: auto; }
.tryit.open .tryit-head .ep-chevron { transform: rotate(180deg); }
.tryit-body { display: none; padding: 4px 16px 16px; border-top: 1px solid var(--border); }
.tryit.open .tryit-body { display: block; }

.field { margin-top: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field label .req-pill { margin-left: 4px; }
.field .field-desc { font-weight: 400; color: var(--ink-3); }
.input, .textarea {
  width: 100%; font-family: var(--font-mono); font-size: 13px; color: var(--ink);
  padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--panel);
  outline: none; transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.textarea { min-height: 120px; line-height: 1.6; resize: vertical; white-space: pre; }
.input-key { display: flex; gap: 8px; }
.input-key .input { flex: 1; }

.tryit-actions { display: flex; align-items: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.send-btn { background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); color: #fff; box-shadow: 0 6px 18px -6px rgba(29,155,240,.6); }
.send-btn:hover { filter: brightness(1.05); }
.send-btn[disabled] { opacity: .6; cursor: progress; }
.send-btn .spin { width: 15px; height: 15px; animation: spin .8s linear infinite; display: none; }
.send-btn.loading .spin { display: inline; }
.send-btn.loading .bolt { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.tryit-note { font-size: 12px; color: var(--ink-3); margin: 12px 0 0; display: flex; gap: 7px; align-items: flex-start; }
.tryit-note svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 1px; color: var(--ink-3); }
.tryit-result { margin-top: 16px; display: none; }
.tryit-result.show { display: block; }
.tryit-timing { font-size: 12px; color: var(--ink-3); font-family: var(--font-mono); }

/* ---------------------------------------------------------------- alerts -- */
.callout {
  display: flex; gap: 12px; padding: 13px 16px; border-radius: var(--r-md); margin: 16px 0 0;
  border: 1px solid var(--border); background: var(--panel-2); font-size: 13.5px; color: var(--ink-2);
}
.callout svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.callout .c-body { min-width: 0; }
.callout .c-body strong { color: var(--ink); }
.callout.note { border-left: 3px solid var(--accent); }
.callout.note svg { color: var(--accent); }
.callout.admin { border-left: 3px solid var(--m-delete); background: var(--m-delete-bg); }
.callout.admin svg { color: var(--m-delete); }
.callout ul { margin: 4px 0 0; padding-left: 18px; }
.callout li { margin: 3px 0; }

/* -------------------------------------------------------------- mobile ---- */
.overlay {
  position: fixed; inset: var(--topbar-h) 0 0; background: rgba(6, 10, 18, .5);
  backdrop-filter: blur(2px); z-index: 50; opacity: 0; visibility: hidden; transition: opacity var(--t), visibility var(--t);
}
.overlay.show { opacity: 1; visibility: visible; }

/* ---------------------------------------------------------------- footer -- */
.foot {
  max-width: var(--content-max); margin: 0 auto; padding: 28px 44px;
  border-top: 1px solid var(--border); color: var(--ink-3); font-size: 13px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.foot a { color: var(--ink-2); font-weight: 600; }

/* loading / error */
.state {
  max-width: 520px; margin: 90px auto; text-align: center; color: var(--ink-2);
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.state p { margin: 0; }
.state svg { width: 28px; height: 28px; color: var(--accent); }
.state .spin { animation: spin .8s linear infinite; }
.state.err { color: var(--err); }
.state.err svg { color: var(--err); }

/* toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); font-size: 13px; font-weight: 600; padding: 10px 16px;
  border-radius: var(--r-pill); box-shadow: var(--shadow-lg); z-index: 300;
  opacity: 0; visibility: hidden; transition: opacity var(--t), transform var(--t), visibility var(--t);
}
.toast.show { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }

/* ------------------------------------------------------- authorize modal -- */
.auth-modal { position: fixed; inset: 0; z-index: 400; display: grid; place-items: center; padding: 20px; }
.auth-modal[hidden] { display: none; }
.auth-backdrop { position: absolute; inset: 0; background: rgba(6, 10, 18, .55); backdrop-filter: blur(3px); }
.auth-card {
  position: relative; width: min(460px, 100%); background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  padding: 22px 22px 20px;
}
.auth-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 6px; }
.auth-head h2 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.auth-desc { margin: 0 0 16px; font-size: 13.5px; color: var(--ink-2); line-height: 1.55; }
.auth-card > label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.auth-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* topbar Authorize button — reflects saved state */
#authorizeBtn.authorized { color: var(--ok); border-color: var(--ok); }
#authorizeBtn.authorized svg { color: var(--ok); }

/* per-endpoint try-it: quiet auth status line (replaces the old key field) */
.tryit-auth { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-3); margin-top: 4px; }
.tryit-auth svg { width: 14px; height: 14px; flex-shrink: 0; }
.tryit-auth.ok { color: var(--ok); }
.tryit-auth .auth-link { font-weight: 600; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; font-family: inherit; font-size: inherit; }
.tryit-auth .auth-link:hover { text-decoration: underline; }

/* ============================================================ hub landing == */
.hub-main { max-width: 1080px; margin: 0 auto; padding: 56px 24px 110px; }
.hub-head { max-width: 720px; }
.hub-head h1 { font-size: clamp(30px, 5vw, 42px); font-weight: 800; letter-spacing: -.03em; line-height: 1.08; margin: 0 0 14px; }
.hub-head .lead { font-size: 17px; color: var(--ink-2); margin: 0; line-height: 1.6; }
.section-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); margin: 44px 0 16px; }
.hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.hub-card {
  display: block; text-decoration: none; color: inherit; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--r-lg); padding: 22px; box-shadow: var(--shadow-sm);
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
}
.hub-card:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: var(--shadow-lg); text-decoration: none; }
.hub-card.soon { opacity: .58; pointer-events: none; }
.hub-card .hc-top { display: flex; align-items: center; gap: 13px; margin-bottom: 13px; }
.hub-card .hc-icon {
  width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; font-size: 23px;
  background: var(--accent-soft); border: 1px solid var(--border);
}
.hub-card h3 { margin: 0; font-size: 17px; font-weight: 700; }
.hub-card .hc-tag { margin: 0; font-size: 14px; color: var(--ink-2); line-height: 1.55; }
.hub-card .hc-badges { margin-top: 16px; display: flex; gap: 7px; flex-wrap: wrap; }
.hub-card .hc-badge { font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: var(--r-pill); background: var(--panel-2); border: 1px solid var(--border); color: var(--ink-2); }
.hub-card .hc-badge.live { background: var(--m-get-bg); color: var(--m-get); border-color: transparent; }

/* ============================================================= responsive == */
@media (max-width: 1080px) {
  :root { --sidebar-w: 264px; }
  .content { padding: 24px 28px 100px; }
  .foot { padding: 24px 28px; }
}

@media (max-width: 900px) {
  .topbar-tags { display: none; }
  .topbar-actions .nav-link { display: none; }
  .topbar-divider { display: none; }   /* no nav group to fence off once links hide */
  .menu-btn { display: inline-grid; }
  .brand-sub { display: none; }

  .sidebar {
    position: fixed; top: var(--topbar-h); left: 0; z-index: 55;
    width: min(320px, 86vw); height: calc(100dvh - var(--topbar-h));
    background: var(--panel); box-shadow: var(--shadow-lg);
    transform: translateX(-102%); transition: transform var(--t); border-right: 1px solid var(--border);
  }
  .sidebar.open { transform: translateX(0); }
  .facts { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  :root { --topbar-h: 56px; }
  .content { padding: 20px 16px 80px; }
  .foot { padding: 20px 16px; flex-direction: column; align-items: flex-start; }
  .facts { grid-template-columns: 1fr; }
  .topbar-inner { padding: 0 14px; gap: 10px; }
  .ep-head { padding: 13px 14px; gap: 10px; }
  .ep-body { padding: 4px 14px 18px; }
  .hero .lead { font-size: 15.5px; }
  .btn .btn-label-lg { display: none; }
}

/* Single reading column at every width — docs then code, stacked. A split
   docs|code layout divides the eye between two live regions; one column keeps
   a single focal path down the page. */

/* Smooth, contained light/dark fade — the `theme-anim` class is added to <html>
   only for the ~260ms of a theme toggle (by refnav.js / app.js), so there are no
   permanent transitions to make other interactions feel laggy. Skipped entirely
   for reduced-motion users. */
@media (prefers-reduced-motion: no-preference) {
  html.theme-anim, html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after {
    transition: background-color .22s ease, border-color .22s ease, color .22s ease,
                fill .22s ease, box-shadow .22s ease !important;
  }
}

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