/* Launchpad (Mission 00): self-contained stylesheet.
   Inherit root design tokens + topbar from the shared sheet, then define
   everything this module needs locally. Accent: Neuronauts green. */
@import url("../styles.css");

:root {
  --accent: #2f7d5b;        /* Launchpad identity: mission-control green */
  --accent-soft: #e6efe0;
  --accent-ink: #173a12;
  --sky: color-mix(in srgb, var(--teal) 14%, var(--panel));
  --butter: #ece6cc;
  --pink: color-mix(in srgb, var(--rose) 14%, white);
  --rail-w: 188px;
}

/* The brand mark gets the module accent */
.topbar .mark {
  display: grid;
  width: 34px; height: 34px;
  place-items: center;
  border-radius: 7px;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 6px 16px rgba(21, 133, 111, .35);
}
nav a { transition: color .18s ease; }
nav a:hover { color: var(--accent); }

button { cursor: pointer; font: inherit; }

/* ---------- Sticky difficulty ladder (level rail) ---------- */
.level-rail {
  position: fixed;
  top: 92px;
  left: 14px;
  z-index: 9;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: var(--rail-w);
  padding: 14px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}
.level-rail a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
  font-size: .92rem;
  transition: background .2s ease, color .2s ease, transform .2s ease;
}
.level-rail a .dot {
  display: grid;
  place-items: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  font-size: .85rem;
  background: #fff;
  transition: all .2s ease;
}
.level-rail a:hover { transform: translateX(2px); }
.level-rail a.active { color: var(--accent-ink); background: var(--accent-soft); }
.level-rail a.active .dot { border-color: var(--accent); color: #fff; background: var(--accent); }
.rail-progress {
  height: 6px;
  margin-top: 6px;
  border-radius: 6px;
  background: var(--line);
  overflow: hidden;
}
.rail-progress i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--accent), #16766c);
  transition: width .25s ease;
}

/* Give the page room for the rail on wide screens */
@media (min-width: 1180px) {
  main { padding-left: calc(var(--rail-w) + 36px); }
}

/* ---------- Layout primitives ---------- */
.hero,
.level {
  padding: clamp(46px, 7vw, 90px) clamp(18px, 4vw, 56px);
}
.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(min(100%, 320px), 1.05fr);
  gap: clamp(26px, 5vw, 64px);
  align-items: center;
  min-height: 640px;
  background:
    radial-gradient(900px 420px at 12% -10%, var(--accent-soft), transparent 60%),
    var(--paper);
}
h1, h2, h3 { margin: 0; line-height: 1.05; letter-spacing: 0; }
h1 { max-width: 900px; font-size: clamp(2.3rem, 5.6vw, 4.8rem); }
h2 { font-size: clamp(1.9rem, 4vw, 3.2rem); }
h3 { font-size: clamp(1.25rem, 2.4vw, 1.8rem); margin: 4px 0 6px; }
h4 { margin: 0; font-size: 1.1rem; }

.lead,
.copy-p {
  max-width: 760px;
  color: var(--muted);
  font-size: clamp(1rem, 1.5vw, 1.15rem);
  line-height: 1.7;
}
.copy-p { margin: 0 0 6px; }
.copy-p em { color: var(--accent-ink); font-style: normal; font-weight: 700; }

.eyebrow {
  margin: 0 0 12px;
  color: var(--rose);
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.note { margin: 8px 2px 0; color: var(--muted); font-size: .86rem; }

.outcomes { display: grid; gap: 9px; margin-top: 22px; }
.outcomes span {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  background: #fff;
  color: var(--muted);
  font-weight: 750;
}

.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 850;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.button:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.button.primary { border-color: var(--accent); color: #fff; background: var(--accent); }

/* ---------- Cards / canvases ---------- */
.canvas-card,
.explain-card,
.example-box,
.math-card,
.code-panel,
.quiz-panel,
.playground,
.softmax-widget {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.canvas-card { padding: 12px; }
canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  background: #f4fbf9;
}

/* ---------- Level sections ---------- */
.level { border-top: 1px solid var(--line); scroll-margin-top: 80px; }
.level.alt {
  background:
    radial-gradient(700px 360px at 90% 0%, var(--accent-soft), transparent 55%),
    #f1f8f6;
}
.level-head { max-width: 980px; margin: 0 auto 20px; text-align: center; }
.level-head .lead { margin-inline: auto; }
.level-badge {
  display: inline-block;
  margin-bottom: 12px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
  font-size: .8rem;
  letter-spacing: .04em;
}

.concept {
  max-width: 1080px;
  margin: 0 auto 34px;
  padding: clamp(18px, 3vw, 30px);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.step-tag {
  display: inline-block;
  margin: 16px 0 8px;
  padding: 3px 10px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.concept > .step-tag:first-child { margin-top: 0; }

/* ---------- Model map (beginner cards) ---------- */
.model-map {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.model-map button {
  min-height: 104px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  transition: transform .15s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.model-map button:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.model-map button strong { display: block; margin-bottom: 6px; font-size: 1.02rem; }
.model-map button span { color: var(--muted); line-height: 1.4; font-size: .9rem; }
.model-map button.active { border-color: var(--accent); background: var(--accent-soft); }

.explain-card { padding: 18px; }
.explain-card strong { display: block; margin-bottom: 8px; color: var(--accent-ink); font-size: 1.05rem; }
.explain-card p { margin: 0; color: var(--muted); line-height: 1.6; }
.explain-card ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); line-height: 1.6; }

.example-box { margin-top: 6px; padding: 16px; background: var(--butter); }
.example-box strong { display: block; margin-bottom: 6px; color: var(--accent-ink); }
.example-box p { margin: 0; color: #6a5a1f; line-height: 1.65; }

/* ---------- Venn / nested sets ---------- */
.venn-wrap { display: grid; grid-template-columns: minmax(0, 360px) 1fr; gap: 20px; align-items: center; }
.venn { width: 100%; max-width: 360px; }
.venn .ring {
  fill: var(--accent);
  fill-opacity: .12;
  stroke: var(--accent);
  stroke-width: 2;
  cursor: pointer;
  transition: fill-opacity .2s ease, stroke-width .2s ease;
}
.venn .ring:hover { fill-opacity: .22; }
.venn .ring.active { fill-opacity: .32; stroke-width: 4; }
.venn .ring-label { fill: var(--accent-ink); font: 800 13px Inter, system-ui, sans-serif; text-anchor: middle; pointer-events: none; }

/* ---------- Tool chooser ---------- */
.chooser-controls,
.robot-loop {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.chooser-controls button,
.robot-loop button {
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  transition: all .15s ease;
}
.chooser-controls button:hover,
.robot-loop button:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.chooser-controls button.active,
.robot-loop button.active { border-color: var(--accent); color: #fff; background: var(--accent); }

/* ---------- Math card ---------- */
.math-card { margin: 14px 0; padding: 18px; }
.math-render { overflow-x: auto; padding: 6px 0 12px; font-size: 1.05rem; }
.math-card figcaption p { margin: 0 0 10px; color: var(--ink); line-height: 1.6; }
.math-card figcaption p strong { color: var(--accent-ink); }
.legend { margin: 0; padding-left: 18px; display: grid; gap: 4px; color: var(--muted); line-height: 1.5; }
.legend strong { color: var(--ink); }

/* ---------- Neuron playground ---------- */
.playground,
.softmax-widget { margin-top: 6px; padding: 18px; }
.playground {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1.2fr;
  gap: 18px;
  align-items: center;
}
.neuron-svg { width: 100%; }
.neuron-svg .wire { stroke: var(--line); stroke-width: 2; transition: stroke .2s ease, stroke-width .2s ease; }
.neuron-svg .node { stroke: var(--accent); stroke-width: 2; }
.neuron-svg .node.in { fill: var(--sky); }
.neuron-svg .node.sum { fill: var(--accent-soft); }
.neuron-svg .node.out { fill: var(--butter); }
.neuron-svg .nlabel { fill: var(--ink); font: 800 12px Inter, system-ui, sans-serif; text-anchor: middle; dominant-baseline: middle; }
.neuron-svg .wlabel { fill: var(--accent-ink); font: 800 11px Inter, system-ui, sans-serif; text-anchor: middle; }

.controls { display: grid; gap: 10px; }
.controls label {
  display: grid;
  gap: 4px;
  font-weight: 800;
  font-size: .88rem;
  color: var(--ink);
}
.controls label span { color: var(--accent-ink); font-variant-numeric: tabular-nums; }
.controls input[type="range"] { accent-color: var(--accent); width: 100%; }
.readout {
  margin-top: 4px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 800;
  line-height: 1.5;
}
.readout b { color: var(--rose); }

/* ---------- Softmax widget ---------- */
.softmax-widget { display: grid; grid-template-columns: 1fr 1.3fr; gap: 20px; align-items: center; }
.bars { display: grid; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 56px 1fr 64px; gap: 10px; align-items: center; }
.bar-row .name { font-weight: 850; }
.bar-track { height: 26px; border-radius: 7px; background: var(--line); overflow: hidden; }
.bar-fill {
  height: 100%;
  border-radius: 7px;
  background: linear-gradient(90deg, var(--accent), #16766c);
  transition: width .3s cubic-bezier(.22,.61,.36,1);
}
.bar-row .pct { text-align: right; font-weight: 850; font-variant-numeric: tabular-nums; color: var(--accent-ink); }

/* ---------- Formal grid ---------- */
.formal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.formal-grid article {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  background: #fff;
  transition: transform .15s ease, box-shadow .15s ease;
}
.formal-grid article:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.formal-grid strong { display: block; margin-bottom: 6px; color: var(--accent-ink); }
.formal-grid span { display: block; color: var(--muted); line-height: 1.55; font-size: .92rem; }

/* ---------- Code panel ---------- */
.code-panel { padding: 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 14px; }
.code-block {
  margin: 0;
  border-radius: 10px;
  padding: 16px;
  background: #10222b;
  color: #e9f4ff;
  overflow-x: auto;
  font: 500 .9rem/1.6 "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}
.code-explanation { display: grid; gap: 9px; margin-top: 14px; }
.code-explanation p { margin: 0; color: var(--muted); line-height: 1.6; }
.code-explanation strong { color: var(--accent-ink); }

/* ---------- Quiz ---------- */
.quiz-panel { padding: 20px; }
.score-pill {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-variant-numeric: tabular-nums;
}
#quizList { display: grid; gap: 14px; }
#quizList article { border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: #fff; }
#quizList strong { display: block; margin-bottom: 8px; }
#quizList .qhint { margin: 0 0 6px; color: var(--muted); font-size: .9rem; }
#quizList button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  margin: 8px 8px 0 0;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 800;
  transition: all .15s ease;
}
#quizList button:hover:not(:disabled) { border-color: var(--accent); }
#quizList button.correct { border-color: var(--accent); color: #fff; background: var(--accent); }
#quizList button.wrong { border-color: var(--rose); color: var(--rose); background: var(--pink); }
.qfeedback { margin: 10px 0 0; font-weight: 700; }
.qfeedback.ok { color: var(--accent-ink); }
.qfeedback.no { color: var(--rose); }
.quiz-done {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 850;
}

/* ---------- Reflection ---------- */
.reflect { display: grid; gap: 14px; margin-top: 6px; }
.reflect label { display: grid; gap: 6px; font-weight: 800; color: var(--ink); }
.reflect textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  color: var(--ink);
  background: #fff;
  resize: vertical;
}
.reflect textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

/* ---------- Mission roadmap ---------- */
.roadmap {
  padding: clamp(46px, 7vw, 90px) clamp(18px, 4vw, 56px);
  border-top: 1px solid var(--line);
  background:
    radial-gradient(820px 380px at 12% 0%, var(--accent-soft), transparent 55%),
    #ffffff;
  scroll-margin-top: 80px;
}
.roadmap-badge { background: var(--ink); }
.roadmap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: 16px;
  max-width: 1200px;
  margin: 8px auto 0;
}
.rm-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent, var(--blue));
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  transition: transform .22s ease, box-shadow .22s ease;
}
a.rm-card:hover { transform: translateY(-4px); box-shadow: 0 22px 50px rgba(24, 35, 49, .18); }
.rm-card.current { background: linear-gradient(180deg, #f1faf6, #fff); }
.rm-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.rm-step {
  border-radius: 999px;
  padding: 3px 10px;
  font-size: .72rem; font-weight: 900; letter-spacing: .04em; text-transform: uppercase;
  color: var(--accent, var(--blue));
  background: color-mix(in srgb, var(--accent, var(--blue)) 14%, white);
}
.rm-level { color: var(--muted); font-size: .78rem; font-weight: 800; }
.rm-card h3 { margin: 8px 0 2px; font-size: 1.4rem; color: var(--accent, var(--ink)); }
.rm-what { margin: 0; color: var(--ink); font-weight: 650; line-height: 1.5; }
.rm-learn-label {
  margin: 12px 0 4px;
  font-size: .72rem; font-weight: 900; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted);
}
.rm-learn { margin: 0; padding-left: 18px; color: var(--muted); line-height: 1.55; }
.rm-learn li { margin: 2px 0; }
.rm-go { margin-top: auto; padding-top: 14px; font-weight: 850; color: var(--accent, var(--blue)); }
.rm-why { margin: 8px 0 0; padding: 8px 10px; border-left: 3px solid color-mix(in srgb, var(--accent, var(--blue)) 50%, var(--line)); background: color-mix(in srgb, var(--accent) 4%, var(--panel)); border-radius: 0 8px 8px 0; color: var(--muted); line-height: 1.5; font-size: .9rem; }
.rm-why strong { color: var(--ink); }
.roadmap-foot { max-width: 1200px; margin: 18px auto 0; text-align: center; font-size: .95rem; }
.rm-path { max-width: 900px; margin: 12px auto 0; color: var(--muted); font-size: .92rem; line-height: 1.6; }
.rm-path strong { color: var(--accent-ink); }

/* ---------- Roadmap tracks (higher-level grouping) ---------- */
.rm-track {
  display: grid;
  grid-template-columns: minmax(0, 300px) minmax(0, 1fr);
  gap: clamp(16px, 3vw, 32px);
  align-items: start;
  max-width: 1200px;
  margin: 0 auto 22px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}
.rm-track.deep { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); background: linear-gradient(180deg, var(--accent-soft), #fff); box-shadow: var(--shadow); }
.rm-track-head { position: sticky; top: 86px; }
.rm-track-tag {
  display: inline-block; margin-bottom: 6px; padding: 5px 12px; border-radius: 999px;
  font-size: .7rem; font-weight: 900; letter-spacing: .05em; text-transform: uppercase;
  color: var(--rose); background: var(--pink);
}
.rm-track.deep .rm-track-tag { color: var(--accent-ink); background: var(--accent-soft); }
.rm-track-head h3 { margin: 4px 0 8px; font-size: clamp(1.2rem, 2.4vw, 1.55rem); }
.rm-track-head p { margin: 0; color: var(--muted); line-height: 1.6; font-size: .92rem; }
.rm-card.deep { border-top-width: 6px; }
.rm-card.deep .rm-step { font-size: .76rem; }

@media (max-width: 900px) {
  .rm-track { grid-template-columns: 1fr; }
  .rm-track-head { position: static; }
}

/* ---------- Footer ---------- */
footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  padding: 28px clamp(18px, 4vw, 56px);
  border-top: 1px solid var(--line);
  color: var(--muted);
}
footer a { color: var(--accent); font-weight: 850; }
@media (min-width: 1180px) { footer { padding-left: calc(var(--rail-w) + 56px); } }

/* ---------- Reveal-on-scroll animation ---------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }

/* ---------- How it all connects (relationship map) ---------- */
.connections {
  padding: clamp(46px, 7vw, 90px) clamp(18px, 4vw, 56px);
  border-top: 1px solid var(--line);
  background:
    radial-gradient(900px 460px at 85% -10%, var(--sky), transparent 60%),
    radial-gradient(700px 380px at 5% 110%, var(--accent-soft), transparent 60%),
    var(--paper);
  scroll-margin-top: 80px;
}
.connect-badge { background: linear-gradient(90deg, var(--accent), #0e7c8a); }
.connect-stage {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 320px);
  gap: clamp(18px, 3vw, 30px);
  align-items: start;
  max-width: 1180px;
  margin: 0 auto;
}
.connect-canvas-wrap {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.connect-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  background: #f4fbf9;
}
.connect-side { display: grid; gap: 14px; }
.connect-trace { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.trace-label { font-weight: 850; font-size: .82rem; color: var(--muted); width: 100%; }
.trace-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  font-size: .86rem;
  min-height: 40px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease, transform .15s ease;
}
.trace-btn:hover { transform: translateY(-1px); border-color: var(--accent); }
.trace-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.connect-info {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.connect-info h3 { margin: 0 0 8px; color: var(--accent-ink); font-size: 1.15rem; }
.connect-info p { margin: 0 0 10px; color: var(--muted); line-height: 1.6; }
.connect-info .ci-why strong { color: var(--ink); }
.ci-link { display: inline-block; margin-top: 2px; color: var(--accent); font-weight: 850; }
.ci-link:hover { text-decoration: underline; }

/* ---------- Responsive ---------- */
/* Below the rail's docked width: it becomes a horizontal bar. Keep it from
   ever overflowing, so let it scroll-x as a last resort and stay tappable. */
@media (max-width: 1179px) {
  .level-rail {
    position: sticky;
    top: 64px;
    left: 0;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    width: auto;
    max-width: 100%;
    margin: 12px clamp(18px, 4vw, 56px) 0;
    border-radius: 10px;
  }
  .level-rail a .txt { display: none; }
  .level-rail a {
    flex: 0 0 auto;
    min-height: 40px;
    min-width: 40px;
    justify-content: center;
    padding: 8px;
  }
  .rail-progress { flex: 1 1 100%; min-width: 0; }
}

@media (max-width: 900px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .hero { grid-template-columns: 1fr; min-height: auto; }
  .connect-stage { grid-template-columns: 1fr; }
  .venn-wrap,
  .playground,
  .softmax-widget { grid-template-columns: 1fr; }
  .model-map,
  .chooser-controls,
  .robot-loop,
  .formal-grid { grid-template-columns: repeat(2, 1fr); }
  /* Center the Venn diagram once it stacks above its explanation */
  .venn { margin-inline: auto; }
}

@media (max-width: 620px) {
  .model-map,
  .chooser-controls,
  .robot-loop,
  .formal-grid { grid-template-columns: 1fr; }
}

/* ---------- Phones: tighten spacing + guarantee tap targets ---------- */
@media (max-width: 600px) {
  .hero,
  .level,
  .roadmap,
  .connections { padding: clamp(34px, 7vw, 56px) clamp(14px, 4vw, 24px); }
  .trace-btn { flex: 1 1 100%; justify-content: center; text-align: center; }
  .concept { padding: clamp(16px, 4vw, 22px); margin-bottom: 22px; }
  .math-card,
  .playground,
  .softmax-widget,
  .explain-card,
  .example-box,
  .code-panel,
  .quiz-panel { padding: 14px; }

  /* Buttons span the row and stay comfortably tappable */
  .actions { gap: 10px; }
  .actions .button { flex: 1 1 100%; justify-content: center; }
  .button { min-height: 44px; }
  .model-map button { min-height: 80px; }
  .chooser-controls button,
  .robot-loop button { min-height: 44px; }

  /* Sliders run full width and stay easy to grab */
  .controls input[type="range"] { width: 100%; height: 28px; }

  /* Panel head can wrap so the toggle / score never push out of the box */
  .panel-head { flex-wrap: wrap; }
}

/* ---------- Narrow phones ---------- */
@media (max-width: 414px) {
  /* Softmax bar rows: drop the rigid 56/64px columns to a fluid 2-col layout */
  .bar-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "name pct"
      "track track";
    gap: 6px 10px;
  }
  .bar-row .name { grid-area: name; }
  .bar-row .pct { grid-area: pct; }
  .bar-track { grid-area: track; }

  /* Quiz answer buttons stack full width for easier tapping */
  #quizList button { display: flex; width: 100%; margin: 8px 0 0; justify-content: center; }
}

/* ---------- Very small phones (320px floor) ---------- */
@media (max-width: 360px) {
  .hero,
  .level,
  .roadmap { padding-inline: 12px; }
  .topbar { padding-inline: 12px; }
  .level-rail { margin-inline: 12px; }
  .math-render { font-size: .98rem; }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  * { scroll-behavior: auto; }
}

/* ---------- "Beautiful math" highlight callout ---------- */
.beauty-note {
  margin: 14px 0 4px;
  padding: 14px 18px 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent-soft) 60%, var(--panel));
}
.beauty-note::before {
  content: "\2726  Beautiful math";
  display: inline-block;
  margin-bottom: 6px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--accent);
}
.beauty-note h4 {
  margin: 0 0 6px;
  font-size: 1.02rem;
  color: var(--accent-ink);
}
.beauty-note .math-render { margin: 6px 0 10px; }
.beauty-note p {
  margin: 0;
  color: var(--ink);
  line-height: 1.6;
  font-size: .94rem;
}

/* ---------- Decision-boundary toggle (Advanced: line vs curve) ---------- */
.boundary-toggle { display: flex; flex-wrap: wrap; gap: 8px; }
.boundary-toggle button {
  flex: 1 1 auto;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease, transform .15s ease;
}
.boundary-toggle button:hover { transform: translateY(-1px); border-color: var(--accent); }
.boundary-toggle button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ===================================================================
   POLISH PASS (additive, CSS-only): focus parity, wide-media affordances,
   micro-typography. Reuses existing class names; never shifts widget layout.
   All motion is re-guarded under prefers-reduced-motion at the very end.
   =================================================================== */

/* ---------- Keyboard focus parity ---------- */
.button:focus-visible,
.model-map button:focus-visible,
.chooser-controls button:focus-visible,
.robot-loop button:focus-visible,
.trace-btn:focus-visible,
#quizList button:focus-visible,
.formal-grid article:focus-visible,
a.rm-card:focus-visible,
.ci-link:focus-visible,
.roadmap-foot a:focus-visible,
footer a:focus-visible,
.inline-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

/* Range sliders */
.controls input[type="range"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 8px;
}

/* Venn rings */
.venn .ring:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Wide media: gentle scroll affordances ---------- */
.math-render {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--accent) 45%, var(--line)) transparent;
  overscroll-behavior-x: contain;
}
.math-render::-webkit-scrollbar { height: 7px; }
.math-render::-webkit-scrollbar-thumb {
  border-radius: 7px;
  background: color-mix(in srgb, var(--accent) 45%, var(--line));
}
.math-render::-webkit-scrollbar-track { background: transparent; }

.code-block {
  scrollbar-width: thin;
  scrollbar-color: rgba(233, 244, 255, .35) transparent;
  overscroll-behavior-x: contain;
}
.code-block::-webkit-scrollbar { height: 8px; }
.code-block::-webkit-scrollbar-thumb {
  border-radius: 8px;
  background: rgba(233, 244, 255, .28);
}
.code-block::-webkit-scrollbar-track { background: transparent; }

/* ---------- Micro-typography refinements ---------- */
.readout { font-variant-numeric: tabular-nums; }
.math-card .legend li { line-height: 1.55; }
.step-tag { vertical-align: middle; }

/* ---------- Subtle interactive easing (no transform on load) ---------- */
.explain-card strong,
.connect-info h3 { transition: color .2s ease; }
.ci-link { transition: color .15s ease; }

/* ---------- Reveal settle for canvas cards ---------- */
.canvas-card,
.connect-canvas-wrap {
  transition: box-shadow .4s ease;
}
.reveal.in .canvas-card,
.reveal.in .connect-canvas-wrap {
  box-shadow: 0 14px 38px rgba(24, 35, 49, .12);
}

/* ---------- Re-assert reduced-motion for everything added here ---------- */
@media (prefers-reduced-motion: reduce) {
  .button:focus-visible,
  .model-map button:focus-visible,
  .chooser-controls button:focus-visible,
  .robot-loop button:focus-visible,
  .trace-btn:focus-visible,
  #quizList button:focus-visible,
  .controls input[type="range"]:focus-visible,
  .venn .ring:focus-visible { transition: none; }
  .canvas-card,
  .connect-canvas-wrap,
  .explain-card strong,
  .connect-info h3,
  .ci-link { transition: none; }
  .reveal.in .canvas-card,
  .reveal.in .connect-canvas-wrap { box-shadow: var(--shadow); }
}
