:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f8;
  --panel: #ffffff;
  --text: #202126;
  --muted: #656872;
  --faint: #91949c;
  --border: #e3e5e8;
  --brand: #6246ea;
  --brand-dark: #4931bd;
  --brand-soft: #f0edff;
  --code: #171820;
  --code-text: #f2f3f7;
  --header: rgba(255, 255, 255, 0.92);
  --shadow: 0 18px 50px rgba(28, 27, 40, 0.1);
  --sans: "Inter", "PingFang SC", "Microsoft YaHei", ui-sans-serif, system-ui, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #18191d;
  --bg-soft: #222329;
  --panel: #202126;
  --text: rgba(255, 255, 250, 0.92);
  --muted: rgba(240, 241, 248, 0.66);
  --faint: rgba(240, 241, 248, 0.43);
  --border: #353740;
  --brand: #a99bff;
  --brand-dark: #c7beff;
  --brand-soft: #312c53;
  --code: #0f1015;
  --code-text: #f3f4f8;
  --header: rgba(24, 25, 29, 0.92);
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.26);
}

* {
  box-sizing: border-box;
}

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

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

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

a {
  color: inherit;
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 38%, transparent);
  outline-offset: 3px;
}

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

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

.site-header {
  position: fixed;
  z-index: 40;
  inset: 0 0 auto;
  height: 64px;
  border-bottom: 1px solid var(--border);
  background: var(--header);
  backdrop-filter: blur(14px);
}

.header-inner {
  height: 100%;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.site-brand,
.guide-home {
  text-decoration: none;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  white-space: nowrap;
}

.brand-mark {
  width: 29px;
  height: 29px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: #fff;
  font: 900 16px/1 var(--mono);
}

.guide-name {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

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

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

.icon-button {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font: 700 16px/1 var(--sans);
}

.menu-button {
  display: none;
}

.guide-layout {
  min-height: 100vh;
  padding-top: 64px;
}

.guide-sidebar {
  position: fixed;
  z-index: 30;
  top: 64px;
  bottom: 0;
  left: 0;
  width: 326px;
  overflow: hidden;
  border-right: 1px solid var(--border);
  background: var(--bg-soft);
  display: flex;
  flex-direction: column;
}

.sidebar-head {
  padding: 22px 18px 15px;
  border-bottom: 1px solid var(--border);
}

.guide-home {
  display: block;
  padding: 2px 3px 14px;
}

.guide-home strong {
  display: block;
  margin-top: 7px;
  font-size: 17px;
  line-height: 1.4;
}

.guide-badge {
  color: var(--brand-dark);
  font: 700 11px/1.2 var(--mono);
  letter-spacing: 0.04em;
}

.search-box {
  display: block;
}

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

.search-box input::placeholder {
  color: var(--faint);
}

.guide-nav {
  padding: 14px 12px 40px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

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

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

.toc-h2 {
  color: var(--text);
  font-weight: 750;
}

.toc-h3 {
  margin-left: 12px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

.toc-link[hidden] {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

.guide-main {
  min-width: 0;
  margin-left: 326px;
}

.content-shell {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 44px 64px 80px;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-bottom: 14px;
  color: var(--faint);
  font-size: 12px;
}

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

.breadcrumbs a:hover {
  color: var(--brand-dark);
}

.document-meta {
  margin-bottom: 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  color: var(--faint);
  font: 12px/1.5 var(--mono);
}

.guide-content {
  overflow-wrap: anywhere;
}

.guide-content > .document-title {
  margin: 0 0 34px;
  font-size: clamp(36px, 5vw, 56px);
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.guide-content h1,
.guide-content h2,
.guide-content h3,
.guide-content h4,
.guide-content h5,
.guide-content h6 {
  scroll-margin-top: 88px;
  line-height: 1.35;
  letter-spacing: -0.015em;
}

.guide-content h2 {
  margin: 50px 0 18px;
  font-size: 28px;
}

.guide-content h3 {
  margin: 35px 0 14px;
  font-size: 22px;
}

.guide-content p {
  margin: 0 0 18px;
}

.guide-content strong {
  color: var(--text);
  font-weight: 760;
}

.guide-content ul,
.guide-content ol {
  margin: 0 0 22px;
  padding-left: 1.5em;
}

.guide-content li {
  margin: 7px 0;
}

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

.guide-content img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--bg-soft);
  box-shadow: var(--shadow);
}

.guide-content figure {
  margin: 30px 0;
}

.guide-content pre {
  margin: 24px 0;
  padding: 20px 22px;
  overflow-x: auto;
  border: 1px solid #30323b;
  border-radius: 12px;
  background: var(--code);
  color: var(--code-text);
  font: 13px/1.72 var(--mono);
  tab-size: 2;
  white-space: pre-wrap;
}

.guide-content code {
  font-family: var(--mono);
}

.guide-content p code,
.guide-content li code {
  padding: 0.18em 0.42em;
  border-radius: 5px;
  background: var(--bg-soft);
  color: var(--brand-dark);
  font-size: 0.92em;
}

.document-callout {
  --callout-bg: var(--brand-soft);
  --callout-border: var(--brand);
  margin: 24px 0 34px;
  padding: 22px 24px;
  border: 1px solid var(--callout-border);
  border-radius: 14px;
  background: var(--callout-bg);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
}

[data-theme="dark"] .document-callout {
  background: color-mix(in srgb, var(--callout-bg) 22%, var(--panel));
}

.callout-emoji {
  font-size: 22px;
}

.callout-content > :first-child {
  margin-top: 0;
}

.callout-content > :last-child {
  margin-bottom: 0;
}

.guide-content blockquote {
  margin: 24px 0;
  padding: 4px 0 4px 20px;
  border-left: 4px solid var(--brand);
  color: var(--muted);
}

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

.source-column {
  min-width: 0;
}

.embedded-sheet {
  margin: 26px 0 34px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}

.embedded-sheet table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  font-size: 14px;
}

.embedded-sheet th,
.embedded-sheet td {
  padding: 13px 15px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.embedded-sheet th:last-child,
.embedded-sheet td:last-child {
  border-right: 0;
}

.embedded-sheet tbody tr:last-child td {
  border-bottom: 0;
}

.embedded-sheet th {
  background: var(--brand-soft);
  color: var(--text);
  font-weight: 760;
}

.document-reference,
.attachment-link {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-soft);
  color: var(--muted);
  text-decoration: none;
}

.guide-footer {
  margin-top: 70px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: var(--faint);
  font-size: 12px;
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 980px) {
  .menu-button {
    display: inline-block;
  }

  .guide-sidebar {
    width: min(88vw, 360px);
    transform: translateX(-105%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow);
  }

  body.sidebar-open {
    overflow: hidden;
  }

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

  .sidebar-backdrop {
    position: fixed;
    z-index: 25;
    inset: 64px 0 0;
    width: 100%;
    height: auto;
    border: 0;
    background: rgba(0, 0, 0, 0.44);
  }

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

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

@media (max-width: 680px) {
  .site-header {
    height: 58px;
  }

  .header-inner {
    padding: 0 13px;
    gap: 11px;
  }

  .guide-layout {
    padding-top: 58px;
  }

  .guide-sidebar {
    top: 58px;
  }

  .site-brand > span:last-child,
  .library-link {
    display: none;
  }

  .guide-name {
    font-size: 13px;
  }

  .content-shell {
    padding: 31px 20px 64px;
  }

  .guide-content > .document-title {
    margin-bottom: 26px;
    font-size: 35px;
  }

  .guide-content h2 {
    font-size: 24px;
  }

  .guide-content pre {
    margin-right: -20px;
    margin-left: -20px;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .source-grid {
    grid-template-columns: 1fr;
  }

  .guide-footer {
    flex-direction: column;
    gap: 5px;
  }
}

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

  .guide-layout {
    padding-top: 0;
  }

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

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