:root {
  --bg: #f4f5f7; --card: #ffffff; --text: #1d232b; --quiet: #5d6875; --line: #dde1e6;
  --accent: #1f6feb; --accent-soft: #e7f0fe; --header: #1d232b; --key: #eef1f4; --warn: #9a5b00; --warn-soft: #fff4e0;
  --good: #1a7f37; --good-soft: #e6f4ea;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161b; --card: #1b2128; --text: #e6e9ed; --quiet: #9aa5b1; --line: #2c343d;
    --accent: #5b9dff; --accent-soft: #1d2d45; --header: #0b0e12; --key: #262e37; --warn: #f0b45a; --warn-soft: #33270f;
    --good: #5ccb7a; --good-soft: #15291c;
  }
}
* { box-sizing: border-box; }
html { scroll-padding-top: 72px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.6 "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif; }
header.top { position: sticky; top: 0; z-index: 10; background: var(--header); color: #fff; display: flex; align-items: center; gap: 16px; padding: 10px 20px; }
header.top .brand { font-weight: 700; letter-spacing: .5px; }
header.top .brand small { font-weight: 400; color: #b9c0c9; margin-left: 8px; }
header.top input { flex: 1; max-width: 360px; margin-left: auto; padding: 7px 10px; border-radius: 6px; border: 0; font: inherit; font-size: 15px; }
header.top nav.lang a { color: #b9c0c9; text-decoration: none; padding: 4px 8px; border-radius: 4px; font-size: 15px; }
header.top nav.lang a.on { background: #fff; color: var(--header); font-weight: 600; }
.layout { display: grid; grid-template-columns: 290px 1fr; max-width: 1280px; margin: 0 auto; }
aside.toc { position: sticky; top: 56px; align-self: start; max-height: calc(100vh - 56px); overflow: auto; padding: 20px 12px 40px 20px; font-size: 14.5px; }
aside.toc ol { list-style: none; margin: 0; padding: 0; }
aside.toc ol ol { padding-left: 14px; margin: 2px 0 8px; }
aside.toc a { display: block; color: var(--text); text-decoration: none; padding: 3px 8px; border-radius: 4px; }
aside.toc a:hover, aside.toc a.on { background: var(--accent-soft); color: var(--accent); }
aside.toc > ol > li > a { font-weight: 600; margin-top: 6px; }
main { padding: 20px 28px 80px; min-width: 0; }
section.chapter { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 28px 20px; margin-bottom: 22px; }
h1 { font-size: 30px; margin: 18px 0 6px; }
h2 { font-size: 24px; margin: 22px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
h3 { font-size: 19px; margin: 24px 0 6px; }
h4 { font-size: 16px; margin: 18px 0 4px; }
p, li { max-width: 78ch; }
a { color: var(--accent); }
kbd { display: inline-block; min-width: 1.6em; text-align: center; padding: 0 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; background: var(--key); font: 600 13.5px/1.6 Consolas, monospace; white-space: nowrap; }
code { background: var(--key); padding: 1px 5px; border-radius: 4px; font: 14px Consolas, monospace; }
.ui { font-weight: 600; }
table { border-collapse: collapse; width: 100%; margin: 10px 0 16px; font-size: 15px; }
th, td { text-align: left; vertical-align: top; padding: 7px 10px; border-bottom: 1px solid var(--line); }
th { background: var(--key); font-weight: 600; }
td:first-child { white-space: nowrap; }
.note, .warn, .tip { border-radius: 8px; padding: 10px 14px; margin: 12px 0; max-width: 82ch; }
.note { background: var(--accent-soft); }
.warn { background: var(--warn-soft); border-left: 4px solid var(--warn); }
.tip { background: var(--good-soft); border-left: 4px solid var(--good); }
.note > :first-child, .warn > :first-child, .tip > :first-child { margin-top: 0; }
.note > :last-child, .warn > :last-child, .tip > :last-child { margin-bottom: 0; }
ol.steps { counter-reset: s; list-style: none; padding-left: 0; }
ol.steps > li { counter-increment: s; position: relative; padding-left: 40px; margin: 10px 0; }
ol.steps > li::before { content: counter(s); position: absolute; left: 0; top: 1px; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; text-align: center; line-height: 28px; font-size: 14px; }
figure { margin: 14px 0 20px; }
figure img { max-width: 100%; border: 1px solid var(--line); border-radius: 8px; display: block; }
figcaption { color: var(--quiet); font-size: 14px; margin-top: 4px; }
.hidden { display: none !important; }
.empty { color: var(--quiet); padding: 30px; text-align: center; }
.top-link { position: fixed; right: 18px; bottom: 18px; background: var(--accent); color: #fff; border-radius: 50%; width: 42px; height: 42px; text-align: center; line-height: 42px; text-decoration: none; font-size: 20px; opacity: .85; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  aside.toc { position: static; max-height: none; border-bottom: 1px solid var(--line); }
  main { padding: 16px; }
  section.chapter { padding: 4px 16px 16px; }
  header.top { flex-wrap: wrap; }
  header.top input { order: 3; max-width: none; flex-basis: 100%; min-width: 0; margin-left: 0; }
  aside.toc ol ol { display: none; }
  table { display: block; overflow-x: auto; }
}
@media print {
  header.top, aside.toc, .top-link { display: none; }
  .layout { display: block; }
  section.chapter { border: 0; page-break-after: always; }
  body { background: #fff; color: #000; }
}
