:root {
  --bg: #16171c;
  --panel: #111217;
  --panel-soft: #1b1d24;
  --panel-lift: #20232c;
  --text: #f1f3f8;
  --muted: #a5adbd;
  --faint: #70798d;
  --line: #303340;
  --accent: #8da2ff;
  --accent-strong: #b7c4ff;
  --callout: #282b4d;
  --green: #6ed6a6;
  --danger: #ff7f8f;
  --warning: #f1c971;
  --sidebar-width: 272px;
  --topbar-height: 64px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #ffffff;
  --panel-lift: #eef2f8;
  --text: #202633;
  --muted: #627087;
  --faint: #7e8aa0;
  --line: #d8deea;
  --accent: #315bdc;
  --accent-strong: #2448bc;
  --callout: #e9eefc;
  --green: #16875b;
  --danger: #c9344d;
  --warning: #9b6b00;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

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

a:hover {
  text-decoration: underline;
}

button,
input,
textarea {
  font: inherit;
}

.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  width: var(--sidebar-width);
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: #141519;
  padding: 20px 16px 34px;
}

:root[data-theme="light"] .sidebar {
  background: #ffffff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 208px;
  margin: 0 auto 22px;
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 21px;
  height: 25px;
  place-items: center;
  border-radius: 5px;
  background: linear-gradient(150deg, #fff 0 45%, #716cff 46% 70%, #ffd768 71%);
  color: #4d43cf;
  font-size: 13px;
  font-weight: 900;
  transform: rotate(-8deg);
}

.side-group {
  width: 208px;
  margin: 0 auto;
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.side-group:first-child {
  border-top: 0;
}

.group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 28px;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  font-weight: 800;
}

.chevron {
  width: 8px;
  height: 8px;
  border-right: 1px solid var(--muted);
  border-bottom: 1px solid var(--muted);
  transform: rotate(45deg);
}

.side-items {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.side-page {
  display: grid;
  gap: 7px;
}

.side-page-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px;
  align-items: center;
  gap: 6px;
}

.side-link {
  display: block;
  color: var(--muted);
  line-height: 1.45;
  font-size: 15px;
}

.side-link.active {
  color: var(--accent);
  font-weight: 700;
}

.side-expand {
  position: relative;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
}

.side-expand::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 7px;
  width: 7px;
  height: 7px;
  border-right: 1px solid var(--muted);
  border-bottom: 1px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 140ms ease;
}

.side-expand[aria-expanded="true"]::before {
  transform: rotate(45deg);
}

.side-section-tree,
.side-section-tree ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.side-section-tree[hidden],
.side-section-tree ul[hidden] {
  display: none;
}

.side-section-tree {
  border-left: 1px solid #2d313d;
  margin-left: 6px;
  padding-left: 12px;
}

.side-section-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20px;
  align-items: center;
  gap: 4px;
}

.side-section-link {
  display: block;
  color: var(--faint);
  line-height: 1.35;
  font-size: 13px;
}

.side-section-expand {
  position: relative;
  width: 20px;
  height: 20px;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.side-section-expand::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 6px;
  width: 6px;
  height: 6px;
  border-right: 1px solid var(--faint);
  border-bottom: 1px solid var(--faint);
  transform: rotate(-45deg);
  transition: transform 140ms ease;
}

.side-section-expand[aria-expanded="true"]::before {
  transform: rotate(45deg);
}

.side-section-link.level-1 {
  padding-left: 10px;
}

.side-section-link.level-2,
.side-section-link.level-3,
.side-section-link.level-4,
.side-section-link.level-5 {
  padding-left: 20px;
  font-size: 12px;
}

.main-frame {
  width: 100%;
  min-width: 0;
  margin-left: var(--sidebar-width);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--topbar-height);
  border-bottom: 1px solid #242730;
  background: rgba(22, 23, 28, 0.94);
  backdrop-filter: blur(14px);
  padding: 0 32px;
}

:root[data-theme="light"] .topbar {
  border-bottom-color: var(--line);
  background: rgba(245, 247, 251, 0.94);
}

.search-wrap {
  position: relative;
  width: min(440px, 44vw);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #111319;
  padding: 0 10px;
}

:root[data-theme="light"] .search-box,
:root[data-theme="light"] .language-trigger,
:root[data-theme="light"] .theme-toggle {
  background: #ffffff;
}

.search-box:focus-within {
  border-color: #4e5fc9;
}

.search-box input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.search-icon,
kbd {
  color: var(--muted);
}

kbd {
  border: 1px solid #2d303b;
  border-radius: 5px;
  padding: 2px 6px;
  font-size: 12px;
}

.search-results {
  position: absolute;
  top: 46px;
  left: 0;
  z-index: 30;
  width: min(560px, calc(100vw - 32px));
  max-height: 420px;
  overflow: auto;
  border: 1px solid #343846;
  border-radius: 8px;
  background: #111319;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  padding: 8px;
}

.search-result {
  display: grid;
  gap: 4px;
  border-radius: 6px;
  padding: 11px 12px;
  color: var(--text);
}

.search-result:hover {
  background: #1d2130;
  text-decoration: none;
}

.search-result strong {
  font-size: 14px;
}

.search-result span,
.search-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.search-empty {
  padding: 12px;
}

.top-links {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-left: auto;
}

.top-links a {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.language-menu {
  position: relative;
}

.language-trigger {
  height: 36px;
  border: 1px solid #303340;
  border-radius: 8px;
  background: #111319;
  color: var(--text);
  cursor: pointer;
  padding: 0 13px;
  font-size: 14px;
  font-weight: 800;
}

.language-trigger::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 9px;
  border-right: 1px solid var(--muted);
  border-bottom: 1px solid var(--muted);
  transform: translateY(-3px) rotate(45deg);
}

.language-options {
  position: absolute;
  top: 43px;
  right: 0;
  z-index: 35;
  display: grid;
  min-width: 150px;
  border: 1px solid #343846;
  border-radius: 8px;
  background: #111319;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  padding: 7px;
}

.language-options[hidden] {
  display: none;
}

.language-option {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  padding: 0 9px;
  text-align: left;
  font-weight: 750;
}

.language-option:hover,
.language-option.active {
  background: #1d2130;
}

:root[data-theme="light"] .language-options,
:root[data-theme="light"] .search-results {
  background: #ffffff;
}

:root[data-theme="light"] .language-option:hover,
:root[data-theme="light"] .language-option.active,
:root[data-theme="light"] .search-result:hover {
  background: #eef2f8;
}

.language-flag {
  font-size: 18px;
  line-height: 1;
}

.theme-toggle {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid #303340;
  border-radius: 999px;
  background: #111319;
  color: var(--text);
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}

.theme-toggle[aria-pressed="true"] {
  border-color: #cbd4e6;
  color: #9b6b00;
}

.version-pill {
  color: var(--text);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 760px) 260px;
  gap: 68px;
  max-width: 1160px;
  margin: 0 auto;
  padding: 48px 32px 80px;
}

.doc {
  min-width: 0;
}

.doc h1 {
  margin: 0 0 18px;
  font-size: 33px;
  line-height: 1.25;
  letter-spacing: 0;
}

.doc h2,
.doc h3,
.doc h4,
.doc h5,
.doc h6 {
  margin: 48px 0 18px;
  border-top: 1px solid var(--line);
  padding-top: 26px;
  letter-spacing: 0;
}

.doc h2 {
  font-size: 25px;
}

.doc h3 {
  font-size: 21px;
}

.doc h4,
.doc h5,
.doc h6 {
  font-size: 18px;
}

.doc-section .doc-section {
  margin-left: 18px;
}

.doc p,
.doc li {
  color: var(--text);
  font-size: 16px;
  font-weight: 550;
  line-height: 1.8;
}

.doc p {
  margin: 14px 0;
}

.doc ul {
  padding-left: 20px;
}

.doc ol {
  padding-left: 22px;
}

.doc blockquote {
  margin: 18px 0;
  border-left: 3px solid var(--accent);
  color: var(--muted);
  padding: 4px 0 4px 16px;
}

.doc table {
  width: 100%;
  margin: 18px 0;
  border-collapse: collapse;
  font-size: 14px;
}

.doc th,
.doc td {
  border: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
}

.doc th {
  background: var(--panel-soft);
  color: var(--text);
}

.doc strong {
  color: #ffffff;
}

:root[data-theme="light"] .doc strong {
  color: var(--text);
}

.doc code {
  border-radius: 5px;
  background: #262936;
  color: #a7f0c7;
  padding: 2px 6px;
  font-size: 0.9em;
}

.doc img {
  display: block;
  max-width: 100%;
  max-height: 560px;
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: contain;
  cursor: zoom-in;
}

.intro {
  margin: 0 0 22px;
}

.callout {
  margin: 18px 0 34px;
  border-radius: 7px;
  background: var(--callout);
  color: #dfe5ff;
  padding: 12px 17px;
  font-size: 14px;
  font-weight: 800;
}

:root[data-theme="light"] .callout {
  border: 1px solid #cbd6f2;
  background: #e8eefc;
  color: #21304f;
}

.toc-wrap {
  position: sticky;
  top: 92px;
  align-self: start;
}

.toc {
  border-left: 1px solid var(--line);
  padding-left: 16px;
  max-height: calc(100vh - 130px);
  overflow: auto;
}

.toc strong {
  display: block;
  margin-bottom: 14px;
  font-size: 14px;
}

.toc-item {
  display: grid;
  gap: 7px;
}

.toc-children {
  display: grid;
  gap: 7px;
  margin-left: 12px;
}

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

.toc-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20px;
  align-items: center;
  gap: 4px;
  margin: 9px 0;
}

.toc a {
  display: block;
  color: var(--faint);
  font-size: 14px;
  line-height: 1.35;
}

.toc a.level-1 {
  font-size: 13px;
}

.toc a.level-2,
.toc a.level-3,
.toc a.level-4 {
  font-size: 12px;
}

.toc-expand {
  position: relative;
  width: 20px;
  height: 20px;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.toc-expand::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 6px;
  width: 6px;
  height: 6px;
  border-right: 1px solid var(--faint);
  border-bottom: 1px solid var(--faint);
  transform: rotate(-45deg);
  transition: transform 140ms ease;
}

.toc-expand[aria-expanded="true"]::before {
  transform: rotate(45deg);
}

.toc a.active {
  color: var(--text);
}

.promo {
  width: 224px;
  margin-top: 360px;
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 32px 36px;
  text-align: center;
}

.promo-card {
  display: grid;
  gap: 14px;
}

.promo-logo {
  display: grid;
  place-items: center;
  width: 130px;
  min-height: 100px;
  margin: 0 auto;
  border-radius: 5px;
  background: #050507;
  color: #fff;
  padding: 12px;
  font-weight: 800;
}

:root[data-theme="light"] .promo-logo {
  background: #202633;
}

.promo-caption {
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

:root[data-theme="light"] .promo-caption {
  color: var(--text);
}

.promo-label {
  color: var(--muted);
  font-size: 11px;
}

:root[data-theme="light"] .promo-label {
  color: #4f5f78;
}

.promo-qr {
  width: 132px;
  max-width: 100%;
  aspect-ratio: 1;
  justify-self: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
  object-fit: contain;
  cursor: zoom-in;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(5, 7, 12, 0.82);
  backdrop-filter: blur(8px);
  cursor: zoom-out;
}

.image-lightbox[hidden] {
  display: none;
}

.image-lightbox img {
  max-width: min(96vw, 1180px);
  max-height: 92vh;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  cursor: default;
  object-fit: contain;
}

.image-lightbox-close {
  position: fixed;
  top: 18px;
  right: 18px;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(18, 20, 28, 0.78);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.toast {
  position: fixed;
  left: 50%;
  top: 34%;
  z-index: 20;
  display: grid;
  place-items: center;
  width: 136px;
  height: 120px;
  border-radius: 8px;
  background: rgba(82, 82, 82, 0.94);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.mobile-menu {
  display: none;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 8px;
  background: #101218;
  color: var(--text);
  cursor: pointer;
}

.mobile-menu span {
  display: block;
  width: 17px;
  height: 2px;
  margin: 4px auto;
  background: var(--text);
}

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

@media (max-width: 1080px) {
  .content-grid {
    grid-template-columns: minmax(0, 760px);
    max-width: 820px;
  }

  .toc-wrap {
    display: none;
  }
}

@media (max-width: 820px) {
  body.menu-open {
    overflow: hidden;
  }

  body.menu-open::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 9;
    background: rgba(4, 8, 16, 0.46);
    backdrop-filter: blur(2px);
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 180ms ease;
    box-shadow: 20px 0 60px rgba(0, 0, 0, 0.35);
  }

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

  .mobile-menu {
    display: block;
  }

  .topbar {
    padding: 0 16px;
  }

  .top-links {
    display: none;
  }

  .language-trigger {
    padding: 0 10px;
  }

  .search-wrap {
    width: 100%;
  }

  .content-grid {
    padding: 34px 22px 64px;
  }

  .doc h1 {
    font-size: 28px;
  }
}
