/* ============ Global Navigation — Anthropic-style ============ */
/* CSS variables for nav, with fallbacks. Sub-pages should define
   --bg / --text / --text-muted / --border / --accent / --bg-hover
   for full theme integration. */

/* Fallback sizing — prevents oversized SVG flash before nav.css applies.
   Each component below overrides with its specific size. */
.qa-nav-top svg, .qa-nav-bottom svg, .qa-sidebar svg,
.qa-related svg, .qa-docs-dropdown svg, .qa-cmdk-overlay svg,
.qa-progress-ring svg, .qa-toc-toggle svg {
  width: 1em; height: 1em;
}

/* Reset for all nav-injected anchors — sub-pages decorate <a> with
   border-bottom (faux underline), which we don't want inside nav UI. */
.qa-nav-top a, .qa-nav-top a:hover, .qa-nav-top a:focus,
.qa-nav-bottom a, .qa-nav-bottom a:hover, .qa-nav-bottom a:focus,
.qa-sidebar a, .qa-sidebar a:hover, .qa-sidebar a:focus,
.qa-related a, .qa-related a:hover, .qa-related a:focus,
.qa-docs-dropdown a, .qa-docs-dropdown a:hover, .qa-docs-dropdown a:focus,
.qa-cmdk-overlay a, .qa-cmdk-overlay a:hover, .qa-cmdk-overlay a:focus {
  border: none;
  text-decoration: none;
}

.qa-nav-top {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 900;
  height: 56px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: color-mix(in srgb, var(--bg, #FDFDFC) 82%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--border, rgba(31, 30, 29, 0.10));
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", sans-serif;
  font-size: 14px;
  transition: background 0.3s, border-color 0.3s;
}

/* Brand on the left */
.qa-nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text, #141413);
  text-decoration: none;
  border: none;
  flex-shrink: 0;
}
.qa-nav-brand:hover,
.qa-nav-brand:focus {
  text-decoration: none;
  border: none;
}
.qa-nav-brand .brand-mark {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.qa-nav-brand .brand-mark svg { width: 26px; height: 26px; display: block; }
.qa-nav-brand .brand-text {
  font-family: "Anthropic Serif", Georgia, "Noto Serif SC", serif;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.qa-nav-brand .brand-text em {
  font-style: italic;
  color: var(--accent, #D97757);
}

/* Center: prev/next + back */
.qa-nav-center {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  justify-content: center;
  min-width: 0;
}
.qa-nav-center a {
  color: var(--text-muted, #5c5b56);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  white-space: nowrap;
  transition: color 0.2s, background 0.2s;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.qa-nav-center a:hover {
  color: var(--accent, #D97757);
  background: var(--bg-hover, rgba(31,30,29,0.04));
}
.qa-nav-center .nav-disabled {
  opacity: 0.35;
  pointer-events: none;
}
.qa-nav-center svg { width: 13px; height: 13px; flex-shrink: 0; }
.qa-nav-center .nav-divider {
  width: 1px; height: 14px;
  background: var(--border, rgba(31,30,29,0.15));
  margin: 0 4px;
}

/* Right: back to index + theme toggle */
.qa-nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.qa-nav-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted, #5c5b56);
  text-decoration: none;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border, rgba(31,30,29,0.15));
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.2s;
  flex-shrink: 0;
}
.qa-nav-back:hover {
  color: var(--accent, #D97757);
  border-color: var(--accent, #D97757);
  background: var(--bg-hover, rgba(31,30,29,0.04));
}
.qa-nav-back svg { width: 13px; height: 13px; }

.qa-nav-theme {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--border, rgba(31,30,29,0.15));
  background: transparent;
  color: var(--text-muted, #5c5b56);
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.qa-nav-theme:hover {
  color: var(--accent, #D97757);
  border-color: var(--accent, #D97757);
  background: var(--bg-hover, rgba(31,30,29,0.04));
}
.qa-nav-theme svg { width: 16px; height: 16px; }
[data-theme="dark"] .qa-nav-theme .icon-sun { display: block; }
[data-theme="dark"] .qa-nav-theme .icon-moon { display: none; }
.qa-nav-theme .icon-sun { display: none; }
.qa-nav-theme .icon-moon { display: block; }

/* ============ Mobile bottom tab bar ============ */
.qa-nav-bottom {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 900;
  height: 60px;
  padding: 0 8px env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg, #FDFDFC) 88%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-top: 1px solid var(--border, rgba(31,30,29,0.10));
  align-items: center;
  justify-content: space-around;
  font-family: system-ui, -apple-system, "PingFang SC", sans-serif;
  font-size: 11px;
}
.qa-nav-bottom a {
  color: var(--text-muted, #5c5b56);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 16px;
  border-radius: 10px;
  min-width: 60px;
  transition: color 0.2s, background 0.2s;
}
.qa-nav-bottom a:active,
.qa-nav-bottom a:hover { color: var(--accent, #D97757); background: var(--bg-hover, rgba(31,30,29,0.04)); }
.qa-nav-bottom .nav-disabled { opacity: 0.3; pointer-events: none; }
.qa-nav-bottom svg { width: 18px; height: 18px; }

/* ============ Reading progress ring ============ */
.qa-progress-ring {
  position: fixed;
  bottom: 28px; right: 28px;
  z-index: 800;
  width: 44px; height: 44px;
  cursor: pointer;
  opacity: 0;
  transform: scale(0.85) translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  border-radius: 50%;
  background: color-mix(in srgb, var(--bg, #FDFDFC) 90%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 16px rgba(31,30,29,0.08), 0 0 0 1px var(--border, rgba(31,30,29,0.10));
}
.qa-progress-ring.visible {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}
.qa-progress-ring:hover { transform: scale(1.06); }
.qa-progress-ring svg {
  width: 44px; height: 44px;
  transform: rotate(-90deg);
}
.qa-progress-ring .ring-bg {
  fill: none;
  stroke: var(--border, rgba(31,30,29,0.12));
  stroke-width: 2.5;
}
.qa-progress-ring .ring-fill {
  fill: none;
  stroke: var(--accent, #D97757);
  stroke-width: 2.5;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.1s linear;
}
.qa-progress-ring .ring-percent {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted, #5c5b56);
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  letter-spacing: -0.02em;
}

/* ============ Responsive ============ */
@media (max-width: 768px) {
  .qa-nav-top { display: none; }
  .qa-nav-bottom { display: flex; }
  .qa-progress-ring { bottom: 76px; right: 20px; }
}
@media (min-width: 769px) {
  .qa-nav-top { display: flex; }
  .qa-nav-bottom { display: none; }
}

/* Body offset for fixed nav */
body.has-qa-nav { padding-top: 56px; }
@media (max-width: 768px) {
  body.has-qa-nav { padding-top: 0; padding-bottom: 60px; }
}

/* ============ Subpage top nav · ⌘K button ============ */
.qa-nav-cmdk {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 12px;
  font-size: 13px;
  color: var(--text-muted, #5c5b56);
  background: transparent;
  border: 1px solid var(--border, rgba(31,30,29,0.15));
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  font-family: inherit;
}
.qa-nav-cmdk:hover {
  color: var(--accent, #D97757);
  border-color: var(--accent, #D97757);
  background: var(--bg-hover, rgba(31,30,29,0.04));
}
.qa-nav-cmdk svg { width: 14px; height: 14px; }
.qa-nav-cmdk kbd {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 10px;
  padding: 1px 5px;
  background: var(--bg, #FDFDFC);
  border: 1px solid var(--border, rgba(31,30,29,0.15));
  border-radius: 4px;
  color: var(--text-muted, #5c5b56);
  letter-spacing: 0.04em;
}

/* ============ Subpage bottom nav · search button ============ */
.qa-nav-bottom-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted, #5c5b56);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 14px;
  border-radius: 10px;
  min-width: 60px;
  font: 11px/1 system-ui, -apple-system, "PingFang SC", sans-serif;
  transition: color 0.2s, background 0.2s;
}
.qa-nav-bottom-btn:hover,
.qa-nav-bottom-btn:active {
  color: var(--accent, #D97757);
  background: var(--bg-hover, rgba(31,30,29,0.04));
}
.qa-nav-bottom-btn svg { width: 18px; height: 18px; }
.qa-nav-bottom a, .qa-nav-bottom-btn { padding: 8px 12px; min-width: 56px; }

/* ============ Homepage docs dropdown ============ */
.qa-docs-dropdown-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.qa-docs-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  width: 380px;
  /* 菜单从顶栏下约 58px 处展开，底部留 14px：视口 ≥ 700px 时整张菜单放得下，不出现滚动条 */
  max-height: calc(100vh - 72px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg-elevated, #ffffff);
  border: 1px solid var(--line, rgba(31,30,29,0.10));
  border-radius: 14px;
  box-shadow: 0 16px 48px -16px rgba(31,30,29,0.18), 0 2px 8px rgba(31,30,29,0.04);
  padding: 14px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
  z-index: 200;
  font-family: system-ui, -apple-system, "PingFang SC", sans-serif;
}
[data-theme="dark"] .qa-docs-dropdown {
  background: var(--bg-elevated, #2c2b29);
  box-shadow: 0 16px 48px -16px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.2);
}
/* 屏幕矮、需要滚动时：细圆角滑块、无箭头，上下留白避开圆角。
   Chrome 121+ 只要设了 scrollbar-color / scrollbar-width 就忽略 ::-webkit-scrollbar，所以标准属性只给不支持后者的 Firefox */
.qa-docs-dropdown::-webkit-scrollbar { width: 12px; }
.qa-docs-dropdown::-webkit-scrollbar-track { background: transparent; margin: 14px 0; }
.qa-docs-dropdown::-webkit-scrollbar-thumb {
  background: rgba(31,30,29,0.16) padding-box;
  border: 4px solid transparent;
  border-radius: 999px;
}
.qa-docs-dropdown::-webkit-scrollbar-thumb:hover { background-color: rgba(31,30,29,0.30); }
[data-theme="dark"] .qa-docs-dropdown::-webkit-scrollbar-thumb { background-color: rgba(222,220,209,0.18); }
[data-theme="dark"] .qa-docs-dropdown::-webkit-scrollbar-thumb:hover { background-color: rgba(222,220,209,0.32); }
@supports not selector(::-webkit-scrollbar) {
  .qa-docs-dropdown { scrollbar-width: thin; scrollbar-color: rgba(31,30,29,0.20) transparent; }
  [data-theme="dark"] .qa-docs-dropdown { scrollbar-color: rgba(222,220,209,0.22) transparent; }
}
.qa-docs-dropdown-wrap.is-open .qa-docs-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.qa-docs-dropdown-group + .qa-docs-dropdown-group {
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--line, rgba(31,30,29,0.08));
}
.qa-docs-dropdown-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 4px 8px 6px;
}
.qa-docs-dropdown-head > span {
  font-family: "Anthropic Serif", "Noto Serif SC", Georgia, serif;
  font-size: 14px;
  color: var(--ink, #141413);
}
.qa-docs-dropdown-head em {
  font-style: normal;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 11px;
  color: var(--ink-4, #8c8a82);
  margin-left: 4px;
}
.qa-docs-dropdown-all {
  font-size: 11px;
  color: var(--accent, #D97757);
  text-decoration: none;
  letter-spacing: 0.02em;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.18s;
}
.qa-docs-dropdown-all:hover { background: var(--accent-soft, rgba(217,119,87,0.10)); }
.qa-docs-dropdown ul {
  list-style: none;
  margin: 0; padding: 0;
}
.qa-docs-dropdown li a {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 8px;
  align-items: baseline;
  padding: 7px 8px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink-2, #2c2b29);
  font-size: 13px;
  line-height: 1.4;
  transition: background 0.18s ease, color 0.18s ease;
}
.qa-docs-dropdown li a:hover {
  background: var(--accent-soft, rgba(217,119,87,0.10));
  color: var(--accent-deep, #b85b3d);
}
.qa-docs-dropdown-date {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 11px;
  color: var(--ink-4, #8c8a82);
  font-variant-numeric: tabular-nums;
}
.qa-docs-dropdown-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.qa-docs-dropdown li.qa-docs-dropdown-more a {
  /* 没有日期列：整行显示，和上面的标题对齐（8px 内边距 + 44px 日期列 + 8px 间距） */
  display: block;
  padding-left: 60px;
  color: var(--ink-4, #8c8a82) !important;
  font-size: 12px !important;
  font-style: italic;
}
.qa-docs-dropdown-footer {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line, rgba(31,30,29,0.08));
}
.qa-docs-dropdown-footer button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font: 13px system-ui, -apple-system, "PingFang SC", sans-serif;
  color: var(--ink-3, #5c5b56);
  transition: color 0.18s, background 0.18s;
}
.qa-docs-dropdown-footer button:hover {
  color: var(--accent-deep, #b85b3d);
  background: var(--accent-soft, rgba(217,119,87,0.10));
}
.qa-docs-dropdown-footer button svg { width: 14px; height: 14px; opacity: 0.7; }
.qa-docs-dropdown-footer button kbd {
  margin-left: auto;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 11px;
  padding: 2px 6px;
  background: var(--bg, #FDFDFC);
  border: 1px solid var(--line, rgba(31,30,29,0.10));
  border-radius: 5px;
  letter-spacing: 0.04em;
}

@media (max-width: 720px) {
  .qa-docs-dropdown-wrap .qa-nav-docs-trigger { pointer-events: auto; }
  .qa-docs-dropdown { display: none; }
}

/* ============ Subpage related reading ============ */
.qa-related {
  padding: 56px 0 32px;
  margin-top: 32px;
}
.qa-related-inner {
  /* 与正文 880 列对齐：避免比正文更宽而探入左侧目录栏 */
  max-width: 880px;
  margin: 0 auto;
  padding: 0 28px;
}
.qa-related-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border, rgba(31,30,29,0.10));
}
.qa-related-eyebrow {
  font-family: "Anthropic Serif", "Noto Serif SC", Georgia, serif;
  font-size: 22px;
  color: var(--text, #141413);
  letter-spacing: -0.01em;
}
.qa-related-all {
  font-size: 12px;
  color: var(--text-muted, #5c5b56);
  text-decoration: none;
  transition: color 0.18s;
}
.qa-related-all:hover { color: var(--accent, #D97757); }
.qa-related-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.qa-related-card {
  display: flex; flex-direction: column;
  gap: 12px;
  padding: 22px 22px 20px;
  background: var(--bg-elevated, #ffffff);
  border: 1px solid var(--border, rgba(31,30,29,0.10));
  border-radius: 14px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}
.qa-related-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent, #D97757);
  box-shadow: 0 12px 32px -16px rgba(31,30,29,0.16);
}
.qa-related-meta {
  display: flex; align-items: center; gap: 10px;
}
.qa-related-cat {
  display: inline-flex;
  padding: 2px 9px;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-deep, #b85b3d);
  background: var(--accent-soft, rgba(217,119,87,0.10));
  border-radius: 999px;
}
.qa-related-cat[data-cat="notes"],
.qa-related-cat[data-cat="changelog"] {
  color: var(--text-muted, #5c5b56);
  background: var(--bg-hover, rgba(31,30,29,0.04));
}
.qa-related-date {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 12px;
  color: var(--text-faint, #8c8a82);
  font-variant-numeric: tabular-nums;
}
.qa-related-title {
  font-family: "Anthropic Serif", "Noto Serif SC", Georgia, serif;
  font-size: 17px;
  font-weight: 400;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: var(--text, #141413);
  transition: color 0.18s;
}
.qa-related-card:hover .qa-related-title { color: var(--accent-deep, #b85b3d); }
.qa-related-summary {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-muted, #5c5b56);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.qa-related-tags {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: auto;
}
.qa-related-tag {
  font-size: 11px;
  color: var(--text-muted, #5c5b56);
  padding: 1px 8px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--border, rgba(31,30,29,0.10));
}
.qa-related-tag::before { content: "#"; opacity: 0.5; }

@media (max-width: 720px) {
  .qa-related { padding: 36px 0 20px; }
  .qa-related-inner { padding: 0 20px; }
  .qa-related-grid { grid-template-columns: 1fr; gap: 14px; }
  .qa-related-eyebrow { font-size: 19px; }
}

/* ============ Command palette (⌘K) ============ */
.qa-cmdk-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(20, 20, 19, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 14vh 20px 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0s linear 0.18s;
  font-family: system-ui, -apple-system, "PingFang SC", sans-serif;
}
.qa-cmdk-overlay.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.18s ease;
}
body.qa-cmdk-lock { overflow: hidden; }

.qa-cmdk-panel {
  width: 100%;
  max-width: 580px;
  background: var(--bg-elevated, #ffffff);
  border: 1px solid var(--border, rgba(31,30,29,0.10));
  border-radius: 16px;
  box-shadow: 0 24px 64px -24px rgba(0,0,0,0.4), 0 4px 12px rgba(0,0,0,0.06);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 70vh;
  transform: scale(0.96);
  transition: transform 0.18s ease;
}
[data-theme="dark"] .qa-cmdk-panel {
  background: var(--bg-elevated, #2c2b29);
  box-shadow: 0 24px 64px -24px rgba(0,0,0,0.6), 0 4px 12px rgba(0,0,0,0.3);
}
.qa-cmdk-overlay.is-open .qa-cmdk-panel { transform: scale(1); }

.qa-cmdk-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border, rgba(31,30,29,0.10));
}
.qa-cmdk-head > svg {
  width: 18px; height: 18px;
  color: var(--text-faint, #8c8a82);
  flex-shrink: 0;
}
.qa-cmdk-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font: 16px/1.4 inherit;
  color: var(--text, #141413);
  padding: 4px 0;
}
.qa-cmdk-input::placeholder { color: var(--text-faint, #8c8a82); }

.qa-cmdk-close {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-faint, #8c8a82);
  transition: color 0.18s, background 0.18s;
}
.qa-cmdk-close:hover {
  color: var(--text, #141413);
  background: var(--bg-hover, rgba(31,30,29,0.04));
}
.qa-cmdk-close svg { width: 14px; height: 14px; }

.qa-cmdk-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px 12px;
}
.qa-cmdk-body::-webkit-scrollbar { width: 6px; }
.qa-cmdk-body::-webkit-scrollbar-thumb {
  background: var(--border, rgba(31,30,29,0.18));
  border-radius: 3px;
}

.qa-cmdk-group { padding: 6px 0; }
.qa-cmdk-group-head {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint, #8c8a82);
  padding: 6px 14px 4px;
  font-weight: 500;
}
.qa-cmdk-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  transition: background 0.12s ease;
}
.qa-cmdk-item.is-selected {
  background: var(--bg-warm, rgba(31,30,29,0.05));
}
.qa-cmdk-item-icon {
  display: grid; place-items: center;
  color: var(--text-faint, #8c8a82);
}
.qa-cmdk-item-icon svg { width: 16px; height: 16px; }
.qa-cmdk-item.is-selected .qa-cmdk-item-icon { color: var(--accent, #D97757); }
.qa-cmdk-item-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.qa-cmdk-item-title {
  font-size: 14px;
  color: var(--text, #141413);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.qa-cmdk-item-sub {
  font-size: 12px;
  color: var(--text-muted, #5c5b56);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.qa-cmdk-item-tag {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--accent-deep, #b85b3d);
  background: var(--accent-soft, rgba(217,119,87,0.10));
}
.qa-cmdk-item-tag[data-cat="notes"],
.qa-cmdk-item-tag[data-cat="changelog"] {
  color: var(--text-muted, #5c5b56);
  background: var(--bg-warm, rgba(31,30,29,0.05));
}
.qa-cmdk-item-count {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 11px;
  color: var(--text-faint, #8c8a82);
  font-variant-numeric: tabular-nums;
}

.qa-cmdk-empty {
  padding: 36px 24px;
  text-align: center;
  color: var(--text-muted, #5c5b56);
  font-family: "Anthropic Serif", "Noto Serif SC", Georgia, serif;
  font-style: italic;
  font-size: 14px;
}

.qa-cmdk-footer {
  display: flex;
  gap: 18px;
  padding: 10px 18px;
  border-top: 1px solid var(--border, rgba(31,30,29,0.10));
  font-size: 11px;
  color: var(--text-faint, #8c8a82);
}
.qa-cmdk-footer kbd {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 10px;
  padding: 1px 5px;
  background: var(--bg, #FDFDFC);
  border: 1px solid var(--border, rgba(31,30,29,0.12));
  border-radius: 4px;
  color: var(--text-muted, #5c5b56);
  margin-right: 4px;
}
[data-theme="dark"] .qa-cmdk-footer kbd {
  background: var(--bg-warm, #262624);
}

@media (max-width: 720px) {
  .qa-cmdk-overlay { padding: 6vh 12px 12px; }
  .qa-cmdk-panel { max-height: 84vh; }
  .qa-cmdk-input { font-size: 15px; }
  .qa-cmdk-footer { display: none; }
}

/* ============ Subpage sidebar TOC ============ */
body.qa-has-sidebar nav.toc { display: none !important; }

.qa-sidebar {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  left: max(16px, calc((100vw - 880px) / 2 - 264px));
  width: 240px;
  max-height: 80vh;
  overflow-y: auto;
  z-index: 80;
  padding: 18px 6px 22px 0;
  font-family: system-ui, -apple-system, "PingFang SC", sans-serif;
}
.qa-sidebar::-webkit-scrollbar { width: 4px; }
.qa-sidebar::-webkit-scrollbar-thumb {
  background: var(--border, rgba(31,30,29,0.14));
  border-radius: 2px;
}
.qa-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border, rgba(31,30,29,0.08));
}
.qa-sidebar-eyebrow {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint, #8c8a82);
}
.qa-sidebar-close {
  display: none;
  width: 28px; height: 28px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-muted, #5c5b56);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: color 0.18s, background 0.18s;
}
.qa-sidebar-close svg { width: 14px; height: 14px; }
.qa-sidebar-close:hover {
  color: var(--text, #141413);
  background: var(--bg-hover, rgba(31,30,29,0.05));
}

.qa-sidebar-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.qa-sidebar-list li {
  list-style: none;
  border: none;
  margin: 0;
  padding: 0;
}
.qa-sidebar-list .qa-sidebar-divider {
  height: 1px;
  background: var(--border, rgba(31,30,29,0.10));
  margin: 10px 16px;
}
.qa-sidebar-list a {
  position: relative;
  display: block;
  padding: 7px 12px 7px 16px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted, #5c5b56);
  text-decoration: none !important;
  border: none;
  border-left: 2px solid transparent;
  margin-left: -2px;
  border-radius: 0 6px 6px 0;
  background-image: none;
  transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}
.qa-sidebar-list a:hover {
  color: var(--text, #141413);
  background: var(--bg-hover, rgba(31,30,29,0.04));
}
.qa-sidebar-list a.is-active {
  color: var(--accent, #D97757);
  border-left-color: var(--accent, #D97757);
  font-weight: 500;
  background: color-mix(in srgb, var(--accent, #D97757) 8%, transparent);
}

/* Mobile floating toggle + drawer */
.qa-toc-toggle {
  display: none;
  position: fixed;
  top: 70px;
  right: 14px;
  z-index: 850;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border, rgba(31,30,29,0.15));
  background: color-mix(in srgb, var(--bg, #FDFDFC) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text-muted, #5c5b56);
  font: 13px/1 system-ui, -apple-system, "PingFang SC", sans-serif;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(31,30,29,0.08);
  transition: color 0.18s, border-color 0.18s, transform 0.18s;
}
.qa-toc-toggle:active { transform: scale(0.96); }
.qa-toc-toggle svg { width: 14px; height: 14px; }
@media (max-width: 768px) {
  .qa-toc-toggle { top: 14px; }
}

.qa-sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 850;
  background: rgba(20,20,19,0.42);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0s linear 0.22s;
}
body.qa-sidebar-open .qa-sidebar-overlay {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.22s ease;
}

/* 仅当左侧 gutter 真能容下 240px 目录栏（≈1440px 起）才停靠；
   否则一律走抽屉，避免目录与正文 / 相关阅读重叠。 */
@media (max-width: 1439px) {
  .qa-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 86vw;
    max-width: 320px;
    height: 100vh;
    max-height: 100vh;
    background: var(--bg-elevated, #ffffff);
    border-right: 1px solid var(--border, rgba(31,30,29,0.10));
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 860;
    padding: 24px 6px 32px 16px;
    box-shadow: 0 16px 48px -16px rgba(0,0,0,0.25);
  }
  [data-theme="dark"] .qa-sidebar {
    background: var(--bg-elevated, #2c2b29);
  }
  body.qa-sidebar-open .qa-sidebar {
    transform: translateX(0);
  }
  .qa-sidebar-close { display: inline-flex; }
  .qa-toc-toggle { display: inline-flex; }
}

@media (min-width: 1440px) {
  .qa-toc-toggle, .qa-sidebar-overlay { display: none !important; }
}
