/* site/styles.css - Material Design 3 / Angular.dev 极简朴素风格与移动端全自适应响应式样式表 */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  
  /* 暗色主题（默认 - Angular / Material Dark / VitePress） */
  --bg-primary: #0b0f19;
  --bg-main: #0b0f19;
  --bg-surface: #131926;
  --bg-surface-variant: #1a2234;
  --bg-card: #131926;
  --bg-card-hover: #1a2234;
  --bg-editor: #080c14;
  --bg-console: #05070d;
  --bg-overlay: rgba(0, 0, 0, 0.72);
  
  --text-primary: #f8fafc;
  --text-main: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --border-color: #242f44;
  --border-subtle: #172033;
  
  --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.28);
  --shadow-modal: 0 20px 50px rgba(0, 0, 0, 0.65);
  
  /* Angular 标志性现代赤红粉 */
  --primary-color: #f43f5e;
  --primary-hover: #e11d48;
  --primary-subtle: rgba(244, 63, 94, 0.12);
  --primary-contrast: #ffffff;
  
  --success-color: #10b981;
  --success-subtle: rgba(16, 185, 129, 0.12);
  
  --warning-color: #f59e0b;
  --warning-subtle: rgba(245, 158, 11, 0.12);
  
  --danger-color: #ef4444;
  --danger-subtle: rgba(239, 68, 68, 0.12);

  /* 超链接色彩系统（Dark 模式：清爽天蓝，对比度极佳） */
  --link-color: #38bdf8;
  --link-hover: #7dd3fc;
  --link-decoration: rgba(56, 189, 248, 0.35);

  --splitter-width: 4px;
  --header-height: 52px;
  --mobile-bar-height: 42px;
}

[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-main: #ffffff;
  --bg-surface: #ffffff;
  --bg-surface-variant: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-editor: #f8fafc;
  --bg-console: #f8fafc;
  --bg-overlay: rgba(15, 23, 42, 0.45);
  
  --text-primary: #0f172a;
  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  
  --border-color: #e2e8f0;
  --border-subtle: #f1f5f9;
  
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-modal: 0 20px 50px rgba(15, 23, 42, 0.15), 0 1px 3px rgba(15, 23, 42, 0.06);
  
  --primary-color: #e11d48;
  --primary-hover: #be123c;
  --primary-subtle: rgba(225, 29, 72, 0.08);
  --primary-contrast: #ffffff;
  
  --success-color: #059669;
  --success-subtle: rgba(5, 150, 105, 0.08);

  /* 超链接色彩系统（Light 模式：深邃优雅蓝，对比度符合 WCAG AAA） */
  --link-color: #0284c7;
  --link-hover: #0369a1;
  --link-decoration: rgba(2, 132, 199, 0.35);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  height: 100%;
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 14px;
}

/* ==========================================================================
   Material Design 基础组件规范 (Buttons, Badges, Tabs)
   ========================================================================== */

button {
  font-family: inherit;
  font-size: inherit;
  border: none;
  cursor: pointer;
  background: transparent;
  color: inherit;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--primary-color);
  color: var(--primary-contrast);
}
.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-tonal {
  background-color: var(--primary-subtle);
  color: var(--primary-color);
}
.btn-tonal:hover {
  background-color: rgba(244, 63, 94, 0.2);
}

.btn-outline {
  border: 1px solid var(--border-color);
  background-color: transparent;
  color: var(--text-primary);
}
.btn-outline:hover {
  background-color: var(--bg-surface-variant);
}

.btn-text {
  color: var(--text-secondary);
}
.btn-text:hover {
  color: var(--text-primary);
  background-color: var(--primary-subtle);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  color: var(--text-secondary);
}
.icon-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-surface-variant);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background-color: var(--bg-surface-variant);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.badge-primary {
  background-color: var(--primary-subtle);
  color: var(--primary-color);
  border-color: transparent;
}

.badge-success {
  background-color: var(--success-subtle);
  color: var(--success-color);
  border-color: transparent;
}

.badge-subtle {
  background-color: var(--bg-surface-variant);
  color: var(--text-muted);
}

/* ==========================================================================
   Header 顶部导航 (Angular.dev 风格)
   ========================================================================== */

.header {
  height: var(--header-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  position: relative;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
}

.nav-btn {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.nav-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-surface-variant);
}

.nav-btn.active {
  color: var(--primary-color);
  font-weight: 600;
  background-color: var(--primary-subtle);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-container {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 20px;
  background-color: var(--bg-surface-variant);
  border: 1px solid var(--border-subtle);
}

.progress-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.progress-track {
  width: 50px;
  height: 4px;
  background-color: var(--border-color);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background-color: var(--primary-color);
  transition: width 0.3s ease;
}

/* ==========================================================================
   侧滑抽屉 (Navigation Drawer)
   ========================================================================== */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.drawer-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 340px;
  max-width: 85vw;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  z-index: 201;
  transform: translateX(-100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}
.drawer.is-open {
  transform: translateX(0);
}

.drawer-header {
  height: var(--header-height);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

.drawer-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
}

.drawer-search-box {
  flex: 1;
  min-width: 0;
}

.drawer-search-input {
  width: 100%;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  outline: none;
  font-size: 0.82rem;
  box-sizing: border-box;
}
.drawer-search-input:focus {
  border-color: var(--primary-color);
}

.drawer-toggle-all-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 9px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface-variant);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  height: 31px;
  box-sizing: border-box;
}
.drawer-toggle-all-btn:hover {
  color: var(--text-primary);
  border-color: var(--primary-color);
  background-color: var(--primary-subtle);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 10px 24px;
}

/* Part 可折叠分组组件 */
.drawer-part-group {
  margin-bottom: 8px;
  border-radius: 8px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.04));
  overflow: hidden;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.drawer-part-group:hover {
  border-color: var(--border-color);
}

.drawer-part-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background-color: var(--bg-surface-variant);
  border: none;
  cursor: pointer;
  user-select: none;
  text-align: left;
  gap: 8px;
  transition: background-color 0.15s ease;
}
.drawer-part-header:hover {
  background-color: var(--bg-card, rgba(255, 255, 255, 0.06));
}

.drawer-part-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.drawer-part-arrow {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.drawer-part-group.is-collapsed .drawer-part-arrow {
  transform: rotate(-90deg);
}

.drawer-part-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.drawer-part-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.drawer-part-count {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-surface);
  padding: 1px 6px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

.drawer-part-chapters {
  padding: 4px 0;
  transition: max-height 0.25s ease;
}
.drawer-part-group.is-collapsed .drawer-part-chapters {
  display: none;
}

/* 章节条目：视觉一致性网格 (绝对等高、等宽对齐) */
.chapter-item {
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 1px 4px;
  min-height: 34px;
  box-sizing: border-box;
  transition: all 0.12s ease;
}
.chapter-item:hover {
  background-color: var(--bg-surface-variant);
  color: var(--text-primary);
}
.chapter-item.active {
  background-color: var(--primary-subtle);
  color: var(--primary-color);
  font-weight: 600;
}
.chapter-item.completed .chapter-title::after {
  content: " ✓";
  color: var(--success-color);
  font-size: 0.78rem;
}

/* 章节标题：单行缩略截断，绝对防止挤占标签宽度 */
.chapter-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.chapter-num {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}
.chapter-item.active .chapter-num {
  color: var(--primary-color);
}

.chapter-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  line-height: 1.35;
}

/* 统一固定尺寸状态标签 (Badge) - 严格恒定 62px × 20px，单行居中，彻底消除大小不一与折行混乱 */
.chapter-item .chapter-badge {
  width: 62px !important;
  min-width: 62px !important;
  max-width: 62px !important;
  height: 20px !important;
  line-height: 18px !important;
  box-sizing: border-box;
  flex-shrink: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 4px !important;
  border-radius: 4px;
  font-size: 0.7rem !important;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  text-align: center !important;
  border: 1px solid transparent;
}

/* ==========================================================================
   主工作区布局 (Main Workspace)
   ========================================================================== */

.main-workspace {
  display: flex;
  height: calc(100vh - var(--header-height));
  position: relative;
  background-color: var(--bg-primary);
}

/* 左栏：教程指南 */
.pane-guide {
  width: 50%;
  height: 100%;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-color);
  background-color: var(--bg-primary);
  overflow: hidden;
}

.guide-header {
  padding: 10px 20px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.guide-step-title {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.guide-heading-text {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.guide-step-nav {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.guide-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 48px;
}

/* 拖拽分割线 */
.splitter {
  width: var(--splitter-width);
  background-color: var(--border-subtle);
  cursor: col-resize;
  transition: background-color 0.2s;
  flex-shrink: 0;
  z-index: 10;
}
.splitter:hover, .splitter.is-dragging {
  background-color: var(--primary-color);
}

/* 右栏：代码与终端 */
.pane-code {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-editor);
  overflow: hidden;
}

.code-header {
  padding: 6px 14px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Material 风格选项卡 (下划线指示器) */
.file-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.file-tabs::-webkit-scrollbar {
  display: none;
}

.file-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 6px 6px 0 0;
  transition: all 0.15s ease;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
  min-width: max-content;
  user-select: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.file-tab:hover {
  color: var(--text-primary);
  background-color: var(--bg-surface-variant);
}
.file-tab.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
  font-weight: 600;
}

#sim-tabs,
#app-tabs {
  margin-bottom: 20px;
  padding: 4px 2px 6px;
  border-bottom: 1px solid var(--border-color);
}
#sim-tabs .file-tab,
#app-tabs .file-tab {
  font-size: 0.86rem;
  padding: 9px 16px;
}

.code-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.editor-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background-color: var(--bg-editor);
}

/* 原生手写双层实时语法高亮编辑器 (CodeEditor) 样式 */
.code-editor-wrap {
  display: flex;
  flex: 1;
  min-height: 0;
  width: 100%;
  height: auto;
  position: relative;
  background-color: var(--bg-editor);
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 22px;
}

.editor-keyboard-help {
  flex: none;
  margin: 0;
  padding: 6px 12px;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  font-size: 12px;
  line-height: 1.5;
}

.editor-gutter {
  width: 46px;
  flex-shrink: 0;
  padding: 12px 8px 12px 0;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  color: var(--text-muted);
  text-align: right;
  user-select: none;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}

.gutter-line {
  height: 22px;
  font-size: 12px;
  line-height: 22px;
  color: var(--text-muted);
}

.editor-code-layer {
  flex: 1;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.editor-highlight-pre,
.editor-textarea {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 12px 16px;
  box-sizing: border-box;
  font-family: inherit;
  font-size: inherit;
  line-height: 22px;
  letter-spacing: 0;
  word-spacing: 0;
  tab-size: 2;
  white-space: pre;
  word-wrap: normal;
  overflow: auto;
  border: none;
  outline: none;
  -webkit-font-smoothing: antialiased;
}

.editor-highlight-pre {
  pointer-events: none;
  z-index: 1;
  background-color: transparent;
}

.editor-highlight-code {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

.editor-textarea {
  z-index: 2;
  resize: none;
  background-color: transparent;
  color: transparent !important;
  caret-color: var(--text-primary);
  -webkit-text-fill-color: transparent;
}

.code-editor-wrap.is-readonly {
  background-color: rgba(15, 23, 42, 0.4);
}
.code-editor-wrap.is-readonly .editor-textarea {
  cursor: default;
}

/* 终端控制台 */
.console-panel {
  height: 200px;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-console);
  display: flex;
  flex-direction: column;
}

.console-header {
  height: 32px;
  padding: 0 14px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.console-body {
  flex: 1;
  padding: 10px 14px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.5;
}

.log-entry {
  margin-bottom: 4px;
  word-break: break-all;
}
.log-time {
  color: var(--text-muted);
  margin-right: 6px;
}
.log-info { color: #60a5fa; }
.log-success { color: #34d399; }
.log-warn { color: #fbbf24; }
.log-error { color: #f87171; }

/* Markdown 排版 (Material Clean Docs) */
.markdown-body {
  font-size: 0.95rem;
  color: var(--text-primary);
  width: 100%;
  max-width: 100%;
  overflow-wrap: break-word;
  word-break: break-word;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
  font-weight: 600;
  line-height: 1.3;
  margin-top: 24px;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.markdown-body h1 { font-size: 1.6rem; border-bottom: 1px solid var(--border-color); padding-bottom: 8px; }
.markdown-body h2 { font-size: 1.3rem; }
.markdown-body h3 { font-size: 1.1rem; }

.markdown-body p {
  margin-bottom: 16px;
  color: var(--text-secondary);
  line-height: 1.75;
}

/* 超链接全局排版规范：双主题自适应颜色、平滑下划线与悬停高亮 */
.markdown-body a {
  color: var(--link-color);
  text-decoration: underline;
  text-decoration-color: var(--link-decoration);
  text-underline-offset: 3px;
  font-weight: 500;
  transition: color 0.16s ease, text-decoration-color 0.16s ease;
}

.markdown-body a:hover {
  color: var(--link-hover);
  text-decoration-color: var(--link-hover);
}

/* 列表排版与对齐规范（彻底解决有序列表序号溢出、悬挂与不对齐问题） */
.markdown-body ul,
.markdown-body ol {
  margin: 0 0 18px 0;
  padding-left: 2rem; /* 预留充足左内边距，确保 1-99+ 序号与圆点完全容纳在容器内，与正文自然垂直对齐，绝不凸出悬挂 */
  color: var(--text-secondary);
  line-height: 1.75;
}

.markdown-body ol {
  list-style-type: decimal;
}

.markdown-body ul {
  list-style-type: disc;
}

/* 有序列表序号高质感等宽数字渲染 */
.markdown-body ol > li::marker {
  color: var(--primary-color);
  font-weight: 600;
  font-feature-settings: "tnum";
}

/* 无序列表标记点微调 */
.markdown-body ul > li::marker {
  color: var(--primary-color);
  font-size: 0.9em;
}

.markdown-body li {
  margin-bottom: 8px;
  padding-left: 4px;
}

.markdown-body li:last-child {
  margin-bottom: 0;
}

/* 嵌套列表支持 */
.markdown-body li > ul,
.markdown-body li > ol {
  margin-top: 6px;
  margin-bottom: 8px;
  padding-left: 1.5rem;
}

.markdown-body li > ul {
  list-style-type: circle;
}

.markdown-body li > ul > li > ul {
  list-style-type: square;
}

/* 任务列表 (Task list) 美化 */
.markdown-body ul:has(li.task-item),
.markdown-body ul.contains-task-list {
  list-style-type: none;
  padding-left: 0.5rem;
}

.markdown-body li.task-item {
  list-style-type: none;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-left: 0;
}

.markdown-body li.task-item input[type="checkbox"] {
  margin: 0;
  accent-color: var(--primary-color);
  transform: translateY(2px);
  cursor: default;
}

.markdown-body strong {
  color: var(--text-primary);
}

/* 代码块容器与头部 */
/* 结构化 JSON 树：自动缩进、层级引导线、整行可折叠 */
.json-tree, .json-tree-body {
  overflow-x: auto;
  font-family: var(--mono-font, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 0.82rem;
  line-height: 1.6;
  padding: 10px 4px;
}
.json-line { white-space: pre; }
.json-children {
  margin-left: 12px;
  padding-left: 12px;
  border-left: 1px solid color-mix(in srgb, var(--border-color) 70%, transparent);
}
.json-foldable { cursor: pointer; }
.json-foldable:hover { background: color-mix(in srgb, var(--accent, #3b82f6) 8%, transparent); }
.json-foldable::before {
  content: '▾';
  display: inline-block;
  width: 1.1em;
  color: var(--fg-muted, inherit);
  font-size: 0.72rem;
}
.json-brk { color: var(--fg-muted, inherit); }
.json-node.collapsed > .json-children,
.json-node.collapsed > .json-close { display: none; }
.json-node.collapsed > .json-foldable::before { content: '▸'; }
.json-node.collapsed > .json-foldable::after {
  content: '…（已折叠，点击展开）';
  color: var(--fg-muted, inherit);
  font-size: 0.72rem;
  font-style: italic;
}

/* :::tabs 对比模式：与基准 Tab 的行级差异高亮（明暗双主题变量化） */
.md-tab-diff-btn {
  margin-left: auto;
  align-self: center;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--fg-muted, inherit);
  border-radius: 6px;
  padding: 2px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
}
.md-tab-diff-btn[aria-pressed="true"] {
  background: var(--accent, #3b82f6);
  border-color: var(--accent, #3b82f6);
  color: #fff;
}
.md-tabs.comparing .md-tab-diff-btn { outline: none; }
.diff-base-badge {
  font-size: 0.68rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0 6px;
  color: var(--fg-muted, inherit);
}
.diff-body {
  overflow-x: auto;
  font-family: var(--mono-font, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 0.82rem;
  line-height: 1.55;
  padding: 8px 0;
}
.diff-line {
  display: flex;
  gap: 8px;
  padding: 0 12px;
}
.diff-line .diff-mark {
  flex: 0 0 1.1em;
  text-align: center;
  user-select: none;
  opacity: 0.85;
}
.diff-line .diff-text {
  white-space: pre;
}
.diff-line.diff-head .diff-text {
  font-size: 0.72rem;
  opacity: 0.7;
  padding-bottom: 4px;
}
.diff-line.diff-changed      { background: color-mix(in srgb, #f59e0b 16%, transparent); }
.diff-line.diff-changed-base { background: color-mix(in srgb, #f59e0b 16%, transparent); opacity: 0.62; }
.diff-line.diff-added        { background: color-mix(in srgb, #10b981 16%, transparent); }
.diff-line.diff-removed      { background: color-mix(in srgb, #ef4444 12%, transparent); opacity: 0.62; }
[data-theme="light"] .diff-line.diff-changed      { background: color-mix(in srgb, #d97706 18%, transparent); }
[data-theme="light"] .diff-line.diff-changed-base { background: color-mix(in srgb, #d97706 18%, transparent); }
[data-theme="light"] .diff-line.diff-added        { background: color-mix(in srgb, #059669 16%, transparent); }
[data-theme="light"] .diff-line.diff-removed      { background: color-mix(in srgb, #dc2626 12%, transparent); }

.code-block-wrapper {
  position: relative;
  margin: 18px 0 24px;
  border-radius: 8px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background-color: var(--bg-surface-variant);
  border-bottom: 1px solid var(--border-color);
}

.code-block-lang {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.copy-code-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.18s ease;
}

.copy-code-btn:hover {
  background-color: var(--bg-surface-variant);
  color: var(--text-primary);
  border-color: var(--primary-color);
  transform: translateY(-1px);
}

.copy-code-btn.success {
  background-color: var(--success-subtle);
  color: var(--success-color);
  border-color: rgba(16, 185, 129, 0.4);
}

/* 内嵌可交互 Sandpack 沙盒卡片规范 */
.sandpack-block-wrapper {
  margin: 18px 0 22px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  background-color: var(--bg-editor);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.sandpack-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background-color: var(--bg-surface-variant);
  border-bottom: 1px solid var(--border-color);
}

.sandpack-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #38bdf8;
  font-family: var(--font-mono);
}

.sandpack-run-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #ffffff;
  background-color: var(--primary-color);
  border: none;
  cursor: pointer;
  transition: all 0.18s ease;
}

.sandpack-run-btn:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}

.sandpack-console {
  display: none;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-console);
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
  max-height: 180px;
  overflow-y: auto;
}

.sandpack-console.is-open {
  display: block;
}

.sandpack-console-header {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.markdown-body pre {
  margin: 0;
  padding: 14px 16px;
  background-color: var(--bg-editor);
  border: none;
  border-radius: 0;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.55;
}

/* 语法高亮配色微调 (现代暗色/亮色) */
.hl-kw { color: #f43f5e; font-weight: 600; }
.hl-type { color: #38bdf8; }
.hl-str { color: #a7f3d0; }
.hl-num { color: #f59e0b; }
.hl-comment { color: #64748b; font-style: italic; }
.hl-fn { color: #c084fc; }
.hl-key { color: #38bdf8; }

[data-theme="light"] .hl-kw { color: #e11d48; }
[data-theme="light"] .hl-type { color: #0284c7; }
[data-theme="light"] .hl-str { color: #059669; }
[data-theme="light"] .hl-num { color: #d97706; }
[data-theme="light"] .hl-comment { color: #94a3b8; }
[data-theme="light"] .hl-fn { color: #7c3aed; }
[data-theme="light"] .hl-key { color: #0284c7; }

/* 原理图与可视化卡片 (支持 baoyu-diagram 与外部 SVG/图例) */
.diagram-figure {
  margin: 22px 0 26px;
  border-radius: 8px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  transition: border-color 0.2s;
}
.diagram-figure:hover {
  border-color: var(--primary-color);
}

.diagram-img-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  background-color: var(--bg-surface);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.diagram-image {
  /* width:100%（而非 max-width）：SVG lazy 加载前无固有尺寸，max-width 会导致 0×0 →
     lazy 判定不可见 → 永不加载的死锁（曾被旧 min-width:580 掩盖）。width 给出确定占位。 */
  width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
  cursor: zoom-in;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.diagram-image:hover {
  opacity: 0.95;
}

/* SVG 以 <img> 引入时，其内部 prefers-color-scheme 跟随 img 的 color-scheme 而非系统设置；
   把站点主题传进去，否则「站点暗色 + 系统亮色」时图内标题是深字压深底 */
.diagram-image,
#lightbox-img {
  color-scheme: light;
}
/* 限定 :root：index.html 的 <body> 也写死了 data-theme="dark"，且主题切换只改 <html> */
:root[data-theme="dark"] .diagram-image,
:root[data-theme="dark"] #lightbox-img {
  color-scheme: dark;
}

.diagram-caption {
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  background-color: var(--bg-surface-variant);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  user-select: none;
}

.diagram-caption .zoom-hint {
  font-size: 0.72rem;
  color: var(--primary-color);
  background-color: var(--primary-container);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid currentColor;
  font-family: inherit;
  flex-shrink: 0;
}

.diagram-caption .zoom-hint:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 3px;
}

.inline-diagram-img {
  max-width: 100%;
  vertical-align: middle;
}

/* 高清图片全屏灯箱查看器 (Lightbox & Zoom/Pan Viewer) */
.diagram-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 22, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
  touch-action: none;
}

.diagram-lightbox.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* 顶部工具栏 */
.lightbox-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgba(15, 23, 42, 0.65);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 10;
  user-select: none;
}

.lightbox-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lightbox-zoom-level {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font-mono);
  border: 1px solid rgba(255, 255, 255, 0.15);
  letter-spacing: 0.5px;
}

.lightbox-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lightbox-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #f1f5f9;
  cursor: pointer;
  transition: all 0.18s ease;
  padding: 0;
}

.lightbox-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  transform: translateY(-1px);
}

.lightbox-btn:active {
  transform: translateY(0) scale(0.96);
}

.lightbox-btn-close {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  margin-left: 6px;
}

.lightbox-btn-close:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #ffffff;
}

/* 主视口与画布 */
.lightbox-viewport {
  flex: 1;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  touch-action: none;
}

.lightbox-canvas {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transform-origin: center center;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.05s linear;
}

/* 矢量注入专用样式：强制开启矢量亚像素与几何抗锯齿精度，杜绝栅格化位图拉伸 */
svg.lightbox-vector {
  shape-rendering: geometricPrecision;
  text-rendering: geometricPrecision;
  image-rendering: -webkit-optimize-contrast;
  display: block;
}

.lightbox-canvas.is-animating {
  transition: transform 0.26s cubic-bezier(0.16, 1, 0.3, 1);
}

#lightbox-img {
  width: min(88vw, 1060px);
  max-height: 74vh;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  background-color: var(--bg-card);
  box-shadow: var(--shadow-modal);
  border: 1px solid var(--border-color);
  cursor: zoom-in;
  user-select: none;
  -webkit-user-drag: none;
  display: block;
}

.lightbox-viewport.is-zoomed #lightbox-img {
  cursor: grab;
}

.lightbox-viewport.is-dragging #lightbox-img {
  cursor: grabbing;
}

/* 底部状态与操作说明 */
.lightbox-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 20px 16px;
  background: rgba(15, 23, 42, 0.75);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 10;
  gap: 4px;
}

.lightbox-caption {
  color: #f8fafc;
  font-size: 0.92rem;
  font-weight: 500;
  text-align: center;
  max-width: 800px;
  line-height: 1.4;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.lightbox-hints {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.76rem;
  color: var(--text-muted);
  user-select: none;
}

@media (max-width: 640px) {
  .lightbox-toolbar {
    padding: 8px 12px;
  }
  .lightbox-btn {
    width: 34px;
    height: 34px;
  }
  .lightbox-hints {
    display: none;
  }
  #lightbox-img {
    max-width: 95vw;
    max-height: 70vh;
  }
}

/* 主流 Agent / 模型方案标准对比空间 (Interactive Agent Comparison Box) */
.agent-compare-box {
  margin: 22px 0 28px;
  border-radius: 8px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

.compare-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background-color: var(--bg-surface-variant);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 8px;
}

.compare-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.compare-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  white-space: nowrap;
  padding: 2px 0;
}
.compare-tabs::-webkit-scrollbar {
  display: none;
}

.compare-tab {
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
  min-width: max-content;
}

.compare-tab:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 1px;
}

.compare-tab:hover {
  color: var(--text-primary);
  background-color: var(--bg-surface);
}

.compare-tab.active {
  background-color: var(--bg-primary);
  color: var(--primary-color);
  font-weight: 600;
  border-color: var(--border-color);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.compare-panels {
  padding: 16px;
  background-color: var(--bg-surface);
}

.compare-panel {
  display: none;
  font-size: 0.88rem;
  line-height: 1.65;
}

.compare-panel.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

.compare-panel pre {
  margin: 12px 0 8px;
}

/* Markdown :::tabs：Docusaurus 风格下划线 Tab，面板内容按正文排版 */
.md-tabs {
  margin: 20px 0 28px;
}
.md-tabs-title {
  margin: 0 0 6px;
  font-weight: 600;
  color: var(--text-primary);
}
.md-tabs-list {
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 16px;
}
.md-tabs-list::-webkit-scrollbar {
  display: none;
}
.md-tab {
  display: inline-flex;
  align-items: center;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
  min-width: max-content;
  padding: 10px 16px;
  margin-bottom: -1px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}
.md-tab:hover {
  color: var(--text-primary);
  background-color: var(--bg-surface);
}
.md-tab.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}
.md-tab:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: -2px;
}
.md-tab-panel > :first-child {
  margin-top: 0;
}
.md-tab-panel table {
  min-width: 0;
}
.md-tab-panel td:first-child {
  white-space: nowrap;
}
.md-tab-panel:not([hidden]) {
  animation: fadeIn 0.2s ease;
}

.compare-meta-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.compare-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 4px;
  background: var(--bg-surface-variant);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.compare-badge.badge-highlight {
  color: var(--primary-color);
  border-color: var(--primary-color);
}

/* 官方一手文档与经典文献卡片网格 (Official Docs & Deep Readings) */
.readings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin: 16px 0 24px;
}

.reading-card {
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  text-decoration: none;
  color: inherit;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.reading-card:hover {
  border-color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.reading-type-tag {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  letter-spacing: 0.3px;
}

.reading-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  line-height: 1.4;
}

.reading-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* 全局 Toast 通知 */
.app-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 8px;
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 1000;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.app-toast.is-active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.app-toast-icon {
  color: var(--success-color);
  font-size: 1.1rem;
}

.markdown-body code:not(pre code) {
  background-color: var(--primary-subtle);
  color: var(--primary-color);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.markdown-body blockquote {
  border-left: 4px solid var(--border-color);
  padding: 10px 16px;
  background-color: var(--bg-surface);
  border-radius: 0 6px 6px 0;
  margin: 16px 0;
  color: var(--text-secondary);
}

.markdown-body blockquote p {
  margin: 6px 0;
}
.markdown-body blockquote p:first-child {
  margin-top: 0;
}
.markdown-body blockquote p:last-child {
  margin-bottom: 0;
}

/* VitePress / GitHub-flavored Alerts 警告框规范样式 */
.callout {
  margin: 20px 0;
  padding: 14px 18px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  border-left-width: 4px;
  background-color: var(--bg-surface);
  line-height: 1.65;
  transition: border-color 0.2s, background-color 0.2s;
}

.callout-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.callout-icon {
  font-size: 1.15rem;
  line-height: 1;
  flex-shrink: 0;
}

.callout-title {
  font-weight: 600;
  letter-spacing: 0.01em;
}

.callout-body {
  font-size: 0.92rem;
  color: var(--text-primary);
}

.callout-body p {
  margin: 8px 0;
}

.callout-body p:first-child {
  margin-top: 0;
}

.callout-body p:last-child {
  margin-bottom: 0;
}

.callout-body ul, .callout-body ol {
  margin: 6px 0;
  padding-left: 1.4rem;
}

.callout-body li {
  margin: 4px 0;
}

/* Callout 五大标准语义色系适配 (Light / Dark) */
/* 1. NOTE / INFO */
.callout-note {
  border-color: rgba(59, 130, 246, 0.25);
  border-left-color: #3b82f6;
  background-color: rgba(59, 130, 246, 0.05);
}
.callout-note .callout-title {
  color: #2563eb;
}
[data-theme="dark"] .callout-note {
  border-color: rgba(96, 165, 250, 0.25);
  border-left-color: #60a5fa;
  background-color: rgba(59, 130, 246, 0.1);
}
[data-theme="dark"] .callout-note .callout-title {
  color: #60a5fa;
}

/* 2. TIP */
.callout-tip {
  border-color: rgba(16, 185, 129, 0.25);
  border-left-color: #10b981;
  background-color: rgba(16, 185, 129, 0.05);
}
.callout-tip .callout-title {
  color: #059669;
}
[data-theme="dark"] .callout-tip {
  border-color: rgba(52, 211, 153, 0.25);
  border-left-color: #34d399;
  background-color: rgba(16, 185, 129, 0.1);
}
[data-theme="dark"] .callout-tip .callout-title {
  color: #34d399;
}

/* 3. IMPORTANT (核心公理 / 核心原则专属) */
.callout-important {
  border-color: rgba(139, 92, 246, 0.25);
  border-left-color: #8b5cf6;
  background-color: rgba(139, 92, 246, 0.06);
}
.callout-important .callout-title {
  color: #7c3aed;
}
[data-theme="dark"] .callout-important {
  border-color: rgba(167, 139, 250, 0.25);
  border-left-color: #a78bfa;
  background-color: rgba(139, 92, 246, 0.12);
}
[data-theme="dark"] .callout-important .callout-title {
  color: #c084fc;
}

/* 4. WARNING */
.callout-warning {
  border-color: rgba(245, 158, 11, 0.25);
  border-left-color: #f59e0b;
  background-color: rgba(245, 158, 11, 0.06);
}
.callout-warning .callout-title {
  color: #d97706;
}
[data-theme="dark"] .callout-warning {
  border-color: rgba(251, 191, 36, 0.25);
  border-left-color: #fbbf24;
  background-color: rgba(245, 158, 11, 0.1);
}
[data-theme="dark"] .callout-warning .callout-title {
  color: #fbbf24;
}

/* 5. CAUTION / DANGER */
.callout-caution {
  border-color: rgba(239, 68, 68, 0.25);
  border-left-color: #ef4444;
  background-color: rgba(239, 68, 68, 0.06);
}
.callout-caution .callout-title {
  color: #dc2626;
}
[data-theme="dark"] .callout-caution {
  border-color: rgba(248, 113, 113, 0.25);
  border-left-color: #f87171;
  background-color: rgba(239, 68, 68, 0.1);
}
[data-theme="dark"] .callout-caution .callout-title {
  color: #f87171;
}


.table-container {
  width: 100%;
  overflow-x: auto;
  margin: 16px 0 20px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  -webkit-overflow-scrolling: touch;
}

.markdown-body table {
  width: 100%;
  /* 560px 放得进桌面双栏布局的文档区（约 633px），窄屏上多列表格仍可横向滚动 */
  min-width: 560px;
  border-collapse: collapse;
  margin: 0;
  font-size: 0.88rem;
}
/* 3 列及以下的表格折行即可读，随容器收缩，不强制横向滚动 */
.markdown-body table:not(:has(tr > :nth-child(4))) {
  min-width: 0;
}
.markdown-body th, .markdown-body td {
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  text-align: left;
}
.markdown-body th {
  background-color: var(--bg-surface);
  color: var(--text-primary);
}

/* 随堂测验与考点卡片 */
.quiz-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px 18px;
  margin: 18px 0;
}

/* 其他全屏视图通用容器 */
.view-container {
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  background-color: var(--bg-primary);
  padding: 28px 20px;
}

.container-inner {
  max-width: 1080px;
  margin: 0 auto;
}

.view-intro {
  margin-bottom: 24px;
}
.view-intro h2 { font-size: 1.5rem; font-weight: 600; margin-bottom: 6px; }
.view-intro p { color: var(--text-secondary); font-size: 0.95rem; }

.paths-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.job-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.job-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary-color);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
}

.job-card-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.job-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* 隐藏移动端专属部件 (默认桌面端) */
.mobile-segmented-bar {
  display: none;
}
.mobile-action-bar {
  display: none;
}

/* ==========================================================================
   核心技术交互仿真器组件系统 (Interactive Simulators System)
   深度吸收 learn-ai / learn-llm 交互拓扑与红旗实验设计哲学
   ========================================================================== */

.sim-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow-card);
  margin-bottom: 24px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.sim-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 10px;
}

.sim-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sim-intro {
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.6;
  margin: 0 0 18px;
}

/* 仿真器双栏交互工作台 */
.sim-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 20px;
  margin-top: 16px;
}

@media (max-width: 992px) {
  .sim-workbench {
    grid-template-columns: minmax(0, 1fr);
  }
}

.sim-workbench > div {
  min-width: 0;
  max-width: 100%;
}

.asm-graph-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.btn-zoom-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface-variant);
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s ease;
}
.btn-zoom-action:hover {
  background: var(--primary-subtle);
  color: var(--primary-color);
  border-color: var(--primary-color);
}

/* 动态 SVG 状态拓扑图 */
.asm-graph-wrap {
  background: var(--bg-editor);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  position: relative;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.08);
}

.asm-svg {
  width: 100%;
  height: auto;
  display: block;
}

.asm-mobile-swipe-hint {
  display: none;
}

.asm-node {
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.asm-node:hover rect {
  stroke-width: 2.2px;
  filter: brightness(1.2);
}

.asm-node.is-active rect {
  filter: drop-shadow(0 0 8px rgba(34, 211, 238, 0.5));
}

.asm-line {
  transition: stroke 0.25s ease, stroke-width 0.25s ease;
}

.asm-line.is-active {
  stroke: var(--primary-color) !important;
  stroke-width: 2.4px !important;
  stroke-dasharray: 6, 4;
  animation: asmFlow 1.2s linear infinite;
}

.asm-badge-rect {
  transition: all 0.2s ease;
}

.asm-badge-text {
  user-select: none;
  font-family: var(--font-mono, monospace);
}

@keyframes asmFlow {
  to {
    stroke-dashoffset: -20;
  }
}

/* 控制与实验参数面板 */
.sim-controls-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background-color: var(--bg-surface-variant);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  margin-top: 14px;
}

.sim-btn-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sim-slider-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.sim-slider-group input[type="range"] {
  width: 90px;
  cursor: pointer;
}

.sim-slider-group strong {
  color: var(--primary-color);
  font-family: var(--font-mono);
  min-width: 28px;
}

/* 状态解析卡片与指示器 */
.sim-side-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.state-detail-card {
  padding: 14px 16px;
  background-color: var(--bg-surface-variant);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--primary-color);
}

.state-detail-card-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.state-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.state-desc {
  font-size: 0.86rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0 0 10px;
}

.state-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.78rem;
  font-family: var(--font-mono);
}

.state-meta-chip {
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
}

.state-meta-chip.highlight {
  border-color: var(--primary-color);
  color: var(--primary-color);
  background: rgba(34, 211, 238, 0.08);
}

/* 实时终端事件流 */
.sim-terminal-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-console);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  min-height: 220px;
  max-height: 280px;
}

.sim-terminal-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--bg-surface-variant);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.76rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.sim-terminal-body {
  flex: 1;
  padding: 10px 12px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.6;
}

.sim-log-item {
  margin-bottom: 6px;
  color: var(--text-secondary);
  word-break: break-all;
}

.sim-log-item.latest {
  color: var(--text-primary);
  font-weight: 600;
}

.sim-log-item .tag-idle { color: var(--text-muted); font-weight: 600; }
.sim-log-item .tag-think { color: #0284c7; font-weight: 600; }
.sim-log-item .tag-tool { color: #d97706; font-weight: 600; }
.sim-log-item .tag-exec { color: #e11d48; font-weight: 600; }
.sim-log-item .tag-observe { color: #059669; font-weight: 600; }
.sim-log-item .tag-done { color: #10b981; font-weight: 700; }
.sim-log-item .tag-error { color: #ef4444; font-weight: 700; }

[data-theme="dark"] .sim-log-item .tag-think { color: #38bdf8; }
[data-theme="dark"] .sim-log-item .tag-tool { color: #fbbf24; }
[data-theme="dark"] .sim-log-item .tag-exec { color: #f43f5e; }
[data-theme="dark"] .sim-log-item .tag-observe { color: #34d399; }

.sim-log-empty {
  color: var(--text-muted);
  text-align: center;
  padding: 40px 0;
}

/* 教学红旗实验提示框 */
.sim-pedagogical-alert {
  margin-top: 18px;
  padding: 12px 16px;
  background: var(--warning-subtle);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-left: 4px solid var(--warning-color);
  border-radius: 8px;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--text-primary);
}

.sim-pedagogical-alert strong {
  color: var(--warning-color);
  font-weight: 700;
}

/* 通用输入/网格/统计组件 */
.sim-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin: 14px 0;
}

.sim-textarea {
  width: 100%;
  padding: 10px;
  border-radius: 6px;
  background-color: var(--bg-editor);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  resize: vertical;
  box-sizing: border-box;
}

.sim-textarea:focus, .sim-input:focus, .sim-select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px var(--primary-subtle);
}

.sim-input, .sim-select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  background-color: var(--bg-surface-variant);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.86rem;
  box-sizing: border-box;
  margin-top: 4px;
}

.sim-console {
  background-color: var(--bg-console);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-primary);
}

.sim-diagram-preview {
  margin: 10px 0 16px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: var(--bg-surface-variant) !important;
  padding: 8px;
}

.sim-diagram-preview img {
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  display: block;
}

/* 仿真器全景蓝图快捷查看栏 */
.sim-diagram-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  margin: 10px 0 14px;
  background: var(--bg-surface-variant);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.82rem;
}

.sim-diagram-bar .sim-diagram-tip {
  color: var(--text-secondary);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-zoom-diagram {
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  font-size: 0.78rem;
  padding: 4px 10px;
}

.btn-zoom-diagram:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  transform: translateY(-1px);
}

/* MCP 动态交互协议总线 */
.mcp-protocol-visualizer {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  align-items: center;
  gap: 14px;
  padding: 14px;
  margin: 10px 0 14px;
  background: var(--bg-surface-variant);
  border: 1px solid var(--border-color);
  border-radius: 10px;
}

.mcp-viz-client, .mcp-viz-server {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--shadow-card);
}

.mcp-viz-icon {
  font-size: 1.5rem;
}

.mcp-viz-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.mcp-viz-info strong {
  font-size: 0.86rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mcp-viz-info span {
  font-size: 0.74rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mcp-viz-channel {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
}

.mcp-viz-wire {
  width: 100%;
  height: 3px;
  background: var(--border-color);
  border-radius: 2px;
  position: relative;
}

.mcp-viz-packet {
  position: absolute;
  top: -10px;
  left: calc(50% - 40px);
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.mcp-viz-packet .packet-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--primary-color);
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 700;
  font-family: var(--font-mono);
  box-shadow: 0 2px 8px var(--primary-subtle);
}

.mcp-viz-packet.packet-to-server {
  left: calc(100% - 80px);
}

.mcp-viz-packet.packet-to-client {
  left: 0;
}

.mcp-viz-wire-label {
  margin-top: 12px;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* SSE 4 阶流式解析管道流水线 */
.sse-pipeline-visualizer {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 10px 0 14px;
}

.sse-step-node {
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  background: var(--bg-surface-variant);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: all 0.25s ease;
}

.sse-step-node.active {
  border-color: var(--primary-color);
  background: var(--bg-card);
  box-shadow: 0 0 0 1px var(--primary-color), var(--shadow-card);
}

.sse-step-hdr {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.sse-step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary-color);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
}

.sse-step-title {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-primary);
}

.sse-step-sub {
  font-size: 0.74rem;
  color: var(--text-secondary);
}

/* Token 上下文预算分层色块 */
.token-budget-visualizer {
  margin: 10px 0 14px;
  padding: 12px 14px;
  background: var(--bg-surface-variant);
  border: 1px solid var(--border-color);
  border-radius: 10px;
}

.token-budget-bar {
  display: flex;
  height: 22px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--border-color);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
  margin-bottom: 10px;
}

.token-budget-seg {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 700;
  font-family: var(--font-mono);
  transition: width 0.3s ease;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.seg-sys { background: #e11d48; }
.seg-sum { background: #7c3aed; }
.seg-win { background: #0284c7; }
.seg-res { background: #059669; }

.token-budget-legend {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  font-size: 0.76rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.sim-stats-card {
  padding: 16px;
  background-color: var(--bg-surface-variant);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.sim-stats-card h4 {
  margin: 0 0 12px;
  font-size: 1rem;
  color: var(--text-primary);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.progress-bar-wrap {
  height: 8px;
  background-color: var(--border-color);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-bar-fill {
  height: 100%;
  transition: width 0.3s ease;
}

.bg-primary { background-color: var(--primary-color); }
.bg-danger { background-color: var(--danger-color); }

.compact-alert {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  margin-top: 10px;
  background: var(--success-subtle);
  color: var(--success-color);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.compact-alert.alert-show {
  background: var(--danger-subtle);
  color: var(--danger-color);
  border-color: rgba(239, 68, 68, 0.35);
}

.diff-view {
  background-color: var(--bg-console);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.6;
  overflow-x: auto;
  color: var(--text-primary);
}

.diff-add {
  color: var(--success-color);
  background: var(--success-subtle);
  display: block;
  border-left: 3px solid var(--success-color);
  padding: 1px 8px;
}

.diff-del {
  color: var(--danger-color);
  background: var(--danger-subtle);
  display: block;
  border-left: 3px solid var(--danger-color);
  padding: 1px 8px;
}

.diff-hdr {
  color: var(--link-color);
  font-weight: 600;
  display: block;
  background: rgba(2, 132, 199, 0.08);
  padding: 2px 8px;
  margin: 4px 0;
  border-radius: 4px;
}

.diff-ctx {
  color: var(--text-secondary);
  display: block;
  padding: 1px 11px;
}

.mcp-frame {
  margin-bottom: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--bg-surface-variant);
  border: 1px solid var(--border-color);
}

.mcp-frame .frame-hdr {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
  margin-bottom: 4px;
  font-weight: 600;
}

.mcp-frame.color-send .frame-hdr { color: var(--primary-color); }
.mcp-frame.color-recv .frame-hdr { color: var(--success-color); }
.mcp-frame pre { margin: 0; }
.mcp-frame code { font-size: 0.78rem; color: var(--text-primary); }

.sim-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.sim-table th {
  background: var(--bg-surface-variant);
  padding: 8px 10px;
  text-align: left;
  border-bottom: 2px solid var(--border-color);
  color: var(--text-primary);
  font-weight: 600;
}

.sim-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.sim-table tr:hover td {
  background: var(--bg-card-hover);
}

/* ==========================================================================
   移动端响应式核心适配 (@media max-width: 840px)
   解决关键问题：
   1. 首次加载避免左右分屏闪烁，默认优先渲染完整文档视图
   2. iOS Safari 视口防横向滚动与橡皮筋溢出
   3. 高清矢量图与交互面板适配
   ========================================================================== */

/* 顶栏图标桌面端与移动端响应式分配：桌面端默认隐藏移动端专属工具箱按钮 */
.nav-mobile-only {
  display: none !important;
}

@media (max-width: 840px) {
  :root {
    --header-height: 48px;
  }

  .header {
    padding: 0 8px;
    gap: 4px;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .header-left {
    gap: 6px;
    flex-shrink: 0;
  }

  .header-right {
    gap: 4px;
    flex-shrink: 0;
  }

  /* 移动端隐藏桌面繁冗图标（⚙ 供应商 / 📁 工作区），移入「⋯ 工具箱」抽屉，彻底解决顶栏拥挤 */
  .nav-desktop-only {
    display: none !important;
  }

  .nav-mobile-only {
    display: inline-flex !important;
  }

  .nav-term-btn {
    display: inline-flex !important;
  }

  /* 移动端隐藏桌面导航文字链接与进度条，保留核心 */
  .nav-links,
  .progress-container,
  .brand-title {
    display: none !important;
  }

  /* 移动端顶栏中央显示极简精致的 Segmented Switcher */
  .mobile-segmented-bar {
    display: flex;
    align-items: center;
    background-color: var(--bg-primary);
    border-radius: 8px;
    padding: 2px;
    border: 1px solid var(--border-color);
    margin: 0 4px;
    flex: 1;
    min-width: 0;
    max-width: 168px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
  }

  .segmented-item {
    flex: 1;
    min-width: 0;
    text-align: center;
    padding: 4px 2px;
    font-size: 0.76rem;
    font-weight: 500;
    border-radius: 6px;
    color: var(--text-secondary);
    white-space: nowrap;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: all 0.16s ease;
  }

  .segmented-item.active {
    background-color: var(--bg-surface-variant);
    color: var(--primary-color);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  }

  .icon-btn {
    width: 32px;
    height: 32px;
    padding: 6px;
    border-radius: 6px;
  }

  /* 主工作区分栏拆解为单屏模式 */
  .main-workspace {
    flex-direction: column;
    height: calc(100vh - var(--header-height));
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  .splitter {
    display: none !important;
  }

  /* 核心修复 1：移动端默认且立即显示文档模式，绝无分屏闪烁（无需依赖 JS 异步加载状态） */
  .pane-guide {
    display: flex !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    flex: 1 1 100% !important;
    overflow-x: hidden !important;
  }

  .pane-code {
    display: none !important;
  }

  /* 核心修复 2：iOS Safari 根治横向滚动与溢出 */
  .guide-body {
    padding: 16px 14px 80px;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
  }

  .guide-header {
    padding: 8px 12px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
  }

  .guide-step-title {
    min-width: 0;
    flex: 1;
    overflow: hidden;
  }

  .guide-heading-text {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .guide-step-nav .btn {
    padding: 4px 8px;
    font-size: 0.75rem;
    flex-shrink: 0;
  }

  .code-header {
    padding: 6px 8px;
  }

  .code-actions .btn {
    padding: 4px 8px;
    font-size: 0.75rem;
  }

  /* 移动端视图状态切换机 */
  body[data-mobile-view="code"] .pane-guide {
    display: none !important;
  }
  body[data-mobile-view="code"] .pane-code {
    display: flex !important;
    width: 100% !important;
    height: calc(100% - 50px) !important;
  }
  body[data-mobile-view="code"] .console-panel {
    display: none !important;
  }

  body[data-mobile-view="console"] .pane-guide {
    display: none !important;
  }
  body[data-mobile-view="console"] .pane-code {
    display: flex !important;
    width: 100% !important;
    height: calc(100% - 50px) !important;
  }
  body[data-mobile-view="console"] .editor-container,
  body[data-mobile-view="console"] .code-header {
    display: none !important;
  }
  body[data-mobile-view="console"] .console-panel {
    display: flex !important;
    flex: 1 !important;
    height: 100% !important;
  }

  /* 移动端底部操作栏 */
  .mobile-action-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50px;
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    padding: 6px 12px;
    gap: 8px;
    align-items: center;
    z-index: 90;
    box-sizing: border-box;
  }

  body[data-mobile-view="guide"] .mobile-action-bar {
    display: none !important;
  }

  /* 非教程页面隐藏专属分段栏 */
  body.view-simulators .mobile-segmented-bar,
  body.view-appendices .mobile-segmented-bar,
  body.view-paths .mobile-segmented-bar,
  body.view-walkthrough .mobile-segmented-bar,
  body.view-simulators .mobile-action-bar,
  body.view-appendices .mobile-action-bar,
  body.view-paths .mobile-action-bar,
  body.view-walkthrough .mobile-action-bar {
    display: none !important;
  }

  /* 移动端阅读引导条 */
  .guide-enter-code-banner {
    margin-top: 24px;
    padding: 14px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--bg-surface), var(--bg-surface-variant));
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
    text-align: center;
    box-sizing: border-box;
  }

  /* 移动端保留图中文字的基准尺寸，横向滚动仅发生在图卡内部。 */
  .diagram-figure {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0;
    margin: 18px 0 22px !important;
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
    box-sizing: border-box;
    overflow: hidden;
  }

  .diagram-img-wrap {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    padding: 8px 4px !important;
    background-color: var(--bg-surface) !important;
    box-sizing: border-box;
    display: flex;
    justify-content: flex-start;
    align-items: center;
  }

  .diagram-img-wrap .diagram-image {
    width: 960px !important;
    min-width: 960px;
    max-width: none !important;
    flex-shrink: 0;
    height: auto !important;
    display: block;
    cursor: zoom-in;
  }

  .inline-diagram-img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    display: block;
    object-fit: contain;
    cursor: zoom-in;
  }

  .diagram-caption {
    font-size: 0.76rem;
    padding: 8px 12px;
    width: 100%;
    box-sizing: border-box;
    flex-wrap: wrap;
  }

  .diagram-caption .zoom-hint {
    display: inline-block;
    min-height: 44px;
    padding: 6px 10px;
  }

  /* 移动端代码块占满全宽（沉浸式排版，避免边距浪费） */
  .code-block-wrapper {
    width: calc(100% + 28px) !important;
    max-width: calc(100% + 28px) !important;
    margin-left: -14px !important;
    margin-right: -14px !important;
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
    box-sizing: border-box;
    overflow: hidden;
  }

  .markdown-body pre {
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
  }

  .table-container {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
  }

  .lightbox-content {
    max-width: 100vw;
    max-height: 92vh;
    padding: 8px;
  }

  #lightbox-img,
  .lightbox-vector {
    max-width: 98vw;
    max-height: 74vh;
    width: 98vw;
    height: auto;
  }

  .lightbox-btn {
    min-width: 44px;
    min-height: 44px;
  }

  .lightbox-close-btn {
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    font-size: 20px;
  }

  /* 移动端 Toast 悬浮在底部操作栏上方 */
  .app-toast {
    left: 16px;
    right: 16px;
    bottom: 64px;
    justify-content: center;
    text-align: center;
  }

  /* 移动端交互仿真器组件紧凑自适应 */
  .mcp-protocol-visualizer {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
  }
  .mcp-viz-channel {
    padding: 4px 0;
  }
  .mcp-viz-wire {
    display: none;
  }
  .sse-pipeline-visualizer {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .token-budget-legend {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .sim-card {
    padding: 14px 12px;
  }
  .sim-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .sim-header h3 {
    font-size: 1rem;
    line-height: 1.4;
  }
  .asm-graph-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px;
    border-radius: 8px;
  }
  .asm-graph-wrap .asm-svg {
    min-width: 640px;
    width: 640px;
    height: auto;
    display: block;
  }
  .asm-mobile-swipe-hint {
    display: inline !important;
  }
}

/* ===== 随堂思考题交互题卡（quiz.js）——答案不直接暴露，对标 javascript.info 任务卡 ===== */
.quiz-card {
  margin: 14px 0 22px;
  padding: 14px 16px;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 12px;
  background: var(--bg-card, rgba(127, 127, 127, 0.04));
}
.quiz-options { display: grid; gap: 8px; margin-top: 4px; }
.quiz-option {
  display: flex; align-items: flex-start; gap: 10px; width: 100%;
  padding: 9px 12px; border-radius: 9px; cursor: pointer; text-align: left;
  border: 1px solid var(--border-color, #e2e8f0);
  background: transparent; color: inherit; font-size: 0.9rem; line-height: 1.55;
  transition: border-color .15s ease, background .15s ease;
}
.quiz-option:hover { border-color: var(--primary-color); background: var(--primary-subtle); }
.quiz-option-letter {
  flex: none; width: 22px; height: 22px; border-radius: 6px; margin-top: 1px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
  background: var(--primary-subtle); color: var(--primary-color);
}
.quiz-option.is-correct { border-color: var(--success-color); background: var(--success-subtle); }
.quiz-option.is-correct .quiz-option-letter { background: var(--success-subtle); color: var(--success-color); }
.quiz-option.is-wrong { border-color: var(--danger-color); background: var(--danger-subtle); }
.quiz-option.is-wrong .quiz-option-letter { background: var(--danger-subtle); color: var(--danger-color); }
.quiz-feedback { margin-top: 10px; font-size: 0.85rem; min-height: 0; }
.quiz-feedback.is-ok { color: var(--success-color); }
.quiz-feedback.is-bad { color: var(--danger-color); }
.quiz-actions { display: flex; gap: 10px; margin-top: 10px; }
.quiz-reveal, .quiz-redo {
  padding: 5px 12px; font-size: 0.8rem; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--border-color, #e2e8f0); background: transparent; color: inherit;
}
.quiz-reveal:hover:not(:disabled) { border-color: var(--primary-color); color: var(--primary-color); }
.quiz-redo:hover { border-color: var(--primary-color); }
.quiz-explain {
  margin-top: 10px; padding: 10px 12px; border-radius: 9px; font-size: 0.85rem; line-height: 1.65;
  border-left: 3px solid var(--primary-color); background: var(--primary-subtle);
}
.quiz-section { margin-top: 34px; }
.quiz-section-sub { opacity: .6; font-size: .85rem; margin: 4px 0 6px; }
.quiz-question { font-weight: 600; font-size: .95rem; line-height: 1.6; }

/* ===== 书籍式引用角标（citations.js） ===== */
.cite-sup {
  cursor: pointer; user-select: none;
  font-size: 0.62em; line-height: 1;
  color: var(--primary-color);
  padding: 0 1px; margin-left: 1px;
  vertical-align: super;
}
/* 统一文献索引列表排版：消除默认圆点，采用 [N] 学术索引徽标 */
.markdown-body .ref-list,
.markdown-body ul:has(.ref-num),
.markdown-body ol:has(.ref-num) {
  list-style-type: none !important;
  padding-left: 0 !important;
  margin-top: 14px;
}

.markdown-body .ref-item,
.markdown-body li:has(> .ref-num) {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 12px;
  line-height: 1.68;
}

.ref-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--primary-color);
  background: var(--primary-subtle);
  border: 1px solid rgba(244, 63, 94, 0.28);
  border-radius: 4px;
  padding: 1px 6px;
  margin-right: 4px;
  line-height: 1.25;
}
.ref-flash { animation: ref-flash 1.6s ease; }
@keyframes ref-flash {
  0% { background: var(--primary-subtle); box-shadow: 0 0 0 3px var(--primary-subtle); }
  100% { background: transparent; box-shadow: none; }
}

/* 统一章节题头：自然换行，沿用正文的主题色。 */
.markdown-body .chapter-intro {
  max-width: 800px;
  margin-bottom: 32px;
  font-size: 16px;
  line-height: 1.75;
}
.markdown-body .chapter-intro h1 {
  margin: 0 0 12px;
  padding: 0;
  border: 0;
  font-size: clamp(26px, 2.5vw, 36px);
  line-height: 1.3;
  text-wrap: pretty;
}
.markdown-body .chapter-intro .chapter-intro-duration {
  margin-bottom: 20px;
  font-size: 14px;
}
.markdown-body .chapter-intro ul {
  margin-top: 0;
  margin-bottom: 20px;
}
.markdown-body .chapter-intro li {
  margin-bottom: 8px;
}
.markdown-body .chapter-intro .chapter-intro-prerequisite {
  margin-bottom: 0;
  font-size: 14px;
}

/* 知识地图定位条：全书各部分 → 本部分问题 → 本部分章节（数据来自 manifest，见 js/locator.js） */
.markdown-body .chapter-locator {
  max-width: 800px;
  margin: 0 0 24px;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-surface-variant);
  font-size: 13px;
  line-height: 1.6;
}
.markdown-body .chapter-locator .locator-parts,
.markdown-body .chapter-locator .locator-chapters {
  display: flex;
  gap: 6px;
  padding: 2px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  white-space: nowrap;
}
.markdown-body .chapter-locator .locator-parts::-webkit-scrollbar,
.markdown-body .chapter-locator .locator-chapters::-webkit-scrollbar { display: none; }
.markdown-body .chapter-locator .locator-part,
.markdown-body .chapter-locator .locator-chapter {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
  min-width: max-content;
  padding: 2px 8px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  color: var(--text-secondary);
  text-decoration: none;
}
.markdown-body .chapter-locator .locator-part:hover,
.markdown-body .chapter-locator .locator-chapter:hover { color: var(--text-primary); border-color: var(--text-muted); }
.markdown-body .chapter-locator .locator-part-no { font-weight: 700; }
.markdown-body .chapter-locator .locator-chapter-no { font-weight: 700; font-variant-numeric: tabular-nums; }
.markdown-body .chapter-locator .locator-chapter-title {
  display: inline-block;
  max-width: 9em;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}
.markdown-body .chapter-locator .is-current {
  color: var(--primary-contrast);
  background: var(--primary-color);
  border-color: var(--primary-color);
}
.markdown-body .chapter-locator .locator-chapter.is-current .locator-chapter-title { max-width: 16em; }
.markdown-body .chapter-locator .locator-chapter.is-done { border-style: dashed; }
.markdown-body .chapter-locator .locator-chapter.is-done .locator-chapter-no::after { content: " ✓"; }
.markdown-body .chapter-locator .locator-question {
  margin: 10px 0;
  color: var(--text-secondary);
}
.markdown-body .chapter-locator .locator-question strong { color: var(--text-primary); }
@media (max-width: 840px) {
  .markdown-body .chapter-locator .locator-part-theme { display: none; }
}
.markdown-body .chapter-locator .locator-trail { margin: 10px 0 2px; color: var(--text-secondary); }
.markdown-body .chapter-locator .locator-trail strong { color: var(--text-primary); }
.markdown-body .chapter-locator .locator-question { margin: 0 0 10px; }
.markdown-body .chapter-locator .locator-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 3px 6px;
  border-radius: 999px;
  background: var(--bg-surface);
}
.markdown-body .chapter-locator .locator-group.is-current { outline: 1px solid var(--primary-color); }
.markdown-body .chapter-locator .locator-group-title {
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

/* 全书地图：统领 → 阶段 → 部分 → 分组 → 章（数据来自 manifest，见 js/book-map.js） */
.book-map { max-width: 1100px; margin: 0 auto; padding: 8px 0 40px; }
.book-map .map-top {
  padding: 20px 24px;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: var(--bg-surface-variant);
}
.book-map .map-question { margin: 0 0 6px; font-size: 14px; color: var(--text-muted); }
.book-map .map-thesis {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: clamp(18px, 2vw, 22px);
  line-height: 1.6;
  color: var(--text-primary);
}
.book-map .map-here { margin: 12px 0 0; font-size: 14px; color: var(--text-secondary); }
.book-map .map-scqa {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0 0;
}
.book-map .map-scqa > div {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-surface);
}
.book-map .map-scqa dt { font-size: 12px; font-weight: 700; color: var(--primary-color); }
.book-map .map-scqa dd { margin: 4px 0 0; font-size: 13.5px; line-height: 1.6; color: var(--text-secondary); }
.book-map .map-order { margin: 18px 0 8px; font-size: 13.5px; color: var(--text-muted); }
.book-map .map-stages { list-style: none; margin: 0; padding: 0; }
.book-map .map-stage {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px;
  padding: 16px 0;
  border-top: 1px dashed var(--border-color);
}
.book-map .map-stage.is-current .map-stage-title { color: var(--primary-color); }
.book-map .map-stage-no { font-size: 12px; font-weight: 700; color: var(--text-muted); }
.book-map .map-stage-title { margin: 2px 0 6px; padding: 0; border: 0; font-size: 18px; }
.book-map .map-stage-point { margin: 0; font-size: 13.5px; line-height: 1.6; color: var(--text-secondary); }
.book-map .map-stage-parts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
  align-items: start;
}
.book-map .map-part {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-card);
}
.book-map .map-part[open] { grid-column: 1 / -1; }
.book-map .map-part.is-current { border-color: var(--primary-color); }
.book-map .map-part > summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}
.book-map .map-part > summary::-webkit-details-marker { display: none; }
.book-map .map-part-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.book-map .map-part-theme, .book-map .map-part-path, .book-map .map-part-progress { white-space: nowrap; }
.book-map .map-part-no { font-size: 12px; font-weight: 700; color: var(--text-muted); }
.book-map .map-part-theme { font-weight: 800; color: var(--text-primary); }
.book-map .map-part-progress { margin-left: auto; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.book-map .map-part-question { font-size: 13.5px; line-height: 1.55; color: var(--text-secondary); }
.book-map .map-part-groups { font-size: 12px; color: var(--text-muted); }
.book-map .map-part-body { padding: 0 14px 14px; }
.book-map .map-part-answer { margin: 0 0 4px; font-size: 14px; line-height: 1.7; }
.book-map .map-part-order { margin: 0 0 10px; font-size: 13px; color: var(--text-muted); }
.book-map .map-group {
  margin-top: 10px;
  padding: 10px 12px;
  border-left: 3px solid var(--border-color);
  background: var(--bg-surface-variant);
  border-radius: 0 8px 8px 0;
}
.book-map .map-group-title { margin: 0; padding: 0; border: 0; font-size: 14.5px; display: flex; gap: 8px; align-items: baseline; }
.book-map .map-group-range { font-size: 12px; font-weight: 400; color: var(--text-muted); }
.book-map .map-group-point { margin: 2px 0 6px; font-size: 13px; color: var(--text-secondary); }
.book-map .map-chapters { list-style: none; margin: 0; padding: 0; }
.book-map .map-chapter { margin: 6px 0; }
.book-map .map-chapter a { display: inline-flex; gap: 8px; text-decoration: none; color: var(--text-primary); font-weight: 600; }
.book-map .map-chapter a:hover { color: var(--primary-color); }
.book-map .map-chapter.is-current a { color: var(--primary-color); }
.book-map .map-chapter.is-done .map-chapter-no::after { content: " ✓"; }
.book-map .map-chapter-no { min-width: 2.2em; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.book-map .map-chapter-summary { margin: 2px 0 0 3em; font-size: 12.5px; line-height: 1.6; color: var(--text-muted); }
.book-map .map-notes { margin-top: 18px; font-size: 13px; color: var(--text-muted); }
.book-map .map-notes p { margin: 4px 0; }
@media (max-width: 840px) {
  .book-map .map-top { padding: 16px; }
  .book-map .map-scqa { grid-template-columns: minmax(0, 1fr); }
  .book-map .map-stage { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .book-map .map-stage-parts { grid-template-columns: minmax(0, 1fr); }
  .book-map .map-chapter-summary { margin-left: 0; }
}
.book-map .map-paths { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 10px; }
.book-map .map-paths-label { font-size: 13px; color: var(--text-muted); }
.book-map .map-path-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
}
.book-map .map-path-btn[aria-pressed="true"] { color: var(--primary-contrast); background: var(--primary-color); border-color: var(--primary-color); }
.book-map .map-path-count { font-size: 11.5px; opacity: 0.8; }
.book-map .map-part-path { font-size: 12px; color: var(--primary-color); }
.book-map .map-part-path.is-empty { color: var(--text-muted); }
.book-map .map-chapter.is-off-path { opacity: 0.38; }
.book-map .map-group-point { font-weight: 600; color: var(--text-primary); }
.book-map .map-part-path { margin-left: auto; }
.book-map .map-part-path + .map-part-progress { margin-left: 8px; }
.book-map .map-part:has(.map-part-path.is-empty) { opacity: 0.55; }
.markdown-body .chapter-locator .locator-part-intro {
  margin: 12px 0 2px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg-surface);
}
.markdown-body .chapter-locator .locator-part-intro-title { margin: 0 0 4px; font-weight: 700; color: var(--text-primary); }
.markdown-body .chapter-locator .locator-part-intro p { margin: 0 0 6px; }
.markdown-body .chapter-locator .locator-part-intro ol { margin: 4px 0 0; padding-left: 1.4em; }
.markdown-body .chapter-locator .locator-part-intro li { margin: 3px 0; }
.markdown-body .chapter-locator .locator-part-intro .locator-intro-range { color: var(--text-muted); font-size: 12px; }

/* Keyboard focus remains visible in both themes; optional motion never carries state. */
:where(button, a, input, textarea, select, summary):focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 3px;
}

@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;
  }
}
