/* style.css */
:root {
  color-scheme: dark;
  --bg: #10172b;
  --bg-soft: #151f38;
  --card: #18243f;
  --card-2: #1d2c4b;
  --graph-bg: #111c32;
  --ink: #f4f7ff;
  --muted: #aebbd3;
  --faint: #7584a2;
  --border: #314363;
  --grid: #273958;
  --coral: #ff7d72;
  --green: #68e0aa;
  --cyan: #58caef;
  --yellow: #ffc85b;
  --shadow: 0 14px 35px rgba(0, 0, 0, .22);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef3fb;
  --bg-soft: #e3ebf8;
  --card: #ffffff;
  --card-2: #f6f9ff;
  --graph-bg: #fbfdff;
  --ink: #18233c;
  --muted: #53637d;
  --faint: #7584a2;
  --border: #cbd8eb;
  --grid: #dee7f4;
  --shadow: 0 14px 35px rgba(39, 61, 100, .12);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg: #eef3fb;
    --bg-soft: #e3ebf8;
    --card: #ffffff;
    --card-2: #f6f9ff;
    --graph-bg: #fbfdff;
    --ink: #18233c;
    --muted: #53637d;
    --faint: #7584a2;
    --border: #cbd8eb;
    --grid: #dee7f4;
  }
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% -15%, rgba(88, 202, 239, .13), transparent 34rem),
    radial-gradient(circle at 8% 18%, rgba(255, 125, 114, .09), transparent 28rem),
    var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
}

h1, h2, h3, p { margin-top: 0; }
h2 { line-height: 1.12; letter-spacing: -.03em; }
h3 { line-height: 1.2; }

.topbar {
  max-width: 1280px;
  margin: auto;
  padding: 18px 20px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: #241a21;
  background: linear-gradient(135deg, var(--coral), #f0a15d);
  box-shadow: 0 8px 22px rgba(255, 125, 114, .22);
  font-size: 26px;
  font-weight: 800;
}

h1 {
  margin-bottom: 0;
  font-size: 1.28rem;
  line-height: 1;
}

.eyebrow,
.kicker {
  margin: 0 0 5px;
  color: var(--cyan);
  font-size: .71rem;
  font-weight: 800;
  letter-spacing: .13em;
}

.kicker { color: var(--yellow); }

.icon-btn,
.secondary-btn,
.primary-btn,
.text-btn,
.complete-btn,
.load-story {
  min-height: 44px;
  border-radius: 10px;
  font-weight: 750;
}

.icon-btn {
  padding: 0 14px;
  color: var(--ink);
  border: 1px solid var(--border);
  background: transparent;
}

main {
  max-width: 1280px;
  margin: auto;
  padding: 10px 20px 34px;
}

.card {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(255,255,255,.035), transparent 60%), var(--card);
  box-shadow: var(--shadow);
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 22px;
  padding: 25px;
}

.hero h2 {
  max-width: 760px;
  margin-bottom: 12px;
  font-size: clamp(1.65rem, 4vw, 2.85rem);
}

.hero h2 em {
  color: var(--coral);
  font-style: normal;
}

.hero-copy {
  max-width: 710px;
  margin-bottom: 0;
  color: var(--muted);
}

.hero-stats {
  display: flex;
  flex-shrink: 0;
  gap: 12px;
}

.stat {
  min-width: 108px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-soft);
}

.stat strong {
  display: block;
  color: var(--yellow);
  font-size: 1.35rem;
}

.stat span {
  color: var(--muted);
  font-size: .76rem;
}

.lesson-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 20px 0;
  padding-bottom: 3px;
}

.nav-tab {
  min-height: 44px;
  padding: 0 16px;
  white-space: nowrap;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  font-weight: 750;
}

.nav-tab.active {
  color: #092434;
  border-color: var(--cyan);
  background: var(--cyan);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.lab-layout {
  display: grid;
  grid-template-columns: minmax(245px, 310px) minmax(0, 1fr);
  gap: 18px;
}

.controls { padding: 20px; }

.section-heading h2 {
  margin-bottom: 20px;
  font-size: 1.28rem;
}

.controls label,
.controls legend {
  color: var(--muted);
  font-size: .88rem;
  font-weight: 700;
}

select {
  width: 100%;
  min-height: 48px;
  margin: 7px 0 13px;
  padding: 0 10px;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
}

.story-box {
  margin-bottom: 19px;
  padding: 14px;
  border-left: 3px solid var(--coral);
  border-radius: 0 10px 10px 0;
  background: var(--bg-soft);
}

.story-box p {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: .88rem;
}

.story-box .story-title {
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 800;
}

code {
  display: inline-block;
  padding: 4px 7px;
  color: var(--yellow);
  border-radius: 6px;
  background: rgba(255, 200, 91, .09);
  font-size: .82rem;
}

.control-group { margin: 16px 0; }

.label-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

output {
  color: var(--cyan);
  font-size: .83rem;
  font-weight: 800;
}

input[type="range"] {
  width: 100%;
  min-height: 33px;
  accent-color: var(--coral);
}

.view-options {
  margin: 18px 0;
  padding: 12px 10px 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.view-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
}

.view-options input {
  width: 17px;
  height: 17px;
  accent-color: var(--green);
}

.secondary-btn {
  width: 100%;
  padding: 0 13px;
  color: var(--ink);
  border: 1px solid var(--border);
  background: var(--bg-soft);
}

.primary-btn {
  padding: 0 18px;
  color: #082b24;
  border: 1px solid var(--green);
  background: var(--green);
}

.secondary-btn:hover,
.icon-btn:hover { border-color: var(--cyan); }

.visual-workspace {
  min-width: 0;
  padding: 20px;
}

.graph-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 15px;
}

.graph-header h2 {
  margin-bottom: 8px;
  font-size: 1.35rem;
}

.drag-hint {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: .8rem;
  text-align: right;
}

.canvas-wrap {
  position: relative;
  overflow: hidden;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--graph-bg);
}

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

.graph-legend {
  position: absolute;
  top: 9px;
  right: 10px;
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 8px;
  color: var(--muted);
  font-size: .7rem;
  pointer-events: none;
}

.graph-legend span {
  padding: 3px 5px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--graph-bg) 82%, transparent);
}

.swatch {
  display: inline-block;
  width: 13px;
  height: 3px;
  margin-right: 3px;
  vertical-align: middle;
  border-radius: 3px;
}

.swatch.function { background: var(--coral); }
.swatch.tangent { background: var(--green); }
.swatch.secant { background: var(--yellow); }
.swatch.derivative { background: var(--cyan); }

.readout-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 9px;
  margin-top: 13px;
}

.readout {
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
}

.readout-label {
  display: block;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.readout strong {
  display: block;
  margin: 4px 0;
  overflow-wrap: anywhere;
  font-size: .92rem;
}

.readout small {
  color: var(--faint);
  font-size: .72rem;
}

.readout.accent strong { color: var(--green); }
.readout.warm strong { color: var(--yellow); }
.area-readout strong { color: var(--cyan); }

.translation {
  margin-top: 13px;
  padding: 13px 15px;
  border-left: 3px solid var(--green);
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(104,224,170,.1), transparent);
}

.translation p:last-child {
  margin: 0;
  color: var(--ink);
}

.math-steps,
.explorer-grid {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.math-steps { grid-template-columns: repeat(3, 1fr); }
.explorer-grid { grid-template-columns: repeat(3, 1fr); }

.explain-card {
  position: relative;
  padding: 22px;
}

.explain-card h3 {
  padding-right: 25px;
  margin-bottom: 10px;
}

.explain-card p {
  color: var(--muted);
  font-size: .92rem;
}

.number {
  position: absolute;
  top: 15px;
  right: 18px;
  color: var(--border);
  font-size: 2.4rem;
  font-weight: 900;
  line-height: 1;
}

.math-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: .75rem;
}

.math-line strong {
  color: var(--coral);
  font-size: 1.25rem;
}

.mini-diagram {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--cyan);
  font-size: .78rem;
  font-weight: 700;
}

.mini-diagram span {
  padding: 5px;
  border: 1px solid var(--cyan);
  border-radius: 5px;
}

.mini-diagram b { color: var(--yellow); }

.slice-row {
  display: flex;
  align-items: end;
  height: 34px;
  margin-bottom: 10px;
}

.slice-row i {
  display: block;
  width: 12%;
  margin-right: 2px;
  background: var(--yellow);
  opacity: .8;
}

.slice-row i:nth-child(1) { height: 15%; }
.slice-row i:nth-child(2) { height: 30%; }
.slice-row i:nth-child(3) { height: 47%; }
.slice-row i:nth-child(4) { height: 68%; }
.slice-row i:nth-child(5) { height: 82%; }
.slice-row i:nth-child(6) { height: 92%; }
.slice-row i:nth-child(7) { height: 97%; }
.slice-row i:nth-child(8) { height: 100%; }

.text-btn {
  min-height: 35px;
  padding: 0;
  color: var(--cyan);
  border: 0;
  border-bottom: 1px solid var(--cyan);
  border-radius: 0;
  background: transparent;
}

.mini-lab {
  min-width: 0;
  padding: 20px;
}

.mini-lab-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.mini-lab-heading h2 {
  margin-bottom: 7px;
  font-size: 1.2rem;
}

.mini-lab > p:not(.mini-message) {
  min-height: 65px;
  color: var(--muted);
  font-size: .88rem;
}

.limit-stage {
  position: relative;
  height: 142px;
  margin: 12px 0 13px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 11px;
  background:
    linear-gradient(transparent 49%, var(--grid) 50%, transparent 51%),
    var(--graph-bg);
}

.limit-axis {
  position: absolute;
  top: 12%;
  bottom: 11%;
  left: 20%;
  width: 1px;
  background: var(--grid);
}

.limit-curve {
  position: absolute;
  top: 28%;
  left: 11%;
  width: 83%;
  height: 54%;
  border-top: 4px solid var(--coral);
  border-radius: 50%;
  transform: rotate(var(--bend, 18deg));
}

.limit-secant {
  position: absolute;
  z-index: 2;
  height: 2px;
  transform-origin: left center;
  background: var(--yellow);
  box-shadow: 0 0 0 1px rgba(255, 200, 91, .16);
}

.limit-dot {
  position: absolute;
  z-index: 3;
  width: 13px;
  height: 13px;
  border: 2px solid var(--graph-bg);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.dot-a { background: var(--coral); }
.dot-b { background: var(--yellow); }

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.metric-row div {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
}

.metric-row span,
.speedometer span {
  display: block;
  color: var(--faint);
  font-size: .67rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.metric-row strong {
  display: block;
  margin-top: 2px;
  overflow-wrap: anywhere;
  color: var(--yellow);
  font-size: .9rem;
}

.metric-row div:nth-child(2) strong { color: var(--green); }

.mini-message {
  min-height: 43px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: .82rem;
}

#sliceCanvas {
  height: 190px;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--graph-bg);
}

.motion-lab { display: flex; flex-direction: column; }

.road-stage {
  position: relative;
  height: 122px;
  margin: 11px 0 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: linear-gradient(180deg, rgba(88, 202, 239, .08), transparent 58%), var(--graph-bg);
}

.road-line {
  position: absolute;
  right: 0;
  bottom: 31px;
  left: 0;
  height: 8px;
  background: repeating-linear-gradient(90deg, var(--yellow) 0 25px, transparent 25px 42px);
  opacity: .85;
}

.car-shape {
  position: absolute;
  bottom: 39px;
  left: 3%;
  width: 48px;
  height: 22px;
  border-radius: 6px 10px 4px 4px;
  background: var(--coral);
  transition: left .04s linear;
}

.car-shape::before {
  position: absolute;
  top: -10px;
  left: 11px;
  width: 25px;
  height: 13px;
  border-radius: 8px 8px 1px 1px;
  background: var(--cyan);
  content: "";
}

.car-shape i,
.car-shape b {
  position: absolute;
  bottom: -6px;
  width: 11px;
  height: 11px;
  border: 3px solid var(--graph-bg);
  border-radius: 50%;
  background: var(--ink);
}

.car-shape i { left: 5px; }
.car-shape b { right: 5px; }

.milepost {
  position: absolute;
  bottom: 8px;
  color: var(--faint);
  font-size: .7rem;
}

.start-post { left: 8px; }
.end-post { right: 8px; }

.motion-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px;
}

.compact-btn {
  width: auto;
  min-width: 80px;
}

.speedometer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
}

.speedometer strong {
  display: block;
  color: var(--green);
  font-size: .98rem;
}

.speed-arc {
  position: relative;
  flex: 0 0 72px;
  width: 72px;
  height: 37px;
  overflow: hidden;
  border: 5px solid var(--cyan);
  border-bottom: 0;
  border-radius: 72px 72px 0 0;
}

.needle {
  position: absolute;
  right: 50%;
  bottom: 0;
  width: 29px;
  height: 3px;
  border-radius: 4px;
  transform: rotate(-72deg);
  transform-origin: right center;
  background: var(--coral);
  transition: transform .05s linear;
}

.intro {
  margin-bottom: 18px;
  padding: 25px;
}

.intro h2 {
  margin-bottom: 8px;
  font-size: clamp(1.5rem, 3vw, 2.25rem);
}

.intro p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

.idea-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

.idea-card { padding: 21px; }

.idea-card p {
  min-height: 70px;
  color: var(--muted);
}

.idea-example {
  min-height: 66px;
  margin-bottom: 15px;
  padding: 10px 11px;
  color: var(--muted);
  border-left: 2px solid var(--cyan);
  border-radius: 0 8px 8px 0;
  background: var(--bg-soft);
  font-size: .82rem;
}

.idea-example strong { color: var(--ink); }

.idea-visual {
  display: flex;
  align-items: center;
  height: 56px;
  margin-bottom: 14px;
}

.limits-visual { gap: 6px; }

.limits-visual span {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--coral);
}

.limits-visual span:nth-child(2) { transform: translateX(9px); opacity: .8; }
.limits-visual span:nth-child(3) { transform: translateX(15px); opacity: .65; }
.limits-visual span:nth-child(4) { transform: translateX(18px); opacity: .45; }
.limits-visual span:nth-child(5) {
  width: 20px;
  height: 20px;
  transform: translateX(22px);
  background: var(--yellow);
}

.slope-visual {
  position: relative;
  border-bottom: 2px solid var(--border);
}

.slope-visual i {
  display: block;
  width: 150px;
  height: 3px;
  transform: rotate(-18deg);
  background: var(--green);
}

.slope-visual b {
  width: 12px;
  height: 12px;
  margin-left: -70px;
  border-radius: 50%;
  background: var(--coral);
}

.area-visual {
  align-items: end;
  gap: 3px;
  border-bottom: 1px solid var(--border);
}

.area-visual i {
  display: block;
  width: 24px;
  background: var(--yellow);
}

.area-visual i:nth-child(1) { height: 12px; }
.area-visual i:nth-child(2) { height: 20px; }
.area-visual i:nth-child(3) { height: 31px; }
.area-visual i:nth-child(4) { height: 39px; }
.area-visual i:nth-child(5) { height: 45px; }
.area-visual i:nth-child(6) { height: 49px; }

.chain-visual {
  gap: 9px;
  color: var(--yellow);
  font-weight: 800;
}

.chain-visual span {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
}

.chain-visual b { color: var(--cyan); }

.complete-btn,
.load-story {
  padding: 0 12px;
  color: var(--cyan);
  border: 1px solid var(--cyan);
  background: transparent;
}

.complete-btn.done {
  color: #102d25;
  border-color: var(--green);
  background: var(--green);
}

.analogy,
.glossary-card,
.prompt-card {
  margin-top: 18px;
  padding: 23px;
}

.analogy h2,
.glossary-card h2,
.prompt-card h2 { margin-bottom: 18px; }

.analogy-grid,
.glossary-grid,
.prompt-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.analogy-grid div,
.glossary-grid div,
.prompt-grid div {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-soft);
}

.analogy-grid strong,
.analogy-grid span,
.analogy-grid b,
.prompt-grid strong,
.prompt-grid span {
  display: block;
}

.analogy-grid span,
.prompt-grid span {
  margin: 5px 0;
  color: var(--muted);
}

.analogy-grid b { color: var(--yellow); }

.glossary-grid {
  grid-template-columns: repeat(4, 1fr);
}

.glossary-grid div {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 13px;
}

.glossary-grid span {
  color: var(--muted);
  font-size: .82rem;
}

.stories-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.story-card { padding: 20px; }

.story-number {
  color: var(--coral);
  font-weight: 900;
  letter-spacing: .1em;
}

.story-card h3 { margin: 6px 0; }

.story-card p {
  min-height: 88px;
  color: var(--muted);
}

.story-card p strong { color: var(--ink); }

.load-story {
  color: var(--ink);
  border-color: var(--border);
  background: var(--bg-soft);
}

.load-story:hover {
  color: var(--coral);
  border-color: var(--coral);
}

.prompt-grid { grid-template-columns: repeat(3, 1fr); }

.prompt-grid strong { color: var(--yellow); }

.quiz-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 18px;
}

.quiz-card,
.score-card { padding: 25px; }

.quiz-card h2 {
  max-width: 700px;
  font-size: clamp(1.4rem, 3vw, 2.05rem);
}

.answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 20px 0;
}

.answer-btn {
  min-height: 56px;
  padding: 10px 13px;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
  text-align: left;
}

.answer-btn:hover:not(:disabled) { border-color: var(--cyan); }

.answer-btn.correct {
  color: #0a2d20;
  border-color: var(--green);
  background: var(--green);
}

.answer-btn.incorrect {
  color: #3a1721;
  border-color: var(--coral);
  background: var(--coral);
}

.quiz-feedback {
  min-height: 48px;
  color: var(--muted);
}

.quiz-feedback.success { color: var(--green); }
.quiz-feedback.try-again { color: var(--yellow); }

.score-card strong {
  display: block;
  margin: 8px 0;
  color: var(--yellow);
  font-size: 2.3rem;
}

.score-card p { color: var(--muted); }

.score-progress {
  height: 8px;
  overflow: hidden;
  margin: 16px 0;
  border-radius: 999px;
  background: var(--bg-soft);
}

.score-progress i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width .3s ease;
}

footer {
  max-width: 1280px;
  margin: auto;
  padding: 0 20px 30px;
  color: var(--faint);
  font-size: .82rem;
}

@media (max-width: 1080px) {
  .explorer-grid { grid-template-columns: 1fr 1fr; }
  .motion-lab { grid-column: 1 / -1; }
  .glossary-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
  .lab-layout { grid-template-columns: 1fr; }

  .controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 18px;
  }

  .controls .section-heading,
  .controls > label,
  .controls > select,
  .controls .story-box,
  .controls > button {
    grid-column: 1 / -1;
  }

  .math-steps { grid-template-columns: 1fr; }
  .stories-grid { grid-template-columns: repeat(2, 1fr); }
  .readout-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
  .topbar,
  main { padding-right: 14px; padding-left: 14px; }

  .hero {
    display: block;
    padding: 20px;
  }

  .hero-stats {
    margin-top: 18px;
    gap: 7px;
  }

  .stat {
    flex: 1;
    min-width: 0;
    padding: 10px;
  }

  .controls { display: block; }
  .graph-header { display: block; }
  .drag-hint { text-align: left; }
  .graph-legend { max-width: 190px; }

  .idea-grid,
  .stories-grid,
  .quiz-layout,
  .analogy-grid,
  .prompt-grid,
  .explorer-grid {
    grid-template-columns: 1fr;
  }

  .motion-lab { grid-column: auto; }
  .answers { grid-template-columns: 1fr; }

  .idea-card p,
  .story-card p,
  .mini-lab > p:not(.mini-message) { min-height: auto; }

  .visual-workspace,
  .controls,
  .quiz-card,
  .score-card,
  .mini-lab { padding: 16px; }

  .glossary-grid { grid-template-columns: 1fr; }
}

@media (max-width: 390px) {
  .readout-grid { grid-template-columns: 1fr; }
  .nav-tab { padding: 0 12px; }
  .metric-row { grid-template-columns: 1fr; }
}
