:root {
  --background: #ffffff;
  --background-soft: #f6f7f9;
  --panel: #ffffff;
  --text: #202124;
  --muted: #62666d;
  --faint: #8b9098;
  --border: #e1e4e8;
  --brand: #3157c8;
  --brand-soft: #eef2ff;
  --brand-border: #c8d2ff;
  --code-background: #17191f;
  --code-text: #edf0f7;
  --header-background: rgba(255, 255, 255, 0.92);
  --sidebar-width: 306px;
  --radius: 14px;
  --sans: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

[data-theme="dark"] {
  --background: #17181c;
  --background-soft: #1e2026;
  --panel: #1c1e23;
  --text: rgba(255, 255, 245, 0.9);
  --muted: rgba(235, 235, 245, 0.64);
  --faint: rgba(235, 235, 245, 0.42);
  --border: #30333b;
  --brand: #aeb9ff;
  --brand-soft: #282d48;
  --brand-border: #424b7d;
  --code-background: #101116;
  --code-text: #f0f1f6;
  --header-background: rgba(23, 24, 28, 0.92);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  color-scheme: light;
}

[data-theme="dark"] {
  color-scheme: dark;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font: 15px/1.78 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--brand);
  text-underline-offset: 3px;
}

button,
input {
  font: inherit;
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--brand-border);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--brand);
  color: #ffffff;
  transform: translateY(-140%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--border);
  background: var(--header-background);
  backdrop-filter: blur(14px);
}

.header-inner {
  min-height: 62px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--brand);
  color: #ffffff;
  font: 800 14px/1 var(--mono);
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.library-link {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.library-link:hover {
  color: var(--brand);
}

.menu-button,
.theme-button {
  min-height: 44px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.menu-button {
  display: none;
}

.layout {
  min-height: calc(100vh - 62px);
}

.sidebar {
  position: fixed;
  top: 62px;
  bottom: 0;
  left: 0;
  width: var(--sidebar-width);
  overflow: auto;
  border-right: 1px solid var(--border);
  background: var(--background-soft);
}

.sidebar-inner {
  padding: 24px 18px 48px;
}

.search-box {
  display: grid;
  gap: 7px;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.search-box input {
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel);
  color: var(--text);
}

.nav-home {
  display: block;
  margin-bottom: 18px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 750;
  text-decoration: none;
}

.nav-chapter {
  margin: 20px 0 6px;
  padding: 0 10px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-link {
  display: block;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  text-decoration: none;
}

.nav-link:hover,
.nav-link.active {
  background: var(--brand-soft);
  color: var(--brand);
}

.nav-link.active {
  font-weight: 750;
}

.nav-item.hidden,
.nav-chapter.hidden {
  display: none;
}

.main-content {
  margin-left: var(--sidebar-width);
}

.content-shell {
  width: min(100%, 920px);
  margin: 0 auto;
  padding: 48px 52px 64px;
}

.breadcrumbs {
  margin-bottom: 32px;
  color: var(--faint);
  font-size: 12px;
}

.breadcrumbs a {
  color: var(--muted);
  text-decoration: none;
}

.breadcrumbs span {
  margin: 0 7px;
}

.article-header {
  padding-bottom: 34px;
  border-bottom: 1px solid var(--border);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(32px, 5vw, 50px);
  line-height: 1.15;
  letter-spacing: -0.035em;
}

.lead {
  max-width: 760px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.75;
}

.article-meta {
  margin-top: 18px;
  color: var(--faint);
  font-size: 12px;
}

.article-section {
  padding-top: 34px;
}

.article-section h2,
.official-sources h2 {
  margin: 0 0 15px;
  font-size: 25px;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.article-section h3 {
  margin: 28px 0 10px;
  font-size: 18px;
}

.article-section p,
.official-sources p {
  margin: 13px 0;
  color: var(--muted);
}

.article-section ul,
.article-section ol,
.official-sources ul {
  padding-left: 22px;
  color: var(--muted);
}

.article-section li,
.official-sources li {
  margin: 8px 0;
}

.callout {
  margin: 24px 0;
  padding: 17px 19px;
  border: 1px solid var(--brand-border);
  border-radius: 11px;
  background: var(--brand-soft);
  color: var(--muted);
}

.callout strong {
  display: block;
  margin-bottom: 5px;
  color: var(--text);
}

.code-block {
  position: relative;
  margin: 22px 0;
  overflow: hidden;
  border: 1px solid #2d3039;
  border-radius: 12px;
  background: var(--code-background);
}

.code-toolbar {
  min-height: 38px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #2d3039;
  color: #a9aeba;
  font: 12px/1 var(--mono);
}

.copy-button {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: #cbd0db;
  cursor: pointer;
  font: 12px/1 var(--sans);
}

pre {
  margin: 0;
  padding: 18px;
  overflow-x: auto;
  color: var(--code-text);
  font: 13px/1.7 var(--mono);
  tab-size: 2;
}

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

.chapter-card {
  padding: 21px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.18s ease, transform 0.18s ease;
}

.chapter-card:hover {
  border-color: var(--brand-border);
  transform: translateY(-2px);
}

.chapter-number {
  color: var(--brand);
  font: 750 12px/1 var(--mono);
}

.chapter-card h2 {
  margin: 13px 0 8px;
  font-size: 19px;
}

.chapter-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.chapter-card small {
  display: block;
  margin-top: 13px;
  color: var(--faint);
}

.official-sources {
  margin-top: 46px;
  padding: 25px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--background-soft);
}

.page-navigation {
  margin-top: 38px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.page-navigation a {
  min-height: 88px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 11px;
  color: var(--text);
  text-decoration: none;
}

.page-navigation a:hover {
  border-color: var(--brand-border);
}

.page-navigation span {
  display: block;
  color: var(--faint);
  font-size: 11px;
}

.page-navigation strong {
  display: block;
  margin-top: 5px;
}

.page-navigation .next {
  text-align: right;
}

.page-footer {
  margin-top: 44px;
  padding-top: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  border-top: 1px solid var(--border);
  color: var(--faint);
  font-size: 12px;
}

.page-footer a {
  color: var(--muted);
  text-decoration: none;
}

.sidebar-backdrop {
  display: none;
  border: 0;
  padding: 0;
}

.official-images > p {
  color: var(--muted);
}

.official-image-source {
  margin-top: 28px;
}

.official-image-source h3 {
  margin-bottom: 14px;
  font-size: 17px;
}

.official-image-source h3 a {
  color: var(--text);
  text-decoration-color: var(--border);
  text-underline-offset: 4px;
}

.official-image-gallery {
  display: grid;
  gap: 22px;
}

.official-figure {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
}

.official-figure img {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
}

.official-figure figcaption {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 14px;
  color: var(--muted);
  font-size: 12px;
}

.official-figure figcaption a {
  flex: 0 0 auto;
}

@media (max-width: 900px) {
  .menu-button {
    display: inline-flex;
    align-items: center;
  }

  .sidebar {
    z-index: 60;
    width: min(88vw, 330px);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: 18px 0 45px rgba(0, 0, 0, 0.18);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 62px 0 0;
    z-index: 50;
    background: rgba(0, 0, 0, 0.34);
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
  }

  .main-content {
    margin-left: 0;
  }

  .content-shell {
    padding: 38px 28px 56px;
  }
}

@media (max-width: 620px) {
  .header-inner {
    padding: 0 14px;
  }

  .brand span:last-child {
    display: none;
  }

  .library-link {
    font-size: 12px;
  }

  .content-shell {
    padding: 30px 19px 48px;
  }

  h1 {
    font-size: 34px;
  }

  .lead {
    font-size: 16px;
  }

  .chapter-grid,
  .page-navigation {
    grid-template-columns: 1fr;
  }

  .page-navigation .next {
    text-align: left;
  }

  .official-figure figcaption {
    display: block;
  }

  .official-figure figcaption a {
    display: inline-block;
    margin-top: 6px;
  }
}

@media print {
  .site-header,
  .sidebar,
  .page-navigation,
  .page-footer {
    display: none;
  }

  .main-content {
    margin: 0;
  }

  .content-shell {
    width: 100%;
    padding: 0;
  }
}
