/* Bipo — base styles, shell, profiles, home, session, results. Module styles live in their own files. */
@font-face { font-family: 'Nunito'; font-style: normal; font-weight: 200 1000; font-display: swap;
  src: url(../fonts/nunito-cyrillic-ext-wght-normal.woff2) format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: 'Nunito'; font-style: normal; font-weight: 200 1000; font-display: swap;
  src: url(../fonts/nunito-cyrillic-wght-normal.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Nunito'; font-style: normal; font-weight: 200 1000; font-display: swap;
  src: url(../fonts/nunito-latin-ext-wght-normal.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Nunito'; font-style: normal; font-weight: 200 1000; font-display: swap;
  src: url(../fonts/nunito-latin-wght-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --ink: #2D3142; --ink2: #5C6378; --muted: #8A90A2;
  --bg1: #E6F4FF; --bg2: #FFF6E5; --card: #FFFFFF; --line: #DCE4F2;
  --blue: #4F8EF7; --blue-d: #3172E0; --orange: #FF9F43; --green: #1DD1A1; --green-d: #10AC84;
  --red: #FF6B6B; --yellow: #FFD93D; --purple: #6C5CE7; --pink: #F368E0;
  --r: 22px; --r-s: 14px;
  --sh: 0 6px 0 rgba(45, 49, 66, .08), 0 10px 30px rgba(45, 49, 66, .08);
  --font: 'Nunito', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); color: var(--ink); font-size: 18px; line-height: 1.35;
  background: linear-gradient(160deg, var(--bg1) 0%, #F2F8FF 45%, var(--bg2) 100%) fixed;
  -webkit-font-smoothing: antialiased; user-select: none; overflow-x: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:disabled { cursor: default; }
input, textarea, select { font: inherit; color: inherit; user-select: text; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
#app { min-height: 100vh; }
.screen { min-height: 100vh; display: flex; flex-direction: column; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.hidden { display: none !important; }
pre.err { white-space: pre-wrap; color: #B00020; padding: 20px; }

/* ---------- common components ---------- */
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--sh); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 999px; font-weight: 800; font-size: 18px;
  transition: transform .08s ease, box-shadow .08s ease, filter .15s;
}
.btn:active:not(:disabled) { transform: translateY(3px); }
.btn.primary { background: var(--blue); color: #fff; box-shadow: 0 5px 0 var(--blue-d); }
.btn.primary:active:not(:disabled) { box-shadow: 0 2px 0 var(--blue-d); }
.btn.good { background: var(--green); color: #fff; box-shadow: 0 5px 0 var(--green-d); }
.btn.danger { background: var(--red); color: #fff; box-shadow: 0 5px 0 #D94B4B; }
.btn.ghost { background: #fff; color: var(--ink); box-shadow: 0 5px 0 var(--line), inset 0 0 0 2px var(--line); }
.btn:disabled { filter: grayscale(.8) opacity(.6); }
.btn.big { padding: 16px 30px; font-size: 21px; }
.btn.huge { padding: 20px 34px; font-size: 25px; }
.btn:hover:not(:disabled) { filter: brightness(1.05); }
.btn-icon {
  width: 48px; height: 48px; border-radius: 50%; background: #fff; box-shadow: var(--sh);
  display: inline-flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 900;
}
.btn-icon:active { transform: scale(.94); }
.chip { padding: 8px 16px; border-radius: 999px; background: #fff; font-weight: 700; box-shadow: inset 0 0 0 2px var(--line); }
.chip.on { background: var(--blue); color: #fff; box-shadow: none; }
.inp { width: 100%; padding: 14px 18px; border-radius: var(--r-s); border: 3px solid var(--line); font-size: 22px; font-weight: 700; outline: none; background: #fff; }
.inp:focus { border-color: var(--blue); }
.lbl { display: block; font-weight: 800; margin: 16px 0 8px; color: var(--ink2); }
.sec-title { text-align: center; font-size: 30px; margin: 10px 0 22px; }
.shake { animation: shake .45s; }
@keyframes shake { 20%, 60% { transform: translateX(-9px); } 40%, 80% { transform: translateX(9px); } }

/* ---------- top bar ---------- */
.topbar { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; padding: 14px 22px; }
.topbar-title { text-align: center; font-size: 26px; }
.topbar-right { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.coins { display: inline-flex; align-items: center; gap: 8px; background: #fff; padding: 8px 16px 8px 10px; border-radius: 999px; box-shadow: var(--sh); font-size: 20px; }
.coin-ic { width: 26px; height: 26px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #FFE680, #FFC300 60%, #E0A800); box-shadow: inset 0 0 0 2px #D19A00; position: relative; }
.coin-ic::after { content: '★'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 14px; color: #B37F00; }
.who { display: inline-flex; align-items: center; gap: 10px; background: #fff; border-radius: 999px; padding: 4px 16px 4px 4px; box-shadow: var(--sh); font-size: 19px; }
.who svg { display: block; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 30px); opacity: 0; z-index: 90;
  background: var(--ink); color: #fff; padding: 14px 24px; border-radius: 999px; font-weight: 800; font-size: 19px;
  transition: all .3s ease; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); max-width: 90vw; text-align: center;
}
.toast.in { transform: translate(-50%, 0); opacity: 1; }
.toast.good { background: var(--green-d); }
.modal-ov { position: fixed; inset: 0; background: rgba(45, 49, 66, .45); display: grid; place-items: center; z-index: 80; padding: 20px; animation: fadeIn .2s; }
.modal { background: #fff; border-radius: var(--r); padding: 28px; max-width: 560px; width: 100%; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); max-height: 90vh; overflow: auto; }
.modal h2 { margin-bottom: 12px; }
.modal p { font-size: 20px; margin: 0 0 8px; }
.modal-btns { display: flex; gap: 14px; justify-content: flex-end; margin-top: 22px; flex-wrap: wrap; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 95; overflow: hidden; }
.confetti i { position: absolute; top: -20px; height: 14px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { top: 110vh; transform: rotate(720deg) translateX(40px); } }
.coin-pop { position: fixed; z-index: 96; transform: translate(-50%, 0); font-weight: 900; font-size: 26px; color: #E0A800; text-shadow: 0 2px 0 #fff; animation: pop-up 1.1s ease-out forwards; pointer-events: none; }
@keyframes pop-up { to { transform: translate(-50%, -70px); opacity: 0; } }
.bubble { position: relative; background: #fff; border-radius: 20px; padding: 16px 20px; font-size: 22px; font-weight: 800; box-shadow: var(--sh); }
.bubble.small { font-size: 18px; padding: 12px 16px; min-height: 48px; }
.bubble:empty { visibility: hidden; }

/* ---------- profiles ---------- */
.prof-main { flex: 1; padding: 10px 24px 40px; max-width: 980px; margin: 0 auto; width: 100%; }
.welcome { display: flex; align-items: center; justify-content: center; gap: 26px; margin: 0 0 10px; }
.logo { font-size: 64px; font-weight: 900; color: var(--blue); letter-spacing: 1px; }
.tagline { font-size: 22px; font-weight: 700; color: var(--ink2); margin: 4px 0 0; }
.lang-switch { display: flex; gap: 8px; }
.prof-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 20px; }
.prof-card { padding: 18px 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 22px; transition: transform .12s; }
.prof-card:hover { transform: translateY(-4px); }
.prof-card small { color: var(--muted); font-weight: 700; font-size: 16px; }
.prof-card.add { background: rgba(255, 255, 255, .6); box-shadow: inset 0 0 0 3px dashed var(--line); border: 3px dashed #C6D2E8; }
.plus { width: 120px; height: 120px; display: grid; place-items: center; font-size: 64px; color: var(--blue); font-weight: 300; }
.prof-form { padding: 26px; }
.prof-form-grid { display: grid; grid-template-columns: 180px 1fr; gap: 24px; align-items: center; }
.prof-preview { display: grid; place-items: center; }
.age-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chip.age { width: 54px; height: 54px; padding: 0; font-size: 20px; }
.color-row { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 44px; height: 44px; border-radius: 50%; box-shadow: inset 0 0 0 3px rgba(0, 0, 0, .12); }
.swatch.on { outline: 4px solid var(--ink); outline-offset: 3px; }
.prof-form > .btn { display: flex; margin: 26px auto 0; }

/* ---------- home ---------- */
.home { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 4px 24px 30px; display: flex; flex-direction: column; gap: 22px; }
.hero { display: grid; grid-template-columns: 220px 1fr; gap: 20px; padding: 22px 28px; align-items: center; }
.hero-bot { display: grid; place-items: center; }
.hero-body { display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.hero-body .bubble { font-size: 24px; }
.streak { display: flex; align-items: baseline; gap: 8px; font-size: 22px; }
.streak .flame { font-size: 28px; }
.streak small { color: var(--muted); font-weight: 700; }
.week { display: flex; gap: 8px; }
.wd { width: 48px; text-align: center; border-radius: 12px; background: #F0F4FB; padding: 4px 0 6px; }
.wd small { display: block; font-size: 13px; font-weight: 800; color: var(--muted); }
.wd span { display: block; height: 22px; font-weight: 900; color: #fff; }
.wd.done { background: var(--green); }
.wd.done small { color: #E9FFF8; }
.wd.today { box-shadow: inset 0 0 0 3px var(--blue); }
.start { margin-top: 6px; }
.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; }
.tile {
  position: relative; background: #fff; border-radius: var(--r); box-shadow: var(--sh); padding: 20px 12px 18px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; font-size: 19px; transition: transform .12s;
}
.tile:hover { transform: translateY(-4px); }
.tile-ic { font-size: 46px; line-height: 1; }
.tile-ic svg { display: block; }
.tile small { color: var(--muted); font-weight: 700; font-size: 14px; }
.tile.locked { opacity: .7; }
.tile .lock { position: absolute; top: 10px; right: 12px; font-size: 20px; }
.tile.parent { background: #F7F9FD; }

/* ---------- session ---------- */
.ses-top { grid-template-columns: auto 1fr auto; }
.tbar { display: flex; align-items: center; gap: 12px; }
.tbar-track { flex: 1; height: 16px; background: #fff; border-radius: 999px; overflow: hidden; box-shadow: inset 0 0 0 2px var(--line); }
.tbar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--green), var(--blue)); border-radius: 999px; transition: width 1s linear; }
.tbar-lbl { font-weight: 800; color: var(--ink2); min-width: 64px; text-align: right; font-size: 16px; }
.ses { flex: 1; display: grid; grid-template-columns: 190px 1fr; gap: 20px; padding: 6px 24px 30px; max-width: 1240px; width: 100%; margin: 0 auto; }
.ses-side { display: flex; flex-direction: column; align-items: center; gap: 10px; padding-top: 10px; }
.ses-bot svg { display: block; }
.ses-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.ex-card { padding: 22px 28px 26px; transition: box-shadow .2s; }
.ex-card.ok { box-shadow: 0 0 0 5px var(--green), var(--sh); }
.ex-card.bad { box-shadow: 0 0 0 5px var(--orange), var(--sh); }
.ex-head { display: flex; align-items: center; gap: 10px; min-height: 30px; }
.ex-tag { background: var(--yellow); color: var(--ink); font-weight: 900; font-size: 13px; padding: 4px 10px; border-radius: 999px; text-transform: uppercase; letter-spacing: .5px; }
.ex-skill { color: var(--muted); font-weight: 800; font-size: 15px; flex: 1; }
.speak { width: 42px; height: 42px; font-size: 20px; }
.power { position: relative; width: 52px; height: 52px; font-size: 24px; margin: 0 auto; box-shadow: 0 4px 0 var(--purple), inset 0 0 0 2px var(--purple); }
.power:disabled { filter: grayscale(.7) opacity(.55); box-shadow: 0 4px 0 var(--line), inset 0 0 0 2px var(--line); }
.power .power-n { position: absolute; right: -4px; bottom: -4px; min-width: 18px; height: 18px; padding: 0 3px; border-radius: 999px; background: var(--purple); color: #fff; font-size: 11px; font-weight: 900; display: grid; place-items: center; }
.ex-q { font-size: 28px; font-weight: 800; margin: 10px 0 14px; white-space: normal; }
.ex-card.young .ex-q { font-size: 34px; }
.ex-viz { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 18px; margin: 6px 0 16px; }
.ex-viz .viz { max-width: 100%; height: auto; }
.ans-box { margin-top: 8px; }
.ans-box.locked { pointer-events: none; }
.ans-entry { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 22px 40px; }
.ans-line { display: flex; align-items: center; gap: 12px; font-size: 34px; font-weight: 900; flex-wrap: wrap; justify-content: center; }
.ans-aff { color: var(--ink2); }
.field {
  min-width: 120px; height: 72px; padding: 0 16px; border-radius: 16px; background: #F4F7FC; box-shadow: inset 0 0 0 3px var(--line);
  display: inline-flex; align-items: center; justify-content: center; font-size: 36px; font-weight: 900; cursor: pointer; outline: none;
}
.field.focus { box-shadow: inset 0 0 0 4px var(--blue); background: #fff; }
.field.focus:not(.filled)::after { content: ''; width: 3px; height: 38px; background: var(--blue); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.field.blank { min-width: 80px; height: 60px; font-size: 30px; }
.bl-txt { white-space: pre; }
.frac-in { display: inline-flex; flex-direction: column; align-items: center; gap: 6px; }
.frac-in .field { min-width: 90px; height: 60px; font-size: 30px; }
.frac-bar { width: 110px; height: 5px; background: var(--ink); border-radius: 3px; }
.field.whole { min-width: 80px; }
.keypad-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.keypad { display: grid; grid-template-columns: repeat(3, 72px); gap: 10px; }
.keypad-extra { display: flex; gap: 10px; }
.key {
  height: 62px; min-width: 72px; border-radius: 16px; background: #fff; font-size: 28px; font-weight: 900;
  box-shadow: 0 4px 0 var(--line), inset 0 0 0 2px var(--line);
}
.key:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line), inset 0 0 0 2px var(--line); }
.key-back { color: var(--red); }
.key-extra { background: #FFF6D6; }
.key-ok { width: 100%; }
.choices { display: grid; gap: 14px; }
.choices.layout-row { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.choices.layout-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.choices.layout-col { grid-template-columns: 1fr; }
.opt {
  background: #fff; border-radius: 18px; padding: 16px 18px; font-size: 26px; font-weight: 800; min-height: 72px;
  box-shadow: 0 5px 0 var(--line), inset 0 0 0 3px var(--line); display: flex; align-items: center; justify-content: center; gap: 10px; text-align: center;
  transition: transform .08s;
}
.choices.layout-col .opt { font-size: 22px; justify-content: flex-start; text-align: left; }
.opt:hover:not(:disabled) { box-shadow: 0 5px 0 var(--line), inset 0 0 0 3px var(--blue); }
.opt:active:not(:disabled) { transform: translateY(3px); }
.opt .viz { max-width: 100%; height: auto; max-height: 150px; }
.opt.wrong { background: #FFE9E9; box-shadow: inset 0 0 0 3px var(--red); opacity: .75; }
.opt.right { background: #E3FBF3; box-shadow: inset 0 0 0 4px var(--green); }
.feedback { padding: 20px 26px; background: #FFF8EC; border-radius: var(--r); box-shadow: inset 0 0 0 3px #FFE1B3; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; animation: fadeIn .25s; }
.fb-ans { font-size: 24px; font-weight: 800; }
.fb-ans b { color: var(--green-d); }
.fb-ans .viz { vertical-align: middle; max-height: 80px; width: auto; }
.fb-exp { font-size: 20px; line-height: 1.5; color: var(--ink); }
.feedback .btn { align-self: flex-end; }

/* exercise visuals from Bipo.draw */
.items { display: inline-grid; grid-template-columns: repeat(var(--cols), var(--sz, 44px)); gap: 6px; padding: 10px; background: #F7FAFF; border-radius: 16px; }
.items .it { font-size: calc(var(--sz, 44px) * .8); line-height: var(--sz, 44px); text-align: center; position: relative; }
.items .it.x { opacity: .45; }
.items .it.x::after { content: ''; position: absolute; left: 10%; right: 10%; top: 50%; height: 4px; background: var(--red); transform: rotate(-35deg); border-radius: 2px; }
.groups { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.grp { border: 3px dashed #B8C6E0; border-radius: 18px; padding: 4px; }
.grp .items { background: none; padding: 4px; }
.seq { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; }
.seq-it { min-width: 56px; min-height: 56px; padding: 6px 10px; border-radius: 14px; background: #F4F7FC; display: inline-flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 900; }
.seq-it .viz { width: 48px; height: 48px; }
.seq-it.q { background: var(--yellow); box-shadow: inset 0 0 0 3px var(--ink); }
.dtable { border-collapse: collapse; font-size: 20px; background: #fff; }
.dtable th, .dtable td { border: 2px solid var(--line); padding: 8px 16px; text-align: center; }
.dtable th { background: #EEF4FF; }

/* ---------- results ---------- */
.results { flex: 1; display: grid; place-items: center; padding: 24px; }
.res-card { padding: 30px 40px; text-align: center; max-width: 720px; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.res-card h1 { font-size: 36px; }
.stars { font-size: 60px; letter-spacing: 6px; }
.star { color: #E3E8F2; }
.star.on { color: #FFC300; text-shadow: 0 3px 0 #E0A800; animation: starIn .5s both; }
.star.on:nth-child(2) { animation-delay: .15s; }
.star.on:nth-child(3) { animation-delay: .3s; }
@keyframes starIn { from { transform: scale(0) rotate(-90deg); } to { transform: none; } }
.res-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; width: 100%; margin: 6px 0; }
.res-stats > div { background: #F4F7FC; border-radius: 16px; padding: 12px 6px; display: flex; flex-direction: column; }
.res-stats b { font-size: 28px; }
.res-stats small { color: var(--muted); font-weight: 700; }
.res-notes { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.res-note { background: #F4F7FC; border-radius: 14px; padding: 10px 16px; font-weight: 800; text-align: left; }
.res-note.good { background: #E3FBF3; }
.res-note.badge { background: #FFF6D6; }
.res-note.story { background: #F1EEFF; font-weight: 700; font-style: italic; }
.res-btns { display: flex; gap: 16px; margin-top: 10px; flex-wrap: wrap; justify-content: center; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .ses { grid-template-columns: 1fr; }
  .ses-side { flex-direction: row; justify-content: center; padding: 0; }
  .ses-bot svg { width: 80px; height: 80px; }
}
@media (max-height: 760px) {
  .key { height: 50px; min-width: 62px; }
  .keypad { grid-template-columns: repeat(3, 62px); gap: 8px; }
  .ex-card { padding: 16px 24px 20px; }
  .ex-viz { margin: 4px 0 10px; }
  .ans-entry { gap: 14px 30px; }
}
@media (max-width: 700px) {
  body { font-size: 16px; }
  .hero { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .hero-body { align-items: center; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .prof-form-grid { grid-template-columns: 1fr; }
  .welcome { flex-direction: column; text-align: center; }
  .res-stats { grid-template-columns: repeat(2, 1fr); }
  .ex-q { font-size: 23px; }
  .keypad { grid-template-columns: repeat(3, 64px); }
  .key { height: 56px; min-width: 64px; }
  .topbar { padding: 10px 12px; }

  /* phones (portrait): shell */
  .topbar { grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; }
  .topbar-title { font-size: 18px; line-height: 1.15; overflow-wrap: anywhere; hyphens: auto; }
  .topbar-right { gap: 6px; }
  .coins { gap: 6px; padding: 6px 12px 6px 8px; font-size: 18px; }
  .coin-ic { width: 24px; height: 24px; }
  .lang-switch { flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
  .lang-switch .chip { min-height: 44px; padding: 8px 12px; font-size: 16px; }
  .sec-title { font-size: 24px; margin: 6px 0 14px; }
  .btn.huge { padding: 16px 26px; font-size: 22px; }
  .modal-ov { padding: 12px; }
  .modal { padding: 20px 18px; }
  .modal p { font-size: 18px; }
  .modal-btns { gap: 10px; }
  .modal-btns .btn { flex: 1 1 auto; }
  /* profiles */
  .prof-main { padding: 6px 12px 28px; }
  .welcome { gap: 6px; }
  .welcome-bot svg { width: 120px; height: 120px; }
  .logo { font-size: 48px; }
  .tagline { font-size: 18px; }
  .prof-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .prof-card { padding: 14px 8px; font-size: 19px; }
  .prof-form { padding: 16px 16px 20px; }
  .prof-form-grid { gap: 8px; }
  .prof-preview svg { width: 110px; height: 110px; }
  .age-grid { gap: 6px; }
  .chip.age { width: 48px; height: 48px; }
  /* session: one column, answer widgets sized to the phone */
  .ses { align-content: start; gap: 10px; padding: 4px 12px 20px; }
  .ses-bot svg { width: 64px; height: 64px; }
  .ex-card { padding: 14px 14px 16px; }
  .ex-head { gap: 8px; }
  .ex-tag { flex: none; }
  .ex-skill { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .ex-q { margin: 6px 0 10px; font-size: 21px; }
  .ex-card.young .ex-q { font-size: 26px; }
  .ex-viz { gap: 10px; margin: 4px 0 10px; }
  /* the answer field and its OK button on one row, the keys below: a single grid three keys wide */
  .ans-entry { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: center; gap: 8px; width: min(100%, 320px); margin: 0 auto; }
  .ans-entry > .ans-line { grid-row: 1; grid-column: 1 / 3; }
  .ans-entry > .ans-line.blanks { grid-column: 1 / -1; }
  .keypad-wrap, .keypad { display: contents; }
  .keypad-extra { grid-row: 2; grid-column: 1 / -1; flex-wrap: wrap; justify-content: center; gap: 8px; }
  .keypad-extra .key { min-width: 64px; }
  .key-ok { grid-row: 1; grid-column: 3; min-height: 56px; padding: 8px 6px; }
  .ans-line.blanks + .keypad-wrap > .key-ok { grid-row: auto; grid-column: 1 / -1; }
  .ans-line { gap: 8px; font-size: 28px; }
  .field { min-width: 104px; height: 60px; font-size: 32px; }
  .field.blank { min-width: 64px; height: 52px; font-size: 26px; }
  .frac-in .field { min-width: 76px; height: 52px; font-size: 26px; }
  .frac-bar { width: 90px; }
  .key { min-width: 0; height: 54px; font-size: 26px; }
  .key-extra { min-width: 64px; }
  .choices { gap: 10px; }
  .choices.layout-row { grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); }
  .choices.layout-grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
  .opt { min-height: 60px; padding: 12px; border-radius: 16px; font-size: 22px; }
  .choices.layout-col .opt { font-size: 18px; }
  .opt .items { --sz: 24px !important; gap: 4px; padding: 6px; }
  .feedback { padding: 14px 16px; gap: 10px; }
  .fb-ans { font-size: 20px; }
  .fb-exp { font-size: 17px; }
  .seq-it { min-width: 44px; min-height: 44px; font-size: 22px; }
  .dtable { font-size: 16px; }
  .dtable th, .dtable td { padding: 6px 8px; }
  /* results */
  .results { padding: 12px; }
  .res-card { padding: 20px 16px; gap: 10px; }
  .res-card h1 { font-size: 28px; }
  .res-bot svg { width: 120px; height: 120px; }
  .stars { font-size: 46px; }
  .res-stats b { font-size: 24px; }
  .res-btns { gap: 12px; }
  .res-btns .btn { flex: 1 1 auto; }
}
/* phones (both orientations): no text under 14px, no button under 44px */
@media (max-width: 700px), (max-height: 500px) and (min-width: 560px) {
  .ex-tag { font-size: 14px; letter-spacing: .2px; }
  .speak { width: 44px; height: 44px; }
  .power .power-n { min-width: 22px; height: 22px; font-size: 14px; }
  .res-stats small, .tile small, .wd small { font-size: 14px; }
  /* plans (its own styles are injected by screens/plans.js) */
  .screen-plans .plan-badge, .screen-plans .plans-foot-note { font-size: 14px; }
}
/* phones and tablets: counting pictures keep their rows (explanations count "the first row has 10") but shrink to the card */
@supports (width: 1cqw) {
  @media (max-width: 1000px), (max-height: 500px) and (min-width: 560px) {
    .ex-viz { container-type: inline-size; }
    .ex-viz .items { --cell: min(var(--sz, 44px), calc((100cqw - 20px) / var(--cols) - 6px)); grid-template-columns: repeat(var(--cols), var(--cell)); }
    .ex-viz .items .it { font-size: calc(var(--cell) * .8); line-height: var(--cell); }
  }
}

@media (max-width: 700px) and (max-height: 780px) {
  .key { height: 48px; }
  .field { height: 56px; }
  .ex-card { padding: 12px 12px 14px; }
  .ex-q { margin: 4px 0 8px; }
  .ex-viz { margin: 2px 0 8px; }
}

/* phones (landscape): little height — compact bars, the exercise beside its answer */
@media (max-height: 500px) and (min-width: 560px) {
  body { font-size: 16px; }
  .topbar { gap: 10px; padding: 6px 14px; }
  .topbar-title { font-size: 21px; }
  .sec-title { font-size: 24px; margin: 4px 0 12px; }
  .btn.big { padding: 12px 24px; font-size: 19px; }
  .btn.huge { padding: 14px 28px; font-size: 21px; }
  .modal-ov { padding: 10px; }
  .modal { padding: 18px 22px; max-height: 96vh; }
  .modal-btns { margin-top: 14px; }
  /* profiles */
  .prof-main { padding: 0 16px 20px; }
  .welcome { gap: 16px; }
  .welcome-bot svg { width: 110px; height: 110px; }
  .logo { font-size: 46px; }
  .prof-form { padding: 16px 20px 18px; }
  .prof-form-grid { grid-template-columns: 130px 1fr; gap: 16px; }
  .prof-preview svg { width: 120px; height: 120px; }
  .prof-form .lbl { margin: 10px 0 6px; }
  .chip.age { width: 48px; height: 48px; }
  .prof-form > .btn { margin-top: 16px; }
  /* session */
  .ses { grid-template-columns: 120px minmax(0, 1fr); gap: 12px; padding: 0 14px 12px; }
  .ses-side { position: relative; flex-direction: column; justify-content: flex-start; gap: 6px; padding: 0; }
  .ses-bot svg { width: 96px; height: 96px; }
  .ses-side .bubble.small { font-size: 14px; padding: 8px 10px; }
  /* the question, its picture and the answer field on the left; the keypad or the options on the right */
  .ex-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto auto auto 1fr; align-items: start;
    column-gap: 18px; padding: 12px 16px 14px; }
  .ex-card > *, .ans-box .ans-line { grid-column: 1; }
  .ex-card > .ans-box, .ans-box > .ans-entry { display: contents; }
  .ans-box .keypad-wrap, .ans-box > .choices { grid-column: 2; grid-row: 1 / -1; align-self: start; position: sticky; top: 8px; }
  .ans-box > .choices { min-width: 220px; max-width: 330px; }
  .ans-box > .choices.has-img { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 330px; }
  .ans-box .ans-line { justify-self: center; margin: 2px 0 4px; }
  .ans-box.shake .ans-line, .ans-box.shake .keypad-wrap { animation: shake .45s; }
  /* number answers: the field and its OK button on one row above the keys, all on the right
     (a progressive enhancement: engines without :has() keep the layout above) */
  .ans-box > .ans-entry:has(.field.num) { display: grid; grid-column: 2; grid-row: 1 / -1; align-self: start; position: sticky; top: 8px; grid-template-columns: repeat(3, 66px); gap: 6px; }
  .ans-entry:has(.field.num) > .ans-line { grid-row: 1; grid-column: 1 / 3; margin: 0; gap: 4px; font-size: 22px; }
  .ans-entry:has(.field.num) .field { min-width: 72px; height: 52px; padding: 0 8px; font-size: 28px; }
  .ans-entry:has(.field.num) .keypad-wrap, .ans-entry:has(.field.num) .keypad { display: contents; }
  .ans-entry:has(.field.num) .keypad-extra { grid-row: 2; grid-column: 1 / -1; justify-content: center; }
  .ans-entry:has(.field.num) .key { min-width: 0; }
  .ans-entry:has(.field.num) .key-ok { grid-row: 1; grid-column: 3; min-height: 52px; padding: 6px 4px; font-size: 16px; }
  .ex-head { min-height: 0; flex-wrap: wrap; row-gap: 4px; }
  .ex-tag { flex: none; }
  .ex-skill { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .ex-q { margin: 6px 0 8px; font-size: 22px; }
  .ex-card.young .ex-q { font-size: 26px; }
  .ex-viz { gap: 10px; margin: 2px 0 4px; }
  .ex-viz .viz { width: auto; max-height: min(150px, calc(100vh - 220px)); }
  .ans-line { gap: 8px; font-size: 28px; }
  .field { min-width: 96px; height: 56px; font-size: 30px; }
  .field.blank { min-width: 60px; height: 50px; font-size: 26px; }
  .frac-in .field { min-width: 70px; height: 48px; font-size: 26px; }
  .frac-bar { width: 84px; }
  .keypad-wrap { gap: 6px; }
  .keypad { grid-template-columns: repeat(3, 58px); gap: 6px; }
  .keypad-extra { gap: 6px; }
  .key { min-width: 58px; height: 48px; font-size: 24px; }
  .key-ok { min-height: 46px; padding: 8px 16px; }
  .choices { gap: 10px; }
  .choices.layout-row, .choices.layout-grid { grid-template-columns: 1fr; }
  .opt { min-height: 52px; padding: 10px 14px; border-radius: 16px; font-size: 21px; }
  .choices.layout-col .opt { font-size: 17px; }
  .opt .viz { max-height: 110px; }
  .opt .items { --sz: 24px !important; gap: 4px; padding: 6px; }
  .feedback { gap: 8px; padding: 12px 16px; }
  .fb-ans { font-size: 20px; }
  .fb-exp { font-size: 17px; }
  .seq-it { min-width: 44px; min-height: 44px; font-size: 22px; }
  .dtable { font-size: 16px; }
  .dtable th, .dtable td { padding: 4px 8px; }
  /* results */
  .results { padding: 12px; }
  .res-card { gap: 6px; padding: 14px 24px 16px; }
  .res-card h1 { font-size: 28px; }
  .res-bot svg { width: 76px; height: 76px; }
  .stars { font-size: 38px; }
  .res-stats { margin: 2px 0; }
  .res-stats > div { padding: 8px 6px; }
  .res-stats b { font-size: 22px; }
  .res-btns { margin-top: 4px; }
}
