:root {
  --bg: #f3f7fb;
  --surface: #ffffff;
  --surface-2: #eef4fa;
  --ink: #0f2438;
  --ink-2: #435b73;
  --muted: #6c8299;
  --line: #d8e3ee;
  --accent: #156082;
  --accent-soft: #e3f1f8;
  --accent-2: #0f766e;
  --warn-bg: #fff7ed;
  --warn-ink: #9a3412;
  --warn-line: #fed7aa;
  --ok-bg: #ecfdf5;
  --ok-ink: #065f46;
  --err-bg: #fef2f2;
  --err-ink: #991b1b;
  --shadow: 0 10px 28px rgba(15, 36, 56, 0.08);
  --radius: 14px;
  --font-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

body.theme-dark {
  --bg: #0b101d;
  --surface: #131b2e;
  --surface-2: #1a2540;
  --ink: #eef3fb;
  --ink-2: #b8c7df;
  --muted: #7f93b3;
  --line: #253454;
  --accent: #7c6cf6;
  --accent-soft: rgba(124, 108, 246, 0.16);
  --accent-2: #22d3ee;
  --warn-bg: rgba(245, 158, 11, 0.13);
  --warn-ink: #fcd34d;
  --warn-line: rgba(245, 158, 11, 0.35);
  --ok-bg: rgba(16, 185, 129, 0.14);
  --ok-ink: #6ee7b7;
  --err-bg: rgba(239, 68, 68, 0.14);
  --err-ink: #fca5a5;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.38);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button, input, select {
  font-family: inherit;
  color: inherit;
}

/* Top Navigation Bar */
.topbar {
  height: 58px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  z-index: 30;
  position: relative;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.brand-title {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
  white-space: nowrap;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.mode-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.mode-tab {
  border: none;
  background: transparent;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.mode-tab:hover { color: var(--ink); }
.mode-tab.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  padding: 6px 11px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.16s ease;
  white-space: nowrap;
}

.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.icon-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Main Workspace */
.workspace {
  height: calc(100vh - 58px);
  display: flex;
  position: relative;
  overflow: hidden;
}

/* Left Model Catalog Sidebar */
.sidebar {
  width: 288px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 15;
  transition: margin-left 0.22s ease;
}

.sidebar.collapsed { margin-left: -288px; }

.sidebar-head {
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--line);
}

.search-box {
  width: 100%;
  padding: 8px 11px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 13px;
  outline: none;
}

.search-box:focus { border-color: var(--accent); }

.module-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 9px;
}

.mod-pill {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 99px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.14s ease;
}

.mod-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.model-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-content: start;
}

.model-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: all 0.16s ease;
}

.model-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.model-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent);
}

.model-thumb {
  width: 60px;
  height: 46px;
  border-radius: 8px;
  object-fit: cover;
  background: #0c1220;
  flex-shrink: 0;
}

.model-meta { min-width: 0; flex: 1; }
.model-name {
  font-size: 13px;
  font-weight: 650;
  line-height: 1.25;
  display: flex;
  align-items: center;
  gap: 5px;
}

.model-id {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
}

.model-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.course-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  margin-top: 4px;
}

/* Center 3D Stage */
.stage-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.stage-canvas-host {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.bio-webgl-canvas {
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  cursor: grab;
}

.bio-webgl-canvas:active { cursor: grabbing; }

/* Loading Overlay */
.stage-loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(15, 23, 42, 0.25);
  backdrop-filter: blur(4px);
  z-index: 12;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.stage-loader.visible {
  opacity: 1;
  pointer-events: auto;
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--accent);
  animation: spin 0.75s linear infinite;
}

.loader-text {
  font-size: 13px;
  font-weight: 600;
  background: var(--surface);
  color: var(--ink);
  padding: 6px 14px;
  border-radius: 99px;
  box-shadow: var(--shadow);
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Floating Breadcrumb / Model Title Banner on Stage */
.stage-banner {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  z-index: 8;
}

.stage-title-card {
  pointer-events: auto;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  max-width: 440px;
  box-shadow: var(--shadow);
}

.stage-eyebrow {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.4px;
}

.stage-heading {
  font-size: 18px;
  font-weight: 750;
  margin: 2px 0 0;
  line-height: 1.25;
}

.stage-en {
  font-size: 12px;
  color: var(--muted);
  margin-left: 6px;
  font-weight: 500;
}

.drill-crumb {
  margin-top: 7px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.crumb-btn {
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 650;
  padding: 3px 9px;
  border-radius: 99px;
  cursor: pointer;
}

.crumb-btn:hover { background: var(--accent); color: #fff; }

/* Bottom Floating 3D Control Dock */
.stage-dock {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 10;
  max-width: calc(100% - 24px);
  overflow-x: auto;
}

.dock-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.14s ease;
}

.dock-btn:hover { background: var(--surface-2); color: var(--ink); }
.dock-btn.active { background: var(--accent); color: #fff; }
.dock-sep { width: 1px; height: 18px; background: var(--line); flex-shrink: 0; }

/* 3D Projected Hotspot Pins */
.hotspot-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 7;
}

.hotspot-pin {
  position: absolute;
  top: 0;
  left: 0;
  margin-left: -14px;
  margin-top: -14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 3px;
  border-radius: 99px;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  background: rgba(15, 28, 46, 0.84);
  color: #fff;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
  transition: background 0.16s ease, border-color 0.16s ease, opacity 0.16s ease;
  white-space: nowrap;
  backdrop-filter: blur(6px);
}

.hotspot-pin .pin-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
}

.hotspot-pin:hover,
.hotspot-pin.active {
  background: var(--accent);
  border-color: #fff;
  z-index: 20;
}

.hotspot-pin.active .pin-dot {
  background: #fff;
  color: var(--accent);
}

/* Whiteboard Annotation Canvas */
.annotate-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 9;
  pointer-events: none;
}

.annotate-canvas.drawing {
  pointer-events: auto;
  cursor: crosshair;
}

/* Right Inspector / Course Story Panel */
.inspector {
  width: 376px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 15;
  overflow: hidden;
}

.inspector-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.sec-block {
  margin-bottom: 16px;
}

.sec-title {
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin: 0 0 8px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.tag-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
}

.summary-text {
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--ink-2);
  margin: 0;
}

.bullet-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-2);
}

.bullet-list li { margin-bottom: 6px; }

.trap-box {
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  color: var(--warn-ink);
  border-radius: 11px;
  padding: 11px 12px;
  font-size: 12.5px;
  line-height: 1.6;
}

.trap-box ul { margin: 4px 0 0; padding-left: 17px; }
.trap-box li { margin-bottom: 4px; }

/* Micro-drill cards */
.drill-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.drill-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.drill-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drill-card img {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  object-fit: cover;
  background: #0c1220;
  flex-shrink: 0;
}

.drill-card span {
  font-size: 12px;
  font-weight: 650;
  line-height: 1.25;
}

/* Course CTA Banner inside Atlas Inspector */
.course-launch-btn {
  width: 100%;
  padding: 11px 14px;
  border: none;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 14px;
  box-shadow: 0 6px 18px rgba(21, 96, 130, 0.25);
  transition: transform 0.14s ease;
}

.course-launch-btn:hover { transform: translateY(-1px); }

/* Quiz Box */
.quiz-card {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 12px;
  margin-bottom: 10px;
  background: var(--surface-2);
}

.quiz-q {
  font-size: 13px;
  font-weight: 650;
  line-height: 1.5;
  margin-bottom: 8px;
}

.quiz-opt {
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  margin-bottom: 5px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.14s ease;
}

.quiz-opt:hover { border-color: var(--accent); }
.quiz-opt.correct { background: var(--ok-bg); border-color: var(--ok-ink); color: var(--ok-ink); font-weight: 650; }
.quiz-opt.wrong { background: var(--err-bg); border-color: var(--err-ink); color: var(--err-ink); }

.quiz-exp {
  margin-top: 7px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-2);
  padding-top: 7px;
  border-top: 1px dashed var(--line);
}

/* Course Guided Mode Panel */
.course-switcher {
  display: flex;
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.course-pick {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 9px;
  padding: 7px 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink-2);
}

.course-pick.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.beat-stepper {
  display: flex;
  gap: 5px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}

.beat-dot {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 6px 4px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  color: var(--muted);
}

.beat-dot.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.beat-kicker {
  font-size: 11px;
  font-weight: 750;
  color: var(--accent);
  letter-spacing: 0.5px;
}

.beat-title {
  font-size: 18px;
  font-weight: 800;
  margin: 4px 0 8px;
  line-height: 1.3;
}

.beat-lead {
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-2);
  margin: 0 0 14px;
}

.info-card {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 11px;
  padding: 10px 12px;
  margin-bottom: 9px;
}

.info-card-h {
  font-size: 13px;
  font-weight: 750;
  margin-bottom: 4px;
  color: var(--ink);
}

.info-card-b {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink-2);
}

.pathway-step {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 9px 11px;
  margin-bottom: 7px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pathway-step:hover,
.pathway-step.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.pulse-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 12px;
}

.hotspot-detail-box {
  border: 1.5px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 11px;
  padding: 11px 12px;
  margin-bottom: 12px;
}

.course-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  background: var(--surface);
}

.nav-btn {
  flex: 1;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.nav-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.nav-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Compare Mode Layout */
.compare-view {
  flex: 1;
  display: none;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.compare-view.active { display: flex; }

.compare-toolbar {
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.compare-split {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  min-height: 0;
}

.compare-pane {
  position: relative;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.compare-pane-bar {
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.compare-select {
  pointer-events: auto;
  padding: 6px 10px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  font-size: 13px;
  font-weight: 700;
  box-shadow: var(--shadow);
}

.compare-table-wrap {
  max-height: 215px;
  overflow-y: auto;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 10px 16px 12px;
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.compare-table th,
.compare-table td {
  border-bottom: 1px solid var(--line);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}

.compare-table th {
  color: var(--accent);
  font-weight: 750;
  background: var(--surface-2);
}

.hidden { display: none !important; }

@media (max-width: 1020px) {
  .sidebar { position: absolute; left: 0; top: 0; bottom: 0; box-shadow: var(--shadow); }
  .inspector { width: 320px; }
}

@media (max-width: 760px) {
  .workspace { flex-direction: column; }
  .inspector { width: 100%; height: 42vh; border-left: none; border-top: 1px solid var(--line); }
  .brand-sub { display: none; }
  .compare-split { grid-template-columns: 1fr; }
}
