:root {
  color-scheme: light;
  --page: #f8f7fc;
  --paper: #fff;
  --ink: #19172e;
  --body: #39364d;
  --muted: #655f77;
  --line: #e5e0f0;
  --accent: #5d3bda;
  --accent-dark: #4925c4;
  --accent-soft: #eee9ff;
  --code-bg: #1d1931;
  --code-top: #26213c;
  --code-line: #3d3652;
  --code-ink: #f0ebfd;
  --header-height: 4rem;
  --layout-width: 91rem;
  --sidebar-width: 15.5rem;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", "Courier New", monospace;
  font-family: var(--sans);
  scroll-padding-top: calc(var(--header-height) + 1.5rem);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--body);
  background: var(--page);
  font-size: 1rem;
  line-height: 1.75;
}

button, input { font: inherit; }
button { cursor: pointer; }
a { color: var(--accent-dark); text-underline-offset: 0.18em; }
svg { display: block; flex-shrink: 0; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 0.7rem;
  left: 0.7rem;
  z-index: 10;
  transform: translateY(-160%);
  padding: 0.5rem 0.85rem;
  border-radius: 0.45rem;
  color: #fff;
  background: var(--accent-dark);
}

.skip-link:focus { transform: none; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  height: var(--header-height);
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: min(100%, var(--layout-width));
  height: 100%;
  margin-inline: auto;
  padding-inline: 1.85rem;
}

.brand, .header-actions, .search-trigger, .menu-toggle {
  display: inline-flex;
  align-items: center;
}

.brand {
  gap: 0.65rem;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  flex: 0 0 2.05rem;
  width: 2.05rem;
  height: 2.05rem;
  place-items: center;
  border-radius: 0.58rem;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 2px 5px #42237b29, inset 0 1px 0 #ffffff38;
  font: 700 0.94rem/1 var(--mono);
}

.brand-mark svg { width: 1.2rem; height: 1.2rem; }
.brand-title { font-size: 1rem; font-weight: 760; letter-spacing: 0.01em; white-space: nowrap; }
.header-actions { gap: 0.55rem; }

.search-trigger, .menu-toggle {
  min-height: 2.25rem;
  gap: 0.55rem;
  padding: 0.25rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--page);
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.35;
}

.search-trigger { min-width: 12.3rem; text-align: left; }
.search-trigger:hover, .menu-toggle:hover { border-color: #c8baf9; color: var(--accent-dark); }
.search-trigger svg, .menu-toggle svg { width: 1rem; height: 1rem; }
.menu-toggle { display: none; justify-content: center; }

.search-icon, .menu-icon, .copy-icon {
  position: relative;
  display: block;
  flex: 0 0 1rem;
  width: 1rem;
  height: 1rem;
}

.search-icon::before, .search-icon::after,
.menu-icon::before, .menu-icon::after,
.copy-icon::before, .copy-icon::after {
  position: absolute;
  content: "";
}

.search-icon::before {
  top: 0.08rem;
  left: 0.08rem;
  width: 0.67rem;
  height: 0.67rem;
  border: 1.5px solid currentColor;
  border-radius: 50%;
}

.search-icon::after {
  right: 0.08rem;
  bottom: 0.12rem;
  width: 0.37rem;
  height: 1.5px;
  transform: rotate(45deg);
  background: currentColor;
  border-radius: 1px;
}

.menu-icon {
  background: linear-gradient(currentColor, currentColor) center / 0.88rem 1.5px no-repeat;
}

.menu-icon::before, .menu-icon::after {
  inset-inline: 0.06rem;
  height: 1.5px;
  border-radius: 1px;
  background: currentColor;
}

.menu-icon::before { top: 0.19rem; }
.menu-icon::after { bottom: 0.19rem; }
.menu-toggle[aria-expanded="true"] .menu-icon { background: none; }
.menu-toggle[aria-expanded="true"] .menu-icon::before { top: calc(50% - 0.75px); transform: rotate(45deg); }
.menu-toggle[aria-expanded="true"] .menu-icon::after { bottom: calc(50% - 0.75px); transform: rotate(-45deg); }

.shortcut {
  margin-left: auto;
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--line);
  border-radius: 0.3rem;
  color: var(--muted);
  background: var(--paper);
  font-family: var(--mono);
  font-size: 0.75rem;
  white-space: nowrap;
}

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: calc(100vh - var(--header-height));
  max-width: var(--layout-width);
  margin-inline: auto;
}

.sidebar {
  position: sticky;
  top: var(--header-height);
  align-self: start;
  height: calc(100vh - var(--header-height));
  height: calc(100dvh - var(--header-height));
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  border-right: 1px solid var(--line);
  background: var(--page);
}

.sidebar-inner { padding: 2rem 1.15rem 2rem 1.5rem; }
.nav-group + .nav-group { margin-top: 1.4rem; }

.nav-label {
  display: block;
  margin: 0 0 0.45rem;
  padding-inline: 0.6rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 750;
  letter-spacing: 0.015em;
}

.nav-link {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.16rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid transparent;
  border-radius: 0.45rem;
  color: var(--body);
  font-size: 0.875rem;
  line-height: 1.5;
  text-decoration: none;
}

.nav-link:hover { color: var(--accent-dark); background: #f1edf9; }
.nav-link.is-active, .nav-link[aria-current="location"] {
  border-color: #e3dafa;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-weight: 700;
}

.nav-index {
  flex: 0 0 1.5rem;
  color: var(--muted);
  font: 0.78rem/1.4 var(--mono);
  font-variant-numeric: tabular-nums;
}

.nav-link.is-active .nav-index, .nav-link[aria-current="location"] .nav-index { color: var(--accent-dark); }
.nav-text { min-width: 0; overflow-wrap: anywhere; }

.main-content {
  width: min(100%, 71rem);
  min-width: 0;
  margin-inline: auto;
  padding: 2.65rem clamp(1.75rem, 4.2vw, 4.3rem) 1.5rem;
}

.intro {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  overflow: clip;
  border: 1px solid #e1d8fc;
  border-radius: 1.12rem;
  background: linear-gradient(108deg, #f1ebff 0%, #ede6ff 58%, #e7dffc 100%);
  color: var(--ink);
}

.intro-inner { position: relative; z-index: 1; padding: clamp(1.7rem, 4vw, 3.1rem); }
.intro-decoration {
  position: absolute;
  z-index: 0;
  inset: 0 0 0 50%;
  opacity: 0.8;
  pointer-events: none;
  background: radial-gradient(ellipse at 88% 22%, #d4c4fa 0%, transparent 71%);
}

.intro-decoration::before, .intro-decoration::after {
  content: "";
  position: absolute;
}

.intro-decoration::before {
  inset: -30% -20% -32% 10%;
  transform: rotate(-27deg) skewX(15deg);
  background-image: linear-gradient(#7658ca32 1px, transparent 1px), linear-gradient(90deg, #7658ca32 1px, transparent 1px);
  background-size: 1.7rem 1.7rem;
  mask-image: linear-gradient(90deg, transparent, #000 45%);
}

.intro-decoration::after {
  top: 11%;
  right: 5%;
  width: clamp(7.4rem, 15vw, 15.5rem);
  aspect-ratio: 1;
  transform: rotate(-27deg) skewX(15deg);
  border: 1px solid #8061ce44;
  border-radius: 1.3rem;
  box-shadow: 0 0 0 0.85rem #a386f012, 0 0 0 2rem #ac91f217;
  background: linear-gradient(145deg, #ffffff1f, #a17fe420);
}

.intro-meta {
  margin: 0 0 0.5rem;
  color: #50436f;
  font-size: 0.875rem;
  font-weight: 650;
}

.hero-title {
  margin: 0;
  color: var(--ink);
  font-size: clamp(2rem, 4vw, 3.55rem);
  font-weight: 800;
  line-height: 1.18;
  letter-spacing: -0.04em;
  overflow-wrap: anywhere;
}

.hero-description { max-width: 40rem; margin: 1rem 0 1.55rem; color: #453b5b; }
.hero-description > p { margin: 0; }

.doc-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 1rem;
}
.doc-shortcuts a {
  padding: 0.22rem 0.72rem;
  border: 1px solid #d9cdf2;
  border-radius: 0.42rem;
  background: #ffffff83;
  color: var(--accent-dark);
  font-size: 0.875rem;
  font-weight: 650;
  text-decoration: none;
}
.doc-shortcuts a:hover, .doc-shortcuts a:focus-visible {
  border-color: #ad99ed;
  background: var(--paper);
}

.base-url {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.7rem;
  max-width: 100%;
  padding: 0.33rem 0.4rem 0.33rem 0.7rem;
  border: 1px solid #d9cdf2;
  border-radius: 0.55rem;
  background: #ffffffb3;
}

.base-label { color: #544871; font-size: 0.82rem; font-weight: 750; white-space: nowrap; }
.base-value { color: #382174; font: 600 0.88rem/1.45 var(--mono); overflow-wrap: anywhere; }

.copy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 1.95rem;
  padding: 0.2rem 0.45rem;
  border: 1px solid transparent;
  border-radius: 0.35rem;
  background: transparent;
  color: inherit;
  font-size: 0.83rem;
  line-height: 1.4;
  white-space: nowrap;
}

.copy-button svg { width: 0.9rem; height: 0.9rem; }
.copy-icon { width: 0.89rem; height: 0.89rem; flex-basis: 0.89rem; }
.copy-icon::before {
  inset: 0.06rem 0.08rem 0.23rem 0.27rem;
  border-top: 1.3px solid currentColor;
  border-right: 1.3px solid currentColor;
  border-radius: 0.15rem 0.15rem 0.12rem 0;
}

.copy-icon::after {
  inset: 0.23rem 0.26rem 0.07rem 0.08rem;
  border: 1.3px solid currentColor;
  border-radius: 0.15rem;
}

.base-url .copy-button { color: var(--accent-dark); }
.base-url .copy-button:hover { border-color: #ddd2fa; background: #f3edff; }
.base-url .copy-button.is-copied { color: #216144; }

.doc-section { min-width: 0; padding-block: 2.55rem 2.25rem; }
.doc-section ~ .doc-section { border-top: 1px solid var(--line); }

.section-heading, .section-heading h2 {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.section-heading { flex-wrap: wrap; margin-bottom: 1.15rem; }
.section-heading h2 { overflow-wrap: anywhere; }
.chapter-actions { margin-inline-start: auto; }
.chapter-actions .copy-button {
  padding-inline: 0.65rem;
  border-color: var(--line);
  color: var(--accent-dark);
  background: var(--paper);
}
.chapter-actions .copy-button:hover { border-color: #c8baf9; background: var(--accent-soft); }
.chapter-actions .copy-button.is-copied { color: #216144; }

.chapter-toc {
  width: fit-content;
  max-width: 100%;
  margin-bottom: 1.2rem;
  padding: 0.46rem 0.82rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  color: var(--muted);
  background: var(--paper);
  font-size: 0.875rem;
}
.chapter-toc summary { color: var(--accent-dark); cursor: pointer; font-weight: 650; }
.doc-section .chapter-toc ul { margin: 0.45rem 0; padding: 0; list-style: none; }
.doc-section .chapter-toc li { margin-block: 0.22rem; }
.chapter-toc .toc-level-4 { margin-inline-start: 1em; }
.chapter-toc .toc-level-5 { margin-inline-start: 2em; }
.chapter-toc a { color: var(--body); }
.chapter-toc a:hover { color: var(--accent-dark); }

.chapter-pagination {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-block-start: 1.65rem;
}
.chapter-pagination a {
  display: grid;
  gap: 0.1rem;
  padding: 0.62rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: var(--paper);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.chapter-pagination a:hover { border-color: #c8baf9; background: var(--accent-soft); }
.chapter-pagination span { color: var(--muted); font-size: 0.83rem; }
.chapter-next { grid-column: 2; text-align: end; }
.doc-section h2, .doc-section h3, .doc-section h4, .doc-section h5 { color: var(--ink); line-height: 1.35; }
.doc-section h2 { margin: 0; font-size: clamp(1.55rem, 2.7vw, 2rem); font-weight: 760; letter-spacing: -0.026em; }
.doc-section h3 { margin: 2rem 0 0.65rem; font-size: 1.25rem; font-weight: 740; }
.doc-section h4 { margin: 1.45rem 0 0.55rem; font-size: 1.07rem; font-weight: 740; }
.doc-section h5 { margin: 1.35rem 0 0.4rem; font-size: 1rem; }

.section-number {
  display: inline-grid;
  flex-shrink: 0;
  min-width: 2.05rem;
  height: 1.9rem;
  padding-inline: 0.3rem;
  place-items: center;
  border: 1px solid #ded4fa;
  border-radius: 0.42rem;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font: 650 0.83rem/1 var(--mono);
  letter-spacing: 0;
}

.heading-anchor {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 1.65rem;
  min-height: 1.7rem;
  margin-inline-start: 0.15rem;
  border-radius: 0.3rem;
  color: var(--accent-dark);
  font: 0.95rem/1 var(--mono);
  text-decoration: none;
  vertical-align: middle;
  opacity: 0.8;
}

.heading-anchor svg { width: 0.9rem; height: 0.9rem; }
.heading-anchor:hover, .heading-anchor:focus-visible { opacity: 1; background: var(--accent-soft); }
.doc-section p, .doc-section ul, .doc-section ol, .doc-section blockquote { margin: 0.65rem 0 1rem; }
.doc-section :is(ul, ol) { padding-inline-start: 1.4rem; }
.doc-section li + li { margin-top: 0.28rem; }
.doc-section li > :is(ul, ol) { margin: 0.3rem 0 0.45rem; }
.doc-section li::marker { color: var(--accent); }
.doc-section > :last-child { margin-bottom: 0; }
.doc-section strong { color: var(--ink); }
.doc-section blockquote {
  padding: 0.15rem 0.85rem;
  border-left: 3px solid #997be9;
  border-radius: 0 0.4rem 0.4rem 0;
  background: #f1ebfc;
}

code { font-family: var(--mono); }
:not(pre) > code:not(.base-value) {
  padding: 0.1em 0.32em;
  border-radius: 0.27rem;
  background: #eee8f9;
  color: #48267e;
  font-size: 0.89em;
  overflow-wrap: anywhere;
}

.code-card {
  min-width: 0;
  margin: 0.85rem 0 1.25rem;
  overflow: hidden;
  border: 1px solid var(--code-line);
  border-radius: 0.72rem;
  color: var(--code-ink);
  background: var(--code-bg);
}

.code-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  min-height: 2.55rem;
  padding: 0.25rem 0.7rem 0.25rem 0.95rem;
  border-bottom: 1px solid var(--code-line);
  background: var(--code-top);
}

.code-language { color: #ddd1f8; font: 0.81rem/1.3 var(--mono); }
.code-toolbar .copy-button { color: #e4daf7; }
.code-toolbar .copy-button:hover { border-color: #514866; background: #39314e; color: #fff; }
.code-toolbar .copy-button.is-copied { color: #c6efb3; }
.code-card :focus-visible { outline-color: #b9a5ff; outline-offset: -2px; }

.code-card pre {
  max-width: 100%;
  margin: 0;
  padding: 0.95rem 1.05rem 1.12rem;
  overflow-x: auto;
  scrollbar-color: #655779 var(--code-bg);
  tab-size: 2;
  font: 0.875rem/1.65 var(--mono);
}

.code-card pre code { color: inherit; background: transparent; font: inherit; }
.code-card .hljs-comment, .code-card .hljs-punctuation { color: #aba0be; }
.code-card .hljs-string { color: #c6efb3; }
.code-card .hljs-keyword, .code-card .hljs-built_in, .code-card .hljs-title { color: #d9b7ff; }
.code-card .hljs-number, .code-card .hljs-literal { color: #fbd39d; }
.code-card .hljs-attr, .code-card .hljs-attribute, .code-card .hljs-variable { color: #a9d8ff; }

.table-wrap {
  max-width: 100%;
  margin: 0.85rem 0 1.25rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 0.62rem;
  background: var(--paper);
}

.doc-section table { width: 100%; border-collapse: collapse; font-size: 0.94rem; }
.doc-section :is(th, td) { padding: 0.58rem 0.79rem; text-align: left; vertical-align: top; }
.doc-section th { color: var(--ink); background: #f0ecfa; font-weight: 750; white-space: nowrap; }
.doc-section tr + tr td, .doc-section tbody tr:first-child td { border-top: 1px solid var(--line); }
.doc-section tbody tr:nth-child(even) { background: #fcfbfe; }

.site-footer {
  margin: 0.8rem 0 0;
  padding: 1.15rem 0 0.45rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.875rem;
}

.site-footer p { margin: 0; }

#search-dialog {
  width: min(calc(100% - 2rem), 40rem);
  max-height: min(34rem, calc(100% - 3rem));
  margin: min(15vh, 7rem) auto auto;
  padding: 0;
  border: 1px solid #ddcff9;
  border-radius: 0.85rem;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1.25rem 4.5rem #20133138;
  overflow: auto;
}

#search-dialog::backdrop { background: #1d133c68; }
.search-panel { min-width: 0; }

.search-form {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.search-form svg { width: 1.05rem; height: 1.05rem; }
.search-form svg, .search-form .search-icon { color: var(--accent); }
.search-form label { flex: 1; min-width: 0; }
.search-input, #search-input {
  display: block;
  flex: 1;
  width: 100%;
  min-width: 0;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  color: var(--ink);
  background: var(--page);
}

.modal-close {
  display: grid;
  flex-shrink: 0;
  min-width: 2.25rem;
  min-height: 2.25rem;
  place-items: center;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  color: var(--muted);
  background: var(--paper);
  font-size: 0.875rem;
}

.modal-close:hover { border-color: #c8baf9; color: var(--accent-dark); }
.search-results { padding: 0.55rem 0.7rem 0.7rem; }

.search-result {
  display: block;
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid transparent;
  border-radius: 0.45rem;
  background: transparent;
  color: var(--ink);
  text-align: left;
  text-decoration: none;
}

.search-result:hover, .search-result:focus-visible, .search-result[aria-selected="true"] {
  border-color: #ded4fa;
  background: var(--accent-soft);
}

.result-label, .search-result strong { display: block; color: var(--accent-dark); font-weight: 750; }
.result-preview, .search-result small { display: block; color: var(--muted); font-size: 0.875rem; overflow-wrap: anywhere; }
.search-empty, .search-message { margin: 0; padding: 0.65rem 0.45rem; color: var(--muted); }

@media (max-width: 57rem) {
  :root { --sidebar-width: 13.5rem; }
  .sidebar-inner { padding-inline: 0.9rem; }
  .main-content { padding-top: 2rem; }
}

@media (max-width: 48rem) {
  :root { --header-height: 3.55rem; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .header-inner { padding-inline: 1rem; }
  .menu-toggle { display: inline-flex; }
  .sidebar {
    position: fixed;
    z-index: 4;
    left: 0;
    width: min(18rem, calc(100% - 3rem));
    visibility: hidden;
    transform: translateX(-100%);
    box-shadow: 0.55rem 0 2rem #2d1d492b;
  }
  .menu-open .sidebar { visibility: visible; transform: none; }
  .menu-open .layout::before {
    content: "";
    position: fixed;
    z-index: 3;
    inset: var(--header-height) 0 0;
    background: #21163240;
  }
  .sidebar-inner { padding: 1.25rem 1rem; }
  .main-content { padding: 1.25rem 1rem 1.4rem; }
  .intro-inner { padding: 1.6rem 1.25rem; }
  .intro-decoration { inset-inline-start: 30%; opacity: 0.5; }
  .doc-section { padding-block: 1.8rem 1.55rem; }
}

@media (max-width: 34rem) {
  .header-inner { gap: 0.5rem; }
  .brand { gap: 0.45rem; }
  .brand-title { font-size: 0.93rem; }
  .brand-mark { width: 1.85rem; height: 1.85rem; flex-basis: 1.85rem; }
  .header-actions { gap: 0.35rem; }
  .search-trigger { min-width: 0; }
  .search-trigger .shortcut { display: none; }
  .base-url { column-gap: 0.43rem; }
  .base-value { font-size: 0.8rem; }
  .section-heading, .section-heading h2 { gap: 0.5rem; }
  .chapter-actions { flex-basis: 100%; margin-inline-start: 0; }
  .table-wrap table { min-width: 28rem; }
}

@media (max-width: 25rem) {
  .search-trigger, .menu-toggle { padding-inline: 0.5rem; }
  .search-trigger .search-label, .menu-toggle .menu-label { display: none; }
}
