:root {
  --bg-deep: #070b14;
  --bg-panel: #0e1628;
  --bg-card: #131e36;
  --bg-card-hover: #192847;
  --border-subtle: rgba(99, 179, 237, 0.18);
  --border-glow: rgba(56, 189, 248, 0.55);
  --text-main: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-cyan: #38bdf8;
  --accent-blue: #3b82f6;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-purple: #a855f7;
  --font-sans: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.45;
  user-select: none;
}

/* 顶部导航栏 */
.top-header {
  height: 62px;
  background: linear-gradient(90deg, #091122 0%, #101d38 55%, #0b1528 100%);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
  z-index: 20;
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.4);
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #ffffff;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.brand-sub {
  font-size: 11px;
  font-weight: 500;
  color: var(--accent-cyan);
  opacity: 0.9;
}

.fusion-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 3px;
}

.badge {
  font-size: 10.5px;
  padding: 1px 7px;
  border-radius: 999px;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.badge-tongjiang { background: rgba(59, 130, 246, 0.18); color: #93c5fd; }
.badge-sciencelab { background: rgba(16, 185, 129, 0.18); color: #6ee7b7; }
.badge-phet { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }
.badge-pep { background: rgba(168, 85, 247, 0.18); color: #d8b4fe; }
.badge-chem { background: rgba(244, 63, 94, 0.18); color: #fda4af; }
.badge-mathigon { background: rgba(14, 165, 233, 0.18); color: #7dd3fc; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat-pill {
  padding: 5px 12px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 12px;
}

.stat-pill strong {
  color: var(--accent-cyan);
  font-size: 14px;
}

.btn-export {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid rgba(56, 189, 248, 0.5);
  background: linear-gradient(135deg, #0284c7 0%, #1d4ed8 100%);
  color: #ffffff;
  font-weight: 600;
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.18s ease;
  box-shadow: 0 2px 12px rgba(2, 132, 199, 0.35);
}

.btn-export:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(56, 189, 248, 0.55);
  filter: brightness(1.08);
}

/* 三栏主工作台网格 */
.workbench-grid {
  display: grid;
  grid-template-columns: 300px 1fr 410px;
  height: calc(100vh - 62px);
  width: 100%;
  overflow: hidden;
}

/* 左侧栏 */
.left-sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.search-box-wrap {
  padding: 10px 12px 8px;
}

.search-input {
  width: 100%;
  padding: 8px 11px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: #080e1c;
  color: var(--text-main);
  font-size: 12.5px;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.18);
}

.subject-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.subject-tab {
  padding: 6px 4px;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.subject-tab:hover {
  background: var(--bg-card-hover);
  color: #ffffff;
}

.subject-tab.active {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #ffffff;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

.experiment-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

/* 章节与分类折叠手风琴分组 */
.chapter-group {
  margin-bottom: 8px;
}

.chapter-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  background: rgba(30, 41, 59, 0.75);
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-weight: 600;
  color: #e2e8f0;
  transition: all 0.2s ease;
}

.chapter-group-header:hover {
  background: rgba(51, 65, 85, 0.9);
  border-color: rgba(56, 189, 248, 0.4);
}

.chapter-group-header .group-toggle-icon {
  font-size: 10px;
  transition: transform 0.2s ease;
  color: #94a3b8;
}

.chapter-group-header.collapsed .group-toggle-icon {
  transform: rotate(-90deg);
}

.chapter-group-header .group-title {
  flex: 1;
}

.chapter-group-header .group-badge {
  padding: 1px 7px;
  border-radius: 9999px;
  background: rgba(56, 189, 248, 0.16);
  color: #38bdf8;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.chapter-group-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
  padding-left: 4px;
}

.chapter-group-body.collapsed {
  display: none;
}

.exp-item {
  padding: 9px 11px;
  border-radius: 9px;
  background: var(--bg-card);
  border: 1px solid rgba(148, 163, 184, 0.12);
  cursor: pointer;
  transition: all 0.16s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.exp-item:hover {
  background: var(--bg-card-hover);
  border-color: rgba(56, 189, 248, 0.38);
}

.exp-item.active {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.28), rgba(37, 99, 235, 0.24));
  border-color: var(--accent-cyan);
  box-shadow: inset 0 0 12px rgba(56, 189, 248, 0.18);
}

.exp-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.exp-subject-pill {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 700;
}

.subj-physics { background: rgba(56, 189, 248, 0.2); color: #38bdf8; }
.subj-chemistry { background: rgba(244, 63, 94, 0.2); color: #fb7185; }
.subj-biology { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.subj-geography { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.subj-math { background: rgba(168, 85, 247, 0.2); color: #c084fc; }

.exp-chapter {
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.exp-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
}

/* 中央主视口区域 */
.center-stage {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #050912;
  overflow: hidden;
  position: relative;
}

.phet-toolbar {
  min-height: 46px;
  background: #0c1425;
  border-bottom: 1px solid var(--border-subtle);
  padding: 6px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  z-index: 10;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tool-btn {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.tool-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-cyan);
}

.tool-btn.primary {
  background: linear-gradient(135deg, #059669, #10b981);
  border-color: #34d399;
  color: #ffffff;
}

.speed-control {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 3px 8px;
  border-radius: 6px;
}

.speed-label {
  font-size: 11px;
  color: var(--text-secondary);
}

.speed-select {
  background: transparent;
  border: none;
  color: var(--accent-cyan);
  font-size: 12px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

.speed-select option {
  background: #0f172a;
  color: #f8fafc;
}

.toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  font-size: 11.5px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.toggle-pill:hover {
  border-color: var(--accent-cyan);
  color: #ffffff;
}

.toggle-pill input {
  accent-color: var(--accent-cyan);
  cursor: pointer;
}

/* Three.js 视口（希沃大屏 touch-action: none 禁用浏览器手势拦截） */
.viewport-3d {
  flex: 1;
  position: relative;
  width: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 45%, #111e38 0%, #060a14 80%);
  cursor: grab;
  touch-action: none;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

.viewport-3d:active {
  cursor: grabbing;
}

.viewport-3d canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  touch-action: none;
}

.viewport-hud-top {
  position: absolute;
  top: 12px;
  left: 14px;
  right: 14px;
  pointer-events: none;
  z-index: 5;
}

.hud-exp-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.hud-badge {
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(56, 189, 248, 0.22);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.hud-chapter {
  font-size: 11.5px;
  color: #93c5fd;
  background: rgba(15, 23, 42, 0.72);
  padding: 2px 8px;
  border-radius: 5px;
}

.hud-title {
  font-size: 17px;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

.hud-subtitle {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.viewport-legend {
  position: absolute;
  bottom: 34px;
  left: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  pointer-events: none;
  z-index: 5;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 6px;
  background: rgba(9, 15, 28, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.22);
  font-size: 11px;
  color: #e2e8f0;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.viewport-status {
  position: absolute;
  bottom: 8px;
  right: 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  background: rgba(9, 15, 28, 0.75);
  padding: 2px 8px;
  border-radius: 4px;
  pointer-events: none;
  z-index: 5;
}

/* 底部 Mathigon 分步引导探究栏 */
.mathigon-bar {
  background: #0c1425;
  border-top: 1px solid var(--border-subtle);
  padding: 8px 14px 10px;
  z-index: 10;
}

.mathigon-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
  gap: 10px;
}

.mathigon-tag {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-cyan);
}

.active-step-desc {
  font-size: 11.5px;
  color: #cbd5e1;
  flex: 1;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.step-cards-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.step-card {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all 0.16s ease;
  text-align: left;
}

.step-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-cyan);
}

.step-card.active {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.25), rgba(59, 130, 246, 0.22));
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.25);
}

.step-card-title {
  font-size: 12px;
  font-weight: 700;
  color: #38bdf8;
  margin-bottom: 3px;
}

.step-card-desc {
  font-size: 11px;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 右侧控制台 */
.right-console {
  background: var(--bg-panel);
  border-left: 1px solid var(--border-subtle);
  height: 100%;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.console-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 12px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.card-header h3 {
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
}

.card-hint {
  font-size: 10.5px;
  color: var(--accent-cyan);
}

/* 参数滑块 */
.params-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.param-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.param-label-line {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.param-name {
  color: #e2e8f0;
  font-weight: 500;
}

.param-val {
  font-family: var(--font-mono);
  color: var(--accent-cyan);
  font-weight: 700;
}

.param-slider {
  width: 100%;
  height: 28px;
  accent-color: var(--accent-cyan);
  cursor: pointer;
  touch-action: pan-x;
  padding: 4px 0;
}

.param-slider::-webkit-slider-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
}

/* 教材公式与实时数值代入推演卡 */
.formula-expression {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: #fcd34d;
  background: rgba(9, 15, 28, 0.72);
  padding: 7px 10px;
  border-radius: 6px;
  border-left: 3px solid var(--accent-amber);
  margin-bottom: 6px;
}

.formula-substitution {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: #bae6fd;
  background: rgba(2, 132, 199, 0.12);
  padding: 6px 9px;
  border-radius: 6px;
  margin-bottom: 8px;
  word-break: break-all;
}

.chem-micro-panel {
  background: rgba(244, 63, 94, 0.11);
  border: 1px solid rgba(244, 63, 94, 0.32);
  border-radius: 7px;
  padding: 7px 9px;
  margin-bottom: 8px;
}

.chem-micro-panel.hidden {
  display: none;
}

.chem-eq-title {
  font-size: 11px;
  color: #fda4af;
  font-weight: 700;
  margin-bottom: 3px;
}

.chem-eq-body {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 5px;
}

.particle-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.particle-badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.75);
  color: #fecdd3;
  font-family: var(--font-mono);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.metric-box {
  background: rgba(9, 15, 28, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 6px;
  padding: 6px 8px;
}

.metric-label {
  font-size: 10.5px;
  color: var(--text-secondary);
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-emerald);
  margin-top: 2px;
}

/* 动态图表 */
.chart-card canvas {
  width: 100%;
  height: 170px;
  background: #080d1a;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  display: block;
}

/* 随堂互动问答卡 */
.quiz-question {
  font-size: 12.5px;
  font-weight: 600;
  color: #f8fafc;
  margin-bottom: 8px;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.quiz-option-btn {
  text-align: left;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(9, 15, 28, 0.65);
  color: #e2e8f0;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.quiz-option-btn:hover {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.12);
}

.quiz-option-btn.correct {
  background: rgba(16, 185, 129, 0.22);
  border-color: #10b981;
  color: #6ee7b7;
  font-weight: 700;
}

.quiz-option-btn.wrong {
  background: rgba(244, 63, 94, 0.22);
  border-color: #f43f5e;
  color: #fda4af;
}

.quiz-feedback {
  margin-top: 8px;
  padding: 7px 9px;
  border-radius: 6px;
  font-size: 11.5px;
  line-height: 1.45;
  background: rgba(15, 23, 42, 0.85);
  border-left: 3px solid var(--accent-cyan);
  color: #cbd5e1;
}

/* HTML ??????????? */
.formula-expression {
  display: block;
  line-height: 1.85;
}
.formula-expression sub,
.formula-expression sup {
  font-size: 0.76em;
  line-height: 0;
}
.math-frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  margin: 0 4px;
  font-size: 0.9em;
  line-height: 1.15;
}
.math-frac .num {
  border-bottom: 1px solid rgba(252, 211, 77, 0.8);
  padding: 0 4px 1px;
}
.math-frac .den {
  padding: 1px 4px 0;
}
.math-cond {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  margin: 0 4px;
  font-size: 0.8em;
  color: #38bdf8;
  line-height: 1.05;
}

.math-vec { position: relative; display: inline-block; font-weight: 700; font-style: italic; margin: 0 1px; }
.math-vec::before { content: "→"; position: absolute; top: -0.62em; left: -1px; right: -1px; font-size: 0.65em; text-align: center; font-style: normal; }
