:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #1f2a37;
  --muted: #667789;
  --line: #d7dee8;
  --line-soft: #e8edf3;
  --accent: #1f6f78;
  --accent-strong: #134e57;
  --accent-soft: #e7f3f4;
  --example: #3f6d2a;
  --example-soft: #edf7e9;
  --warn: #8a5b16;
  --warn-soft: #fff6df;
  --code: #f8fafc;
  --sidebar: #ffffff;
  --table-head: #eef4f7;
  --row-alt: #fafcfe;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.74;
  letter-spacing: 0;
}

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

a:hover {
  text-decoration: underline;
}

.nav-toggle,
.mobile-topbar,
.mobile-backdrop {
  display: none;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 318px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
  padding: 22px 18px 26px;
}

.brand {
  padding: 4px 10px 18px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 14px;
}

.brand-title,
.brand-subtitle {
  display: block;
}

.brand-title {
  font-size: 18px;
  font-weight: 750;
  color: var(--text);
}

.brand-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.root-link,
.nav-children a,
summary {
  display: block;
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
}

.root-link,
.nav-children a {
  padding: 7px 10px;
}

.nav-children a:hover,
summary:hover {
  background: #f4f8fa;
  color: #263948;
  text-decoration: none;
}

.root-link.active,
.nav-children a.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 650;
  box-shadow: inset 3px 0 0 var(--accent);
}

details {
  margin-top: 4px;
}

summary {
  cursor: pointer;
  padding: 9px 10px;
  color: #344250;
  font-weight: 650;
  list-style: none;
}

summary::-webkit-details-marker {
  display: none;
}

summary::before {
  content: "›";
  display: inline-block;
  width: 15px;
  color: var(--muted);
  transform: translateY(-1px);
}

details[open] summary::before {
  transform: rotate(90deg) translateX(1px);
}

.nav-children {
  margin: 2px 0 8px 19px;
  padding-left: 8px;
  border-left: 1px solid var(--line-soft);
}

.content {
  min-width: 0;
  padding: 34px 46px 56px;
}

.doc-page {
  max-width: 1020px;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 38px 40px;
  box-shadow: 0 12px 34px rgba(31, 42, 55, 0.06);
}

.breadcrumb {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 2px 9px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: #fbfdff;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 12px;
}

.page-outline {
  margin: -4px 0 22px;
  padding: 12px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fbfdff;
}

.page-outline strong {
  display: block;
  margin-bottom: 9px;
  color: #344250;
  font-size: 13px;
}

.page-outline div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.page-outline a {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border: 1px solid #dce7ee;
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}

.page-outline a:hover {
  border-color: #a9c4cb;
  color: var(--accent-strong);
  text-decoration: none;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.35;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-soft);
}

h2 {
  font-size: 22px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
  margin: 24px 0 14px;
}

h3 {
  font-size: 20px;
  margin: 30px 0 12px;
  color: var(--accent-strong);
  scroll-margin-top: 24px;
}

h4 {
  font-size: 16px;
  margin: 22px 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #263948;
  scroll-margin-top: 24px;
}

h4::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--example);
  flex: 0 0 auto;
}

p {
  margin: 8px 0;
}

ul,
ol {
  margin: 8px 0 8px 22px;
  padding: 0;
}

li {
  margin: 5px 0;
}

li::marker {
  color: var(--accent);
}

.lead {
  color: var(--muted);
  font-size: 17px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #fbfcfd;
  font-size: 13px;
  white-space: nowrap;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 16px 0;
}

.box {
  border: 1px solid #dce6ec;
  border-radius: 8px;
  background: #fbfdfe;
  padding: 17px 18px;
}

.box h3:first-child,
.box h4:first-child {
  margin-top: 0;
}

.note {
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  padding: 13px 15px;
  margin: 16px 0;
  border-radius: 0 8px 8px 0;
}

.warning {
  border-left-color: var(--warn);
  background: var(--warn-soft);
}

.formula {
  display: block;
  overflow-x: auto;
  padding: 34px 16px 14px;
  margin: 14px 0 16px;
  border: 1px solid #dce7ee;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--code);
  color: #152331;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.72;
  white-space: pre-wrap;
  position: relative;
}

.formula::before {
  content: "公式";
  position: absolute;
  top: 10px;
  left: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 12px;
  font-weight: 650;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 16px 0 18px;
  background: #fff;
  box-shadow: 0 1px 0 rgba(31, 42, 55, 0.03);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--table-head);
  color: #26313d;
  font-weight: 650;
  white-space: nowrap;
}

tbody tr:nth-child(even) td {
  background: var(--row-alt);
}

tr:last-child td {
  border-bottom: 0;
}

.compact th,
.compact td {
  padding: 9px 11px;
  font-size: 14px;
}

.small {
  color: var(--muted);
  font-size: 14px;
  background: #fbfcfd;
  border-left: 3px solid var(--line);
  padding: 8px 11px;
  border-radius: 0 8px 8px 0;
}

.source-note {
  margin-top: 18px;
  padding: 11px 13px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--muted);
  font-size: 14px;
}

.source-note a {
  margin-left: 4px;
}

.subpage-list {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fcfdfe;
  padding: 18px;
  margin-top: 18px;
}

.subpage-list h2 {
  margin-top: 0;
}

.pager {
  max-width: 980px;
  margin: 16px auto 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.pager-link {
  display: block;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px 14px;
  color: var(--text);
}

.pager-link:hover {
  border-color: #a9c4cb;
  background: #fbfdff;
  text-decoration: none;
}

.pager-link span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.pager-link.next {
  text-align: right;
}

@media (max-width: 980px) {
  body {
    padding-top: 58px;
  }

  .mobile-topbar {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 70;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 58px;
    padding: 0 14px 0 16px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
  }

  .mobile-title {
    min-width: 0;
  }

  .mobile-title span,
  .mobile-title small {
    display: block;
  }

  .mobile-title span {
    color: var(--text);
    font-size: 16px;
    font-weight: 750;
  }

  .mobile-title small {
    margin-top: 1px;
    color: var(--muted);
    font-size: 12px;
  }

  .menu-button {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
  }

  .menu-button span {
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: #273644;
  }

  .mobile-backdrop {
    position: fixed;
    inset: 0;
    z-index: 55;
    display: block;
    background: rgba(15, 23, 42, 0.32);
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease;
  }

  .nav-toggle:checked ~ .mobile-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 58px;
    left: 0;
    z-index: 60;
    width: min(84vw, 326px);
    height: calc(100dvh - 58px);
    border-right: 1px solid var(--line);
    border-bottom: 0;
    box-shadow: none;
    transform: translateX(-110%);
    transition: transform 180ms ease;
  }

  .sidebar .brand {
    display: none;
  }

  .nav-toggle:checked ~ .app-shell .sidebar {
    transform: translateX(0);
    box-shadow: 18px 0 42px rgba(15, 23, 42, 0.18);
  }

  .content {
    padding: 18px 14px 34px;
  }

  .doc-page {
    padding: 22px;
  }

  .grid,
  .pager {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 25px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .app-shell {
    display: block;
  }

  .sidebar,
  .pager {
    display: none;
  }

  .content {
    padding: 0;
  }

  .doc-page {
    max-width: none;
    border: 0;
  }
}