:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #5f6b7a;
  --line: #d9dee7;
  --brand: #2563eb;
  --brand-strong: #1d4ed8;
  --code-bg: #111827;
  --code-text: #e5e7eb;
  --ok-bg: #ecfdf5;
  --ok-text: #047857;
  --warn-bg: #fff7ed;
  --warn-text: #c2410c;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.72;
}

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

a:hover {
  text-decoration: underline;
}

.page-hero {
  background: #0f172a;
  color: white;
  padding: 44px max(24px, calc((100vw - 1180px) / 2)) 36px;
}

.eyebrow {
  margin: 0 0 10px;
  color: #bfdbfe;
  font-size: 14px;
}

.page-hero h1 {
  margin: 0;
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1.08;
  letter-spacing: 0;
}

.page-hero .subtitle {
  margin: 16px 0 0;
  max-width: 760px;
  color: #dbeafe;
  font-size: 18px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.page-hero .button {
  border-color: rgba(255, 255, 255, .25);
  background: rgba(255, 255, 255, .08);
  color: white;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 270px) minmax(0, 1fr);
  gap: 28px;
  width: min(1180px, calc(100% - 48px));
  margin: 28px auto 56px;
  align-items: start;
}

.toc {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.toc h2 {
  margin: 0 0 10px;
  font-size: 15px;
}

.toc a {
  display: block;
  padding: 5px 0;
  color: var(--muted);
  font-size: 14px;
}

.toc a.depth-2 {
  color: var(--text);
  font-weight: 650;
}

.toc a.depth-4,
.toc a.depth-5 {
  padding-left: 14px;
  font-size: 13px;
}

.content {
  min-width: 0;
}

.doc-section {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.doc-section + .doc-section,
.code-demo + .doc-section {
  margin-top: 18px;
}

.doc-section h2,
.doc-section h3,
.doc-section h4,
.doc-section h5 {
  margin: 0 0 14px;
  line-height: 1.32;
  letter-spacing: 0;
}

.doc-section h2 {
  font-size: 28px;
}

.doc-section h3 {
  font-size: 23px;
}

.doc-section h4 {
  font-size: 19px;
}

.doc-section p {
  margin: 10px 0;
}

.doc-section ul,
.doc-section ol {
  padding-left: 24px;
}

.demo-links {
  margin: 16px 0 18px;
  padding: 16px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
}

.demo-links h3 {
  margin: 0 0 12px;
  font-size: 17px;
}

.demo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.demo-card {
  display: block;
  min-height: 84px;
  padding: 12px;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  background: #ffffff;
}

.demo-card strong,
.demo-card span {
  display: block;
}

.demo-card span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.code-demo {
  margin: 18px 0;
  border: 1px solid #243044;
  border-radius: 8px;
  overflow: hidden;
  background: var(--code-bg);
}

.code-demo figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid #243044;
  color: #cbd5e1;
  font-size: 13px;
}

.code-actions {
  display: flex;
  gap: 8px;
}

.code-actions button {
  min-height: 30px;
  padding: 4px 10px;
  border: 1px solid #475569;
  border-radius: 6px;
  background: #1f2937;
  color: #e5e7eb;
  cursor: pointer;
}

pre {
  margin: 0;
  overflow: auto;
  padding: 16px;
}

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
}

pre code {
  display: block;
  color: var(--code-text);
  line-height: 1.62;
  white-space: pre;
}

.demo-output {
  display: none;
  margin: 0;
  padding: 12px 16px;
  border-top: 1px solid #243044;
  background: #020617;
  color: #bbf7d0;
  white-space: pre-wrap;
}

.demo-output.is-visible {
  display: block;
}

.note {
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--ok-bg);
  color: var(--ok-text);
}

.source-note {
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
    width: min(100% - 28px, 760px);
  }

  .toc {
    position: static;
    max-height: none;
  }

  .doc-section {
    padding: 20px;
  }
}
