/* ============================================================
   CGL Blog · GitHub 风格静态博客预览
   ============================================================ */

/* ---------- 主题变量 ---------- */
:root {
  --canvas: #ffffff;
  --canvas-subtle: #f6f8fa;
  --canvas-inset: #f6f8fa;
  --border-default: #d1d9e0;
  --border-muted: #d8dee4;
  --fg-default: #1f2328;
  --fg-muted: #59636e;
  --fg-subtle: #6e7781;
  --accent-fg: #0969da;
  --accent-emphasis: #0969da;
  --accent-subtle: #ddf4ff;
  --success-fg: #1a7f37;
  --danger-fg: #cf222e;
  --hover: rgba(208, 215, 222, 0.36);
  --active-row-bg: #0969da;
  --active-row-fg: #ffffff;
  --shadow-sm: 0 1px 0 rgba(31, 35, 40, 0.04);
  --shadow-md: 0 8px 24px rgba(66, 74, 83, 0.16);
  --scrollbar-thumb: #d1d9e0;
  --focus-ring: #0969da;
  --mark-bg: #fff8c5;
  --sidebar-w: 300px;
  --head-h: 52px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial,
    sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono",
    monospace;
}

html[data-theme="dark"] {
  --canvas: #0d1117;
  --canvas-subtle: #151b23;
  --canvas-inset: #010409;
  --border-default: #3d444d;
  --border-muted: #30363d;
  --fg-default: #f0f6fc;
  --fg-muted: #9198a1;
  --fg-subtle: #6e7781;
  --accent-fg: #4493f8;
  --accent-emphasis: #1f6feb;
  --accent-subtle: #121d2f;
  --success-fg: #3fb950;
  --danger-fg: #f85149;
  --hover: rgba(177, 186, 196, 0.12);
  --active-row-bg: #1f6feb;
  --active-row-fg: #ffffff;
  --shadow-sm: 0 1px 0 rgba(1, 4, 9, 0.4);
  --shadow-md: 0 8px 24px rgba(1, 4, 9, 0.6);
  --scrollbar-thumb: #3d444d;
  --focus-ring: #4493f8;
  --mark-bg: rgba(187, 128, 9, 0.4);
}

/* ---------- 基础 ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg-default);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

body.sidebar-open {
  overflow: hidden;
}

button,
input {
  font-family: inherit;
}

a {
  color: var(--accent-fg);
}

::-moz-selection {
  background: var(--accent-subtle);
}

::selection {
  background: var(--accent-subtle);
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  display: block;
  width: 16px;
  height: 16px;
  flex: none;
}

.skip-link {
  position: fixed;
  top: -48px;
  left: 12px;
  z-index: 200;
  padding: 8px 14px;
  border-radius: 6px;
  color: #fff;
  background: var(--accent-emphasis);
  text-decoration: none;
  font-size: 13px;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 12px;
}

/* ---------- 布局 ---------- */
.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  width: var(--sidebar-w);
  min-width: 0;
  background: var(--canvas-subtle);
  border-right: 1px solid var(--border-default);
}

.main {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  background: var(--canvas);
}

/* ---------- 左侧：仓库头 ---------- */
.repo-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  height: var(--head-h);
  padding: 0 10px 0 12px;
  border-bottom: 1px solid var(--border-default);
}

.repo-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  padding: 4px 6px;
  margin-left: -6px;
  border-radius: 6px;
  color: var(--fg-default);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.repo-link:hover {
  background: var(--hover);
}

.repo-icon {
  width: 17px;
  height: 17px;
  color: var(--fg-muted);
}

.repo-owner {
  font-weight: 400;
  color: var(--fg-default);
  overflow: hidden;
  text-overflow: ellipsis;
}

.repo-slash {
  color: var(--fg-subtle);
  font-weight: 400;
}

.repo-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.visibility-pill {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border: 1px solid var(--border-default);
  border-radius: 2em;
  color: var(--fg-muted);
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
}

.repo-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  color: var(--fg-muted);
  background: transparent;
  cursor: pointer;
}

.icon-btn:hover {
  color: var(--fg-default);
  background: var(--hover);
}

.icon-btn .icon {
  width: 16px;
  height: 16px;
}

.theme-icon-light {
  display: none;
}

html[data-theme="dark"] .theme-icon-light {
  display: block;
}

html[data-theme="dark"] .theme-icon-dark {
  display: none;
}

/* ---------- 左侧：搜索 ---------- */
.tree-head {
  flex: 0 0 auto;
  padding: 12px 12px 8px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 9px;
  width: 15px;
  height: 15px;
  color: var(--fg-subtle);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 32px;
  padding: 0 30px 0 31px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  color: var(--fg-default);
  background: var(--canvas);
  font-size: 13px;
  line-height: 20px;
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
  -webkit-appearance: none;
  appearance: none;
}

.search-input::placeholder {
  color: var(--fg-subtle);
}

.search-input:focus {
  border-color: var(--accent-fg);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.search-input::-webkit-search-cancel-button {
  display: none;
}

.search-clear {
  position: absolute;
  right: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  color: var(--fg-muted);
  background: transparent;
  cursor: pointer;
}

.search-clear:hover {
  color: var(--fg-default);
  background: var(--hover);
}

.search-clear .icon {
  width: 14px;
  height: 14px;
}

.tree-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  color: var(--fg-muted);
  font-size: 11.5px;
  line-height: 1.4;
}

#tree-summary-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.branch-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  height: 20px;
  padding: 0 8px;
  border: 1px solid var(--border-muted);
  border-radius: 2em;
  color: var(--fg-muted);
  font-size: 11px;
  background: var(--canvas);
}

.branch-icon {
  width: 11px;
  height: 11px;
}

/* ---------- 左侧：文件树 ---------- */
.tree {
  flex: 1 1 auto;
  padding: 2px 8px 16px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.tree-item {
  min-width: 0;
}

.tree-item:not(.open) > .tree-children {
  display: none;
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  height: 32px;
  padding: 0 8px 0 calc(8px + var(--depth, 0) * 14px);
  border: 0;
  border-radius: 6px;
  color: var(--fg-default);
  background: transparent;
  font-size: 13px;
  line-height: 20px;
  text-align: left;
  cursor: pointer;
  user-select: none;
}

.tree-row:hover {
  background: var(--hover);
}

.tree-row:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: -2px;
}

.tree-row.active {
  color: var(--active-row-fg);
  background: var(--active-row-bg);
}

.tree-row.active .tree-icon,
.tree-row.active .chevron,
.tree-row.active .tree-name mark {
  color: var(--active-row-fg);
}

.tree-row.active .tree-name mark {
  background: rgba(255, 255, 255, 0.24);
}

.chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--fg-muted);
  transition: transform 0.12s ease;
}

.chevron .icon {
  width: 13px;
  height: 13px;
}

.tree-item.open > .tree-row .chevron {
  transform: rotate(90deg);
}

.tree-item.is-file .chevron {
  visibility: hidden;
}

.tree-icon {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--fg-muted);
}

.tree-item.is-file .tree-icon {
  color: var(--accent-fg);
  opacity: 0.9;
}

.tree-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-name mark {
  padding: 0 1px;
  border-radius: 2px;
  color: inherit;
  background: var(--mark-bg);
}

.tree-empty {
  padding: 28px 12px;
  color: var(--fg-muted);
  font-size: 12.5px;
  text-align: center;
  line-height: 1.7;
}

/* 骨架屏 */
.tree-skeleton {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 8px;
}

.sk-row {
  display: block;
  width: var(--w, 70%);
  height: 12px;
  margin-left: var(--indent, 0);
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    var(--hover) 25%,
    var(--canvas) 37%,
    var(--hover) 63%
  );
  background-size: 400% 100%;
  animation: skeleton 1.4s ease infinite;
}

@keyframes skeleton {
  0% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0 50%;
  }
}

/* ---------- 左侧：底栏 ---------- */
.sidebar-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: 0 0 auto;
  height: 34px;
  padding: 0 14px;
  border-top: 1px solid var(--border-default);
  color: var(--fg-subtle);
  font-size: 11px;
  line-height: 1;
}

#tree-generated {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.foot-link {
  flex: none;
  color: var(--fg-muted);
  text-decoration: none;
}

.foot-link:hover {
  color: var(--accent-fg);
  text-decoration: underline;
}

/* ---------- 拖拽分隔条 ---------- */
.resizer {
  position: relative;
  z-index: 12;
  flex: 0 0 auto;
  width: 5px;
  margin-left: -3px;
  cursor: col-resize;
  background: transparent;
}

.resizer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 2px;
  width: 1px;
  background: transparent;
  transition: background 0.15s ease;
}

.resizer:hover::after,
.resizer:focus-visible::after,
body.resizing .resizer::after {
  background: var(--accent-fg);
}

.resizer:focus-visible {
  outline: none;
}

body.resizing {
  cursor: col-resize;
  user-select: none;
}

body.resizing .sidebar {
  transition: none;
}

/* ---------- 右侧：顶部路径栏 ---------- */
.content-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  height: var(--head-h);
  padding: 0 16px;
  border-bottom: 1px solid var(--border-default);
  background: var(--canvas);
}

.mobile-menu {
  display: none;
  flex: none;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 1px;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  color: var(--fg-muted);
  font-size: 13px;
  scrollbar-width: none;
}

.breadcrumb::-webkit-scrollbar {
  display: none;
}

.crumb {
  flex: none;
  display: inline-flex;
  align-items: center;
  max-width: 240px;
  padding: 4px 6px;
  border: 0;
  border-radius: 6px;
  color: inherit;
  background: transparent;
  font: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

button.crumb {
  cursor: pointer;
}

button.crumb:hover {
  color: var(--fg-default);
  background: var(--hover);
}

.crumb.current {
  color: var(--fg-default);
  font-weight: 600;
}

.crumb-sep {
  flex: none;
  padding: 0 1px;
  color: var(--fg-subtle);
  font-size: 12px;
  opacity: 0.7;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  margin-left: auto;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  color: var(--fg-default);
  background: var(--canvas-subtle);
  box-shadow: var(--shadow-sm);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  line-height: 20px;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.action-btn:hover {
  background: var(--hover);
  border-color: var(--border-muted);
}

.action-btn:active {
  background: var(--canvas-inset);
}

.action-btn .icon {
  width: 14px;
  height: 14px;
  color: var(--fg-muted);
}

/* ---------- 右侧：正文滚动区 ---------- */
.content-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
}

.content-wrap {
  width: 100%;
  max-width: 1012px;
  margin: 0 auto;
  padding: 32px 40px 96px;
}

/* ---------- 文章元信息 ---------- */
.doc-meta {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-muted);
}

.doc-title {
  margin: 0 0 10px;
  color: var(--fg-default);
  font-size: 32px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.doc-description {
  margin: 0 0 14px;
  color: var(--fg-muted);
  font-size: 15px;
  line-height: 1.65;
}

.doc-info {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 14px;
  color: var(--fg-muted);
  font-size: 12px;
  line-height: 1.6;
}

.doc-info-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.doc-info-item .icon {
  width: 14px;
  height: 14px;
  color: var(--fg-subtle);
}

.doc-info-dot {
  color: var(--fg-subtle);
}

.doc-tags {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.doc-tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border: 1px solid var(--border-muted);
  border-radius: 2em;
  color: var(--accent-fg);
  background: var(--accent-subtle);
  font-size: 11.5px;
  line-height: 1;
  text-decoration: none;
}

/* ---------- Markdown 正文（GitHub 风格） ---------- */
.markdown-body {
  min-width: 0;
  background: transparent;
  font-size: 16px;
}

.markdown-body > *:first-child {
  margin-top: 0 !important;
}

.markdown-body > *:last-child {
  margin-bottom: 0 !important;
}

.markdown-body img {
  max-width: 100%;
  background: transparent;
}

.markdown-body :is(h1, h2, h3, h4, h5, h6) {
  position: relative;
  scroll-margin-top: 24px;
}

.markdown-body :is(h1, h2, h3, h4, h5, h6):hover .heading-anchor,
.markdown-body .heading-anchor:focus-visible {
  opacity: 1;
}

.heading-anchor {
  position: absolute;
  top: 50%;
  left: -1.25em;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  height: 1em;
  transform: translateY(-50%);
  color: var(--fg-muted);
  opacity: 0;
  transition: opacity 0.12s ease;
  text-decoration: none;
}

.heading-anchor:hover {
  color: var(--accent-fg);
}

.heading-anchor .icon {
  width: 0.72em;
  height: 0.72em;
}

/* 代码块：外层背景使用 GitHub 主题色，hljs 只负责着色 */
.markdown-body pre {
  position: relative;
}

.markdown-body pre code.hljs,
.markdown-body pre code {
  padding: 0;
  background: transparent;
}

.markdown-body .hljs {
  background: transparent;
}

.code-block {
  position: relative;
  margin-bottom: 16px;
}

.code-block > pre {
  margin-bottom: 0;
}

.markdown-body a.missing-link {
  color: var(--danger-fg);
  text-decoration-style: wavy;
}

.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  color: var(--fg-muted);
  background: var(--canvas);
  box-shadow: var(--shadow-sm);
  font-family: var(--font-sans);
  font-size: 11.5px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease, color 0.12s ease, background 0.12s ease;
}

.markdown-body pre:hover .code-copy-btn,
.code-block:hover .code-copy-btn,
.code-block:focus-within .code-copy-btn,
.code-copy-btn:focus-visible {
  opacity: 1;
}

.code-copy-btn:hover {
  color: var(--fg-default);
  background: var(--canvas-subtle);
}

.code-copy-btn.copied {
  color: var(--success-fg);
  opacity: 1;
}

.code-copy-btn .icon {
  width: 13px;
  height: 13px;
}

/* 任务列表 */
.markdown-body .task-list-item {
  list-style-type: none;
}

.markdown-body .task-list-item input[type="checkbox"] {
  margin: 0 0.4em 0.25em -1.4em;
  vertical-align: middle;
}

/* 键盘按键、引用等细节 */
.markdown-body kbd {
  font-family: var(--font-mono);
}

/* 加载 / 空状态 */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 96px 20px;
  color: var(--fg-muted);
  font-size: 13.5px;
}

.loading-state p {
  margin: 0;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border-default);
  border-top-color: var(--accent-fg);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.state-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 72px 20px;
  color: var(--fg-muted);
  font-size: 14px;
  text-align: center;
}

.state-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 6px;
  border: 1px solid var(--border-default);
  border-radius: 50%;
  color: var(--accent-fg);
  background: var(--canvas-subtle);
}

.state-icon .icon {
  width: 26px;
  height: 26px;
}

.state-icon.danger {
  color: var(--danger-fg);
}

.state-panel h2 {
  margin: 2px 0 0;
  color: var(--fg-default);
  font-size: 20px;
  font-weight: 600;
}

.state-panel p {
  max-width: 520px;
  margin: 0;
  line-height: 1.7;
}

.state-panel code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--canvas-subtle);
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.state-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
}

.state-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  color: var(--fg-default);
  background: var(--canvas-subtle);
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
}

.state-btn:hover {
  background: var(--hover);
}

.state-btn.primary {
  border-color: transparent;
  color: #fff;
  background: var(--accent-emphasis);
}

.state-btn.primary:hover {
  background: var(--accent-fg);
}

.welcome-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  width: 100%;
  max-width: 720px;
  margin-top: 14px;
  text-align: left;
}

.welcome-card {
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--border-default);
  border-radius: 8px;
  color: inherit;
  background: var(--canvas-subtle);
  text-decoration: none;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}

.welcome-card:hover {
  border-color: var(--accent-fg);
}

.welcome-card strong {
  display: block;
  margin-bottom: 3px;
  color: var(--fg-default);
  font-size: 13.5px;
}

.welcome-card span {
  color: var(--fg-muted);
  font-size: 12px;
  line-height: 1.6;
}

/* 文章底部 */
.doc-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid var(--border-muted);
  color: var(--fg-subtle);
  font-size: 11.5px;
}

.doc-footer code {
  font-family: var(--font-mono);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  z-index: 100;
  max-width: calc(100vw - 32px);
  padding: 8px 14px;
  border-radius: 8px;
  color: #ffffff;
  background: #1f2328;
  box-shadow: var(--shadow-md);
  font-size: 12.5px;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

html[data-theme="dark"] .toast {
  color: #0d1117;
  background: #f0f6fc;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- 遮罩 / 移动端 ---------- */
.backdrop {
  display: none;
}

.noscript-tip {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--fg-default);
  background: var(--canvas);
  font-size: 15px;
  text-align: center;
}

/* ---------- 滚动条 ---------- */
.tree,
.content-scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

.tree::-webkit-scrollbar,
.content-scroll::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.tree::-webkit-scrollbar-track,
.content-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.tree::-webkit-scrollbar-thumb,
.content-scroll::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 6px;
  background: var(--scrollbar-thumb);
  background-clip: content-box;
}

.tree::-webkit-scrollbar-thumb:hover,
.content-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--fg-subtle);
  background-clip: content-box;
}

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 60;
    width: min(86vw, 340px);
    transform: translateX(-102%);
    box-shadow: var(--shadow-md);
    transition: transform 0.2s ease;
  }

  .sidebar .tree {
    padding-bottom: 24px;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .resizer {
    display: none;
  }

  .backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: block;
    background: rgba(1, 4, 9, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  body.sidebar-open .backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-menu {
    display: inline-flex;
  }

  .content-head {
    gap: 4px;
    padding: 0 10px;
  }

  .content-wrap {
    padding: 26px 22px 72px;
  }

  .head-actions {
    gap: 6px;
  }

  .head-actions .action-btn span {
    display: none;
  }

  .head-actions .action-btn {
    padding: 0 8px;
  }

  .doc-title {
    font-size: 27px;
  }
}

@media (max-width: 600px) {
  :root {
    --head-h: 48px;
  }

  .visibility-pill {
    display: none;
  }

  .content-wrap {
    padding: 22px 16px 64px;
  }

  .doc-title {
    font-size: 24px;
  }

  .doc-description {
    font-size: 14px;
  }

  .doc-meta {
    margin-bottom: 22px;
    padding-bottom: 16px;
  }

  .markdown-body {
    font-size: 15px;
  }

  .markdown-body :is(h1, h2, h3, h4, h5, h6) {
    scroll-margin-top: 16px;
  }

  .heading-anchor {
    display: none;
  }

  .doc-footer {
    margin-top: 36px;
  }

  .breadcrumb .crumb {
    max-width: 42vw;
  }

  .code-copy-btn {
    opacity: 1;
  }
}

/* ---------- 动效偏好 / 打印 ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .sidebar,
  .resizer,
  .content-head,
  .code-copy-btn,
  .toast,
  .backdrop {
    display: none !important;
  }

  html,
  body,
  .app,
  .main,
  .content-scroll {
    height: auto !important;
    overflow: visible !important;
    background: #ffffff !important;
  }

  .content-wrap {
    max-width: none;
    padding: 0;
  }

  .doc-footer {
    border-top-color: #d1d9e0;
  }
}
