:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #1f2733;
  --muted: #6b7684;
  --line: #e3e8f0;
  --brand: #0f7ce8;
  --brand-soft: rgba(15, 124, 232, .10);
  --accent: #7c5cff;
  --ok: #21a366;
  --warn: #d9822b;
  --code-bg: #f2f5fa;
  --radius: 12px;
  --sidebar-w: 288px;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 8px 24px rgba(20, 30, 50, .06);
}

html[data-theme="dark"] {
  --bg: #141922;
  --panel: #1b2130;
  --text: #e6ebf3;
  --muted: #97a2b3;
  --line: #2a3341;
  --brand: #5b9dff;
  --brand-soft: rgba(91, 157, 255, .16);
  --code-bg: #222a38;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }

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

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

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

.sidebar {
  position: sticky;
  top: 0;
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  height: 100vh;
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 18px 14px 40px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 14px; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 10px; flex: 0 0 36px;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 18px;
}
.brand-title { font-weight: 700; font-size: 15px; line-height: 1.3; }
.brand-sub { font-size: 11px; color: var(--muted); }

.search {
  width: 100%; margin: 4px 0 12px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text); font: inherit; font-size: 13px;
}
.search:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }

.nav-group { margin-bottom: 6px; }
.nav-cap {
  padding: 10px 10px 6px; font-size: 11px; letter-spacing: 1px;
  color: var(--muted); font-weight: 700;
}
.nav-group + .nav-group { border-top: 1px solid var(--line); }
.navlink {
  display: block; padding: 7px 10px; border-radius: 9px;
  color: var(--muted); font-size: 13.5px; cursor: pointer;
  border: 1px solid transparent;
}
.navlink:hover { background: var(--brand-soft); color: var(--text); }
.navlink.on {
  background: var(--brand-soft); color: var(--brand);
  font-weight: 700; border-color: rgba(15, 124, 232, .35);
}
.navlink.hide { display: none; }
.nav-empty { padding: 10px; font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------- 内容 */
.content { flex: 1 1 auto; min-width: 0; padding: 26px 30px 80px; }
.wrap { max-width: 980px; margin: 0 auto; }

header.hero {
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: #fff; border-radius: 16px; padding: 26px 28px; margin-bottom: 26px;
  box-shadow: var(--shadow);
}
header.hero h1 { margin: 0 0 6px; font-size: 26px; }
header.hero p { margin: 0; opacity: .92; font-size: 14px; }
.hero-tags { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.hero-tags span {
  background: rgba(255, 255, 255, .18); border: 1px solid rgba(255, 255, 255, .3);
  padding: 3px 10px; border-radius: 999px; font-size: 12px;
}

section.doc {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 26px; margin-bottom: 18px;
  box-shadow: var(--shadow); scroll-margin-top: 16px;
}
section.doc > h2 {
  margin: 0 0 4px; font-size: 20px; display: flex; align-items: center; gap: 10px;
}
section.doc > h2 .idx {
  font-size: 12px; color: #fff; background: var(--brand);
  border-radius: 8px; padding: 2px 8px; font-weight: 700;
}
section.doc > .lead { color: var(--muted); font-size: 13.5px; margin: 0 0 16px; }
h3 { font-size: 16px; margin: 22px 0 8px; padding-left: 10px; border-left: 3px solid var(--brand); }
h4 { font-size: 14.5px; margin: 16px 0 6px; color: var(--text); }
p { margin: 8px 0; }
ul, ol { margin: 8px 0; padding-left: 22px; }
li { margin: 4px 0; }

table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13.5px; }
th, td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
th { background: var(--code-bg); font-weight: 700; white-space: nowrap; }
td p { margin: 2px 0; }

code, kbd {
  background: var(--code-bg); border: 1px solid var(--line);
  border-radius: 6px; padding: 1px 6px; font-size: 12.5px;
  font-family: "Cascadia Mono", Consolas, monospace;
}

figure { margin: 14px 0; }
figure img {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  display: block; background: #fff; cursor: zoom-in;
}
figure figcaption { font-size: 12.5px; color: var(--muted); margin-top: 6px; text-align: center; }

.tip, .warn, .ok {
  border-radius: 10px; padding: 10px 14px; margin: 12px 0; font-size: 13.5px;
  border: 1px solid var(--line); background: var(--code-bg);
}
.tip { border-left: 4px solid var(--brand); }
.warn { border-left: 4px solid var(--warn); }
.ok { border-left: 4px solid var(--ok); }
.tip b, .warn b, .ok b { color: var(--text); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } }

.steps { counter-reset: s; list-style: none; padding: 0; }
.steps li {
  counter-increment: s; position: relative; padding: 8px 0 8px 40px;
  border-bottom: 1px dashed var(--line);
}
.steps li:last-child { border-bottom: 0; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 8px;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 13px; font-weight: 700;
  display: grid; place-items: center;
}

details.faq { border: 1px solid var(--line); border-radius: 10px; padding: 0; margin: 8px 0; background: var(--bg); }
details.faq summary {
  cursor: pointer; padding: 10px 14px; font-weight: 700; font-size: 14px; list-style: none;
}
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::before { content: "＋ "; color: var(--brand); }
details.faq[open] summary::before { content: "－ "; }
details.faq .body { padding: 0 14px 12px; font-size: 13.5px; color: var(--text); }

.badge {
  display: inline-block; font-size: 11.5px; padding: 1px 8px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand); border: 1px solid rgba(15, 124, 232, .3);
}
.badge.new { background: rgba(33, 163, 102, .12); color: var(--ok); border-color: rgba(33, 163, 102, .35); }

footer.foot { text-align: center; color: var(--muted); font-size: 12.5px; padding: 10px 0 40px; }

/* ------------------------------------------------------------- 小工具 */
.topbar-tools {
  position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 20;
}
.topbar-tools button {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); cursor: pointer; font-size: 16px;
  box-shadow: var(--shadow);
}
.topbar-tools button:hover { color: var(--brand); border-color: var(--brand); }

#menuBtn { display: none; }
@media (max-width: 900px) {
  #menuBtn {
    display: grid; place-items: center; position: fixed; left: 14px; bottom: 18px; z-index: 30;
    width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line);
    background: var(--panel); color: var(--text); box-shadow: var(--shadow); font-size: 18px;
  }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: var(--shadow);
  }
  body.nav-open .sidebar { transform: none; }
  .content { padding: 18px 14px 70px; }
}

/* 图片放大预览 */
.lightbox {
  position: fixed; inset: 0; background: rgba(10, 14, 22, .82); z-index: 99;
  display: none; place-items: center; padding: 24px; cursor: zoom-out;
}
.lightbox.on { display: grid; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .5); }
