:root {
  --paper: #f6f0e1;
  --paper-2: #fffaf0;
  --ink: #2d3a6e;
  --ink-soft: #5b6595;
  --coral: #ef6f5e;
  --mustard: #f2b134;
  --teal: #2a9d8f;
  --sky: #9fd3ef;
  --grass: #8cc152;
  --pink: #f4a3b4;
  --plum: #7a5a99;
  --good: #3f9a4a;
  --bad: #d94b3b;
  --hand: 255px 18px 225px 18px / 18px 225px 18px 255px;
  --hand-2: 18px 225px 18px 255px / 255px 18px 225px 18px;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background-color: var(--paper);
  /* toothy paper */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .45  0 0 0 0 .38  0 0 0 0 .25  0 0 0 .09 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  color: var(--ink);
  font-family: "Patrick Hand", "Comic Sans MS", system-ui, sans-serif;
  font-size: 20px;
  line-height: 1.4;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, .title-font { font-family: "Gaegu", cursive; font-weight: 700; line-height: 1.1; margin: 0 0 .4em; }
h1 { font-size: 2.4rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
p { margin: 0 0 .7em; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  max-width: 980px; margin: 0 auto; padding: 10px 16px 0;
}
.brand { width: 56px; height: 56px; flex: none; }
.brand svg { width: 100%; height: 100%; overflow: visible; }
.day { flex: 1; min-width: 0; }
.day-sub { font-size: .85rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-title { font-family: Gaegu, cursive; font-weight: 700; font-size: 1.5rem; line-height: 1.05; }
.tools { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  font-size: 1.3rem; width: 44px; height: 44px; border: 3px solid var(--ink); border-radius: var(--hand);
  background: var(--paper-2); cursor: pointer;
}
.icon-btn[aria-pressed="true"] { background: var(--mustard); }
.timer {
  font-family: Gaegu, cursive; font-weight: 700; font-size: 1.15rem; white-space: nowrap;
  padding: 6px 12px; border: 3px solid var(--ink); border-radius: var(--hand-2); background: var(--paper-2);
}
.timer.late { background: var(--pink); }

/* ---------- step tracker: 6 crayons ---------- */
.steps {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px;
  max-width: 980px; margin: 10px auto 0; padding: 0 16px;
}
.step {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: 0; padding: 4px 0; cursor: pointer; color: var(--ink); font: inherit;
}
.step .tip {
  width: 100%; height: 14px; border: 3px solid var(--ink); border-radius: 8px 2px 2px 8px;
  background: var(--paper-2); position: relative;
}
.step .tip::after {
  content: ""; position: absolute; right: -12px; top: -3px; border: 7px solid transparent;
  border-left: 10px solid var(--ink);
}
.step.done .tip, .step.current .tip { background: var(--c); }
.step.current .tip { box-shadow: 0 0 0 3px var(--mustard); }
.step .lbl { font-size: .8rem; white-space: nowrap; }
.step.current .lbl { font-weight: bold; text-decoration: underline wavy var(--c); }

/* ---------- main stage ---------- */
.stage { max-width: 980px; margin: 0 auto; padding: 14px 16px 40px; outline: none; }

.card {
  background: var(--paper-2);
  border: 3px solid var(--ink);
  border-radius: var(--hand);
  padding: 22px 22px 18px;
  box-shadow: 5px 6px 0 rgba(45, 58, 110, .18);
}
.card + .card { margin-top: 16px; }

.art { width: 100%; height: auto; display: block; border-radius: 14px; }
.art-frame { border: 3px solid var(--ink); border-radius: var(--hand-2); background: var(--paper); overflow: hidden; }

.btn {
  font-family: Gaegu, cursive; font-weight: 700; font-size: 1.45rem; color: var(--ink);
  background: var(--mustard); border: 3px solid var(--ink); border-radius: var(--hand);
  padding: 8px 22px 10px; cursor: pointer; min-height: 52px;
  box-shadow: 3px 4px 0 var(--ink); transition: transform .08s, box-shadow .08s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 5px 0 var(--ink); }
.btn:active { transform: translate(2px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: 3px 4px 0 var(--ink); }
.btn.teal { background: var(--teal); color: #fff; }
.btn.coral { background: var(--coral); color: #fff; }
.btn.plain { background: var(--paper-2); }
.btn.small { font-size: 1.15rem; min-height: 44px; padding: 4px 14px 6px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

/* ---------- welcome ---------- */
.welcome { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: center; }
.welcome .bubble {
  position: relative; background: var(--paper-2); border: 3px solid var(--ink); border-radius: var(--hand);
  padding: 18px 20px; font-size: 1.25rem;
}
.plan { list-style: none; padding: 0; margin: 14px 0 18px; display: grid; gap: 8px; }
.plan li { display: flex; align-items: center; gap: 10px; }
.plan .dot { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--ink); background: var(--c); flex: none; }
.plan .mins { color: var(--ink-soft); margin-left: auto; white-space: nowrap; }

/* ---------- questions ---------- */
.q-meta { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.tag {
  font-size: .85rem; padding: 2px 10px; border: 2px solid var(--ink); border-radius: var(--hand-2);
  background: var(--sky);
}
.tag.marks { background: var(--mustard); }
.tag.src { background: var(--paper); }
.q-text { font-size: 1.35rem; white-space: pre-line; margin-bottom: 14px; }
.options { display: grid; gap: 10px; }
.opt {
  text-align: left; font: inherit; font-size: 1.2rem; color: var(--ink);
  background: var(--paper); border: 3px solid var(--ink); border-radius: var(--hand-2);
  padding: 10px 14px; cursor: pointer; display: flex; gap: 12px; align-items: center;
}
.opt .letter {
  flex: none; width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--ink);
  display: grid; place-items: center; font-family: Gaegu, cursive; font-weight: 700; background: var(--paper-2);
}
.opt:hover:not(:disabled) { background: #fff3cf; }
.opt.right { background: #d8f0c8; border-color: var(--good); }
.opt.right .letter { background: var(--grass); }
.opt.wrong { background: #fde0dc; border-color: var(--bad); }
.opt:disabled { cursor: default; }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); } }

.feedback {
  margin-top: 14px; padding: 12px 16px; border: 3px dashed var(--ink); border-radius: var(--hand);
  display: flex; gap: 12px; align-items: flex-start;
}
.feedback.good { background: #e6f5dc; }
.feedback.hint { background: #fff3cf; }
.feedback.bad { background: #fde8e4; }
.feedback .fb-mithu { width: 64px; flex: none; }
.feedback .fb-mithu svg { width: 100%; height: auto; overflow: visible; }

.progress-dots { display: flex; gap: 6px; }
.progress-dots span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); background: var(--paper-2); }
.progress-dots span.on { background: var(--teal); }
.progress-dots span.miss { background: var(--coral); }

textarea {
  width: 100%; min-height: 120px; font: inherit; font-size: 1.2rem; color: var(--ink);
  background: var(--paper); border: 3px solid var(--ink); border-radius: var(--hand-2); padding: 12px; resize: vertical;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip { padding: 3px 12px; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper); }
.chip.hit { background: var(--grass); }
.model { background: #eef6ff; border-left: 6px solid var(--sky); padding: 10px 14px; border-radius: 6px; }

/* ---------- story ---------- */
.story-text {
  min-height: 3.4em; font-size: 1.45rem; font-family: "Patrick Hand", cursive; margin: 14px 4px 10px;
}
.story-text .caret { display: inline-block; width: 2px; height: 1em; background: var(--ink); vertical-align: -2px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.pop { opacity: 0; animation: pop .45s cubic-bezier(.2, 1.6, .4, 1) forwards; }
@keyframes pop { from { opacity: 0; } to { opacity: 1; } }
.art-frame { animation: frameIn .35s ease-out both; }
@keyframes frameIn { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: none; } }

.pause-q { margin-top: 12px; }

/* ---------- play ---------- */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.tab {
  font-family: Gaegu, cursive; font-weight: 700; font-size: 1.2rem; color: var(--ink);
  border: 3px solid var(--ink); border-radius: var(--hand-2); background: var(--paper); padding: 6px 14px; cursor: pointer;
}
.tab[aria-selected="true"] { background: var(--sky); }
.tab .tick { color: var(--good); }
.readout { font-family: Gaegu, cursive; font-weight: 700; font-size: 1.3rem; }
.predict { background: #fff3cf; border: 3px dashed var(--ink); border-radius: var(--hand); padding: 12px 16px; margin-top: 12px; }
.predict .row { margin-top: 8px; }

/* ---------- key idea / summary ---------- */
.key {
  background: #fff8e2; border: 3px solid var(--ink); border-radius: var(--hand-2); padding: 14px 18px;
  font-size: 1.25rem; margin-top: 12px;
}
.key b { font-family: Gaegu, cursive; font-size: 1.35rem; }
.summary-card { background: var(--paper-2); }
.summary-card ul { padding-left: 1.2em; margin: 0; }
.summary-card li { margin: 6px 0; }

/* ---------- mission ---------- */
.checklist { list-style: none; padding: 0; margin: 8px 0 14px; display: grid; gap: 8px; }
.checklist label { display: flex; gap: 10px; align-items: center; cursor: pointer; font-size: 1.2rem; }
.checklist input { width: 26px; height: 26px; accent-color: var(--teal); }

/* ---------- wrap ---------- */
.crayon-new { animation: crayonIn 1s .4s cubic-bezier(.2, 1.5, .4, 1) both; }
@keyframes crayonIn { from { transform: translateY(-120px); opacity: 0; } to { transform: none; opacity: 1; } }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0; }
.stat { text-align: center; border: 3px solid var(--ink); border-radius: var(--hand-2); padding: 8px; background: var(--paper); }
.stat b { display: block; font-family: Gaegu, cursive; font-size: 2rem; }

/* ---------- overlay ---------- */
.overlay { position: fixed; inset: 0; background: rgba(45, 58, 110, .35); display: grid; place-items: center; padding: 16px; z-index: 10; }
.overlay[hidden] { display: none; }
.overlay-card { max-width: 440px; text-align: center; }
.overlay-card svg { width: 160px; height: auto; overflow: visible; }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 20; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 22px; border: 2px solid var(--ink); border-radius: 3px; animation: fall 2.2s ease-in forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

@media (max-width: 640px) {
  body { font-size: 18px; }
  h1 { font-size: 2rem; }
  .welcome { grid-template-columns: 1fr; }
  .welcome .who { max-width: 150px; margin: 0 auto; }
  .card { padding: 16px 14px 14px; }
  .step .lbl { font-size: .62rem; }
  .q-text { font-size: 1.2rem; }
  .story-text { font-size: 1.25rem; }
  .day-title { font-size: 1.2rem; }
  .brand { width: 44px; height: 44px; }
  .btn { font-size: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; }
}

.crayon-box { max-width: 420px; margin: 4px auto 0; }
.welcome .who svg { width: 100%; height: auto; overflow: visible; }

@media (max-width: 640px) {
  .topbar { gap: 8px; padding-top: 8px; }
  .day-sub { display: none; }
  .day-title { font-size: 1.05rem; line-height: 1.15; }
  .icon-btn { width: 38px; height: 38px; font-size: 1.05rem; }
  .timer { font-size: .95rem; padding: 4px 8px; }
  .welcome .who { max-width: 120px; }
}
.row.between { flex-wrap: nowrap; }
@media (max-width: 640px) {
  .progress-dots { gap: 4px; }
  .progress-dots span { width: 10px; height: 10px; }
  .row.between .btn { padding-left: 12px; padding-right: 12px; }
}

/* ---------- welcome on phones: compact, with "Let's go!" always reachable ---------- */
.hello { display: flex; align-items: center; gap: 10px; }
.hello h1 { margin: 0; }
.who-mini { display: none; width: 58px; flex: none; }
.who-mini svg { width: 100%; height: auto; overflow: visible; }
.start-row { margin-top: 16px; }

@media (max-width: 640px) {
  .welcome { display: block; }
  .welcome .who { display: none; }
  .who-mini { display: block; }
  .welcome .bubble { border: 0; padding: 0; font-size: 1.1rem; background: none; }
  .welcome .bubble p { margin: 10px 0; }
  .plan { grid-template-columns: 1fr 1fr; gap: 6px 14px; margin: 10px 0; font-size: 1rem; }
  .plan .dot { width: 16px; height: 16px; border-width: 2px; }
  .plan .mins { font-size: .9rem; }
  .start-row {
    position: sticky; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); z-index: 5;
    margin-top: 10px;
  }
  .start-row .btn { width: 100%; }
}
@media (max-width: 640px) {
  .options { gap: 8px; }
  .opt { padding: 7px 12px; font-size: 1.08rem; gap: 10px; }
  .opt .letter { width: 28px; height: 28px; border-width: 2px; font-size: .95rem; }
  .feedback { padding: 10px 12px; }
  .feedback .fb-mithu { width: 46px; }
}
@media (max-width: 640px) {
  h2 { font-size: 1.55rem; }
  .stage > p { font-size: 1rem; }
}

/* Hear again: small replay link under explanations and story lines */
.hear {
  font: inherit; font-size: .95rem; color: var(--ink); background: var(--paper-2);
  border: 2px solid var(--ink); border-radius: 999px; padding: 2px 12px; margin-top: 8px; cursor: pointer;
}
.story-text .hear { vertical-align: middle; margin-top: 0; }
.hear:hover { background: var(--sky); }
.challenge-offer {
  margin-top: 14px; padding: 10px 14px; border: 3px dashed var(--mustard); border-radius: var(--hand-2); background: #fff8e2;
}

/* ---------- home: lesson picker ---------- */
.brand-btn { background: none; border: 0; padding: 0; width: 100%; height: 100%; cursor: pointer; }
.home-hello { display: flex; align-items: center; gap: 14px; margin: 6px 0 16px; }
.home-hello .who-mini { display: block; width: 72px; }
.home-hello h1 { font-size: 2rem; margin: 0 0 4px; text-wrap: balance; }
.home-hello p { margin: 0; }
.lesson-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.lesson-card {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto auto auto; column-gap: 12px; row-gap: 2px;
  text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  background: var(--paper-2); border: 3px solid var(--ink); border-radius: var(--hand);
  padding: 14px 16px; box-shadow: 4px 5px 0 var(--c); transition: transform .08s, box-shadow .08s;
}
.lesson-card:hover { transform: translate(-1px, -1px); box-shadow: 6px 7px 0 var(--c); }
.lesson-card:focus-visible { outline: 3px solid var(--mustard); outline-offset: 3px; }
.lc-icon { grid-row: 1 / span 4; font-size: 2.2rem; width: 58px; height: 58px; display: grid; place-items: center; border: 3px solid var(--ink); border-radius: 50%; background: var(--c); }
.lc-subject { font-size: .85rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
.lc-title { font-family: Gaegu, cursive; font-weight: 700; font-size: 1.45rem; line-height: 1.1; }
.lc-chapter { font-size: .95rem; color: var(--ink-soft); }
.lc-status { justify-self: start; margin-top: 6px; font-size: .85rem; padding: 1px 10px; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper); }
.home-note { margin-top: 18px; color: var(--ink-soft); }
@media (max-width: 640px) {
  .home-hello h1 { font-size: 1.5rem; }
  .home-hello .who-mini { width: 56px; }
  .lesson-grid { grid-template-columns: 1fr; gap: 10px; }
  .lesson-card { padding: 10px 12px; }
  .lc-icon { width: 48px; height: 48px; font-size: 1.7rem; }
  .lc-title { font-size: 1.25rem; }
}
@media (max-width: 640px) {
  .start-row .btn { width: auto; }
  .start-row #startBtn { flex: 1; }
}

/* ---------- browsing: subjects, chapters, concepts ---------- */
.pbar { display: block; height: 10px; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper); overflow: hidden; }
.pbar > span { display: block; height: 100%; background: var(--c); border-radius: 999px; }
.subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.subject-card, .resume {
  display: flex; gap: 14px; align-items: center; text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  background: var(--paper-2); border: 3px solid var(--ink); border-radius: var(--hand);
  padding: 16px; box-shadow: 4px 5px 0 var(--c); transition: transform .08s, box-shadow .08s;
}
.subject-card:hover, .resume:hover { transform: translate(-1px, -1px); box-shadow: 6px 7px 0 var(--c); }
.subject-card:focus-visible, .resume:focus-visible, .concept:focus-visible, .chapter summary:focus-visible { outline: 3px solid var(--mustard); outline-offset: 3px; }
.subject-card .lc-icon, .resume .lc-icon, .subject-title .lc-icon {
  flex: none; font-size: 2rem; width: 62px; height: 62px; display: grid; place-items: center;
  border: 3px solid var(--ink); border-radius: 50%; background: var(--c);
}
.sc-body { display: grid; gap: 4px; flex: 1; min-width: 0; }
.subject-card .lc-title { font-size: 1.7rem; }
.sc-meta { font-size: .9rem; color: var(--ink-soft); }
.resume { width: 100%; margin-bottom: 16px; background: #fff8e2; }
.resume > span:last-child { display: grid; gap: 2px; }
.resume .lc-icon { font-size: 1.5rem; width: 52px; height: 52px; }
.subject-head { margin-bottom: 10px; }
.subject-title { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.subject-title > div { flex: 1; display: grid; gap: 6px; }
.subject-title h1 { margin: 0; }
.chips.filter { margin: 4px 0 8px; }
.chips.filter .chip { font: inherit; font-size: .95rem; cursor: pointer; color: var(--ink); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 10px; margin: 0 0 14px; font-size: .85rem; }
.pill { display: inline-block; white-space: nowrap; font-size: .85rem; padding: 1px 10px; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper); }
.pill.new { background: var(--sky); }
.pill.progress { background: var(--mustard); }
.pill.done { background: var(--grass); }
.pill.soon { border-style: dashed; color: var(--ink-soft); border-color: var(--ink-soft); }
.chapter { background: var(--paper-2); border: 3px solid var(--ink); border-radius: var(--hand-2); margin: 0 0 12px; box-shadow: 3px 4px 0 rgba(45, 58, 110, .15); }
.chapter summary {
  list-style: none; cursor: pointer; display: grid; grid-template-columns: auto 1fr auto; gap: 2px 12px; align-items: center;
  padding: 12px 16px; border-left: 10px solid var(--c); border-radius: var(--hand-2);
}
.chapter summary::-webkit-details-marker { display: none; }
.ch-num { font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); grid-column: 1 / 3; }
.ch-title { font-family: Gaegu, cursive; font-weight: 700; font-size: 1.35rem; line-height: 1.15; grid-column: 1 / 3; text-wrap: balance; }
.ch-tag { grid-column: 3; grid-row: 1; justify-self: end; font-size: .78rem; padding: 0 8px; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper); }
.ch-progress { grid-column: 3; grid-row: 2; display: flex; gap: 8px; align-items: center; font-size: .85rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ch-progress .pbar { width: 90px; height: 8px; }
.chapter[open] summary { border-bottom: 2px dashed rgba(45, 58, 110, .25); border-radius: var(--hand-2) var(--hand-2) 0 0; }
.concepts { list-style: none; margin: 0; padding: 6px 10px 10px; display: grid; gap: 4px; }
.concept {
  width: 100%; display: grid; grid-template-columns: 3.2em 1fr auto; gap: 10px; align-items: center; text-align: left;
  font: inherit; font-size: 1.05rem; color: var(--ink); background: none; border: 0; border-radius: 10px; padding: 8px 8px; cursor: pointer;
}
.concept:hover { background: #fff3cf; }
.concept .cn { font-variant-numeric: tabular-nums; color: var(--ink-soft); font-size: .9rem; }
.concept.soon { cursor: default; color: var(--ink-soft); }
.concept.soon:hover { background: none; }
.concept.new .ct, .concept.progress .ct { font-weight: bold; }
.star { font-size: .9em; }
.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 15;
  background: var(--ink); color: var(--paper-2); padding: 10px 18px; border-radius: 999px; font-size: 1rem; max-width: calc(100vw - 32px); text-align: center;
}
@media (max-width: 640px) {
  .subject-grid { grid-template-columns: 1fr; gap: 10px; }
  .subject-card { padding: 12px; }
  .subject-card .lc-icon, .subject-title .lc-icon { width: 50px; height: 50px; font-size: 1.6rem; }
  .subject-card .lc-title { font-size: 1.4rem; }
  .chapter summary { padding: 10px 12px; grid-template-columns: 1fr auto; }
  .ch-num, .ch-title { grid-column: 1; }
  .ch-tag { grid-column: 2; }
  .ch-progress { grid-column: 2; }
  .ch-progress .pbar { width: 54px; }
  .concept { grid-template-columns: 2.6em 1fr; font-size: 1rem; padding: 8px 4px; }
  .concept .pill { grid-column: 2; justify-self: start; }
  .legend { font-size: .8rem; }
}

/* the hidden attribute always wins over display rules like .row { display: flex } */
[hidden] { display: none !important; }

/* ---------- questions: pick, then Check answer ---------- */
.opt.selected { background: #dff1fb; border-color: var(--ink); box-shadow: inset 0 0 0 3px var(--sky); }
.opt.selected .letter { background: var(--sky); }
.q-count { font-size: .85rem; color: var(--ink-soft); white-space: nowrap; }
.q-actions { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: center; justify-content: flex-end; margin-top: 14px; }
.q-tip { flex: 1 1 220px; font-size: .95rem; color: var(--ink-soft); }
.q-tip.again { color: var(--ink); background: #fff3cf; border-radius: 8px; padding: 4px 10px; }
.btn.check:not(:disabled) { background: var(--mustard); }
@media (max-width: 640px) {
  .q-actions { justify-content: stretch; }
  .q-actions .check, .q-actions .next { flex: 1 1 100%; }
  .q-count { display: none; }
}

/* ---------- navigation: exit button and step footer ---------- */
.exit-btn { white-space: nowrap; }
.step-foot {
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center;
  margin-top: 22px; padding-top: 14px; border-top: 2px dashed rgba(45, 58, 110, .25);
}
.step-foot .sf-where { text-align: center; font-size: .9rem; color: var(--ink-soft); }
@media (max-width: 640px) {
  .exit-btn { padding: 4px 10px 6px; font-size: 1rem; min-height: 38px; }
  .step-foot { grid-template-columns: 1fr 1fr; }
  .step-foot .sf-where { grid-column: 1 / -1; grid-row: 1; }
  .step-foot [data-go]:last-child { justify-self: end; }
}
@media (max-width: 640px) {
  .exit-btn { width: 38px; padding: 0; display: grid; place-items: center; }
  .exit-txt { display: none; }
}

/* ---------- dashboard ---------- */
.dash { display: grid; gap: 18px; }
.hero {
  display: grid; grid-template-columns: 120px 1fr; gap: 18px; align-items: center;
  background: linear-gradient(135deg, #fff8e2, var(--paper-2)); border: 3px solid var(--ink); border-radius: var(--hand);
  padding: 16px 22px; box-shadow: 5px 6px 0 rgba(45, 58, 110, .18);
}
.hero-mithu svg { width: 100%; height: auto; overflow: visible; animation: bob 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-2deg); } }
.hero h1 { font-size: 2.3rem; margin: 0 0 4px; text-wrap: balance; }
.bubble-line { font-size: 1.2rem; margin: 0 0 6px; }
.edit-name { background: none; border: 0; font-size: 1.1rem; cursor: pointer; vertical-align: middle; opacity: .7; padding: 4px; }
.edit-name:hover, .edit-name:focus-visible { opacity: 1; }
.name-form { margin-top: 8px; display: grid; gap: 8px; }
.name-form label { font-family: Gaegu, cursive; font-weight: 700; font-size: 1.5rem; }
.name-form input {
  font: inherit; font-size: 1.3rem; color: var(--ink); padding: 8px 14px; min-width: 0; flex: 1 1 200px;
  background: var(--paper-2); border: 3px solid var(--ink); border-radius: var(--hand-2);
}
.name-form input:focus { outline: 3px solid var(--mustard); outline-offset: 2px; }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.dash-main { display: grid; gap: 14px; min-width: 0; }
.dash-side { display: grid; gap: 14px; }
.dash-h { margin: 8px 0 0; font-size: 1.6rem; }

.mission {
  display: grid; gap: 6px; text-align: left; font: inherit; color: var(--ink); cursor: pointer; position: relative;
  background: var(--paper-2); border: 3px solid var(--ink); border-radius: var(--hand);
  padding: 18px 22px 20px; box-shadow: 6px 7px 0 var(--c); transition: transform .08s, box-shadow .08s; overflow: hidden;
}
.mission::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 10px; background: var(--c); }
.mission:hover { transform: translate(-1px, -2px); box-shadow: 8px 9px 0 var(--c); }
.mission:focus-visible, .subj-open:focus-visible, .subj-next:focus-visible { outline: 3px solid var(--mustard); outline-offset: 3px; }
.m-label { font-size: .9rem; letter-spacing: .08em; text-transform: uppercase; margin-top: 4px; }
.m-title { font-family: Gaegu, cursive; font-weight: 700; font-size: 2rem; line-height: 1.1; text-wrap: balance; }
.m-meta { color: var(--ink-soft); }
.m-steps { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.m-steps i { width: 26px; height: 10px; border: 2px solid var(--ink); border-radius: 6px; background: var(--paper); }
.m-steps i.on { background: var(--c); }
.m-steps em { font-style: normal; font-size: .9rem; color: var(--ink-soft); margin-left: 4px; }
.m-go {
  justify-self: start; margin-top: 6px; font-family: Gaegu, cursive; font-weight: 700; font-size: 1.5rem; color: #fff;
  background: var(--teal); border: 3px solid var(--ink); border-radius: var(--hand); padding: 6px 26px 8px; box-shadow: 3px 4px 0 var(--ink);
}
.mission.done { cursor: default; --c: var(--grass); }

.subjects { display: grid; gap: 12px; }
.subj { background: var(--paper-2); border: 3px solid var(--ink); border-radius: var(--hand-2); box-shadow: 4px 5px 0 var(--c); overflow: hidden; }
.subj-open {
  width: 100%; display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; text-align: left;
  font: inherit; color: var(--ink); background: none; border: 0; padding: 12px 16px; cursor: pointer;
}
.subj-open:hover { background: #fff8e2; }
.subj-body { display: grid; gap: 2px; min-width: 0; }
.subj-title { font-family: Gaegu, cursive; font-weight: 700; font-size: 1.6rem; line-height: 1.1; }
.subj-icon { font-size: 1.3rem; }
.subj-meta { font-size: .9rem; color: var(--ink-soft); }
.subj-arrow { font-size: 2.2rem; color: var(--ink-soft); }
.subj-next {
  width: 100%; display: flex; gap: 8px; align-items: center; text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  background: color-mix(in srgb, var(--c) 18%, var(--paper-2)); border: 0; border-top: 2px dashed rgba(45, 58, 110, .25); padding: 10px 16px;
}
.subj-next b { flex: 1; min-width: 0; }
.subj-next .go { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border: 2px solid var(--ink); border-radius: 50%; background: var(--c); color: var(--ink); }
.subj-next:hover { background: color-mix(in srgb, var(--c) 30%, var(--paper-2)); }
.subj-next.none { cursor: default; margin: 0; color: var(--ink-soft); }
.ring { flex: none; display: block; }

.tile { background: var(--paper-2); border: 3px solid var(--ink); border-radius: var(--hand-2); padding: 12px 14px; box-shadow: 3px 4px 0 rgba(45, 58, 110, .15); }
.tile-h { font-family: Gaegu, cursive; font-weight: 700; font-size: 1.3rem; margin-bottom: 6px; }
.tile p { margin: 0 0 8px; font-size: 1rem; }
.tile-sub { display: block; text-align: center; font-size: .9rem; color: var(--ink-soft); }
.streak .flame { font-size: 1.5rem; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.day { display: grid; justify-items: center; gap: 2px; font-size: .8rem; color: var(--ink-soft); }
.day i { width: 30px; height: 30px; border: 2px solid var(--ink); border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: .9rem; background: var(--paper); }
.day.done i { background: var(--mustard); }
.day.today i { box-shadow: 0 0 0 3px var(--coral); }
.day.future i { border-style: dashed; opacity: .5; }
.time { display: flex; gap: 12px; align-items: center; }
.time span { font-size: .9rem; color: var(--ink-soft); }
.crayons .crayon-box { max-width: 100%; margin: 0; }
.fact { background: #eef8ec; }

@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
  .dash-side { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
}
@media (max-width: 640px) {
  .hero { grid-template-columns: 70px 1fr; padding: 12px 14px; gap: 12px; }
  .hero h1 { font-size: 1.6rem; }
  .bubble-line { font-size: 1.05rem; }
  .name-form label { font-size: 1.3rem; }
  .m-title { font-size: 1.6rem; }
  .mission { padding: 14px 16px 16px; }
  .m-go { justify-self: stretch; text-align: center; }
  .subj-open { padding: 10px 12px; gap: 10px; }
  .subj-open .ring { width: 58px; height: 58px; }
  .subj-title { font-size: 1.35rem; }
  .dash-side { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .hero-mithu svg { animation: none; } }
/* let every dashboard column shrink to the screen; long words and inputs wrap instead of widening the page */
.dash { grid-template-columns: minmax(0, 1fr); }
.hero-talk, .mission, .subj, .tile { min-width: 0; }
.name-form input { width: 100%; }
.name-form .row { flex-wrap: wrap; }

/* ---------- Mithu's fact of the day ---------- */
.fact-card {
  position: relative; display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 18px; align-items: center;
  background: radial-gradient(circle at 92% 12%, #fff3b0 0 70px, transparent 72px), linear-gradient(135deg, #fffbe9, #fff3cf);
  border: 3px solid var(--ink); border-radius: var(--hand-2); padding: 16px 18px; box-shadow: 6px 7px 0 var(--c);
}
.fact-card.is-new { animation: factIn .9s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes factIn { 0% { transform: scale(.96) rotate(-1deg); opacity: 0; } 60% { transform: scale(1.01) rotate(.4deg); opacity: 1; } 100% { transform: none; } }
.fact-thumb {
  background: var(--paper-2); border: 3px solid var(--ink); border-radius: 10px; padding: 8px 8px 18px;
  transform: rotate(-3deg); box-shadow: 3px 4px 0 rgba(45, 58, 110, .25);
}
.fact-thumb svg { display: block; width: 100%; height: auto; border-radius: 6px; }
.fact-body { display: grid; gap: 6px; min-width: 0; }
.fact-top { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.fact-label { font-family: Gaegu, cursive; font-weight: 700; font-size: 1.45rem; }
.fact-new {
  font-size: .8rem; font-weight: bold; letter-spacing: .06em; padding: 2px 10px; border-radius: 999px;
  background: var(--coral); color: #fff; border: 2px solid var(--ink); animation: sparkle 1.6s ease-in-out infinite;
}
@keyframes sparkle { 50% { transform: scale(1.08) rotate(-3deg); box-shadow: 0 0 0 4px rgba(239, 111, 94, .25); } }
.fact-tag { justify-self: start; font-size: .85rem; padding: 1px 10px; border: 2px solid var(--ink); border-radius: 999px; background: color-mix(in srgb, var(--c) 35%, var(--paper-2)); }
.fact-text { font-size: 1.3rem; line-height: 1.4; margin: 2px 0 4px; text-wrap: pretty; }
.fact-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.fact-say { background: var(--mustard); }
@media (max-width: 640px) {
  .fact-card { grid-template-columns: 1fr; padding: 14px; gap: 12px; }
  .fact-thumb { max-width: 260px; justify-self: center; }
  .fact-text { font-size: 1.15rem; }
  .fact-actions .btn { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) { .fact-card.is-new, .fact-new { animation: none; } }
@media (max-width: 640px) {
  .fact-thumb { max-width: 210px; padding: 6px 6px 14px; }
  .fact-actions .btn { flex: 1 1 40%; }
}
/* the fact of the day sits in the greeting banner, top of the page */
.hero { grid-template-columns: 120px minmax(0, 1fr); }
.hero .fact-card { grid-column: 1 / -1; box-shadow: 4px 5px 0 var(--c); }
@media (min-width: 1000px) {
  .hero { grid-template-columns: 110px minmax(0, .8fr) minmax(0, 1.5fr); }
  .hero .fact-card { grid-column: auto; grid-template-columns: 170px minmax(0, 1fr); gap: 14px; padding: 12px 14px; }
  .hero .fact-text { font-size: 1.12rem; }
  .hero .fact-label { font-size: 1.25rem; }
}
@media (max-width: 640px) { .hero { grid-template-columns: 70px minmax(0, 1fr); } }
@media (max-width: 640px) { .hero .fact-thumb { max-width: 170px; } .hero .fact-card { gap: 8px; } }
