:root {
  color-scheme: light;
  --bg: #f7f8f5;
  --surface: #ffffff;
  --surface-2: #eef1ed;
  --text: #19201e;
  --muted: #66716d;
  --line: #d9dedb;
  --strong-line: #bdc6c1;
  --accent: #087f6b;
  --accent-strong: #006151;
  --accent-soft: #e1f2ed;
  --amber: #9a5b08;
  --amber-soft: #fff3d8;
  --red: #b14242;
  --code-bg: #151c1a;
  --code-text: #e7eee9;
  --shadow: 0 14px 35px rgba(31, 45, 40, 0.12);
  --topbar: 64px;
  --sidebar: 260px;
  --outline: 210px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101513;
  --surface: #171e1b;
  --surface-2: #202824;
  --text: #e6ece8;
  --muted: #9aa7a1;
  --line: #303a35;
  --strong-line: #445049;
  --accent: #47c6aa;
  --accent-strong: #83dec9;
  --accent-soft: #173c34;
  --amber: #f0b85c;
  --amber-soft: #402e14;
  --red: #ef8b8b;
  --code-bg: #0a0f0d;
  --code-text: #edf4ef;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar) + 24px); }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.72 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; letter-spacing: 0; }
button, input { font: inherit; letter-spacing: 0; }
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
code, pre { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
code { padding: 2px 5px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-2); color: var(--text); font-size: 0.9em; overflow-wrap: anywhere; }

.skip-link { position: fixed; z-index: 100; top: 8px; left: 8px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--strong-line); transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }

.topbar { position: fixed; z-index: 30; inset: 0 0 auto; height: var(--topbar); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(14px); }
.topbar-inner { display: flex; align-items: center; gap: 24px; height: 100%; padding: 0 22px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: calc(var(--sidebar) - 22px); color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { width: 34px; height: 34px; }
.brand-copy { display: grid; line-height: 1.12; }
.brand-copy strong { font-size: 15px; }
.brand-copy small { margin-top: 4px; color: var(--muted); font-size: 11px; }

.search-trigger { display: flex; align-items: center; gap: 9px; width: min(420px, 40vw); height: 38px; padding: 0 13px; color: var(--muted); text-align: left; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); cursor: pointer; }
.search-trigger:hover { border-color: var(--strong-line); color: var(--text); }
.search-trigger span:first-child { font-size: 21px; line-height: 1; }
.top-actions { display: flex; align-items: center; gap: 18px; margin-left: auto; }
.top-actions a { color: var(--muted); font-size: 13px; }
.icon-button { display: inline-grid; width: 36px; height: 36px; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); cursor: pointer; }
.icon-button:hover { border-color: var(--strong-line); }
.mobile-menu { display: none; }

.site-shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr) var(--outline); min-height: 100vh; padding-top: var(--topbar); }
.sidebar { position: fixed; z-index: 20; top: var(--topbar); bottom: 0; left: 0; display: flex; width: var(--sidebar); flex-direction: column; border-right: 1px solid var(--line); background: var(--bg); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 20px 14px; }
.nav-label { margin: 20px 10px 6px; color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.nav-label:first-child { margin-top: 0; }
.sidebar-nav a { display: flex; align-items: center; gap: 11px; min-height: 38px; padding: 7px 10px; color: var(--muted); border-radius: 5px; font-size: 13px; }
.sidebar-nav a span { width: 20px; color: var(--strong-line); font-family: monospace; font-size: 10px; }
.sidebar-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidebar-nav a.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; }
.sidebar-nav a.active span { color: var(--accent); }
.sidebar-footer { display: flex; align-items: center; gap: 8px; padding: 14px 24px 18px; color: var(--muted); border-top: 1px solid var(--line); font-size: 10px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #2fae78; box-shadow: 0 0 0 3px color-mix(in srgb, #2fae78 18%, transparent); }
.sidebar-backdrop { display: none; }

.content { grid-column: 2; width: min(860px, calc(100% - 64px)); min-height: calc(100vh - var(--topbar)); margin: 0 auto; padding: 58px 0 30px; }
.doc-page { display: none; animation: page-in 170ms ease-out; }
.doc-page.active { display: block; }
@keyframes page-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.page-header { margin-bottom: 46px; padding-bottom: 30px; border-bottom: 1px solid var(--line); }
.home-header { display: flex; align-items: flex-start; justify-content: space-between; }
.header-mark { width: 104px; height: 104px; margin: 4px 18px 0 32px; filter: drop-shadow(0 14px 18px rgba(8, 127, 107, 0.18)); }
.eyebrow { margin: 0 0 12px; color: var(--accent); font: 800 11px/1.4 ui-monospace, monospace; }
h1 { max-width: 760px; margin: 0; font-size: clamp(34px, 6vw, 54px); line-height: 1.08; letter-spacing: 0; }
.lead { max-width: 720px; margin: 18px 0 0; color: var(--muted); font-size: 18px; line-height: 1.7; }
section { margin: 42px 0; }
h2 { margin: 0 0 16px; font-size: 24px; line-height: 1.3; letter-spacing: 0; }
h3 { margin: 0; font-size: 17px; line-height: 1.4; letter-spacing: 0; }
p { margin: 10px 0; }
ul, ol { padding-left: 23px; }
li { margin: 7px 0; }

.endpoint-strip { display: grid; grid-template-columns: 1fr 1fr; margin: -22px 0 42px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.endpoint-strip div { min-width: 0; padding: 14px 16px; }
.endpoint-strip div + div { border-left: 1px solid var(--line); }
.endpoint-strip span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 11px; font-weight: 700; }
.endpoint-strip code { padding: 0; border: 0; background: transparent; font-size: 12px; }

.route-map { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: var(--surface); }
.route-map a { position: relative; display: flex; gap: 11px; min-width: 0; padding: 18px 14px; color: var(--text); }
.route-map a + a { border-left: 1px solid var(--line); }
.route-map a:not(:last-child)::after { content: "›"; position: absolute; right: -5px; top: 22px; z-index: 1; color: var(--strong-line); background: var(--surface); }
.route-map a:hover { background: var(--surface-2); text-decoration: none; }
.route-map b { display: grid; flex: 0 0 27px; width: 27px; height: 27px; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); font: 800 11px/1 monospace; }
.route-map span { display: grid; min-width: 0; }
.route-map strong { font-size: 13px; }
.route-map small { margin-top: 3px; color: var(--muted); font-size: 10px; }

.topic-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.topic { display: grid; grid-template-columns: 38px 1fr; align-items: center; min-height: 86px; padding: 15px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--text); }
.topic:hover { border-color: var(--strong-line); text-decoration: none; transform: translateY(-1px); }
.topic-icon { grid-row: 1 / 3; color: var(--accent); font: 800 16px/1 monospace; }
.topic strong { font-size: 14px; }
.topic small { color: var(--muted); font-size: 11px; }

.steps { display: grid; gap: 0; padding: 0; list-style: none; }
.steps li { display: grid; grid-template-columns: 44px 1fr; gap: 14px; margin: 0; padding: 20px 0; border-bottom: 1px solid var(--line); }
.steps li > span { display: grid; width: 32px; height: 32px; place-items: center; border: 1px solid var(--strong-line); border-radius: 50%; color: var(--accent-strong); font: 800 12px/1 monospace; }
.steps p { color: var(--muted); }

.client-directory { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 24px 0 32px; }
.client-directory a { display: grid; grid-template-columns: 38px 1fr; align-items: center; min-height: 90px; padding: 15px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--text); }
.client-directory a:hover { border-color: var(--strong-line); text-decoration: none; transform: translateY(-1px); }
.client-directory span { grid-row: 1 / 3; color: var(--accent); font: 800 11px/1 monospace; }
.client-directory strong { font-size: 14px; }
.client-directory small { color: var(--muted); font-size: 11px; }

.related-links { display: grid; margin: 0; padding: 0; border-top: 1px solid var(--line); list-style: none; }
.related-links li { margin: 0; border-bottom: 1px solid var(--line); }
.related-links a { display: block; padding: 12px 2px; font-size: 13px; }

.callout { margin: 28px 0; padding: 17px 19px; border-left: 3px solid var(--accent); border-radius: 0 6px 6px 0; background: var(--accent-soft); }
.callout.warning { border-color: var(--amber); background: var(--amber-soft); }
.callout strong { display: block; font-size: 13px; }
.callout p { margin: 5px 0 0; color: var(--muted); }

.doc-figure { margin: 26px 0 38px; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.doc-figure a { display: block; background: var(--surface-2); }
.doc-figure a:hover { text-decoration: none; }
.doc-figure img { display: block; width: 100%; height: auto; max-height: 680px; object-fit: contain; }
.doc-figure figcaption { display: flex; align-items: baseline; gap: 10px; padding: 12px 15px; border-top: 1px solid var(--line); }
.doc-figure figcaption strong { flex: 0 0 auto; font-size: 12px; }
.doc-figure figcaption span { color: var(--muted); font-size: 11px; }

.data-table { overflow-x: auto; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 13px 15px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
tr:last-child th, tr:last-child td { border-bottom: 0; }
th { color: var(--muted); font-size: 11px; font-weight: 800; }
tbody th { width: 180px; color: var(--text); }

.code-block { position: relative; margin: 18px 0 26px; overflow: hidden; border: 1px solid var(--strong-line); border-radius: 7px; background: var(--code-bg); color: var(--code-text); box-shadow: 0 8px 25px rgba(0,0,0,0.08); }
.code-head { display: flex; align-items: center; justify-content: space-between; height: 40px; padding: 0 8px 0 15px; color: #9fb0a8; border-bottom: 1px solid #2d3833; font: 700 10px/1 monospace; }
.copy-button { display: grid; width: 29px; height: 29px; place-items: center; padding: 0; border: 1px solid transparent; border-radius: 5px; background: transparent; color: #afbeb7; cursor: pointer; }
.copy-button:hover { border-color: #3b4943; background: #202a26; color: white; }
pre { margin: 0; padding: 19px; overflow-x: auto; font-size: 12px; line-height: 1.7; }
pre code { padding: 0; border: 0; border-radius: 0; background: transparent; color: inherit; overflow-wrap: normal; }

.check-list { padding: 0; list-style: none; }
.check-list li { position: relative; padding-left: 28px; }
.check-list li::before { content: "✓"; position: absolute; left: 0; color: var(--accent); font-weight: 900; }

.faq-list { display: grid; gap: 8px; }
details { border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
summary { display: flex; align-items: center; gap: 12px; padding: 15px 17px; cursor: pointer; font-weight: 700; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; margin-left: auto; color: var(--muted); font-size: 20px; font-weight: 400; }
details[open] summary::after { content: "−"; }
summary span { min-width: 48px; color: var(--accent-strong); font: 800 11px/1 monospace; }
details div { padding: 0 17px 15px 77px; color: var(--muted); }

.content-footer { display: flex; justify-content: space-between; margin-top: 64px; padding: 22px 0 10px; color: var(--muted); border-top: 1px solid var(--line); font-size: 11px; }
.page-outline { position: fixed; top: calc(var(--topbar) + 58px); right: 0; width: var(--outline); padding: 0 25px 24px; }
.page-outline > p { color: var(--muted); font-size: 10px; font-weight: 800; }
.page-outline nav { display: grid; border-left: 1px solid var(--line); }
.page-outline a { padding: 5px 0 5px 13px; color: var(--muted); font-size: 11px; }
.page-outline a:hover { color: var(--text); text-decoration: none; }

.search-dialog { width: min(650px, calc(100vw - 28px)); max-height: min(680px, calc(100vh - 48px)); padding: 0; border: 1px solid var(--strong-line); border-radius: 8px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.search-dialog::backdrop { background: rgba(7, 12, 10, 0.55); backdrop-filter: blur(3px); }
.search-box { position: relative; padding: 18px; border-bottom: 1px solid var(--line); }
.search-box label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 11px; font-weight: 800; }
.search-box input { width: 100%; height: 44px; padding: 0 44px 0 13px; border: 1px solid var(--strong-line); border-radius: 6px; background: var(--bg); color: var(--text); outline: none; }
.search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dialog-close { position: absolute; top: 13px; right: 16px; }
.search-results { max-height: 480px; overflow-y: auto; padding: 8px; }
.search-result { display: grid; padding: 12px; border-radius: 5px; color: var(--text); }
.search-result:hover { background: var(--surface-2); text-decoration: none; }
.search-result strong { font-size: 13px; }
.search-result small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.search-empty { padding: 32px 18px; color: var(--muted); text-align: center; }

.toast { position: fixed; z-index: 80; right: 20px; bottom: 20px; padding: 9px 13px; border-radius: 5px; background: var(--text); color: var(--bg); font-size: 12px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: 160ms ease; }
.toast.show { opacity: 1; transform: none; }

@media (max-width: 1120px) {
  .site-shell { grid-template-columns: var(--sidebar) minmax(0, 1fr); }
  .page-outline { display: none; }
  .content { width: min(860px, calc(100% - 56px)); }
}

@media (max-width: 760px) {
  :root { --topbar: 58px; }
  .topbar-inner { gap: 10px; padding: 0 12px; }
  .mobile-menu { display: inline-grid; }
  .brand { min-width: 0; }
  .brand img { width: 30px; height: 30px; }
  .brand-copy small { display: none; }
  .search-trigger { width: 38px; margin-left: auto; padding: 0; justify-content: center; }
  .search-trigger span:last-child { display: none; }
  .top-actions { gap: 7px; margin-left: 0; }
  .top-actions a { display: none; }
  .site-shell { display: block; }
  .sidebar { transform: translateX(-100%); width: min(290px, 85vw); transition: transform 180ms ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .sidebar-backdrop { position: fixed; z-index: 15; inset: var(--topbar) 0 0; display: block; background: rgba(7, 12, 10, 0.45); opacity: 0; pointer-events: none; transition: opacity 180ms ease; }
  .sidebar-backdrop.open { opacity: 1; pointer-events: auto; }
  .content { width: calc(100% - 32px); padding-top: 34px; }
  .page-header { margin-bottom: 32px; padding-bottom: 24px; }
  .home-header { align-items: center; }
  .header-mark { width: 66px; height: 66px; margin: 0 0 0 18px; }
  h1 { font-size: 36px; }
  .lead { font-size: 16px; }
  .endpoint-strip { grid-template-columns: 1fr; }
  .endpoint-strip div + div { border-top: 1px solid var(--line); border-left: 0; }
  .route-map { grid-template-columns: 1fr 1fr; }
  .route-map a + a { border-left: 0; }
  .route-map a:nth-child(even) { border-left: 1px solid var(--line); }
  .route-map a:nth-child(n+3) { border-top: 1px solid var(--line); }
  .route-map a::after { display: none; }
  .topic-grid { grid-template-columns: 1fr; }
  .client-directory { grid-template-columns: 1fr; }
  .doc-figure figcaption { align-items: flex-start; flex-direction: column; gap: 2px; }
  th, td { min-width: 140px; }
  details div { padding-left: 17px; }
  .content-footer { align-items: flex-start; gap: 12px; }
}

@media (max-width: 430px) {
  .brand-copy strong { font-size: 13px; }
  .home-header { display: block; }
  .header-mark { display: none; }
  .route-map { grid-template-columns: 1fr; }
  .route-map a:nth-child(even) { border-left: 0; }
  .route-map a:nth-child(n+2) { border-top: 1px solid var(--line); }
  .steps li { grid-template-columns: 38px 1fr; }
}

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