/* =========================================================
   知识星图孵化器 · 阶段一底座样式
   原则：核心布局不依赖 Tailwind；即使 CDN 失效，页面仍可用。
   ========================================================= */

:root {
  --bg: #05070f;
  --bg-soft: #0a1020;
  --panel: rgba(11, 18, 32, 0.82);
  --panel-solid: #0b1220;
  --line: rgba(99, 102, 241, 0.18);
  --line-strong: rgba(99, 102, 241, 0.42);
  --text: #e6ecff;
  --muted: #93a3c4;
  --muted-2: #6b7c9e;
  --accent: #6366f1;              /* 主强调色（靛蓝，默认主题） */
  --accent-strong: #4f46e5;       /* 主强调色深色档 */
  --accent-soft: #818cf8;         /* 主强调色浅色档 */
  --accent-2: #22d3ee;            /* 次级强调色 */
  --accent-glow: rgba(99, 102, 241, 0.28);   /* 品牌/按钮辉光 */
  --accent-border: rgba(99, 102, 241, 0.35); /* 强调边框 */
  --accent-chip-bg: rgba(99, 102, 241, 0.16);/* 强调 chip 背景 */
  --success: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 16px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "Consolas", "SFMono-Regular", "Menlo", monospace;
}

/* 阶段五 · 主题彩蛋：点击左上角品牌图标循环切换（仅界面外壳配色，不影响三维数据着色） */
body[data-theme="violet"] {
  --accent: #8b5cf6;
  --accent-strong: #7c3aed;
  --accent-soft: #a78bfa;
  --accent-2: #c4b5fd;
  --accent-glow: rgba(139, 92, 246, 0.28);
  --accent-border: rgba(139, 92, 246, 0.4);
  --accent-chip-bg: rgba(139, 92, 246, 0.16);
}
body[data-theme="starlight"] {
  --accent: #ec4899;
  --accent-strong: #db2777;
  --accent-soft: #f472b6;
  --accent-2: #f9a8d4;
  --accent-glow: rgba(236, 72, 153, 0.28);
  --accent-border: rgba(236, 72, 153, 0.4);
  --accent-chip-bg: rgba(236, 72, 153, 0.16);
}

* { box-sizing: border-box; }

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body {
  overflow: hidden;
  background:
    radial-gradient(1200px 700px at 72% -10%, rgba(79, 70, 229, 0.18), transparent 60%),
    radial-gradient(900px 600px at 8% 110%, rgba(34, 211, 238, 0.10), transparent 60%),
    var(--bg);
}

button { font-family: inherit; }
a { color: var(--accent-2); }

.noscript-warning {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  z-index: 200;
}

/* ------------------------- 基础组件 ------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.12s ease, box-shadow 0.16s ease;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  border-color: var(--accent-soft);
  box-shadow: 0 6px 18px var(--accent-glow);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--accent-soft), var(--accent)); }
.btn-ghost {
  background: rgba(99, 102, 241, 0.08);
  border-color: var(--accent-border);
  color: #cbd5ec;
}
.btn-ghost:hover { background: var(--accent-chip-bg); border-color: var(--accent-soft); }
.btn-ghost[aria-pressed="true"] {
  background: rgba(34, 211, 238, 0.14);
  border-color: rgba(34, 211, 238, 0.5);
  color: #a5f3fc;
}
.btn-outline {
  background: rgba(8, 13, 24, 0.6);
  border-color: rgba(148, 163, 184, 0.28);
  color: #cbd5ec;
}
.btn-outline:hover { border-color: rgba(148, 163, 184, 0.5); background: rgba(148, 163, 184, 0.08); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 10px; font-size: 11.5px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.6);
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.icon-btn:hover { color: var(--text); border-color: rgba(148, 163, 184, 0.45); background: rgba(30, 41, 59, 0.8); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid transparent;
}
.chip-stage { color: var(--accent-soft); background: var(--accent-chip-bg); border-color: var(--accent-border); }
.chip-ok { color: #6ee7b7; background: rgba(16, 185, 129, 0.12); border-color: rgba(16, 185, 129, 0.3); }
.chip-warn { color: #fde68a; background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.32); }
.chip-muted { color: var(--muted); background: rgba(148, 163, 184, 0.1); border-color: rgba(148, 163, 184, 0.24); }
.chip-accent { color: #a5f3fc; background: rgba(34, 211, 238, 0.1); border-color: rgba(34, 211, 238, 0.3); }

/* ------------------------- 整体骨架 ------------------------- */

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
}

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(9, 14, 26, 0.94), rgba(5, 7, 15, 0.72));
  backdrop-filter: blur(10px);
  flex: 0 0 auto;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: radial-gradient(circle at 30% 25%, var(--accent-soft), rgba(8, 12, 24, 0.92));
  border: 1px solid var(--line-strong);
  box-shadow: 0 0 24px var(--accent-glow);
  cursor: pointer; /* 阶段五：主题切换彩蛋入口，悬停可见手型提示 */
}
.brand-mark svg { width: 26px; height: 26px; }
.brand-text { min-width: 0; }
.brand-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.brand-sub {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.workspace {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  min-height: 0;
  flex: 1 1 auto;
}

/* ------------------------- 左侧面板 ------------------------- */

.panel-left {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.3) transparent;
}
.panel-left::-webkit-scrollbar { width: 6px; }
.panel-left::-webkit-scrollbar-thumb { background: rgba(99, 102, 241, 0.28); border-radius: 999px; }
.panel-left::-webkit-scrollbar-track { background: transparent; }

/* ------------------------- 阶段九 IA：分组页签 / 面板分组 / 空态 ------------------------- */

.panel-tabs {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
  border-bottom: 1px solid var(--line);
}
.panel-tab {
  flex: 1 1 0;
  padding: 9px 2px 10px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: color 0.16s ease, border-color 0.16s ease;
}
.panel-tab:hover { color: #dbe3fa; }
.panel-tab.is-active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* 面板分组：单列 + 12px 间距（原 .panel-left 的 gap 下沉到此处） */
.panel-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 0 0 auto;
}

/* 「更多」折叠区（默认收起） */
.more-toggle-row {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
}
.more-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(8, 13, 24, 0.6);
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
  transition: color 0.16s ease, border-color 0.16s ease;
}
.more-toggle:hover { color: #dbe3fa; border-color: rgba(129, 140, 248, 0.5); }
.more-toggle-caret { font-size: 11px; transition: transform 0.16s ease; }
.more-toggle[aria-expanded="true"] .more-toggle-caret { transform: rotate(90deg); }
.more-panels {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 0 0 auto;
}

/* 空态 */
.progress-empty {
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
  padding: 4px 0 2px;
}
.progress-empty-text { margin: 0; font-size: 12px; color: var(--muted); }
.progress-empty-note { margin: 0; font-size: 11px; line-height: 1.65; color: var(--muted-2); }
.search-empty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px dashed rgba(148, 163, 184, 0.28);
  background: rgba(15, 23, 42, 0.45);
}
.search-empty-text { margin: 0; font-size: 11.5px; color: var(--muted); }

/* 空星系：进度看板隐藏常规内容，仅显示空态 */
#progress-panel .progress-empty { display: none; }
#progress-panel.is-empty .progress-empty { display: flex; }
#progress-panel.is-empty .progress-wrap,
#progress-panel.is-empty #chapter-progress,
#progress-panel.is-empty #group-chips,
#progress-panel.is-empty .panel-desc { display: none; }

/* 不可用按钮置灰（禁用态统一降透明度 + 禁用光标） */
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* 窄屏抽屉按钮：默认隐藏，<1024 显示 */
.panel-toggle-btn { display: none; }

.panel-block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  backdrop-filter: blur(8px);
  flex: 0 0 auto;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.panel-title {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #d7e0f5;
}
.panel-desc {
  margin: 0 0 10px;
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--muted);
}
.panel-desc.small { font-size: 11px; line-height: 1.65; color: var(--muted-2); margin-bottom: 0; }

.kv {
  margin: 12px 0 0;
  padding: 10px 0 0;
  border-top: 1px dashed rgba(99, 102, 241, 0.16);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kv-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kv-row dt { font-size: 11px; color: var(--muted-2); }
.kv-row dd {
  margin: 0;
  font-size: 11px;
  color: #cbd5ec;
  font-family: var(--mono);
  word-break: break-all;
  text-align: right;
}

.panel-boundary { border-color: rgba(245, 158, 11, 0.22); background: linear-gradient(180deg, rgba(28, 20, 10, 0.5), rgba(11, 18, 32, 0.82)); }
.boundary-list {
  margin: 0;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  line-height: 1.65;
  color: #c8b995;
}
.boundary-list li::marker { color: rgba(251, 191, 36, 0.7); }

.placeholder-grid { display: grid; gap: 8px; }
.placeholder-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px dashed rgba(148, 163, 184, 0.28);
  background: rgba(15, 23, 42, 0.45);
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}
.placeholder-card:hover { border-color: rgba(99, 102, 241, 0.5); background: rgba(99, 102, 241, 0.08); color: #cbd5ec; }
.placeholder-name { font-weight: 500; }
.placeholder-stage { font-size: 10px; color: var(--muted-2); font-family: var(--mono); }
.panel-debug-entry code {
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.14);
  border: 1px solid rgba(99, 102, 241, 0.24);
  font-family: var(--mono);
  font-size: 10.5px;
  color: #c7d2fe;
}

/* ------------------------- 三维画布 ------------------------- */

.stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    radial-gradient(ellipse at 50% 42%, #0d1830 0%, #070c18 55%, #04060d 100%);
  box-shadow: inset 0 0 90px rgba(2, 4, 10, 0.85), 0 18px 50px rgba(0, 0, 0, 0.35);
}
.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 140px rgba(3, 5, 12, 0.9);
  z-index: 2;
}
.scene-container { position: absolute; inset: 0; z-index: 1; }
.scene-container canvas { display: block; width: 100%; height: 100%; outline: none; }

.label-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 3;
}
.node-label {
  position: absolute;
  left: 0;
  top: 0;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  line-height: 1.4;
  color: #cbd7f0;
  background: rgba(5, 9, 18, 0.58);
  border: 1px solid rgba(99, 102, 241, 0.3);
  backdrop-filter: blur(3px);
  white-space: nowrap;
  opacity: 0;
  will-change: transform;
  transition: opacity 0.18s ease, background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}
.node-label.is-hovered {
  opacity: 1 !important;
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent-soft);
}

.stage-tip {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 11px;
  color: var(--muted);
  background: rgba(7, 11, 21, 0.72);
  border: 1px solid var(--accent-border);
  backdrop-filter: blur(8px);
  pointer-events: none;
}
.stage-tip .sep { color: rgba(148, 163, 184, 0.4); }

.stage-meta {
  position: absolute;
  right: 16px;
  top: 16px;
  z-index: 4;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 10.5px;
  color: var(--muted-2);
  background: rgba(7, 11, 21, 0.66);
  border: 1px solid rgba(148, 163, 184, 0.16);
  backdrop-filter: blur(8px);
  pointer-events: none;
}

.scene-fallback {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(ellipse at center, rgba(10, 16, 32, 0.92), rgba(4, 6, 13, 0.98));
}
.scene-fallback-card {
  max-width: 440px;
  text-align: center;
  padding: 24px;
  border-radius: 16px;
  border: 1px solid rgba(248, 113, 113, 0.28);
  background: rgba(24, 12, 16, 0.5);
}
.scene-fallback-card h3 { margin: 0 0 8px; font-size: 15px; color: #fecaca; }
.scene-fallback-card p { margin: 0 0 6px; font-size: 12px; line-height: 1.7; color: var(--muted); }
.scene-fallback-card p.small { font-size: 11px; color: var(--muted-2); }

/* ------------------------- 右下角状态区 ------------------------- */

.status-dock {
  position: fixed;
  right: 18px;
  bottom: 18px;
  /* 高于弹窗遮罩(70)，保证闯关回落等 toast 可见；仍低于加载层(110)与致命错误层(120) */
  z-index: 95;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  max-width: min(420px, calc(100vw - 36px));
  pointer-events: none;
}
.toast-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
  pointer-events: auto;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: max-content;
  max-width: 360px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  background: rgba(9, 14, 26, 0.95);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5);
  font-size: 12px;
  line-height: 1.55;
  color: var(--text);
  animation: toast-in 0.22s ease both;
}
.toast--success { border-left-color: var(--success); }
.toast--warn { border-left-color: var(--warn); }
.toast--error { border-left-color: var(--danger); }
.toast-body { flex: 1 1 auto; word-break: break-word; }
.toast-close {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--muted-2);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.toast-close:hover { color: var(--text); background: rgba(148, 163, 184, 0.14); }

.status-line {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(9, 14, 26, 0.9);
  backdrop-filter: blur(10px);
  font-size: 10.5px;
  color: var(--muted-2);
  pointer-events: auto;
  white-space: nowrap;
}
.status-line b { color: #cbd5ec; font-weight: 600; font-variant-numeric: tabular-nums; }
.status-flag { display: inline-flex; align-items: center; gap: 6px; color: var(--success); font-weight: 500; }
.status-flag.is-bad { color: var(--danger); }
.status-item { color: var(--muted-2); }
.status-item b { color: #cbd5ec; }
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
  animation: dot-pulse 2.4s ease-in-out infinite;
}

/* ------------------------- 弹窗 ------------------------- */

body.modal-open { overflow: hidden; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(3, 6, 14, 0.74);
  backdrop-filter: blur(6px);
  animation: fade-in 0.18s ease both;
}
.modal-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  max-height: 84vh;
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #0c1526, #080d18);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.65);
  animation: modal-in 0.24s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.modal-card--wide { max-width: 720px; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.modal-title { margin: 0; font-size: 15px; font-weight: 600; color: #eef2ff; }
.modal-body {
  padding: 18px;
  overflow-y: auto;
  /* 阶段七 B4：窄屏下禁止弹窗出现横向滚动条 */
  overflow-x: hidden;
  font-size: 12.5px;
  line-height: 1.75;
  color: #cbd5ec;
  flex: 1 1 auto;
}
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 13px 18px;
  border-top: 1px solid var(--line);
  background: rgba(8, 12, 22, 0.6);
  flex: 0 0 auto;
}

.guide-lead { margin: 0 0 14px; color: #cbd5ec; }
.guide-steps { margin: 0 0 16px; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.guide-steps li {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(99, 102, 241, 0.16);
  background: rgba(99, 102, 241, 0.05);
  font-size: 12px;
  line-height: 1.65;
}
.guide-step-index {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.22);
  border: 1px solid rgba(129, 140, 248, 0.4);
  color: #c7d2fe;
  font-size: 10.5px;
  font-family: var(--mono);
}
.guide-steps b { color: #eef2ff; font-weight: 600; }
.guide-note {
  padding: 10px 12px;
  border-radius: 10px;
  border-left: 3px solid var(--warn);
  background: rgba(245, 158, 11, 0.08);
  font-size: 11px;
  line-height: 1.7;
  color: #e7d6ae;
}

.detail-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.detail-section-title {
  margin: 20px 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted-2);
}
/* 阶段七 B1：概述限制阅读宽度、加大行高，长文本不糊成一片 */
.detail-text { margin: 0; color: #cbd5ec; line-height: 1.85; max-width: 64ch; overflow-wrap: anywhere; }
/* 阶段七 B1：关键要点改为有序列表（1. 2. 3.），行距与分区间距统一 */
.detail-list { margin: 0; padding-left: 20px; display: block; list-style: decimal; color: #cbd5ec; line-height: 1.75; }
.detail-list li { margin-bottom: 4px; }
.detail-list li::marker { color: rgba(34, 211, 238, 0.65); font-family: var(--mono); }
/* 阶段七 B1：公式区块浅色底 + 居中展示 */
.formula-box {
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--accent-border);
  background: var(--accent-chip-bg);
  color: #e2e8f5;
  overflow-x: auto;
  text-align: center;
  font-size: 14px;
}
.formula-box .katex-display { margin: 0; }
.formula-note { margin: 8px 0 0; font-size: 10px; color: var(--muted-2); text-align: center; }
.detail-related { display: flex; flex-wrap: wrap; gap: 6px; }
/* 阶段七 B3：关联节点 chip 可点击 */
.chip-link {
  cursor: pointer;
  font-family: inherit;
  white-space: normal;
  text-align: left;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.chip-link:hover { color: #dbe3fa; border-color: rgba(129, 140, 248, 0.6); background: rgba(99, 102, 241, 0.18); }
/* 阶段七 B4：回溯按钮下方辅助说明 */
.detail-foot-path { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.detail-foot-hint { font-size: 10px; line-height: 1.2; color: var(--muted-2); }
.boundary-note {
  margin-top: 18px;
  padding: 10px 12px;
  border-radius: 10px;
  border-left: 3px solid var(--warn);
  background: rgba(245, 158, 11, 0.07);
  font-size: 10.5px;
  line-height: 1.7;
  color: #dcc9a0;
}

/* ------------------------- 自检面板 ------------------------- */

.debug-panel {
  position: fixed;
  top: 78px;
  right: 18px;
  z-index: 50;
  width: 340px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--line-strong);
  background: rgba(8, 13, 24, 0.97);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.6);
  font-size: 11.5px;
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.3) transparent;
}
.debug-panel::-webkit-scrollbar { width: 6px; }
.debug-panel::-webkit-scrollbar-thumb { background: rgba(99, 102, 241, 0.3); border-radius: 999px; }
.debug-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 12.5px;
  color: #dbe4f7;
}
.debug-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 12px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(99, 102, 241, 0.14);
  background: rgba(2, 6, 14, 0.5);
}
.debug-grid > div { min-width: 0; }
.debug-grid dt { font-size: 10px; color: var(--muted-2); margin-bottom: 2px; }
.debug-grid dd {
  margin: 0;
  font-size: 10.5px;
  font-family: var(--mono);
  color: #cbd5ec;
  word-break: break-all;
}
.debug-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.test-output {
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(99, 102, 241, 0.14);
  background: #04070e;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.65;
  color: var(--muted);
  max-height: 260px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.test-summary {
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px dashed rgba(148, 163, 184, 0.2);
  font-weight: 600;
}
.test-summary.is-pass { color: var(--success); }
.test-summary.is-fail { color: var(--danger); }
.test-row { display: flex; gap: 8px; padding: 2px 0; align-items: baseline; }
.test-row.is-pass .test-name { color: #86efac; }
.test-row.is-fail .test-name { color: #fca5a5; }
.test-name { flex: 1 1 auto; }
.test-info {
  flex: 0 0 auto;
  max-width: 58%;
  color: var(--muted-2);
  font-size: 9.5px;
  text-align: right;
  white-space: normal;
  word-break: break-word;
}

/* ------------------------- 气泡提示 ------------------------- */

.tooltip {
  position: fixed;
  z-index: 90;
  max-width: 260px;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid rgba(99, 102, 241, 0.35);
  background: rgba(8, 13, 24, 0.97);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55);
  font-size: 11px;
  line-height: 1.6;
  color: #cbd5ec;
  pointer-events: none;
  animation: fade-in 0.14s ease both;
}

/* ------------------------- 致命错误层 ------------------------- */

.fatal-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 4, 10, 0.96);
}
.fatal-card {
  width: 100%;
  max-width: 560px;
  padding: 26px;
  border-radius: 18px;
  border: 1px solid rgba(248, 113, 113, 0.35);
  background: #0b0f1a;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.fatal-card h2 { margin: 0 0 10px; font-size: 18px; color: #fecaca; }
.fatal-card p { margin: 0 0 12px; font-size: 12.5px; line-height: 1.7; color: var(--muted); }
.fatal-detail {
  max-height: 180px;
  overflow: auto;
  margin: 0 0 16px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: #04070e;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.6;
  color: #fca5a5;
  white-space: pre-wrap;
  word-break: break-word;
}

/* =========================================================
   阶段二：星系档案馆 / 进度看板 / 档案弹窗
   ========================================================= */

/* ---------- 档案馆面板 ---------- */

.galaxy-select {
  width: 100%;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid rgba(99, 102, 241, 0.3);
  background: rgba(8, 13, 24, 0.85);
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  margin-bottom: 10px;
}
.galaxy-select:focus { border-color: rgba(129, 140, 248, 0.7); }
.galaxy-select:disabled { opacity: 0.55; cursor: not-allowed; }
.galaxy-select option { background: #0b1220; color: var(--text); }

.btn-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}

.btn-danger {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.4);
  color: #fca5a5;
}
.btn-danger:hover { background: rgba(248, 113, 113, 0.22); border-color: rgba(248, 113, 113, 0.65); }
.btn-danger:disabled { opacity: 0.45; cursor: not-allowed; }

.corrupt-entry { justify-content: center; gap: 8px; }
.corrupt-entry .chip { margin-left: 4px; }

/* ---------- 进度环形看板 ---------- */

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 4px 0 10px;
}
.ring-box {
  position: relative;
  width: 96px;
  height: 96px;
  flex: 0 0 auto;
}
.ring-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track {
  fill: none;
  stroke: rgba(99, 102, 241, 0.14);
  stroke-width: 9;
}
.ring-fill {
  fill: none;
  stroke: #34d399;
  stroke-width: 9;
  stroke-linecap: round;
  stroke-dasharray: 263.89;   /* 2π × 42 */
  stroke-dashoffset: 263.89;
  transition: stroke-dashoffset 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
}
.ring-percent {
  font-size: 19px;
  font-weight: 700;
  color: #d1fae5;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.ring-label { font-size: 9.5px; color: var(--muted-2); letter-spacing: 0.08em; }

.progress-legend {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1 1 auto;
  min-width: 0;
}
.legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 9px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(148, 163, 184, 0.1);
}
.legend-row dt { font-size: 10.5px; color: var(--muted-2); }
.legend-row dd {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: #cbd5ec;
}
.legend-master { border-left: 3px solid var(--success); }
.legend-master dd { color: #86efac; }
.legend-consolidate { border-left: 3px solid var(--warn); }
.legend-consolidate dd { color: #fde68a; }
.legend-notmaster { border-left: 3px solid rgba(148, 163, 184, 0.5); }

/* ---------- 分组标签条 ---------- */

.group-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
  min-height: 24px;
}
.group-chip-empty { font-size: 10.5px; color: var(--muted-2); line-height: 24px; }
.group-chip {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(15, 23, 42, 0.55);
  color: var(--muted);
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.group-chip:hover { border-color: rgba(129, 140, 248, 0.6); color: #dbe3fa; }
.group-chip.is-active {
  border-color: rgba(99, 102, 241, 0.45);
  background: rgba(99, 102, 241, 0.12);
  color: #c7d2fe;
}
.group-chip.is-hidden {
  border-color: rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.1);
  color: #fca5a5;
  text-decoration: line-through;
}

/* ---------- 阶段五：章节掌握度（迷你进度条） ---------- */

.chapter-progress {
  margin: 0 0 10px;
  padding-top: 8px;
  border-top: 1px dashed rgba(99, 102, 241, 0.16);
}
.chapter-progress-title {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 168px;       /* 章节较多时内部滚动，不撑破面板 */
  overflow-y: auto;
  padding-right: 2px;
}
.chapter-list::-webkit-scrollbar { width: 5px; }
.chapter-list::-webkit-scrollbar-thumb { background: rgba(99, 102, 241, 0.3); border-radius: 999px; }
.chapter-row { display: flex; flex-direction: column; gap: 3px; }
.chapter-row-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chapter-name {
  font-size: 10.5px;
  color: #cbd5ec;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chapter-count {
  flex: 0 0 auto;
  font-size: 10px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--muted-2);
}
.chapter-bar {
  height: 5px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.14);
  overflow: hidden;
}
.chapter-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--success), var(--accent-2));
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- 阶段五：复习顺序弹窗 ---------- */

.review-order-warn {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 11.5px;
  line-height: 1.6;
  color: #fca5a5;
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.32);
}
.review-order-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: min(52vh, 420px);
  overflow-y: auto;
}
.review-order-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.12);
}
.review-order-index {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 10.5px;
  font-family: var(--mono);
  color: #c7d2fe;
  background: rgba(99, 102, 241, 0.16);
  border: 1px solid rgba(99, 102, 241, 0.3);
}
.review-order-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  color: #e2e8f8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 档案弹窗补充 ---------- */

.modal-lead { margin: 0 0 12px; font-size: 12.5px; line-height: 1.75; color: #cbd5ec; }
.modal-lead b { color: #fde68a; }

.copy-rules {
  margin: 0 0 12px;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--muted);
}
.copy-rules li::marker { color: rgba(129, 140, 248, 0.7); }
.copy-rules.danger li::marker { color: rgba(248, 113, 113, 0.7); }

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  color: var(--muted-2);
}
.text-input {
  width: 100%;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid rgba(99, 102, 241, 0.3);
  background: rgba(8, 13, 24, 0.85);
  color: var(--text);
  font-size: 12.5px;
  font-family: inherit;
  outline: none;
}
.text-input:focus { border-color: rgba(129, 140, 248, 0.75); box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15); }

.file-input {
  width: 100%;
  padding: 8px;
  border-radius: 10px;
  border: 1px dashed rgba(99, 102, 241, 0.4);
  background: rgba(8, 13, 24, 0.6);
  color: var(--muted);
  font-size: 11.5px;
}
.file-input::file-selector-button {
  margin-right: 10px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(129, 140, 248, 0.5);
  background: rgba(99, 102, 241, 0.16);
  color: #c7d2fe;
  font-size: 11px;
  cursor: pointer;
}

.backup-list, .corrupt-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 2px;
}
.backup-empty { margin: 0; font-size: 11.5px; color: var(--muted-2); line-height: 1.7; }
.backup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 11px;
  border-radius: 9px;
  border: 1px solid rgba(99, 102, 241, 0.18);
  background: rgba(15, 23, 42, 0.5);
  font-size: 11px;
}
.backup-label { color: #cbd5ec; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.backup-meta { flex: 0 0 auto; color: var(--muted-2); font-family: var(--mono); font-size: 10px; }

.corrupt-row {
  padding: 10px 11px;
  border-radius: 9px;
  border: 1px solid rgba(248, 113, 113, 0.25);
  background: rgba(30, 12, 16, 0.4);
  font-size: 11px;
}
.corrupt-reason { color: #fca5a5; line-height: 1.6; margin-bottom: 6px; word-break: break-word; }
.corrupt-snippet {
  margin: 0 0 8px;
  padding: 7px 9px;
  border-radius: 7px;
  background: #04070e;
  border: 1px solid rgba(148, 163, 184, 0.14);
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 9.5px;
  line-height: 1.55;
  max-height: 72px;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-all;
}
.corrupt-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.corrupt-time { color: var(--muted-2); font-family: var(--mono); font-size: 10px; }

/* ------------------------- 动效 ------------------------- */

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes dot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ------------------------- 响应式（移动端适配为预留方向，此处仅保证不破版） ------------------------- */

@media (max-width: 1280px) {
  .workspace { grid-template-columns: 300px minmax(0, 1fr); }
  .toast { max-width: 320px; }
}

@media (max-width: 1024px) {
  /* 阶段九 IA：窄屏下左栏折叠为抽屉（默认收起），把画布还给三维视图 */
  .panel-toggle-btn { display: inline-flex; }
  .brand-sub { display: none; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .panel-left {
    position: fixed;
    top: 64px;
    left: 0;
    bottom: 0;
    width: 300px;
    max-width: 86vw;
    z-index: 45;
    transform: translateX(-105%);
    transition: transform 0.24s ease;
    background: var(--panel-solid);
    padding: 12px;
    box-shadow: 0 0 0 rgba(0, 0, 0, 0);
  }
  .panel-left.is-open {
    transform: translateX(0);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  }
  .status-dock { right: 10px; bottom: 10px; }
  .status-line { gap: 9px; padding: 6px 11px; font-size: 10px; }
  .debug-panel { top: 12px; right: 12px; left: 12px; width: auto; max-height: 70vh; }
  .stage-tip { left: 10px; bottom: 10px; font-size: 10px; }
  .stage-meta { right: 10px; top: 10px; }
}

@media (max-width: 560px) {
  .topbar-actions { width: 100%; }
  .topbar-actions .btn { flex: 1 1 0; padding: 8px 8px; font-size: 11px; }
  .brand-title { font-size: 14px; }
  .status-item:nth-of-type(3) { display: none; }
  .modal-card { max-height: 88vh; }
  /* 阶段七 B4：窄屏下详情底部按钮换行，公式块不产生横向滚动条 */
  .modal-foot { flex-wrap: wrap; gap: 8px; }
  .modal-foot .btn { flex: 1 1 auto; }
  .detail-foot-path { flex: 1 1 100%; }
  .detail-text { max-width: 100%; }
  .formula-box { overflow-x: hidden; }
}

/* =========================================================
   阶段三：手动编辑面板 / 编辑弹窗 / 公式预览 / 依赖关系
   ========================================================= */

/* ---------- 常驻编辑面板（左栏） ---------- */
.edit-grid { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.edit-row { display: flex; gap: 8px; }
.edit-col { flex: 1 1 auto; min-width: 0; }
.edit-col--narrow { flex: 0 0 104px; }
.text-area {
  width: 100%;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid rgba(99, 102, 241, 0.3);
  background: rgba(8, 13, 24, 0.85);
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  outline: none;
}
.text-area:focus { border-color: rgba(129, 140, 248, 0.75); box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15); }
.char-counter {
  text-align: right;
  font-size: 10px;
  color: var(--muted-2);
  font-family: var(--mono);
  margin-top: 3px;
}
.boundary-note--flat { margin-top: 0; }

/* ---------- 三维标签状态配色（与掌握进度图例一致） ---------- */
.node-label.st-master { border-color: rgba(52, 211, 153, 0.6); color: #a7f3d0; }
.node-label.st-consolidate { border-color: rgba(251, 191, 36, 0.6); color: #fde68a; }
.node-label.st-not_master { border-color: rgba(148, 163, 184, 0.4); }

/* ---------- 编辑弹窗：掌握状态选择 ---------- */
.status-pills { display: flex; gap: 6px; margin-bottom: 4px; }
.status-pill {
  flex: 1 1 0;
  padding: 8px 6px;
  border-radius: 9px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(8, 13, 24, 0.6);
  color: var(--muted);
  font-size: 11.5px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.status-pill.st-master.is-active {
  border-color: rgba(52, 211, 153, 0.65);
  background: rgba(16, 185, 129, 0.14);
  color: #6ee7b7;
}
.status-pill.st-consolidate.is-active {
  border-color: rgba(251, 191, 36, 0.65);
  background: rgba(245, 158, 11, 0.14);
  color: #fde68a;
}
.status-pill.st-not_master.is-active {
  border-color: rgba(148, 163, 184, 0.6);
  background: rgba(148, 163, 184, 0.12);
  color: #cbd5ec;
}

/* ---------- 编辑弹窗：依赖关系编辑 ---------- */
.relation-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; max-height: 150px; overflow-y: auto; }
.relation-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid rgba(99, 102, 241, 0.22);
  background: rgba(15, 23, 42, 0.5);
  font-size: 11.5px;
}
.relation-name { color: #cbd5ec; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.relation-empty { font-size: 11px; color: var(--muted-2); line-height: 1.7; }
.relation-edit-row { display: flex; gap: 8px; align-items: stretch; }
.relation-edit-row select { flex: 1 1 auto; min-width: 0; }

/* ---------- LaTeX 模板条与实时预览 ---------- */
.template-bar { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 8px; }
.template-btn {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(34, 211, 238, 0.32);
  background: rgba(34, 211, 238, 0.08);
  color: #a5f3fc;
  font-size: 10.5px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.template-btn:hover { background: rgba(34, 211, 238, 0.18); border-color: rgba(34, 211, 238, 0.55); }
.latex-preview {
  min-height: 52px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(34, 211, 238, 0.2);
  background: rgba(6, 16, 24, 0.6);
  color: #e2e8f5;
  overflow-x: auto;
  font-size: 14px;
}
.latex-preview .katex-display { margin: 0; }
.latex-preview--empty { color: var(--muted-2); font-size: 11.5px; }
.latex-error {
  margin-top: 6px;
  font-size: 10.5px;
  color: #fca5a5;
  line-height: 1.6;
}
.latex-input { font-family: var(--mono); font-size: 11.5px; }

/* ---------- 编辑弹窗布局 ---------- */
.edit-section { margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(99, 102, 241, 0.16); }
.edit-section:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.edit-section-title {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted-2);
}

/* =========================================================
   阶段四：智能萃取 · 独立预览缓冲区
   ========================================================= */

/* 特殊符号风险告警（标红，不阻断） */
.risk-warning {
  margin: 6px 0 8px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.1);
  color: #fca5a5;
  font-size: 10.5px;
  line-height: 1.6;
}

/* 预览缓冲区容器 */
.extract-preview {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 预览头部：统计 + 操作 */
.extract-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(99, 102, 241, 0.22);
  background: rgba(15, 23, 42, 0.5);
}
.extract-head-info { font-size: 11px; color: #cbd5ec; }
.extract-head-actions { display: flex; gap: 6px; }

/* 候选卡片列表 */
.extract-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.3) transparent;
}
.extract-list::-webkit-scrollbar { width: 5px; }
.extract-list::-webkit-scrollbar-thumb { background: rgba(99, 102, 241, 0.3); border-radius: 999px; }

.extract-card {
  padding: 10px 11px;
  border-radius: 10px;
  border: 1px solid rgba(99, 102, 241, 0.18);
  background: rgba(15, 23, 42, 0.5);
  font-size: 11.5px;
}
.extract-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}
.extract-card-name {
  color: #e6ecff;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.extract-card-tag {
  flex: 0 0 auto;
  font-size: 10px;
  color: #a5f3fc;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(34, 211, 238, 0.1);
  border: 1px solid rgba(34, 211, 238, 0.28);
}
.extract-card-snippet {
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.6;
  margin-bottom: 7px;
  word-break: break-word;
}
.extract-card-foot { display: flex; align-items: center; gap: 8px; }
.extract-card-rel { flex: 1 1 auto; font-size: 10px; color: var(--muted-2); }

/* =========================================================
   阶段五：主题彩蛋 / 发布模式 / 原始数据结构查看
   ========================================================= */

/* 调试入口默认隐藏，仅 ?debug=1（body.debug-enabled）时显示 */
.debug-entry { display: none !important; }
body.debug-enabled #btn-debug { display: inline-flex !important; }
body.debug-enabled .panel-debug-entry { display: block !important; }

/* 发布 / 演示模式：无论是否开启调试入口，都隐藏调试入口与「后续规划」 */
body.publish-mode #btn-debug { display: none !important; }
body.publish-mode .panel-debug-entry { display: none !important; }
body.publish-mode .future-plan { display: none !important; }

/* 原始数据结构查看弹窗中的只读 JSON 展示区 */
.raw-data-pre {
  max-height: 52vh;
  overflow: auto;
  margin: 0 0 12px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: #04070e;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.6;
  color: #a5b4fc;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 备份提示小字（档案馆面板） */
.backup-hint {
  margin-top: 8px;
  font-size: 10.5px;
  color: var(--muted-2);
  line-height: 1.6;
}

/* =========================================================
   阶段六：自测闯关（彩蛋占位模块 · 预置题目兜底）
   ========================================================= */

/* 弹窗顶部引导说明 */
.quiz-lead {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border-left: 3px solid var(--accent-2);
  background: rgba(34, 211, 238, 0.06);
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--muted);
}
.quiz-lead b { color: #a5f3fc; }

/* 题目列表与单题容器 */
.quiz-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.quiz-item {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(99, 102, 241, 0.16);
  background: rgba(15, 23, 42, 0.4);
}
.quiz-item-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}
.quiz-item-index {
  flex: 0 0 auto;
  font-size: 10.5px;
  font-family: var(--mono);
  color: var(--accent-soft);
  letter-spacing: 0.06em;
}
.quiz-item-text {
  font-size: 12.5px;
  line-height: 1.65;
  color: #e6ecff;
}

/* 选项按钮 */
.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.quiz-option {
  width: 100%;
  padding: 8px 11px;
  border-radius: 9px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(8, 13, 24, 0.55);
  color: #cbd5ec;
  font-size: 11.5px;
  line-height: 1.5;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
}
.quiz-option:hover:not(:disabled) {
  border-color: rgba(129, 140, 248, 0.6);
  background: rgba(99, 102, 241, 0.1);
}
.quiz-option:disabled { cursor: default; opacity: 1; }
.quiz-option.is-correct {
  border-color: rgba(52, 211, 153, 0.65);
  background: rgba(16, 185, 129, 0.14);
  color: #6ee7b7;
}
.quiz-option.is-wrong {
  border-color: rgba(248, 113, 113, 0.55);
  background: rgba(248, 113, 113, 0.12);
  color: #fca5a5;
}

/* 作答后的解析说明 */
.quiz-explanation {
  margin: 8px 0 0;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px dashed rgba(148, 163, 184, 0.2);
  background: rgba(2, 6, 14, 0.4);
  font-size: 10.5px;
  line-height: 1.6;
  color: var(--muted);
}

/* 最终得分汇总 */
.quiz-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 14px 0 4px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(8, 13, 24, 0.55);
  font-size: 12px;
}
.quiz-summary-score { font-weight: 600; color: #e6ecff; }
.quiz-summary.is-pass { border-color: rgba(52, 211, 153, 0.4); }
.quiz-summary.is-pass .quiz-summary-score { color: #6ee7b7; }
.quiz-summary.is-fail { border-color: rgba(251, 191, 36, 0.4); }
.quiz-summary.is-fail .quiz-summary-score { color: #fde68a; }
.quiz-summary-hint { font-size: 10.5px; color: var(--muted-2); }

/* 阶段八：答完后追加的成绩单（按考点聚合薄弱分析） */
.quiz-report {
  margin-top: 14px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(99, 102, 241, 0.24);
  background: rgba(8, 13, 24, 0.6);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.quiz-report-notice {
  margin: 0;
  font-size: 10.5px;
  line-height: 1.6;
  color: var(--muted-2);
}
.quiz-report-score {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: #e6ecff;
}
.quiz-report-verdict {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 10px;
  border-radius: 9px;
  border-left: 3px solid var(--accent-2);
  background: rgba(34, 211, 238, 0.06);
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--muted);
}
.quiz-report-verdict strong { font-size: 12px; color: #a5f3fc; }
.quiz-report-tags {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.quiz-tag-row { display: flex; flex-direction: column; gap: 4px; }
.quiz-tag-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #cbd5ec;
}
.quiz-tag-name { flex: 1 1 auto; }
.quiz-tag-weak {
  flex: 0 0 auto;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid rgba(251, 191, 36, 0.4);
  background: rgba(251, 191, 36, 0.12);
  color: #fde68a;
  font-size: 10px;
}
.quiz-tag-jump { flex: 0 0 auto; padding: 2px 8px; font-size: 10.5px; }
.quiz-tag-bar {
  height: 5px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
  overflow: hidden;
}
.quiz-tag-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(52, 211, 153, 0.75), rgba(52, 211, 153, 0.95));
}
.quiz-tag-fill.is-weak {
  background: linear-gradient(90deg, rgba(251, 191, 36, 0.7), rgba(251, 191, 36, 0.95));
}

/* =========================================================
   阶段四（闯关重构）：关卡式界面 / 逐题详解 / 答题报告
   ========================================================= */
.quiz-stage {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 顶部信息条：关卡进度 / 得分 / 连击 */
.quiz-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(99, 102, 241, 0.22);
  background: rgba(8, 13, 24, 0.6);
  font-size: 11.5px;
  color: var(--muted);
}
.quiz-hud-item { white-space: nowrap; }
.quiz-hud-progress { color: #a5f3fc; font-weight: 600; }
.quiz-hud-score { color: #e6ecff; font-weight: 600; }
.quiz-hud-streak { color: #fde68a; }

/* 单题卡片 */
.quiz-question-card { padding: 14px; }
.quiz-level {
  flex: 0 0 auto;
  margin-left: auto;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.26);
  background: rgba(148, 163, 184, 0.1);
  color: var(--muted-2);
  font-size: 10px;
}

/* 底部关卡导航 */
.quiz-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.quiz-nav .btn { min-width: 96px; }
.quiz-nav .btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

/* 逐题详解：对错都给，四块完整展示 */
.quiz-feedback-host { display: flex; flex-direction: column; gap: 8px; }
.quiz-feedback-verdict {
  padding: 8px 11px;
  border-radius: 9px;
  font-size: 11.5px;
  line-height: 1.6;
  font-weight: 600;
}
.quiz-feedback-verdict.is-pass {
  border: 1px solid rgba(52, 211, 153, 0.4);
  background: rgba(16, 185, 129, 0.12);
  color: #6ee7b7;
}
.quiz-feedback-verdict.is-fail {
  border: 1px solid rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.1);
  color: #fca5a5;
}
.quiz-feedback-block {
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px dashed rgba(148, 163, 184, 0.2);
  background: rgba(2, 6, 14, 0.4);
}
.quiz-feedback-title {
  margin: 0 0 4px;
  font-size: 10.5px;
  font-weight: 600;
  color: #a5f3fc;
  letter-spacing: 0.02em;
}
.quiz-feedback-text {
  margin: 0;
  font-size: 11px;
  line-height: 1.65;
  color: var(--muted);
}
.quiz-explain-list {
  margin: 0;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.quiz-explain-item {
  font-size: 10.8px;
  line-height: 1.6;
  color: var(--muted);
}

/* 关联知识点 chip */
.quiz-related {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 2px 2px 0;
}
.quiz-related-label { font-size: 10.5px; color: var(--muted-2); }
.quiz-related-chip {
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(34, 211, 238, 0.34);
  background: rgba(34, 211, 238, 0.1);
  color: #a5f3fc;
  font-size: 10.5px;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease;
}
.quiz-related-chip:hover {
  border-color: rgba(34, 211, 238, 0.65);
  background: rgba(34, 211, 238, 0.18);
}

/* 答题报告 */
.quiz-report-host:empty { display: none; }
.quiz-report {
  margin-top: 4px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(99, 102, 241, 0.24);
  background: rgba(8, 13, 24, 0.6);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.quiz-report-section { display: flex; flex-direction: column; gap: 8px; }
.quiz-report-title {
  margin: 0;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  font-size: 12px;
  font-weight: 600;
  color: #a5f3fc;
}
.quiz-report-rating {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
}
.quiz-report-rating.is-pass { color: #6ee7b7; }
.quiz-report-rating.is-fail { color: #fca5a5; }
.quiz-report-empty {
  margin: 0;
  font-size: 11px;
  color: var(--muted-2);
}
.quiz-tag-list { display: flex; flex-direction: column; gap: 8px; }
.quiz-tag-pct {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted-2);
}

/* 错题清单 */
.quiz-wrong-list { display: flex; flex-direction: column; gap: 7px; }
.quiz-wrong-item {
  border-radius: 9px;
  border: 1px solid rgba(248, 113, 113, 0.22);
  background: rgba(248, 113, 113, 0.05);
  overflow: hidden;
}
.quiz-wrong-item > summary {
  padding: 8px 10px;
  font-size: 10.8px;
  line-height: 1.6;
  color: #fca5a5;
  cursor: pointer;
  list-style: none;
}
.quiz-wrong-item > summary::-webkit-details-marker { display: none; }
.quiz-wrong-item > summary::before {
  content: '▸ ';
  color: var(--muted-2);
}
.quiz-wrong-item[open] > summary::before { content: '▾ '; }
.quiz-wrong-body {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 10px 10px;
  border-top: 1px dashed rgba(248, 113, 113, 0.2);
}
.quiz-wrong-choice,
.quiz-wrong-correct,
.quiz-wrong-reason {
  margin: 0;
  font-size: 10.8px;
  line-height: 1.6;
  color: var(--muted);
}
.quiz-wrong-correct { color: #6ee7b7; }
.quiz-wrong-reason { color: #fde68a; }

/* 复习建议与底部声明 */
.quiz-suggest-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.quiz-suggest-list li {
  font-size: 11px;
  line-height: 1.65;
  color: var(--muted);
}
.quiz-report-footer {
  margin: 0;
  padding-top: 8px;
  border-top: 1px solid rgba(148, 163, 184, 0.14);
  font-size: 10.5px;
  line-height: 1.6;
  color: var(--muted-2);
}

/* =========================================================
   体验收尾：首屏加载层（纯 CSS，无第三方依赖）
   - 层级低于致命错误层（120），高于弹窗（70）与气泡（90）
   - 初始化完成后由 main.js 直接移除，不参与后续布局
   ========================================================= */
.loading-layer {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 600px at 50% 35%, rgba(99, 102, 241, 0.16), transparent 65%),
    var(--bg);
}
.loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.loading-spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid rgba(99, 102, 241, 0.22);
  border-top-color: var(--accent-2);
  animation: loading-spin 0.9s linear infinite;
}
.loading-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #eef2ff;
}
.loading-text {
  font-size: 12px;
  color: var(--muted);
}
@keyframes loading-spin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .loading-spinner { animation-duration: 2.4s; }
}

/* =========================================================
   学习闭环：详情动作区 / 章节筛选 / 复习顺序聚焦 / 能力边界
   ========================================================= */

/* 详情弹窗底部动作区（练这一节 / 返回闯关，独立一行） */
.detail-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(99, 102, 241, 0.16);
}

/* 章节筛选条（点击章节行后出现） */
.chapter-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 10px 0 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(99, 102, 241, 0.32);
  background: rgba(99, 102, 241, 0.1);
}
.chapter-filter-text {
  font-size: 11.5px;
  color: #c7d2fe;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chapter-filter-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
}

/* 章节行 / 复习顺序行可点击 */
.chapter-row { cursor: pointer; border-radius: 8px; padding: 4px; transition: background 0.15s ease; }
.chapter-row:hover { background: rgba(99, 102, 241, 0.08); }
.review-order-row { cursor: pointer; transition: border-color 0.15s ease, background 0.15s ease; }
.review-order-row:hover { border-color: rgba(99, 102, 241, 0.5); background: rgba(99, 102, 241, 0.08); }
.review-order-count {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: #e2e8f8;
}
.review-order-hint {
  flex: 0 0 auto;
  font-size: 10px;
  color: var(--muted-2);
}

/* 错题清单「去看这个知识点」按钮 */
.quiz-wrong-goto { margin-top: 8px; }

/* 能力边界：能做什么 / 做不到什么 / 为什么 三块结构 */
.boundary-blocks {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.boundary-block-title {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #c7d2fe;
}
.quiz-lead--warn { color: var(--warn); font-weight: 600; }
