/* ==========================================================================
   CPU-349 考研英语模块 · 易混词思维导图系统样式 (Zen Master v5.0)
   - 与 reading.html / essay.html 保持全站统一架构（App-Container + Sidebar）
   - 单字母聚焦导图渲染 (Letter A-Z 分离精读)
   - 默认遮挡汉语自测 (Active Recall) + 悬停即刻透视
   - 第四层级详情节点向右自然伸展 (无纵向抖动)
   - 完美适配自然米白与沉浸暗黑主题
   ========================================================================== */

:root {
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --border-color: #e2e8f0;
  --border-hover: #cbd5e1;
  --primary-color: #2563eb;
  --primary-light: #eff6ff;
  --primary-dark: #1d4ed8;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --accent-orange: #ea580c;
  --accent-orange-light: #fff7ed;
  --accent-green: #059669;
  --accent-green-light: #ecfdf5;
  --font-serif: "Lora", "Georgia", "Cambria", "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

/* 1. 侧边栏字母列表项样式微调 */
.chapter-item[data-letter] {
  cursor: pointer;
  user-select: none;
}

.chapter-item[data-letter] .chapter-index-num {
  min-width: 24px;
  font-family: var(--font-serif);
  font-weight: 800;
  font-size: 0.95rem;
}

.chapter-badge-count {
  font-size: 10.5px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.05);
  color: #64748b;
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: auto;
  flex-shrink: 0;
}

.chapter-item.active .chapter-badge-count {
  background: rgba(45, 90, 39, 0.12);
  color: var(--primary-color, #2D5A27);
}

body.dark-theme .chapter-badge-count {
  background: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
}

body.dark-theme .chapter-item.active .chapter-badge-count {
  background: rgba(134, 239, 172, 0.15);
  color: #86efac;
}

/* 3. 主画布舞台 (与 main-content 完美填充) */
.mm-canvas-stage {
  flex: 1 1 0%;
  min-height: 0;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  background-color: var(--bg-color, #F7F9F6);
  background-image: radial-gradient(#cbd5e1 1.2px, transparent 1.2px);
  background-size: 26px 26px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

body.dark-theme .mm-canvas-stage {
  background-color: #0b1120;
  background-image: radial-gradient(#334155 1.2px, transparent 1.2px);
}

.mm-svg-canvas {
  width: 100%;
  height: 100%;
  cursor: grab;
  display: block;
  touch-action: none;
  pointer-events: auto;
}

.mm-svg-canvas:active,
.mm-canvas-stage.is-panning .mm-svg-canvas {
  cursor: grabbing;
}

/* 4. 导图节点外观 (SVG foreignObject 容器) */
foreignObject.node-fo {
  overflow: visible;
}

/* 根节点 (Level 0: 字母总枢纽) */
.hub-card {
  background: #ffffff;
  border: 2px solid var(--primary-color, #2563eb);
  border-radius: 12px;
  padding: 10px 14px;
  height: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.12);
  user-select: none;
  white-space: nowrap;
  transition: all 0.2s ease;
}

body.dark-theme .hub-card {
  background: #1e293b;
  border-color: #3b82f6;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* 关系组分类节点 (Cluster Hub - 第二层级) */
.cluster-card {
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  padding: 8px 12px;
  height: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.04);
  transition: all 0.15s ease;
  user-select: none;
  overflow: hidden;
}

.cluster-card:hover {
  border-color: #94a3b8;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

body.dark-theme .cluster-card {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.2);
}

body.dark-theme .cluster-card:hover {
  border-color: #475569;
}

.cluster-title {
  font-size: 13px;
  font-weight: 800;
  color: #1e293b;
  font-family: var(--font-serif);
  line-height: 1.35;
  word-break: break-word;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

body.dark-theme .cluster-title {
  color: #f1f5f9;
}

.cluster-relation {
  font-size: 11px;
  color: #64748b;
  margin-top: 3px;
  line-height: 1.3;
  word-break: break-word;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.dark-theme .cluster-relation {
  color: #94a3b8;
}

/* 单词节点：极简纯粹态 (第三层级) */
.word-node-card {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 9px;
  padding: 7px 11px;
  height: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.04);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  position: static;
  user-select: none;
  overflow: hidden;
}

.word-node-card:hover {
  border-color: #3b82f6;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.12);
}

.word-node-card.active-branch {
  border-color: #cbd5e1;
  background: #ffffff;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.05);
}

body.dark-theme .word-node-card {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

body.dark-theme .word-node-card:hover {
  border-color: #60a5fa;
  box-shadow: 0 4px 14px rgba(96, 165, 250, 0.18);
}

body.dark-theme .word-node-card.active-branch {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.25);
}

/* 单词卡片内部排版 */
.word-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-shrink: 0;
}

.word-title-group {
  display: flex;
  align-items: baseline;
  gap: 5px;
  white-space: nowrap;
  flex-shrink: 0;
}

.word-text {
  font-family: var(--font-serif);
  font-size: 15.5px;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
}

body.dark-theme .word-text {
  color: #f8fafc;
}

.word-pos-badge {
  font-size: 10px;
  font-weight: 700;
  color: #2563eb;
  background: #eff6ff;
  padding: 1px 4px;
  border-radius: 3px;
  white-space: nowrap;
}

body.dark-theme .word-pos-badge {
  background: rgba(37, 99, 235, 0.25);
  color: #93c5fd;
}

.word-expand-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  transition: color 0.15s ease;
}

.word-node-card:hover .word-expand-indicator,
.word-node-card.active-branch .word-expand-indicator {
  color: #2563eb;
}

body.dark-theme .word-node-card:hover .word-expand-indicator,
body.dark-theme .word-node-card.active-branch .word-expand-indicator {
  color: #60a5fa;
}

.word-short-m {
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
  line-height: 1.35;
}

body.dark-theme .word-short-m {
  color: #cbd5e1;
}

/* 第四层级：考研真题考点与助记详情节点 (挂在单词右侧) */
.detail-node-card {
  background: #ffffff;
  border: 1.5px solid #bfdbfe;
  border-left: 3.5px solid var(--accent-orange, #ea580c);
  border-radius: 10px;
  padding: 9px 13px;
  height: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 5px;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.08);
  font-size: 11px;
  line-height: 1.35;
  animation: fadeInRight 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

@keyframes fadeInRight {
  from { opacity: 0; }
  to { opacity: 1; }
}

body.dark-theme .detail-node-card {
  background: #1e293b;
  border-color: #334155;
  border-left-color: #f97316;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.detail-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 4px;
  border-bottom: 1px dashed #e2e8f0;
  flex-shrink: 0;
}

body.dark-theme .detail-header-row {
  border-bottom-color: #334155;
}

.detail-word-title {
  font-family: var(--font-serif);
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
}

body.dark-theme .detail-word-title {
  color: #f8fafc;
}

.detail-word-phonetic {
  font-family: var(--font-serif);
  font-size: 11.5px;
  color: #64748b;
}

body.dark-theme .detail-word-phonetic {
  color: #94a3b8;
}

.detail-source-pill {
  font-size: 10px;
  font-weight: 700;
  color: #92400e;
  background: #fef3c7;
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

body.dark-theme .detail-source-pill {
  background: rgba(245, 158, 11, 0.2);
  color: #fde68a;
}

.word-sound-btn {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #2563eb;
  cursor: pointer;
  padding: 1px 5px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  font-size: 11px;
}

.word-sound-btn:hover {
  background: #dbeafe;
}

body.dark-theme .word-sound-btn {
  background: rgba(37, 99, 235, 0.2);
  border-color: #3b82f6;
  color: #93c5fd;
}

/* 核心辨析要点行 (从单词卡移入详情节点，凸显关键对比) */
.detail-diff-row {
  font-size: 11px;
  color: #9a3412;
  background: #fff7ed;
  border: 1px solid #ffedd5;
  border-radius: 4px;
  padding: 3px 6px;
  line-height: 1.35;
  word-break: break-word;
  flex-shrink: 0;
}

body.dark-theme .detail-diff-row {
  background: rgba(234, 88, 12, 0.16);
  border-color: rgba(234, 88, 12, 0.35);
  color: #fdba74;
}

.detail-mnemonic-row {
  font-size: 11px;
  color: #334155;
  background: #fffbeb;
  border: 1px solid #fef3c7;
  border-radius: 4px;
  padding: 3px 6px;
  line-height: 1.35;
  word-break: break-word;
  flex-shrink: 0;
}

body.dark-theme .detail-mnemonic-row {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.3);
  color: #fde68a;
}

.detail-collocation-row {
  font-size: 11px;
  color: #1e40af;
  background: #f0f9ff;
  border: 1px solid #e0f2fe;
  border-radius: 4px;
  padding: 3px 6px;
  line-height: 1.35;
  word-break: break-word;
  flex-shrink: 0;
}

body.dark-theme .detail-collocation-row {
  background: rgba(37, 99, 235, 0.15);
  border-color: rgba(37, 99, 235, 0.3);
  color: #bfdbfe;
}

.detail-exam-row {
  font-size: 10.5px;
  color: #451a03;
  background: #fafaf9;
  border: 1px solid #e7e5e4;
  border-radius: 4px;
  padding: 4px 6px;
  line-height: 1.35;
  word-break: break-word;
  overflow: hidden;
}

body.dark-theme .detail-exam-row {
  background: rgba(15, 23, 42, 0.6);
  border-color: #334155;
  color: #fde68a;
}

/* 5. 背诵遮罩模式 (Space) */
.blur-mode .maskable-meaning {
  filter: blur(5px);
  user-select: none;
  transition: filter 0.15s ease;
}

.blur-mode .word-node-card:hover .maskable-meaning,
.blur-mode .detail-node-card:hover .maskable-meaning {
  filter: none;
}

/* 6. 贝塞尔导图连线 */
.mm-tree-link {
  fill: none;
  stroke: #94a3b8;
  stroke-width: 1.8px;
  stroke-linecap: round;
  transition: stroke 0.2s ease;
}

body.dark-theme .mm-tree-link {
  stroke: #475569;
}

.mm-detail-link {
  fill: none;
  stroke: #2563eb;
  stroke-width: 1.6px;
  stroke-linecap: round;
  stroke-dasharray: 4, 3;
}

body.dark-theme .mm-detail-link {
  stroke: #60a5fa;
}

/* 6. 底部操作浮动条 (极简3个小圆钮，靠右放置，永远置顶可见且适配安全区) */
.mm-canvas-floater {
  position: fixed !important;
  bottom: max(20px, calc(env(safe-area-inset-bottom, 0px) + 16px)) !important;
  right: max(20px, calc(env(safe-area-inset-right, 0px) + 16px)) !important;
  left: auto !important;
  transform: none !important;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 999px;
  padding: 4px 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.06);
  z-index: 1000 !important;
  pointer-events: auto !important;
  touch-action: manipulation !important;
}

body.dark-theme .mm-canvas-floater {
  background: rgba(30, 41, 59, 0.94);
  border-color: #334155;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
}

.floater-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted, #64748b);
  cursor: pointer;
  transition: all 0.16s ease;
  user-select: none;
}

.floater-btn svg,
.floater-btn i {
  width: 15px;
  height: 15px;
}

.floater-btn:hover {
  background: #f1f5f9;
  color: var(--primary-color, #2D5A27);
  transform: scale(1.08);
}

.floater-btn.active {
  background: var(--primary-light, #eff6ff);
  color: #1d4ed8;
  border-color: #bfdbfe;
}

body.dark-theme .floater-btn {
  color: #94a3b8;
}

body.dark-theme .floater-btn:hover {
  background: #334155;
  color: #86efac;
}

body.dark-theme .floater-btn.active {
  background: rgba(37, 99, 235, 0.25);
  color: #93c5fd;
  border-color: rgba(147, 197, 253, 0.4);
}

/* 7. 响应式与移动端适配 */
@media (max-width: 768px) {
  .mm-canvas-floater {
    bottom: 16px;
    right: 16px;
    left: auto;
    transform: none;
    padding: 3px 5px;
    gap: 4px;
  }
  .floater-btn {
    width: 28px;
    height: 28px;
  }
  .floater-btn svg,
  .floater-btn i {
    width: 13.5px;
    height: 13.5px;
  }
}

/* 8. 药理学导图同款真·全屏沉浸模式 (Fullscreen Immersive Mode) */
body.fullscreen-mode-active .top-bar {
  display: none !important;
}

body.fullscreen-mode-active .sidebar.open {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  bottom: 0 !important;
  width: 288px !important;
  z-index: 1000002 !important;
  margin-left: 0 !important;
  transform: none !important;
  box-shadow: 4px 0 30px rgba(0, 0, 0, 0.28) !important;
}

body.fullscreen-mode-active .sidebar-overlay {
  display: none !important;
}

body.fullscreen-mode-active .sidebar-overlay.open {
  display: block !important;
  z-index: 1000001 !important;
}

body.fullscreen-mode-active .app-container {
  display: block !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  max-height: 100dvh !important;
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 0 !important;
  border: none !important;
  box-shadow: none !important;
  overflow: hidden !important;
}

body.fullscreen-mode-active .main-content {
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  max-height: 100dvh !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex !important;
  flex-direction: column !important;
}

body.fullscreen-mode-active .mm-canvas-stage {
  width: 100% !important;
  height: 100% !important;
  border-radius: 0 !important;
}

/* 9. 考点详情下方弹出抽屉 (Word Detail Bottom Sheet) */
.mm-word-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 10001;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.mm-word-drawer-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.mm-word-drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  max-height: 82vh;
  max-height: 82dvh;
  background: #ffffff;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 36px rgba(0, 0, 0, 0.16);
  z-index: 10002;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.mm-word-drawer.active {
  transform: translateY(0);
}

body.dark-theme .mm-word-drawer {
  background: #1e293b;
  border-top: 1px solid #334155;
  box-shadow: 0 -8px 36px rgba(0, 0, 0, 0.5);
}

.mm-drawer-handle-bar {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.15);
  margin: 10px auto 4px auto;
  flex-shrink: 0;
}

body.dark-theme .mm-drawer-handle-bar {
  background: rgba(255, 255, 255, 0.2);
}

.mm-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px 12px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
}

body.dark-theme .mm-drawer-header {
  border-bottom-color: #334155;
}

.mm-drawer-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mm-drawer-word {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  font-weight: 800;
  color: #0f172a;
}

body.dark-theme .mm-drawer-word {
  color: #f8fafc;
}

.mm-drawer-phonetic {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  color: #64748b;
}

body.dark-theme .mm-drawer-phonetic {
  color: #94a3b8;
}

.mm-drawer-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.05);
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

body.dark-theme .mm-drawer-close {
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
}

.mm-drawer-body {
  padding: 14px 18px max(24px, env(safe-area-inset-bottom, 24px));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

