html:has(.page-docs) {
  scroll-behavior: auto;
}
.page-docs {
  background: var(--white);
}
.page-docs .site-header {
  background: rgba(255, 255, 255, 0.88);
}

/* 搜索按钮（页头） */
.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  min-width: 200px;
  padding: 0 8px 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--muted);
  font-size: 14px;
}
.search-trigger svg {
  width: 16px;
  height: 16px;
}
.search-trigger span {
  flex: 1;
  text-align: left;
}
.search-trigger:hover {
  border-color: var(--sage);
}

/* ===== 三栏布局 ===== */
.docs-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr) 220px;
  gap: 48px;
  max-width: 1360px;
  align-items: start;
}
.docs-sidebar,
.docs-toc {
  position: sticky;
  top: var(--header-h);
  max-height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 32px 0 48px;
  overscroll-behavior: contain;
}
.docs-sidebar {
  border-right: 1px solid var(--line);
  padding-right: 20px;
}
.sidebar-group + .sidebar-group {
  margin-top: 22px;
}
.sidebar-title {
  margin: 0 0 6px 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.docs-sidebar ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.docs-sidebar a {
  display: block;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 14.5px;
  line-height: 1.5;
  text-decoration: none;
}
.docs-sidebar a:hover {
  background: var(--paper-2);
  color: var(--text);
}
.docs-sidebar a[aria-current='page'] {
  background: var(--green-soft);
  color: var(--green-strong);
  font-weight: 600;
}
.badge-draft {
  margin-left: 4px;
  padding: 0 6px;
  border-radius: 4px;
  background: #fff1d6;
  color: #9a6400;
  font-size: 11px;
}
.sidebar-toggle {
  display: none;
}

.docs-toc {
  font-size: 13px;
}
.toc-title {
  margin-bottom: 10px;
  font-weight: 700;
  color: var(--text);
}
.docs-toc ul {
  margin: 0;
  padding: 0;
  list-style: none;
  border-left: 1px solid var(--line);
}
.docs-toc a,
.docs-toc a:visited {
  display: block;
  padding: 4px 0 4px 14px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--muted);
  line-height: 1.5;
  text-decoration: none;
}
.docs-toc .toc-d3 a {
  padding-left: 26px;
}
.docs-toc a:hover {
  color: var(--text);
}
.docs-toc a.is-active,
.docs-toc a.is-active:visited {
  color: var(--green-strong);
  border-left-color: var(--green);
  font-weight: 600;
}

/* ===== 正文排版 ===== */
.doc {
  min-width: 0;
  max-width: 780px;
  padding: 40px 0 80px;
}
.doc-breadcrumb {
  font-size: 13px;
  font-weight: 600;
  color: var(--green-strong);
}
.doc-title {
  margin-top: 8px;
  font-size: clamp(28px, 3.4vw, 38px);
  font-weight: 800;
}
.doc-lead {
  margin-top: 14px;
  font-size: 18px;
  color: var(--text-2);
}
.doc-title + .callout,
.doc-lead + .callout {
  margin-top: 24px;
}
.doc-content {
  margin-top: 32px;
  font-size: 16px;
  line-height: 1.85;
  color: var(--text);
}
.doc-content > * + * {
  margin-top: 1.1em;
}
.doc-content h2,
.doc-content h3,
.doc-content h4 {
  position: relative;
  scroll-margin-top: calc(var(--header-h) + 20px);
}
.doc-content h2 {
  margin-top: 2.4em;
  padding-top: 0.6em;
  border-top: 1px solid var(--line);
  font-size: 24px;
}
.doc-content > h2:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}
.doc-content h3 {
  margin-top: 1.8em;
  font-size: 19px;
}
.doc-content h4 {
  margin-top: 1.5em;
  font-size: 16px;
}
.heading-anchor {
  position: absolute;
  left: -1.1em;
  padding-right: 0.3em;
  color: var(--sage);
  opacity: 0;
  text-decoration: none !important;
  font-weight: 400;
}
.doc-content h2:hover .heading-anchor,
.doc-content h3:hover .heading-anchor,
.doc-content h4:hover .heading-anchor,
.heading-anchor:focus {
  opacity: 1;
}
.doc-content ul,
.doc-content ol {
  padding-left: 1.4em;
}
.doc-content li + li {
  margin-top: 0.35em;
}
.doc-content li > ul,
.doc-content li > ol {
  margin-top: 0.35em;
}
.doc-content a {
  text-decoration: underline;
  text-decoration-color: rgba(0, 143, 74, 0.35);
  text-underline-offset: 3px;
}
.doc-content a:hover {
  text-decoration-color: currentColor;
}
.doc-content strong {
  font-weight: 700;
}
.doc-content blockquote {
  margin-left: 0;
  margin-right: 0;
  padding: 2px 0 2px 18px;
  border-left: 3px solid var(--line);
  color: var(--text-2);
}
.doc-content hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2.4em 0;
}
.doc-content :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 0.12em 0.4em;
  border-radius: 6px;
  background: var(--paper-2);
  border: 1px solid #e8e4d8;
}
.doc-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  cursor: zoom-in;
}
.doc-figure {
  margin: 1.6em 0;
}
.doc-figure figcaption {
  margin-top: 8px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* 代码块 */
.code-block {
  position: relative;
  border-radius: var(--radius);
  background: var(--ink);
  overflow: hidden;
}
.code-block pre {
  margin: 0;
  padding: 18px 20px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.7;
  color: #e6efe9;
}
.code-lang {
  position: absolute;
  top: 8px;
  left: 14px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--sage);
  text-transform: uppercase;
}
.code-block:has(.code-lang) pre {
  padding-top: 30px;
}
.code-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  border: 1px solid rgba(237, 234, 225, 0.2);
  border-radius: 6px;
  background: rgba(237, 234, 225, 0.06);
  color: rgba(237, 234, 225, 0.8);
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.code-block:hover .code-copy,
.code-copy:focus {
  opacity: 1;
}

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

/* 提示块 */
.callout {
  --c: var(--green);
  --bg: #effaf3;
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
  border-left-width: 4px;
  border-left-color: var(--c);
  background: var(--bg);
}
.callout-info {
  --c: #3a7bd5;
  --bg: #eff5fd;
}
.callout-warning {
  --c: #d99a00;
  --bg: #fff8e6;
}
.callout-danger {
  --c: #d4482b;
  --bg: #fdf0ec;
}
.callout-title {
  font-weight: 700;
  color: color-mix(in srgb, var(--c) 75%, var(--text));
  margin-bottom: 4px;
}
.callout-body > * + * {
  margin-top: 0.7em;
}
.callout-details {
  --c: var(--sage);
  --bg: var(--paper-2);
}
.callout-details summary {
  font-weight: 700;
  cursor: pointer;
}
.callout-details[open] summary {
  margin-bottom: 8px;
}

.doc-download {
  margin: 1.6em 0;
  padding: 20px;
  border-radius: var(--radius);
  background: var(--paper-2);
  border: 1px solid var(--line);
}

/* 上下篇 */
.doc-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 64px;
}
.doc-pager a {
  display: grid;
  gap: 2px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color 0.2s ease;
}
.doc-pager a:hover {
  border-color: var(--green);
}
.doc-pager span {
  font-size: 13px;
  color: var(--muted);
}
.doc-pager strong {
  color: var(--text);
}
.pager-next {
  text-align: right;
  grid-column: 2;
}

/* ===== 更新日志卡片 ===== */
.changelog-feed {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin: 24px 0 32px;
}
.changelog-item {
  position: relative;
  padding: 22px 26px;
  border-radius: var(--radius);
  background: var(--paper-2);
  border: 1px solid var(--line);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.changelog-item:hover {
  border-color: var(--line-bold);
}
.changelog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.changelog-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  font-size: 20px !important;
}
.changelog-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}
.changelog-item ul,
.changelog-item ol {
  margin: 0 !important;
  padding-left: 20px !important;
}
.changelog-item li {
  margin-bottom: 6px;
  line-height: 1.7;
  color: var(--text);
}
.changelog-item li:last-child {
  margin-bottom: 0;
}
.changelog-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--green-subtle);
  color: var(--green);
}
.changelog-date {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.changelog-loading,
.changelog-empty,
.changelog-error {
  padding: 36px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  background: var(--paper-2);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.changelog-error {
  color: var(--text);
  border-color: rgba(220, 38, 38, 0.3);
}
.changelog-error button {
  margin-left: 8px;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--text);
  cursor: pointer;
}

/* ===== 搜索弹窗 ===== */
.search-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  justify-content: center;
  padding: 10vh 16px 16px;
}
.search-modal[hidden] {
  display: none;
}
.search-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 17, 16, 0.5);
  backdrop-filter: blur(3px);
}
.search-panel {
  position: relative;
  width: 100%;
  max-width: 640px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  background: var(--white);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.search-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}
.search-input-row svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
}
.search-input-row input {
  flex: 1;
  height: 56px;
  border: 0;
  outline: 0;
  font: inherit;
  font-size: 17px;
  background: transparent;
}
.search-input-row kbd {
  cursor: pointer;
}
.search-results {
  margin: 0;
  padding: 8px;
  list-style: none;
  overflow-y: auto;
}
.search-results a {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
}
.search-results a:hover,
.search-results li.is-active a {
  background: var(--green-soft);
}
.sr-path {
  font-size: 12px;
  color: var(--muted);
}
.sr-title {
  font-weight: 600;
}
.sr-snippet {
  margin-top: 2px;
  font-size: 13px;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.search-results mark {
  background: rgba(0, 168, 87, 0.22);
  color: inherit;
  border-radius: 3px;
}
.search-empty {
  padding: 28px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* 图片放大 */
.zoom-overlay {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  place-items: center;
  padding: 4vh 4vw;
  background: rgba(8, 17, 16, 0.86);
  cursor: zoom-out;
}
.zoom-overlay[hidden] {
  display: none;
}
.zoom-overlay img {
  max-width: 100%;
  max-height: 92vh;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

/* ===== 响应式 ===== */
@media (max-width: 1180px) {
  .docs-shell {
    grid-template-columns: 232px minmax(0, 1fr);
    gap: 40px;
  }
  .docs-toc {
    display: none;
  }
}
@media (max-width: 860px) {
  .search-trigger {
    min-width: 0;
    width: 36px;
    padding: 0;
    justify-content: center;
  }
  .search-trigger span,
  .search-trigger kbd {
    display: none;
  }
  .docs-shell {
    display: block;
  }
  .sidebar-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 16px 0 0;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--white);
    font-size: 14px;
    font-weight: 600;
  }
  .sidebar-toggle svg {
    width: 16px;
    height: 16px;
  }
  .docs-sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    z-index: 40;
    width: min(320px, 86vw);
    max-height: none;
    padding: 20px;
    background: var(--white);
    border-right: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    transform: translateX(-105%);
    transition: transform 0.25s ease;
  }
  .sidebar-open .docs-sidebar {
    transform: none;
  }
  .doc {
    padding-top: 20px;
  }
  .heading-anchor {
    display: none;
  }
}
