:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1c1c1e;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #0a84ff;
  --accent-soft: #e8f1ff;
  --code-bg: #11161f;
  --code-text: #e6edf3;
  --ok: #16a34a;
  --warn: #d97706;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --card: #151b24;
    --text: #e6edf3;
    --muted: #9aa4b2;
    --line: #232b36;
    --accent: #4aa3ff;
    --accent-soft: #16273d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

html { scroll-padding-top: 24px; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.7 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* 顶部栏 */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar .inner {
  max-width: 1180px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; gap: 14px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .2px; }
.brand .dot {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, #5b8def, #8fb6ff);
  display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 800;
}
.topnav { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.topnav a {
  padding: 6px 12px; border-radius: 8px; color: var(--muted); font-size: 14px;
}
.topnav a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.topnav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* 通用卡片 */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow);
}
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; }

/* 首页 */
.hero { padding: 54px 0 28px; }
.hero h1 { font-size: 40px; line-height: 1.22; margin: 0 0 14px; letter-spacing: -.5px; }
.hero p.lead { font-size: 17px; color: var(--muted); margin: 0 0 24px; max-width: 720px; }
.badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 999px; font-size: 13px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.btnrow { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px; border-radius: 10px; font-weight: 600; font-size: 15px;
  background: var(--accent); color: #fff; border: 1px solid transparent;
}
.btn:hover { text-decoration: none; filter: brightness(1.06); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }

.grid { display: grid; gap: 16px; }
.grid.c3 { grid-template-columns: repeat(3, 1fr); }
.grid.c2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .grid.c3, .grid.c2 { grid-template-columns: 1fr; } }

.stat { display: flex; align-items: baseline; gap: 8px; }
.stat b { font-size: 22px; }
.stat span { color: var(--muted); font-size: 13px; }

.navcard { display: block; color: inherit; transition: transform .12s ease, border-color .12s ease; }
.navcard:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--accent); }
.navcard h3 { margin: 0 0 6px; font-size: 16px; }
.navcard p { margin: 0; color: var(--muted); font-size: 13px; }
.navcard .count { float: right; font-size: 12px; color: var(--accent); background: var(--accent-soft); padding: 2px 8px; border-radius: 999px; }

h2.sec { font-size: 24px; margin: 44px 0 14px; letter-spacing: -.2px; }
h2.sec:first-of-type { margin-top: 28px; }

/* 文档页布局 */
.doc { display: grid; grid-template-columns: 268px minmax(0, 1fr); gap: 34px; padding: 26px 0 80px; }
.side { position: sticky; top: 74px; align-self: start; max-height: calc(100vh - 96px); overflow: auto; padding-right: 6px; }
@media (max-width: 980px) {
  .doc { grid-template-columns: 1fr; gap: 18px; }
  .side {
    position: static; max-height: 44vh; overflow: auto;
    background: var(--card); border: 1px solid var(--line);
    border-radius: 12px; padding: 12px 14px;
  }
}

/* 手机端：避免任何元素宽于视口，防止浏览器自动缩小整页 */
@media (max-width: 760px) {
  .wrap { padding: 0 14px; }
  .topbar .inner { padding: 10px 14px; gap: 8px; }
  .brand { font-size: 15px; }
  .topnav { gap: 2px; }
  .topnav a { padding: 5px 8px; font-size: 13px; }
  .hero { padding: 30px 0 16px; }
  .hero h1 { font-size: 26px; }
  .hero p.lead { font-size: 15px; }
  .card { padding: 15px 15px; }
  h2.sec { font-size: 20px; margin: 32px 0 12px; }
  .content h2 { font-size: 21px; }
  .content h3 { font-size: 16px; }
  pre { font-size: 11.5px; line-height: 1.6; padding: 12px 12px; white-space: pre-wrap; word-break: break-word; }
  pre code { white-space: pre-wrap; word-break: break-word; }
  .copy { top: 6px; right: 6px; padding: 3px 7px; font-size: 11px; }
  table { font-size: 13px; }
  th, td { padding: 7px 8px; }
  .ep { padding: 9px 11px; gap: 8px; }
  .path { font-size: 12.5px; overflow-wrap: anywhere; }
  .ep .note { margin-left: 0; width: 100%; }
  .side { max-height: 38vh; }
}

/* 超窄屏：精简顶部导航，避免吸顶栏占掉过多高度 */
@media (max-width: 560px) {
  .topbar .inner { padding: 8px 12px; }
  .brand { font-size: 14px; gap: 7px; }
  .brand .dot { width: 22px; height: 22px; border-radius: 7px; font-size: 11px; }
  .topnav a { padding: 4px 7px; font-size: 12.5px; }
  .topnav a:nth-last-child(-n+2) { display: none; }
  .side { max-height: 34vh; }
  pre { font-size: 11px; }
}

.side .search {
  width: 100%; padding: 9px 12px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-size: 14px; margin-bottom: 12px;
}
.side h4 { margin: 16px 0 6px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.side ul { list-style: none; margin: 0; padding: 0; }
.side li a {
  display: block; padding: 6px 10px; border-radius: 8px; font-size: 14px; color: var(--muted);
  border-left: 2px solid transparent;
}
.side li a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.side li a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; border-left-color: var(--accent); }

.content { min-width: 0; }
.content > section { padding-top: 18px; scroll-margin-top: 24px; }
.content h2 { font-size: 26px; margin: 34px 0 12px; letter-spacing: -.2px; }
.content h2:first-child { margin-top: 6px; }
.content h3 { font-size: 18px; margin: 26px 0 10px; }
.content h4 { font-size: 15px; margin: 20px 0 8px; color: var(--muted); }
.content p { margin: 10px 0; }

/* 表格 */
table { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 14px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 13px; background: color-mix(in srgb, var(--card) 60%, var(--bg)); }
tr:last-child td { border-bottom: 0; }
td code, p code, li code {
  background: var(--accent-soft); color: var(--accent);
  padding: 1px 6px; border-radius: 5px; font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* 代码块 */
pre {
  position: relative; margin: 14px 0; padding: 16px 18px; border-radius: 12px;
  background: var(--code-bg); color: var(--code-text); overflow: auto;
  max-width: 100%; box-sizing: border-box;
  font: 13px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
pre code { display: block; min-width: 0; }
td, th { overflow-wrap: anywhere; }
td code, td .mono, p code, li code { overflow-wrap: anywhere; }
img, svg, table, iframe { max-width: 100%; }
pre code { background: none; color: inherit; padding: 0; font-size: inherit; }
.copy {
  position: absolute; top: 8px; right: 8px; padding: 4px 9px; border-radius: 7px;
  border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.08);
  color: #cfd8e3; font-size: 12px; cursor: pointer;
}
.copy:hover { background: rgba(255,255,255,.16); }

/* 接口条 */
.ep {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-radius: 11px;
  padding: 11px 14px; margin: 12px 0;
}
.method { background: #0a84ff; color: #fff; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 6px; letter-spacing: .04em; }
.path { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; }
.ep .note { color: var(--muted); font-size: 13px; margin-left: auto; }

.callout {
  border-left: 3px solid var(--accent); background: var(--accent-soft);
  padding: 12px 16px; border-radius: 10px; margin: 16px 0; font-size: 14px;
}
.callout.warn { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }

.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--accent-soft); color: var(--accent); }
.pill.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }

footer { border-top: 1px solid var(--line); padding: 26px 0 46px; color: var(--muted); font-size: 13px; }
footer .wrap { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }

.anchor { color: var(--muted); font-weight: 400; font-size: 16px; margin-left: 6px; opacity: 0; }
h2:hover .anchor, h3:hover .anchor { opacity: 1; }
