/* ==========================================================================
   SHM & Mechanical Waves Interactive Lab — Navy Classroom Projection Theme
   Zero external URLs, offline-first, 4-viewport responsive & projection mode.
   ========================================================================== */

:root {
  /* Author-approved navy classroom projection palette */
  --navy: #1F2A44;
  --navy-hover: #2A3859;
  --navy-deep: #151E33;
  --navy-muted-text: #C9D3E6;

  --amber: #F2A900;
  --amber-border: #92400E;
  --amber-soft: #FEF7E0;

  --crimson: #C00000;
  --crimson-soft: #FDF2F2;

  --blue: #1F4E9C;
  --blue-soft: #EFF5FF;

  --green: #15803D;
  --green-soft: #ECFDF3;

  --teal: #0D9488;
  --teal-soft: #ECFEFF;

  --bg-page: #F4F6FA;
  --bg-card: #FFFFFF;
  --bg-tint: #EEF2F8;
  --border: #B8C2D6;
  --border-soft: #CBD5E1;
  --ink: #1E293B;
  --ink-muted: #5A6478;
  --ghost: #64748B;

  /* Typography & sizing tokens */
  --font-ui: "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", "Heiti SC", system-ui, -apple-system, sans-serif;
  --font-math: "STIX Two Math", "Cambria Math", "Times New Roman", "Liberation Serif", Times, Georgia, serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Liberation Mono", "DejaVu Sans Mono", monospace;

  --base-font: 15px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --shadow-card: 0 1px 3px rgba(31, 42, 68, 0.08), 0 1px 2px rgba(31, 42, 68, 0.04);
  --shadow-popover: 0 12px 28px rgba(21, 30, 51, 0.22);

  --canvas-h: clamp(320px, 49vh, 490px);
  --canvas-dual-h: clamp(190px, 25vh, 260px);
}

html:has(body.projection-mode) {
  --base-font: 17.7px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  font-size: var(--base-font);
  overflow-x: clip;
  max-width: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg-page);
  overflow-x: clip;
  max-width: 100%;
}

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

button:focus-visible,
input:focus-visible {
  outline: 2.5px solid var(--amber);
  outline-offset: 2px;
}

/* ==================== Top Navigation Bar ==================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--navy);
  color: #FFFFFF;
  border-bottom: 2px solid var(--navy-deep);
  box-shadow: 0 2px 8px rgba(21, 30, 51, 0.18);
}

.topbar-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
}

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

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--amber);
  color: var(--navy-deep);
  font-family: var(--font-math);
  font-style: italic;
  font-weight: 700;
  font-size: 1.05rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-title {
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.brand-badge {
  font-size: 0.72rem;
  color: var(--navy-muted-text);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(201, 211, 230, 0.25);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1 1 auto;
  justify-content: center;
}

.nav-tab {
  appearance: none;
  border: 1px solid rgba(201, 211, 230, 0.26);
  background: rgba(255, 255, 255, 0.06);
  color: var(--navy-muted-text);
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.nav-tab:hover {
  background: var(--navy-hover);
  color: #FFFFFF;
}

.nav-tab.is-active,
.nav-tab[aria-selected="true"] {
  background: #FFFFFF;
  color: var(--navy);
  border-color: #FFFFFF;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}

.topbar-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--ink);
  padding: 6px 11px;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.btn:hover {
  background: var(--bg-tint);
  border-color: var(--navy);
}

.btn-chrome {
  background: rgba(255, 255, 255, 0.1);
  color: #FFFFFF;
  border-color: rgba(201, 211, 230, 0.35);
}

.btn-chrome:hover {
  background: var(--navy-hover);
  border-color: #FFFFFF;
  color: #FFFFFF;
}

.btn-chrome[aria-pressed="true"],
.btn-chrome[aria-expanded="true"] {
  background: var(--amber);
  color: var(--navy-deep);
  border-color: var(--amber-border);
}

.btn-primary {
  background: var(--navy);
  color: #FFFFFF;
  border-color: var(--navy);
  min-width: 72px;
}

.btn-primary:hover {
  background: var(--navy-hover);
  border-color: var(--navy-hover);
  color: #FFFFFF;
}

.btn-primary[aria-pressed="true"] {
  background: var(--amber);
  color: var(--navy-deep);
  border-color: var(--amber-border);
}

.btn-secondary {
  background: var(--bg-tint);
  color: var(--navy);
  border-color: var(--border);
}

.btn-step {
  padding: 5px 9px;
  font-size: 0.84rem;
}

.btn-chip {
  padding: 4px 8px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--bg-card);
  color: var(--ink);
}

.btn-chip.is-active,
.btn-chip[aria-pressed="true"] {
  background: var(--navy);
  color: #FFFFFF;
  border-color: var(--navy);
}

/* Shortcuts Popover */

.shortcuts-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 300px;
  background: var(--bg-card);
  color: var(--ink);
  border: 1.5px solid var(--navy);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popover);
  padding: 12px 14px;
  z-index: 60;
}

.shortcuts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-soft);
}

.shortcuts-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--navy);
}

.shortcuts-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
  font-size: 0.84rem;
}

.shortcuts-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-tint);
  color: var(--navy);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
}

/* ==================== Main Workspace Layout ==================== */

.app-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 14px 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  min-width: 0;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 70fr) minmax(0, 30fr);
  gap: 16px;
  align-items: start;
}

.stage-column {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.stage-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stage-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 12px;
}

.module-title {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--navy);
}

.module-subtitle {
  margin: 0;
  font-size: 0.86rem;
  color: var(--ink-muted);
}

.live-formula-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 7px 11px;
  background: var(--bg-tint);
  border: 1px solid var(--border-soft);
  border-left: 3.5px solid var(--navy);
  border-radius: var(--radius-sm);
  min-height: 40px;
  overflow-x: auto;
  max-width: 100%;
}

/* Stage Viewport & Canvases */

.stage-viewport {
  min-width: 0;
  width: 100%;
}

.stage-panel {
  width: 100%;
  min-width: 0;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  height: var(--canvas-h);
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.dual-canvas-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dual-canvas-slot {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.canvas-slot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--navy);
  padding: 0 2px;
}

.canvas-slot-hint {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-muted);
}

.canvas-wrap-dual {
  position: relative;
  width: 100%;
  height: var(--canvas-dual-h);
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.stage-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

/* ==================== Global Transport Bar ==================== */

.transport-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 10px;
  padding: 8px 10px;
  background: var(--bg-tint);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
}

.transport-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.transport-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-muted);
  margin-right: 2px;
  white-space: nowrap;
}

.time-readout {
  padding: 5px 10px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--navy);
  white-space: nowrap;
}

.time-period {
  color: var(--ink-muted);
  font-weight: 500;
}

/* ==================== Telemetry Readout Grid ==================== */

.telemetry-bar {
  min-width: 0;
}

.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 8px;
}

.telemetry-tile {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-top: 2.5px solid var(--navy);
  border-radius: var(--radius-sm);
  padding: 6px 9px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.telemetry-tile.tone-blue {
  border-top-color: var(--blue);
}

.telemetry-tile.tone-crimson {
  border-top-color: var(--crimson);
}

.telemetry-tile.tone-green {
  border-top-color: var(--green);
}

.telemetry-tile.tone-amber {
  border-top-color: var(--amber);
}

.telemetry-tile.tone-teal {
  border-top-color: var(--teal);
}

.telemetry-tile.tile-wide {
  grid-column: span 2;
}

.telemetry-label {
  font-size: 0.76rem;
  color: var(--ink-muted);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.telemetry-value {
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

/* ==================== Right Control & Pedagogical Rail ==================== */

.control-rail {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.rail-card {
  padding: 12px 13px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rail-heading {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--navy);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-soft);
}

/* Presets Bar */

.preset-bar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.preset-btn {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-tint);
  color: var(--navy);
  padding: 6px 8px;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  line-height: 1.3;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.preset-btn:hover {
  background: #E2E9F5;
  border-color: var(--navy);
}

.preset-btn.is-active {
  background: var(--navy);
  color: #FFFFFF;
  border-color: var(--navy);
}

/* Control Groups, Segmented Toggles, Sliders & Switches */

.controls-group {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.control-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-section-tag {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--navy);
  background: var(--bg-tint);
  border-left: 3px solid var(--navy);
  padding: 3px 8px;
  border-radius: 3px;
}

.control-section-tag.tag-blue {
  border-left-color: var(--blue);
  color: var(--blue);
  background: var(--blue-soft);
}

.control-section-tag.tag-teal {
  border-left-color: var(--teal);
  color: var(--teal);
  background: var(--teal-soft);
}

.control-section-tag.tag-amber {
  border-left-color: var(--amber);
  color: var(--amber-border);
  background: var(--amber-soft);
}

.submode-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.seg-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 3px;
  background: var(--bg-tint);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}

.seg-btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-muted);
  padding: 6px 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.seg-btn:hover {
  color: var(--navy);
  background: rgba(255, 255, 255, 0.7);
}

.seg-btn.is-active,
.seg-btn[aria-pressed="true"] {
  background: var(--navy);
  color: #FFFFFF;
  border-color: var(--navy);
}

.slider-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.slider-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.83rem;
}

.slider-head label {
  font-weight: 600;
  color: var(--ink);
}

.slider-output {
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
  margin: 0;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: var(--border-soft);
  border: 1px solid var(--border);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--navy);
  border: 2px solid #FFFFFF;
  box-shadow: 0 1px 3px rgba(21, 30, 51, 0.35);
  margin-top: -6px;
}

input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: var(--border-soft);
  border: 1px solid var(--border);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--navy);
  border: 2px solid #FFFFFF;
  box-shadow: 0 1px 3px rgba(21, 30, 51, 0.35);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.chip-row .btn-chip {
  flex: 1 1 auto;
}

.notice-badge {
  font-size: 0.77rem;
  font-weight: 600;
  color: var(--amber-border);
  background: var(--amber-soft);
  border: 1px solid rgba(146, 64, 14, 0.25);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
}

/* Native Visible Toggle Switch (Playwright-actionable real checkbox box) */

.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-page);
  border: 1px solid var(--border-soft);
  font-size: 0.83rem;
  font-weight: 500;
  cursor: pointer;
}

.toggle-row:hover {
  border-color: var(--border);
}

.toggle-text {
  min-width: 0;
  flex: 1 1 auto;
}

.toggle-switch {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
  margin: 0;
  border-radius: 999px;
  background: var(--border);
  border: 1px solid var(--ghost);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.toggle-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 1px 2px rgba(21, 30, 51, 0.28);
  transition: transform 0.15s ease;
}

.toggle-switch:checked {
  background: var(--navy);
  border-color: var(--navy);
}

.toggle-switch:checked::after {
  transform: translateX(16px);
}

/* Comparison Particle Q Panel (always visible; subtly muted when off) */

.compare-q-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 9px;
  border-radius: var(--radius-sm);
  background: var(--teal-soft);
  border: 1px solid rgba(13, 148, 136, 0.3);
  transition: opacity 0.15s ease;
}

.compare-q-box.is-muted .compare-q-controls {
  opacity: 0.72;
}

.compare-q-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Keypoints Card */

.keypoints-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.83rem;
  color: var(--ink);
}

.keypoints-list li strong {
  color: var(--navy);
}

/* ==================== Below-the-Fold Deepening Section ==================== */

.deepening-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.compare-table-card,
.quiz-section {
  padding: 16px 18px;
}

.section-heading {
  margin: 0 0 10px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--navy);
}

.section-desc {
  margin: -4px 0 12px;
  font-size: 0.86rem;
  color: var(--ink-muted);
}

.table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

.compare-table {
  width: 100%;
  min-width: 580px;
  border-collapse: collapse;
  font-size: 0.88rem;
}

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

.compare-table thead th {
  background: var(--navy);
  color: #FFFFFF;
  font-weight: 700;
}

.compare-table tbody tr:nth-child(even) {
  background: var(--bg-page);
}

.compare-table tbody th {
  background: var(--bg-tint);
  color: var(--navy);
  font-weight: 700;
  width: 18%;
  white-space: nowrap;
}

/* Misconception Micro-Check Grid (populated in M3) */

.quiz-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.quiz-card {
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.quiz-stem {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--navy);
}

.quiz-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.quiz-option {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #FFFFFF;
  color: var(--ink);
  padding: 7px 9px;
  text-align: left;
  font-size: 0.83rem;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease;
}

.quiz-option:hover {
  background: var(--bg-tint);
  border-color: var(--navy);
}

.quiz-option.is-correct {
  background: var(--green-soft);
  border-color: var(--green);
  color: var(--green);
  font-weight: 700;
}

.quiz-option.is-wrong {
  background: var(--crimson-soft);
  border-color: var(--crimson);
  color: var(--crimson);
  font-weight: 600;
}

.quiz-feedback {
  font-size: 0.83rem;
  line-height: 1.5;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: #FFFFFF;
  border-left: 3px solid var(--navy);
  color: var(--ink);
}

.quiz-feedback.is-correct {
  border-left-color: var(--green);
  background: var(--green-soft);
}

.quiz-feedback.is-wrong {
  border-left-color: var(--crimson);
  background: var(--crimson-soft);
}

.quiz-actions {
  display: flex;
  justify-content: flex-end;
}

.quiz-verify-btn {
  appearance: none;
  border: 1px solid var(--amber-border);
  border-radius: var(--radius-sm);
  background: var(--amber-soft);
  color: var(--amber-border);
  padding: 5px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.quiz-verify-btn:hover {
  background: var(--amber);
  color: var(--navy-deep);
}

/* ==================== Semantic HTML/CSS Math Typography ==================== */

.math-expr {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  font-size: 0.98rem;
  color: var(--ink);
  line-height: 1.35;
}

.math-inline {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
}

.math-clause {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
}

.math-sep {
  color: var(--border);
  margin: 0 2px;
  user-select: none;
}

.math-cond {
  font-size: 0.88em;
  color: var(--ink-muted);
  margin-left: 3px;
}

.var {
  font-family: var(--font-math);
  font-style: italic;
  font-weight: 400;
  padding-right: 0.04em;
}

.op-greek {
  font-family: var(--font-math);
  font-style: normal;
  font-weight: 400;
}

.fn {
  font-family: var(--font-math);
  font-style: normal;
  font-weight: 400;
  margin-right: 0.08em;
}

.op {
  font-family: var(--font-math);
  font-style: normal;
  padding: 0 0.08em;
}

.num {
  font-variant-numeric: tabular-nums;
  font-style: normal;
}

.unit {
  font-family: var(--font-ui);
  font-style: normal;
  font-size: 0.9em;
  font-weight: 500;
}

.unit-deg {
  margin-left: 0;
}

sub,
sup {
  font-style: normal;
  font-size: 0.72em;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

sub {
  bottom: -0.24em;
}

sup {
  top: -0.44em;
}

.sub-zh {
  font-family: var(--font-ui);
  font-size: 0.7em;
}

.frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  line-height: 1.05;
  margin: 0 0.14em;
  font-size: 0.86em;
}

.frac-num {
  border-bottom: 1px solid currentColor;
  padding: 0 0.2em 0.08em;
  text-align: center;
}

.frac-den {
  padding: 0.08em 0.2em 0;
  text-align: center;
}

.sqrt {
  display: inline-flex;
  align-items: stretch;
  vertical-align: middle;
  margin: 0 0.08em;
}

.sqrt-sign {
  font-family: var(--font-math);
  font-style: normal;
  font-size: 1.18em;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  padding-right: 1px;
}

.sqrt-body {
  border-top: 1px solid currentColor;
  padding: 0.08em 0.2em 0 0.12em;
  display: inline-flex;
  align-items: center;
}

.math-vec {
  position: relative;
  display: inline-block;
  padding-top: 0.16em;
}

.math-vec::before {
  content: "\2192";
  position: absolute;
  top: -0.42em;
  left: 50%;
  transform: translateX(-50%) scaleX(0.85);
  font-size: 0.68em;
  font-style: normal;
  line-height: 1;
  pointer-events: none;
}

.math-hl {
  display: inline-flex;
  align-items: baseline;
  padding: 0 4px;
  border-radius: 4px;
  font-weight: 700;
}

.hl-navy {
  color: var(--navy);
  background: rgba(31, 42, 68, 0.09);
}

.hl-amber {
  color: var(--amber-border);
  background: var(--amber-soft);
}

.hl-crimson {
  color: var(--crimson);
  background: var(--crimson-soft);
}

.hl-blue {
  color: var(--blue);
  background: var(--blue-soft);
}

.hl-green {
  color: var(--green);
  background: var(--green-soft);
}

.hl-teal {
  color: var(--teal);
  background: var(--teal-soft);
}

/* ==================== Classroom Projection Mode ==================== */

body.projection-mode {
  --base-font: 17.7px;
  --canvas-h: clamp(340px, 54vh, 560px);
  --canvas-dual-h: clamp(210px, 28vh, 300px);
  font-size: 17.7px;
}

body.projection-mode .app-shell {
  max-width: 100%;
  padding: 10px 14px 16px;
}

body.projection-mode .workspace-grid {
  grid-template-columns: minmax(0, 76fr) minmax(276px, 24fr);
  gap: 14px;
}

body.projection-mode .card {
  border-width: 1.5px;
}

body.projection-mode .btn,
body.projection-mode .seg-btn {
  min-height: 36px;
}

body.projection-mode .telemetry-value {
  font-size: 1.12rem;
}

body.projection-mode .brand-badge,
body.projection-mode .keypoints-card,
body.projection-mode .deepening-section,
body.projection-mode .quiz-section,
body.projection-mode .compare-table-card {
  display: none !important;
}

/* ==================== Responsive Breakpoints ==================== */

/* 1280x720 Projector / Compact Laptop */
@media (max-width: 1320px) {
  :root {
    --canvas-h: clamp(300px, 46vh, 440px);
    --canvas-dual-h: clamp(180px, 24vh, 240px);
  }

  .topbar-inner {
    padding: 6px 12px;
    gap: 8px;
  }

  .brand-badge {
    display: none;
  }

  .nav-tab {
    padding: 5px 9px;
    font-size: 0.84rem;
  }

  .app-shell {
    padding: 10px 12px 20px;
  }
}

/* 768x1024 Tablet */
@media (max-width: 1024px) {
  .topbar-inner {
    flex-wrap: wrap;
    padding: 8px 12px;
  }

  .brand {
    order: 1;
  }

  .topbar-actions {
    order: 2;
    margin-left: auto;
  }

  .nav-tabs {
    order: 3;
    flex-basis: 100%;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .nav-tab {
    text-align: center;
    padding: 7px 6px;
    font-size: 0.82rem;
    white-space: normal;
    line-height: 1.25;
  }

  .workspace-grid,
  body.projection-mode .workspace-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .quiz-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* 390x844 Mobile */
@media (max-width: 640px) {
  :root {
    --canvas-h: clamp(280px, 42vh, 360px);
    --canvas-dual-h: clamp(175px, 24vh, 220px);
  }

  .topbar {
    position: static;
  }

  .topbar-inner {
    padding: 8px 10px;
    gap: 8px;
  }

  .brand-title {
    font-size: 0.9rem;
  }

  .topbar-actions .btn {
    padding: 5px 8px;
    font-size: 0.78rem;
  }

  .nav-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app-shell {
    padding: 8px 10px 20px;
    gap: 12px;
  }

  .stage-column,
  .rail-card,
  .compare-table-card,
  .quiz-section {
    padding: 10px;
  }

  .transport-bar {
    padding: 7px 8px;
    gap: 6px;
  }

  .transport-group {
    width: 100%;
    justify-content: flex-start;
  }

  .time-readout {
    width: 100%;
    text-align: center;
  }

  .telemetry-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .telemetry-tile.tile-wide {
    grid-column: span 2;
  }

  .preset-bar,
  .quiz-options {
    grid-template-columns: minmax(0, 1fr);
  }

  .shortcuts-popover {
    position: fixed;
    top: 64px;
    left: 10px;
    right: 10px;
    width: auto;
  }
}
