:root {
  --bg: #020814;
  --bg-soft: #071120;
  --panel: rgba(7, 15, 28, 0.88);
  --panel-strong: rgba(10, 20, 36, 0.96);
  --line: rgba(86, 146, 221, 0.22);
  --line-strong: rgba(122, 247, 228, 0.34);
  --text: #e8fbff;
  --muted: #82a8c8;
  --accent: #7cf7e4;
  --accent-strong: #48c9ff;
  --accent-soft: rgba(122, 247, 228, 0.14);
  --danger: #ff7ca8;
  --danger-soft: rgba(255, 124, 168, 0.14);
  --shadow: 0 24px 44px rgba(0, 0, 0, 0.42);
  --left-w: clamp(360px, 30vw, 456px);
  --topbar-h: 72px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { color-scheme: dark; }

body {
  min-height: 100vh;
  overflow: hidden;
  font-family: "Space Grotesk", "Segoe UI Variable Text", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -10%, rgba(72, 201, 255, 0.18), transparent 28%),
    radial-gradient(circle at top left, rgba(122, 247, 228, 0.12), transparent 22%),
    radial-gradient(circle at top right, rgba(24, 118, 255, 0.16), transparent 24%),
    linear-gradient(180deg, #020712 0%, #050c17 54%, #08111d 100%);
}

button, select, input, textarea { font: inherit; }
button,
[role="button"],
label[for] {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(122, 247, 228, 0.14);
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -44px;
  z-index: 50;
  padding: 0.7rem 1rem;
  border-radius: 999px;
  background: rgba(7, 20, 35, 0.98);
  color: #f7fcff;
  text-decoration: none;
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.34);
  transition: top 140ms ease;
}

.skip-link:focus-visible {
  top: 16px;
  outline: 2px solid rgba(122, 247, 228, 0.5);
}

/* ============ APP SHELL ============ */
.app-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  width: 100vw;
  height: 100vh;
}

/* ============ TOPBAR ============ */
.topbar {
  display: grid;
  grid-template-columns: minmax(0, var(--left-w)) minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  min-height: var(--topbar-h);
  padding: 10px 16px 10px 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(8, 18, 33, 0.96), rgba(5, 14, 26, 0.92));
  box-shadow: inset 0 -1px 0 rgba(122, 247, 228, 0.06), 0 14px 24px rgba(0, 0, 0, 0.32);
}

.brand-lockup {
  display: grid;
  gap: 3px;
  align-content: center;
  min-width: 0;
  padding-right: 14px;
}
.eyebrow {
  margin: 0; color: var(--muted);
  font-family: "Exo 2", "Space Grotesk", sans-serif;
  font-size: 0.64rem; font-weight: 600;
  letter-spacing: 0.18em; text-transform: uppercase;
}
h1 {
  margin: 0;
  font-family: "Exo 2", "Space Grotesk", sans-serif;
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-wrap: balance;
}

.topbar-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 0;
}

/* Tool buttons */
.tool-cluster {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  padding: 6px 8px;
  border: 1px solid rgba(76, 133, 196, 0.18);
  border-radius: 16px;
  background: rgba(5, 14, 27, 0.44);
  backdrop-filter: blur(18px);
}
.tool-btn {
  position: relative;
  border: 1px solid rgba(76, 133, 196, 0.22);
  color: var(--text);
  background: linear-gradient(180deg, rgba(9, 23, 40, 0.98), rgba(7, 16, 30, 0.98));
  box-shadow: inset 0 1px 0 rgba(126, 214, 255, 0.08), 0 10px 20px rgba(0, 0, 0, 0.24);
}
.tool-btn {
  width: 36px; height: 36px; border-radius: 6px; cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease, color 140ms ease;
}
.tool-btn::before {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 0.92rem; font-weight: 700; color: currentColor;
}
.tool-btn::after {
  content: attr(data-tooltip); position: absolute; left: 50%; bottom: -26px; transform: translateX(-50%);
  padding: 3px 7px; border-radius: 999px;
  border: 1px solid rgba(122, 247, 228, 0.24);
  background: rgba(5, 14, 27, 0.94); color: var(--accent);
  font-size: 0.62rem; letter-spacing: 0.04em; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity 140ms ease; z-index: 20;
}
.tool-btn:hover, .tool-btn:focus-visible {
  border-color: rgba(122, 247, 228, 0.44);
  background: linear-gradient(180deg, rgba(18, 46, 72, 0.98), rgba(10, 26, 44, 0.98));
  box-shadow: inset 0 1px 0 rgba(182, 236, 255, 0.14), 0 0 0 1px rgba(122, 247, 228, 0.18);
  color: #f3fcff;
}
.tool-btn:hover::after, .tool-btn:focus-visible::after { opacity: 1; }
.tool-btn:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid rgba(122, 247, 228, 0.22); outline-offset: 2px;
}
.tool-btn:disabled { opacity: 0.42; cursor: not-allowed; transform: none; box-shadow: none; }
.tool-btn.is-start { border-color: rgba(122, 247, 228, 0.42); }
.tool-btn.is-start::before { content: "\25b7"; margin-left: 1px; }
.tool-btn.is-stop::before { content: "\25a0"; font-size: 0.72rem; }
.tool-btn.is-undo::before { content: "\21b6"; }
.tool-btn.is-clear { border-color: rgba(255, 124, 168, 0.28); background: linear-gradient(180deg, rgba(31, 10, 23, 0.96), rgba(19, 8, 16, 0.96)); }
.tool-btn.is-clear::before { content: "\2715"; }
.tool-btn.is-save::before { content: "\2193"; }
.tool-btn.is-load::before { content: "\2191"; }
.tool-btn.is-start:hover, .tool-btn.is-start:focus-visible {
  background: linear-gradient(180deg, rgba(18, 67, 72, 0.98), rgba(9, 34, 39, 0.98));
}
.tool-btn.is-clear:hover, .tool-btn.is-clear:focus-visible,
.tool-btn.is-stop:hover, .tool-btn.is-stop:focus-visible {
  border-color: rgba(255, 138, 176, 0.56);
  background: linear-gradient(180deg, rgba(72, 21, 39, 0.98), rgba(38, 13, 23, 0.98));
}
.tool-label {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Field */
.field { display: grid; gap: 6px; }
.field span {
  color: var(--muted); font-size: 0.66rem; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
}
select, input[type="color"] {
  width: 100%; min-width: 0; height: 36px;
  border: 1px solid rgba(76, 133, 196, 0.18); border-radius: 8px;
  background: linear-gradient(180deg, rgba(9, 21, 38, 0.98), rgba(5, 15, 27, 0.98));
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(126, 214, 255, 0.06);
}
select {
  appearance: none; padding: 0 34px 0 12px;
  color-scheme: dark;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--accent) 50%),
    linear-gradient(135deg, var(--accent) 50%, transparent 50%),
    linear-gradient(180deg, rgba(9, 21, 38, 0.98), rgba(5, 15, 27, 0.98));
  background-position: calc(100% - 18px) 16px, calc(100% - 12px) 16px, 0 0;
  background-size: 6px 6px, 6px 6px, 100% 100%;
  background-repeat: no-repeat;
}
select option {
  background: #09182c;
  color: #effbff;
}
select option:checked,
select option:hover,
select option:focus {
  background: #ffd166;
  color: #07111d;
}
input[type="color"] { padding: 4px; cursor: pointer; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 5px; }

/* ============ WORKSPACE: TWO-COLUMN LAYOUT ============ */
.workspace {
  display: grid;
  grid-template-columns: minmax(340px, var(--left-w)) minmax(0, 1fr);
  min-height: 0;
}

/* ============ LEFT PANEL ============ */
.left-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background:
    radial-gradient(circle at top left, rgba(122, 247, 228, 0.06), transparent 28%),
    linear-gradient(180deg, rgba(7, 14, 27, 0.98), rgba(4, 11, 20, 0.98));
  border-right: 1px solid var(--line);
  overflow: hidden;
  backdrop-filter: blur(18px);
}

/* Tab Navigation */
.panel-tabs {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
  padding: 0;
  margin: 0;
  background: rgba(4, 11, 20, 0.96);
  backdrop-filter: blur(18px);
}
.panel-tab {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
  border-bottom: 2px solid transparent;
}
.panel-tab:hover {
  color: #f3fcff;
  background: linear-gradient(180deg, rgba(14, 31, 52, 0.92), rgba(9, 20, 36, 0.92));
}
.panel-tab:focus-visible {
  outline: 2px solid rgba(122, 247, 228, 0.22);
  outline-offset: -2px;
}
.panel-tab.active {
  color: var(--accent); border-bottom-color: var(--accent);
  background: rgba(122, 247, 228, 0.06);
}

/* Tab Content */
.tab-content {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  display: none;
  scrollbar-gutter: stable;
}
.tab-content.active { display: flex; flex-direction: column; }

/* Sections inside tab content */
.tab-content > section {
  padding: 18px;
  border-bottom: 1px solid rgba(76, 133, 196, 0.12);
}
.card-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-heading h2 {
  margin: 0; font-family: "Exo 2", "Space Grotesk", sans-serif;
  font-size: 0.86rem; font-weight: 600; letter-spacing: 0.05em;
}
.pill {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 22px; padding: 0 8px; border-radius: 999px;
  border: 1px solid rgba(0, 166, 255, 0.2);
  background: rgba(0, 166, 255, 0.08);
  color: var(--accent-strong); font-size: 0.7rem; font-weight: 600;
}

/* Question input (clean & minimal) */
.question-section {
  flex: 0 0 auto;
  display: grid;
  gap: 12px;
  padding: 16px 18px !important;
  background:
    radial-gradient(circle at top right, rgba(72, 201, 255, 0.08), transparent 30%),
    linear-gradient(180deg, rgba(8, 16, 30, 0.94), rgba(5, 13, 24, 0.9));
  border-bottom: 1px solid rgba(76, 133, 196, 0.12) !important;
}
.lesson-panel-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.question-section[data-collapsible="false"] .lesson-panel-toggle {
  cursor: default;
}
.lesson-panel-copy {
  min-width: 0;
}
.lesson-panel-copy h2 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 600;
  color: #f2fbff;
  text-wrap: balance;
}
.lesson-panel-icon {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1;
  transform: rotate(0deg);
  transition: transform 160ms ease;
}
.question-section[data-collapsible="false"] .lesson-panel-icon {
  opacity: 0.3;
}
.question-summary {
  display: -webkit-box;
  margin: 4px 0 0;
  overflow: hidden;
  color: var(--accent);
  font-size: 0.72rem;
  line-height: 1.4;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}
.question-section-body {
  display: grid;
  gap: 8px;
}
.question-section.is-compact {
  gap: 8px;
}
.question-section.is-compact .question-textarea {
  min-height: 48px;
}
.question-section.is-collapsed {
  gap: 8px;
  padding-bottom: 8px !important;
}
.question-section.is-collapsed .question-section-body {
  display: none;
}
.question-section.is-collapsed .lesson-panel-icon {
  transform: rotate(-90deg);
}
.question-section.is-collapsed .lesson-panel-toggle {
  align-items: center;
}
.question-section.is-collapsed .new-question-btn {
  display: block;
}
.new-question-btn {
  display: none;
  width: 100%;
  padding: 6px 12px;
  margin-top: 6px;
  border: 1px solid rgba(122, 247, 228, 0.18);
  border-radius: 8px;
  background: transparent;
  color: var(--accent);
  font-size: 0.74rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
}
.new-question-btn:hover {
  background: rgba(122, 247, 228, 0.06);
  border-color: rgba(122, 247, 228, 0.3);
}
.question-input-wrap {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(76, 133, 196, 0.18);
  border-radius: 18px;
  background: rgba(4, 11, 21, 0.56);
  box-shadow: inset 0 1px 0 rgba(126, 214, 255, 0.04);
}
.question-textarea {
  width: 100%;
  min-height: 72px;
  max-height: 148px;
  padding: 12px 14px;
  border: 1px solid rgba(76, 133, 196, 0.18);
  border-radius: 14px;
  background: rgba(5, 13, 25, 0.72);
  color: var(--text);
  font-size: 0.84rem;
  line-height: 1.5;
  resize: vertical;
  font-family: inherit;
}
.question-textarea::placeholder { color: var(--muted); font-size: 0.8rem; }
.question-textarea:focus-visible {
  outline: 2px solid rgba(122, 247, 228, 0.22);
  outline-offset: 1px;
  border-color: rgba(122, 247, 228, 0.4);
}
.composer-math-preview {
  padding: 10px 12px;
  border: 1px solid rgba(122, 247, 228, 0.12);
  border-radius: 12px;
  background: rgba(8, 18, 32, 0.58);
  color: var(--text);
  font-size: 0.78rem;
  line-height: 1.5;
  overflow-x: auto;
}
.composer-math-preview::before {
  content: "Math Preview";
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.question-upload-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.question-upload-btn,
.question-upload-clear {
  border: 1px solid rgba(76, 133, 196, 0.18);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.32rem 0.7rem;
  cursor: pointer;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}
.question-upload-btn:hover,
.question-upload-clear:hover {
  color: var(--text);
  border-color: rgba(76, 133, 196, 0.32);
  background: rgba(255, 255, 255, 0.03);
}
.question-image-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  background: rgba(122, 247, 228, 0.06);
  border: 1px solid rgba(122, 247, 228, 0.12);
  color: var(--accent);
  font-size: 0.68rem;
}
.question-image-preview {
  border: 1px solid rgba(76, 133, 196, 0.12);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(5, 14, 26, 0.5);
  max-width: min(100%, 220px);
}
.question-image-preview img {
  width: 100%;
  display: block;
  object-fit: cover;
}
.question-submit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 11px 14px;
  border: 1px solid rgba(122, 247, 228, 0.28);
  border-radius: 12px;
  cursor: pointer;
  background: rgba(122, 247, 228, 0.08);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.82rem;
  transition: background 180ms ease, border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}
.question-submit-btn:hover {
  background: rgba(122, 247, 228, 0.12);
  border-color: rgba(122, 247, 228, 0.44);
  box-shadow: 0 14px 28px rgba(6, 17, 26, 0.26);
  transform: translateY(-1px);
}
.question-submit-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.submit-icon { font-size: 0.9rem; }
.question-status {
  padding: 6px 10px; border-radius: 8px; font-size: 0.74rem;
  border: 1px solid rgba(76, 133, 196, 0.12);
  background: rgba(8, 18, 34, 0.5); color: var(--muted);
}
.question-status.is-loading { color: var(--accent); border-color: rgba(122, 247, 228, 0.2); }
.question-status.is-error { color: var(--danger); border-color: rgba(255, 124, 168, 0.2); }

/* Voice button (inline mic) */
.voice-mic-btn {
  width: 36px; height: 36px; flex-shrink: 0;
  border: 1px solid rgba(76, 133, 196, 0.18);
  border-radius: 10px; cursor: pointer;
  background: transparent; color: var(--muted);
  font-size: 0.9rem;
  transition: color 140ms, border-color 140ms;
}
.voice-mic-btn:hover { color: var(--text); border-color: rgba(76, 133, 196, 0.32); }
.voice-mic-btn:focus-visible,
.question-upload-btn:focus-visible,
.question-upload-clear:focus-visible,
.question-submit-btn:focus-visible,
.new-question-btn:focus-visible {
  outline: 2px solid rgba(122, 247, 228, 0.24);
  outline-offset: 2px;
}
.voice-mic-btn.is-recording {
  color: var(--accent);
  border-color: rgba(122, 247, 228, 0.4);
  animation: voicePulse 1.2s ease infinite;
}
.voice-mic-btn:disabled { opacity: 0.3; cursor: not-allowed; }
@keyframes voicePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(122, 247, 228, 0.15); }
  50% { box-shadow: 0 0 0 4px rgba(122, 247, 228, 0.08); }
}
.voice-status-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.68rem;
  text-align: center;
}

.muted-text { margin: 0; color: var(--muted); font-size: 0.78rem; line-height: 1.5; }

/* Sandbox */
.sandbox-section { padding: 0 !important; border-bottom: none !important; }
.sandbox-details { width: 100%; }
.sandbox-toggle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; cursor: pointer; user-select: none;
  border-bottom: 1px solid var(--line);
}
.sandbox-toggle h2 { margin: 0; font-size: 0.82rem; font-weight: 600; }
.sandbox-tools-content { border-bottom: 1px solid var(--line); }
.algebra-card { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.controls-card { display: grid; gap: 10px; }
.status-card { display: grid; gap: 8px; }
.object-card { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; }
.status {
  margin: 0; padding: 8px 10px;
  border: 1px solid rgba(76, 133, 196, 0.14); border-radius: 10px;
  background: rgba(8, 18, 34, 0.78); color: var(--muted); font-size: 0.82rem;
}
.status[data-state="ok"] { color: #aefcf3; border-color: rgba(122, 247, 228, 0.22); background: rgba(122, 247, 228, 0.08); }
.status[data-state="error"] { color: #c43d6d; border-color: rgba(255, 95, 142, 0.24); background: var(--danger-soft); }

/* Object list */
.object-list {
  overflow: auto; min-height: 0; padding: 6px;
  border: 1px solid rgba(76, 133, 196, 0.14); border-radius: 12px;
  background: linear-gradient(180deg, rgba(7, 16, 30, 0.92), rgba(4, 12, 24, 0.9));
}
.object-item {
  padding: 10px; border: 1px solid rgba(76, 133, 196, 0.14); border-radius: 10px;
  background: rgba(9, 20, 36, 0.76); cursor: pointer;
  transition: border-color 140ms, background 140ms;
}
.object-item + .object-item { margin-top: 6px; }
.object-item.is-active {
  border-color: rgba(255, 209, 102, 0.82);
  background:
    linear-gradient(180deg, rgba(48, 32, 6, 0.94), rgba(24, 17, 7, 0.94)),
    radial-gradient(circle at top right, rgba(255, 209, 102, 0.14), transparent 42%);
  box-shadow: inset 0 1px 0 rgba(255, 232, 173, 0.18), 0 0 0 1px rgba(255, 209, 102, 0.18);
}
.object-item-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; color: var(--text); font-size: 0.82rem; }
.object-swatch {
  width: 12px; height: 12px; border-radius: 999px; background: var(--swatch);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12); flex: 0 0 auto;
}
.object-label { font-family: "Exo 2", "Space Grotesk", sans-serif; letter-spacing: 0.05em; }
.object-state { margin-left: auto; color: var(--accent); font-size: 0.62rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.object-item.is-active .object-state { color: #ffe39c; }
.object-controls { display: grid; gap: 8px; }
.object-empty { color: var(--muted); font-size: 0.72rem; line-height: 1.45; padding: 10px; }

/* Scene Plan Section */
.scene-plan-section { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.scene-plan {
  display: flex; flex-direction: column; gap: 12px;
}
.source-evidence,
.agent-trace {
  display: grid;
  gap: 8px;
}
.source-evidence-card,
.agent-trace-card {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(76, 133, 196, 0.18);
  background: rgba(8, 18, 34, 0.72);
}
.source-evidence-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.source-evidence-list .pill {
  min-width: auto;
}
.agent-trace-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.agent-trace-status {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}
.agent-trace-status.is-fallback { color: #ffd966; }
.agent-trace-status.is-muted { color: var(--muted); }
.evidence-panel {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 6;
  width: min(420px, calc(100% - 36px));
  border-radius: 18px;
}
.evidence-panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 118px) minmax(0, 1fr);
  gap: 14px;
}
.evidence-panel-column {
  display: grid;
  align-content: start;
  gap: 10px;
}
.evidence-panel-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  color: #f3fbff;
  font-size: 0.96rem;
  line-height: 1.35;
}
.score-bar {
  width: 100%;
  height: 8px;
  background: rgba(122, 160, 206, 0.16);
  border-radius: 999px;
  margin: 2px 0 0;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.score-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #6c7cff 0%, #7cf7e4 100%);
  border-radius: inherit;
  box-shadow: 0 0 18px rgba(122, 247, 228, 0.22);
}
.badge-info {
  width: fit-content;
  background: rgba(72, 201, 255, 0.12);
  color: #b6ebff;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.34rem 0.72rem;
  border-radius: 999px;
  border: 1px solid rgba(72, 201, 255, 0.24);
}
.badge-muted {
  width: fit-content;
  background: rgba(122, 160, 206, 0.08);
  color: #c4d8ea;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.34rem 0.72rem;
  border-radius: 999px;
  border: 1px solid rgba(122, 160, 206, 0.18);
}
.tag {
  width: fit-content;
  font-size: 0.72rem;
  color: #edf8ff;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
  padding: 0.26rem 0.62rem;
  border-radius: 999px;
}
.label-muted {
  font-size: 0.68rem;
  color: #8daecc;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 4px;
}
.plan-summary {
  padding: 10px 12px; border-radius: 8px;
  background: rgba(122, 247, 228, 0.08); border: 1px solid rgba(122, 247, 228, 0.2);
  color: var(--accent); font-size: 0.84rem; font-weight: 500;
}
.build-summary {
  padding: 10px 12px; border-radius: 8px;
  background: rgba(72, 201, 255, 0.08); border: 1px solid rgba(72, 201, 255, 0.18);
  color: var(--text); font-size: 0.78rem; line-height: 1.5;
}
.plan-objects {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 8px;
}
.plan-objects li {
  padding: 8px 12px; border-radius: 8px; font-size: 0.8rem;
  background: rgba(72, 201, 255, 0.06); border: 1px solid rgba(72, 201, 255, 0.2);
  color: var(--text);
}
.plan-actions {
  display: grid; gap: 6px;
}
.plan-btn {
  padding: 8px 12px; border-radius: 8px; border: 1px solid;
  font-size: 0.8rem; font-weight: 600; cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}
.btn-primary {
  border-color: rgba(122, 247, 228, 0.5);
  background: rgba(122, 247, 228, 0.1); color: var(--accent);
}
.btn-primary:hover { background: rgba(122, 247, 228, 0.16); border-color: var(--accent); }
.btn-secondary {
  border-color: rgba(72, 201, 255, 0.3);
  background: rgba(72, 201, 255, 0.06); color: var(--text);
}
.btn-secondary:hover { background: rgba(72, 201, 255, 0.12); border-color: rgba(72, 201, 255, 0.5); }
.btn-ghost {
  border-color: rgba(76, 133, 196, 0.2);
  background: transparent; color: var(--muted);
}
.btn-ghost:hover { background: rgba(255,255,255,0.04); color: var(--text); }

.build-steps-section,
.scene-validation-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.camera-bookmark-panel {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 7;
  width: min(284px, calc(100% - 32px));
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(98, 146, 214, 0.24);
  background:
    radial-gradient(circle at top left, rgba(122, 247, 228, 0.1), transparent 28%),
    linear-gradient(180deg, rgba(8, 17, 31, 0.94), rgba(6, 13, 24, 0.92));
  box-shadow:
    inset 0 1px 0 rgba(180, 224, 255, 0.06),
    0 24px 50px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(14px);
}

.camera-bookmark-panel.is-dragging {
  cursor: grabbing;
  box-shadow:
    inset 0 1px 0 rgba(180, 224, 255, 0.08),
    0 28px 58px rgba(0, 0, 0, 0.42);
}

.camera-bookmark-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(122, 160, 206, 0.16);
  cursor: grab;
  user-select: none;
}

.camera-bookmark-panel-eyebrow {
  margin: 0 0 4px;
  color: #8daecc;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.camera-bookmark-panel-title {
  margin: 0;
  color: #f4fbff;
  font-size: 0.92rem;
  font-weight: 600;
  text-wrap: balance;
}

.camera-bookmark-panel-hint {
  flex: 0 0 auto;
  padding: 0.24rem 0.58rem;
  border-radius: 999px;
  border: 1px solid rgba(122, 247, 228, 0.16);
  background: rgba(122, 247, 228, 0.08);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.build-steps-list,
.challenge-prompt-list,
.camera-bookmark-list {
  display: grid;
  gap: 11px;
}

.compact-heading { margin-top: 14px; }

.build-step-card,
.challenge-prompt-card,
.camera-bookmark-btn {
  border: 1px solid rgba(76, 133, 196, 0.18);
  border-radius: 10px;
  background: rgba(8, 18, 34, 0.72);
}

.build-step-card {
  padding: 10px 12px;
  display: grid;
  gap: 8px;
}

.build-step-card.is-active {
  border-color: rgba(122, 247, 228, 0.42);
  box-shadow: inset 0 0 0 1px rgba(122, 247, 228, 0.1);
}

.build-step-card.is-complete {
  border-color: rgba(122, 247, 228, 0.26);
  background: rgba(122, 247, 228, 0.06);
}

.build-step-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.build-step-title {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
}

.build-step-state {
  color: var(--accent);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.build-step-instruction,
.build-step-hint,
.build-step-feedback {
  margin: 0;
  font-size: 0.76rem;
  line-height: 1.45;
  color: var(--muted);
}

.build-step-feedback.is-good { color: var(--accent); }
.build-step-feedback.is-warn { color: #ffd966; }

.build-step-actions {
  display: flex;
  gap: 6px;
}

.step-card-btn,
.camera-bookmark-btn {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.step-card-btn {
  border: 1px solid rgba(122, 247, 228, 0.24);
  background: rgba(122, 247, 228, 0.08);
}

.camera-bookmark-btn {
  text-align: left;
  border: 1px solid rgba(76, 133, 196, 0.22);
  background: linear-gradient(180deg, rgba(10, 23, 40, 0.96), rgba(7, 16, 30, 0.96));
  box-shadow: inset 0 1px 0 rgba(126, 214, 255, 0.06);
}

.step-card-btn:hover,
.camera-bookmark-btn:hover {
  border-color: rgba(122, 247, 228, 0.44);
  transform: translateY(-1px);
}

.camera-bookmark-btn:hover {
  background: linear-gradient(180deg, rgba(16, 38, 62, 0.98), rgba(9, 22, 39, 0.98));
  box-shadow: inset 0 1px 0 rgba(182, 236, 255, 0.12), 0 12px 22px rgba(0, 0, 0, 0.24);
}

.challenge-prompt-card {
  padding: 10px 12px;
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.45;
}

.voice-transcript {
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(76, 133, 196, 0.18);
  background: rgba(8, 18, 34, 0.72);
  font-size: 0.76rem;
  line-height: 1.5;
}

.live-challenge-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.live-challenge-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 217, 102, 0.24);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(38, 28, 9, 0.96), rgba(24, 18, 8, 0.96)),
    radial-gradient(circle at top right, rgba(255, 217, 102, 0.14), transparent 36%);
}

.live-challenge-title {
  margin: 0;
  color: #ffe699;
  font-size: 0.9rem;
  font-weight: 600;
}

.live-challenge-prompt {
  margin: 0;
  color: var(--text);
  font-size: 0.78rem;
  line-height: 1.5;
}

.live-challenge-metric {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.live-challenge-stat {
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 217, 102, 0.16);
  background: rgba(255, 255, 255, 0.04);
}

.live-challenge-stat-label {
  display: block;
  margin-bottom: 4px;
  color: rgba(255, 245, 214, 0.72);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.live-challenge-stat-value {
  color: #fff5d6;
  font-size: 0.82rem;
  font-weight: 600;
}

.live-challenge-progress {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.live-challenge-progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffd966, #fff2a6);
}

.build-status-note {
  margin-top: 10px;
}

.scene-validation {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.validation-stat {
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid rgba(76, 133, 196, 0.18);
  background: rgba(8, 18, 34, 0.72);
  color: var(--muted);
  font-size: 0.76rem;
}

.validation-stat strong {
  color: var(--text);
}

/* Chat Section */
.chat-section {
  flex: 1; display: flex; flex-direction: column; min-height: 0;
  padding: 0; border-bottom: none;
}

.lesson-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(76, 133, 196, 0.18);
  border-radius: 16px;
  background:
    radial-gradient(circle at top right, rgba(122, 247, 228, 0.08), transparent 28%),
    linear-gradient(180deg, rgba(8, 18, 34, 0.92), rgba(5, 14, 27, 0.94));
  box-shadow: inset 0 1px 0 rgba(126, 214, 255, 0.06);
}
.lesson-hero {
  display: grid;
  gap: 6px;
}
.lesson-headline {
  margin: 0;
  font-family: "Exo 2", "Space Grotesk", sans-serif;
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--text);
}
.lesson-message {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.55;
}
.lesson-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.lesson-block {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(76, 133, 196, 0.16);
  background: rgba(255, 255, 255, 0.04);
}
.lesson-block-label,
.lesson-panel-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.lesson-block-value,
.lesson-panel-text {
  margin: 0;
  color: var(--text);
  font-size: 0.8rem;
  line-height: 1.55;
}
.lesson-panel {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 217, 102, 0.14);
  background: rgba(255, 217, 102, 0.04);
}
.prediction-input-wrap {
  display: flex;
  gap: 8px;
}
.lesson-actions {
  padding: 0;
  border-top: none;
}
.lesson-details {
  border: 1px solid rgba(76, 133, 196, 0.16);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  overflow: hidden;
}
.lesson-details-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  cursor: pointer;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
  list-style: none;
}
.lesson-details-toggle::-webkit-details-marker { display: none; }
.lesson-details-body {
  margin: 0;
  padding: 0 12px 12px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.55;
}
.transcript-messages {
  padding-top: 0;
  max-height: 220px;
}
.lesson-follow-up {
  padding-top: 0;
  border-top: none;
}

/* Shape Controls */
.shape-controls-section { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.shape-controls { display: grid; gap: 10px; }

/* Object Section */
.object-section { padding: 14px 16px; border-bottom: 1px solid var(--line); }

/* Transform editor */
.transform-card {
  margin-top: 6px; padding: 8px; border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 8px;
  background: linear-gradient(180deg, rgba(188, 188, 188, 0.1), rgba(128, 128, 128, 0.06)), rgba(24, 30, 38, 0.94);
}
.dimension-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}
.dimension-field-wrap {
  display: grid;
  gap: 6px;
}
.dimension-slider-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.dimension-label {
  color: rgba(235, 241, 247, 0.84);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.dimension-value {
  color: #ffe39c;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.dimension-field {
  width: 100%;
  min-width: 0;
  height: 8px;
  padding: 0;
  border: none;
  border-radius: 999px;
  appearance: none;
  background: linear-gradient(90deg, rgba(122, 247, 228, 0.28), rgba(255, 209, 102, 0.36));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  cursor: pointer;
}
.dimension-field::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(7, 17, 29, 0.92);
  border-radius: 50%;
  background: #ffd166;
  box-shadow: 0 0 0 3px rgba(255, 209, 102, 0.18);
}
.dimension-field::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(7, 17, 29, 0.92);
  border-radius: 50%;
  background: #ffd166;
  box-shadow: 0 0 0 3px rgba(255, 209, 102, 0.18);
}
.dimension-field::-moz-range-track {
  height: 8px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(122, 247, 228, 0.28), rgba(255, 209, 102, 0.36));
}
.dimension-field:focus-visible {
  outline: 2px solid rgba(255, 209, 102, 0.34);
  outline-offset: 3px;
}
.transform-grid { display: grid; grid-template-columns: 64px repeat(3, minmax(0, 1fr)); gap: 5px; align-items: center; margin-bottom: 5px; }
.transform-grid:last-child { margin-bottom: 0; }
.transform-grid-head { margin-bottom: 6px; }
.transform-grid-head span { color: rgba(222, 231, 241, 0.72); font-size: 0.64rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; text-align: center; }
.transform-spacer { opacity: 0; }
.transform-label { color: rgba(235, 241, 247, 0.92); font-size: 0.74rem; font-weight: 600; }
.transform-field {
  width: 100%; min-width: 0; height: 26px; padding: 0 6px;
  border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 4px;
  background: rgba(241, 241, 241, 0.06); color: #f2f6fa; font-size: 0.74rem; text-align: center;
}
.transform-field:focus-visible { outline: 1px solid rgba(122, 247, 228, 0.54); border-color: rgba(122, 247, 228, 0.32); }

/* ============ VIEWPORT PANEL ============ */
.viewport-panel {
  min-width: 0; min-height: 0;
  background: linear-gradient(180deg, rgba(2, 8, 21, 0.98), rgba(3, 10, 24, 0.98));
}
.stage-wrap {
  position: relative; width: 100%; height: 100%; min-height: 0; overflow: hidden;
  background:
    radial-gradient(circle at 50% 38%, rgba(10, 26, 46, 0.82), rgba(4, 12, 24, 0.96) 52%, rgba(2, 8, 20, 1) 100%),
    linear-gradient(180deg, rgba(4, 12, 24, 0.96), rgba(2, 8, 20, 1));
  box-shadow: inset 0 0 0 1px rgba(80, 139, 207, 0.14), inset 0 0 64px rgba(0, 0, 0, 0.46);
}
.stage-wrap::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(circle at 50% 22%, rgba(122, 247, 228, 0.1), transparent 26%),
    radial-gradient(circle at 18% 8%, rgba(72, 201, 255, 0.08), transparent 18%),
    radial-gradient(circle at 82% 16%, rgba(39, 113, 255, 0.08), transparent 22%);
  pointer-events: none; z-index: 0;
}
.stage, #overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage { z-index: 2; }
#worldMount canvas { position: absolute; inset: 0; z-index: 2; cursor: grab; filter: saturate(1.08) contrast(1.05); }
#worldMount canvas:active { cursor: grabbing; }
#overlay { pointer-events: none; z-index: 4; opacity: 0.92; mix-blend-mode: screen; }
.stage-wrap[data-representation-mode="split_2d"] .stage,
.stage-wrap[data-representation-mode="split_2d"] #overlay {
  right: min(392px, calc(100vw - 24px));
}
.stage-wrap[data-representation-mode="2d"] .stage,
.stage-wrap[data-representation-mode="2d"] #overlay {
  right: min(492px, calc(100vw - 24px));
}
.stage-wrap[data-representation-mode="2d"] #worldMount canvas {
  opacity: 0.24;
  filter: saturate(0.72) contrast(0.9);
}
.stage-wrap[data-representation-mode="2d"] #overlay {
  opacity: 0.18;
}
#webcam {
  position: absolute; right: 14px; bottom: 12px; z-index: 5;
  pointer-events: none; width: 130px;
  border: 1px solid rgba(122, 247, 228, 0.24); border-radius: 12px;
  background: rgba(6, 18, 32, 0.82);
  box-shadow: 0 0 0 1px rgba(72, 201, 255, 0.12), 0 14px 24px rgba(0, 0, 0, 0.28);
  opacity: 0.78; transform: scaleX(-1);
}
.scene-reset-btn {
  position: absolute; top: 12px; right: 12px; z-index: 6;
  border: 1px solid rgba(109, 219, 255, 0.48); border-radius: 8px;
  background: linear-gradient(180deg, rgba(10, 28, 46, 0.92), rgba(7, 18, 34, 0.92));
  color: #b9edff; font-size: 0.72rem; padding: 0.4rem 0.72rem; cursor: pointer;
  backdrop-filter: blur(10px);
}
.scene-reset-btn:hover { border-color: rgba(132, 231, 255, 0.8); color: #e6f8ff; }
.mouse-place-menu {
  position: absolute; z-index: 7; min-width: 160px; padding: 0.36rem;
  border: 1px solid rgba(98, 202, 255, 0.34); border-radius: 12px;
  background: linear-gradient(180deg, rgba(8, 24, 42, 0.96), rgba(5, 15, 30, 0.96));
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.34); backdrop-filter: blur(12px);
}
.mouse-place-action {
  width: 100%; border: 1px solid rgba(120, 216, 255, 0.18); border-radius: 8px;
  background: linear-gradient(180deg, rgba(12, 34, 56, 0.94), rgba(9, 24, 42, 0.94));
  color: #d8f6ff; font: 600 0.8rem/1 "Space Grotesk", sans-serif; text-align: left;
  padding: 0.6rem 0.8rem; cursor: pointer;
}
.mouse-place-action:hover { border-color: rgba(132, 231, 255, 0.36); color: #f3fcff; }
.unfold-drawer {
  position: absolute;
  top: 12px;
  right: 12px;
  bottom: 12px;
  width: min(360px, calc(100vw - 32px));
  z-index: 8;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(122, 247, 228, 0.24);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(7, 16, 30, 0.96), rgba(5, 14, 26, 0.96)),
    radial-gradient(circle at top right, rgba(122, 247, 228, 0.1), transparent 36%);
  box-shadow: 0 24px 44px rgba(0, 0, 0, 0.44);
  backdrop-filter: blur(18px);
}
.unfold-drawer[data-representation-mode="split_2d"] {
  width: min(380px, calc(100vw - 32px));
  border-color: rgba(255, 217, 102, 0.24);
}
.unfold-drawer[data-representation-mode="2d"] {
  width: min(480px, calc(100vw - 32px));
  border-color: rgba(255, 217, 102, 0.28);
  box-shadow: 0 24px 52px rgba(0, 0, 0, 0.54);
}
.unfold-drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid rgba(76, 133, 196, 0.16);
}
.unfold-drawer-head h2 {
  margin: 4px 0 0;
  font-family: "Exo 2", "Space Grotesk", sans-serif;
  font-size: 1rem;
}
.unfold-close-btn {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(122, 247, 228, 0.16);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.unfold-drawer-body {
  flex: 1;
  overflow-y: auto;
  display: grid;
  gap: 12px;
  padding: 16px;
}
.unfold-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.unfold-stat {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(76, 133, 196, 0.16);
  background: rgba(255, 255, 255, 0.04);
}
.unfold-stat-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.unfold-stat-value {
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 600;
}
.unfold-formula,
.unfold-breakdown,
.unfold-net {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(76, 133, 196, 0.16);
  background: rgba(255, 255, 255, 0.04);
}
.unfold-formula {
  color: #ffe699;
  font-size: 0.84rem;
  line-height: 1.5;
}
.unfold-breakdown {
  display: grid;
  gap: 6px;
  color: var(--text);
  font-size: 0.78rem;
  line-height: 1.5;
}
.unfold-breakdown-item {
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
}
.unfold-net svg {
  width: 100%;
  height: auto;
  display: block;
}
.unfold-net-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.6;
}

/* Chat-first tutor (clean, minimal) */
.chat-lesson-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 18px 16px !important;
  overflow: hidden;
  background: transparent;
}

/* Stage rail (subtle inline progress) */
.stage-rail {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(76, 133, 196, 0.12);
  border-radius: 16px;
  background: rgba(6, 15, 28, 0.54);
}
.stage-rail-step-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px; height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid rgba(122, 247, 228, 0.2);
  background: rgba(122, 247, 228, 0.06);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.stage-rail-goal {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.4;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stage-rail-next {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(72, 201, 255, 0.28);
  background: rgba(72, 201, 255, 0.1);
  color: #d9f7ff;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}
.stage-rail-next:hover {
  background: rgba(72, 201, 255, 0.16);
  border-color: rgba(72, 201, 255, 0.44);
  transform: translateY(-1px);
}
.stage-rail-next:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

/* Formula card & solution drawer (non-intrusive) */
.formula-card,
.solution-drawer {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 217, 102, 0.12);
  border-radius: 12px;
  background: rgba(15, 21, 34, 0.6);
  animation: slideDown 200ms ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.formula-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.formula-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.formula-card-dismiss {
  width: 24px; height: 24px;
  border: none; border-radius: 6px;
  background: transparent; color: var(--muted);
  font-size: 1rem; cursor: pointer;
  transition: color 120ms;
}
.formula-card-dismiss:hover { color: var(--text); }
.formula-card-title {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
}
.formula-card-equation {
  margin: 0;
  color: #ffd966;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.84rem;
  line-height: 1.45;
  overflow-x: auto;
}
.formula-card-copy {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}
.solution-drawer-answer {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 217, 102, 0.16);
  background: rgba(33, 26, 8, 0.34);
}
.solution-drawer-answer-value {
  color: #fff5cc;
  overflow-x: auto;
}
.solution-drawer-steps {
  display: grid;
  gap: 6px;
  max-height: min(30vh, 240px);
  overflow-y: auto;
  padding-right: 2px;
}
.solution-step {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(76, 133, 196, 0.1);
  background: rgba(7, 16, 30, 0.5);
}
.solution-step-index {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.solution-step h4 {
  margin: 0 0 4px;
  font-size: 0.78rem;
}
.solution-step-formula {
  margin: 0 0 4px;
  color: #ffd966;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.76rem;
  line-height: 1.4;
  overflow-x: auto;
}
.solution-step-copy {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.4;
}
.chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 6px 0;
  scrollbar-gutter: stable;
}
.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  flex: 1;
  gap: 8px;
  padding: 12px 4px 18px;
  text-align: left;
}
.chat-welcome-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--text);
  text-wrap: balance;
}
.chat-welcome-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
  max-width: 34ch;
}
.chat-msg {
  display: flex;
  max-width: 100%;
  animation: msgFadeIn 180ms ease;
}
@keyframes msgFadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.chat-msg-bubble {
  max-width: min(94%, 380px);
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 0.82rem;
  line-height: 1.58;
  border: none;
  background: rgba(8, 18, 34, 0.7);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03), 0 10px 22px rgba(0, 0, 0, 0.16);
}
.chat-msg.is-tutor {
  justify-content: flex-start;
}
.chat-msg.is-tutor .chat-msg-bubble {
  background: linear-gradient(180deg, rgba(12, 24, 42, 0.9), rgba(8, 18, 32, 0.92));
  border-left: 2px solid rgba(122, 247, 228, 0.34);
}
.chat-msg.is-user {
  justify-content: flex-end;
}
.chat-msg.is-user .chat-msg-bubble {
  background: rgba(27, 52, 78, 0.7);
}
.chat-msg.is-system {
  justify-content: center;
}
.chat-msg.is-system .chat-msg-bubble {
  max-width: min(100%, 340px);
  background: transparent;
  border: none;
  color: var(--muted);
  text-align: center;
  font-size: 0.72rem;
  padding: 4px 8px;
}
.chat-msg-text {
  margin: 0;
}
.chat-msg-paragraph {
  margin: 0;
  color: #f2fbff;
}
.chat-msg-paragraph + .chat-msg-paragraph {
  margin-top: 0.45rem;
}
.chat-msg-paragraph strong,
.chat-msg-list strong {
  color: #ffffff;
  font-weight: 700;
}
.chat-msg-display-math {
  margin: 0.18rem 0;
  overflow-x: auto;
}
.chat-msg-paragraph .katex-display,
.chat-msg-display-math .katex-display,
.formula-card-equation .katex-display,
.solution-step-formula .katex-display,
.solution-drawer-answer-value .katex-display,
.composer-math-preview .katex-display {
  margin: 0.35rem 0;
}
.formula-card-copy .chat-msg-paragraph,
.formula-card-copy .chat-msg-list li,
.solution-step-copy .chat-msg-paragraph,
.solution-step-copy .chat-msg-list li,
.composer-math-preview .chat-msg-paragraph,
.composer-math-preview .chat-msg-list li {
  color: inherit;
}
.chat-msg-paragraph .katex,
.chat-msg-display-math .katex,
.formula-card-equation .katex,
.solution-step-formula .katex,
.solution-drawer-answer-value .katex,
.composer-math-preview .katex {
  font-size: 1em;
}
.chat-msg-list {
  margin: 0;
  padding-left: 1.05rem;
  display: grid;
  gap: 0.38rem;
}
.chat-msg-paragraph + .chat-msg-list,
.chat-msg-list + .chat-msg-paragraph {
  margin-top: 0.5rem;
}
.chat-msg-list li {
  color: #f2fbff;
}
.chat-msg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.tutor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 8px;
  border-top: 0.5px solid var(--color-border-tertiary, rgba(229, 231, 235, 0.12));
}
.chat-action-chip,
.tutor-action-btn {
  padding: 6px 10px;
  border: 1px solid rgba(122, 247, 228, 0.18);
  border-radius: 999px;
  cursor: pointer;
  background: transparent;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 500;
  transition: background 140ms, border-color 140ms;
}
.chat-action-chip:hover,
.tutor-action-btn:hover {
  background: rgba(122, 247, 228, 0.08);
  border-color: rgba(122, 247, 228, 0.3);
}
.chat-action-chip:disabled,
.tutor-action-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.tutor-btn {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  border: 0.5px solid var(--color-border-secondary, rgba(229, 231, 235, 0.18));
  background: var(--color-background-primary, rgba(8, 18, 34, 0.7));
  color: var(--color-text-primary, #f2fbff);
  transition: background 0.15s, opacity 0.15s;
}
.tutor-btn:hover {
  background: var(--color-background-secondary, rgba(12, 24, 42, 0.92));
}
.tutor-btn--secondary {
  background: transparent;
}
.tutor-btn--primary {
  background: var(--accent-color, #6366f1);
  color: #ffffff;
  border-color: transparent;
}
.tutor-btn--primary:hover {
  opacity: 0.9;
}
.tutor-btn--danger-muted {
  background: var(--color-danger-subtle, rgba(239, 68, 68, 0.08));
  color: var(--color-danger-muted, #b91c1c);
  border-color: var(--color-danger-subtle, rgba(239, 68, 68, 0.15));
}

/* Checkpoint (subtle inline prompt) */
.chat-checkpoint {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(122, 247, 228, 0.12);
  background: rgba(122, 247, 228, 0.04);
  animation: slideDown 200ms ease;
}
.chat-checkpoint-prompt {
  margin: 0;
  font-size: 0.76rem;
  color: var(--text);
  flex: 1;
}
.chat-checkpoint-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.plan-btn.btn-secondary,
.plan-btn.btn-ghost {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 500;
}
.plan-btn.btn-secondary {
  border: 1px solid rgba(122, 247, 228, 0.24);
  background: rgba(122, 247, 228, 0.08);
  color: var(--accent);
}
.plan-btn.btn-ghost {
  border: 1px solid rgba(76, 133, 196, 0.18);
  background: transparent;
  color: var(--muted);
}

/* Composer (streamlined) */
.chat-composer {
  display: grid;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid rgba(76, 133, 196, 0.12);
  border: none;
  background: transparent;
}
.chat-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border: 1px solid rgba(76, 133, 196, 0.16);
  border-radius: 16px;
  background: rgba(6, 14, 26, 0.72);
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}
.chat-input-wrap:focus-within {
  border-color: rgba(122, 247, 228, 0.3);
  box-shadow: 0 0 0 1px rgba(122, 247, 228, 0.14), 0 18px 34px rgba(0, 0, 0, 0.18);
  background: rgba(6, 14, 26, 0.82);
}
.chat-input {
  flex: 1;
  min-width: 0;
  min-height: 38px;
  max-height: 132px;
  padding: 8px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.45;
  resize: none;
  font-family: inherit;
}
.chat-input::placeholder { color: var(--muted); font-size: 0.78rem; }
.chat-input:focus-visible { outline: none; }
.input--awaiting {
  border-left: 2px solid transparent;
  animation: awaiting-pulse 2s ease-in-out infinite;
}
@keyframes awaiting-pulse {
  0%, 100% {
    border-left-color: var(--accent-color, #6366f1);
  }
  50% {
    border-left-color: transparent;
  }
}
.chat-input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.voice-control {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}
.mic-ring {
  position: absolute;
  inset: 1px;
  pointer-events: none;
}
.chat-send-btn {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  background: rgba(122, 247, 228, 0.08);
  color: var(--accent);
  font-size: 0.82rem;
  flex-shrink: 0;
  transition: background 120ms ease, transform 120ms ease;
}
.chat-send-btn:hover {
  background: rgba(122, 247, 228, 0.16);
  transform: translateY(-1px);
}
.chat-send-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.chat-send-btn:focus-visible {
  outline: 2px solid rgba(122, 247, 228, 0.24);
  outline-offset: 2px;
}
.voice--listening .mic-ring {
  animation: voice-ring-pulse 1.5s ease-in-out infinite;
  border: 2px solid var(--color-info, #3b82f6);
  border-radius: 50%;
}
@keyframes voice-ring-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.6; }
}
.voice--processing .mic-ring {
  border: 2px solid #9ca3af;
  border-radius: 50%;
}
.voice-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
}
.voice-bars span {
  display: inline-block;
  width: 3px;
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  border-radius: 2px;
  animation: bar-bounce 0.8s ease-in-out infinite;
}
.voice-bars span:nth-child(1) { height: 8px; }
.voice-bars span:nth-child(2) {
  height: 14px;
  animation-delay: 0.15s;
}
.voice-bars span:nth-child(3) {
  height: 8px;
  animation-delay: 0.3s;
}
@keyframes bar-bounce {
  0%, 100% { transform: scaleY(0.5); }
  50% { transform: scaleY(1.2); }
}
.beat {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0;
  color: var(--color-muted, #6b7280);
  font-size: 12px;
}
.beat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e5e7eb;
  flex-shrink: 0;
  transition: background 0.3s;
}
.beat.done .beat-dot {
  background: var(--accent-color, #6366f1);
}
.beat.done {
  color: var(--color-text, #111827);
}

/* ============ 3D LABELS (CSS2DRenderer) ============ */
.label-renderer { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 3; }
.scene-label {
  padding: 4px 9px; border-radius: 10px; font-size: 0.72rem;
  font-family: "Space Grotesk", sans-serif; font-weight: 600;
  white-space: nowrap; pointer-events: none;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
  transform: translate(-50%, -115%);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.26);
  backdrop-filter: blur(8px);
}
.scene-label--dimension { color: #fff; background: rgba(5, 12, 24, 0.72); border: 1px solid rgba(255,255,255,0.2); }
.scene-label--name { color: var(--accent); background: rgba(4, 16, 28, 0.8); border: 1px solid rgba(122, 247, 228, 0.34); font-size: 0.78rem; }
.scene-label--formula { color: #ffd966; background: rgba(28, 20, 4, 0.78); border: 1px solid rgba(255, 217, 102, 0.32); }
.scene-label--annotation { color: var(--text); background: rgba(4, 12, 24, 0.72); border: 1px solid rgba(122, 160, 206, 0.18); }
.scene-label--normal {
  color: #ffe38f;
  background: linear-gradient(180deg, rgba(56, 40, 8, 0.92), rgba(24, 17, 5, 0.9));
  border: 1px solid rgba(255, 217, 102, 0.52);
  letter-spacing: 0.04em;
  font-weight: 700;
}
.scene-label--intersection {
  color: #fff5b7;
  background: linear-gradient(180deg, rgba(58, 34, 10, 0.94), rgba(28, 14, 4, 0.92));
  border: 1px solid rgba(255, 217, 102, 0.62);
  box-shadow: 0 0 0 1px rgba(255, 217, 102, 0.14), 0 0 22px rgba(255, 209, 102, 0.22);
}
.scene-label--anchor {
  color: #ffd4e2;
  background: linear-gradient(180deg, rgba(43, 12, 25, 0.92), rgba(19, 7, 12, 0.92));
  border: 1px solid rgba(255, 124, 168, 0.44);
}
.scene-label--callout {
  max-width: 22ch;
  white-space: normal;
  text-align: center;
  line-height: 1.35;
}
.scene-label--axis {
  box-shadow: none;
  backdrop-filter: none;
}
.scene-label--tick {
  padding: 1px 5px;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 700;
  color: rgba(229, 243, 255, 0.86);
  background: rgba(4, 12, 24, 0.18);
  border: 1px solid rgba(122, 160, 206, 0.12);
  transform: translate(-50%, -105%);
}

/* ============ LOADING STATES ============ */
.loading-dots::after {
  content: ""; animation: dots 1.4s steps(4, end) infinite;
}
@keyframes dots {
  0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; }
}

/* ============ TOAST NOTIFICATIONS ============ */
.toast-container {
  position: fixed; top: 16px; right: 16px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 10px 18px; border-radius: 10px; font-size: 0.82rem; font-weight: 500;
  max-width: 380px; pointer-events: auto;
  transform: translateX(120%); opacity: 0;
  transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1), opacity 280ms ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.toast--visible { transform: translateX(0); opacity: 1; }
.toast--info {
  background: rgba(9, 24, 42, 0.95); color: var(--accent-strong);
  border: 1px solid rgba(72, 201, 255, 0.3);
}
.toast--success {
  background: rgba(9, 30, 24, 0.95); color: var(--accent);
  border: 1px solid rgba(122, 247, 228, 0.3);
}
.toast--error {
  background: rgba(30, 9, 16, 0.95); color: var(--danger);
  border: 1px solid rgba(255, 124, 168, 0.3);
}

.hidden { display: none !important; }

.evidence-panel {
  overflow: hidden;
  transition: max-height 0.4s ease, opacity 0.3s ease;
  max-height: 0;
  opacity: 0;
}

.evidence--visible {
  max-height: 600px;
  opacity: 1;
}

.evidence--hidden {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  padding: 0;
  margin: 0;
}
.evidence-panel .agent-trace-card {
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(98, 146, 214, 0.22);
  background:
    radial-gradient(circle at top right, rgba(108, 124, 255, 0.12), transparent 30%),
    linear-gradient(180deg, rgba(8, 17, 31, 0.94), rgba(6, 13, 24, 0.9));
  box-shadow:
    inset 0 1px 0 rgba(180, 224, 255, 0.06),
    0 22px 48px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(14px);
}
.evidence-panel-media-frame,
.evidence-panel-source-card {
  min-height: 118px;
  border-radius: 14px;
  border: 1px solid rgba(122, 160, 206, 0.16);
  background: linear-gradient(180deg, rgba(12, 24, 42, 0.88), rgba(7, 15, 28, 0.82));
}
.evidence-panel-media-frame {
  overflow: hidden;
}
.evidence-panel-image {
  width: 100%;
  height: 118px;
  display: block;
  object-fit: cover;
}
.evidence-panel-source-card {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 12px;
}
.evidence-panel-source-copy {
  margin: 0;
  color: #c9d9e8;
  font-size: 0.78rem;
  line-height: 1.45;
}
.evidence-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.evidence-panel-score {
  flex: 0 0 auto;
  padding: 0.24rem 0.54rem;
  border-radius: 999px;
  border: 1px solid rgba(122, 247, 228, 0.18);
  background: rgba(122, 247, 228, 0.08);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.evidence-panel-summary {
  margin: 0;
  color: #dcebf8;
  font-size: 0.88rem;
  font-style: italic;
  font-weight: 500;
  line-height: 1.45;
}
.evidence-panel-divider {
  height: 1px;
  background: linear-gradient(90deg, rgba(122, 160, 206, 0.18), rgba(122, 247, 228, 0.12), transparent);
}
.evidence-panel-match {
  display: block;
  color: #f7fbff;
  font-size: 1.02rem;
  line-height: 1.25;
}
.evidence-panel-empty {
  color: #9cb8d3;
}

.formula-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-tertiary, #9ca3af);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 6px;
}

.formula-card {
  background: var(--color-background-secondary, rgba(12, 24, 42, 0.92));
  border: 0.5px solid var(--color-border-tertiary, rgba(229, 231, 235, 0.12));
  border-radius: 8px;
  padding: 12px 14px;
  margin: 8px 0;
}

.formula-display {
  overflow-x: auto;
}

.solution-step {
  padding: 10px 12px;
  border-left: 2px solid var(--color-border-secondary, #e5e7eb);
  margin: 8px 0;
  border-radius: 0 6px 6px 0;
}

.solution-step .step-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-tertiary, #9ca3af);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 2px;
}

.step-description {
  font-size: 13px;
  color: var(--color-text-secondary, #6b7280);
  display: block;
  margin-bottom: 6px;
}

.step-description .chat-msg-paragraph,
.step-result .chat-msg-paragraph,
.solution-prose .chat-msg-paragraph {
  color: inherit;
}

.step-description .chat-msg-paragraph + .chat-msg-paragraph,
.step-result .chat-msg-paragraph + .chat-msg-paragraph,
.solution-prose .chat-msg-paragraph + .chat-msg-paragraph {
  margin-top: 0.35rem;
}

.step-math {
  overflow-x: auto;
}

.step-result {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-primary, var(--text));
  display: block;
  margin-top: 4px;
}

.solution-answer {
  padding: 12px 14px;
  background: var(--color-background-success-subtle, rgba(34, 197, 94, 0.08));
  border: 0.5px solid var(--color-border-success, rgba(34, 197, 94, 0.2));
  border-radius: 8px;
  margin-top: 12px;
}

.answer-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-success, #15803d);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 6px;
}

.answer-math {
  font-size: 16px;
  overflow-x: auto;
}

.solution-prose {
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text-secondary, #6b7280);
  margin: 0 0 8px;
}

.formula-display .katex-display,
.step-math .katex-display,
.answer-math .katex-display {
  margin: 0.35rem 0;
}

.formula-display .katex,
.step-math .katex,
.answer-math .katex {
  font-size: 1em;
}
@keyframes blink { 50% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1200px) {
  :root { --left-w: clamp(340px, 34vw, 412px); }
}
@media (max-width: 1000px) {
  .topbar {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }
  .topbar-tools {
    justify-content: flex-start;
  }
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(360px, 48vh) minmax(0, 1fr);
  }
  .viewport-panel {
    order: 1;
    min-height: 360px;
  }
  .left-panel {
    order: 2;
    border-right: 0;
    border-top: 1px solid var(--line);
    max-height: none;
  }
  .lesson-grid { grid-template-columns: 1fr; }
  .chat-lesson-shell {
    min-height: 0;
  }
  .camera-bookmark-panel {
    width: min(320px, calc(100% - 24px));
  }
  .unfold-drawer {
    left: 12px;
    width: auto;
  }
  .stage-wrap[data-representation-mode="split_2d"] .stage,
  .stage-wrap[data-representation-mode="split_2d"] #overlay,
  .stage-wrap[data-representation-mode="2d"] .stage,
  .stage-wrap[data-representation-mode="2d"] #overlay {
    right: 0;
  }
  .stage-wrap[data-representation-mode="2d"] #worldMount canvas {
    opacity: 0.46;
  }
}
@media (max-width: 640px) {
  body {
    overflow: auto;
  }
  .app-shell {
    min-height: 100dvh;
    height: auto;
  }
  .topbar {
    padding: 10px;
  }
  .brand-lockup {
    padding-right: 0;
  }
  .tool-cluster {
    gap: 3px;
    width: 100%;
    justify-content: space-between;
  }
  .tool-btn { width: 32px; height: 32px; }
  .workspace {
    grid-template-rows: minmax(300px, 42vh) minmax(0, 1fr);
  }
  .tab-content > section,
  .question-section,
  .chat-lesson-shell {
    padding-inline: 14px !important;
  }
  .question-input-wrap {
    padding: 12px;
  }
  .camera-bookmark-panel,
  .scene-reset-btn {
    right: 12px;
  }
  .camera-bookmark-panel {
    left: 12px;
    width: auto;
  }
  .evidence-panel {
    width: calc(100% - 24px);
    top: 12px;
    left: 12px;
  }
  .evidence-panel-grid {
    grid-template-columns: 1fr;
  }
  .evidence-panel-media-frame,
  .evidence-panel-source-card {
    min-height: auto;
  }
  .evidence-panel-image {
    height: 96px;
  }
  .chat-input-wrap,
  .chat-checkpoint-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .voice-control,
  .chat-send-btn {
    width: 100%;
  }
  .chat-msg-bubble { max-width: 100%; }
}
