/* ==========================================================================
   学习笔记阅读台 - Editorial Archive 视觉系统
   纯静态零依赖设计，完整兼容现有 DOM 钩子与响应式布局
   ========================================================================== */

:root {
  /* 色彩系统：温润纸感 + 群青墨蓝 */
  --bg-canvas: #faf9f6;
  --bg-surface: #ffffff;
  --bg-subtle: #f2efe9;
  --bg-elevated: #fcfbf9;
  --bg-code: #18181b;
  --bg-code-header: #222226;

  --text-primary: #18181b;
  --text-secondary: #52525b;
  --text-muted: #71717a;
  --text-faint: #a1a1aa;

  --accent-primary: #1e40af;      /* 群青墨蓝：主交互与当前态 */
  --accent-primary-soft: #eff6ff; /* 浅群青背景 */
  --accent-primary-border: #bfdbfe;
  --accent-warm: #b45309;         /* 赤陶琥珀：编号与微标 */
  --accent-warm-soft: #fef3c7;

  --border-light: #e7e4dc;
  --border-medium: #d6d1c7;
  --border-focus: #1e40af;

  /* 阴影与圆角 */
  --shadow-xs: 0 1px 2px rgba(24, 24, 27, 0.04);
  --shadow-sm: 0 2px 8px -2px rgba(24, 24, 27, 0.06), 0 1px 3px -1px rgba(24, 24, 27, 0.04);
  --shadow-md: 0 10px 24px -6px rgba(24, 24, 27, 0.08), 0 4px 10px -4px rgba(24, 24, 27, 0.04);
  --shadow-drawer: 12px 0 32px rgba(24, 24, 27, 0.12);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 9999px;

  /* 字体栈 */
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Inter", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  /* 布局尺寸 */
  --topbar-height: 56px;
  --spine-collapsed-width: 0px;
  --spine-expanded-width: 300px;
  --content-max-width: 1120px;
  --prose-max-width: 740px;

  /* 动效 */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: 160ms var(--ease-out);
  --transition-base: 240ms var(--ease-out);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
}

body {
  margin: 0;
  font-family: var(--font-sans);
  line-height: 1.65;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font-family: inherit;
  font-size: inherit;
}

/* ==========================================================================
   顶部导航栏 (Topbar)
   ========================================================================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 0 12px;
  background-color: rgba(250, 249, 246, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.spine-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.spine-toggle:hover {
  border-color: var(--border-medium);
  color: var(--text-primary);
  background-color: var(--bg-subtle);
}

.spine-toggle[aria-expanded="true"] {
  background-color: var(--accent-primary-soft);
  border-color: var(--accent-primary-border);
  color: var(--accent-primary);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-fast);
}

.brand:hover {
  background-color: var(--bg-subtle);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  background-color: var(--accent-primary);
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  background-color: var(--bg-subtle);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-light);
}

/* 文章页顶栏操作组 */
.topbar-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background-color: transparent;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.nav-btn:hover:not(.is-disabled) {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.nav-btn.is-disabled {
  opacity: 0.38;
  pointer-events: none;
}

.topic-chip {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  color: var(--accent-primary);
  background-color: var(--accent-primary-soft);
  border: 1px solid var(--accent-primary-border);
  transition: all var(--transition-fast);
}

.topic-chip:hover {
  background-color: var(--accent-primary);
  color: #ffffff;
}

/* ==========================================================================
   主布局容器与左侧导航 (.spine)
   桌面端默认展开，显示编号、标题与（文章页）内容大纲；
   窄屏收为抽屉，由顶栏按钮打开，不挤压正文。
   ========================================================================== */
.layout {
  display: flex;
  min-height: calc(100vh - var(--topbar-height));
  position: relative;
}

.spine {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  bottom: 0;
  width: var(--spine-expanded-width);
  background-color: var(--bg-elevated);
  border-right: 1px solid var(--border-light);
  z-index: 35;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 0 28px;
  transition: transform var(--transition-base), box-shadow var(--transition-base);
  scrollbar-width: thin;
  scrollbar-color: var(--border-medium) transparent;
}

.spine::-webkit-scrollbar {
  width: 4px;
}

.spine::-webkit-scrollbar-thumb {
  background-color: var(--border-medium);
  border-radius: 4px;
}

.main {
  flex: 1;
  margin-left: var(--spine-expanded-width);
  padding: 40px 36px 88px;
  min-width: 0;
  transition: margin-left var(--transition-base);
}

/* 桌面端可收起，把阅读区拉满 */
@media (min-width: 901px) {
  body.spine-collapsed .spine {
    transform: translateX(-100%);
    box-shadow: none;
  }

  body.spine-collapsed .main {
    margin-left: 0;
  }
}

/* 当前篇抬头（仅文章页） */
.spine-now {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 14px 16px 12px;
  background-color: var(--bg-elevated);
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 4px;
}

.spine-now-kicker {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}

.spine-now-link {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--text-primary);
}

.spine-now-link:hover .spine-now-title {
  color: var(--accent-primary);
}

.spine-now-num {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-warm);
  background-color: var(--accent-warm-soft);
  padding: 1px 6px;
  border-radius: 5px;
  margin-top: 1px;
  font-variant-numeric: tabular-nums;
}

.spine-now-title {
  font-size: 13.5px;
  font-weight: 650;
  line-height: 1.4;
  color: var(--text-primary);
}

.spine-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 12px 16px 6px;
  letter-spacing: 0.02em;
}

/* 内容大纲 */
.spine-toc {
  padding-bottom: 8px;
  border-bottom: 1px dashed rgba(214, 209, 199, 0.7);
  margin-bottom: 4px;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0 8px 4px 0;
}

.toc-item {
  margin: 0;
}

.toc-link {
  display: block;
  padding: 5px 14px 5px 16px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-secondary);
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.toc-item.toc-level-3 .toc-link,
.toc-item.toc-level-4 .toc-link {
  padding-left: 28px;
  font-size: 12px;
}

.toc-item.toc-level-4 .toc-link {
  padding-left: 38px;
}

.toc-link:hover {
  color: var(--accent-primary);
  background-color: rgba(30, 64, 175, 0.06);
}

.toc-link.is-active,
.toc-item.is-active .toc-link {
  color: var(--accent-primary);
  font-weight: 600;
  background-color: var(--accent-primary-soft);
  border-left-color: var(--accent-primary);
}

.toc-fallback {
  margin: 0;
  padding: 4px 16px 10px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-muted);
}

.spine-toc .toc-link[href="#article-top"] {
  margin: 0 8px 6px 14px;
}

/* 全部笔记分组 */
.spine-group {
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px dashed rgba(214, 209, 199, 0.7);
}

.spine-group:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.spine-group-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 4px 16px 4px;
  letter-spacing: 0.02em;
}

.spine-tick {
  display: flex;
  align-items: flex-start;
  min-height: 28px;
  padding: 5px 14px 5px 16px;
  gap: 8px;
  color: var(--text-secondary);
  position: relative;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.spine-tick-num {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  width: 20px;
  padding-top: 1px;
  font-variant-numeric: tabular-nums;
}

.spine-tick-title {
  font-size: 12.5px;
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.spine-tick:hover {
  background-color: rgba(30, 64, 175, 0.06);
  color: var(--accent-primary);
}

.spine-tick:hover .spine-tick-num {
  color: var(--accent-primary);
}

.spine-tick.is-match .spine-tick-num {
  color: var(--accent-warm);
  font-weight: 600;
}

.spine-tick.is-current {
  background-color: var(--accent-primary-soft);
  color: var(--accent-primary);
  font-weight: 600;
}

.spine-tick.is-current .spine-tick-num {
  color: var(--accent-primary);
  font-weight: 700;
}

/* 书脊遮罩层：仅窄屏打开抽屉时出现 */
.spine-backdrop {
  display: none;
  position: fixed;
  inset: var(--topbar-height) 0 0 0;
  background-color: rgba(24, 24, 27, 0.28);
  backdrop-filter: blur(2px);
  z-index: 30;
}

body.spine-open .spine-backdrop {
  display: block;
}

.prose h2,
.prose h3,
.prose h4,
.article-title {
  scroll-margin-top: calc(var(--topbar-height) + 16px);
}

/* ==========================================================================
   主内容区 (Main Workspace)
   ========================================================================== */

.container {
  max-width: var(--content-max-width);
  margin: 0 auto;
}

/* 首页头部区 */
.hero {
  margin-bottom: 28px;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-primary);
  background-color: var(--accent-primary-soft);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  margin-bottom: 12px;
  font-weight: 500;
}

.hero-title {
  margin: 0 0 8px;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.25;
  color: var(--text-primary);
}

.hero-subtitle {
  margin: 0;
  font-size: 15px;
  color: var(--text-secondary);
  max-width: 640px;
}

/* ==========================================================================
   搜索框与主题筛选栏
   ========================================================================== */
.controls {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 24px;
}

.search-wrap {
  position: relative;
  max-width: 540px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  display: flex;
  align-items: center;
}

.search-input {
  width: 100%;
  height: 44px;
  padding: 0 76px 0 40px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14.5px;
  box-shadow: var(--shadow-xs);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-input::placeholder {
  color: var(--text-faint);
}

.search-input:hover {
  border-color: #a8a29e;
}

.search-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.12);
}

/* 隐藏原生搜索清除按钮，使用自定义按钮与快捷键徽章 */
.search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.search-actions {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
}

.search-clear {
  display: none;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: var(--radius-sm);
  background-color: var(--bg-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  transition: all var(--transition-fast);
}

.search-clear.is-visible {
  display: inline-flex;
}

.search-clear:hover {
  background-color: var(--border-light);
  color: var(--text-primary);
}

.search-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: 5px;
  pointer-events: none;
}

.search-input:focus ~ .search-actions .search-kbd {
  opacity: 0;
}

/* 主题筛选按钮组 */
.topic-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.topic-btn {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 13px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-light);
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.topic-btn:hover {
  border-color: var(--border-medium);
  color: var(--text-primary);
  background-color: var(--bg-subtle);
}

.topic-btn.is-active,
.topic-btn[aria-pressed="true"] {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(30, 64, 175, 0.22);
}

/* 状态统计栏 */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
  color: var(--text-muted);
}

.status-count {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-secondary);
}

.status-reset {
  display: none;
  border: none;
  background: none;
  color: var(--accent-primary);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

.status-reset.is-visible {
  display: inline-flex;
}

.status-reset:hover {
  background-color: var(--accent-primary-soft);
}

/* ==========================================================================
   笔记卡片网格 (Notes Grid)
   ========================================================================== */
.note-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

@media (max-width: 1120px) {
  .note-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.note-item {
  display: flex;
}

.note-item[hidden] {
  display: none !important;
}

.note-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 18px 20px 20px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
  position: relative;
}

.note-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-primary-border);
  box-shadow: var(--shadow-md);
}

.note-card:focus-visible {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.14);
}

.note-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.note-num {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-warm);
  background-color: var(--accent-warm-soft);
  padding: 2px 7px;
  border-radius: 5px;
  font-variant-numeric: tabular-nums;
}

.note-topic {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  background-color: var(--bg-subtle);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-title {
  margin: 0 0 8px;
  font-size: 16.5px;
  font-weight: 650;
  line-height: 1.4;
  color: var(--text-primary);
  transition: color var(--transition-fast);
}

.note-card:hover .note-title {
  color: var(--accent-primary);
}

.note-summary {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 空搜索结果提示 */
.empty-state {
  display: none;
  text-align: center;
  padding: 64px 20px;
  background-color: var(--bg-surface);
  border: 1px dashed var(--border-medium);
  border-radius: var(--radius-lg);
  margin-top: 12px;
}

.empty-state.is-visible {
  display: block;
}

.empty-state-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.empty-state-desc {
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--text-muted);
}

/* ==========================================================================
   文章阅读页与排版系统 (.article / .prose)
   ========================================================================== */
.reading-progress {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  right: 0;
  height: 2px;
  background-color: transparent;
  z-index: 45;
  pointer-events: none;
}

.reading-progress-bar {
  height: 100%;
  width: 0%;
  background-color: var(--accent-primary);
  transition: width 60ms linear;
}

.article-wrap {
  max-width: var(--prose-max-width);
  margin: 0 auto;
}

.article-header {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-light);
}

.article-kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.article-num {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-warm);
  background-color: var(--accent-warm-soft);
  padding: 2px 9px;
  border-radius: 6px;
}

.article-topic-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.article-title {
  margin: 0 0 18px;
  font-size: 32px;
  font-weight: 750;
  line-height: 1.28;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}

/* 核心导读摘要框 */
.article-lead {
  padding: 16px 20px;
  background-color: var(--bg-subtle);
  border-left: 3.5px solid var(--accent-primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-primary);
}

/* 正文排印 (.prose) */
.prose {
  font-size: 16px;
  line-height: 1.8;
  color: #27272a;
}

.prose > *:first-child {
  margin-top: 0;
}

.prose h2 {
  margin: 40px 0 16px;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.015em;
  color: var(--text-primary);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

.prose h3 {
  margin: 28px 0 12px;
  font-size: 17.5px;
  font-weight: 650;
  line-height: 1.4;
  color: var(--text-primary);
}

.prose p {
  margin: 0 0 16px;
}

.prose a {
  color: var(--accent-primary);
  text-decoration: underline;
  text-decoration-color: rgba(30, 64, 175, 0.35);
  text-underline-offset: 3px;
  transition: text-decoration-color var(--transition-fast);
}

.prose a:hover {
  text-decoration-color: var(--accent-primary);
}

.prose ul,
.prose ol {
  margin: 0 0 20px;
  padding-left: 22px;
}

.prose li {
  margin-bottom: 9px;
  padding-left: 4px;
}

.prose li::marker {
  color: var(--accent-primary);
  font-weight: 600;
}

.prose strong {
  font-weight: 650;
  color: var(--text-primary);
}

/* 行内代码 */
.prose :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  padding: 2px 6px;
  margin: 0 2px;
  border-radius: 5px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-light);
  color: #9a3412;
  word-break: break-word;
}

/* 引用块 */
.prose blockquote {
  margin: 24px 0;
  padding: 14px 18px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-left: 3.5px solid var(--accent-warm);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 15px;
}

.prose blockquote p:last-child {
  margin-bottom: 0;
}

/* ==========================================================================
   表格排版 (Table)
   ========================================================================== */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 24px 0;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  box-shadow: var(--shadow-xs);
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.6;
  text-align: left;
}

.prose thead {
  background-color: var(--bg-subtle);
  border-bottom: 1.5px solid var(--border-medium);
}

.prose th {
  padding: 11px 14px;
  font-weight: 650;
  color: var(--text-primary);
  white-space: nowrap;
}

.prose td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
  vertical-align: top;
}

.prose tbody tr:last-child td {
  border-bottom: none;
}

.prose tbody tr:nth-child(even) {
  background-color: rgba(250, 249, 246, 0.65);
}

.prose tbody tr:hover {
  background-color: var(--accent-primary-soft);
}

/* ==========================================================================
   代码块排版 (Code Block)
   ========================================================================== */
.code-block {
  margin: 24px 0;
  border-radius: var(--radius-md);
  background-color: var(--bg-code);
  border: 1px solid #27272a;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background-color: var(--bg-code-header);
  border-bottom: 1px solid #2e2e33;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: #a1a1aa;
}

.code-dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.code-dots span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: #3f3f46;
}

.code-lang {
  margin-left: 8px;
  text-transform: lowercase;
  color: #d4d4d8;
}

.code-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 5px;
  border: 1px solid #3f3f46;
  background-color: #27272a;
  color: #e4e4e7;
  font-family: var(--font-sans);
  font-size: 11.5px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.code-copy-btn:hover {
  background-color: #3f3f46;
  border-color: #52525b;
}

.code-copy-btn.is-copied {
  background-color: #065f46;
  border-color: #059669;
  color: #ecfdf5;
}

.prose pre {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
  background-color: var(--bg-code);
  color: #f4f4f5;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.65;
  tab-size: 2;
}

/* 兼容未包裹 .code-block 的裸 pre 标签 */
.prose > pre {
  margin: 24px 0;
  border-radius: var(--radius-md);
  border: 1px solid #27272a;
}

.prose pre code {
  font-family: inherit;
  font-size: inherit;
  background: none;
  border: none;
  padding: 0;
  color: inherit;
}

/* ==========================================================================
   文末上下篇导航 (.article-foot)
   ========================================================================== */
.article-foot {
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--border-light);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.foot-link {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 18px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.foot-link:hover {
  border-color: var(--accent-primary-border);
  background-color: var(--accent-primary-soft);
  transform: translateY(-1px);
}

.foot-link.is-next {
  text-align: right;
  align-items: flex-end;
}

.foot-link.is-empty {
  visibility: hidden;
  pointer-events: none;
}

.foot-dir {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.foot-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}

.foot-link:hover .foot-title {
  color: var(--accent-primary);
}

/* ==========================================================================
   移动端响应式适配 (<= 900px)
   ========================================================================== */
@media (max-width: 900px) {
  .spine {
    width: min(var(--spine-expanded-width), 86vw);
    transform: translateX(-100%);
    background-color: var(--bg-elevated);
    box-shadow: none;
  }

  body.spine-open .spine {
    transform: translateX(0);
    box-shadow: var(--shadow-drawer);
  }

  .main {
    margin-left: 0;
    padding: 24px 16px 64px;
  }

  body.spine-collapsed .main {
    margin-left: 0;
  }

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

  /* 移动端主题栏支持横向平滑滑动，避免折行过长 */
  .topic-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 6px;
    margin: 0 -16px;
    padding-left: 16px;
    padding-right: 16px;
    scrollbar-width: none;
  }

  .topic-bar::-webkit-scrollbar {
    display: none;
  }

  .note-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

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

  .article-foot {
    grid-template-columns: 1fr;
  }

  .foot-link.is-next {
    text-align: left;
    align-items: flex-start;
  }

  .topbar-nav .topic-chip {
    display: none;
  }
}
/* --------------------------------------------------------------------------
   Compatibility supplements (Gemini CSS did not cover these selectors).
   Visual language matches the paper/cobalt system; not a restyle.
   -------------------------------------------------------------------------- */
.prose img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 20px 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}

.prose h4 {
  margin: 24px 0 10px;
  font-size: 15.5px;
  font-weight: 650;
  line-height: 1.4;
  color: var(--text-primary);
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--border-light);
  margin: 32px 0;
}

.prose h1 {
  margin: 0 0 20px;
  font-size: 28px;
  font-weight: 750;
  line-height: 1.28;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}

/* 窄屏文章顶栏：避免品牌名与「返回目录 / 上一篇 / 下一篇」被挤成两行 */
@media (max-width: 700px) {
  .topbar {
    gap: 6px;
    padding: 0 10px 0 8px;
  }

  .topbar-nav {
    flex-shrink: 0;
    gap: 2px;
  }

  .nav-btn {
    padding: 0 8px;
    font-size: 12.5px;
    white-space: nowrap;
  }

  .topbar:has(.topbar-nav) .brand > span:not(.brand-mark) {
    display: none;
  }
}
