:root {
  --ink: #17243b;
  --muted: #667085;
  --paper: #f6f3eb;
  --panel: #fffefa;
  --line: #ded9cf;
  --purple: #6957e8;
  --purple-dark: #4e3fd0;
  --purple-soft: #eeebff;
  --mint: #dff3df;
  --green: #237a4b;
  --coral: #e36f56;
  --shadow: 0 18px 50px rgba(34, 42, 63, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 10%, rgba(105, 87, 232, 0.08), transparent 21rem),
    var(--paper);
  font-family: "DM Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, textarea, input { font: inherit; }
button { color: inherit; }

.topic-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  min-height: 100dvh;
  overflow: auto;
  padding: 24px clamp(20px, 5vw, 76px) 28px;
  color: #23314a;
  background: #ebe8df;
  isolation: isolate;
  transition: opacity .24s ease, visibility .24s ease;
}
.topic-gate[aria-hidden="true"] { visibility: hidden; opacity: 0; pointer-events: none; }
.topic-gate-open, .overlay-open { overflow: hidden; }
.pixel-sky { position: absolute; inset: 0; z-index: -2; overflow: hidden; }
.pixel-sky::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .22;
  background-image:
    linear-gradient(rgba(78,63,208,.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(78,63,208,.08) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(to bottom, black, transparent 76%);
}
.pixel-cloud { position: absolute; width: 112px; height: 25px; background: rgba(255,255,255,.5); box-shadow: 22px -18px 0 rgba(255,255,255,.5), 54px -7px 0 rgba(255,255,255,.5); image-rendering: pixelated; }
.cloud-one { top: 19%; left: 6%; }
.cloud-two { top: 13%; right: 12%; transform: scale(.68); opacity: .68; }
.pixel-star { position: absolute; color: rgba(78,63,208,.34); font: 800 24px/1 monospace; }
.star-one { top: 16%; left: 30%; }
.star-two { top: 31%; right: 26%; }
.star-three { top: 57%; left: 19%; }
.pixel-hill { position: absolute; bottom: -16%; width: 70%; height: 38%; transform: rotate(-4deg); background: #d6ddcf; clip-path: polygon(0 100%, 0 58%, 14% 58%, 14% 42%, 29% 42%, 29% 23%, 45% 23%, 45% 40%, 60% 40%, 60% 55%, 76% 55%, 76% 38%, 100% 38%, 100% 100%); }
.hill-back { left: -6%; opacity: .62; }
.hill-front { right: -9%; bottom: -22%; background: #c6d1c2; transform: rotate(3deg) scaleX(-1); }
.gate-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.calm-mode { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px; color: #586579; background: rgba(255,255,255,.52); font-size: 11px; font-weight: 700; }
.calm-mode i { width: 7px; height: 7px; border-radius: 50%; background: #61a078; box-shadow: 0 0 0 4px rgba(97,160,120,.14); }
.gate-copy { width: min(670px, 100%); margin: clamp(42px, 8vh, 88px) auto 18px; text-align: center; }
.gate-copy .eyebrow { margin-bottom: 13px; }
.gate-copy h1 { margin: 0; font: 800 clamp(38px, 6vw, 72px)/1.02 "Manrope", sans-serif; letter-spacing: -.05em; }
.gate-copy > p:last-child { max-width: 590px; margin: 17px auto 0; color: #657087; font-size: clamp(14px, 1.7vw, 18px); line-height: 1.55; }
.topic-scene { width: min(980px, 100%); height: 330px; margin: 0 auto; position: relative; }
.topic-orb {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 190px;
  min-height: 104px;
  display: grid;
  grid-template-columns: 50px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 2px 12px;
  padding: 17px;
  border: 0;
  border-radius: 7px;
  color: #697287;
  background: rgba(255,255,255,.5);
  box-shadow: 8px 8px 0 rgba(104,112,126,.08);
  cursor: pointer;
  text-align: left;
  transform: rotate(var(--tilt));
  animation: topic-float 5.5s ease-in-out var(--delay) infinite;
}
.topic-orb::after { content: ""; position: absolute; inset: 7px; border: 1px dashed rgba(92,101,117,.17); border-radius: 3px; pointer-events: none; }
.topic-orb:hover, .topic-orb:focus-visible { color: #3f4b60; background: rgba(255,255,255,.78); outline: 3px solid rgba(105,87,232,.2); outline-offset: 4px; }
.topic-orb.topic-ready { color: #27344b; background: #fff9df; box-shadow: 8px 8px 0 rgba(130,105,34,.13), 0 16px 44px rgba(61,68,81,.1); }
.topic-orb.topic-ready::before { content: "PLAY"; position: absolute; top: -9px; right: 10px; padding: 4px 7px; color: white; background: #6957e8; font: 800 8px/1 "DM Sans", sans-serif; letter-spacing: .12em; }
.topic-pixel { grid-row: 1 / 3; width: 50px; height: 50px; display: grid; place-items: center; border-radius: 4px; color: #6152cb; background: #e9e5ff; font: 800 14px/1 monospace; image-rendering: pixelated; }
.topic-ready .topic-pixel { color: #8a610e; background: #f4df94; }
.topic-orb strong { align-self: end; font: 800 15px/1.2 "Manrope", sans-serif; }
.topic-orb small { align-self: start; color: #858b97; font-size: 10px; }
.topic-status { width: min(620px, calc(100% - 30px)); min-height: 54px; margin: -8px auto 0; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 11px 16px; border-radius: 12px; color: #626b7a; background: rgba(255,255,255,.65); text-align: center; }
.topic-status > span { color: #6957e8; font-size: 18px; }
.topic-status p { margin: 0; font-size: 11px; line-height: 1.45; }
.topic-status strong { color: #354158; }
.topic-status-bump { animation: status-bump .3s ease; }
.gate-footnote { margin: 13px 0 0; color: #7d8490; font-size: 10px; font-weight: 700; text-align: center; letter-spacing: .04em; }
@keyframes topic-float { 0%, 100% { translate: 0 0; } 50% { translate: 0 -5px; } }
@keyframes status-bump { 50% { transform: translateY(-3px); } }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.mode-gate {
  position: fixed;
  inset: 0;
  z-index: 105;
  min-height: 100dvh;
  overflow: auto;
  padding: 24px clamp(20px, 5vw, 76px) 48px;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 10%, rgba(105,87,232,.08), transparent 26rem),
    radial-gradient(circle at 86% 82%, rgba(97,160,120,.09), transparent 22rem),
    #f1eee6;
  transition: opacity .24s ease, visibility .24s ease;
}
.mode-gate[aria-hidden="true"] { visibility: hidden; opacity: 0; pointer-events: none; }
.mode-header {
  max-width: 1160px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
}
.mode-header .calm-mode { justify-self: end; background: rgba(255,255,255,.68); }
.mode-back {
  width: fit-content;
  padding: 9px 12px;
  border: 0;
  border-radius: 10px;
  color: #586579;
  background: rgba(255,255,255,.58);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}
.mode-back:hover, .mode-back:focus-visible { color: var(--purple-dark); background: white; }
.mode-shell { width: min(1100px, 100%); margin: clamp(44px, 8vh, 82px) auto 0; }
.mode-copy { width: min(760px, 100%); margin: 0 auto 32px; text-align: center; }
.mode-copy h1 { margin: 0; font: 800 clamp(34px, 5vw, 58px)/1.05 "Manrope", sans-serif; letter-spacing: -.045em; }
.mode-copy > p:last-child { max-width: 630px; margin: 17px auto 0; color: var(--muted); font-size: 16px; line-height: 1.55; }
.mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; align-items: start; }
.mode-card {
  min-height: 430px;
  padding: clamp(24px, 3vw, 34px);
  border: 1px solid rgba(111,104,91,.2);
  border-radius: 24px;
  color: var(--ink);
  background: rgba(255,254,250,.84);
  box-shadow: 0 20px 55px rgba(39,47,64,.08);
}
.test-mode-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  cursor: pointer;
  text-align: left;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.test-mode-card:hover, .test-mode-card:focus-visible {
  transform: translateY(-3px);
  border-color: rgba(105,87,232,.45);
  outline: none;
  box-shadow: 0 24px 62px rgba(69,57,147,.14);
}
.mode-card-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 17px;
  color: var(--purple-dark);
  background: var(--purple-soft);
  font: 800 14px/1 "Manrope", sans-serif;
}
.mode-card-kicker { display: block; margin-top: 24px; color: #7568cc; font-size: 10px; font-weight: 900; letter-spacing: .13em; }
.test-mode-card > strong { margin-top: 9px; font: 800 27px/1.2 "Manrope", sans-serif; }
.mode-card-description { display: block; margin: 12px 0 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.mode-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 24px; }
.mode-chips i { padding: 6px 9px; border-radius: 999px; color: #5d6170; background: #f0eee8; font-size: 10px; font-style: normal; font-weight: 700; }
.mode-card-action { margin-top: auto; padding-top: 34px; color: var(--purple-dark); font-weight: 900; }
.mode-card-action b { margin-left: 8px; }
.understanding-card { background: rgba(248,252,247,.9); }
.understanding-heading { display: flex; align-items: center; gap: 15px; }
.understanding-heading .mode-card-kicker { margin-top: 0; color: #4c7a5a; }
.understanding-heading h2 { margin: 5px 0 0; font: 800 25px/1.2 "Manrope", sans-serif; }
.understanding-heading .mode-card-icon { color: #2f6845; background: #e1f1e2; }
#understandingInput {
  width: 100%;
  min-height: 122px;
  margin-top: 18px;
  resize: vertical;
  padding: 15px 16px;
  border: 1px solid #d3d8ce;
  border-radius: 14px;
  outline: none;
  color: var(--ink);
  background: rgba(255,255,255,.86);
  font-size: 14px;
  line-height: 1.55;
}
#understandingInput:focus { border-color: #69a179; box-shadow: 0 0 0 3px rgba(97,160,120,.13); }
#understandingInput::placeholder { color: #92988f; }
.understanding-controls { margin-top: 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#understandingCount { color: #858b88; font-size: 10px; }
.understanding-submit {
  padding: 10px 14px;
  border: 0;
  border-radius: 10px;
  color: white;
  background: #4d8260;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}
.understanding-submit:hover:not(:disabled) { background: #376e4b; }
.understanding-submit:disabled { color: #9b9e99; background: #e4e6e0; cursor: not-allowed; }
.understanding-privacy { margin: 10px 0 0; color: #838a84; font-size: 9px; line-height: 1.4; }
.understanding-response { margin-top: 16px; display: grid; gap: 10px; padding: 15px; border-radius: 14px; background: #edf5ed; }
.understanding-response[hidden] { display: none; }
.understanding-response[aria-busy="true"] { color: #54705d; font-size: 13px; }
.understanding-point { display: grid; gap: 3px; }
.understanding-point span { color: #52705b; font-size: 9px; font-weight: 900; letter-spacing: .1em; }
.understanding-point p { margin: 0; color: #314c39; font-size: 12px; line-height: 1.45; }
.understanding-source { color: #758078; font-size: 9px; }

.site-header {
  height: 74px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 243, 235, 0.9);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  font-family: "Manrope", sans-serif;
  font-size: 18px;
  font-weight: 800;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: white;
  background: var(--purple);
  font: 800 20px/1 Georgia, serif;
  box-shadow: 0 7px 18px rgba(105, 87, 232, 0.25);
}

.header-actions { display: flex; align-items: center; gap: 12px; }
.ghost-button, .primary-button, .stuck-actions button, .formula-chips button, .option {
  border: 0;
  cursor: pointer;
}

.ghost-button {
  padding: 10px 16px;
  border: 1px solid #cfc9bd;
  border-radius: 10px;
  background: transparent;
  font-weight: 700;
}
.ghost-button:hover { background: white; }
.reset-button { color: #625a50; }
.header-icon { margin-right: 5px; font-weight: 900; }

.app-shell {
  max-width: 1500px;
  min-height: calc(100vh - 74px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 235px minmax(500px, 740px) 300px;
  gap: 28px;
  padding: 34px 32px 130px;
}

.progress-panel { padding: 16px 4px; }
.eyebrow {
  margin: 0 0 10px;
  color: var(--purple-dark);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
}
.progress-panel h1, .scratch-heading h2 {
  margin: 0;
  font-family: "Manrope", sans-serif;
  line-height: 1.16;
}
.progress-panel h1 { font-size: 25px; }
.lesson-meta, .microcopy, .scratch-prompt, .mission-context {
  color: var(--muted);
}
.lesson-meta { margin: 10px 0 0; font-size: 13px; }

.lesson-principle {
  margin-top: 30px;
  padding: 14px 15px;
  border-left: 3px solid #e1ac28;
  border-radius: 11px;
  background: rgba(255, 249, 232, .82);
}
.lesson-principle p {
  margin: 0 0 7px;
  color: #8a610e;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .13em;
}
.lesson-principle strong { display: block; font: 800 17px/1.2 "Manrope", sans-serif; }
.lesson-principle span { display: block; margin-top: 6px; color: #62583e; font-size: 11px; line-height: 1.45; }
.step-list { margin-top: 26px; display: grid; gap: 20px; }
.step-row { display: flex; align-items: center; gap: 12px; color: #9397a0; }
.step-row span {
  width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid #cec9c0;
  border-radius: 50%;
  background: rgba(255,255,255,.45);
  font-size: 12px;
  font-weight: 800;
}
.step-row p { margin: 0; font-size: 13px; font-weight: 600; }
.step-row.active { color: var(--ink); }
.step-row.active span { color: white; border-color: var(--purple); background: var(--purple); }
.step-row.done span { color: var(--green); border-color: #acd1b7; background: var(--mint); }
.reasoning-trail {
  margin-top: 34px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.trail-heading { display: flex; align-items: center; gap: 8px; }
.trail-heading > span { color: var(--purple); font-size: 18px; }
.trail-heading h2 { margin: 0; font: 800 12px/1.3 "Manrope", sans-serif; }
#reasoningTrail { margin-top: 12px; display: grid; gap: 9px; }
.trail-empty { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.trail-item { display: flex; align-items: flex-start; gap: 8px; }
.trail-item > span {
  width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: var(--green);
  background: var(--mint);
  font-size: 10px;
  font-weight: 800;
}
.trail-item div { min-width: 0; display: grid; gap: 1px; }
.trail-item strong { font-size: 10px; }
.trail-item small { color: var(--muted); font-size: 10px; line-height: 1.35; }

.workspace { min-width: 0; }
.workspace-topline { min-height: 45px; display: flex; align-items: flex-start; justify-content: space-between; }
.workspace-topline .eyebrow { margin-bottom: 5px; }
.microcopy { margin: 0; font-size: 13px; }
.progress-dots { display: flex; gap: 7px; padding-top: 6px; }
.progress-dots span { width: 8px; height: 8px; border-radius: 50%; background: #d5d1c9; }
.progress-dots span.filled { width: 22px; border-radius: 8px; background: var(--purple); }

.problem-card {
  margin-top: 20px;
  display: grid;
  grid-template-columns: 1.25fr .9fr;
  align-items: center;
  gap: 20px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(255,255,255,.56);
}
.problem-label, .mission-kicker {
  color: #8b6c26;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .13em;
}
.problem-facts { margin-top: 11px; display: grid; gap: 8px; }
.fact-row { display: grid; grid-template-columns: 66px 1fr; align-items: baseline; gap: 9px; }
.fact-row p { margin: 0; font-size: 13px; line-height: 1.45; }
.command-word {
  padding: 3px 6px;
  border-radius: 6px;
  color: #5644c7;
  background: #eeeaff;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .08em;
  text-align: center;
}
.command-find { color: #7b5307; background: #ffe8a7; }
.quantity {
  padding: 1px 3px;
  border-radius: 4px;
  color: var(--ink);
  background: #fff0ae;
  font-weight: 800;
}
.unit { color: var(--purple-dark); font-weight: 800; }
.force-diagram { width: 100%; max-height: 95px; }

.mission-card {
  margin-top: 18px;
  padding: 35px 38px 32px;
  border: 1px solid rgba(105, 87, 232, 0.25);
  border-radius: 21px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.mission-kicker { color: var(--purple-dark); }
.mission-card h2 {
  max-width: 620px;
  margin: 10px 0 8px;
  font: 800 clamp(22px, 2.5vw, 30px)/1.25 "Manrope", sans-serif;
  letter-spacing: -.025em;
}
.mission-context { margin: 0 0 24px; font-size: 14px; }
.answer-area { display: grid; gap: 10px; }
.option {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 15px 17px;
  text-align: left;
  border: 1px solid #dcd7ce;
  border-radius: 12px;
  background: #fff;
  font-weight: 600;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.option:hover { border-color: #a99efa; transform: translateY(-1px); }
.option.selected { border-color: var(--purple); background: var(--purple-soft); }
.option-key {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #f0eee8;
  color: #5f6470;
  font-size: 12px;
  font-weight: 800;
}
.option.selected .option-key { color: white; background: var(--purple); }
.number-input-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  border: 1.5px solid #d8d2c8;
  border-radius: 12px;
  background: #fff;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.number-input-wrap:focus-within {
  border-color: var(--purple);
  box-shadow: 0 0 0 4px var(--purple-soft);
}
.text-answer {
  width: 100%;
  min-width: 0;
  padding: 16px 18px;
  border: 0;
  outline: none;
  color: var(--ink);
  background: transparent;
  font-size: 18px;
  font-weight: 700;
}
.text-answer::-webkit-outer-spin-button,
.text-answer::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}
.text-answer[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}
.unit-suffix {
  flex: 0 0 auto;
  min-width: 68px;
  margin: 10px 0;
  padding: 6px 18px;
  border-left: 1px solid #ddd8ed;
  color: var(--purple);
  font-size: 17px;
  font-weight: 800;
  text-align: center;
}
.feedback {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
}
.feedback.success { color: #17683e; background: #e3f5e7; }
.feedback.retry { color: #87422f; background: #fff0e8; }
.feedback.thinking { color: #5146a8; background: #f0edff; }
.feedback.ai { color: #2f5361; background: #e9f4f4; border-left: 3px solid #6d9aa3; }
.feedback.detective { color: #594c31; background: #f7f2e7; border-left: 3px solid #b49a62; }
.feedback.diagnosing::after {
  content: " · AI is checking the pattern…";
  color: #7c6d51;
  font-size: 12px;
}
.coach-feedback {
  display: grid;
  gap: 5px;
  text-align: left;
}
.coach-tag {
  width: fit-content;
  padding: 2px 7px;
  border-radius: 999px;
  color: #595079;
  background: rgba(255, 255, 255, .62);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
}
.coach-title { font-size: 15px; }
.coach-body, .coach-next { display: block; }
.coach-next { font-weight: 800; }
.coach-source { color: #77736a; font-size: 11px; }
.primary-button {
  min-width: 190px;
  margin-top: 22px;
  padding: 14px 19px;
  border-radius: 11px;
  color: white;
  background: var(--purple);
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(105, 87, 232, .22);
}
.primary-button:hover:not(:disabled) { background: var(--purple-dark); }
.primary-button:disabled { cursor: not-allowed; color: #9da0a6; background: #e6e3dd; box-shadow: none; }
.primary-button span { margin-left: 10px; }

.help-dock {
  position: fixed;
  right: 26px;
  bottom: 24px;
  z-index: 30;
  width: min(340px, calc(100vw - 32px));
  pointer-events: none;
}

.help-launcher {
  position: relative;
  width: 142px;
  min-height: 82px;
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 12px 14px 13px 11px;
  border: 0;
  border-radius: 58% 42% 54% 46% / 46% 57% 43% 54%;
  color: #293650;
  background: #fff0ae;
  box-shadow: 0 10px 26px rgba(75,68,42,.16);
  cursor: pointer;
  text-align: left;
  pointer-events: auto;
}
.help-launcher::after {
  content: "";
  position: absolute;
  right: 12px;
  bottom: -5px;
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 40% 60% 65% 35%;
  background: #fff0ae;
  transform: rotate(23deg);
}
.help-launcher:hover { background: #ffeba0; }
.help-launcher:focus-visible { outline: 4px solid rgba(105,87,232,.32); outline-offset: 3px; }
.help-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 55% 45% 58% 42% / 48% 58% 42% 52%;
  color: #5544c7;
  background: #eeeaff;
  font: 800 19px/1 "Manrope", sans-serif;
}
.help-launcher-copy { display: grid; gap: 2px; flex: 1; }
.help-launcher-copy strong { white-space: nowrap; font: 800 14px/1.2 "Manrope", sans-serif; }
.help-launcher-copy small { color: #746b4e; font-size: 9px; }

.help-popover {
  position: absolute;
  right: 0;
  bottom: 92px;
  width: 100%;
  padding: 21px;
  border: 1px solid rgba(105,87,232,.24);
  border-radius: 19px;
  background: var(--panel);
  box-shadow: 0 22px 65px rgba(23,36,59,.22);
  pointer-events: auto;
}
.help-popover[hidden] { display: none; }
.help-popover-header { display: flex; align-items: start; justify-content: space-between; gap: 14px; }
.help-popover-header .eyebrow { margin-bottom: 5px; color: #9a6710; }
.help-popover h2 { margin: 0; font: 800 20px/1.25 "Manrope", sans-serif; }
.help-close {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  background: #f0eee8;
  cursor: pointer;
  font-size: 20px;
}
.help-intro { margin: 8px 0 15px; color: var(--muted); font-size: 12px; }
.help-privacy { margin: -7px 0 15px; color: #7c8491; font-size: 9px; line-height: 1.45; }
.help-options { display: grid; gap: 8px; }
.help-options button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px;
  border: 1px solid #ddd7cc;
  border-radius: 12px;
  color: var(--ink);
  background: white;
  cursor: pointer;
  text-align: left;
}
.help-options button:hover { border-color: var(--purple); background: var(--purple-soft); }
.help-options button > span {
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 9px;
  color: var(--purple-dark);
  background: var(--purple-soft);
  font-weight: 800;
}
.help-options button div { display: grid; gap: 2px; }
.help-options button strong { font-size: 12px; }
.help-options button small { color: var(--muted); font-size: 10px; }

.right-rail {
  margin-top: 45px;
  display: grid;
  align-self: start;
  gap: 14px;
}
.scratch-panel {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.58);
}
.scratch-heading { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.scratch-heading h2 { font-size: 20px; }
.saved-state { color: var(--green); font-size: 10px; font-weight: 700; }
.scratch-prompt { margin: 10px 0 12px; font-size: 12px; }
#scratchpad {
  width: 100%;
  min-height: 230px;
  resize: vertical;
  padding: 15px;
  border: 1px solid #d9d4ca;
  border-radius: 12px;
  outline: none;
  color: var(--ink);
  background: repeating-linear-gradient(#fff 0, #fff 30px, #ede9e1 31px);
  line-height: 31px;
}
#scratchpad:focus { border-color: var(--purple); }
.formula-chips { display: flex; gap: 6px; margin-top: 10px; }
.formula-chips button {
  padding: 6px 9px;
  border: 1px solid #d8d2c8;
  border-radius: 8px;
  background: white;
  font: 700 11px Georgia, serif;
}
.formula-chips button:hover { border-color: var(--purple); }

.experiment-reward {
  padding: 19px 20px 20px;
  border: 1px solid #ddd7c6;
  border-radius: 18px;
  background: #f4f0e4;
  transition: border-color .2s ease, background .2s ease;
}
.experiment-reward.unlocked { border-color: #bdd7c2; background: #edf6eb; }
.reward-topline { display: flex; align-items: center; gap: 9px; color: #777263; font-size: 10px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.reward-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; color: #745f29; background: #eee2b7; font-size: 15px; }
.unlocked .reward-icon { color: #236d43; background: #d8edd9; }
.experiment-reward h2 { margin: 12px 0 6px; font: 800 19px/1.2 "Manrope", sans-serif; }
.experiment-reward p { margin: 0; color: #737066; font-size: 11px; line-height: 1.5; }
.reward-dots { display: flex; gap: 7px; margin: 14px 0; }
.reward-dots span { width: 100%; height: 5px; border-radius: 999px; background: #ddd8ca; transition: background .2s ease; }
.reward-dots span.filled { background: #76a67e; }
.experiment-open {
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  color: white;
  background: #4d8260;
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
}
.experiment-open:hover:not(:disabled) { background: #376e4b; }
.experiment-open:disabled { color: #8c897f; background: #e4e0d4; cursor: not-allowed; }

dialog {
  max-width: 430px;
  padding: 38px;
  border: 0;
  border-radius: 22px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 28px 90px rgba(23,36,59,.25);
  text-align: center;
}
dialog::backdrop { background: rgba(23,36,59,.48); backdrop-filter: blur(4px); }
.dialog-close { position: absolute; top: 14px; right: 16px; border: 0; background: transparent; font-size: 24px; cursor: pointer; }
.pause-icon { width: 54px; height: 54px; margin: 0 auto 20px; display: grid; place-items: center; border-radius: 50%; color: var(--purple-dark); background: var(--purple-soft); font-weight: 800; }
dialog h2 { margin: 7px 0 10px; font: 800 27px "Manrope", sans-serif; }
dialog > p:not(.eyebrow) { color: var(--muted); line-height: 1.55; }
.experiment-unlock-dialog { overflow: visible; background: #fbf9ef; }
.unlock-flask { width: 62px; height: 62px; margin: 0 auto 18px; display: grid; place-items: center; border-radius: 42% 58% 52% 48% / 58% 43% 57% 42%; color: #3d7450; background: #dfeede; font-size: 29px; transform: rotate(-5deg); }
.experiment-unlock-dialog .primary-button { margin-top: 14px; }

.experiment-dialog {
  width: min(920px, calc(100vw - 32px));
  max-width: 920px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 32px;
  text-align: left;
}
.lab-heading { display: flex; align-items: end; justify-content: space-between; gap: 30px; padding-right: 28px; }
.lab-heading .eyebrow { margin-bottom: 4px; }
.lab-heading h2 { margin: 0; }
.lab-heading > p { max-width: 390px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.lab-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(240px, .8fr); gap: 20px; margin-top: 24px; }
.lab-scene, .lab-controls { border: 1px solid #dfdbd1; border-radius: 17px; background: #f8f6f0; }
.lab-scene { min-height: 340px; display: flex; flex-direction: column; padding: 20px; overflow: hidden; }
.lab-readout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.lab-readout div { padding: 12px; border-radius: 11px; background: white; }
.lab-readout span { display: block; color: #7a7680; font-size: 10px; font-weight: 800; }
.lab-readout strong { display: block; margin-top: 3px; color: #273650; font-size: 14px; }
.lab-track { flex: 1; display: grid; grid-template-columns: 1fr 78px 1fr; align-items: center; gap: 12px; min-height: 160px; border-bottom: 3px solid #cbc5b9; }
.lab-crate { width: 78px; height: 64px; display: grid; place-items: center; border-radius: 10px 10px 4px 4px; color: white; background: #283750; font-size: 13px; font-weight: 900; transition: transform .25s ease; }
.lab-force { display: flex; flex-direction: column; gap: 7px; color: #77727a; font-size: 9px; font-weight: 800; }
.lab-force span { position: relative; display: block; height: 8px; border-radius: 999px; transition: width .2s ease; }
.lab-force-left { align-items: flex-end; text-align: right; }
.lab-force-left span { background: #d97762; }
.lab-force-left span::before { content: ""; position: absolute; left: -7px; top: -4px; border-top: 8px solid transparent; border-bottom: 8px solid transparent; border-right: 11px solid #d97762; }
.lab-force-right { align-items: flex-start; }
.lab-force-right span { background: #6957e8; }
.lab-force-right span::after { content: ""; position: absolute; right: -7px; top: -4px; border-top: 8px solid transparent; border-bottom: 8px solid transparent; border-left: 11px solid #6957e8; }
.lab-observation { min-height: 42px; margin: 16px 0 0; color: #44556b; font-size: 12px; line-height: 1.5; }
.lab-controls { display: grid; align-content: start; padding: 22px; }
.lab-controls label { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 2px 0 7px; font-size: 12px; font-weight: 800; }
.lab-controls output { color: var(--purple-dark); font-size: 11px; }
.lab-controls input[type="range"] { width: 100%; margin: 0 0 25px; accent-color: var(--purple); cursor: pointer; }
.lab-reset { width: 100%; margin-top: 2px; padding: 10px; border: 1px solid #d9d4ca; border-radius: 10px; background: white; cursor: pointer; font-size: 11px; font-weight: 800; }
.lab-reset:hover { border-color: var(--purple); color: var(--purple-dark); }

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 190px minmax(480px, 1fr); }
  .right-rail { grid-column: 2; margin-top: 0; grid-template-columns: minmax(210px, .7fr) minmax(280px, 1.3fr); }
}

@media (max-width: 780px) {
  .topic-gate { padding: 18px 16px 26px; }
  .mode-gate { padding: 18px 16px 34px; }
  .mode-header { grid-template-columns: 1fr auto; }
  .mode-header .brand { display: none; }
  .mode-shell { margin-top: 40px; }
  .mode-copy { margin-bottom: 24px; text-align: left; }
  .mode-copy > p:last-child { margin-left: 0; }
  .mode-grid { grid-template-columns: 1fr; }
  .mode-card { min-height: 0; }
  .test-mode-card { min-height: 340px; }
  .calm-mode { padding: 7px 9px; font-size: 9px; }
  .gate-copy { margin: 42px auto 22px; }
  .topic-scene { height: auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .topic-orb { position: relative; inset: auto; width: 100%; min-height: 94px; transform: none; animation: none; }
  .topic-status { margin-top: 18px; }
  .site-header { padding: 0 18px; }
  .header-actions { gap: 7px; }
  .ghost-button { padding: 9px 11px; font-size: 12px; }
  .app-shell { display: block; padding: 22px 16px 40px; }
  .progress-panel { display: flex; flex-wrap: wrap; align-items: start; justify-content: space-between; gap: 15px; padding: 5px 2px 20px; }
  .progress-panel h1 { font-size: 20px; }
  .lesson-principle { width: 100%; margin-top: 0; }
  .step-list { display: none; }
  .reasoning-trail { width: 100%; margin-top: 4px; padding: 13px 14px; border: 0; border-radius: 12px; background: rgba(255,255,255,.6); }
  #reasoningTrail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace-topline { margin-top: 4px; }
  .problem-card { grid-template-columns: 1fr; }
  .force-diagram { max-width: 330px; margin: 0 auto; }
  .mission-card { padding: 28px 22px 24px; }
  .right-rail { margin-top: 18px; grid-template-columns: 1fr; }
  .lab-heading { display: block; }
  .lab-heading > p { margin-top: 9px; }
  .lab-layout { grid-template-columns: 1fr; }
  .experiment-dialog { padding: 26px 20px; }
  .help-dock { right: 16px; bottom: 14px; width: calc(100vw - 32px); }
  .help-launcher { width: 132px; min-height: 76px; }
  .help-popover { bottom: 86px; max-height: calc(100vh - 120px); overflow-y: auto; }
}

@media (max-width: 520px) {
  .site-header .brand > span:last-child { display: none; }
  .header-actions .button-label { display: none; }
  .header-icon { margin-right: 0; }
  .header-actions .ghost-button { width: 40px; height: 40px; padding: 0; }
  .topic-scene { grid-template-columns: 1fr; }
  .topic-orb { grid-template-columns: 46px 1fr; min-height: 82px; }
  .topic-pixel { width: 44px; height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
