:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #667085;
  --subtle: #8a94a6;
  --line: #dfe5ec;
  --surface: #ffffff;
  --canvas: #f5f7fa;
  --accent: #2563eb;
  --accent-soft: #eaf1ff;
  --good: #16845b;
  --code: #f0f3f7;
  --shadow: 0 12px 36px rgba(23, 32, 51, 0.07);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--canvas); color: var(--ink); font-size: 16px; line-height: 1.65; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid rgba(37, 99, 235, 0.35); outline-offset: 3px; }

.skip-link { position: fixed; left: 16px; top: 12px; z-index: 20; padding: 8px 12px; color: #fff; background: var(--ink); border-radius: 6px; transform: translateY(-150%); transition: transform 180ms ease; }
.skip-link:focus { transform: translateY(0); }
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner { width: min(1280px, calc(100% - 40px)); min-height: 76px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; color: #fff; background: var(--ink); border-radius: 8px; font-size: 12px; font-weight: 800; letter-spacing: 0; }
.brand strong, .brand small { display: block; line-height: 1.2; }
.brand strong { font-size: 15px; }
.brand small { margin-top: 4px; color: var(--muted); font-size: 12px; }
.header-actions { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 4px #e3f5ed; }
.dashboard-link { margin-left: 4px; padding: 8px 12px; color: var(--accent); border: 1px solid #b9c7da; border-radius: 6px; font-weight: 700; }
.dashboard-link:hover { background: var(--accent-soft); text-decoration: none; }
.download-link { margin-left: 12px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); font-weight: 600; }
.download-link:hover { border-color: #b9c7da; background: #fafcff; text-decoration: none; }

.page-shell { width: min(1280px, calc(100% - 40px)); margin: 32px auto 80px; display: grid; grid-template-columns: 228px minmax(0, 1fr); gap: 32px; align-items: start; }
.toc-panel { position: sticky; top: 24px; max-height: calc(100vh - 48px); overflow: auto; padding: 18px 14px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.toc-heading { padding: 0 10px 12px; color: var(--ink); border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 800; letter-spacing: 0; text-transform: uppercase; }
#toc { padding-top: 8px; }
#toc a { display: block; padding: 5px 10px; color: var(--muted); font-size: 13px; line-height: 1.45; border-left: 2px solid transparent; }
#toc a:hover { color: var(--accent); border-left-color: var(--accent); text-decoration: none; }
#toc .toc-level-3 { padding-left: 22px; color: var(--subtle); font-size: 12px; }
.document { min-width: 0; }
.prose { padding: 44px 56px 52px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.prose > :first-child { margin-top: 0; }
.prose h1 { margin: 0 0 20px; color: var(--ink); font-size: clamp(30px, 4vw, 46px); line-height: 1.2; letter-spacing: 0; }
.prose h2 { scroll-margin-top: 24px; margin: 50px 0 16px; padding-top: 22px; border-top: 1px solid var(--line); color: var(--ink); font-size: 25px; line-height: 1.3; letter-spacing: 0; }
.prose h3 { scroll-margin-top: 24px; margin: 30px 0 10px; color: var(--ink); font-size: 19px; line-height: 1.4; letter-spacing: 0; }
.prose h4 { margin: 22px 0 8px; font-size: 16px; }
.prose p { margin: 13px 0; }
.prose blockquote { margin: 20px 0; padding: 14px 18px; color: #4f5e73; background: #f7f9fc; border-left: 4px solid var(--accent); }
.prose ul, .prose ol { margin: 12px 0 18px; padding-left: 26px; }
.prose li { margin: 5px 0; }
.prose code { padding: 2px 5px; color: #26344a; background: var(--code); border: 1px solid #e3e8ef; border-radius: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.88em; }
.prose pre { max-width: 100%; margin: 18px 0; padding: 17px 18px; overflow: auto; color: #eef4ff; background: #172033; border-radius: 6px; line-height: 1.55; }
.prose pre code { padding: 0; color: inherit; background: transparent; border: 0; font-size: 13px; }
.prose table { display: block; width: 100%; margin: 20px 0; overflow-x: auto; border-collapse: collapse; border: 1px solid var(--line); font-size: 14px; }
.prose th, .prose td { min-width: 120px; padding: 10px 12px; text-align: left; vertical-align: top; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.prose th { color: var(--ink); background: #f7f9fc; font-weight: 700; white-space: nowrap; }
.prose tr:last-child td { border-bottom: 0; }
.prose tr > :last-child { border-right: 0; }
.prose hr { margin: 28px 0; border: 0; border-top: 1px solid var(--line); }
.prose img { max-width: 100%; height: auto; }
.loading, .error { color: var(--muted); }
.error { padding: 18px; background: #fff5f5; border: 1px solid #ffd7d7; border-radius: 6px; }
.mobile-toolbar, .mobile-toc { display: none; }
.document-footer { display: flex; justify-content: space-between; gap: 16px; margin-top: 16px; padding: 0 4px; color: var(--muted); font-size: 12px; }

@media (max-width: 900px) {
  .page-shell { grid-template-columns: 1fr; }
  .toc-panel { display: none; }
  .mobile-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
  .mobile-toolbar button { min-height: 40px; padding: 8px 12px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
  .mobile-toolbar a { padding: 8px 0; font-size: 13px; }
  .mobile-toc { display: block; margin-bottom: 12px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
  #toc-mobile a { display: block; padding: 5px 6px; font-size: 13px; }
  #toc-mobile .toc-level-3 { padding-left: 18px; color: var(--muted); font-size: 12px; }
}

@media (max-width: 640px) {
  .header-inner, .page-shell { width: min(100% - 24px, 1280px); }
  .header-inner { min-height: 66px; }
  .header-actions .status-label, .header-actions .status-dot { display: none; }
  .dashboard-link, .download-link { margin-left: 0; padding: 7px 9px; font-size: 12px; }
  .page-shell { margin-top: 16px; margin-bottom: 40px; }
  .prose { padding: 28px 20px 34px; }
  .prose h1 { font-size: 30px; }
  .prose h2 { margin-top: 38px; font-size: 22px; }
  .prose h3 { font-size: 18px; }
  .document-footer { display: block; }
  .document-footer a { display: block; margin-top: 6px; }
}

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