:root {
  --bg: #0d1117;
  --bg-soft: #161b22;
  --bg-code: #0a0e14;
  --border: #21262d;
  --text: #e6edf3;
  --text-dim: #9da7b3;
  --accent: #58a6ff;
  --accent-2: #7ee787;
  --warn: #f0a45f;
  --sidebar-w: 260px;
  --radius: 10px;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 1.5rem; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

code, pre, .mono {
  font-family: "SF Mono", "JetBrains Mono", "Fira Code", ui-monospace, Menlo, Consolas, monospace;
}

/* Layout */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar .brand {
  display: flex; align-items: center; gap: .6rem;
  font-weight: 700; font-size: 1.15rem; margin-bottom: .25rem;
}
.sidebar .brand .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.sidebar .tagline { color: var(--text-dim); font-size: .82rem; margin-bottom: 1rem; }

/* Language toggle */
.lang-toggle {
  display: flex; width: fit-content; margin-bottom: 1.25rem;
  border: 1px solid var(--border); border-radius: 999px; overflow: hidden;
}
.lang-toggle button {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  padding: .3rem .85rem; font-size: .8rem; font-family: inherit;
}
.lang-toggle button.active { background: var(--accent); color: #0d1117; font-weight: 600; }

/* Bilingual show/hide. Exactly one language is ever visible: Chinese is
   hidden unless the body is explicitly lang-zh (so the no-class / no-JS state
   falls back to English), and English is hidden in lang-zh. Hiding only ever
   applies `display:none`, so the shown side keeps its natural display type. */
body:not(.lang-zh) .zh { display: none; }
body.lang-zh .en { display: none; }

.nav-group { margin-bottom: 1.25rem; }
.nav-group h4 {
  text-transform: uppercase; letter-spacing: .06em;
  font-size: .7rem; color: var(--text-dim); margin: 0 0 .5rem .5rem;
}
.nav-group a {
  display: block; padding: .35rem .5rem; border-radius: 6px;
  color: var(--text-dim); font-size: .9rem;
}
.nav-group a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav-group a.active { background: rgba(88,166,255,.12); color: var(--accent); }

.content {
  flex: 1 1 auto;
  max-width: 860px;
  padding: 3rem 3rem 6rem;
  margin: 0 auto;
}

/* Hero */
.hero { margin-bottom: 2.5rem; }
.hero h1 { font-size: 2.4rem; margin: 0 0 .5rem; letter-spacing: -.02em; }
.hero .lede { font-size: 1.15rem; color: var(--text-dim); margin: 0 0 1.25rem; }
.badges { display: flex; flex-wrap: wrap; gap: .5rem; }
.badge {
  font-size: .78rem; padding: .25rem .6rem; border-radius: 999px;
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--text-dim);
}

section { margin-bottom: 3rem; scroll-margin-top: 1rem; }
section > h2 {
  font-size: 1.5rem; margin: 0 0 1rem; padding-bottom: .4rem;
  border-bottom: 1px solid var(--border);
}
section h3 { font-size: 1.12rem; margin: 1.75rem 0 .6rem; }
p { margin: .6rem 0; }

ul { padding-left: 1.25rem; }
li { margin: .25rem 0; }

.muted { color: var(--text-dim); }

/* Callouts */
.note, .warn {
  border-radius: var(--radius); padding: .85rem 1rem; margin: 1rem 0;
  border: 1px solid var(--border); font-size: .92rem;
}
.note { background: rgba(88,166,255,.08); border-color: rgba(88,166,255,.3); }
.warn { background: rgba(240,164,95,.08); border-color: rgba(240,164,95,.3); }
.note strong, .warn strong { color: var(--text); }

/* Inline code */
:not(pre) > code {
  background: var(--bg-soft); border: 1px solid var(--border);
  padding: .1rem .4rem; border-radius: 5px; font-size: .86em; color: var(--accent-2);
}

/* Code blocks + tabs */
.tabs { margin: 1rem 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.tab-bar { display: flex; background: var(--bg-soft); border-bottom: 1px solid var(--border); }
.tab-btn {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  padding: .6rem 1rem; font-size: .85rem; font-family: inherit; border-bottom: 2px solid transparent;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

pre {
  margin: 0; background: var(--bg-code); padding: 1rem 1.1rem;
  overflow-x: auto; font-size: .85rem; line-height: 1.55;
}
pre code { color: #c9d1d9; }
.tabs pre { border-radius: 0; }

/* standalone code block */
.code { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin: 1rem 0; }

/* Endpoint method tags */
.endpoint { display: flex; align-items: center; gap: .6rem; margin-top: 1.5rem; }
.method { font-size: .72rem; font-weight: 700; padding: .2rem .5rem; border-radius: 5px; letter-spacing: .03em; }
.method.get { background: rgba(126,231,135,.15); color: var(--accent-2); }
.method.post { background: rgba(88,166,255,.15); color: var(--accent); }
.path { font-family: "SF Mono", ui-monospace, monospace; font-size: .95rem; }

/* Tables */
table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: .9rem; }
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--text-dim); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
td code { white-space: nowrap; }
.ok { color: var(--accent-2); }
.plan { color: var(--warn); }

/* Feature cards (value proposition) */
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.card { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; background: var(--bg-soft); }
.card .ic { color: var(--accent); font-size: .7rem; font-weight: 700; letter-spacing: .1em; }
.card h4 { margin: .35rem 0 .45rem; font-size: 1rem; }
.card p { margin: 0; color: var(--text-dim); font-size: .88rem; line-height: 1.55; }
td.q { color: var(--text); width: 46%; }

/* Architecture diagrams (inline SVG) */
.diagram { width: 100%; height: auto; margin: 1.25rem 0 .5rem; display: block; }
.diagram .band { fill: rgba(88,166,255,.05); stroke: var(--border); }
.diagram .box { fill: var(--bg-soft); stroke: var(--border); }
.diagram .box.accent { stroke: var(--accent); }
.diagram .box.accent2 { stroke: var(--accent-2); }
.diagram .box.plan { stroke: var(--warn); stroke-dasharray: 4 3; }
.diagram text { fill: var(--text); font-family: inherit; }
.diagram .lbl { font-size: 14px; font-weight: 600; }
.diagram .mono { font-family: "SF Mono", ui-monospace, Menlo, monospace; }
.diagram .sub { font-size: 11px; fill: var(--text-dim); }
.diagram .band-title { font-size: 11px; fill: var(--text-dim); letter-spacing: .12em; }
.diagram .edge { stroke: var(--text-dim); stroke-width: 1.4; fill: none; }
.diagram .edge.accent { stroke: var(--accent); }
.diagram .edge.accent2 { stroke: var(--accent-2); }
.diagram marker path { fill: var(--text-dim); }
.fig-cap { color: var(--text-dim); font-size: .85rem; margin: 0 0 2rem; }

footer {
  margin-top: 4rem; padding-top: 1.5rem; border-top: 1px solid var(--border);
  color: var(--text-dim); font-size: .85rem;
}

/* Mobile */
.menu-toggle { display: none; }
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { position: static; width: 100%; height: auto; }
  .content { padding: 2rem 1.25rem 4rem; }
  .hero h1 { font-size: 1.8rem; }
}
