:root {
  --bg: #FFF8EC; --card: #fff; --ink: #1F2340; --muted: #5A5E7C; --line: #EADFC6; --field: #857852;
  --pri: #4B3FD8; --pri-d: #3629B3; --sun: #FFB020; --sun-d: #E08A00; --teal: #19B6C8; --pink: #E4577F;
  --green: #14794C; --green-bg: #DDF5E8; --red: #B33030; --red-bg: #FDE6E6; --night: #12163B;
  --r: 18px; --tab: 64px;
  --cta-from: #C2335E; --cta-to: #C4421C; --cta-shadow: #8F2447; --focus: #4B3FD8; --hdr-h: 60px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { color-scheme: light; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", sans-serif;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.2; }
h1 { font-size: 1.55rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .7em; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
[hidden] { display: none !important; }

/* shell */
#hdr {
  position: sticky; top: 0; z-index: 20; max-width: 480px; margin: 0 auto; display: flex; align-items: center; gap: 6px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: var(--bg); min-width: 0;
}
/* The header must fit at 320 px, in Hindi and at 200% text: every item shrinks or hides, none may push the page wider.
   Sizes here are px on purpose (the logo is a brand mark, not reading text) so a bigger root font cannot widen it. */
.logo { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: min(1.15rem, 18px); flex: 1 1 0; min-width: 0; overflow: hidden; white-space: nowrap; letter-spacing: -.2px; }
.logo svg { width: 28px; height: 28px; flex: none; }
.logo small { font-weight: 700; color: var(--pri-t); background: #E8E5FF; border-radius: 8px; padding: 1px 7px; font-size: 12px; letter-spacing: .5px; text-transform: uppercase; }
.langbtn, .iconbtn {
  min-width: 44px; height: 44px; border-radius: 14px; border: 2px solid var(--field); background: #fff; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
}
.langbtn { padding: 0 8px; flex: none; }
.iconbtn { flex: none; }
.iconbtn svg { width: 22px; height: 22px; }
#app { max-width: 480px; margin: 0 auto; padding: 4px 14px calc(var(--tab) + 28px + env(safe-area-inset-bottom)); min-width: 0; overflow-wrap: break-word; }
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: #fff; border-top: 2px solid var(--line);
  display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom);
}
#tabs .in { display: flex; width: 100%; max-width: 480px; }
#tabs a {
  flex: 1; min-height: var(--tab); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: 13px; font-weight: 700; line-height: 1.15; text-align: center; min-width: 0; padding: 4px 2px; overflow-wrap: anywhere;
}
#tabs a svg { width: 26px; height: 26px; }
#tabs a.on { color: var(--pri-t); }
body.in-lesson #tabs { display: none; }
/* Lesson: the footer sits IN the page flow at the end of #app and sticks to the bottom of the screen, so it can never cover
   the lesson's own button (it takes up its own space). The header scrolls away to give the lesson more room. */
body.in-lesson #app { padding-bottom: 0; min-height: calc(100vh - var(--hdr-h) - env(safe-area-inset-top)); min-height: calc(100dvh - var(--hdr-h) - env(safe-area-inset-top)); display: flex; flex-direction: column; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
body.in-lesson #hdr { position: static; }
body.in-lesson #app > * { flex: none; }
body.in-lesson #app > .lfoot { margin-top: auto; }
html { scroll-padding-bottom: 150px; scroll-padding-top: 12px; }   /* at least the tallest footer (about 128 px in Hindi) plus a gap */

/* basics */
.card { background: var(--card); border: 2px solid var(--line); border-radius: var(--r); padding: 14px; margin: 0 0 12px; }
.card.hero { background: linear-gradient(135deg, #4B3FD8, #6A50E8); color: #fff; border: 0; }
.card.hero .muted { color: #F3F0FF; }
.card.night { background: var(--night); color: #fff; border: 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 10px 20px; border-radius: 16px;
  border: 0; font-weight: 800; background: #fff; border: 2px solid var(--field); text-decoration: none; color: var(--ink); text-align: center; line-height: 1.3; overflow-wrap: break-word;
}
.btn.pri { background: var(--pri); color: #fff; border-color: var(--pri); box-shadow: 0 4px 0 var(--pri-d); }
.btn.pri:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--pri-d); }
.btn.ok { background: var(--green); border-color: var(--green); color: #fff; box-shadow: 0 4px 0 #0E5C39; }
.btn.sun { background: var(--sun); border-color: var(--sun); box-shadow: 0 4px 0 var(--sun-d); }
.btn.ghost { background: transparent; }
.btn.ok:active { transform: translateY(3px); box-shadow: 0 1px 0 #0E5C39; }
.btn.sm { min-height: 44px; padding: 6px 14px; font-size: .92rem; }
.btn.block { display: flex; width: 100%; }
.btn[disabled] { opacity: .45; box-shadow: none; transform: none; cursor: default; }
.btn.pri[disabled] { opacity: 1; background: #E6E1D6; border-color: #E6E1D6; color: #5A5E7C; }   /* not ready yet: readable, not washed out */
.row { display: flex; gap: 10px; margin: 10px 0; flex-wrap: wrap; } .row > .btn { flex: 1 1 130px; min-width: min-content; } .row > .linkbtn { flex: 1 1 auto; margin: 0; }
.chip { display: inline-flex; align-items: center; min-height: 44px; padding: 4px 14px; border-radius: 999px; border: 2px solid var(--field); background: #fff; font-weight: 800; line-height: 1.25; }
.chip.on { background: var(--pri); color: #fff; border-color: var(--pri); }
.chip.layer-a.on { background: var(--sun); border-color: var(--sun-d); color: var(--ink); }
.chip.layer-d.on { background: var(--teal); border-color: #0E8CA0; color: var(--ink); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.badge { display: inline-block; font-size: 13px; font-weight: 800; border-radius: 8px; padding: 2px 8px; background: #EFEAFB; color: var(--pri-t); }
.badge.cls { background: #E8F7FA; color: #0B7A8A; }
.badge.soon { background: #F1EEE6; color: var(--muted); }
.badge.draft { background: #FFF0CC; color: #8A5B00; }
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: #fff; border: 2px solid var(--line); border-radius: 16px; padding: 12px; min-height: 64px;
}
.item:active { background: #FBF3E0; }
.item .grow { flex: 1; min-width: 0; }
.item .t { font-weight: 800; overflow-wrap: anywhere; }
.item .sub { font-size: .85rem; color: var(--muted); overflow-wrap: anywhere; }
.star { width: 30px; height: 30px; flex: none; }
.big-cta { display: block; width: 100%; text-align: left; border: 0; border-radius: 22px; padding: 18px; color: #fff; background: linear-gradient(135deg, var(--cta-from), var(--cta-to)); box-shadow: 0 5px 0 var(--cta-shadow); margin-bottom: 14px; }
.big-cta:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--cta-shadow); }
.big-cta h2 { font-size: 1.4rem; margin-bottom: 4px; }
.big-cta p { margin: 0; }

/* fractions */
.fr { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; line-height: 1.05; margin: 0 .12em; font-weight: 800; }
.fr > span:first-child { border-bottom: 2.5px solid currentColor; padding: 0 .2em .06em; }
.fr > span:last-child { padding: .06em .2em 0; }
.bigfr { font-size: 1.5rem; font-weight: 800; }
.blank { display: inline-block; min-width: 1.2em; padding: 0 .25em; border-radius: 8px; background: #FFF0CC; border: 2px dashed var(--sun-d); text-align: center; }
.blank.filled { background: #E8E5FF; border: 2px solid var(--pri); color: var(--pri-t); }

/* lesson shell */
.lhead { display: flex; align-items: center; gap: 8px; margin: 2px 0 10px; }
.dots { flex: 1; display: flex; gap: 5px; }
.dots i { flex: 1; height: 8px; border-radius: 6px; background: #E8DEC4; }
.dots i.done { background: var(--green); } .dots i.cur { background: var(--pri); }
.stagetitle { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; }
.stagetitle .num { width: 30px; height: 30px; border-radius: 50%; background: var(--pri); color: #fff; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.stagetitle h2 { margin: 0; }
.lfoot {
  position: sticky; bottom: 0; z-index: 30; background: var(--bg); border-top: 2px solid var(--line);
  margin: 14px -14px 0; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center;
}
.lfoot .in { width: 100%; max-width: 480px; display: flex; flex-wrap: wrap; gap: 10px; }
.lfoot .btn { flex: 1; min-width: 0; }
.lfoot .why { flex: 1 0 100%; order: 3; }
.scene { width: 100%; height: auto; display: block; border-radius: 18px; margin-bottom: 10px; }
.story { font-size: 1.08rem; }
.wprompt { font-weight: 700; margin: 0 0 10px; font-size: 1.02rem; }
.taskhead { font-size: 13px; font-weight: 800; color: var(--pri-t); text-transform: uppercase; letter-spacing: .6px; margin: 4px 0; }
.bar-svg, .grid-svg, .viz, .pic { width: 100%; height: auto; display: block; background: #fff; border: 2px solid var(--line); border-radius: 16px; }
.bar-svg { touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.grid-svg { touch-action: none; user-select: none; -webkit-user-select: none; max-width: 340px; margin: 0 auto 6px; }
.pic { margin: 6px 0 10px; }
.svg-lab { font-family: inherit; }
.cap { min-height: 3.2rem; margin: 8px 0 4px; display: flex; flex-direction: column; justify-content: center; }
.capt { font-weight: 600; color: var(--ink); }
.msg { border-radius: 14px; padding: 0; margin: 6px 0; font-weight: 700; }
.msg.ok, .msg.warn { padding: 10px 12px; }
.msg.ok { background: var(--green-bg); color: #0F6B43; }
.msg.warn { background: #FFF0CC; color: #7A4F00; }
.note { background: #E8F7FA; border-radius: 14px; padding: 10px 12px; margin-top: 10px; font-weight: 600; }
.say { font-weight: 700; }
.expr { font-size: 1.5rem; font-weight: 800; padding: 14px 6px; text-align: center; background: #fff; border: 2px solid var(--line); border-radius: 16px; margin: 8px 0; line-height: 1.9; }
.fitlist { list-style: none; margin: 8px 0 0; padding: 0; font-size: .9rem; font-weight: 700; }
.fitlist li { padding: 2px 0; }
.fitlist li.ok { color: var(--green-t); } .fitlist li.no { color: var(--red-t); }
.fitlist li::before { content: "✓ "; } .fitlist li.no::before { content: "✗ "; }

/* slider */
.slider { margin: 10px 0; }
.sl-out { font-weight: 800; text-align: center; margin-bottom: 2px; }
.sl-row { display: flex; align-items: center; gap: 8px; }
.sl-btn, .st-btn { width: 48px; height: 48px; flex: none; border-radius: 50%; border: 2px solid var(--field); background: #fff; font-size: 1.5rem; font-weight: 800; line-height: 1; }
.sl-btn:active, .st-btn:active { background: #FBF3E0; }
.sl-btn[disabled], .st-btn[disabled], input[disabled] { opacity: .4; }
input[type=range] { -webkit-appearance: none; appearance: none; flex: 1; height: 44px; background: transparent; margin: 0; min-width: 0; touch-action: pan-y; }
input[type=range]::-webkit-slider-runnable-track { height: 12px; border-radius: 8px; background: #E8DEC4; }
input[type=range]::-moz-range-track { height: 12px; border-radius: 8px; background: #E8DEC4; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 40px; height: 40px; margin-top: -14px; border-radius: 50%; background: var(--sun); border: 4px solid var(--ink); box-shadow: 0 3px 0 rgba(0,0,0,.2); }
input[type=range]::-moz-range-thumb { width: 32px; height: 32px; border-radius: 50%; background: var(--sun); border: 4px solid var(--ink); }
.steppers { display: flex; gap: 14px; justify-content: center; margin: 6px 0; flex-wrap: wrap; }
.stepper { text-align: center; }
.st-lab { font-size: .78rem; font-weight: 800; color: var(--muted); margin-bottom: 2px; }
.st-row { display: flex; align-items: center; gap: 6px; }
.st-val { min-width: 54px; font-size: 1.6rem; font-weight: 800; padding: 2px 6px; border-radius: 12px; background: #fff; border: 2px solid var(--line); }

/* 3 ways */
.tabs3 { display: flex; gap: 8px; margin-bottom: 8px; }
.tab3 { flex: 1; min-height: 64px; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 2px solid var(--field); background: #fff; border-radius: 14px; font-size: 13px; font-weight: 800; padding: 4px; position: relative; line-height: 1.2; }
.tab3.on { border-color: var(--pri); background: #F1EFFF; }
.tab3.done::after { content: "✓"; position: absolute; top: 2px; right: 6px; color: var(--green-t); font-weight: 900; }
.micon { width: 40px; height: 28px; }
.vizbox { min-height: 120px; }
.vizcap { min-height: 3.4rem; font-weight: 700; margin: 8px 0; font-size: 1.05rem; }
.symsteps { background: #fff; border: 2px solid var(--line); border-radius: 16px; padding: 14px; min-height: 190px; font-size: 1.3rem; font-weight: 700; }
.symline { margin: 8px 0; } .symline small { font-size: .85rem; font-weight: 600; color: var(--muted); }
.symline b { color: var(--pri-t); }
.pop { animation: pop .35s ease-out both; transform-box: fill-box; transform-origin: center; }
@keyframes pop { 0% { opacity: 0; transform: scale(.7); } 100% { opacity: 1; transform: scale(1); } }

/* quiz */
.optbtn { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 58px; font-size: 1.15rem; font-weight: 800; background: #fff; border: 2px solid var(--field); border-radius: 16px; padding: 8px; }
.optbtn:active { background: #F1EFFF; border-color: var(--pri); }
.optbtn.notsure { font-weight: 700; color: var(--muted); border-style: dashed; font-size: .98rem; }
.optbtn.picked { border-color: var(--pri); background: #F1EFFF; }
.optpic { width: 140px; height: 50px; }
.optgrid { display: grid; gap: 10px; }
.optgrid.two { grid-template-columns: 1fr 1fr; }
.chain { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 12px; }
.chain span { font-size: 13px; font-weight: 800; border-radius: 999px; padding: 3px 10px; background: #fff; border: 2px solid var(--line); }
.chain .ok { background: var(--green-bg); border-color: #9ADBB9; color: #0F6B43; }
.chain .gap { background: #FFF0CC; border-color: #F0C466; color: #7A4F00; }

/* path ladder */
.ladder { position: relative; display: flex; flex-direction: column; gap: 0; margin: 12px 0; }
.rung { display: flex; gap: 12px; align-items: stretch; }
.rail { width: 34px; display: flex; flex-direction: column; align-items: center; flex: none; }
.rail .line { flex: 1; width: 4px; background: repeating-linear-gradient(#C9BDF7 0 6px, transparent 6px 11px); }
.rung:first-child .rail .line.up, .rung:last-child .rail .line.down { visibility: hidden; }
.rung .card { flex: 1; margin: 6px 0; }
.rung .card.next { border-color: var(--pri); box-shadow: 0 4px 0 #CFC9FA; }
.rung .card.done { background: #F2FBF6; border-color: #A9DEC2; }
.rung .card.target { border-style: dashed; }
.ref { font-size: .78rem; color: var(--muted); margin-top: 2px; }

/* map */
.mapwrap { background: radial-gradient(ellipse at 50% 20%, #232a6b, var(--night) 70%); border-radius: 22px; overflow: hidden; padding: 6px 0; margin: 0 0 12px; }
.mapsvg { width: 100%; height: auto; display: block; }
.mapsvg text { font-family: inherit; }
.mnode { cursor: pointer; }
.mnode:focus { outline: none; }
.pulse { animation: pulse 1.8s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes pulse { 0%,100% { opacity: .35; transform: scale(.9); } 50% { opacity: 1; transform: scale(1.15); } }
.twinkle { animation: tw 3s ease-in-out infinite; }
@keyframes tw { 0%,100% { opacity: .9; } 50% { opacity: .45; } }
.dash { animation: dash 1.2s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -16; } }
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; font-weight: 700; color: var(--muted); margin: 6px 0 12px; }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend svg { width: 16px; height: 16px; }
.sheetbg { position: fixed; inset: 0; background: rgba(18,22,59,.5); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: #fff; width: 100%; max-width: 480px; border-radius: 24px 24px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 86vh; overflow: auto; animation: rise .22s ease-out; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet h2 { margin-top: 2px; }
.sheet .x { float: right; }
.sheet .sec { margin-top: 14px; }
.sheet .sec h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.refrow { font-size: .92rem; padding: 3px 0; }
.seg { display: flex; gap: 6px; margin: 6px 0 10px; }
.seg .chip { flex: 1; justify-content: center; }

/* parent report */
.phone { background: #E5DDD5; border-radius: 22px; padding: 14px 10px; border: 2px solid var(--line); margin-bottom: 12px; }
.phone .who { font-size: .8rem; color: #46565F; text-align: center; margin-bottom: 8px; font-weight: 700; }
.bubble { background: #DCF8C6; border-radius: 14px 14px 4px 14px; padding: 12px 14px; font-size: .95rem; box-shadow: 0 1px 1px rgba(0,0,0,.15); white-space: pre-wrap; line-height: 1.5; margin-left: 18px; }
.bubble .time { display: block; text-align: right; font-size: 12px; color: #4E5D66; margin-top: 4px; }
.bar-mini { display: flex; gap: 4px; margin: 6px 0; }
.bar-mini i { flex: 1; height: 26px; border-radius: 6px; background: #E8DEC4; position: relative; }
.bar-mini i.on { background: var(--sun); }

/* celebration */
.celebrate { text-align: center; padding: 10px 0; }
.celebrate svg { width: 150px; height: 150px; }
.starburst { animation: burst .8s cubic-bezier(.2,1.4,.4,1) both; transform-origin: center; }
@keyframes burst { 0% { transform: scale(0) rotate(-40deg); } 100% { transform: scale(1) rotate(0); } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (min-width: 520px) { #app { padding-top: 12px; } }

/* ===== roles: welcome, accounts, textbook, parent, teacher ===== */
.center { text-align: center; }
.rolechip { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 10px; border-radius: 999px; background: #E8E5FF; color: var(--pri-t); font-weight: 800; font-size: 13px; text-decoration: none; }
.rolechip svg { width: 16px; height: 16px; }
.welcome { text-align: center; padding-top: 10px; }
.wlogo { display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 800; font-size: 1.3rem; margin-bottom: 6px; }
.wlogo svg { width: 36px; height: 36px; }
.welcome h1 { font-size: 1.6rem; margin-top: 8px; }
.rolecards { display: flex; flex-direction: column; gap: 12px; margin: 14px 0 10px; }
.rolecard {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; border: 2px solid var(--line); border-radius: 20px; padding: 16px; min-height: 92px; background: #fff;
  box-shadow: 0 4px 0 var(--line);
}
.rolecard:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.rolecard .emo { font-size: 2rem; width: 54px; height: 54px; display: inline-flex; align-items: center; justify-content: center; border-radius: 16px; flex: none; }
.rolecard.r-student .emo { background: #E8E5FF; } .rolecard.r-parent .emo { background: #FFE3EA; } .rolecard.r-teacher .emo { background: #DDF5E8; }
.rolecard .grow { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.rolecard b { font-size: 1.1rem; }
.rolecard .d { color: var(--muted); font-size: .9rem; line-height: 1.3; }
.rolecard .go { font-size: 1.8rem; color: var(--muted); }
.linkbtn { display: block; margin: 8px auto; background: none; border: 0; color: var(--pri-t); font-weight: 800; text-decoration: underline; min-height: 44px; min-width: 44px; padding: 0 12px; }
.back { background: none; border: 0; font-weight: 800; color: var(--pri-t); min-height: 44px; padding: 0 4px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 14px; }
.field .lbl { font-weight: 800; font-size: .92rem; }
.field input[type=text], .field input[type=password] { font: inherit; padding: 12px; border: 2px solid var(--field); border-radius: 12px; width: 100%; min-height: 48px; background: #fff; color: var(--ink); }
.field input:focus { border-color: var(--pri); }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 12px; font-size: .92rem; }
.check input { width: 24px; height: 24px; flex: none; margin-top: 2px; }
.err { color: var(--red-t); font-weight: 700; min-height: 1.2em; margin: 0 0 8px; }
.soon { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.clsrow { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 8px; margin: 6px -2px; scrollbar-width: none; }
.clsrow .chip { flex: none; min-width: 44px; justify-content: center; }
.card.onb { border-color: var(--pri); }
.emo { font-size: 1.5rem; }
.item.static { cursor: default; }
.bookh { margin-top: 18px; font-size: 1.05rem; }
.chn { flex: none; width: 34px; height: 34px; border-radius: 10px; background: #EFEAFB; color: var(--pri-t); font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.item.chap { min-height: 60px; }
.dot-none { width: 30px; height: 30px; flex: none; }
.dots { display: flex; gap: 6px; margin-top: 6px; }
.dot { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; border: 2px solid var(--ink); }
.dot.lv0 { background: #fff; border-style: dashed; border-color: #7C7894; color: var(--muted); }
.dot.lv1 { background: #FF9F43; }
.dot.lv2 { background: #FFD66B; }
.dot.lv3 { background: #FFF3B0; border-color: #E08A00; box-shadow: 0 0 0 2px #FFE88A; }
.code { font: 800 1.6rem ui-monospace, Menlo, monospace; letter-spacing: 3px; background: #F4F1FF; border-radius: 12px; padding: 10px 14px; display: inline-block; color: var(--pri-t); }
details.faq summary { font-weight: 800; cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.btn.danger { color: var(--red-t); border-color: var(--red); margin-top: 14px; }
a.pdflink { color: var(--pri-t); font-weight: 800; }
a.btn { text-decoration: none; }
.sheet h2 { margin-top: 4px; }

@media (max-width: 460px) { .logo small { display: none; } }

/* ===== Cycle 1 (ux-designer): shared classes, focus, tap targets, narrow screens ===== */

/* one-sentence card at the top of a screen (parent week, teacher class, result, home) */
.summary { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: #fff; border: 2px solid var(--pri); border-radius: var(--r); padding: 12px 14px; margin: 0 0 12px; font-size: 1.08rem; font-weight: 800; line-height: 1.35; overflow-wrap: anywhere; }
.summary > p, .summary > .t { flex: 1 1 200px; min-width: 0; margin: 0; }
.summary .btn { flex: 1 1 auto; }
.summary .small, .summary .sub { display: block; font-size: .9rem; font-weight: 600; color: var(--muted); }
.summary.hero { background: linear-gradient(135deg, #4B3FD8, #6A50E8); color: #fff; border-color: transparent; }

/* class picker that wraps into two rows of five (no sideways scroll): first run, Textbook, sign-up */
.clsrow.wrap { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; overflow: visible; padding: 4px 0 8px; margin: 6px 0; }
.clsrow.wrap .chip { min-width: 0; min-height: 48px; padding: 4px 0; justify-content: center; }

/* one-line reason under a disabled button (also fine inside .lfoot) */
.why { margin: 6px 0 0; font-size: .92rem; font-weight: 700; color: var(--muted); text-align: center; line-height: 1.3; overflow-wrap: anywhere; }
.why:empty { display: none; }

/* "Open PDF" link: always a real 44 px target (a.pdflink is the old name, same look) */
a.pdf, a.pdflink { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 14px; margin: 2px 0; border-radius: 14px; border: 2px solid var(--field); background: #fff; color: var(--pri-t); font-weight: 800; font-size: .92rem; text-decoration: none; line-height: 1.2; }
a.pdf:active, a.pdflink:active { background: #F1EFFF; }

/* focus: one strong ring everywhere (keyboard and switch users); dark surfaces get a white ring */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.field input:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.card.hero :focus-visible, .card.night :focus-visible, .summary.hero :focus-visible, .mapwrap :focus-visible, .big-cta:focus-visible { outline-color: #fff; box-shadow: 0 0 0 5px var(--focus); }
.big-cta:focus-visible { outline-color: var(--focus); box-shadow: none; }
.mnode:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }
input[type=range]:focus-visible::-webkit-slider-thumb { outline: 3px solid var(--focus); outline-offset: 2px; }
input[type=range]:focus-visible::-moz-range-thumb { outline: 3px solid var(--focus); outline-offset: 2px; }

/* checkbox: 44 px touch box with a 28 px drawn box */
.check { align-items: center; min-height: 44px; }
.check input { -webkit-appearance: none; appearance: none; width: 44px; height: 44px; flex: none; margin: 0; background: transparent; border: 0; position: relative; cursor: pointer; }
.check input::before { content: ""; position: absolute; left: 8px; top: 8px; width: 28px; height: 28px; box-sizing: border-box; border: 2px solid var(--field); border-radius: 8px; background: #fff; }
.check input:checked::before { background: var(--pri); border-color: var(--pri); }
.check input:checked::after { content: ""; position: absolute; left: 17px; top: 13px; width: 8px; height: 15px; border: solid #fff; border-width: 0 3px 3px 0; transform: rotate(45deg); }

/* star outlines and placeholders: 3:1 against white (the drawing is in JS, the colour is overridden here) */
.star polygon[fill=none] { stroke: #7A7466; }
.star circle[stroke-dasharray] { stroke: #7A7466; }
/* map labels: size comes from the SVG font-size attribute set in drawMap (15 units); do not override here (B-036) */

/* long names (a 20 character first name, long Hindi concept names) wrap inside the card */
h1, h2, h3, .bubble, .refrow, .rolecard b, .rolecard .d, .field .lbl, .err, .msg, .note, .capt { overflow-wrap: anywhere; }
.card, .item, .sheet, .rung .card { min-width: 0; }

/* Hindi: taller lines, buttons and chips grow to two lines instead of clipping */
html[lang="hi"] body { line-height: 1.6; }
html[lang="hi"] .btn, html[lang="hi"] .chip, html[lang="hi"] .item .t, html[lang="hi"] h2, html[lang="hi"] h3, html[lang="hi"] #tabs a { line-height: 1.35; }
html[lang="hi"] .btn, html[lang="hi"] .chip { padding-top: 8px; padding-bottom: 8px; }

/* lesson 4 (grid) and other tall widgets: smaller grid on short screens, result line near the grid */
.grid-svg { max-width: max(200px, min(340px, 100%, 34vh)); }
@media (max-height: 700px) {
  .stagebox .slider { margin: 4px 0; }
  .stagebox .sl-out { font-size: .92rem; margin-bottom: 0; }
  .stagebox .chips { margin: 4px 0; }
  .stagebox .cap { min-height: 0; margin: 4px 0; }
  .stagebox .row { margin: 6px 0; }
  .stagetitle { margin-bottom: 2px; }
  .lhead { margin-bottom: 4px; }
}

/* Short screens (a 640 px phone is common): the lesson footer, the picture and the answer buttons all shrink a little so a hook or
   'which do you like' question and every answer fit above the footer without scrolling (B-010, round 2). Only sizes change, never
   the 44 px minimum. Measured footer: 109 px before, about 92 px after (128 px with a two-line reason). */
@media (max-height: 700px) {
  .lfoot { margin-top: 8px; padding-top: 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .lfoot .in { gap: 8px; }
  .lfoot .btn { min-height: 48px; padding-top: 6px; padding-bottom: 6px; }
  .lfoot .why { margin-top: 2px; font-size: .86rem; line-height: 1.25; }
  .stagebox .optgrid { gap: 8px; }
  .stagebox .optbtn { min-height: 48px; padding: 4px 8px; }
  .stagebox .optbtn .fr { line-height: 1; font-size: 1.02rem; }
  .stagebox .wprompt { margin-bottom: 8px; }
}
/* answers that are all short stacked fractions sit side by side (three in a row) instead of one under the other */
@supports selector(:has(*)) {
  .optgrid:has(.optbtn .fr):not(:has(.optbtn.notsure)):not(:has(.optbtn .optpic)) { grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); }
}
/* very short screens (a phone held sideways): the footer stops sticking and sits at the end of the page, so it can never hide anything */
@media (max-height: 480px) {
  .lfoot { position: static; }
}

/* narrow phones (320 px): tighter gutters; the role chip is hidden so the header always fits */
@media (max-width: 359px) {
  #app { padding-left: 12px; padding-right: 12px; }
  .lfoot { margin-left: -12px; margin-right: -12px; padding-left: 12px; padding-right: 12px; }
  .rolechip { display: none; }   /* role moves to Settings (B-007); until the markup is gone, hide the chip rather than squeeze it */
  .rolecard { gap: 10px; padding: 12px; }
  .rolecard .emo { width: 46px; height: 46px; }
}
/* role chip while it still exists: never wider than needed, label clipped before the page widens */
.rolechip { flex: 0 1 auto; min-width: 44px; max-width: 120px; overflow: hidden; white-space: nowrap; }

/* ================= any device: tablets, laptops, landscape ================= */
button, a, [role="button"] { touch-action: manipulation; }
img, svg { max-width: 100%; }
@media (min-width: 760px) {
  #hdr, #app, #tabs .in, .lfoot .in, .sheet { max-width: 720px; }
  #app { padding-left: 24px; padding-right: 24px; }
  .jstickers { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .jopts { max-width: 600px; margin-left: auto; margin-right: auto; }
}
@media (min-width: 1100px) {
  #hdr, #app, #tabs .in, .sheet { max-width: 880px; }
}

/* ================= install bar ================= */
.installbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; border: 2px solid #E8E5FF; }
.installbar img { border-radius: 10px; flex: none; }
.installbar .grow { flex: 1 1 160px; min-width: 0; display: flex; flex-direction: column; }
.installbar .ibtns { display: flex; align-items: center; gap: 6px; }
.installsteps { padding-left: 22px; } .installsteps li { margin: 0 0 10px; }

/* ================= Junior (Classes 1 to 5) ================= */
body.in-play #tabs { display: none; }
body.in-play #app { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.jhero { display: flex; align-items: center; gap: 12px; background: linear-gradient(135deg, #FFF3D6, #E8E5FF); }
.jhero h1 { font-size: 1.4rem; margin-bottom: 2px; }
.jhero p { margin: 0; }
.jmascot { width: 72px; height: 72px; flex: none; }
.jmascot.bob { animation: jbob 2.4s ease-in-out infinite; }
.jmascot.cheer { animation: jcheer .7s ease-out 2; }
.jmascot.think { animation: jtilt .5s ease-in-out; }
@keyframes jbob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes jcheer { 0% { transform: translateY(0) scale(1); } 40% { transform: translateY(-16px) scale(1.12) rotate(-8deg); } 100% { transform: translateY(0) scale(1); } }
@keyframes jtilt { 0%,100% { transform: rotate(0); } 30% { transform: rotate(-10deg); } 70% { transform: rotate(8deg); } }
.jcta { display: flex; align-items: center; gap: 14px; background: linear-gradient(135deg, #14794C, #0E6B8A); box-shadow: 0 5px 0 #0B4F33; }
.jcta-e { font-size: 2.6rem; line-height: 1; animation: jbob 2s ease-in-out infinite; }
.jtoggles { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 10px; }
.jhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin: 6px 0 8px; }
.jhead h2 { margin: 0; }
.jstk { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 8px; border-radius: 20px; border: 3px solid var(--line); background: #fff; text-align: center; min-height: 132px; animation: jin .35s ease-out both; }
.jstk .bub { width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center; font-size: 2rem; background: #E8E5FF; }
.jstk .t { font-weight: 800; font-size: .95rem; line-height: 1.2; }
.jstk:active, .jopt:active { transform: scale(.96); }
@keyframes jin { from { opacity: 0; transform: translateY(10px) scale(.95); } to { opacity: 1; transform: none; } }
@keyframes jpulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.1); } }
.jstars { color: #6F6754; letter-spacing: 2px; font-size: 1.05rem; }
.jstars .on { color: var(--sun); }
.jstars.big { font-size: 3rem; letter-spacing: 8px; display: block; }
.jstars .pop { display: inline-block; animation: jstar .5s ease-out; }
@keyframes jstar { 0% { transform: scale(0) rotate(-90deg); } 70% { transform: scale(1.4) rotate(10deg); } 100% { transform: scale(1) rotate(0); } }
.jstickers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.jstk .t { overflow-wrap: anywhere; max-width: 100%; hyphens: auto; } .jstk { padding-left: 3px; padding-right: 3px; } .jstk .t { font-size: .86rem; }
.jstk { min-height: 120px; }
.jstk:not(.got) .bub { filter: grayscale(1); opacity: .45; }
.jstk.got { border-color: var(--sun); }

/* the game screen */
.jtop { display: flex; align-items: center; gap: 10px; margin: 2px 0 10px; }
.jtitle { flex: 1; min-width: 0; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jprog { display: flex; gap: 5px; flex: none; }
.jprog span { width: 12px; height: 12px; border-radius: 50%; background: #E3DAC4; }
.jprog span.on { background: var(--green); }
.jprog span.cur { background: var(--sun); transform: scale(1.25); }
.jqcard { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: var(--r); padding: 10px 12px; box-shadow: 0 2px 0 var(--line); margin-bottom: 10px; }
.jqcard .jmascot { width: 56px; height: 56px; }
.jsay { flex: 1; margin: 0; font-size: 1.25rem; font-weight: 800; line-height: 1.3; }
.jear { font-size: 1.3rem; }
.jpic { display: flex; justify-content: center; margin: 4px 0 12px; }
.jpic > * { max-width: 100%; }
.jsvg { display: block; width: 100%; height: auto; }
.jpic .jsvg { max-width: 300px; }
.jpic .jclock { max-width: 210px; }
.jpic .jruler { max-width: 420px; }
.jpic .jroti { max-width: 220px; }
.jroti.tap path { cursor: pointer; }
.jroti.tap path:focus { outline: none; stroke: var(--pri); stroke-width: 4; }
.jpopin { animation: jpopin .3s ease-out both; transform-origin: center; transform-box: fill-box; }
@keyframes jpopin { from { opacity: 0; transform: scale(.3); } to { opacity: 1; transform: scale(1); } }
.jobjs { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 340px; }
.jobjs .jo { font-size: 2.1rem; line-height: 1; width: 52px; height: 52px; display: inline-grid; place-items: center; border-radius: 14px; border: 0; background: transparent; padding: 0; position: relative; animation: jin .3s ease-out both; }
.jobjs.small .jo, .jdata .jo { font-size: 1.4rem; width: 30px; height: 30px; }
.jobjs.pink .jo { background: #FDE6EE; }
.jobjs button.jo { background: #FFF3D6; }
.jobjs .jo.counted { background: #DDF5E8; }
.jobjs .jo.counted::after { content: attr(data-n); position: absolute; right: -4px; top: -6px; background: var(--green); color: #fff; font: 800 .8rem/1 system-ui, sans-serif; padding: 3px 6px; border-radius: 10px; }
.jobjs .jo.away { opacity: .25; filter: grayscale(1); animation: jaway .9s ease-in .5s both; }
@keyframes jaway { from { opacity: 1; transform: none; filter: none; } to { opacity: .25; transform: translateY(-14px) rotate(-12deg) scale(.85); filter: grayscale(1); } }
.jobjs.seq .jo { width: 44px; height: 44px; font-size: 1.8rem; }
.jobjs .jo.q { background: #E8E5FF; color: var(--pri-t); font-weight: 900; font-size: 1.6rem; }
.jobjs.grp { border: 2px dashed var(--field); border-radius: 14px; padding: 4px; }
.jgroups { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.jrow { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px; }
.jsign { font-size: 2rem; font-weight: 900; color: var(--pri-t); }
.jbig { font-size: 2rem; font-weight: 900; text-align: center; letter-spacing: 1px; }
.jemoji { font-size: 3.4rem; text-align: center; }
.jcolumn { font: 800 2rem/1.25 ui-monospace, Menlo, Consolas, monospace; text-align: right; background: #fff; padding: 8px 18px; border-radius: 14px; box-shadow: 0 2px 0 var(--line); }
.jcolumn .line { border-top: 3px solid var(--ink); margin-top: 4px; height: 1.25em; }
.jblocks { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: center; gap: 5px; max-width: 340px; min-height: 60px; }
.jblocks .bh { width: 50px; height: 50px; background: #4B3FD8; border-radius: 4px; background-image: linear-gradient(rgba(255,255,255,.35) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.35) 1px, transparent 1px); background-size: 5px 5px; }
.jblocks .bt { width: 10px; height: 50px; background: #19B6C8; border-radius: 3px; background-image: linear-gradient(rgba(255,255,255,.5) 1px, transparent 1px); background-size: 10px 5px; }
.jblocks .bos { display: grid; grid-template-columns: repeat(3, 10px); gap: 2px; }
.jblocks .bo { width: 10px; height: 10px; background: #E4577F; border-radius: 2px; }
.jbuild { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.jctls { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.jctl { display: flex; align-items: center; gap: 6px; background: #fff; border-radius: 16px; padding: 6px 8px; box-shadow: 0 2px 0 var(--line); }
.jctl .lbl { font-weight: 900; min-width: 36px; text-align: center; }
.jstep { width: 48px; height: 48px; border-radius: 14px; border: 2px solid var(--field); background: #FFF3D6; font-size: 1.5rem; font-weight: 900; }
.jdots { max-width: 280px; }
.jpic .jsvg.jdots { max-height: 34vh; }   /* tall times-table arrays leave the answers on screen (B-093) */
.jarea { display: flex; width: 100%; max-width: 340px; min-height: 90px; border: 3px solid var(--ink); border-radius: 8px; overflow: hidden; font-weight: 800; }
.jarea > div { display: grid; place-items: center; padding: 6px; text-align: center; font-size: .95rem; }
.jarea .p1 { background: #E8E5FF; } .jarea .p2 { background: #FDE6EE; border-left: 3px dashed var(--ink); }
.jshare { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.jobjs.pile { min-height: 34px; }
.jobjs.pile .jo, .jplate .jo { font-size: 1.3rem; width: 26px; height: 26px; }
.jplates { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.jplate { width: 92px; min-height: 64px; border-radius: 50%; background: #fff; border: 3px solid #C9C2AE; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; padding: 6px; }
.jplate .jo.drop { animation: jdrop .35s ease-out both; }
@keyframes jdrop { from { opacity: 0; transform: translateY(-24px); } to { opacity: 1; transform: none; } }
.jdata { display: flex; flex-direction: column; gap: 6px; background: #fff; padding: 10px; border-radius: 14px; box-shadow: 0 2px 0 var(--line); width: 100%; max-width: 360px; }
.jdata .r { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.jdata .k { font-size: 1.4rem; width: 34px; text-align: center; border-right: 2px solid var(--line); }
.jdata .jobjs { justify-content: flex-start; gap: 2px; flex-wrap: nowrap; min-width: 0; }
.jdata .jo { font-size: 1.2rem; width: 26px; height: 28px; }   /* a row of 8 stays on one line at 320 px (B-091) */
.jcoins { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.jcoin { width: 64px; animation: jin .3s ease-out both; }
.jcoin.note { width: 104px; }
.jcol { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; }
.jfrac { font-size: 1.3rem; }
.jgrid { max-width: 260px; }
.jsym { max-width: 120px; }
.jshape { width: 76px; height: 76px; display: block; }
/* answer buttons */
.jopts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.jopts.three { grid-template-columns: repeat(3, 1fr); }
.jopts.wide { grid-template-columns: 1fr; }
.jopt { min-height: 72px; border-radius: 20px; border: 3px solid var(--field); background: #fff; font-size: 1.6rem; font-weight: 900; display: flex; align-items: center; justify-content: center; padding: 8px; box-shadow: 0 4px 0 var(--line); animation: jin .3s ease-out both; }
.jopts.wide .jopt { font-size: 1.1rem; }
.jopts.bigem .jopt { font-size: 2.6rem; }
.jopt:nth-child(2) { animation-delay: 60ms; } .jopt:nth-child(3) { animation-delay: 120ms; } .jopt:nth-child(4) { animation-delay: 180ms; }
.jopt.right { border-color: var(--green); background: var(--green-bg); animation: jright .45s ease-out; }
.jopt.reveal { box-shadow: 0 0 0 4px rgba(20, 121, 76, .3); }
.jopt.wrong { border-color: var(--red); background: var(--red-bg); animation: jshake .4s ease-in-out; }
.jopt[disabled]:not(.right) { opacity: .5; }
@keyframes jright { 0% { transform: scale(1); } 40% { transform: scale(1.1); } 100% { transform: scale(1); } }
@keyframes jshake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(5px); } }
.jfeed { min-height: 1.6em; margin: 10px 0 4px; font-weight: 800; font-size: 1.1rem; text-align: center; }
.jfeed.good { color: var(--green-t); } .jfeed.try { color: var(--red-t); }
.jfeed.how { color: var(--ink); background: #FFF3D6; border-radius: 14px; padding: 10px 12px; text-align: left; font-weight: 600; }
.jcheck, .jnext { margin-top: 8px; min-height: 56px; font-size: 1.2rem; }
.jnext { animation: jin .3s ease-out both; }
.jend { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 18px; }
.jend .jmascot { width: 110px; height: 110px; }
.jsticker { font-weight: 800; display: flex; align-items: center; gap: 8px; }
.jsticker .bub { font-size: 2.4rem; display: inline-block; animation: jstar .6s ease-out .9s both; }
.jendbtns { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.jconfetti { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.jconfetti i { position: absolute; top: -20px; width: 9px; height: 14px; border-radius: 2px; animation: jfall 1.6s ease-in both; }
@keyframes jfall { from { top: -20px; } to { top: 105%; transform: rotate(540deg) translateX(30px); } }
@media (max-width: 359px) {
  .jopt { min-height: 60px; font-size: 1.3rem; }
  .jsay { font-size: 1.1rem; }
  .jstickers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.jopt.right, .jopt.wrong { animation-delay: 0s !important; }
/* phone held sideways (B-088): compact question card, picture on the left, answers on the right, all on screen.
   Kept after the base Junior rules so it wins. */
@media (orientation: landscape) and (max-height: 500px) {
  .jtop { margin-bottom: 4px; }
  .jqcard { padding: 4px 10px; margin-bottom: 6px; }
  .jqcard .jmascot { width: 40px; height: 40px; }
  .jsay { font-size: 1.05rem; }
  .jbody.haspic { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 14px; align-items: start; }
  .jbody.haspic > * { grid-column: 2; }
  .jbody.haspic > .jqcard { grid-column: 1 / -1; }
  .jbody.haspic > .jpic { grid-column: 1; grid-row: 2 / span 3; margin: 0; }
  .jpic svg.jsvg, .jpic .jsvg.jdots { max-height: 38vh; }
  .haspic .jpic svg.jsvg, .haspic .jpic .jsvg.jdots { max-height: 50vh; }
  .jpic > .jobjs .jo { width: 48px; height: 48px; font-size: 1.7rem; }
  .jopt { min-height: 52px; }
  .jopts { gap: 8px; }
  .jopts.bigem .jopt { font-size: 2rem; }
  .jfeed { margin-top: 6px; }
  .jbuild { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 6px 12px; }
  .jbuild .jbig { font-size: 1.6rem; }
  .jbuild .jctls { width: 100%; gap: 6px; }
  .jblocks { min-height: 50px; }
  .jctl { padding: 4px 6px; gap: 4px; }
  .jctl .lbl { min-width: 30px; }
  .jstep { width: 44px; height: 44px; }
}
/* tablets and laptops: placed last so the base grid rules above cannot override them */
@media (min-width: 760px) { .jstickers { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

/* ================= bridges, hands-on problems ================= */
.jbridgetag { display: inline-block; background: #FFF3D6; border: 2px dashed var(--sun-d); border-radius: 999px; padding: 4px 12px; font-weight: 800; font-size: .9rem; margin: 0 0 8px; }
.jchain h3 { margin-bottom: 8px; }
.jflow { display: flex; align-items: stretch; gap: 6px; overflow-x: auto; padding: 4px 2px 8px; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; }
.jarrow { align-self: center; font-weight: 900; color: var(--muted); flex: none; }
.jbnode { flex: none; width: 104px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 4px; border-radius: 16px; border: 3px solid var(--line); background: #fff; text-align: center; scroll-snap-align: start; }
.jbnode .bub { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 1.5rem; background: #E8E5FF; }
.jbnode .t { font-weight: 800; font-size: .82rem; line-height: 1.15; }
.jbnode .badge { font-size: .8125rem; }
.jbnode .jstars { font-size: .9rem; letter-spacing: 1px; }
.jbnode.lit .bub { background: #DDF5E8; }
.jbnode.mine { border-color: #C9C2F5; }
.jbnode.later { opacity: .7; }
.jbnode.now { border-color: var(--sun); box-shadow: 0 0 0 4px rgba(255, 176, 32, .25); opacity: 1; }
.jbnode.now .bub { animation: jpulse 1.6s ease-in-out infinite; }
.jline { max-width: 420px; touch-action: manipulation; }
.jline .jpt { cursor: pointer; }
.jline .jpt:focus { outline: none; }
.jline .jpt:focus circle { opacity: 1; }
.jhops { transition: opacity .3s; }
.jface { display: flex; justify-content: center; width: 100%; }
.jface .jclock { max-width: 180px; }
.jface .jdots { max-width: 240px; }
.jcbtn { border: 0; background: transparent; padding: 2px; border-radius: 50%; min-width: 44px; min-height: 44px; }
.jcbtn .jcoin { width: 54px; } .jcbtn .jcoin.note { width: 86px; }
.jtray { min-height: 64px; width: 100%; max-width: 360px; border: 3px dashed var(--field); border-radius: 16px; padding: 6px; background: #FFFBF2; }
.jbank { gap: 4px; }
.jq { color: var(--pri-t); }
.jfeed[data-streak]::after { content: " 🔥" attr(data-streak); }
@media (orientation: landscape) and (max-height: 500px) { .jface .jclock { max-width: 120px; } .jtray { min-height: 50px; } }

.jtop .jbridgetag { margin: 0; padding: 3px 10px; font-size: .85rem; border-width: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (orientation: landscape) and (max-height: 500px) {
  .jbuild { flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; }
  .jbuild .jbig { font-size: 1.4rem; }
  .jbuild .jemoji { font-size: 2rem; }
  .jface .jclock { max-width: 104px; }
  .jface .jdots, .jpic .jdots { max-height: 30vh; width: auto; }
  .jcbtn .jcoin { width: 40px; } .jcbtn .jcoin.note { width: 64px; }
  .jtray { min-height: 44px; max-width: 260px; }
  .jbuild > .muted { display: none; }
}
.jface .jdots { max-height: 30vh; width: auto; max-width: 100%; }
.jbuild { gap: 6px; }
.jbuild .jbig { font-size: 1.5rem; }
.jface .jdots { max-height: 24vh; }
.jbuild .jstep { width: 44px; height: 44px; }
@media (orientation: landscape) and (max-height: 500px) {
  .jface .jclock { max-width: 88px; }
  .jbuild .jctl { padding: 2px 6px; }
  .jbuild .jbig { font-size: 1.2rem; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .jbody.isbuild .jpic { grid-row: 2 / span 4; }
  .jbody.isbuild .jbuild { flex-direction: column; }
  .jbody.isbuild .jface .jclock { max-width: 120px; }
  .jbody.isbuild .jface .jdots { max-height: 34vh; }
}

/* ===== Stories: one short comic per idea ===== */
.jlearn { display: flex; flex-direction: column; gap: 12px; max-width: 640px; margin: 0 auto; }
.jpanel { position: relative; border: 3px solid #1F2340; border-radius: 18px; box-shadow: 5px 5px 0 #1F2340; padding: 14px; background: #FFFDF6; animation: jpin .35s ease-out both; }
.jpanel.back { animation-name: jpinb; }
@keyframes jpin { from { opacity: 0; transform: translateX(40px) rotate(2deg); } to { opacity: 1; transform: none; } }
@keyframes jpinb { from { opacity: 0; transform: translateX(-40px) rotate(-2deg); } to { opacity: 1; transform: none; } }
.jpnum { position: absolute; top: -12px; left: -10px; width: 32px; height: 32px; border-radius: 50%; background: #FFC53D; border: 3px solid #1F2340; display: grid; place-items: center; font-weight: 900; }
.jscene { font-size: 2.8rem; line-height: 1.25; text-align: center; white-space: pre-line; word-break: break-word; padding: 18px 6px; margin-bottom: 10px; border-radius: 12px;
  background: radial-gradient(circle at 30% 20%, #FFF 0, #E9F6FF 70%); font-weight: 800; color: #1F2340; animation: jpop .5s .15s ease-out both; }
@keyframes jpop { from { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.06); } to { transform: none; opacity: 1; } }
.jbubble { display: flex; gap: 10px; align-items: flex-start; }
.jbubble .jmascot { width: 48px; height: 48px; flex: none; }
.jbubble p { position: relative; margin: 0; flex: 1; background: #fff; border: 2px solid #1F2340; border-radius: 16px; padding: 10px 12px; font-size: 1.12rem; font-weight: 700; line-height: 1.4; }
.jbubble p::before { content: ""; position: absolute; left: -9px; top: 16px; width: 14px; height: 14px; background: #fff; border-left: 2px solid #1F2340; border-bottom: 2px solid #1F2340; transform: rotate(45deg); }
.jsum { display: flex; flex-direction: column; gap: 10px; }
.jinfo { display: flex; gap: 12px; align-items: flex-start; border-radius: 14px; padding: 12px; }
.jinfo .ji { font-size: 2rem; line-height: 1; flex: none; }
.jinfo b { display: block; font-size: .95rem; text-transform: uppercase; letter-spacing: .03em; }
.jinfo p { margin: 4px 0 0; font-size: 1.08rem; font-weight: 700; line-height: 1.4; }
.jinfo.big { background: #FFF3D6; } .jinfo.life { background: #E3F6EC; } .jinfo.try { background: #ECE9FF; }
.jlnav { display: flex; gap: 10px; }
.jlnav .btn { min-height: 52px; font-size: 1.1rem; }
.jlnav .btn:first-child { flex: none; width: 60px; }
.jlnav .jlnext { flex: 1; }
.jlnav .btn[disabled] { opacity: .4; }
.jtop .jstorybtn { flex: none; }
.jhowstory { display: inline-block; margin-left: 4px; font-weight: 800; padding: 6px 0; }
.jstories { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; padding: 0 5px 5px 0; }
.jstory { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 8px; min-height: 120px; border: 3px solid #1F2340; border-radius: 16px; background: #FFFDF6; box-shadow: 3px 3px 0 #1F2340; font: inherit; cursor: pointer; animation: jpin .35s ease-out both; }
.jstory .bub { font-size: 2.2rem; } .jstory .t { font-weight: 800; text-align: center; }
.jstory:active, .jpanel:active { box-shadow: 1px 1px 0 #1F2340; transform: translate(2px, 2px); }
@media (max-width: 360px) { .jscene { font-size: 2rem; padding: 12px 4px; } .jbubble p { font-size: 1.02rem; } }
@media (orientation: landscape) and (max-height: 500px) {
  .jpanel:not(.jsum) { display: grid; grid-template-columns: 1fr 1.2fr; gap: 12px; align-items: center; padding: 10px; }
  .jscene { margin: 0; padding: 10px 4px; font-size: 2rem; }
  .jsum { flex-direction: row; } .jinfo { flex: 1; padding: 8px; } .jinfo p { font-size: .98rem; }
  .jlnav { position: sticky; bottom: 0; padding: 6px 0; background: var(--bg); }
}
@media (prefers-reduced-motion: reduce) { .jpanel, .jscene, .jstory { animation: none; } }

/* ===== practice round, looking back at answers, video slot ===== */
.jpractice { margin: 6px 0 0; text-align: center; font-weight: 700; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.jhint { min-height: 44px; }
.jtop .jbackbtn, .jtop .jskip { flex: none; }
.jtop .jskip { min-height: 44px; }
.jreview .jopts, .jreview .jpic, .jreview .jcheck, .jreview .jhint { pointer-events: none; }
.jreview .jnextwrap, .jreview .jcheck, .jreview .jpractice { display: none; }
.jreview .jopt.was { opacity: .6; }
.jreview .jopt.was::after { content: " ✗"; color: var(--red-t); }
.jreview .jopt.picked.right::after { content: " ✓"; color: var(--green-t); }
.jreview .jqcard { outline: 3px dashed var(--line); }
.jrevbar { position: sticky; bottom: 0; padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); background: var(--bg); }
.jrevbar[hidden] { display: none; }
.jvideo { position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: #1F2340; }
.jvideo iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.jvplay { position: absolute; inset: 0; width: 100%; border: 0; background: radial-gradient(circle, #4B3FD8 0, #1F2340 75%); color: #fff; font: inherit; font-weight: 800; font-size: 1.1rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; cursor: pointer; }
.jvbig { width: 64px; height: 64px; border-radius: 50%; background: #E4577F; display: grid; place-items: center; font-size: 1.8rem; }
@media (max-width: 360px) { .jtop .jskip { padding: 0 10px; } .jtop { gap: 6px; } }

/* ===== recorded voice: the small 🔊 next to a sentence ===== */
.saybtn { display: inline-grid; place-items: center; vertical-align: middle; margin-left: 4px; width: 44px; height: 44px; margin-top: -14px; margin-bottom: -14px; line-height: 1; border: 0; border-radius: 50%; background: transparent; font-size: 1.15rem; cursor: pointer; }
.saybtn:active { background: #FFF3D6; }
html.saying .saybtn { animation: saypulse 1s ease-in-out infinite; }
@keyframes saypulse { 50% { transform: scale(1.15); } }
@media (prefers-reduced-motion: reduce) { html.saying .saybtn { animation: none; } }

/* ===== Stages (Primary 1-5, Middle 6-8, Secondary 9-10, Higher Secondary 11-12) & ThinkCraft-inspired soft tactile polish ===== */
body[data-stage="middle"] { --bg: #F5F9FB; --line: #DDE9F0; --pri: #0E7490; --pri-d: #0A5368; --cta-from: #0E7490; --cta-to: #2563EB; --cta-shadow: #09485A; --focus: #0E7490; }
body[data-stage="secondary"] { --bg: #F6F6FC; --line: #E0E2F5; --pri: #4338CA; --pri-d: #312E81; --cta-from: #4338CA; --cta-to: #7C3AED; --cta-shadow: #2E2475; --focus: #4338CA; }
body[data-stage="higher"] { --bg: #F8F5FC; --line: #E4DCF5; --pri: #6D28D9; --pri-d: #4C1D95; --cta-from: #6D28D9; --cta-to: #9333EA; --cta-shadow: #4C1D95; --focus: #6D28D9; }

/* Desktop subtle app-frame feel (like ThinkCraft) without breaking mobile 320-480px */
@media (min-width: 640px) {
  body { background: #EDE6D6; }
  body[data-stage="middle"] { background: #E4EEF3; }
  body[data-stage="secondary"] { background: #E7E9F6; }
  body[data-stage="higher"] { background: #ECE6F6; }
  #hdr, #app { background: var(--bg); box-shadow: 0 0 0 1px rgba(15, 23, 42, .05), 0 12px 36px rgba(15, 23, 42, .07); }
  #app { min-height: calc(100vh - var(--hdr-h)); }
}

/* Pastel icon boxes (ThinkCraft-style soft rounded badges) */
.pico { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; font-size: 1.35rem; flex: none; background: #EDE9FE; }
.pico.c1 { background: #E0F2FE; } .pico.c2 { background: #FEF3C7; } .pico.c3 { background: #FCE7F3; }
.pico.c4 { background: #DCFCE7; } .pico.c5 { background: #EDE9FE; } .pico.c6 { background: #FFEDD5; }

/* 3-step onboarding + live Maths Pass */
.onb-wrap { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }
.onb-top { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.onb-dots { flex: 1; display: flex; justify-content: center; gap: 6px; }
.onb-dots i { width: 8px; height: 8px; border-radius: 999px; background: #D7CEBA; transition: width .2s, background .2s; }
.onb-dots i.on { width: 24px; background: var(--pri); }
.onb-dots i.done { background: var(--green); }
.onb-head { text-align: center; margin: 4px 0 6px; }
.onb-head h1 { font-size: 1.45rem; margin: 0 0 4px; }
.onb-head p { margin: 0; color: var(--muted); font-size: .95rem; }

.mstage-cards { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.mstage-card { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 13px 14px; border-radius: 20px; border: 1.5px solid var(--line); background: #fff; min-height: 70px; box-shadow: 0 4px 14px rgba(15, 23, 42, .05); transition: transform .12s, border-color .15s, box-shadow .15s; }
.mstage-card:active { transform: scale(.985); }
.mstage-card .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mstage-card b { font-size: 1.02rem; color: var(--ink); }
.mstage-card .d { font-size: .84rem; color: var(--muted); }
.mstage-card.on { border-color: var(--pri); background: #F5F7FF; box-shadow: 0 0 0 3px rgba(75, 63, 216, .16); }

.onb-clsgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 10px; margin: 8px 0; }
.onb-clsbtn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 78px; padding: 12px; border-radius: 20px; border: 1.5px solid var(--line); background: #fff; box-shadow: 0 4px 14px rgba(15, 23, 42, .05); font-weight: 800; font-size: 1.05rem; }
.onb-clsbtn:active { transform: scale(.97); }
.onb-clsbtn.on { border-color: var(--pri); background: var(--pri); color: #fff; box-shadow: 0 6px 16px rgba(75, 63, 216, .25); }
.onb-namebar { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.onb-namebar input { flex: 1; min-height: 54px; padding: 10px 16px; border-radius: 999px; border: 2px solid var(--pri); background: #fff; font: 700 1.05rem inherit; color: var(--ink); }
.onb-namebar .btn { min-width: 54px; height: 54px; border-radius: 50%; padding: 0; flex: none; }

/* Live Maths Pass card */
.mpass { margin-top: 10px; border-radius: 22px; padding: 16px 18px; background: linear-gradient(135deg, #16182F, #272B54); color: #fff; box-shadow: 0 10px 24px rgba(18, 22, 59, .22); display: flex; align-items: center; gap: 12px; }
.mpass-tag { font-size: 11px; font-weight: 900; letter-spacing: .12em; color: #FDE047; text-transform: uppercase; }
.mpass-name { font-size: 1.15rem; font-weight: 800; margin: 2px 0; }
.mpass-meta { font-size: .84rem; color: #C7D2FE; font-weight: 600; }

.mstage-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mstage-pill { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 8px; border-radius: 16px; border: 1.5px solid var(--line); background: #fff; text-align: center; min-height: 78px; box-shadow: 0 2px 8px rgba(15, 23, 42, .04); }
.mstage-pill .emo { font-size: 1.45rem; }
.mstage-pill b { font-size: .92rem; }
.mstage-pill small { font-size: .78rem; color: var(--muted); }
.mstage-pill.on { border-color: var(--pri); background: #E0F2FE; }

.mhero { background: linear-gradient(135deg, #0E7490, #1D4ED8); color: #fff; border: 0; border-radius: 22px; box-shadow: 0 8px 22px rgba(14, 116, 144, .2); }
.mhero.sec-stage { background: linear-gradient(135deg, #3730A3, #6D28D9); box-shadow: 0 8px 22px rgba(55, 48, 163, .22); }
.mhero.hi-stage { background: linear-gradient(135deg, #5B21B6, #9333EA); box-shadow: 0 8px 22px rgba(91, 33, 182, .22); }
.mhero-top { display: flex; align-items: flex-start; gap: 10px; }
.mhero .grow { flex: 1; min-width: 0; }
.mbadge { display: inline-block; font-size: 12px; font-weight: 800; background: rgba(255, 255, 255, .2); color: #fff; padding: 3px 10px; border-radius: 999px; margin-bottom: 6px; }
.mhero h1 { margin: 0 0 4px; color: #fff; }
.mhero-sub { margin: 0; font-size: .9rem; color: rgba(255, 255, 255, .92); font-weight: 600; }
.mswitch { background: #fff; color: #1F2340; border-color: transparent; flex: none; }

.mcta { display: flex; align-items: center; gap: 14px; border-radius: 22px; }
.mcta-e { font-size: 2.2rem; flex: none; }
.mcta .grow { flex: 1; min-width: 0; }

/* Practice Arena (Spot the Mistake) */
.marena { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 13px 14px; border-radius: 20px; border: 1.5px solid #FDE68A; background: linear-gradient(135deg, #FFFBEB, #FEF3C7); margin: 0 0 12px; box-shadow: 0 4px 12px rgba(217, 119, 6, .08); }
.marena .grow { flex: 1; min-width: 0; }
.marena b { display: block; font-size: .98rem; color: #78350F; }
.marena span.d { display: block; font-size: .83rem; color: #92400E; }

.mgroup { margin: 16px 0 8px; font-size: 1.02rem; color: var(--muted); }
.mlist { display: flex; flex-direction: column; gap: 9px; margin-bottom: 12px; }
.mchap { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: #fff; border: 1.5px solid var(--line); border-radius: 18px; padding: 12px; min-height: 68px; box-shadow: 0 3px 10px rgba(15, 23, 42, .04); transition: transform .1s, border-color .15s; }
.mchap:active { transform: scale(.99); background: #F1F8FB; }
.mchap.now { border-color: var(--pri); box-shadow: 0 0 0 3px rgba(14, 116, 144, .16); }
.mchap.done { border-color: #A7DFC5; }
.mchn { width: 38px; height: 38px; border-radius: 12px; background: #E0F2FE; color: #0E7490; font-weight: 900; font-size: .92rem; display: grid; place-items: center; flex: none; }
body[data-stage="secondary"] .mchn { background: #E0E7FF; color: #3730A3; }
.mchap.done .mchn { background: var(--green-bg); color: var(--green-t); }
.mchap .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mchap .t { font-weight: 800; font-size: .97rem; color: var(--ink); overflow-wrap: anywhere; }
.mchap .sub { font-size: .82rem; color: var(--muted); overflow-wrap: anywhere; }
.mright { flex: none; }
.mstuck-card { margin-top: 14px; border-radius: 20px; }

/* Middle & Secondary explainer, tap-to-reveal worked examples, Spot the Mistake */
.mpanel { position: relative; border: 1.5px solid var(--line); border-radius: 22px; box-shadow: 0 6px 20px rgba(15, 23, 42, .06); padding: 18px 16px; background: #fff; animation: jpin .26s ease-out both; }
.mpanel.back { animation-name: jpinb; }
.mpnum { position: absolute; top: -11px; left: 16px; width: 28px; height: 28px; border-radius: 50%; background: var(--pri); color: #fff; display: grid; place-items: center; font-weight: 900; font-size: .88rem; }
.mvisual { font-size: 1.22rem; line-height: 1.48; text-align: center; white-space: pre-line; word-break: break-word; padding: 16px 12px; margin: 6px 0 14px; border-radius: 16px; background: linear-gradient(135deg, #ECFEFF, #EFF6FF); border: 1.5px solid #CBE8F0; font-weight: 800; color: var(--ink); }
body[data-stage="secondary"] .mvisual { background: linear-gradient(135deg, #EEF2FF, #F5F3FF); border-color: #C7D2FE; }
.mexplain { margin: 0; font-size: 1.05rem; line-height: 1.55; color: var(--ink); font-weight: 600; }
.mex-tag { display: inline-block; font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; background: #FEF3C7; color: #92400E; padding: 4px 10px; border-radius: 999px; margin-bottom: 10px; }
.mex-q { font-weight: 800; font-size: 1.08rem; margin: 0 0 12px; color: var(--ink); }
.mex-steps { margin: 0 0 12px; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.mex-step { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 14px; background: #F8FAFC; border: 1.5px solid #E2E8F0; font-weight: 600; line-height: 1.45; animation: jpin .2s ease-out both; }
.mex-step .sn { width: 24px; height: 24px; border-radius: 50%; background: var(--pri); color: #fff; font-size: .8rem; font-weight: 900; display: grid; place-items: center; flex: none; margin-top: 1px; }
.mex-ans { padding: 11px 14px; border-radius: 14px; background: var(--green-bg); color: #0F5132; font-weight: 800; font-size: 1.03rem; animation: jpin .2s ease-out both; }
.mex-reveal { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.mextras { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.msvg { width: 100%; max-width: 340px; height: auto; display: block; margin: 0 auto; }
.mexpr { font-size: 1.32rem; font-weight: 800; text-align: center; padding: 13px 14px; border-radius: 16px; background: #fff; border: 1.5px solid var(--line); box-shadow: 0 3px 10px rgba(15, 23, 42, .04); color: var(--ink); word-break: break-word; }
.mqcard { padding: 12px 14px; border-radius: 18px; }
.mend-emo { font-size: 3rem; margin-bottom: 4px; }
.mopt { font-size: 1.05rem; border-radius: 16px; }

/* Spot the Mistake step cards */
.mist-steps { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.mist-btn { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 13px 14px; border-radius: 16px; border: 2px solid var(--line); background: #fff; font-weight: 700; font-size: 1rem; box-shadow: 0 3px 8px rgba(15, 23, 42, .04); }
.mist-btn .sn { width: 28px; height: 28px; border-radius: 9px; background: #EEF2FF; color: var(--pri-t); font-weight: 900; font-size: .85rem; display: grid; place-items: center; flex: none; }
.mist-btn.right { background: var(--green-bg); border-color: var(--green); color: #0F5132; }
.mist-btn.wrong { background: var(--red-bg); border-color: var(--red); opacity: .75; }

/* ===== Maths Labs, "Why?" openers, where-used and career paths (Classes 6-12) ===== */
.mwhy-scene { font-size: 3.2rem; text-align: center; padding: 14px 0 6px; animation: jpop .5s .1s ease-out both; }
.mlab { padding: 12px; }
.lab { display: flex; flex-direction: column; gap: 10px; }
.ltitle b { display: block; font-size: 1.08rem; } .ltitle span { display: block; margin-top: 2px; }
.labsvg { width: 100%; height: auto; max-height: 46vh; background: #FBFDFF; border: 2px solid var(--line); border-radius: 14px; touch-action: pan-y; }
.llab { font: 700 12px system-ui, sans-serif; fill: #1F2340; paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.lax { font: 600 10px system-ui, sans-serif; fill: #5A5E7C; }
.lwarn { font: 800 12px system-ui, sans-serif; fill: #C2410C; }
.ltile { animation: ltile .35s ease-out both; transform-box: fill-box; transform-origin: center; }
@keyframes ltile { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: none; } }
.lborder { animation: lmarch 1.2s linear infinite; } @keyframes lmarch { to { stroke-dashoffset: -32; } }
.lbeam { transition: transform .45s cubic-bezier(.3,1.6,.5,1); }
.lbar { transition: y .3s, height .3s; }
.lunroll { animation: lunroll .7s ease-out both; transform-box: fill-box; transform-origin: left; } @keyframes lunroll { from { transform: scaleX(.05); } }
.lctl { display: grid; gap: 8px; }
.lslider { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; font-weight: 700; }
.lslider input { grid-column: 1 / -1; width: 100%; height: 36px; accent-color: var(--pri, #4B3FD8); }
.lsval { font-variant-numeric: tabular-nums; color: var(--pri, #4B3FD8); }
.lread { background: #F3F6FF; border-radius: 12px; padding: 8px 12px; } .lread p { margin: 4px 0; line-height: 1.45; }
.leq { text-align: center; font-size: 1.5rem; padding: 4px; }
.lbtns { display: flex; flex-wrap: wrap; gap: 8px; } .lbtns .btn { min-height: 44px; }
.lgoal { margin: 0; font-weight: 700; color: #5A3E00; background: #FFF3D6; border-radius: 12px; padding: 8px 12px; }
.lwin { display: none; margin: 0; } .lwin.show { display: block; font-weight: 800; color: #166534; background: #DCFCE7; border-radius: 12px; padding: 8px 12px; animation: jpop .4s ease-out both; }
.muses { display: grid; gap: 8px; margin-bottom: 6px; }
.muse { display: flex; gap: 10px; align-items: center; font-weight: 600; }
.mcareers { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.mcareer { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 8px; min-height: 110px; background: #fff; border-radius: 18px; box-shadow: 0 2px 0 var(--line), 0 6px 18px rgba(15,23,42,.05); text-decoration: none; color: inherit; text-align: center; animation: jpin .35s ease-out both; }
.mcareer .pico { width: 52px; height: 52px; font-size: 1.7rem; }
.mcar-hero { text-align: center; } .mcar-e { font-size: 3rem; } .mcar-hero h1 { margin: 6px 0 0; }
.mroad { list-style: none; padding: 0; margin: 6px 0 14px; background: linear-gradient(var(--line), var(--line)) 13px 0 / 4px 100% no-repeat; }
.mroad li { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 12px; font-weight: 700; animation: jpin .4s ease-out both; }
.mroad .sn { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--pri, #4B3FD8); color: #fff; display: grid; place-items: center; font-weight: 900; }
.mroad li.goal .sn { background: #FFC53D; }
.mcarcard { text-decoration: none; color: inherit; }
@media (prefers-reduced-motion: reduce) { .ltile, .lborder, .lunroll, .mcareer, .mroad li, .mwhy-scene { animation: none; } }
/* panels slide in from 40px to the right; clip that so phones never widen the page (no scroll container, so sticky still works) */
.jlearn, .jstories, .mcareers, .mroad { overflow-x: clip; }

/* ===== Shared shell (28 Nov 2026): today card, foundations, next class, Practice / Family / Me ===== */
.today { padding: 14px; }
.today-top { display: flex; align-items: center; gap: 12px; }
.today-top b { display: block; font-size: 1.05rem; }
.tring { position: relative; width: 68px; height: 68px; flex: none; display: grid; place-items: center; }
.tring svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.tring b { position: relative; font-size: 1.05rem; line-height: 1; margin-top: -8px; } .tring small { position: absolute; bottom: 14px; font-size: .75rem; color: #5A5E7C; font-weight: 700; }
.tmissions { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.tmissions a { display: flex; align-items: center; gap: 10px; min-height: 48px; font-weight: 700; padding: 6px 10px; border-radius: 14px; background: #fff; border: 2px solid var(--line); box-shadow: 0 2px 0 var(--line); text-decoration: none; color: inherit; }
.tmissions .grow { flex: 1; }
.tmissions .go { font-weight: 900; color: var(--pri-t); font-size: 1.2rem; }
.tmissions .done a { background: #DCFCE7; border-color: #86EFAC; color: #166534; box-shadow: none; }
.tmissions .tick { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; font-size: 1.1rem; flex: none; background: #EEF0FF; }
.tmissions .done .tick { background: #166534; color: #fff; border-radius: 50%; }
.tall { margin: 10px 0 0; font-weight: 800; color: #166534; }
.tfound h2, .tnext h2 { margin: 0 0 4px; font-size: 1.1rem; }
.tfrow { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin-top: 8px; }
.tfnode { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px; min-height: 44px; border-radius: 14px; background: #FFF7E6; border: 2px dashed #F0C36A; text-decoration: none; color: inherit; text-align: center; }
.tfnode .e { font-size: 1.6rem; } .tfnode .t { font-weight: 800; font-size: .95rem; }
.tfoundbtn { margin: 8px 0; }
.tnext { border: 2px dashed var(--line); background: #FBFAF6; }
.tnext.open { border-style: solid; border-color: #86EFAC; background: #F0FDF4; }
.tbar { height: 12px; border-radius: 6px; background: #ECE6D6; overflow: hidden; margin: 8px 0 10px; } .tbar i { display: block; height: 100%; background: linear-gradient(90deg, #FFB020, #E4577F); border-radius: 6px; }
.tbig { font-size: 3rem; } .tfrom { margin: 0 0 6px; }
.pquick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 10px 0 6px; }
.pcard, .pgame { display: flex; flex-direction: column; gap: 6px; padding: 14px 12px; min-height: 44px; background: #fff; border-radius: 18px; box-shadow: 0 2px 0 var(--line), 0 6px 18px rgba(15,23,42,.05); text-decoration: none; color: inherit; }
.pcard b { font-size: 1rem; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.pgame { align-items: center; text-align: center; } .pgame .e { font-size: 1.9rem; } .pgame .t { font-weight: 800; }
.fsum p { margin: 4px 0; font-weight: 700; }
.fweek { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; height: 90px; align-items: end; margin-top: 8px; }
.fday { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.fday i { display: block; width: 70%; min-height: 4px; border-radius: 6px 6px 2px 2px; background: #FFB020; } .fday i.none { background: #E9E2D0; } .fday small { color: #5A5E7C; font-weight: 700; }
.mehero { display: flex; align-items: center; gap: 12px; } .mehero h1 { margin: 0; font-size: 1.3rem; }
.meav { width: 64px; height: 64px; border-radius: 20px; background: #EDE9FE; display: grid; place-items: center; font-size: 2.2rem; flex: none; }
.mestats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.mestats div { background: #fff; border-radius: 16px; padding: 10px; text-align: center; box-shadow: 0 2px 0 var(--line); }
.mestats b { display: block; font-size: 1.3rem; } .mestats small { color: #5A5E7C; font-weight: 700; }
.mefield { display: grid; gap: 6px; margin: 10px 0; } .mefield input { font: inherit; padding: 12px; min-height: 44px; border: 2px solid var(--field, #857852); border-radius: 12px; }
.meavs { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 8px; }
.meavbtn { min-height: 48px; font-size: 1.6rem; border-radius: 14px; border: 2px solid var(--line); background: #fff; cursor: pointer; }
.meavbtn.on { border-color: var(--pri, #4B3FD8); background: #EDE9FE; }
.onb-go .pico { background: #DCFCE7; } .onb-check .pico { background: #FEF3C7; }
.melinks a.item, .pcard, .pgame, .tfnode { text-decoration: none; color: inherit; }

/* challenge: one thin bar on its own line, so the title fits on small phones */
.jtop:has(.tprog) { flex-wrap: wrap; }
.tprog { flex: 1 0 100%; height: 10px; border-radius: 5px; background: #E3DAC4; overflow: hidden; } .tprog i { display: block; height: 100%; background: var(--green, #2E9E5B); border-radius: 5px; transition: width .3s; }

/* ===== Winding path on Home (29 Nov 2026) ===== */
.ppath { max-width: 520px; margin: 4px auto 18px; isolation: isolate; }
.prow { position: relative; }
.plink { position: absolute; z-index: -1; left: 0; top: 50%; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.plink path { fill: none; stroke: #D9CFB6; stroke-width: 9px; stroke-linecap: round; stroke-dasharray: 1 17; vector-effect: non-scaling-stroke; }
.plink.lit path { stroke: #E0A100; stroke-dasharray: none; stroke-width: 7px; }
.pnode { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 104px; padding: 8px 0; border: 0; background: none; font: inherit; color: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.pnode.rt { flex-direction: row-reverse; text-align: right; }
.pbub { flex: none; width: 68px; height: 68px; margin-left: calc(var(--x) - 34px); border-radius: 50%; display: grid; place-items: center; font-size: 2rem; background: #fff; border: 4px solid #D9CFB6; box-shadow: 0 6px 0 #D9CFB6; }
.pnode.rt .pbub { margin: 0 calc(var(--x) - 34px) 0 0; }
.pnode.part .pbub { background: #FFF3D6; border-color: #F0C36A; box-shadow: 0 6px 0 #E0A84A; }
.pnode.done .pbub { background: #FFD45C; border-color: #F0B429; box-shadow: 0 6px 0 #C98A00; }
.pnode.now .pbub { background: #fff; border-color: var(--pri); box-shadow: 0 6px 0 var(--pri-d), 0 0 0 5px var(--sun); animation: jpulse 1.8s ease-in-out infinite; }
.pnode.ptro .pbub { border-radius: 22px; background: #EDE9FE; border-color: #8B7CF0; box-shadow: 0 6px 0 #6D5FD0; }
.pnode:active .pbub { transform: translateY(4px); box-shadow: 0 2px 0 #D9CFB6; animation: none; }
.plab { min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 4px 8px; border-radius: 12px; background: var(--bg); overflow-wrap: anywhere; }
.pnode.rt .plab { align-items: flex-end; }
.plab .t { font-weight: 800; line-height: 1.2; }
.pgo { align-self: flex-start; padding: 2px 10px; border-radius: 99px; background: var(--sun); color: #1F2340; font-weight: 900; font-size: .85rem; }
.pnode.rt .pgo { align-self: flex-end; }
@media (max-width: 340px) { .pbub { width: 60px; height: 60px; margin-left: calc(var(--x) - 30px); } .pnode.rt .pbub { margin-right: calc(var(--x) - 30px); } .plab { font-size: .95rem; padding: 4px 4px; } .pnode { gap: 6px; } }

/* ===== Choose, then Check: the answer dock ===== */
.jopt.was { border-color: var(--red); background: var(--red-bg); }
.jopt:disabled, .mist-btn:disabled { color: var(--ink); }
.jopt.was, .jopt.wrong { opacity: 1 !important; }
a.iconbtn { text-decoration: none; color: inherit; }
.vseg { flex-wrap: wrap; } .vseg .chip { flex: 1 1 auto; white-space: nowrap; } .vseg:empty { display: none; }
.jlearn { padding-top: 10px; }
a.chip { text-decoration: none; color: inherit; }
.jdock { position: sticky; bottom: 0; z-index: 5; margin: 10px -8px 0; padding: 6px 8px calc(8px + env(safe-area-inset-bottom)); border-radius: 18px; background: var(--bg); }
.jdock .jfeed { margin: 0 0 4px; }
.jdock:has(.jfeed.good) { background: var(--green-bg); }
.jdock:has(.jfeed.try) { background: var(--red-bg); }
.jdock:has(.jfeed.how) { background: #FFF3D6; }
.jdock .jfeed.how { padding: 4px; }
.jopt { border-bottom-width: 6px; }
.jopt.sel { border-color: var(--pri); background: #E6F0FF; box-shadow: 0 0 0 3px rgba(14, 107, 138, .25); }
.jreview .jdock { position: static; }
/* progress: one bar of steps on its own line, so the title has room */
@media (orientation: portrait), (min-height: 501px) {
  .jtop:has(.jprog) { flex-wrap: wrap; row-gap: 8px; }
  .jtop .jprog { order: 9; flex: 1 0 100%; }
  .jtop .jprog span { flex: 1; height: 8px; border-radius: 4px; transform: none; }
}
@media (prefers-reduced-motion: reduce) { .pnode.now .pbub { animation: none; } }

/* ===== Grown-ups' area: PIN pad, children, Who's learning (30 Nov 2026) ===== */
.pinbox { max-width: 300px; margin: 8px auto; text-align: center; }
.pindots { display: flex; justify-content: center; gap: 14px; margin: 10px 0 4px; }
.pindots i { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--field); background: #fff; }
.pindots i.on { background: var(--pri); border-color: var(--pri); }
.pinmsg { min-height: 1.5em; margin: 4px 0 8px; font-weight: 800; color: var(--red-t); }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pinkey { min-height: 60px; border-radius: 18px; border: 2px solid var(--field); background: #fff; font-size: 1.5rem; font-weight: 900; box-shadow: 0 4px 0 var(--line); }
.pinkey:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.pinask { text-align: center; font-weight: 800; font-size: 1.1rem; margin: 6px 0 0; }
.pinforgot { margin-top: 10px; } .pinforgot[hidden] { display: none; }
.pinforgot input, .faddrow input { font: inherit; padding: 12px; min-height: 44px; border: 2px solid var(--field); border-radius: 12px; width: 100%; margin: 6px 0; background: #fff; }
.fkids h2 { margin: 0 0 8px; font-size: 1.1rem; }
.fkid { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fkid.on { border-color: var(--pri); }
.meav.small { width: 44px; height: 44px; border-radius: 14px; font-size: 1.6rem; }
.faddrow { display: flex; gap: 8px; align-items: center; } .faddrow input { flex: 1; min-width: 0; margin: 0; }
.whogrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 12px 0; }
.whocard { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 8px; min-height: 140px; background: #fff; border: 3px solid var(--line); border-radius: 22px; box-shadow: 0 5px 0 var(--line); font: inherit; overflow-wrap: anywhere; }
.whocard.on { border-color: var(--sun); }
.whocard:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--line); }
.whocard .meav { width: 72px; height: 72px; font-size: 2.6rem; }
.iconbtn.grownup { text-decoration: none; display: grid; place-items: center; font-size: 1.25rem; }

/* ==========================================================================
   TACTILE 3D DUOLINGO-INSPIRED UI SYSTEM (30 Nov 2026)
   Crisp white canvas, chunky 4px pressable 3D lips, vibrant high-contrast
   palette, gamified top status bar, glossy progress bar, slide-up feedback
   drawer, island skill-tree bridges, and responsive 3-column desktop shell.
   ========================================================================== */
:root {
  --bg: #FFFFFF; --card: #FFFFFF; --ink: #3C3C3C; --muted: #5F5F5F; --line: #E5E5E5; --field: #8A8A8A;
  --pri-t: #3A7300; --on: #123300; --green-t: #2E6B00; --red-t: #B91C1C; --blue-t: #0B6494;   /* words: dark shades of the same colours, so children can read them (4.5:1) */
  --pri: #58CC02; --pri-d: #58A700;
  --blue: #1CB0F6; --blue-d: #1899D6;
  --sun: #FFC800; --sun-d: #E5B400;
  --green: #58CC02; --green-bg: #D7FFB8;
  --red: #EA2B2B; --red-bg: #FFDFE0;
  --cta-from: #58CC02; --cta-to: #46B600; --cta-shadow: #58A700;
  --focus: #1CB0F6;
}
body[data-stage="middle"] { --bg: #FFFFFF; --pri-t: #0B6494; --on: #04293D; --line: #E5E5E5; --pri: #1CB0F6; --pri-d: #1899D6; --cta-from: #1CB0F6; --cta-to: #0E9CE0; --cta-shadow: #1899D6; --focus: #1CB0F6; }
body[data-stage="secondary"] { --bg: #FFFFFF; --pri-t: #4036C8; --on: #FFFFFF; --line: #E5E5E5; --pri: #635BFF; --pri-d: #4840D6; --cta-from: #635BFF; --cta-to: #5046E5; --cta-shadow: #4840D6; --focus: #635BFF; }
body[data-stage="higher"] { --bg: #FFFFFF; --pri-t: #5B21B6; --on: #FFFFFF; --line: #E5E5E5; --pri: #7C3AED; --pri-d: #5B21B6; --cta-from: #7C3AED; --cta-to: #6D28D9; --cta-shadow: #5B21B6; --focus: #7C3AED; }

body {
  background: var(--bg); color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Noto Sans", "Noto Sans Devanagari", sans-serif;
}

/* Tactile 3D chunky buttons, chips, cards & answer tiles */
.btn {
  border: 2px solid #E5E5E5; border-bottom: 4px solid #CECECE; border-radius: 16px;
  background: #FFFFFF; color: var(--ink); font-weight: 800;
  box-shadow: none; transition: transform .08s ease, border-bottom-width .08s ease;
}
.btn:active:not([disabled]) { transform: translateY(3px); border-bottom-width: 1px; }
.btn.pri { background: var(--pri); color: var(--on); border-color: var(--pri); border-bottom: 4px solid var(--pri-d); box-shadow: none; }
.btn.pri:active:not([disabled]) { transform: translateY(3px); border-bottom-width: 1px; box-shadow: none; }
.btn.sun { background: var(--sun); color: #1F2340; border-color: var(--sun); border-bottom: 4px solid var(--sun-d); box-shadow: none; }
.btn.ok { background: #58CC02; color: #123300; border-color: #58CC02; border-bottom: 4px solid #58A700; box-shadow: none; }
.big-cta { border-radius: 20px; border: 0; border-bottom: 5px solid var(--cta-shadow); box-shadow: none; transition: transform .08s ease, border-bottom-width .08s ease; }
.big-cta:active { transform: translateY(3px); border-bottom-width: 2px; box-shadow: none; }

.card { border: 2px solid #E5E5E5; border-bottom: 4px solid #E5E5E5; border-radius: 20px; }   /* no background here: it would blank the coloured cards */
.card.mhero { border: 0; }
.chip { border: 2px solid var(--field); border-bottom: 4px solid var(--field); border-radius: 14px; background: #FFFFFF; }
.chip:active { transform: translateY(2px); border-bottom-width: 2px; }
.chip.on { background: var(--blue); color: #04293D; border-color: var(--blue); border-bottom-color: var(--blue-d); }

.jopt { border: 2px solid #E5E5E5; border-bottom: 5px solid #CECECE; border-radius: 18px; background: #FFFFFF; font-weight: 800; transition: transform .08s ease, border-bottom-width .08s ease; }
.jopt:active:not([disabled]) { transform: translateY(3px); border-bottom-width: 2px; }
.jopt.sel { background: #DDF4FF; border-color: #1CB0F6; border-bottom-color: #1899D6; color: #0B6B99; box-shadow: none; }
.jopt.right { background: #D7FFB8; border-color: #58CC02; border-bottom-color: #58A700; color: #2D6A00; }
.jopt.wrong, .jopt.was { background: #FFDFE0; border-color: #EA2B2B; border-bottom-color: #C51F1F; color: #A61B1B; }

/* Gamified Sticky Top Status Bar */
#hdr { background: #FFFFFF; border-bottom: 2px solid #E5E5E5; gap: 6px; padding-top: calc(6px + env(safe-area-inset-top)); padding-bottom: 6px; }
.stat-cls {
  display: inline-flex; align-items: center; gap: 5px; min-height: 44px; padding: 0 11px;
  border-radius: 14px; border: 2px solid #E5E5E5; border-bottom: 4px solid #CECECE;
  background: #FFFFFF; font-weight: 800; font-size: .9rem; color: var(--ink); white-space: nowrap; flex: none;
}
.stat-cls:active { transform: translateY(2px); border-bottom-width: 2px; }
.stat-cls .emo { font-size: 1.15rem; }
.stat-cls .caret { font-size: .78rem; color: var(--muted); }
.stat-pills { display: flex; align-items: center; gap: 6px; flex: 1 1 auto; min-width: 0; justify-content: center; overflow: hidden; }
.stat-pill {
  display: inline-flex; align-items: center; gap: 3px; padding: 4px 8px; border-radius: 12px;
  font-weight: 900; font-size: .92rem; white-space: nowrap;
}
.stat-pill.fire { color: #8F4B00; background: #FFF4E0; }
.stat-pill.star { color: #755200; background: #FFF8D6; }
#hdr .langbtn, #hdr .iconbtn { border: 2px solid #E5E5E5; border-bottom: 4px solid #CECECE; border-radius: 14px; background: #FFFFFF; }
#hdr .langbtn:active, #hdr .iconbtn:active { transform: translateY(2px); border-bottom-width: 2px; }
@media (max-width: 360px) { .stat-cls { padding: 0 8px; font-size: .82rem; } .stat-pill { padding: 3px 6px; font-size: .82rem; } }

/* Chunky Colored Bottom Nav Bar + Soft Blue Active Pill */
#tabs { background: #FFFFFF; border-top: 2px solid #E5E5E5; }
#tabs .nav-brand { display: none; }
#tabs a { gap: 3px; padding: 5px 4px; color: #5F5F5F; font-weight: 800; font-size: 13px; }
#tabs .tab-ico {
  width: 36px; height: 32px; border-radius: 12px; display: grid; place-items: center; font-size: 1.25rem;
  border: 2px solid transparent; transition: transform .1s ease, background .15s ease;
}
#tabs a.on { color: #0B6494; }
#tabs a.on .tab-ico { background: #DDF4FF; border-color: #1CB0F6; border-bottom: 3px solid #1899D6; transform: translateY(-1px); }

/* Winding S-Curve Path: Large Raised 3D Stepping Stones + Bouncing START Tooltip + Treasure Chests */
.plink path { stroke: #E5E5E5; stroke-width: 10px; stroke-dasharray: 1 18; }
.plink.lit path { stroke: #FFC800; stroke-width: 8px; stroke-dasharray: none; }
.pbub {
  position: relative; width: 76px; height: 76px; margin-left: calc(var(--x) - 38px);
  border-radius: 50%; font-size: 2.15rem;
  background: #E5E5E5; border: 3px solid #D4D4D4; border-bottom: 7px solid #AFAFAF; box-shadow: none;
  transition: transform .08s ease, border-bottom-width .08s ease;
}
.pnode.rt .pbub { margin: 0 calc(var(--x) - 38px) 0 0; }
.pnode.part .pbub { background: #1CB0F6; border-color: #1CB0F6; border-bottom: 7px solid #1899D6; }
.pnode.done .pbub { background: #FFC800; border-color: #FFC800; border-bottom: 7px solid #E5B400; }
.pnode.now .pbub { background: #58CC02; border-color: #58CC02; border-bottom: 7px solid #58A700; box-shadow: 0 0 0 6px rgba(88, 204, 2, .22); animation: none; }
body[data-stage="middle"] .pnode.now .pbub { background: #1CB0F6; border-color: #1CB0F6; border-bottom-color: #1899D6; box-shadow: 0 0 0 6px rgba(28, 176, 246, .22); }
.pnode.pchest .pbub { border-radius: 22px; background: #FFF4CC; border-color: #FFC800; border-bottom: 6px solid #E5B400; width: 64px; height: 64px; margin-left: calc(var(--x) - 32px); font-size: 1.8rem; }
.pnode.pchest.rt .pbub { margin: 0 calc(var(--x) - 32px) 0 0; }
.pnode.ptro .pbub { border-radius: 22px; background: #CE82FF; border-color: #CE82FF; border-bottom: 7px solid #A560E8; }
.pnode:active .pbub { transform: translateY(4px); border-bottom-width: 3px; box-shadow: none; }
.pstart-tip {
  position: absolute; top: -32px; left: 50%; transform: translateX(-50%);
  padding: 4px 12px; border-radius: 12px; background: #FFFFFF; color: var(--pri-t);
  border: 2px solid #E5E5E5; border-bottom: 3px solid #CECECE;
  font-size: 12px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap;
  animation: pfloat 1.4s ease-in-out infinite;
}
@keyframes pfloat { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -5px); } }
.pgo { display: none; }
.plab { background: #FFFFFF; }
@media (max-width: 340px) { .pbub { width: 64px; height: 64px; margin-left: calc(var(--x) - 32px); } .pnode.rt .pbub { margin-right: calc(var(--x) - 32px); } }

/* Thick Glossy Green Progress Bar + Full-Width Slide-Up Feedback Drawer */
.jtop .jprog { gap: 4px; background: #E5E5E5; padding: 3px; border-radius: 999px; }
.jtop .jprog span { position: relative; height: 14px; border-radius: 999px; background: transparent; transition: background .25s ease; }
.jtop .jprog span.on { background: #58CC02; }
.jtop .jprog span.on::after { content: ""; position: absolute; left: 12%; right: 12%; top: 3px; height: 4px; border-radius: 999px; background: rgba(255, 255, 255, .38); }
.jtop .jprog span.cur { background: #B8F28B; }
.tprog { height: 16px; border-radius: 999px; background: #E5E5E5; }
.tprog i { position: relative; background: #58CC02; border-radius: 999px; }

.jdock {
  margin: 12px -14px 0; padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0; border-top: 2px solid #E5E5E5; background: #FFFFFF;
  transition: background .2s ease, border-color .2s ease;
}
.jdock:has(.jfeed.good) { background: #D7FFB8; border-top-color: #58CC02; animation: dslide .2s ease-out; }
.jdock:has(.jfeed.good) .btn.pri { background: #58CC02; border-color: #58CC02; border-bottom-color: #58A700; }
.jdock:has(.jfeed.try), .jdock:has(.jfeed.how) { background: #FFDFE0; border-top-color: #EA2B2B; animation: dslide .2s ease-out; }
.jdock:has(.jfeed.try) .btn.pri, .jdock:has(.jfeed.how) .btn.pri { background: #EA2B2B; border-color: #EA2B2B; border-bottom-color: #C51F1F; }
@keyframes dslide { from { transform: translateY(18px); opacity: .7; } to { transform: none; opacity: 1; } }

/* Visual Island / Skill-Tree Bridges */
.jchain { background: linear-gradient(180deg, #F7FCFF, #FFFFFF); border: 2px solid #DDF4FF; border-bottom: 4px solid #BAE6FD; border-radius: 22px; }
.jbnode {
  width: 112px; border-radius: 20px; border: 2px solid #E5E5E5; border-bottom: 5px solid #CECECE;
  background: #FFFFFF; padding: 10px 6px; transition: transform .08s ease;
}
.jbnode:active { transform: translateY(3px); border-bottom-width: 2px; }
.jbnode .bub { width: 52px; height: 52px; background: #F0F9FF; border: 2px solid #BAE6FD; }
.jbnode.lit { background: #FFFBEB; border-color: #FFC800; border-bottom-color: #E5B400; }
.jbnode.lit .bub { background: #FFC800; border-color: #E5B400; }
.jbnode.mine { border-color: #1CB0F6; border-bottom-color: #1899D6; }
.jbnode.later { background: #F7F7F7; border-style: dashed; border-color: #D4D4D4; border-bottom-style: solid; border-bottom-color: #CECECE; opacity: .78; }
.jbnode.now { border-color: #58CC02; border-bottom-color: #58A700; box-shadow: 0 0 0 4px rgba(88, 204, 2, .2); }

.ppath { padding-top: 26px; }
.onb-crumbs { text-align: center; font-size: .85rem; font-weight: 800; color: var(--blue-t); background: #DDF4FF; border: 2px solid #BAE6FD; border-radius: 999px; padding: 5px 14px; align-self: center; }
.saybtn.playing { background: #DDF4FF; border: 2px solid #1CB0F6; }
.home-grid { display: block; }
.home-side { margin-top: 10px; }

/* Responsive 3-Column Desktop Layout (Left Sidebar Nav · Center Path · Right Missions & Foundations) */
@media (min-width: 640px) {
  body, body[data-stage="middle"], body[data-stage="secondary"], body[data-stage="higher"] { background: #FFFFFF; }
  #hdr, #app { box-shadow: none; }
}
@media (min-width: 960px) {
  body:has(#tabs:not([hidden])):not(.in-lesson):not(.in-play):not(.in-welcome) { padding-left: 224px; }
  body:has(#tabs:not([hidden])):not(.in-lesson):not(.in-play):not(.in-welcome) #tabs {
    position: fixed; top: 0; left: 0; bottom: 0; right: auto; width: 224px;
    border-top: 0; border-right: 2px solid #E5E5E5; padding: 18px 14px;
    display: flex; flex-direction: column; justify-content: flex-start;
  }
  body:has(#tabs:not([hidden])):not(.in-lesson):not(.in-play):not(.in-welcome) #tabs .in {
    flex-direction: column; gap: 6px; max-width: none;
  }
  body:has(#tabs:not([hidden])):not(.in-lesson):not(.in-play):not(.in-welcome) #tabs .nav-brand {
    display: flex; align-items: center; gap: 8px; font-weight: 900; font-size: 1.25rem;
    color: var(--pri-t); padding: 4px 10px 16px;
  }
  body:has(#tabs:not([hidden])):not(.in-lesson):not(.in-play):not(.in-welcome) #tabs a {
    flex: none; flex-direction: row; justify-content: flex-start; gap: 12px;
    padding: 10px 14px; border-radius: 16px; font-size: .95rem; text-align: left;
    border: 2px solid transparent; min-height: 50px;
  }
  body:has(#tabs:not([hidden])):not(.in-lesson):not(.in-play):not(.in-welcome) #tabs a:hover { background: #F7F7F7; }
  body:has(#tabs:not([hidden])):not(.in-lesson):not(.in-play):not(.in-welcome) #tabs a.on {
    background: #DDF4FF; border-color: #1CB0F6; color: #0B6494;
  }
  body:has(#tabs:not([hidden])):not(.in-lesson):not(.in-play):not(.in-welcome) #tabs a.on .tab-ico {
    background: transparent; border-color: transparent; border-bottom: 0; transform: none;
  }
  body:has(#tabs:not([hidden])) #hdr { max-width: 940px; padding-left: 24px; padding-right: 24px; }
  body:has(#tabs:not([hidden])) #app { max-width: 940px; padding: 16px 24px 48px; }
  .home-grid { display: grid; grid-template-columns: minmax(0, 560px) 300px; gap: 28px; align-items: start; }
  .home-side { margin-top: 0; position: sticky; top: 76px; }
}
@media (prefers-reduced-motion: reduce) { .pstart-tip, .jdock { animation: none; } }

/* Textbook: the chapter, then a one-tap PDF button */
.chaprow { display: flex; gap: 8px; align-items: stretch; }
.chaprow .chap { flex: 1; min-width: 0; }
.chaprow .chappdf { flex: none; color: var(--ink); margin: 0; padding: 0 10px; border: 2px solid #E5E5E5; border-bottom: 4px solid #CECECE; border-radius: 14px; background: #fff; text-decoration: none; font-weight: 800; font-size: .88rem; white-space: nowrap; }
/* narrow phones: one count in the top bar (the streak is on Home and Me), so nothing is cut off */
@media (max-width: 420px) { .stat-pill.fire, .stat-cls .caret { display: none; } #hdr { gap: 4px; } }
.pdfnote { margin: 0 0 12px; padding: 8px 12px; border-radius: 12px; background: #DDF4FF; color: #0B4A6B; font-weight: 700; font-size: .92rem; }
.big-cta, .big-cta h2, .big-cta p, .stagetitle .num, .onb-clsbtn.on, .mpnum, .mex-step .sn, .mroad .sn { color: var(--on); }
/* ===== v25 Visual Polish & Bug Fixes (30 Nov 2026) ===== */
:root { --pri: #46A302; --pri-d: #357E00; --on: #FFFFFF; --cta-from: #46A302; --cta-to: #3B8E00; --cta-shadow: #2F7000; }
body[data-stage="middle"] { --pri: #0284C7; --pri-d: #0369A1; --on: #FFFFFF; --cta-from: #0284C7; --cta-to: #0369A1; --cta-shadow: #075985; }
body[data-stage="secondary"] { --pri: #4F46E5; --pri-d: #3730A3; --on: #FFFFFF; --cta-from: #4F46E5; --cta-to: #4338CA; --cta-shadow: #312E81; }
body[data-stage="higher"] { --pri: #7C3AED; --pri-d: #5B21B6; --on: #FFFFFF; --cta-from: #7C3AED; --cta-to: #6D28D9; --cta-shadow: #4C1D95; }

/* Bug fix 1: .stat-pill.star was inheriting .star { width: 30px; height: 30px }! */
.stat-pill.star { width: auto; height: auto; padding: 5px 10px; border-radius: 12px; color: #755200; background: #FFF8D6; border: 2px solid #FFE484; }
.stat-pill.fire { width: auto; height: auto; padding: 5px 10px; border-radius: 12px; color: #8F4B00; background: #FFF4E0; border: 2px solid #FFD599; }

/* Bug fix 2: .mpanel right border & step badge clipping inside .jlearn */
.jlearn { padding: 16px 4px 10px; }

/* Bug fix 3: hide empty .jdock divider in Class 1-2 games before an answer is tapped */
.jdock:has(.jfeed:empty):has(.jnextwrap:empty) { border-top-color: transparent; background: transparent; padding: 0; margin: 0; }
.jdock:has(.jfeed.good) .btn.pri { background: #46A302; border-color: #46A302; border-bottom-color: #357E00; color: #FFFFFF; }

/* Unified Home Unit Banner (replaces redundant double-stacked hero + CTA) */
.unit-banner {
  border-radius: 22px; padding: 16px; margin: 0 0 14px; color: #FFFFFF;
  background: linear-gradient(135deg, var(--cta-from), var(--cta-to));
  border: 0; border-bottom: 5px solid var(--cta-shadow);
}
.unit-banner.primary { background: linear-gradient(135deg, #46A302, #2E8540); border-bottom-color: #246630; }
.unit-banner .ub-top { display: flex; align-items: center; gap: 12px; }
.unit-banner .ub-top .grow { flex: 1; min-width: 0; }
.unit-banner .mbadge { margin-bottom: 4px; background: rgba(255, 255, 255, .22); color: #FFFFFF; }
.unit-banner h1 { margin: 0 0 2px; font-size: 1.35rem; color: #FFFFFF; }
.unit-banner .ub-sub { margin: 0; font-size: .88rem; color: rgba(255, 255, 255, .92); font-weight: 700; }
.unit-banner .ub-go {
  margin-top: 12px; width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 10px 14px; min-height: 52px; border-radius: 16px;
  background: #FFFFFF; color: var(--ink); border: 0; border-bottom: 4px solid rgba(0, 0, 0, .18);
  font-weight: 800; font-size: .96rem; transition: transform .08s ease;
}
.unit-banner .ub-go:active { transform: translateY(2px); border-bottom-width: 2px; }
.unit-banner .ub-go .ue { font-size: 1.5rem; flex: none; }
.unit-banner .ub-go .grow { flex: 1; min-width: 0; }
.unit-banner .ub-go small { display: block; font-size: .8rem; font-weight: 700; color: var(--muted); }
.unit-banner .ub-go .arrow { font-size: 1.2rem; color: var(--pri); flex: none; }
.unit-banner .jmascot { width: 54px; height: 54px; flex: none; }
.onb-clsbtn:not(.on) { border-color: var(--field); }
.mefield input { border-color: var(--field); }


/* v26 additions: tappable numeric stepper (B-068), short-screen lesson fit (B-069), spaced-review card & backup input */
.st-inp {
  width: 64px; height: 48px; text-align: center; font: 900 1.35rem var(--font, system-ui, sans-serif);
  color: var(--ink); background: #fff; border: 2px solid var(--field); border-radius: 14px;
  padding: 0 4px;
}
.st-inp:focus { outline: none; border-color: var(--pri); box-shadow: 0 0 0 3px rgba(79, 70, 229, .18); }
.st-jump { width: 42px; height: 42px; font-size: .95rem; background: #F8FAFC; }
@media (max-height: 700px) {
  body.in-lesson .bar-svg { max-height: 156px; }
  body.in-lesson .wprompt { font-size: .95rem; margin-bottom: 6px; }
}
.due-card {
  background: linear-gradient(135deg, #FFFBEB 0%, #FEF3C7 100%);
  border: 2px solid #F59E0B !important;
  box-shadow: 0 4px 0 #FCD34D;
  margin-bottom: 14px;
}
.backup-inp {
  flex: 1; min-width: 0; font: 600 .9rem ui-monospace, monospace;
  padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink);
}


/* v27 additions: Teacher / Parent 1-page printable gap sheet */
.print-sheet { background: #fff; padding: 20px; }
.print-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; border-bottom: 2px solid var(--line); padding-bottom: 12px; margin-bottom: 12px; }
.print-kpis { display: flex; gap: 6px; flex-wrap: wrap; }
.print-sec { margin: 12px 0; }
.print-sec h2 { font-size: 1.02rem; margin: 0 0 6px; color: var(--ink); }
.print-list { margin: 0; padding-left: 20px; }
.print-list li { margin: 5px 0; line-height: 1.45; }
@media print {
  #hdr, #tabs, .no-print { display: none !important; }
  body, #app { background: #fff !important; margin: 0 !important; padding: 0 !important; max-width: 100% !important; }
  .print-sheet { border: none !important; box-shadow: none !important; padding: 0 !important; }
}


/* ================= v28: Calm Evening Dark Mode (Brilliant.org style) ================= */
html[data-theme="dark"] {
  --bg: #0F172A;
  --card: #1E293B;
  --ink: #F1F5F9;
  --muted: #94A3B8;
  --line: #334155;
  --field: #64748B;
  --green-bg: #064E3B;
  --red-bg: #4C0519;
}
html[data-theme="dark"] body { background: #0F172A !important; color: #F1F5F9 !important; }
html[data-theme="dark"] #hdr,
html[data-theme="dark"] #tabs,
html[data-theme="dark"] .card,
html[data-theme="dark"] .sheet,
html[data-theme="dark"] .item,
html[data-theme="dark"] .jopt,
html[data-theme="dark"] .optbtn,
html[data-theme="dark"] .pcard,
html[data-theme="dark"] .pgame,
html[data-theme="dark"] .tfnode,
html[data-theme="dark"] .jqcard,
html[data-theme="dark"] .mpanel,
html[data-theme="dark"] .jdock,
html[data-theme="dark"] .lfoot,
html[data-theme="dark"] .btn:not(.pri):not(.sun):not(.ok):not(.danger),
html[data-theme="dark"] .chip:not(.on),
html[data-theme="dark"] .iconbtn,
html[data-theme="dark"] .langbtn,
html[data-theme="dark"] .stat-cls,
html[data-theme="dark"] .mstage-card {
  background: #1E293B !important;
  color: #F1F5F9 !important;
  border-color: #334155 !important;
}
html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] .st-inp,
html[data-theme="dark"] .backup-inp {
  background: #0F172A !important;
  color: #F1F5F9 !important;
  border-color: #475569 !important;
}
html[data-theme="dark"] .stat-pill.fire { background: #431407 !important; border-color: #9A3412 !important; color: #FDBA74 !important; }
html[data-theme="dark"] .stat-pill.star { background: #422006 !important; border-color: #A16207 !important; color: #FDE047 !important; }
html[data-theme="dark"] .due-card { background: linear-gradient(135deg, #2E1A05 0%, #422006 100%) !important; border-color: #D97706 !important; }
html[data-theme="dark"] .pnode .pbub { background: #1E293B; border-color: #475569; }
html[data-theme="dark"] .unit-banner .ub-btn { background: #0F172A !important; color: #F8FAFC !important; }
html[data-theme="dark"] .jopt.right { background: #064E3B !important; border-color: #10B981 !important; color: #ECFDF5 !important; }
html[data-theme="dark"] .jopt.wrong { background: #4C0519 !important; border-color: #F43F5E !important; color: #FFF1F2 !important; }

/* ================= v28: 1-Tap Rough-Work Scratchpad (Khan Academy style) ================= */
.pad-overlay {
  position: fixed; inset: 0; z-index: 80; display: flex; flex-direction: column;
  background: rgba(255, 255, 255, 0.86); backdrop-filter: blur(2px);
}
html[data-theme="dark"] .pad-overlay { background: rgba(15, 23, 42, 0.88); }
.pad-overlay.grid .pad-canvas {
  background-image: linear-gradient(to right, rgba(148, 163, 184, .22) 1px, transparent 1px),
                    linear-gradient(to bottom, rgba(148, 163, 184, .22) 1px, transparent 1px);
  background-size: 24px 24px;
}
.pad-bar {
  display: flex; align-items: center; gap: 6px; padding: 10px 12px;
  background: var(--card, #fff); border-bottom: 2px solid var(--line, #E2E8F0);
  flex-wrap: wrap;
}
.pad-lbl { font-weight: 800; font-size: .9rem; margin-right: auto; }
.pad-dot { width: 28px; height: 28px; border-radius: 50%; border: 3px solid transparent; padding: 0; }
.pad-dot.on { border-color: var(--ink, #1F2340); transform: scale(1.1); }
.pad-btn {
  min-width: 36px; height: 34px; padding: 0 10px; border-radius: 10px;
  border: 2px solid var(--line, #E2E8F0); background: var(--card, #fff); color: var(--ink, #1F2340);
  font-weight: 800; font-size: .88rem;
}
.pad-btn.on { background: #EEF2FF; border-color: #4F46E5; color: #4F46E5; }
.pad-btn.pad-done { background: #46A302; border-color: #367E00; color: #fff; }
.pad-canvas { flex: 1; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }

/* ================= v28: Math Gym Combo & Interactive Fraction Wall ================= */
.gym-combo {
  align-self: center; background: #FFF7ED; color: #C2410C; border: 2px solid #FB923C;
  padding: 4px 12px; border-radius: 999px; font-weight: 900; font-size: .9rem; margin-bottom: 8px;
}
.fw-read {
  background: #F8FAFC; border: 2px solid var(--line, #E2E8F0); border-radius: 12px;
  padding: 10px 12px; text-align: center; font-size: 1.05rem; margin-bottom: 10px;
}
html[data-theme="dark"] .fw-read { background: #0F172A; }
.fwall { display: flex; flex-direction: column; gap: 5px; }
.fw-row { display: flex; gap: 3px; width: 100%; }
.fw-tile {
  flex: 1; min-width: 0; height: 36px; padding: 0 2px; border-radius: 8px;
  border: 2px solid var(--line, #CBD5E1); background: var(--card, #fff); color: var(--ink, #1F2340);
  font-weight: 800; font-size: .78rem; transition: transform .08s, background .12s;
}
.fw-tile.on { background: var(--fwc); border-color: var(--fwc); color: #fff; transform: translateY(-1px); box-shadow: 0 2px 0 rgba(0, 0, 0, .2); }
