/* Docs — 干净、克制的产品文档视觉 */

:root {
  --font-display: "Plus Jakarta Sans", "Noto Sans SC", sans-serif;
  --font-sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --bg: #f3f5f8;
  --bg-solid: #ffffff;
  --bg-muted: #eef1f5;
  --sidebar-bg: #0f1720;
  --sidebar-text: #9aa6b5;
  --sidebar-text-active: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, 0.06);
  --sidebar-active: rgba(56, 189, 248, 0.14);

  --border: #e5e9ef;
  --border-strong: #d5dbe4;
  --text: #111827;
  --text-secondary: #4b5565;
  --text-muted: #8b95a5;

  --brand: #0284c7;
  --brand-hover: #0369a1;
  --brand-soft: #e0f2fe;
  --accent: #0ea5e9;
  --scan: #38bdf8;

  --info: #0284c7;
  --info-bg: #f0f9ff;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;

  --method-get: #059669;
  --method-post: #0284c7;
  --method-put: #d97706;
  --method-delete: #dc2626;
  --method-patch: #7c3aed;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(15, 23, 32, 0.04);
  --shadow-md: 0 4px 16px rgba(15, 23, 32, 0.06);
  --header-h: 56px;
  --sidebar-w: 268px;
  --toc-w: 220px;
  --content-max: 960px;
  --ease: cubic-bezier(0.25, 1, 0.5, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f14;
    --bg-solid: #121820;
    --bg-muted: #1a222d;
    --sidebar-bg: #080c11;
    --sidebar-text: #8b98a8;
    --sidebar-text-active: #f3f6fa;
    --sidebar-hover: rgba(255, 255, 255, 0.05);
    --sidebar-active: rgba(56, 189, 248, 0.12);
    --border: #243041;
    --border-strong: #314155;
    --text: #e8eef5;
    --text-secondary: #a0aec0;
    --text-muted: #6b7a8c;
    --brand: #38bdf8;
    --brand-hover: #7dd3fc;
    --brand-soft: rgba(56, 189, 248, 0.12);
    --accent: #7dd3fc;
    --info: #38bdf8;
    --info-bg: rgba(56, 189, 248, 0.1);
    --warn: #fbbf24;
    --warn-bg: rgba(251, 191, 36, 0.1);
    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.1);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  }
}

:root[data-theme="dark"] {
  --bg: #0b0f14;
  --bg-solid: #121820;
  --bg-muted: #1a222d;
  --sidebar-bg: #080c11;
  --sidebar-text: #8b98a8;
  --sidebar-text-active: #f3f6fa;
  --sidebar-hover: rgba(255, 255, 255, 0.05);
  --sidebar-active: rgba(56, 189, 248, 0.12);
  --border: #243041;
  --border-strong: #314155;
  --text: #e8eef5;
  --text-secondary: #a0aec0;
  --text-muted: #6b7a8c;
  --brand: #38bdf8;
  --brand-hover: #7dd3fc;
  --brand-soft: rgba(56, 189, 248, 0.12);
  --accent: #7dd3fc;
  --info: #38bdf8;
  --info-bg: rgba(56, 189, 248, 0.1);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, 0.1);
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.1);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 20px);
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.8;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  color: var(--brand-hover);
  text-decoration: underline;
  text-underline-offset: 2px;
}

img {
  max-width: 100%;
  height: auto;
}

/* —— Header —— */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px 0 0;
  background: var(--bg-solid);
  border-bottom: 1px solid var(--border);
}

.site-header .brand {
  width: var(--sidebar-w);
  flex-shrink: 0;
  height: 100%;
  padding: 0 20px;
  background: var(--sidebar-bg);
  border-right: 1px solid transparent;
  color: #fff;
}

.site-header .brand:hover {
  color: #fff;
}

.menu-toggle {
  display: none;
  width: 36px;
  height: 36px;
  margin-left: 12px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-solid);
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.brand:hover {
  text-decoration: none;
}

div.brand {
  cursor: default;
}

.header-nav {
  display: flex;
  gap: 4px;
  margin-left: 8px;
}

.header-nav a {
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
}

.header-nav a:hover {
  color: var(--text);
  background: var(--bg-muted);
  text-decoration: none;
}

.header-nav a.active {
  color: var(--brand);
  background: var(--brand-soft);
  text-decoration: none;
}

.doc-meta {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-left: 16px;
  min-width: 0;
  font-size: 14px;
}

.doc-meta-label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.doc-meta time {
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  white-space: nowrap;
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 8px;
}

.theme-toggle {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-solid);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

/* —— Layout —— */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  min-height: calc(100vh - var(--header-h));
  max-width: none;
  margin: 0;
}

.layout.no-toc {
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 20px 12px 40px;
  background: var(--sidebar-bg);
  border-right: none;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.sidebar-section {
  margin-bottom: 24px;
}

.sidebar-title {
  padding: 6px 12px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.35);
}

.sidebar-group {
  margin-bottom: 6px;
}

.sidebar-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

.sidebar-row .sidebar-link {
  flex: 1;
  min-width: 0;
}

.sidebar-toggle {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  margin-right: 4px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  position: relative;
}

.sidebar-toggle::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 5px 0 5px 7px;
  border-color: transparent transparent transparent currentColor;
  transform: translate(-40%, -50%) rotate(0deg);
  transition: transform 0.15s var(--ease);
}

.sidebar-group:not(.is-collapsed) .sidebar-toggle::before {
  transform: translate(-50%, -40%) rotate(90deg);
}

.sidebar-toggle:hover {
  color: var(--sidebar-text-active);
  background: var(--sidebar-hover);
}

.sidebar a,
.sidebar-link {
  display: block;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--sidebar-text);
  font-size: 15px;
  text-decoration: none;
  line-height: 1.45;
  transition: background 0.12s var(--ease), color 0.12s var(--ease);
}

.sidebar a:hover,
.sidebar-link:hover {
  color: var(--sidebar-text-active);
  background: var(--sidebar-hover);
  text-decoration: none;
  transform: none;
}

.sidebar a.active,
.sidebar-link.active {
  color: var(--sidebar-text-active);
  background: var(--sidebar-active);
  font-weight: 600;
  box-shadow: none;
}

.sidebar-children {
  margin: 2px 0 8px 12px;
  padding: 2px 0 2px 0;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-group.is-collapsed .sidebar-children {
  display: none;
}

.sidebar-children a {
  padding: 5px 10px 5px 12px;
  font-size: 13.5px;
  font-weight: 400;
  color: rgba(154, 166, 181, 0.92);
  line-height: 1.4;
}

.sidebar-children a:hover {
  color: var(--sidebar-text-active);
  background: var(--sidebar-hover);
}

.sidebar-children a.active {
  color: var(--scan);
  background: transparent;
  font-weight: 550;
  box-shadow: none;
}

.main {
  padding: 40px 40px 96px;
  min-width: 0;
  background: var(--bg-solid);
  border-right: 1px solid var(--border);
}

.doc {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  animation: none;
}

.toc {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 32px 16px 40px 12px;
  background: var(--bg);
  border-left: none;
}

.toc-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding-left: 10px;
}

.toc nav a {
  display: block;
  padding: 5px 10px;
  border-left: 2px solid var(--border);
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.5;
  text-decoration: none;
}

.toc nav a:hover {
  color: var(--text-secondary);
}

.toc nav a.active {
  color: var(--brand);
  border-left-color: var(--brand);
  font-weight: 500;
}

.toc nav a.depth-3 {
  padding-left: 18px;
  font-size: 13px;
}

/* —— Typography —— */

.doc-lead {
  margin: 0 0 28px;
  font-size: 18px;
  color: var(--text-secondary);
  line-height: 1.75;
  max-width: 46em;
}

.doc h1 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.25;
  color: var(--text);
}

.doc h2 {
  margin: 40px 0 12px;
  padding-top: 0;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  border-top: none;
  color: var(--text);
}

.doc h2:first-of-type {
  margin-top: 24px;
}

.doc h3 {
  margin: 24px 0 8px;
  font-size: 18px;
  font-weight: 650;
  color: var(--text);
}

.doc p {
  margin: 0 0 14px;
  color: var(--text-secondary);
}

.doc h1 + .doc-lead,
.doc h2 + p,
.doc h3 + p {
  color: var(--text-secondary);
}

.doc ul,
.doc ol {
  margin: 0 0 16px;
  padding-left: 20px;
  color: var(--text-secondary);
}

.doc li {
  margin-bottom: 6px;
}

.doc li::marker {
  color: var(--accent);
}

.doc strong {
  font-weight: 650;
  color: var(--text);
}

.doc hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 28px 0;
}

/* —— Home —— */

body.page-home {
  background:
    radial-gradient(ellipse 80% 50% at 70% 20%, rgba(14, 165, 233, 0.12), transparent 55%),
    radial-gradient(ellipse 60% 40% at 10% 80%, rgba(2, 132, 199, 0.08), transparent 50%),
    var(--bg);
}

body.page-home .site-header {
  background: color-mix(in srgb, var(--bg-solid) 85%, transparent);
  backdrop-filter: blur(12px);
  padding: 0 28px;
}

body.page-home .site-header .brand {
  width: auto;
  background: transparent;
  color: var(--text);
  padding: 0;
}

body.page-home .site-header .brand:hover {
  color: var(--text);
}

/* —— 文档中心（多套文档入口） —— */

body.page-catalog {
  background:
    radial-gradient(ellipse 70% 45% at 80% 0%, rgba(14, 165, 233, 0.1), transparent 55%),
    var(--bg);
}

.site-header-catalog {
  padding: 0 28px !important;
}

.site-header-catalog .brand {
  width: auto !important;
  background: transparent !important;
  color: var(--text) !important;
  padding: 0 !important;
}

.catalog {
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 28px 96px;
}

.catalog-hero {
  margin-bottom: 36px;
}

.catalog-kicker {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand);
}

.catalog-hero h1 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: clamp(32px, 5vw, 42px);
  font-weight: 750;
  letter-spacing: -0.03em;
  color: var(--text);
}

.catalog-lead {
  margin: 0;
  max-width: 36em;
  font-size: 17px;
  line-height: 1.7;
  color: var(--text-secondary);
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.catalog-card {
  display: block;
  padding: 24px;
  background: var(--bg-solid);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s var(--ease), transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

a.catalog-card:hover {
  border-color: var(--brand);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  color: inherit;
}

.catalog-card-placeholder {
  border-style: dashed;
  background: transparent;
  color: var(--text-secondary);
}

.catalog-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.catalog-tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
  font-weight: 650;
}

.catalog-tag.muted {
  background: var(--bg-muted);
  color: var(--text-muted);
}

.catalog-card-arrow {
  color: var(--brand);
  font-size: 18px;
  transition: transform 0.15s var(--ease);
}

a.catalog-card:hover .catalog-card-arrow {
  transform: translateX(3px);
}

.catalog-card h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.catalog-card > p {
  margin: 0 0 14px;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-secondary);
}

.catalog-card-points {
  margin: 0;
  padding-left: 18px;
  color: var(--text-muted);
  font-size: 14px;
}

.catalog-card-points li {
  margin-bottom: 4px;
}

.catalog-card code {
  font-size: 0.9em;
}

.home {
  position: relative;
  min-height: calc(100vh - var(--header-h));
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 32px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 48px 32px 80px;
}

.home-visual {
  position: relative;
  z-index: 0;
  display: grid;
  place-items: center;
  order: 2;
}

.home-visual svg {
  width: min(100%, 420px);
  height: auto;
  filter: drop-shadow(0 20px 40px rgba(2, 132, 199, 0.15));
}

.scan-line {
  animation: scan-move 4.8s ease-in-out infinite;
}

@keyframes scan-move {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  50% {
    transform: translateY(160px);
    opacity: 1;
  }
}

.home-frame-pulse {
  animation: frame-pulse 3s ease-in-out infinite;
}

@keyframes frame-pulse {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

.home-content {
  position: relative;
  z-index: 1;
  order: 1;
  max-width: 480px;
}

.home-brand {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-size: clamp(44px, 7vw, 64px);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1;
  color: var(--text);
}

.home-headline {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--text);
}

.home-lead {
  margin: 0 0 28px;
  font-size: 15.5px;
  line-height: 1.7;
  color: var(--text-secondary);
}

.home-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.15s var(--ease), background 0.15s var(--ease), box-shadow 0.15s var(--ease),
    border-color 0.15s var(--ease), color 0.15s var(--ease);
}

.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--text);
  color: #fff;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  color: #fff;
  background: #1f2937;
}

:root[data-theme="dark"] .btn-primary,
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-primary {
    background: var(--brand);
    color: #0b0f14;
  }

  :root:not([data-theme="light"]) .btn-primary:hover {
    background: var(--brand-hover);
    color: #0b0f14;
  }
}

:root[data-theme="dark"] .btn-primary {
  background: var(--brand);
  color: #0b0f14;
}

:root[data-theme="dark"] .btn-primary:hover {
  background: var(--brand-hover);
  color: #0b0f14;
}

.btn-ghost {
  background: var(--bg-solid);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.btn-ghost:hover {
  color: var(--brand);
  border-color: var(--brand);
}

.btn-arrow {
  transition: transform 0.15s var(--ease);
}

.btn:hover .btn-arrow {
  transform: translateX(3px);
}

/* —— Callout —— */

.callout {
  display: flex;
  gap: 12px;
  margin: 20px 0;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-left-width: 3px;
  font-size: 16px;
  line-height: 1.65;
  background: var(--bg-muted);
}

.callout-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 11px;
  margin-top: 2px;
}

.callout-body {
  color: var(--text-secondary);
}

.callout-body > :first-child {
  margin-top: 0;
}

.callout-body > :last-child {
  margin-bottom: 0;
}

.callout.info {
  background: var(--info-bg);
  border-color: var(--border);
  border-left-color: var(--info);
}

.callout.info .callout-icon {
  background: color-mix(in srgb, var(--info) 15%, transparent);
  color: var(--info);
}

.callout.warn {
  background: var(--warn-bg);
  border-left-color: var(--warn);
}

.callout.warn .callout-icon {
  background: color-mix(in srgb, var(--warn) 15%, transparent);
  color: var(--warn);
}

.callout.danger {
  background: var(--danger-bg);
  border-left-color: var(--danger);
}

.callout.danger .callout-icon {
  background: color-mix(in srgb, var(--danger) 15%, transparent);
  color: var(--danger);
}

/* —— API endpoint —— */

.api-endpoint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 14px 0 8px;
  padding: 12px 14px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 15px;
}

.api-dir {
  margin: 0 0 20px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: color-mix(in srgb, var(--accent, #2563eb) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent, #2563eb) 28%, var(--border));
  border-radius: var(--radius);
}

.method {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.4;
}

.method.get { background: var(--method-get); }
.method.post { background: var(--method-post); }
.method.put { background: var(--method-put); }
.method.delete { background: var(--method-delete); }
.method.patch { background: var(--method-patch); }

.api-path {
  color: var(--text);
  word-break: break-all;
  font-weight: 500;
}

.api-base {
  color: var(--text-muted);
  font-size: 11.5px;
  margin-left: auto;
}

/* —— Param table —— */

.param-table-wrap {
  overflow-x: auto;
  margin: 12px 0 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-solid);
}

.param-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.param-table th,
.param-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.param-table th {
  background: var(--bg-muted);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.param-table tr:last-child td {
  border-bottom: none;
}

.param-table tbody tr:hover {
  background: var(--bg-muted);
}

.param-table td {
  color: var(--text-secondary);
}

.param-table code {
  font-family: var(--font-mono);
  font-size: 13.5px;
  color: var(--brand);
  background: none;
  padding: 0;
}

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-muted);
  color: var(--text-muted);
}

.badge.required {
  background: var(--danger-bg);
  color: var(--danger);
}

/* —— Code —— */

pre,
.code-block {
  position: relative;
  margin: 12px 0 18px;
  padding: 14px 16px;
  background: #0f1720;
  color: #d7e0ea;
  border-radius: var(--radius);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.65;
  border: 1px solid #1e2936;
}

code:not(pre code):not(.code-block code) {
  font-family: var(--font-mono);
  font-size: 0.86em;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-muted);
  color: var(--brand);
}

pre code,
.code-block code {
  font-family: inherit;
  font-size: inherit;
  background: none;
  padding: 0;
  color: inherit;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: #9aa6b5;
  font-family: var(--font-sans);
  font-size: 12px;
  cursor: pointer;
}

.copy-btn:hover {
  background: rgba(56, 189, 248, 0.18);
  color: #fff;
}

/* —— Tabs —— */

.tabs {
  margin: 12px 0 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-solid);
}

.tab-list {
  display: flex;
  gap: 2px;
  padding: 6px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-muted);
}

.tab-btn {
  padding: 6px 12px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--text);
  background: var(--bg-solid);
  box-shadow: var(--shadow);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.tab-panel pre,
.tab-panel .code-block {
  margin: 0;
  border-radius: 0;
  border: none;
}

/* —— Steps —— */

.steps {
  margin: 16px 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  position: relative;
  padding: 0 0 22px 40px;
  counter-increment: step;
  color: var(--text-secondary);
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 1px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--text);
  color: #fff;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: none;
}

:root[data-theme="dark"] .steps li::before {
  background: var(--brand);
  color: #0b0f14;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .steps li::before {
    background: var(--brand);
    color: #0b0f14;
  }
}

.steps li::after {
  content: "";
  position: absolute;
  left: 12px;
  top: 30px;
  bottom: 2px;
  width: 1px;
  background: var(--border-strong);
  opacity: 1;
}

.steps li:last-child {
  padding-bottom: 0;
}

.steps li:last-child::after {
  display: none;
}

.steps li > strong:first-child {
  display: block;
  margin-bottom: 4px;
  font-family: var(--font-sans);
  font-weight: 650;
  letter-spacing: 0;
  color: var(--text);
}

/* —— Footer —— */

.doc-footer {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-muted);
}

.site-beian {
  margin-top: 12px;
  padding-bottom: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.site-beian a {
  color: var(--text-muted);
  text-decoration: none;
}

.site-beian a:hover {
  color: var(--text-secondary);
  text-decoration: underline;
}

.site-footer {
  padding: 20px 28px 28px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.site-footer a {
  color: var(--text-muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--text-secondary);
  text-decoration: underline;
}

/* —— 假 404 门禁 —— */

body.page-gate {
  min-height: 100vh;
  margin: 0;
  background: #f7f8fa;
}

:root[data-theme="dark"] body.page-gate,
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body.page-gate {
    background: #0b0f14;
  }
}

.gate-404 {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  cursor: default;
  user-select: none;
}

.gate-404-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.gate-404-code {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: clamp(72px, 16vw, 120px);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  color: #111827;
}

:root[data-theme="dark"] .gate-404-code {
  color: #e8eef5;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .gate-404-code {
    color: #e8eef5;
  }
}

.gate-404-inner h1 {
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 650;
  color: #111827;
}

:root[data-theme="dark"] .gate-404-inner h1 {
  color: #e8eef5;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .gate-404-inner h1 {
    color: #e8eef5;
  }
}

.gate-404-desc {
  margin: 0;
  font-size: 15px;
  color: #6b7280;
}

.site-footer-gate {
  border-top: none;
  background: transparent;
}

.gate-catalog[hidden],
.gate-404[hidden] {
  display: none !important;
}

.page-catalog .site-footer {
  margin-top: auto;
}

/* —— Mobile —— */

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 23, 32, 0.5);
}

body.sidebar-open .sidebar-backdrop {
  display: block;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }

  .toc {
    display: none;
  }

  .main {
    border-right: none;
  }

  .home {
    grid-template-columns: 1fr;
    padding-top: 32px;
  }

  .home-visual {
    order: 0;
  }

  .home-visual svg {
    width: min(100%, 280px);
  }
}

@media (max-width: 800px) {
  .menu-toggle {
    display: inline-grid;
    place-items: center;
  }

  .header-nav {
    display: none;
  }

  .doc-meta-label {
    display: none;
  }

  .site-header {
    padding: 0 12px;
  }

  .site-header .brand {
    width: auto;
    background: transparent;
    color: var(--text);
    padding: 0;
  }

  .site-header .brand:hover {
    color: var(--text);
  }

  .layout,
  .layout.no-toc {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: var(--header-h);
    z-index: 90;
    width: min(var(--sidebar-w), 86vw);
    transform: translateX(-100%);
    transition: transform 0.22s var(--ease);
    box-shadow: var(--shadow-md);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .main {
    padding: 28px 18px 72px;
  }

  .home {
    padding: 24px 20px 48px;
  }

  .catalog {
    padding: 32px 18px 72px;
  }

  .catalog-grid {
    grid-template-columns: 1fr;
  }

  .home-brand {
    font-size: 42px;
  }

  .doc h1 {
    font-size: 30px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
