:root {
  --navy: #102a46;
  --navy-soft: #1b3f66;
  --accent: #0b6bcb;
  --accent-soft: #e8f1fb;
  --text: #1f2933;
  --muted: #5b6b7c;
  --line: #e3e8ef;
  --bg: #ffffff;
  --bg-soft: #f5f7fa;
  --code-bg: #f4f6f9;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 42, 70, .06), 0 8px 24px rgba(16, 42, 70, .06);
  --sidebar-w: 292px;
  --toc-w: 232px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

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

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--navy);
  color: #fff;
  padding: 8px 14px;
  z-index: 100;
}
.skip-link:focus { left: 12px; top: 12px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 18px;
  height: 60px;
  padding: 0 22px;
  background: var(--navy);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #fff;
  color: var(--navy);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: .5px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15px; letter-spacing: .3px; }
.brand-text small { font-size: 11px; color: rgba(255, 255, 255, .72); }

.search-trigger {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 240px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
  background: rgba(255, 255, 255, .08);
  color: rgba(255, 255, 255, .86);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.search-trigger:hover { background: rgba(255, 255, 255, .14); }
.search-trigger kbd {
  margin-left: auto;
  font-family: inherit;
  font-size: 11px;
  color: rgba(255, 255, 255, .66);
  border: 1px solid rgba(255, 255, 255, .24);
  border-radius: 4px;
  padding: 1px 5px;
}

.icon-btn {
  display: none;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, .1);
  cursor: pointer;
}
.burger,
.burger::before,
.burger::after {
  display: block;
  width: 18px;
  height: 2px;
  margin: 0 auto;
  background: #fff;
  position: relative;
}
.burger::before, .burger::after { content: ""; position: absolute; left: 0; }
.burger::before { top: -6px; }
.burger::after { top: 6px; }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  align-items: start;
  max-width: 1560px;
  margin: 0 auto;
}

/* ---------- sidebar ---------- */
.sidebar {
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
  background: var(--bg-soft);
  border-right: 1px solid var(--line);
  scrollbar-width: thin;
}
.sidebar-inner { padding: 18px 12px 48px; }

.nav-list, .nav-list ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-list a {
  display: block;
  padding: 6px 10px;
  border-radius: 6px;
  color: #35485c;
  font-size: 13.5px;
  line-height: 1.5;
  text-decoration: none;
}
.nav-list a:hover { background: #e9eef5; color: var(--navy); text-decoration: none; }
.nav-list a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}
.nav-list ul { padding-left: 12px; }
.nav-list > li { margin: 1px 0; }

.nav-section { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.nav-section-title {
  display: block;
  padding: 0 10px 6px;
  font-size: 10.5px;
  letter-spacing: 1.2px;
  color: #8a97a6;
}
.nav-section ul { padding-left: 0; }
.toc-empty { margin: 0; color: #9aa6b4; font-size: 12px; }

.nav-group > details > summary {
  list-style: none;
  cursor: pointer;
  border-radius: 6px;
}
.nav-group > details > summary::-webkit-details-marker { display: none; }
.nav-group > details > summary::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 8px 1px 4px;
  border-right: 1.5px solid #8a97a6;
  border-bottom: 1.5px solid #8a97a6;
  transform: rotate(-45deg);
  transition: transform .15s ease;
}
.nav-group > details[open] > summary::before { transform: rotate(45deg); }
.nav-group > details > summary > a { display: inline-block; padding: 6px 8px 6px 0; }
.nav-group > details > summary > a:hover { background: transparent; text-decoration: underline; }

.sidebar-backdrop { display: none; }

/* ---------- content ---------- */
.content {
  min-width: 0;
  padding: 26px 46px 72px;
}

.breadcrumb {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 18px;
  line-height: 1.6;
}
.breadcrumb a { color: var(--muted); }
.breadcrumb .sep { margin: 0 7px; color: #b3bdca; }
.breadcrumb .current { color: var(--text); }

.doc-title {
  margin: 0 0 22px;
  font-size: 30px;
  line-height: 1.35;
  letter-spacing: -.2px;
  color: var(--navy);
  font-weight: 700;
}

.doc { font-size: 15.5px; }
.doc > :first-child { margin-top: 0; }
.doc h2 {
  margin: 44px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 22px;
  line-height: 1.45;
  color: var(--navy);
  scroll-margin-top: 76px;
}
.doc h3 {
  margin: 32px 0 10px;
  font-size: 18px;
  line-height: 1.5;
  color: var(--navy-soft);
  scroll-margin-top: 76px;
}
.doc h4 { margin: 26px 0 8px; font-size: 16px; color: var(--navy-soft); }
.doc p { margin: 0 0 14px; }
.doc ul, .doc ol { margin: 0 0 16px; padding-left: 1.6em; }
.doc li { margin: 5px 0; }
.doc li > ul, .doc li > ol { margin: 4px 0; }
.doc strong { color: #17232f; }
.doc hr { border: 0; border-top: 1px solid var(--line); margin: 30px 0; }

.doc blockquote {
  margin: 18px 0;
  padding: 12px 16px;
  border-left: 3px solid var(--accent);
  background: var(--bg-soft);
  color: #405062;
}
.doc blockquote p:last-child { margin-bottom: 0; }

.doc code {
  font-family: "Cascadia Code", Consolas, "SFMono-Regular", Menlo, monospace;
  font-size: .9em;
  background: var(--code-bg);
  padding: 1px 5px;
  border-radius: 4px;
}
.doc pre {
  overflow-x: auto;
  background: #f7f9fc;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  line-height: 1.6;
}
.doc pre code { background: transparent; padding: 0; font-size: 13px; }

.doc img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}
.doc table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0 22px;
  font-size: 14px;
  display: block;
  overflow-x: auto;
}
.doc th, .doc td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
.doc th { background: var(--bg-soft); color: var(--navy); }
.doc tr:nth-child(even) td { background: #fafbfd; }

.missing-image {
  display: inline-block;
  padding: 10px 14px;
  border: 1px dashed #c4cedb;
  border-radius: 6px;
  color: var(--muted);
  background: var(--bg-soft);
  font-size: 13px;
}

/* ---------- home ---------- */
.home-hero {
  margin: 8px 0 34px;
  padding: 34px 36px;
  border-radius: 14px;
  background: linear-gradient(135deg, #102a46 0%, #1d4775 100%);
  color: #fff;
  box-shadow: var(--shadow);
}
.home-hero h2 { margin: 6px 0 12px; font-size: 26px; border: 0; color: #fff; padding: 0; }
.home-hero p { margin: 0; color: rgba(255, 255, 255, .82); max-width: 720px; }
.home-eyebrow {
  font-size: 12px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .62) !important;
}

/* ---------- page toc ---------- */
.page-toc {
  position: sticky;
  top: 60px;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  padding: 30px 20px 40px 0;
  font-size: 12.5px;
  scrollbar-width: thin;
}
.page-toc-title {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: 1.2px;
  color: #8a97a6;
  text-transform: uppercase;
}
.page-toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.page-toc li { margin: 0; }
.page-toc a {
  display: block;
  padding: 4px 0 4px 12px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--muted);
  line-height: 1.5;
}
.page-toc a:hover, .page-toc a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  text-decoration: none;
}
.page-toc .toc-h3 { padding-left: 24px; }

/* ---------- pager ---------- */
.pager {
  display: flex;
  gap: 16px;
  margin-top: 56px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.pager a {
  flex: 1;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  text-decoration: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.pager a:hover { border-color: #b9c6d6; box-shadow: var(--shadow); text-decoration: none; }
.pager .label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.pager .next { text-align: right; }

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
  padding: 22px 24px 30px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.site-footer p { margin: 0; }
.site-footer a { color: var(--accent); }

/* ---------- search ---------- */
.search-overlay[hidden] { display: none; }
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(16, 42, 70, .38);
  display: flex;
  justify-content: center;
  padding: 9vh 18px 18px;
}
.search-panel {
  width: min(720px, 100%);
  max-height: 74vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 24px 70px rgba(16, 42, 70, .28);
  overflow: hidden;
}
.search-box { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.search-box input {
  flex: 1;
  border: 0;
  outline: 0;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: transparent;
}
.search-box button {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--muted);
  border-radius: 6px;
  padding: 2px 8px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
.search-results { overflow-y: auto; padding: 8px; }
.search-hint { margin: 10px; color: var(--muted); font-size: 13px; }
.search-hit {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}
.search-hit:hover, .search-hit.selected { background: var(--accent-soft); text-decoration: none; }
.search-hit .hit-title { font-weight: 600; color: var(--navy); font-size: 14.5px; }
.search-hit .hit-path { font-size: 11px; color: var(--muted); margin-top: 1px; }
.search-hit .hit-snippet { font-size: 12.5px; color: var(--muted); margin-top: 4px; line-height: 1.55; }
.search-hit mark { background: #ffe9a8; color: inherit; padding: 0 1px; border-radius: 2px; }

/* ---------- 404 ---------- */
.notfound { padding: 90px 24px; max-width: 720px; margin: 0 auto; text-align: center; }
.notfound-code { font-size: 72px; font-weight: 800; color: #dbe3ec; margin: 0; line-height: 1; }
.notfound h1 { margin: 12px 0 10px; color: var(--navy); }
.button {
  display: inline-block;
  margin-top: 12px;
  padding: 9px 18px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}
.button:hover { text-decoration: none; background: #0a5cb0; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  :root { --sidebar-w: 264px; --toc-w: 0px; }
  .page-toc { display: none; }
}
@media (max-width: 980px) {
  :root { --sidebar-w: 280px; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .icon-btn { display: block; }
  .content { padding: 22px 26px 64px; }
  .sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    z-index: 50;
    width: var(--sidebar-w);
    transform: translateX(-102%);
    transition: transform .22s ease;
    box-shadow: 0 18px 40px rgba(16, 42, 70, .18);
  }
  body.sidebar-open .sidebar { transform: none; }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 60px 0 0;
    z-index: 45;
    background: rgba(16, 42, 70, .3);
  }
  .sidebar-backdrop[hidden] { display: none; }
}
@media (max-width: 620px) {
  .topbar { padding: 0 14px; gap: 12px; }
  .search-trigger { min-width: 0; }
  .search-trigger span { display: none; }
  .search-trigger kbd { margin-left: 0; }
  .brand-text small { display: none; }
  .content { padding: 18px 18px 56px; }
  .doc-title { font-size: 24px; }
  .doc { font-size: 15px; }
  .doc h2 { font-size: 20px; }
  .pager { flex-direction: column; }
  .home-hero { padding: 24px 22px; }
}

@media print {
  .topbar, .sidebar, .page-toc, .pager, .site-footer, .search-overlay, .breadcrumb { display: none !important; }
  .layout { display: block; }
  .content { padding: 0; }
  .doc { font-size: 12pt; }
  .doc a { color: inherit; }
  .doc h2, .doc h3 { page-break-after: avoid; }
  .doc table, .doc pre, .doc img { page-break-inside: avoid; }
}
