/* ═══════════════════════════════════════════════════════════════════
   AlphaProxy Docs. Same tokens as alphaproxy.ai: light by default, dark
   on request, brand red, no gradients.
   ═══════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #ffffff; --bg-alt: #f7f7f8; --surface: #ffffff; --surface-2: #f4f4f5;
  --line: #e7e7ea; --line-strong: #d4d4d8;
  --text: #0b0b0c; --text-dim: #55555d; --text-faint: #8e8e96;
  --accent: #ff1a4f; --accent-hover: #e6163f; --accent-soft: rgba(255, 26, 79, 0.08);
  --live: #00a04a; --live-soft: rgba(0, 176, 80, 0.10);
  --amber: #a86500; --amber-soft: rgba(214, 140, 0, 0.10);
  --blue: #2b6fd6; --blue-soft: rgba(43, 111, 214, 0.08);
  --code-bg: #f7f7f8;
  --shadow: 0 1px 2px rgba(10, 10, 11, 0.04), 0 12px 40px rgba(10, 10, 11, 0.08);
  --shadow-lg: 0 2px 4px rgba(10, 10, 11, 0.04), 0 30px 80px rgba(10, 10, 11, 0.16);
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --top: 64px; --tabs: 44px; --side: 280px; --toc: 240px;
  color-scheme: light;
}
html.dark-mode {
  --bg: #0a0a0b; --bg-alt: #0f0f11; --surface: #121214; --surface-2: #18181b;
  --line: #222227; --line-strong: #2e2e35;
  --text: #fafafa; --text-dim: #a1a1aa; --text-faint: #6b6b74;
  --accent-hover: #ff3d6b; --accent-soft: rgba(255, 26, 79, 0.14);
  --live: #2ee27a; --live-soft: rgba(46, 226, 122, 0.12);
  --amber: #ffb454; --amber-soft: rgba(255, 180, 84, 0.12);
  --blue: #6ea8ff; --blue-soft: rgba(110, 168, 255, 0.12);
  --code-bg: #111113;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 40px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.4), 0 30px 80px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}
html { scroll-padding-top: calc(var(--top) + var(--tabs) + 16px); }
html, body { background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
body.search-open, body.menu-open { overflow: hidden; }
::selection { background: var(--accent); color: #fff; }
a { color: inherit; }
button { font: inherit; color: inherit; }
img { display: block; }
.skip { position: absolute; left: -9999px; top: 8px; z-index: 200; padding: 8px 12px; border-radius: 8px; background: var(--text); color: var(--bg); }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ─── Top bar ─────────────────────────────────────────────────── */
.topbar { position: sticky; top: 0; z-index: 60; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px); border-bottom: 1px solid var(--line); }
.topbar-row { display: flex; align-items: center; gap: 16px; height: var(--top); padding: 0 clamp(16px, 2.4vw, 32px); }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); white-space: nowrap; }
.brand img { width: 24px; height: 24px; border-radius: 6px; }
.brand-word { font-family: var(--mono); font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.brand-word .dot { color: var(--accent); }
.brand-docs { padding-left: 10px; margin-left: 2px; border-left: 1px solid var(--line-strong); font-size: 15px; font-weight: 500; color: var(--text-dim); }
.search-btn {
  display: inline-flex; align-items: center; gap: 10px; flex: 0 1 340px; margin-left: clamp(8px, 4vw, 64px);
  height: 38px; padding: 0 10px 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-alt);
  color: var(--text-faint); font-size: 14px; cursor: pointer; text-align: left;
}
.search-btn:hover { border-color: var(--line-strong); }
.search-btn svg, .search-field svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; flex-shrink: 0; }
.search-btn span { flex: 1; }
kbd { font-family: var(--mono); font-size: 11px; padding: 2px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text-faint); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.top-link { display: inline-flex; align-items: center; gap: 4px; height: 36px; padding: 0 10px; border-radius: 999px; font-size: 14px; font-weight: 500; color: var(--text-dim); text-decoration: none; white-space: nowrap; }
.top-link:hover { color: var(--text); background: var(--surface-2); }
.ext { width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; }
.theme { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer; color: var(--text-dim); }
.theme:hover { color: var(--text); }
.theme svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.theme .moon { display: none; }
html.dark-mode .theme .sun { display: none; }
html.dark-mode .theme .moon { display: block; }
.btn { display: inline-flex; align-items: center; justify-content: center; height: 36px; padding: 0 16px; border-radius: 999px; border: 1px solid transparent; font-size: 14px; font-weight: 500; text-decoration: none; white-space: nowrap; }
.btn--solid { background: var(--accent); color: #fff; }
.btn--solid:hover { background: var(--accent-hover); }
.btn--ghost { color: var(--text); }
.btn--ghost:hover { background: var(--surface-2); }
.icon-btn { display: none; position: relative; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; flex-shrink: 0; }
.menu-btn span { position: absolute; left: 10px; right: 10px; height: 1.6px; background: var(--text); border-radius: 2px; transition: transform 0.2s ease, top 0.2s ease; }
.menu-btn span:first-child { top: 13px; } .menu-btn span:last-child { top: 20px; }
body.menu-open .menu-btn span:first-child { top: 16.5px; transform: rotate(45deg); }
body.menu-open .menu-btn span:last-child { top: 16.5px; transform: rotate(-45deg); }

.tabs { display: flex; gap: 4px; height: var(--tabs); padding: 0 clamp(16px, 2.4vw, 32px); align-items: stretch; }
.tabs a { display: inline-flex; align-items: center; padding: 0 12px; font-size: 14px; font-weight: 500; color: var(--text-dim); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); }
.tabs a.is-active { color: var(--text); border-bottom-color: var(--accent); }

/* ─── Layout ──────────────────────────────────────────────────── */
.layout { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); max-width: 1560px; margin: 0 auto; }
.sidebar {
  position: sticky; top: calc(var(--top) + var(--tabs)); align-self: start;
  height: calc(100vh - var(--top) - var(--tabs)); overflow-y: auto; overscroll-behavior: contain;
  padding: 28px 20px 48px clamp(16px, 2.4vw, 32px); border-right: 1px solid var(--line);
}
.nav-group + .nav-group { margin-top: 26px; }
.nav-group-title { margin-bottom: 8px; font-size: 13px; font-weight: 600; color: var(--text); }
.nav-group ul { list-style: none; display: grid; gap: 1px; }
.nav-group a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 10px; margin-left: -10px; border-radius: 8px; font-size: 14px; line-height: 1.4;
  color: var(--text-dim); text-decoration: none;
}
.nav-group a:hover { color: var(--text); background: var(--surface-2); }
.nav-group a.is-current { color: var(--accent); background: var(--accent-soft); font-weight: 500; }
.nav-badge { flex-shrink: 0; font-size: 10.5px; font-weight: 600; letter-spacing: 0.02em; padding: 1px 7px; border-radius: 999px; background: var(--amber-soft); color: var(--amber); }

.content { display: grid; grid-template-columns: minmax(0, 1fr) var(--toc); gap: clamp(24px, 4vw, 64px); padding: 0 clamp(16px, 3vw, 48px); }
.doc { min-width: 0; max-width: 800px; width: 100%; margin: 0 auto; padding: 44px 0 64px; }
.toc { position: sticky; top: calc(var(--top) + var(--tabs) + 32px); align-self: start; max-height: calc(100vh - var(--top) - var(--tabs) - 64px); overflow-y: auto; padding: 44px 0 24px; }
.toc-title { font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.toc ul { list-style: none; display: grid; gap: 2px; border-left: 1px solid var(--line); }
.toc a { display: block; padding: 4px 0 4px 14px; margin-left: -1px; border-left: 1px solid transparent; font-size: 13.5px; line-height: 1.45; color: var(--text-dim); text-decoration: none; }
.toc .lvl-3 a { padding-left: 26px; font-size: 13px; }
.toc a:hover { color: var(--text); }
.toc a.is-active { color: var(--accent); border-left-color: var(--accent); }

/* ─── Page head ───────────────────────────────────────────────── */
.eyebrow { font-size: 13.5px; font-weight: 600; color: var(--accent); margin-bottom: 10px; }
.doc h1 { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; font-size: clamp(30px, 3.2vw, 40px); font-weight: 600; line-height: 1.12; letter-spacing: -0.03em; text-wrap: balance; }
.status { font-size: 12px; font-weight: 600; letter-spacing: 0.02em; padding: 3px 10px; border-radius: 999px; background: var(--amber-soft); color: var(--amber); }
.lead { margin-top: 12px; font-size: 18px; line-height: 1.6; color: var(--text-dim); text-wrap: pretty; }

/* ─── Prose ───────────────────────────────────────────────────── */
.prose { margin-top: 32px; font-size: 16px; line-height: 1.75; color: var(--text-dim); }
.prose > * + * { margin-top: 18px; }
.prose h2 { margin-top: 48px; font-size: 24px; font-weight: 600; line-height: 1.25; letter-spacing: -0.02em; color: var(--text); }
.prose h3 { margin-top: 32px; font-size: 18px; font-weight: 600; line-height: 1.35; letter-spacing: -0.01em; color: var(--text); }
.prose h2 + *, .prose h3 + * { margin-top: 12px; }
.prose .anchor { margin-left: 8px; color: var(--text-faint); text-decoration: none; opacity: 0; transition: opacity 0.15s ease; font-weight: 400; }
.prose h2:hover .anchor, .prose h3:hover .anchor, .prose .anchor:focus { opacity: 1; }
.prose strong { color: var(--text); font-weight: 600; }
.prose a { color: var(--text); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent); text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
.prose a:hover { color: var(--accent); }
.prose ul, .prose ol { padding-left: 22px; }
.prose li + li { margin-top: 6px; }
.prose li::marker { color: var(--text-faint); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 36px 0; }
.prose :not(pre) > code {
  font-family: var(--mono); font-size: 0.86em; padding: 2px 6px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
}
.prose table { width: 100%; border-collapse: separate; border-spacing: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; font-size: 14.5px; line-height: 1.55; display: block; overflow-x: auto; }
.prose th, .prose td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.prose th { background: var(--bg-alt); color: var(--text); font-weight: 600; font-size: 13.5px; white-space: nowrap; }
.prose tbody tr:last-child td { border-bottom: 0; }
.prose td code { white-space: nowrap; }
.prose dl dt { color: var(--text); font-weight: 600; margin-top: 16px; }
.prose dl dd { margin-left: 0; }

/* Code */
.hl { position: relative; border: 1px solid var(--line); border-radius: 12px; background: var(--code-bg); overflow: hidden; }
.code-tabs { border: 1px solid var(--line); border-radius: 12px; background: var(--code-bg); overflow: hidden; }
.code-tabs .hl { border: 0; border-radius: 0; }
.code-tabs > * + * { margin-top: 0; }
.code-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 40px; padding: 0 8px 0 14px; border-bottom: 1px solid var(--line); font-size: 12.5px; color: var(--text-faint); }
.code-bar--tabs { padding-left: 6px; }
.code-bar [role="tablist"] { display: flex; gap: 2px; height: 100%; }
.code-bar [role="tab"] { border: 0; background: transparent; padding: 0 10px; font-size: 13px; font-weight: 500; color: var(--text-faint); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.code-bar [role="tab"][aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.copy { border: 1px solid var(--line); background: var(--surface); border-radius: 7px; padding: 3px 10px; font-size: 12px; color: var(--text-dim); cursor: pointer; }
.copy:hover { color: var(--text); }
.copy.is-done { color: var(--live); border-color: color-mix(in srgb, var(--live) 40%, var(--line)); }
.hl pre { margin: 0; padding: 16px 18px; overflow-x: auto; font-family: var(--mono); font-size: 13.5px; line-height: 1.7; color: var(--text); tab-size: 2; }
.hl pre code { font-family: inherit; }
/* Syntax colours, on brand in both themes */
.hl .c, .hl .c1, .hl .cm, .hl .ch, .hl .cs, .hl .cp { color: var(--text-faint); font-style: italic; }
.hl .k, .hl .kn, .hl .kd, .hl .kr, .hl .kt, .hl .ow, .hl .kc { color: var(--accent); }
.hl .s, .hl .s1, .hl .s2, .hl .sb, .hl .sd, .hl .se, .hl .sh, .hl .si, .hl .sx, .hl .dl { color: var(--live); }
.hl .m, .hl .mi, .hl .mf, .hl .mh, .hl .il { color: var(--amber); }
.hl .nf, .hl .fm, .hl .nc { color: var(--blue); }
.hl .nb, .hl .bp, .hl .nt, .hl .na, .hl .nv { color: var(--blue); }
.hl .o, .hl .p { color: var(--text-dim); }
.hl .err { color: inherit; background: none; }

/* Callouts (Markdown "!!! note") */
.admonition { position: relative; padding: 14px 18px 14px 20px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-alt); font-size: 15px; line-height: 1.65; }
.admonition::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--text-faint); }
.admonition > * + * { margin-top: 8px; }
.admonition-title { font-weight: 600; color: var(--text); font-size: 14px; }
.admonition.tip { background: var(--live-soft); border-color: color-mix(in srgb, var(--live) 25%, var(--line)); }
.admonition.tip::before { background: var(--live); }
.admonition.warning { background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 28%, var(--line)); }
.admonition.warning::before { background: var(--amber); }
.admonition.note { background: var(--blue-soft); border-color: color-mix(in srgb, var(--blue) 22%, var(--line)); }
.admonition.note::before { background: var(--blue); }
.admonition.preview { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, var(--line)); }
.admonition.preview::before { background: var(--accent); }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.cards.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.prose .card {
  display: flex; flex-direction: column; gap: 6px; padding: 18px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); text-decoration: none; color: var(--text-dim); transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.prose .card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); transform: translateY(-1px); box-shadow: var(--shadow); color: var(--text-dim); }
.prose .card strong { font-size: 15.5px; }
.prose .card span { font-size: 14px; line-height: 1.55; }
.prose .card p { margin: 0; }
.card-ico { width: 34px; height: 34px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 4px; }
.card-ico svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* Steps */
.steps { counter-reset: step; position: relative; padding-left: 44px; }
.steps > h3 { counter-increment: step; position: relative; margin-top: 28px; }
.steps > h3:first-child { margin-top: 4px; }
.steps > h3::before {
  content: counter(step); position: absolute; left: -44px; top: -2px; width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--line-strong); color: var(--text);
}
.steps::before { content: ""; position: absolute; left: 13.5px; top: 30px; bottom: 6px; width: 1px; background: var(--line); }

/* Pager and footer */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 56px; }
.pager a { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; }
.pager a:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.pager span { font-size: 12.5px; color: var(--text-faint); }
.pager strong { font-size: 15px; font-weight: 600; color: var(--text); }
.pager-next { text-align: right; grid-column: 2; }
.doc-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line); font-size: 13px; color: var(--text-faint); }
.doc-foot a { color: var(--text-dim); text-decoration: none; }
.doc-foot a:hover { color: var(--text); }

/* ─── Search ──────────────────────────────────────────────────── */
.search { position: fixed; inset: 0; z-index: 100; }
.search[hidden] { display: none; }
.search-backdrop { position: absolute; inset: 0; background: rgba(10, 10, 11, 0.45); backdrop-filter: blur(2px); }
.search-panel { position: relative; width: min(640px, calc(100vw - 32px)); margin: min(12vh, 120px) auto 0; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-lg); overflow: hidden; }
.search-field { display: flex; align-items: center; gap: 10px; padding: 0 14px; height: 56px; border-bottom: 1px solid var(--line); color: var(--text-faint); }
.search-field input { flex: 1; height: 100%; border: 0; outline: none; background: transparent; font: inherit; font-size: 16px; color: var(--text); }
.search-field input::-webkit-search-cancel-button { display: none; }
.search-results { list-style: none; max-height: min(60vh, 520px); overflow-y: auto; padding: 8px; }
.search-results a { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 10px; text-decoration: none; }
.search-results li.is-sel a { background: var(--surface-2); }
.search-results strong { font-size: 14.5px; font-weight: 600; color: var(--text); }
.sr-group { font-size: 12px; color: var(--accent); font-weight: 500; }
.sr-text { font-size: 13px; line-height: 1.5; color: var(--text-dim); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.search-empty { padding: 22px 12px; font-size: 14px; color: var(--text-faint); text-align: center; }

/* 404 */
.nf { max-width: 560px; margin: 0 auto; padding: 18vh 24px; }
.nf h1 { margin-top: 40px; font-size: 40px; letter-spacing: -0.03em; line-height: 1.1; }
.nf p { margin-top: 14px; color: var(--text-dim); }
.nf p .btn { margin-right: 6px; }

/* ─── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1240px) {
  .content { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 960px) {
  .icon-btn { display: inline-block; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; z-index: 55; left: 0; top: calc(var(--top) + var(--tabs)); bottom: 0; width: min(320px, 86vw); height: auto;
    background: var(--bg); transform: translateX(-102%); visibility: hidden; transition: transform 0.22s ease, visibility 0s linear 0.22s;
  }
  body.menu-open .sidebar { transform: none; visibility: visible; box-shadow: var(--shadow-lg); transition: transform 0.22s ease; }
  .top-link { display: none; }
  .search-btn { margin-left: auto; flex: 0 1 220px; }
  .topbar-actions { margin-left: 0; }
}
@media (max-width: 640px) {
  :root { --top: 58px; }
  .brand-docs { display: none; }
  .topbar-row { gap: 8px; }
  .theme { width: 34px; height: 34px; }
  .search-btn { flex: 0 0 auto; width: 38px; padding: 0; justify-content: center; }
  .search-btn span, .search-btn kbd { display: none; }
  .btn--ghost { display: none; }
  .btn { padding: 0 12px; }
  .cards, .cards.cols-3 { grid-template-columns: 1fr; }
  .pager { grid-template-columns: 1fr; }
  .pager-next { grid-column: 1; }
  .doc { padding-top: 28px; }
  .steps { padding-left: 38px; }
  .steps > h3::before { left: -38px; }
}
@media (max-width: 420px) {
  .topbar-actions .btn--solid { display: none; }
}
