:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #667085;
  --line: #d9e0ea;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --accent: #0f766e;
  --soft: #eef4ff;
  --code-bg: #111827;
  --code-text: #e5e7eb;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.76 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); text-decoration: underline; }
.skip-link {
  position: fixed;
  left: 12px;
  top: 12px;
  z-index: 20;
  transform: translateY(-64px);
  padding: 8px 12px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  font-weight: 700;
}
.skip-link:focus { transform: translateY(0); }
.layout { min-height: 100vh; display: grid; grid-template-columns: 300px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 28px 20px;
  border-right: 1px solid var(--line);
  background: #fff;
}
.brand { margin-bottom: 26px; }
.brand-title { font-size: 20px; font-weight: 800; color: #111827; }
.brand-subtitle { margin-top: 5px; color: var(--muted); font-size: 14px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  color: #374151;
  font-size: 15px;
}
.nav a.active { background: var(--soft); color: var(--brand-dark); font-weight: 700; }
.nav a:hover { background: #f1f5f9; text-decoration: none; }
.main { min-width: 0; padding: 28px 18px 48px; }
.doc-shell { max-width: none; margin: 0 auto; }
.doc-header {
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 15px;
}
.doc-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.doc-header a { font-weight: 600; }
.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  align-items: start;
  gap: 24px;
}
.doc {
  min-width: 0;
  padding: 42px 50px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.05);
}
.toc {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 22px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}
.toc-title {
  margin-bottom: 10px;
  color: #111827;
  font-size: 14px;
  font-weight: 800;
}
.toc-nav { display: flex; flex-direction: column; gap: 5px; }
.toc-nav a {
  display: block;
  padding: 3px 0;
  color: #475467;
  font-size: 14px;
  line-height: 1.45;
}
.toc-nav a:hover { color: var(--brand-dark); }
.toc-nav a.toc-h3 { padding-left: 12px; color: #667085; }
h1, h2, h3, h4 { line-height: 1.28; color: #111827; }
h1 { margin: 0 0 24px; padding-bottom: 16px; border-bottom: 1px solid var(--line); font-size: 38px; }
h2 { margin-top: 38px; padding-top: 8px; font-size: 29px; }
h3 { margin-top: 28px; font-size: 22px; }
h4 { margin-top: 24px; font-size: 19px; }
.doc :target { scroll-margin-top: 24px; }
p, ul, ol, table, pre, blockquote { margin-top: 0; margin-bottom: 16px; }
ul, ol { padding-left: 1.45rem; }
li + li { margin-top: 4px; }
table { width: 100%; border-collapse: collapse; display: block; overflow-x: auto; }
th, td { border: 1px solid var(--line); padding: 11px 13px; vertical-align: top; }
th { background: #f8fafc; font-weight: 700; }
tbody tr:nth-child(even) { background: #fbfcfe; }
code {
  padding: 2px 5px;
  border-radius: 5px;
  background: #eef2f7;
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  font-size: 0.92em;
}
pre { overflow: auto; padding: 18px; border-radius: 12px; background: var(--code-bg); color: var(--code-text); }
pre code { padding: 0; background: transparent; color: inherit; }
blockquote {
  margin-left: 0;
  padding: 12px 18px;
  border-left: 4px solid var(--accent);
  background: #f8fafc;
  color: #374151;
}
img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 16px auto 22px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}
hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }
.footer-nav {
  margin-top: 36px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.footer-nav a { font-weight: 700; }
@media (max-width: 1180px) {
  .content-grid { display: block; }
  .toc { position: static; max-height: none; margin-bottom: 16px; }
  .toc-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; }
  .toc-nav a.toc-h3 { padding-left: 0; }
}
@media (max-width: 900px) {
  .layout { display: block; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main { padding: 20px 12px 36px; }
  .doc { padding: 24px 18px; border-radius: 10px; }
  .doc-header { display: block; }
  .doc-actions { margin-top: 6px; justify-content: flex-start; }
  .toc-nav { display: block; }
  h1 { font-size: 26px; }
  h2 { font-size: 21px; }
}
@media (max-width: 560px) {
  body { font-size: 15px; }
  .nav { grid-template-columns: 1fr; }
  .footer-nav { display: block; }
  .footer-nav span { display: block; margin-top: 8px; }
}
@media print {
  body { background: #fff; }
  .layout { display: block; }
  .skip-link, .sidebar, .doc-header, .toc, .footer-nav { display: none; }
  .main, .doc-shell, .doc { padding: 0; margin: 0; max-width: none; border: 0; box-shadow: none; }
  .content-grid { display: block; }
  a { color: #111827; text-decoration: none; }
  img { box-shadow: none; page-break-inside: avoid; }
}
