/* 678API Docs — shared stylesheet
   All colors come from the variables below. Light is default; dark is
   enabled by <html data-theme="dark">. Never hardcode colors in rules. */

:root {
  --bg: #eceef2;
  --sidebar: #e6e9ee;
  --sidebar-hover: #dce0e7;
  --surface: #ffffff;
  --surface-2: #e3e6ec;
  --line: #d6dbe3;
  --line-strong: #c6ccd6;
  --ink: #141821;
  --ink-2: #3c4452;
  --ink-3: #5f6777;
  --accent: #4152e0;
  --accent-ink: #ffffff;
  --accent-soft: rgb(65 82 224 / 9%);
  --signal: #11a596;
  --signal-soft: rgb(17 165 150 / 12%);
  --warn: #b7791f;
  --warn-soft: rgb(183 121 31 / 9%);
  --code-bg: #f1f3f7;
  --code-bar: #e7eaf0;
  --shadow: 0 1px 2px rgb(20 24 33 / 5%), 0 4px 16px rgb(20 24 33 / 4%);

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Cascadia Code", Consolas, "Liberation Mono", Menlo, monospace;

  --header-h: 60px;
  --sidebar-w: 272px;
  --toc-w: 220px;
  --content-max: 760px;
  --radius: 10px;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0d1015;
  --sidebar: #0d1015;
  --sidebar-hover: #1b2029;
  --surface: #151920;
  --surface-2: #1b2029;
  --line: #262c37;
  --line-strong: #353d4b;
  --ink: #e8ebf0;
  --ink-2: #b7bfcc;
  --ink-3: #808998;
  --accent: #8291ff;
  --accent-ink: #0d1015;
  --accent-soft: rgb(130 145 255 / 12%);
  --signal: #3dd6c6;
  --signal-soft: rgb(61 214 198 / 12%);
  --warn: #e0a548;
  --warn-soft: rgb(224 165 72 / 10%);
  --code-bg: #10141a;
  --code-bar: #181d25;
  --shadow: none;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--header-h) + 20px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.75 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
img { max-width: 100%; height: auto; }
::selection { background: var(--accent-soft); }

.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; padding: 8px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.skip-link:focus { left: 12px; }

/* ---------- Header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  display: flex; align-items: center; gap: 20px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand img { width: 26px; height: 26px; }
.brand small { font: 500 11px var(--font-mono); color: var(--ink-3); padding: 2px 6px; border: 1px solid var(--line); border-radius: 4px; }

/* Signature: the endpoint chip — the one value every page asks you to paste */
.endpoint {
  display: flex; align-items: center; gap: 0;
  margin-left: 8px;
  font: 500 12.5px var(--font-mono);
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface);
  overflow: hidden;
}
.endpoint .dot { width: 7px; height: 7px; margin: 0 8px 0 12px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 0 3px var(--signal-soft); }
.endpoint code { color: var(--ink-2); padding: 6px 4px 6px 0; white-space: nowrap; }
.endpoint button {
  margin-left: 8px; padding: 6px 12px; border: 0; border-left: 1px solid var(--line);
  background: transparent; color: var(--ink-3); font: inherit; cursor: pointer;
}
.endpoint button:hover { color: var(--accent); background: var(--accent-soft); }

.topnav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.topnav a, .topnav button.icon {
  display: inline-flex; align-items: center; gap: 4px;
  height: 34px; padding: 0 10px; border-radius: 6px;
  color: var(--ink-2); font-size: 14px; font-weight: 500;
  background: transparent; border: 0; cursor: pointer; font-family: inherit;
}
.topnav a:hover, .topnav button.icon:hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }
.topnav a.active { color: var(--accent); }
.topnav .sep { width: 1px; height: 20px; background: var(--line); margin: 0 6px; }
.topnav svg { width: 16px; height: 16px; }
.lang-switch { font-family: var(--font-mono) !important; font-size: 12.5px !important; }
.menu-toggle {
  display: none; align-items: center; justify-content: center;
  width: 36px; height: 36px; margin-left: -6px; border: 0; border-radius: 6px;
  background: transparent; color: var(--ink-2); cursor: pointer;
}
.menu-toggle:hover { background: var(--surface-2); color: var(--ink); }
.menu-toggle svg { width: 20px; height: 20px; }
#theme-toggle .i-sun { display: none; }
html[data-theme="dark"] #theme-toggle .i-sun { display: block; }
html[data-theme="dark"] #theme-toggle .i-moon { display: none; }

/* ---------- Shell ---------- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: calc(100vh - var(--header-h));
}
.sidebar {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 24px 16px 40px 24px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
}
.side-group + .side-group { margin-top: 22px; }
.side-group h2 {
  margin: 0 0 6px 10px;
  font: 600 11px/1.6 var(--font-mono);
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3);
}
.side-group ul { list-style: none; margin: 0; padding: 0; }
.side-group a {
  display: block; padding: 5px 10px; border-radius: 6px;
  color: var(--ink-2); font-size: 14px; line-height: 1.55;
}
.side-group a:hover { color: var(--ink); background: var(--sidebar-hover); text-decoration: none; }
.side-group a[aria-current="page"] {
  color: var(--accent); font-weight: 600;
  background: var(--accent-soft);
  box-shadow: inset 2px 0 0 var(--accent);
}

.scrim { display: none; position: fixed; inset: var(--header-h) 0 0; z-index: 30; background: rgb(0 0 0 / 30%); }

.page {
  display: grid;
  grid-template-columns: minmax(0, var(--content-max)) var(--toc-w);
  gap: 56px;
  justify-content: center;
  padding: 48px 40px 80px;
}
.page.no-toc { grid-template-columns: minmax(0, var(--content-max)); }

/* ---------- TOC ---------- */
.toc { position: sticky; top: calc(var(--header-h) + 40px); align-self: start; max-height: calc(100vh - var(--header-h) - 80px); overflow-y: auto; }
.toc h2 { margin: 0 0 10px; font: 600 11px var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc a { display: block; margin-left: -1px; padding: 4px 0 4px 14px; border-left: 1px solid transparent; color: var(--ink-3); font-size: 13px; line-height: 1.5; }
.toc a.lvl-3 { padding-left: 26px; }
.toc a:hover { color: var(--ink); text-decoration: none; }
.toc a.active { color: var(--accent); border-left-color: var(--accent); }
/* ---------- Document typography ---------- */
.doc { min-width: 0; }
.doc > :first-child { margin-top: 0; }
.doc-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  margin-bottom: 14px;
  font: 500 12px var(--font-mono); color: var(--ink-3);
}
.doc-eyebrow::before { content: ""; width: 14px; height: 1px; background: var(--ink-3); }
.doc h1 {
  margin: 0 0 14px;
  font-size: clamp(28px, 4vw, 38px); line-height: 1.22; font-weight: 750;
  letter-spacing: -.025em; color: var(--ink);
}
.doc h2 {
  margin: 52px 0 16px; padding-top: 0;
  font-size: 21px; line-height: 1.4; font-weight: 700; letter-spacing: -.012em;
  color: var(--ink);
}
.doc h3 { margin: 30px 0 10px; font-size: 16.5px; line-height: 1.5; font-weight: 650; color: var(--ink); }
.doc h2 code, .doc h3 code { font-size: .88em; }
.doc p, .doc li { color: var(--ink-2); }
.doc p { margin: 14px 0; }
.doc ul, .doc ol { padding-left: 1.3em; margin: 14px 0; }
.doc li + li { margin-top: 6px; }
.doc li::marker { color: var(--ink-3); }
.doc strong { color: var(--ink); font-weight: 650; }
.doc hr { border: 0; border-top: 1px solid var(--line); margin: 40px 0; }
.doc-lead { margin: 0 0 8px !important; font-size: 16.5px; line-height: 1.8; color: var(--ink-2); max-width: 64ch; }

.anchor { margin-left: 8px; color: var(--ink-3); opacity: 0; font-weight: 400; text-decoration: none !important; }
h2:hover .anchor, h3:hover .anchor, .anchor:focus { opacity: 1; }

.doc :not(pre) > code {
  padding: 2px 6px; border-radius: 5px;
  background: var(--surface-2); color: var(--ink);
  font: 500 .86em var(--font-mono);
  word-break: break-word;
}

/* ---------- Code blocks ---------- */
.code {
  position: relative; margin: 18px 0;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--code-bg); overflow: hidden;
}
.code-bar {
  display: flex; align-items: center; justify-content: space-between;
  height: 36px; padding: 0 8px 0 14px;
  background: var(--code-bar); border-bottom: 1px solid var(--line);
  font: 500 11.5px var(--font-mono); color: var(--ink-3); text-transform: lowercase;
}
.code-bar button {
  height: 26px; padding: 0 10px; border: 1px solid var(--line); border-radius: 5px;
  background: var(--surface); color: var(--ink-2); font: inherit; cursor: pointer;
}
.code-bar button:hover { color: var(--accent); border-color: var(--accent); }
.code-bar button.done { color: var(--signal); border-color: var(--signal); }
.code pre { margin: 0; padding: 16px 18px; overflow-x: auto; }
.code code { font: 13px/1.75 var(--font-mono); color: var(--ink); white-space: pre; }
/* shiki inline colors from the original build */
.code code span[style] { color: var(--shiki-light); }
html[data-theme="dark"] .code code span[style] { color: var(--shiki-dark); }

/* ---------- Tables ---------- */
.table-wrap { margin: 20px 0; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.doc table { width: 100%; border-collapse: collapse; font-size: 14px; }
.doc > table { display: block; overflow-x: auto; margin: 20px 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.doc th, .doc td { padding: 11px 16px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.doc th { font: 600 12px var(--font-mono); letter-spacing: .03em; color: var(--ink-3); background: var(--surface-2); white-space: nowrap; }
.doc td { color: var(--ink-2); }
.doc td:first-child { color: var(--ink); font-weight: 550; }
.doc tr:last-child td { border-bottom: 0; }

/* ---------- Callouts ---------- */
.callout {
  margin: 22px 0; padding: 14px 18px;
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 8px; background: var(--accent-soft);
}
.callout.warning { border-left-color: var(--warn); background: var(--warn-soft); }
.callout strong { display: block; margin-bottom: 4px; color: var(--ink); font-size: 14.5px; }
.callout p { margin: 0; font-size: 14px; }
.callout p + p { margin-top: 6px; }

/* ---------- Steps ---------- */
.steps { counter-reset: step; margin: 24px 0; padding: 0; }
.step { position: relative; padding: 0 0 26px 46px; }
.step::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface);
  font: 600 12.5px var(--font-mono); color: var(--accent);
}
.step::after { content: ""; position: absolute; left: 14px; top: 34px; bottom: 6px; width: 1px; background: var(--line); }
.step:last-child { padding-bottom: 4px; }
.step:last-child::after { display: none; }
.step > strong { display: block; padding-top: 2px; color: var(--ink); font-size: 15.5px; }
.step > p { margin: 6px 0 0; }

/* ---------- Figures ---------- */
.doc-figure { margin: 16px 0 4px; }
.doc-figure img { display: block; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.doc-figure.compact img { max-width: 520px; width: 100%; }
.doc-figure figcaption { margin-top: 8px; font-size: 12.5px; color: var(--ink-3); }
/* ---------- Buttons ---------- */
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 26px 0 8px; }
.btn, .download-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 18px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  font-size: 14px; font-weight: 600; line-height: 1; white-space: nowrap;
  color: var(--ink); background: var(--surface);
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover, .download-button:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.btn.primary, .download-button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover, .download-button.primary:hover { background: color-mix(in srgb, var(--accent) 86%, var(--ink)); color: var(--accent-ink); }

/* ---------- Cards ---------- */
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 24px 0; }
.card {
  padding: 18px 18px 16px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 6px; font-size: 15px; }
.card p { margin: 0; font-size: 13.5px; line-height: 1.7; }

/* ---------- Download / tool access panels ---------- */
.download-card, .tool-access {
  display: grid; gap: 18px 28px; align-items: center;
  margin: 18px 0; padding: 22px 24px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
}
.download-card { grid-template-columns: minmax(0, 1fr) auto; }
.tool-access { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main actions" "meta meta"; }
.tool-access-main { grid-area: main; }
.tool-access-actions { grid-area: actions; }
.download-kicker, .tool-access-kicker { display: block; margin-bottom: 4px; font: 500 11.5px var(--font-mono); color: var(--accent); }
.download-card h3, .tool-access h3 { margin: 0 0 4px; font-size: 17px; }
.download-card p, .tool-access p { margin: 0; font-size: 14px; }
.download-actions, .tool-access-actions { display: flex; flex-direction: column; gap: 8px; min-width: 150px; }
.tool-access-meta {
  grid-area: meta; display: flex; flex-wrap: wrap; gap: 0;
  margin: 0; padding-top: 14px; border-top: 1px dashed var(--line);
}
.tool-access-meta > div { flex: 1 1 180px; padding-right: 16px; }
.tool-access-meta dt { font: 500 11px var(--font-mono); color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.tool-access-meta dd { margin: 2px 0 0; font-size: 13.5px; color: var(--ink); }

/* ---------- Config strip (signature, in-page) ---------- */
.config-card {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 20px 0;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); overflow: hidden; box-shadow: var(--shadow);
}
.config-card > div { position: relative; min-width: 0; padding: 14px 18px; border-left: 1px solid var(--line); }
.config-card > div:first-child { border-left: 0; }
.config-card span { display: block; margin-bottom: 4px; font: 500 11px var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.config-card code {
  display: block; padding: 0 !important; background: none !important;
  font: 500 13.5px var(--font-mono) !important; color: var(--ink) !important;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.config-card > div:first-child code { color: var(--accent) !important; }

/* ---------- Pager + footer ---------- */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 64px; padding-top: 28px; border-top: 1px solid var(--line); }
.pager a {
  display: block; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
}
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager a.next { grid-column: 2; text-align: right; }
.pager small { display: block; font: 500 11.5px var(--font-mono); color: var(--ink-3); }
.pager span { font-weight: 600; font-size: 14.5px; }
.site-footer { margin-top: 40px; font-size: 12.5px; color: var(--ink-3); }

/* ---------- Home hero ---------- */
.home .doc h1 { font-size: clamp(32px, 5vw, 48px); line-height: 1.12; letter-spacing: -.035em; }
.home .doc h1 em { font-style: normal; color: var(--accent); }
.home .doc-lead { font-size: 17px; }

/* ---------- 404 ---------- */
.notfound { max-width: 520px; margin: 12vh auto; padding: 0 24px; text-align: left; }
.notfound .code-num { font: 600 13px var(--font-mono); color: var(--accent); }
.notfound h1 { margin: 8px 0 10px; font-size: 32px; letter-spacing: -.02em; }
.notfound p { color: var(--ink-2); }

/* ---------- Responsive ---------- */
@media (max-width: 1240px) {
  .page { grid-template-columns: minmax(0, var(--content-max)); }
  .toc { display: none; }
}
@media (max-width: 1000px) {
  .endpoint { display: none; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .menu-toggle { display: inline-flex !important; }
  .sidebar {
    position: fixed; top: var(--header-h); left: 0; z-index: 35;
    width: min(300px, 86vw); transform: translateX(-100%);
    transition: transform .2s ease; background: var(--sidebar);
    box-shadow: 0 10px 40px rgb(0 0 0 / 18%);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; }
  .page { padding: 32px 20px 64px; }
  .topnav .hide-sm { display: none; }
}
@media (max-width: 680px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .brand small { display: none; }
  .grid, .config-card { grid-template-columns: 1fr; }
  .config-card > div { border-left: 0; border-top: 1px solid var(--line); }
  .config-card > div:first-child { border-top: 0; }
  .download-card, .tool-access { grid-template-columns: 1fr; grid-template-areas: "main" "actions" "meta"; padding: 18px; }
  .download-actions, .tool-access-actions { flex-direction: row; flex-wrap: wrap; }
  .download-actions a, .tool-access-actions a { flex: 1 1 140px; }
  .pager { grid-template-columns: 1fr; }
  .pager a.next { grid-column: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media print {
  .topbar, .sidebar, .toc, .pager, .code-bar button { display: none !important; }
  .shell, .page { display: block; padding: 0; }
}
