:root {
  --bg: #ffffff;
  --panel: #f8fafc;
  --panel-2: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --brand: #2563eb;
  --brand-2: #4f46e5;
  --accent: #0ea5e9;
  --code: #0b1220;
  --code-text: #dbeafe;
  --success: #059669;
  --warning: #b45309;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
  --radius: 16px;
  --topbar: 64px;
  --sidebar: 272px;
  --toc: 220px;
}
[data-theme="dark"] {
  --bg: #0a0f1c;
  --panel: #0f172a;
  --panel-2: #111c31;
  --text: #e5edf8;
  --muted: #93a4bb;
  --border: #21304a;
  --brand: #60a5fa;
  --brand-2: #818cf8;
  --accent: #38bdf8;
  --code: #050914;
  --code-text: #dbeafe;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}
* {
  box-sizing: border-box;
}
/* Bilingual content: both languages live in the DOM, only the active one renders.
   The active language is set by `data-lang` on <html> (see docs.js). */
html[data-lang="zh"] [data-lang-block="en"],
html[data-lang="en"] [data-lang-block="zh"] {
  display: none;
}
html {
  scroll-behavior: smooth;
  /* Keep fragment navigation clear of the fixed topbar (64px + a 20px gap). */
  scroll-padding-top: calc(var(--topbar) + 20px);
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    14px/1.7 Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}
a {
  color: inherit;
  text-decoration: none;
}
button {
  font: inherit;
}
.topbar {
  height: var(--topbar);
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 780;
  font-size: 16px;
  letter-spacing: -0.02em;
  min-width: 248px;
}
.logo {
  width: 31px;
  height: 31px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.25);
}
.brand small {
  font-weight: 650;
  color: var(--muted);
  font-size: 11px;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
}
.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.icon-btn {
  height: 36px;
  width: 36px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 9px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.lang-switch {
  display: flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel);
}
.lang-switch button {
  height: 28px;
  min-width: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 650;
}
.lang-switch button.active {
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}
.layout {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr) var(--toc);
  gap: 0;
  padding-top: var(--topbar);
}
aside.sidebar {
  position: fixed;
  top: var(--topbar);
  bottom: 0;
  left: 0;
  width: var(--sidebar);
  overflow: auto;
  border-right: 1px solid var(--border);
  padding: 24px 18px 40px;
  background: var(--bg);
}
.sidebar .group {
  margin-bottom: 24px;
}
.group-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 0 10px 7px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 540;
}
.nav-link:hover {
  background: var(--panel);
  color: var(--text);
}
.nav-link.active {
  background: color-mix(in srgb, var(--brand) 11%, transparent);
  color: var(--brand);
  font-weight: 700;
}
.badge {
  margin-left: auto;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
main {
  grid-column: 2;
  width: min(920px, calc(100vw - var(--sidebar) - var(--toc)));
  padding: 62px 56px 100px;
  margin: 0 auto;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 7%, transparent);
  font-size: 12px;
  font-weight: 700;
}
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}
h1 {
  font-size: 48px;
  line-height: 1.04;
  letter-spacing: -0.045em;
  margin: 18px 0 16px;
  max-width: 760px;
}
h2 {
  font-size: 28px;
  line-height: 1.25;
  letter-spacing: -0.025em;
  margin: 68px 0 16px;
}
h3 {
  font-size: 18px;
  letter-spacing: -0.01em;
  margin: 30px 0 10px;
}
p {
  color: var(--muted);
  font-size: 15px;
}
main ul,
main ol {
  margin: 14px 0;
  padding-left: 22px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}
main ul {
  list-style: disc;
}
main ol {
  list-style: decimal;
}
main li {
  margin: 5px 0;
}
main li::marker {
  color: var(--brand);
}
main li > ul,
main li > ol {
  margin: 5px 0;
}
.qr-code {
  display: block;
  margin: 14px 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}
.lead {
  font-size: 18px;
  line-height: 1.7;
  max-width: 760px;
}
.lead b {
  color: var(--text);
}
.hero-actions {
  display: flex;
  gap: 10px;
  margin: 26px 0 22px;
  flex-wrap: wrap;
}
.btn {
  height: 42px;
  padding: 0 15px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg);
}
.btn.primary {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.24);
}
.hero-meta {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}
.hero-meta span {
  display: flex;
  align-items: center;
  gap: 6px;
}
.code-card {
  position: relative;
  margin-top: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.code-card.plain {
  margin-top: 16px;
  box-shadow: none;
}
.code-head {
  height: 46px;
  background: var(--panel);
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
}
.tabs {
  display: flex;
  gap: 4px;
}
.tab {
  padding: 6px 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 7px;
  cursor: pointer;
  font-weight: 650;
}
.tab.active {
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}
.copy {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
/* Per-block copy button, injected by docs.js onto every .code-card that has no
   header of its own; it sits over the dark <pre>, hence its own colours. */
.code-copy {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  padding: 4px 9px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 7px;
  background: rgba(2, 6, 23, 0.78);
  color: #94a3b8;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.5;
  cursor: pointer;
  transition:
    color 0.15s ease,
    border-color 0.15s ease;
}
.code-copy:hover {
  color: var(--code-text);
  border-color: rgba(148, 163, 184, 0.55);
}
pre {
  margin: 0;
  padding: 20px 22px;
  background: var(--code);
  color: var(--code-text);
  overflow: auto;
  font:
    13px/1.75 "SFMono-Regular",
    Consolas,
    monospace;
}
.tok-k {
  color: #c4b5fd;
}
.tok-s {
  color: #86efac;
}
.tok-f {
  color: #7dd3fc;
}
.tok-c {
  color: #64748b;
}
.tok-n {
  color: #fdba74;
}
.tok-t {
  color: #f9a8d4;
}
.tok-a {
  color: #a5b4fc;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  margin: 34px 0 0;
}
.stat {
  padding: 18px;
  border-right: 1px solid var(--border);
  background: var(--panel);
}
.stat:last-child {
  border-right: 0;
}
.stat strong {
  display: block;
  font-size: 18px;
  color: var(--text);
  margin-bottom: 2px;
}
.stat span {
  color: var(--muted);
  font-size: 12px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.card {
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 18px;
  background: var(--bg);
  transition:
    0.16s transform,
    0.16s border-color,
    0.16s box-shadow;
}
.card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--brand) 45%, var(--border));
  box-shadow: var(--shadow);
}
.card-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--brand) 10%, transparent);
  color: var(--brand);
  display: grid;
  place-items: center;
  font-weight: 800;
  margin-bottom: 12px;
}
.card h3 {
  margin: 0 0 5px;
  font-size: 15px;
}
.card p {
  margin: 0;
  font-size: 13px;
}
.callout {
  display: flex;
  gap: 12px;
  border: 1px solid color-mix(in srgb, var(--brand) 25%, var(--border));
  border-radius: 12px;
  background: color-mix(in srgb, var(--brand) 6%, transparent);
  padding: 14px 16px;
  margin: 20px 0;
  color: var(--muted);
}
.callout b {
  color: var(--text);
}
table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: table;
}
th,
td {
  text-align: left;
  padding: 11px 13px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
th {
  background: var(--panel);
  color: var(--muted);
  font-weight: 700;
}
main :not(pre) > code,
.inline-code {
  font-family: "SFMono-Regular", Consolas, monospace;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 5px;
  color: var(--text);
}
.api-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: start;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}
.api-row h3 {
  margin: 0 0 6px;
}
.api-row p {
  margin: 0;
}
.pill {
  white-space: nowrap;
  font: 11px/1.6 monospace;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 9px;
  color: var(--brand);
}
aside.toc {
  position: fixed;
  right: 0;
  top: var(--topbar);
  bottom: 0;
  width: var(--toc);
  padding: 44px 22px;
  border-left: 1px solid transparent;
  overflow-y: auto;
}
.toc-title {
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 12px;
}
.toc a {
  display: block;
  color: var(--muted);
  font-size: 12px;
  padding: 4px 0 4px 10px;
  border-left: 1px solid var(--border);
}
.toc a:hover {
  color: var(--text);
  border-color: var(--brand);
}
.footer {
  margin-top: 70px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}
.mobile-menu {
  display: none;
}
@media (max-width: 1100px) {
  :root {
    --toc: 0px;
  }
  aside.toc {
    display: none;
  }
  main {
    width: calc(100vw - var(--sidebar));
    padding-right: 40px;
    padding-left: 40px;
  }
}
@media (max-width: 760px) {
  .topbar {
    padding: 0 14px;
  }
  .brand {
    min-width: auto;
  }
  .brand small {
    display: none;
  }
  .mobile-menu {
    display: inline-flex;
  }
  aside.sidebar {
    width: min(86vw, 320px);
    visibility: hidden;
    transform: translateX(-100%);
    transition:
      transform 0.18s ease,
      visibility 0.18s;
    box-shadow: var(--shadow);
  }
  body.nav-open aside.sidebar {
    visibility: visible;
    transform: translateX(0);
  }
  .layout {
    display: block;
  }
  main {
    width: 100%;
    padding: 38px 20px 80px;
  }
  h1 {
    font-size: 38px;
  }
  .stats {
    grid-template-columns: 1fr 1fr;
  }
  .stat:nth-child(2) {
    border-right: 0;
  }
  .stat:nth-child(-n + 2) {
    border-bottom: 1px solid var(--border);
  }
  .grid-3 {
    grid-template-columns: 1fr;
  }
}
