/* 文档阅读布局：侧边导航、正文、页内目录、代码与表格。 */
.page-docs { background: var(--bg); }
.docs-shell {
  display: grid; grid-template-columns: 272px minmax(0, 1fr) 232px; gap: 0 40px;
  max-width: 1440px; margin: 0 auto; padding: 0 24px;
}

.page-docs--wide .docs-shell { grid-template-columns: 272px minmax(0, 1fr); }
.page-docs--wide .docs-toc { display: none; }
.page-docs--wide .doc-content, .page-docs--wide .doc-meta, .page-docs--wide .pager { max-width: 1120px; }
.page-docs--wide .doc-content > p, .page-docs--wide .doc-content > ul, .page-docs--wide .doc-content > ol { max-width: 820px; }

/* 侧边导航 */
.docs-sidebar {
  position: sticky; top: 64px; align-self: start; height: calc(100vh - 64px); overflow-y: auto; overscroll-behavior: contain;
  padding: 28px 12px 40px 0; border-right: 1px solid var(--border); scrollbar-width: thin;
}
.docs-sidebar__head { display: none; }
.docs-nav__section + .docs-nav__section { margin-top: 22px; }
.docs-nav__title { margin: 0 0 6px; padding: 0 12px; color: var(--text-muted); font-size: 12px; font-weight: 650; letter-spacing: .08em; }
.docs-nav ul { margin: 0; padding: 0; list-style: none; }
.docs-nav li a {
  position: relative; display: block; padding: 6px 12px; border-radius: var(--radius-sm); color: var(--text-2);
  font-size: 14px; line-height: 1.5; transition: background var(--dur-fast), color var(--dur-fast);
}
.docs-nav li a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.docs-nav li a.is-active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.docs-nav li a.is-active::before {
  content: ""; position: absolute; left: 0; top: 7px; bottom: 7px; width: 2px; border-radius: 2px; background: var(--brand-gradient);
}
.docs-nav__cta {
  display: flex; align-items: center; gap: 8px; margin: 26px 0 0; padding: 12px; border: 1px solid var(--border);
  border-radius: var(--radius-md); background: linear-gradient(135deg, var(--accent-soft), var(--violet-soft)); color: var(--text); font-size: 13px; font-weight: 600;
}
.docs-nav__cta:hover { border-color: var(--accent); text-decoration: none; }
.docs-sidebar__scrim { display: none; }

/* 正文 */
.docs-main { min-width: 0; padding: 28px 0 72px; outline: none; }
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 18px; color: var(--text-muted); font-size: 13px; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb [aria-current] { color: var(--text-2); }
.doc-content { max-width: 820px; color: var(--text-2); font-size: 16px; line-height: 1.85; }
.doc-content > :first-child { margin-top: 0; }
.doc-content h1, .doc-content h2, .doc-content h3, .doc-content h4 { position: relative; color: var(--text); letter-spacing: -.01em; line-height: 1.35; }
.doc-content h1 { margin: 0 0 18px; font-size: clamp(30px, 4vw, 40px); font-weight: 760; letter-spacing: -.025em; }
.doc-content h1 + p { color: var(--text-2); font-size: 18px; line-height: 1.8; }
.doc-content h2 { margin: 56px 0 16px; padding-top: 22px; border-top: 1px solid var(--border); font-size: 24px; font-weight: 700; }
.doc-content h3 { margin: 36px 0 12px; font-size: 18.5px; font-weight: 680; }
.doc-content h4 { margin: 26px 0 8px; font-size: 16px; }
.doc-content p, .doc-content ul, .doc-content ol { margin: 0 0 16px; }
.doc-content ul, .doc-content ol { padding-left: 1.4em; }
.doc-content li { margin: 4px 0; }
.doc-content li::marker { color: var(--text-muted); }
.doc-content strong { color: var(--text); font-weight: 650; }
.doc-content a { color: var(--accent-text); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent-text) 35%, transparent); text-underline-offset: 3px; }
.doc-content a:hover { text-decoration-color: currentColor; }
.doc-content hr { margin: 40px 0; border: 0; border-top: 1px solid var(--border); }
.doc-content img { border-radius: var(--radius-md); }
.heading-anchor {
  position: absolute; left: -1.1em; padding-right: .3em; color: var(--text-muted); opacity: 0; text-decoration: none !important;
  transition: opacity var(--dur-fast);
}
.doc-content h2 .heading-anchor { top: 22px; }
.doc-content :is(h2, h3, h4):hover .heading-anchor, .heading-anchor:focus-visible { opacity: 1; }

/* 行内代码 */
.doc-content :not(pre) > code {
  padding: .12em .42em; border: 1px solid var(--border); border-radius: 5px; background: var(--surface-2);
  color: var(--text); font-size: .86em; overflow-wrap: anywhere;
}

/* 代码块（Rouge） */
.doc-content .highlighter-rouge, .doc-content pre { position: relative; }
.doc-content div.highlighter-rouge { margin: 20px 0 24px; }
.doc-content pre {
  margin: 0; padding: 18px 20px; overflow-x: auto; border: 1px solid var(--code-border); border-radius: var(--radius-md);
  background: var(--code-bg); color: #dbe4f3; font-size: 13.5px; line-height: 1.7; tab-size: 4; scrollbar-width: thin;
}
.doc-content div.highlighter-rouge pre { padding-top: 48px; }
.doc-content div.highlighter-rouge[data-lang]::before {
  content: attr(data-lang); position: absolute; z-index: 1; top: 14px; left: 20px; max-width: calc(100% - 104px);
  padding: 0 8px; overflow: hidden; border-radius: 999px; white-space: nowrap; text-overflow: ellipsis; pointer-events: none;
  background: var(--code-bg); border: 1px solid var(--code-border); color: #8a96ad; font: 600 10.5px/18px var(--font-mono); letter-spacing: .08em; text-transform: uppercase;
}
.copy-btn {
  position: absolute; z-index: 1; top: 10px; right: 10px; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px;
  border: 1px solid #26324a; border-radius: var(--radius-sm); background: #121a2a; color: #aab4c8; font-size: 12px; opacity: 0;
  transition: opacity var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}
.highlighter-rouge:hover .copy-btn, pre:hover + .copy-btn, .copy-btn:focus-visible, .copy-btn.is-copied { opacity: 1; }
.copy-btn:hover { color: #fff; border-color: #3a4866; }
.copy-btn.is-copied { color: #6ee7b7; border-color: rgba(52, 211, 153, .5); }
@media (hover: none) { .copy-btn { opacity: 1; } }

/* Rouge 配色：深色代码面板在两种主题下保持一致 */
.highlight .c, .highlight .c1, .highlight .cm, .highlight .cs, .highlight .cp { color: #6b7894; font-style: italic; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kp, .highlight .kr, .highlight .kc { color: #b49bff; }
.highlight .kt, .highlight .nc, .highlight .nn { color: #6eeeff; }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb, .highlight .sc, .highlight .sh, .highlight .sx, .highlight .dl { color: #9ee6a8; }
.highlight .se, .highlight .si { color: #ffcc80; }
.highlight .m, .highlight .mi, .highlight .mf, .highlight .mh, .highlight .il { color: #ffb38a; }
.highlight .nf, .highlight .fm, .highlight .nx + .p + .nx { color: #7cc4ff; }
.highlight .nb, .highlight .bp { color: #ff9bd2; }
.highlight .o, .highlight .ow { color: #8fd3ff; }
.highlight .p { color: #9aa6bd; }
.highlight .nv, .highlight .vi, .highlight .na { color: #ffd58a; }
.highlight .gp { color: #6b7894; user-select: none; }
.highlight .err { color: inherit; background: none; }

/* 表格 */
.table-wrap { margin: 20px 0 26px; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); scrollbar-width: thin; }
.doc-content table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.65; }
.doc-content th, .doc-content td { padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.doc-content th { background: var(--surface-2); color: var(--text); font-weight: 600; white-space: nowrap; }
.doc-content tr:last-child td { border-bottom: 0; }
.doc-content td code { white-space: nowrap; }

/* 提示块：支持 GitHub 的 > [!NOTE] 语法 */
.callout {
  --callout: var(--accent); margin: 22px 0; padding: 14px 18px 14px 16px; border: 1px solid color-mix(in srgb, var(--callout) 32%, var(--border));
  border-left: 3px solid var(--callout); border-radius: var(--radius-md); background: color-mix(in srgb, var(--callout) 7%, transparent); color: var(--text-2);
}
.callout > :last-child { margin-bottom: 0; }
.callout__title { display: flex; align-items: center; gap: 8px; margin: 0 0 6px !important; color: var(--callout); font-size: 14px; font-weight: 700; }
.callout--tip { --callout: var(--state-done); }
.callout--important { --callout: var(--accent-2); }
.callout--warning { --callout: var(--state-partial); }
.callout--caution { --callout: var(--state-none); }
:root[data-theme="light"] .callout--warning { --callout: #b45309; }
:root[data-theme="light"] .callout--tip { --callout: #047857; }
:root[data-theme="light"] .callout--caution { --callout: #b42318; }
.doc-content blockquote:not(.callout) { margin: 20px 0; padding: 4px 18px; border-left: 3px solid var(--border-strong); color: var(--text-muted); }

/* 步骤卡片：快速开始等页面使用 <ol class="steps"> 风格 */
.doc-content .lead { font-size: 18px; color: var(--text-2); }
.doc-content .card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 22px 0 28px; padding: 0; list-style: none; }
.doc-content .card-grid li { margin: 0; }
.doc-content .card-grid a {
  display: block; height: 100%; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface);
  color: var(--text); text-decoration: none; transition: border-color var(--dur-fast), transform var(--dur-fast) var(--ease-out);
}
.doc-content .card-grid a:hover { border-color: var(--accent); transform: translateY(-2px); }
.doc-content .card-grid strong { display: block; margin-bottom: 4px; }
.doc-content .card-grid span { color: var(--text-muted); font-size: 14px; line-height: 1.6; }

/* 元信息与翻页 */
.doc-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 20px; max-width: 820px; margin-top: 56px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 13px; }
.doc-meta a { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); }
.doc-meta a:hover { color: var(--text); }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 820px; margin-top: 24px; }
.pager__link { display: flex; flex-direction: column; gap: 2px; padding: 14px 18px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); color: var(--text); transition: border-color var(--dur-fast); }
.pager__link:hover { border-color: var(--accent); text-decoration: none; }
.pager__link small { color: var(--text-muted); font-size: 12px; }
.pager__link span { font-weight: 600; }
.pager__link--next { grid-column: 2; text-align: right; }

/* 页内目录 */
.docs-toc { position: sticky; top: 64px; align-self: start; max-height: calc(100vh - 64px); overflow-y: auto; padding: 32px 0 40px; scrollbar-width: thin; }
.docs-toc__title { margin: 0 0 10px; color: var(--text); font-size: 12px; font-weight: 650; letter-spacing: .08em; }
.docs-toc__list { margin: 0; padding: 0; list-style: none; border-left: 1px solid var(--border); }
.docs-toc__list a { display: block; margin-left: -1px; padding: 4px 0 4px 14px; border-left: 2px solid transparent; color: var(--text-muted); font-size: 13px; line-height: 1.5; }
.docs-toc__list a:hover { color: var(--text); text-decoration: none; }
.docs-toc__list a.is-active { border-left-color: var(--accent); color: var(--accent-text); }
.docs-toc__list .toc-h3 a { padding-left: 26px; font-size: 12.5px; }
.docs-toc:has(.docs-toc__list:empty) { visibility: hidden; }

@media (max-width: 1200px) {
  .docs-shell { grid-template-columns: 248px minmax(0, 1fr); gap: 0 36px; }
  .docs-toc { display: none; }
}
@media (max-width: 960px) {
  .sidebar-toggle { display: inline-grid; }
  .docs-shell { display: block; padding: 0 16px; }
  .docs-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 60; width: min(320px, 86vw); height: 100dvh; padding: 0 12px 32px;
    border-right: 1px solid var(--border-strong); background: var(--bg-elev); box-shadow: var(--shadow-lg);
    transform: translateX(-104%); visibility: hidden; transition: transform var(--dur-mid) var(--ease-out), visibility 0s linear var(--dur-mid);
  }
  .docs-sidebar.is-open { transform: none; visibility: visible; transition: transform var(--dur-mid) var(--ease-out); }
  .docs-sidebar__head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; height: 58px; margin: 0 -12px 12px; padding: 0 8px 0 24px; border-bottom: 1px solid var(--border); background: var(--bg-elev); color: var(--text); font-weight: 650; }
  .docs-sidebar__scrim { position: fixed; inset: 0; z-index: 55; display: block; background: rgba(3, 6, 12, .55); }
  .docs-sidebar__scrim[hidden] { display: none; }
  .docs-main { padding-top: 20px; }
  .doc-content h2 { margin-top: 44px; font-size: 22px; }
  .heading-anchor { display: none; }
}
@media (max-width: 560px) {
  .doc-content { font-size: 15.5px; }
  .doc-content pre { margin: 0 -16px; padding: 16px; border-left: 0; border-right: 0; border-radius: 0; font-size: 12.5px; }
  .doc-content div.highlighter-rouge[data-lang]::before { left: 0; }
  .doc-content div.highlighter-rouge > .copy-btn { right: 0; }
  .table-wrap { margin-left: -16px; margin-right: -16px; border-left: 0; border-right: 0; border-radius: 0; }
  .pager { grid-template-columns: 1fr; }
  .pager__link--next { grid-column: 1; }
}
