/* ==========================================================================
   Art direction — warm, colourful, still school-presentable (8–15 year olds).
   Ink green anchor on cool white; one colour per subject; rounded tiles, soft shadows.
   Display: Nunito · Text/UI: Nunito Sans · Arabic: IBM Plex Sans Arabic.
   ========================================================================== */
:root {
  --ink: #0F3A33;        /* anchor — headings, primary buttons */
  --slate: #1E2F36;      /* body text */
  --paper: #F5F9FB;      /* cool white background */
  --card: #FFFFFF;
  --rule: #DCE6E8;
  --rule-strong: #B9C9CC;
  --muted: #50636A;
  --coral: #E4664A; --saffron: #F2A93B; --teal: #1F8A7E; --sky: #3C7FC1; --leaf: #6BAA4B; --plum: #7B5AA6;
  --coral-d: #B8442B;    /* coral for text (AA on white) */
  --teal-d: #17736A; --sky-d: #2E6AA6;   /* AA (≥4.5:1) with white text */
  --ink-tint: #E4F1EE;
  --brick: var(--coral-d);
  --sc: var(--teal);     /* current subject colour (set inline per subject) */
  --display: 'Nunito', 'Nunito Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --sans: 'Nunito Sans', 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --serif: var(--display);
  --arabic: 'IBM Plex Sans Arabic', 'Noto Sans Arabic', 'Geeza Pro', Tahoma, sans-serif;
  --r: 12px; --r-lg: 16px; --r-sm: 10px;
  --sh: 0 1px 2px rgba(15,58,51,.06), 0 4px 14px rgba(15,58,51,.06);
  --sh-up: 0 2px 4px rgba(15,58,51,.07), 0 10px 24px rgba(15,58,51,.10);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--slate); font: 400 16px/1.6 var(--sans); }
[lang="ar"], [lang="ar"] * { font-family: var(--arabic); }
a { color: var(--ink); text-underline-offset: 3px; text-decoration-thickness: 1.5px; text-decoration-color: rgba(31,138,126,.5); }
a:hover { color: var(--teal); }
h1, h2, h3 { font-family: var(--display); font-weight: 800; color: var(--ink); letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 4.2vw, 3.2rem); line-height: 1.1; margin: .2em 0 .45em; }
h2 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 .8em; }
h3 { font-size: 1.15rem; margin: 0 0 .4em; font-weight: 700; }
h4, .h4 { font: 800 .74rem/1.3 var(--display); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 0 0 .8em; }
[lang="ar"] h4, [lang="ar"] .h4 { letter-spacing: 0; }
p { margin: 0 0 1em; }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 32px; }
.narrow { max-width: 760px; }
.small { font-size: .86rem; }
.muted { color: var(--muted); }
.kicker { font: 800 .78rem/1.4 var(--display); text-transform: uppercase; letter-spacing: .12em; color: var(--teal-d); margin: 0; }
.lede { font-size: 1.16rem; line-height: 1.55; max-width: 40em; color: var(--slate); }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; background: var(--card); padding: 6px 10px; z-index: 9; border-radius: 8px; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; border-radius: 6px; }
.chip { display: inline-block; width: 12px; height: 12px; border-radius: 4px; background: var(--sc); margin-inline-end: 8px; vertical-align: -1px; flex: none; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: .5em; font: 800 .95rem/1 var(--display); padding: .8em 1.25em; border: 2px solid var(--ink); background: var(--ink); color: #fff; border-radius: 999px; cursor: pointer; text-decoration: none; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
.btn:hover { background: #0A2B26; color: #fff; transform: translateY(-2px); box-shadow: var(--sh-up); }
.btn:active { transform: translateY(0); }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--rule-strong); }
.btn-ghost:hover { background: var(--ink-tint); color: var(--ink); border-color: var(--teal); }
.btn-sm { padding: .55em .95em; font-size: .85rem; }
.btn-warm { background: var(--coral); border-color: var(--coral); } .btn-warm:hover { background: var(--coral-d); border-color: var(--coral-d); }
.btn-inv { background: #fff; color: var(--ink); border-color: #fff; } .btn-inv:hover { background: #FFF1CF; color: var(--ink); }
.btn-inv-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.6); } .btn-inv-ghost:hover { background: rgba(255,255,255,.1); color: #fff; }
.lnk { background: none; border: 0; padding: 0; font: inherit; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px; text-decoration-color: rgba(31,138,126,.5); cursor: pointer; }
.lnk:hover { color: var(--teal); }

/* Header */
.hdr { background: rgba(255,255,255,.96); border-bottom: 1px solid var(--rule); position: sticky; top: 0; z-index: 5; backdrop-filter: blur(6px); }
.hdr::after { content: ''; display: block; height: 3px; background: linear-gradient(90deg, var(--coral) 0 16.6%, var(--saffron) 0 33.3%, var(--leaf) 0 50%, var(--teal) 0 66.6%, var(--sky) 0 83.3%, var(--plum) 0); opacity: .9; }
.hdr-in { display: flex; align-items: center; gap: 26px; height: 64px; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); }
.brand-name { font: 800 1.45rem/1 var(--display); letter-spacing: -.01em; color: var(--ink); }
.nav { display: flex; gap: 4px; }
.nav a { text-decoration: none; color: var(--slate); font: 700 .93rem/1 var(--display); padding: 9px 13px; border-radius: 999px; transition: background .15s; }
.nav a:hover { background: var(--ink-tint); color: var(--ink); }
.nav a.active { background: var(--ink); color: #fff; }
.hdr-right { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: .86rem; }
.hdr-av { display: inline-flex; border-radius: 50%; transition: transform .15s; } .hdr-av:hover { transform: translateY(-2px) rotate(-4deg); }
.hdr-av svg { display: block; }
.who { color: var(--muted); }
.langsw { display: inline-flex; border: 1.5px solid var(--rule-strong); border-radius: 999px; overflow: hidden; }
.langsw button { background: none; border: 0; font: 800 .78rem/1 var(--display); letter-spacing: .06em; padding: 7px 11px; cursor: pointer; color: var(--muted); }
.langsw button[aria-pressed="true"] { background: var(--teal-d); color: #fff; }
.menu-btn { display: none; }

/* Hero */
.hero { display: grid; grid-template-columns: 1.25fr 1fr; gap: 56px; align-items: center; padding-top: 64px; padding-bottom: 40px; }
.ctas { display: flex; gap: 12px; margin: 1.6em 0 1em; flex-wrap: wrap; }
.hero-fig { margin: 0; }
.hero-art { position: relative; background: var(--card); border-radius: var(--r-lg); box-shadow: var(--sh); padding: 26px 26px 44px; }
.hero-fig svg { width: 100%; height: auto; display: block; }
.hero-avs { position: absolute; inset-inline-end: 18px; bottom: -26px; display: flex; }
.hero-avs svg { width: 64px; height: 64px; margin-inline-start: -12px; filter: drop-shadow(0 4px 8px rgba(15,58,51,.18)); animation: bob 3.2s ease-in-out infinite; }
.hero-avs svg:nth-child(2) { animation-delay: .5s; } .hero-avs svg:nth-child(3) { animation-delay: 1s; }
.hero-fig figcaption { font-size: .86rem; color: var(--muted); margin-top: 38px; }
.ht { animation: fillin .5s cubic-bezier(.3,1.4,.6,1) both; animation-delay: var(--d); transform-box: fill-box; transform-origin: center; }
.ht-now { animation: pulse 1.6s ease-in-out infinite; }
@keyframes fillin { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: scale(1); } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes bob { 50% { transform: translateY(-5px); } }

/* Sections */
.sec { padding-top: 56px; padding-bottom: 32px; }
.sec-h { display: flex; align-items: baseline; gap: 14px; padding-top: 6px; }
.sec-h span { font: 800 .8rem/1 var(--display); color: #fff; background: var(--teal-d); border-radius: 8px; padding: 6px 8px; letter-spacing: .04em; }
.cols3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.col { background: var(--card); border-radius: var(--r); box-shadow: var(--sh); padding: 22px; border-top: 5px solid var(--sc); transition: transform .15s, box-shadow .15s; }
.col:nth-child(1) { --sc: var(--coral); } .col:nth-child(2) { --sc: var(--saffron); } .col:nth-child(3) { --sc: var(--sky); }
.col:hover { transform: translateY(-2px); box-shadow: var(--sh-up); }
.col p { color: var(--slate); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; }
.ruled { list-style: none; padding: 0; margin: 0; }
.ruled li { border-bottom: 1px solid var(--rule); padding: 10px 0; }
ol.ruled { counter-reset: w; } ol.ruled li { counter-increment: w; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card); border-radius: var(--r); box-shadow: var(--sh); overflow: hidden; font-size: .93rem; }
.tbl th, .tbl td { text-align: start; padding: 11px 14px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl thead th { font: 800 .72rem/1.2 var(--display); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); background: #F0F6F7; }
.mono-t { font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap; }

/* Strategy badges — one colour each */
.badge-sm { --bc: var(--teal-d); display: inline-block; font: 800 .66rem/1 var(--display); letter-spacing: .06em; padding: 6px 9px; border-radius: 999px; color: #fff; background: var(--bc); direction: ltr; }
[data-s="EXAMPLE"], [data-strategy="EXAMPLE"] { --bc: var(--sky-d); }
[data-s="SOCRATIC"], [data-strategy="SOCRATIC"] { --bc: var(--teal-d); }
[data-s="STRETCH"], [data-strategy="STRETCH"] { --bc: var(--plum); }
[data-s="REVIEW"], [data-strategy="REVIEW"] { --bc: #94590F; }
[data-s="WORKED"], [data-strategy="WORKED"] { --bc: #3F7527; }
[data-s="REFUSE_ANSWER"], [data-strategy="REFUSE_ANSWER"] { --bc: var(--coral-d); }

.lang-demo { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.lang-demo span { border-radius: 999px; padding: 8px 16px; font: 700 .9rem/1 var(--display); background: var(--card); box-shadow: var(--sh); }
.lang-demo span:nth-child(1) { color: var(--sky-d); } .lang-demo span:nth-child(2) { color: var(--plum); } .lang-demo span:nth-child(3) { color: var(--teal-d); }
.cur { display: grid; grid-template-columns: 2fr 1fr; gap: 28px; margin-top: 24px; }
.cur ul { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cur-local ul { grid-template-columns: 1fr; }
.cur li { background: var(--card); border-radius: var(--r); box-shadow: var(--sh); padding: 14px 16px 6px; border-inline-start: 6px solid var(--sc); transition: transform .15s, box-shadow .15s; }
.cur li:hover { transform: translateY(-2px); box-shadow: var(--sh-up); }
.cur-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.cur-h strong { font: 800 1.05rem/1.2 var(--display); color: var(--ink); display: flex; align-items: center; }
.cur-h span { font-size: .78rem; color: var(--muted); white-space: nowrap; }
.cur li p { font-size: .88rem; color: var(--muted); margin: 4px 0 8px; }
.prs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.pr { padding: 22px; background: var(--card); border-radius: var(--r); box-shadow: var(--sh); }
.pr .pr-n { font: 800 .9rem/1 var(--display); color: #fff; display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; margin-bottom: 12px; background: var(--sc); }
.pr:nth-child(1) { --sc: var(--coral-d); } .pr:nth-child(2) { --sc: var(--saffron); } .pr:nth-child(2) .pr-n { color: var(--ink); } .pr:nth-child(3) { --sc: var(--teal-d); } .pr:nth-child(4) { --sc: var(--sky-d); }
.pr p { font-size: .9rem; margin: 0; }

/* Footer */
.ftr { border-top: 1px solid var(--rule); margin-top: 72px; background: var(--card); }
.ftr-in { padding-top: 28px; padding-bottom: 28px; display: grid; grid-template-columns: 1fr auto; gap: 8px 24px; font-size: .86rem; }
.ftr-brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 600; }
.ftr-links { display: flex; gap: 20px; flex-wrap: wrap; color: var(--muted); }
.ftr-proto { grid-column: 1 / -1; color: var(--muted); margin: 6px 0 0; font-size: .8rem; }

/* Auth */
.auth { display: grid; grid-template-columns: 1.1fr .9fr; gap: 48px; padding-top: 48px; align-items: start; }
.auth-card { background: var(--card); border-radius: var(--r-lg); box-shadow: var(--sh); padding: 32px; }
.auth-card.wide { max-width: 860px; }
.auth-card h1 { font-size: 2rem; }
label { display: block; font-size: .88rem; font-weight: 700; color: var(--slate); margin-bottom: 16px; }
input, select { display: block; width: 100%; margin-top: 6px; font: 400 1rem/1.3 var(--sans); padding: 10px 13px; border: 1.5px solid var(--rule-strong); border-radius: var(--r-sm); background: #fff; color: var(--slate); }
input:focus, select:focus { border-color: var(--teal); outline: 3px solid rgba(31,138,126,.18); }
fieldset { border: 0; padding: 0; margin: 4px 0 14px; min-width: 0; }
legend { font-size: .88rem; font-weight: 700; margin-bottom: 8px; padding: 0; }
.radios { display: flex; gap: 8px; flex-wrap: wrap; }
.radio { margin: 0; } .radio input { position: absolute; opacity: 0; width: 1px; }
.radio span { display: inline-block; padding: 8px 16px; border: 1.5px solid var(--rule-strong); border-radius: 999px; cursor: pointer; font-weight: 700; }
.radio input:checked + span { background: var(--teal); color: #fff; border-color: var(--teal); }
.radio input:focus-visible + span { outline: 3px solid var(--sky); outline-offset: 2px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; background: #F0F6F7; border-radius: var(--r-sm); padding: 12px 14px; }
.check input { width: auto; margin-top: 4px; accent-color: var(--teal); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.err { color: var(--coral-d); min-height: 1.2em; font-size: .9rem; font-weight: 600; }
.demo-box { border-top: 1px solid var(--rule); margin-top: 22px; padding-top: 18px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.auth-side { padding-top: 24px; }
.auth-side h2 { margin-top: 18px; }
.row { display: flex; gap: 12px; }
.flash { border-radius: var(--r-sm); background: #E5F2DC; color: #2C5418; padding: 10px 14px; font-weight: 600; }
.signup { padding-top: 30px; }
.signup h1 { font-size: 2.3rem; margin-bottom: .2em; }
.signup .lede { margin-bottom: 16px; }
.signup-grid { display: grid; grid-template-columns: 1fr 1.05fr; gap: 24px; align-items: start; }
.signup-grid > .auth-card { padding: 26px; }
.av-card { position: sticky; top: 84px; }
.set-av { margin-bottom: 26px; padding-bottom: 22px; border-bottom: 1px solid var(--rule); }

/* Avatar builder */
.av-head { display: flex; gap: 18px; align-items: center; margin-bottom: 10px; }
.av-head h3 { margin: 0 0 2px; font-size: 1.25rem; }
.av-head p { margin: 0 0 10px; }
.av-preview { flex: none; width: 132px; height: 132px; border-radius: 24px; background: #F0F6F7; display: grid; place-items: center; }
.av-preview svg { display: block; }
.av-preview.pop svg { animation: pop .35s cubic-bezier(.3,1.6,.6,1); }
@keyframes pop { 0% { transform: scale(.85); } 100% { transform: scale(1); } }
.av-group { margin: 0 0 8px; }
.av-group legend { font: 800 .72rem/1 var(--display); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 6px; }
[lang="ar"] .av-group legend { letter-spacing: 0; font-size: .8rem; }
.av-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.av-opt { margin: 0; position: relative; cursor: pointer; display: flex; flex-direction: column; align-items: center; width: 56px; font-weight: 600; }
.av-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.av-thumb { width: 50px; height: 50px; border-radius: 12px; display: grid; place-items: center; background: #F5F9FB; border: 2px solid transparent; transition: transform .12s, border-color .12s; }
.av-thumb svg { width: 44px; height: 44px; display: block; }
.av-opt:hover .av-thumb { transform: translateY(-2px); }
.av-opt input:checked + .av-thumb { border-color: var(--ink); background: #fff; box-shadow: var(--sh); }
.av-opt input:focus-visible + .av-thumb { outline: 3px solid var(--sky); outline-offset: 2px; }
.av-name { font-size: .64rem; line-height: 1.15; color: var(--muted); text-align: center; margin-top: 3px; min-height: 1.2em; }
.av-group[data-g="c"] .av-name, .av-group[data-g="b"] .av-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.av-group[data-g="c"] .av-opt, .av-group[data-g="b"] .av-opt { width: 40px; }
.av-group[data-g="c"] .av-thumb, .av-group[data-g="b"] .av-thumb { width: 38px; height: 38px; border-radius: 50%; }
.sw { width: 28px; height: 28px; border-radius: 50%; display: block; box-shadow: inset 0 0 0 1px rgba(15,58,51,.12); }

/* Session */
.sess { display: grid; grid-template-columns: 300px 1fr; gap: 28px; padding-top: 32px; align-items: start; }
.sess-side .lbl { font: 800 .74rem/1.3 var(--display); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 6px; }
.sess-side label.lbl select { text-transform: none; letter-spacing: 0; font-family: var(--sans); font-weight: 600; }
.notions { list-style: none; padding: 0; margin: 0 0 20px; display: flex; flex-direction: column; gap: 6px; }
.notion { width: 100%; text-align: start; background: var(--card); border: 0; border-radius: var(--r-sm); box-shadow: 0 1px 2px rgba(15,58,51,.06); padding: 10px 12px 11px; cursor: pointer; font: 600 .9rem/1.3 var(--sans); color: var(--slate); border-inline-start: 5px solid var(--sc); transition: transform .15s, box-shadow .15s; }
.notion:hover { transform: translateY(-2px); box-shadow: var(--sh-up); }
.notion.sel { box-shadow: 0 0 0 2px var(--sc), var(--sh); }
.notion .nl { display: block; margin-bottom: 7px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; background: var(--saffron); vertical-align: middle; margin-inline-start: 4px; }
.bar { position: relative; height: 9px; background: #E8EFF0; border-radius: 99px; overflow: visible; }
.bar span { position: absolute; inset: 0 auto 0 0; background: var(--sc); border-radius: 99px; transition: width .5s ease; }
[dir="rtl"] .bar span { inset: 0 0 0 auto; }
.bar i { position: absolute; top: -3px; bottom: -3px; width: 2px; border-radius: 2px; background: var(--rule-strong); }
.bar.thin { height: 6px; } .bar.thin i { display: none; }
.memcard { background: var(--card); border-radius: var(--r); box-shadow: var(--sh); padding: 16px; margin-bottom: 20px; border-top: 5px solid var(--sc); }
.mem-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.mem-row strong { font: 800 1.5rem/1 var(--display); color: var(--ink); }
.memcard dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 14px 0 0; font-size: .86rem; }
.memcard dt { color: var(--muted); } .memcard dd { margin: 0; text-align: end; }
.stg { display: inline-block; min-width: 24px; text-align: center; border-radius: 6px; background: #EEF3F4; font-size: .75rem; margin-inline-start: 3px; padding: 1px 4px; font-weight: 700; }
.stg.on { background: var(--sc); color: #fff; }
.due { color: #9A5A0C; font-weight: 700; }
.legend ul { list-style: none; padding: 0; margin: 0; font-size: .82rem; }
.legend li { display: flex; gap: 8px; align-items: center; padding: 4px 0; color: var(--muted); }
.legend .badge-sm { min-width: 108px; text-align: center; }

.panel { position: relative; background: var(--card); border-radius: var(--r-lg); box-shadow: var(--sh); display: flex; flex-direction: column; min-height: 560px; border-top: 6px solid var(--sc); overflow: hidden; }
.panel.empty { align-items: center; justify-content: center; border-top-color: var(--rule); }
.empty-in { max-width: 380px; text-align: center; color: var(--muted); } .empty-in .mono { margin-bottom: 14px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--rule); flex-wrap: wrap; background: linear-gradient(180deg, color-mix(in srgb, var(--sc) 9%, #fff), #fff); }
.ph-n { display: flex; align-items: center; }
.ph-n .chip { width: 16px; height: 16px; border-radius: 5px; }
.ph-y { font: 800 1.25rem/1.2 var(--display); color: var(--ink); }
.ph-meta { display: flex; gap: 14px; align-items: stretch; }
.badge { display: flex; flex-direction: column; justify-content: center; border-radius: var(--r); padding: 7px 14px; min-width: 150px; background: var(--bc, var(--teal-d)); color: #fff; transition: background .25s; }
.badge .b-l, .clock span { font-size: .66rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 700; }
.badge .b-l { color: rgba(255,255,255,.85); }
.badge .b-c { font: 800 .92rem/1.2 var(--display); letter-spacing: .05em; color: #fff; direction: ltr; text-align: start; }
.badge .b-n { font-size: .78rem; color: rgba(255,255,255,.92); }
.clock { display: flex; flex-direction: column; justify-content: center; background: #F0F6F7; border-radius: var(--r); padding: 6px 14px; }
.clock strong { font: 800 1.15rem/1.2 var(--display); font-variant-numeric: tabular-nums; color: var(--ink); }
.log { flex: 1; overflow-y: auto; padding: 20px; max-height: 560px; min-height: 380px; }
.start-box { height: 100%; min-height: 320px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.msg { margin-bottom: 16px; max-width: 86%; animation: msgin .25s ease both; }
@keyframes msgin { from { opacity: 0; transform: translateY(6px); } }
.msg .who { display: flex; gap: 8px; align-items: center; font-size: .74rem; color: var(--muted); margin-bottom: 5px; font-weight: 700; }
.msg .who svg { flex: none; }
.msg.agent .body { background: #F5F9FB; border-radius: 4px var(--r-lg) var(--r-lg) var(--r-lg); border-inline-start: 4px solid var(--bc, var(--teal)); padding: 10px 16px; }
[dir="rtl"] .msg.agent .body { border-radius: var(--r-lg) 4px var(--r-lg) var(--r-lg); }
.msg.pupil { margin-inline-start: auto; width: fit-content; max-width: 70%; min-width: 120px; }
.msg.pupil .who { justify-content: flex-end; }
.msg.pupil .body { background: color-mix(in srgb, var(--sc) 14%, #fff); border-radius: var(--r-lg) 4px var(--r-lg) var(--r-lg); padding: 9px 16px; font-weight: 600; color: var(--ink); }
[dir="rtl"] .msg.pupil .body { border-radius: 4px var(--r-lg) var(--r-lg) var(--r-lg); }
.msg .body p { margin: 0 0 .5em; } .msg .body p:last-child { margin-bottom: 0; }
.m-title { font: 800 1.02rem/1.3 var(--display); color: var(--ink); }
.m-q { font-weight: 700; color: var(--slate); }
.m-label { display: inline-block; font: 800 .68rem/1 var(--display); text-transform: uppercase; letter-spacing: .08em; color: #fff; background: var(--bc, var(--teal-d)); border-radius: 6px; padding: 4px 7px; margin-inline-end: 8px; vertical-align: 1px; }
[lang="ar"] .m-label { letter-spacing: 0; font-size: .78rem; }
.m-math { background: #fff; border: 1.5px solid var(--rule); border-radius: var(--r-sm); padding: 10px 14px; margin: 6px 0 10px; font: 600 .98rem/1.7 var(--sans); font-variant-numeric: tabular-nums; color: var(--ink); text-align: left; }
.m-hint { border: 2px dashed #F2C77E; border-radius: var(--r-sm); padding: 10px 14px; margin: 4px 0 8px; background: #FFF8EA; }
.m-note { font-size: .86rem; color: var(--muted); }
.composer { display: flex; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--rule); background: #FBFDFD; }
.composer input { margin: 0; flex: 1; border-radius: 999px; padding-inline: 18px; }
.panel-foot { display: flex; justify-content: space-between; align-items: center; padding: 8px 20px 14px; font-size: .86rem; background: #FBFDFD; }
.panel-info { margin-top: 10px; }

/* Celebration — small burst of coloured squares */
.confetti { position: absolute; left: 50%; bottom: 96px; width: 0; height: 0; pointer-events: none; z-index: 3; }
.confetti i { position: absolute; width: 10px; height: 10px; border-radius: 3px; opacity: 0; animation: burst 1s cubic-bezier(.15,.7,.4,1) forwards; }
.confetti.big i { width: 13px; height: 13px; animation-duration: 1.25s; }
@keyframes burst { 0% { opacity: 1; transform: translate(0,0) rotate(0) scale(.6); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--x), var(--y)) rotate(var(--r)) scale(1); } }

/* Mastery */
.banner { display: inline-block; border-radius: 999px; background: #FFF1CF; color: #7A4A08; padding: 6px 14px; font-size: .8rem; letter-spacing: .04em; text-transform: uppercase; font-weight: 800; }
.family { display: flex; gap: 10px; margin: 14px 0 6px; flex-wrap: wrap; }
.kid { display: flex; align-items: center; gap: 10px; background: var(--card); border: 2px solid transparent; border-radius: 999px; padding: 5px 18px 5px 6px; box-shadow: var(--sh); cursor: pointer; font: inherit; color: var(--slate); text-align: start; transition: transform .15s; }
.kid:hover { transform: translateY(-2px); }
.kid.sel { border-color: var(--teal); }
.kid span { display: flex; flex-direction: column; line-height: 1.2; } .kid small { color: var(--muted); }
.mast-head { display: flex; align-items: center; gap: 20px; margin-top: 10px; }
.mast-head > svg { flex: none; filter: drop-shadow(0 4px 10px rgba(15,58,51,.15)); }
.mast-head h1 { margin-bottom: .2em; }
.stats { display: grid; grid-template-columns: 1.4fr repeat(4, 1fr); gap: 12px; margin: 14px 0 10px; }
.stat { padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; background: var(--card); border-radius: var(--r); box-shadow: var(--sh); border-top: 5px solid var(--sc); }
.stat:nth-child(2) { --sc: var(--sky); } .stat:nth-child(3) { --sc: var(--leaf); } .stat:nth-child(4) { --sc: var(--saffron); } .stat:nth-child(5) { --sc: var(--coral); }
.stat strong { font: 800 1.8rem/1 var(--display); color: var(--ink); }
.stat span { font-size: .8rem; color: var(--muted); }
.stat.key { background: var(--ink); border-top-color: var(--leaf); } .stat.key strong, .stat.key span { color: #fff; }
.mast-tbl { margin-top: 18px; }
.mast-tbl tr.grp th { background: color-mix(in srgb, var(--sc) 10%, #fff); font: 800 1rem/1.2 var(--display); color: var(--ink); text-transform: none; letter-spacing: 0; padding-top: 14px; }
.mast-tbl .c-bar { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.mast-tbl .c-bar .bar { flex: 1; }
.pct { font-variant-numeric: tabular-nums; min-width: 3em; text-align: end; font-weight: 700; }
.num { text-align: end !important; font-variant-numeric: tabular-nums; }
.st { display: inline-block; margin-inline-start: 10px; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.st-acq { color: #fff; background: #4E8A31; border-radius: 999px; padding: 2px 8px; }
.oversight { margin-top: 32px; border-top: 1px solid var(--rule); padding-top: 24px; }

/* Pricing */
.sim { border-radius: var(--r-sm); background: #FFF1CF; color: #6B4006; padding: 10px 14px; font-size: .9rem; font-weight: 600; }
.balance { font-weight: 700; }
.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 20px; }
.plan { --sc: var(--teal); padding: 24px; background: var(--card); border-radius: var(--r-lg); box-shadow: var(--sh); display: flex; flex-direction: column; gap: 4px; border-top: 6px solid var(--sc); transition: transform .15s, box-shadow .15s; }
.plan:hover { transform: translateY(-3px); box-shadow: var(--sh-up); }
.plan:nth-child(1) { --sc: var(--leaf); } .plan:nth-child(2) { --sc: var(--sky); } .plan:nth-child(3) { --sc: var(--coral); }
.plan:nth-child(4) { --sc: var(--saffron); } .plan:nth-child(5) { --sc: var(--plum); } .plan:nth-child(6) { --sc: var(--ink); }
.plan h3 { font-size: 1.3rem; }
.plan .price { font: 800 2rem/1.1 var(--display); color: var(--ink); margin: 6px 0 0; }
.plan .hours { font-weight: 700; margin: 0 0 4px; color: var(--ink); }
.plan .btn { margin-top: auto; align-self: flex-start; }
.plan .small { min-height: 2.6em; }
.plan-mid { box-shadow: 0 0 0 2px var(--coral), var(--sh-up); }
.plan-school { background: var(--ink-tint); }

/* Cranleigh — sober, print-safe, light accents */
.cr h1, .cr h2 { font-weight: 800; }
.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 28px 0 8px; }
.fact { padding: 16px 18px; display: flex; align-items: baseline; gap: 12px; background: var(--card); border-radius: var(--r); border: 1px solid var(--rule); border-top: 4px solid var(--sc); }
.fact:nth-child(1) { --sc: var(--coral); } .fact:nth-child(2) { --sc: var(--sky); } .fact:nth-child(3) { --sc: var(--teal); } .fact:nth-child(4) { --sc: var(--saffron); }
.fact strong { font: 800 2.4rem/1 var(--display); color: var(--ink); }
.fact span { font-size: .9rem; color: var(--muted); }
.cr .col { box-shadow: none; border: 1px solid var(--rule); border-top: 4px solid var(--sc); }
.cr .col:hover { transform: none; box-shadow: none; }
.cr .split, .cr .cols3 { margin-top: 40px; }
.weeks li { font-size: .95rem; }
.cta-block { background: var(--ink); color: #fff; padding: 36px 40px; display: flex; justify-content: space-between; gap: 32px; align-items: center; margin-top: 48px; border-radius: var(--r-lg); position: relative; overflow: hidden; }
.cta-block::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 5px; background: linear-gradient(90deg, var(--coral) 0 25%, var(--saffron) 0 50%, var(--teal) 0 75%, var(--sky) 0); }
.cta-block h2 { color: #fff; margin-bottom: .4em; }
.cta-block p { color: #D9E4E1; margin-bottom: .4em; }
.cta-btns { display: flex; flex-direction: column; gap: 10px; min-width: 220px; }

/* Responsive */
@media (max-width: 960px) {
  .wrap { padding: 0 18px; }
  .hero, .split, .auth, .sess, .cur, .signup-grid { grid-template-columns: 1fr; gap: 26px; }
  .av-card { position: static; }
  .hero { padding-top: 32px; }
  .cols3, .prs { grid-template-columns: 1fr; gap: 12px; }
  .cur ul { grid-template-columns: 1fr; }
  .plans { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .facts { grid-template-columns: 1fr 1fr; }
  .cta-block { flex-direction: column; align-items: flex-start; padding: 28px; }
  .who { display: none; }
  .grid2 { grid-template-columns: 1fr; }
  .tbl { font-size: .84rem; } .tbl th, .tbl td { padding: 8px; }
  .strat-tbl td:nth-child(2) { white-space: normal; }
  .mast-tbl { display: block; overflow-x: auto; }
  .ph-meta { flex-wrap: wrap; }
  .msg { max-width: 100%; }
  .hero-art { padding: 18px 18px 40px; }
  .mast-head > svg { width: 60px; height: 60px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .ht { opacity: 1; transform: none; }
  .btn:hover, .col:hover, .cur li:hover, .notion:hover, .plan:hover, .kid:hover, .hdr-av:hover, .av-opt:hover .av-thumb { transform: none; }
}
@media print {
  .hdr, .ftr, .composer, .panel-foot, .hero-avs { display: none; }
  body { background: #fff; }
  .col, .cur li, .plan, .stat, .tbl, .panel { box-shadow: none; border: 1px solid var(--rule); }
}

/* ---------------- Session modes + "My homework" ----------------------------- */
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mode-tabs { display: flex; background: #E8EFF0; border-radius: 999px; padding: 4px; margin-bottom: 18px; gap: 4px; }
.mode-tabs button { flex: 1; border: 0; background: none; border-radius: 999px; padding: 9px 10px; font: 800 .86rem/1.1 var(--display); color: var(--muted); cursor: pointer; }
.mode-tabs button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: var(--sh); }
.mode-tabs button[data-mode="homework"][aria-pressed="true"] { color: var(--coral-d); }
.sess.hw-mode { max-width: 1440px; grid-template-columns: 250px 1fr; }
.hw-side { margin: 0 0 18px; }
.hw-tag { display: inline-block; margin-inline-start: 10px; font: 800 .68rem/1 var(--display); text-transform: uppercase; letter-spacing: .06em; color: var(--coral-d); background: #FDE5DE; border-radius: 999px; padding: 5px 9px; }
[lang="ar"] .hw-tag { letter-spacing: 0; font-size: .78rem; }
.hw-work { display: grid; grid-template-columns: minmax(0, 1.02fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.hw-up { max-width: 860px; }
.hw-upload, .hw-viewer, .hw-read { background: var(--card); border-radius: var(--r-lg); box-shadow: var(--sh); padding: 22px; }
.hw-upload h2 { margin-bottom: .3em; }
.hw-lede { color: var(--slate); max-width: 46em; }
.hw-drop { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; border: 2.5px dashed #B9D6D1; border-radius: var(--r-lg); background: #F3FAF8; padding: 30px 20px; cursor: pointer; transition: background .15s, border-color .15s; }
.hw-drop:hover, .hw-drop.over { background: #E4F4F0; border-color: var(--teal); }
.hw-drop strong { font: 800 1.15rem/1.2 var(--display); color: var(--ink); }
.hw-drop-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.hw-cam { display: none; }
@media (pointer: coarse) { .hw-cam { display: inline-flex; } }
.hw-sample-row { margin: 14px 0 6px; }
.hw-privacy { display: flex; gap: 10px; align-items: flex-start; background: #F1F8EC; color: #2C5418; border-radius: var(--r-sm); padding: 10px 12px; margin: 12px 0 0; }
.hw-privacy svg { flex: none; margin-top: 1px; }
.hw-api { background: #FFF1CF; color: #6B4006; border-radius: var(--r-sm); padding: 9px 12px; margin: 10px 0 0; font-weight: 600; }
.hw-local { color: var(--muted); margin: 10px 0 0; }
.hw-notice { background: #E0ECF8; color: #1D4C7A; border-radius: var(--r-sm); padding: 9px 12px; margin: 12px 0 0; font-weight: 600; }
.hw-viewer { padding: 14px; }
.hw-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.hw-tools .sp { flex: 1; }
.ib { width: 34px; height: 34px; display: inline-grid; place-items: center; border: 1.5px solid var(--rule-strong); background: #fff; border-radius: 10px; cursor: pointer; font: 800 1.05rem/1 var(--display); color: var(--ink); }
.ib:hover { border-color: var(--teal); background: var(--ink-tint); } .ib[disabled] { opacity: .4; cursor: default; }
.hw-zoom { min-width: 3.4em; text-align: center; font: 700 .82rem var(--sans); color: var(--muted); }
.hw-pages { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--muted); margin-inline-start: 6px; }
.tb { display: inline-flex; align-items: center; gap: 6px; border: 1.5px solid var(--rule-strong); background: #fff; border-radius: 999px; padding: 7px 12px; font: 800 .8rem/1 var(--display); color: var(--ink); cursor: pointer; }
.tb:hover { border-color: var(--teal); }
.tb[aria-pressed="true"] { background: var(--coral); border-color: var(--coral); color: #fff; }
.hw-stage { position: relative; height: 470px; overflow: auto; background: #E9EFF1; border-radius: var(--r); }
.hw-canvas { position: relative; margin: 0 auto; min-width: 100%; user-select: none; }
.hw-canvas img { display: block; width: 100%; height: auto; }
.hw-canvas[data-selecting="1"] { cursor: crosshair; touch-action: none; }
.hw-sel { position: absolute; border: 3px solid var(--coral); border-radius: 6px; box-shadow: 0 0 0 9999px rgba(15, 58, 51, .32); pointer-events: none; }
.hw-sel.drawing { border-style: dashed; }
.hw-help { color: var(--muted); margin: 8px 2px 10px; }
.hw-docs { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hw-docs-l { font: 800 .7rem/1 var(--display); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-inline-end: 2px; }
[lang="ar"] .hw-docs-l { letter-spacing: 0; font-size: .8rem; }
.hw-doc { display: inline-flex; align-items: center; gap: 7px; border: 1.5px solid var(--rule); background: #fff; border-radius: 999px; padding: 4px 12px 4px 4px; font: 700 .8rem/1 var(--sans); color: var(--slate); cursor: pointer; }
[dir="rtl"] .hw-doc { padding: 4px 4px 4px 12px; }
.hw-doc img { width: 26px; height: 26px; object-fit: cover; border-radius: 50%; border: 1px solid var(--rule); }
.hw-doc.sel { border-color: var(--teal); box-shadow: 0 0 0 1px var(--teal); }
.hw-doc.add { padding: 9px 12px; color: var(--teal); border-style: dashed; }
.hw-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.hw-keep { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-weight: 700; font-size: .86rem; }
.hw-keep input { width: auto; margin: 0; accent-color: var(--teal); }
.hw-del { display: inline-flex; align-items: center; gap: 5px; color: var(--coral-d); text-decoration-color: rgba(184, 68, 43, .4); font-size: .86rem; font-weight: 700; }
.hw-kept { margin: 6px 0 0; }
.hw-read h3 { margin-bottom: 10px; }
.hw-read-top { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.hw-thumb { max-width: 46%; max-height: 120px; border-radius: 8px; border: 2px solid var(--coral); background: #fff; object-fit: contain; }
.hw-status { margin: 0; font-size: .88rem; font-weight: 600; color: var(--muted); }
.hw-status[data-state="running"] { color: var(--sky); }
.hw-status[data-state="ocr"], .hw-status[data-state="api"] { color: #2C5418; }
.hw-status[data-state="none"], .hw-status[data-state="fail"] { color: #9A5A0C; }
.hw-read textarea { display: block; width: 100%; margin: 6px 0 14px; font: 600 1.02rem/1.45 var(--sans); padding: 10px 13px; border: 1.5px solid var(--rule-strong); border-radius: var(--r-sm); resize: vertical; color: var(--ink); background: #FFFDF6; }
.hw-read textarea:focus { border-color: var(--teal); outline: 3px solid rgba(31,138,126,.18); }
.hw-read label { margin-bottom: 0; }
.hw-read select { margin-bottom: 4px; }
.hw-read .row { flex-wrap: wrap; margin-top: 4px; }
.hw-wait { text-align: center; color: var(--muted); padding: 40px 26px; }
.hw-wait svg { margin-bottom: 8px; }
.hw-right .panel { min-height: 600px; }
.hw-right .panel-head { padding: 12px 16px; }
.hw-right .badge { min-width: 128px; padding: 6px 12px; }
.hw-right .clock { padding: 5px 10px; }
.hw-right .log { padding: 16px; }
.m-chip { display: inline-flex; align-items: center; gap: 10px; background: #FDE5DE; border-radius: 10px; padding: 5px 12px 5px 5px; font-size: .82rem; font-weight: 700; color: var(--coral-d); margin: 2px 0 8px !important; }
[dir="rtl"] .m-chip { padding: 5px 5px 5px 12px; }
.m-chip img { height: 40px; max-width: 120px; object-fit: cover; border-radius: 6px; border: 2px solid var(--coral); background: #fff; }
.st-hw { color: var(--coral-d); background: #FDE5DE; border-radius: 999px; padding: 2px 8px; text-transform: none; letter-spacing: 0; }
@media (max-width: 1100px) { .hw-work { grid-template-columns: 1fr; } .hw-stage { height: 420px; } }
@media (max-width: 960px) { .sess.hw-mode { grid-template-columns: 1fr; } .hw-stage { height: 360px; } .hw-upload, .hw-viewer, .hw-read { padding: 14px; } .hw-drop { padding: 22px 14px; } }

.hw-mode .legend .badge-sm { min-width: 0; flex: none; padding: 6px 8px; }
.hw-mode .legend li { align-items: flex-start; }
.hw-mode .mode-tabs button { font-size: .84rem; }
.hw-right .log { max-height: 430px; min-height: 300px; }
.hw-right .panel { min-height: 560px; }
.hw-stage { height: 440px; }
@media (max-width: 1100px) { .hw-stage { height: 420px; } }
@media (max-width: 960px) { .hw-stage { height: 360px; } .hw-mode .legend, .hw-mode .memcard { display: none; } }
@media (max-width: 640px) { .ftr-in { grid-template-columns: 1fr; } .ftr-links { gap: 8px 16px; } }
.m-chip img { height: 38px; max-width: 170px; object-fit: contain; }
.hw-doc img { width: 46px; height: 26px; object-fit: contain; object-position: center; border-radius: 6px; background: #fff; }
.hw-right .composer .btn { padding-left: 15px; padding-right: 15px; }

/* ==========================================================================
   PWA + responsive shell: install button, bottom tab bar, toasts, iOS sheet,
   safe areas, 44 px touch targets.
   ========================================================================== */
.hdr { padding-top: env(safe-area-inset-top); }
.hdr-in, .ftr-in { padding-left: max(32px, env(safe-area-inset-left)); padding-right: max(32px, env(safe-area-inset-right)); }
.logout .ico { display: none; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.install-btn { display: inline-flex; align-items: center; gap: 6px; background: var(--ink-tint); color: var(--ink); border: 1.5px solid transparent; border-radius: 999px; padding: 7px 12px; font: 800 .8rem/1 var(--display); cursor: pointer; }
.install-btn:hover { border-color: var(--teal); }
.install-btn[hidden] { display: none; }
.tabbar { display: none; }
.hw-status[data-state="proxy"] { color: #2C5418; }

@media (max-width: 960px) {
  .hdr-in { height: 60px; gap: 10px; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .ftr-in { padding-left: max(18px, env(safe-area-inset-left)); padding-right: max(18px, env(safe-area-inset-right)); }
  .nav { display: none; }
  .hdr-right { margin-left: auto; gap: 8px; }
  .hdr-right > .lnk:not(.logout) { display: none; }          /* Settings: reached through the avatar */
  .logout span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .logout { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; text-decoration: none; color: var(--ink); }
  .logout .ico { display: block; }
  .logout:hover { background: var(--ink-tint); }
  .install-btn { width: 44px; height: 44px; padding: 0; justify-content: center; }
  .install-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .langsw button { min-width: 44px; min-height: 44px; padding: 0 10px; }
  .brand { min-height: 44px; }
  .hdr-av { width: 44px; height: 44px; align-items: center; justify-content: center; }
  .hdr-right .btn-sm { min-height: 44px; }
  body { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 8; height: calc(66px + env(safe-area-inset-bottom));
    background: rgba(255,255,255,.97); border-top: 1px solid var(--rule); box-shadow: 0 -4px 18px rgba(15,58,51,.07);
    padding: 4px max(6px, env(safe-area-inset-left)) calc(4px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-right)); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 56px; text-decoration: none;
    color: var(--muted); font: 800 .7rem/1.1 var(--display); border-radius: 14px; -webkit-tap-highlight-color: transparent; }
  .tabbar a svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
  .tabbar a.on { color: var(--ink); }
  .tabbar a.on svg { background: var(--ink-tint); border-radius: 999px; padding: 3px 14px; box-sizing: content-box; margin: -3px 0; stroke: var(--teal); }
  .tabbar a:active { background: var(--ink-tint); }
  .ftr { margin-top: 48px; }
  /* touch targets */
  .btn { min-height: 44px; }
  .lnk { min-height: 44px; display: inline-flex; align-items: center; }
  .composer input, .composer .btn { min-height: 48px; }
  .notion { min-height: 48px; }
  input, select, textarea { font-size: 16px; }              /* no iOS zoom on focus */
  .hw-tools .ib, .hw-tools .tb { min-width: 44px; min-height: 44px; }
  .mode-tabs button { min-height: 44px; }
  .av-opt { min-width: 44px; min-height: 44px; }
}
@media (max-width: 420px) {
  .hdr-in { gap: 6px; }
  .brand-name { font-size: 1.15rem; }
  .langsw button { min-width: 44px; padding: 0 8px; }
}
@media print { .tabbar, .pwa-toasts, .install-btn { display: none !important; } body { padding-bottom: 0; } }

/* Toasts (update available / offline) */
.pwa-toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 20; display: flex; flex-direction: column; gap: 8px; width: min(560px, calc(100% - 24px)); pointer-events: none; }
.pwa-toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; background: var(--ink); color: #fff; border-radius: 16px; padding: 10px 12px 10px 18px; box-shadow: 0 10px 30px rgba(15,58,51,.25); font: 700 .92rem/1.35 var(--sans); }
.pwa-toast > span:first-child { flex: 1; }
.pwa-toast .btn { background: var(--saffron); border-color: var(--saffron); color: var(--ink); min-height: 40px; }
.pwa-toast .btn:hover { background: #FFC266; color: var(--ink); }
.pwa-toast .lnk { color: #fff; text-decoration-color: rgba(255,255,255,.5); min-height: 40px; }
.pwa-toast.off { background: #FFF6E4; color: #6B4300; box-shadow: 0 6px 18px rgba(15,58,51,.12); }
.pwa-toast.off .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--saffron); flex: none; }
.pwa-toast.off > span:first-child { flex: none; }
@media (max-width: 960px) { .pwa-toasts { bottom: calc(76px + env(safe-area-inset-bottom)); } }

/* iOS "Add to Home Screen" sheet */
.sheet-wrap { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.sheet-back { position: absolute; inset: 0; background: rgba(15,30,35,.45); }
.sheet { position: relative; width: min(520px, 100%); max-height: 92vh; overflow: auto; background: #fff; border-radius: 26px 26px 0 0; padding: 10px 24px calc(22px + env(safe-area-inset-bottom)); box-shadow: 0 -10px 40px rgba(15,58,51,.2); animation: sheetUp .28s ease-out; }
@media (min-width: 700px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 26px; padding-bottom: 24px; } }
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-grip { width: 44px; height: 5px; border-radius: 3px; background: var(--rule-strong); margin: 4px auto 12px; }
.sheet-langs { display: flex; gap: 6px; justify-content: flex-end; }
.sheet-langs button { min-width: 48px; min-height: 44px; border: 1.5px solid var(--rule-strong); background: #fff; border-radius: 999px; font: 800 .8rem var(--display); color: var(--muted); cursor: pointer; }
.sheet-langs button[aria-pressed="true"] { background: var(--teal-d); border-color: var(--teal-d); color: #fff; }
.sheet-icon { width: 72px; height: 72px; margin: 2px auto 6px; background: var(--paper); border-radius: 18px; display: grid; place-items: center; box-shadow: var(--sh); }
.sheet-icon svg { width: 56px; height: 56px; }
.sheet h2 { text-align: center; font-size: 1.4rem; margin: 8px 0 4px; }
.sheet-lede { text-align: center; color: var(--muted); margin: 0 0 14px; }
.sheet-steps { list-style: none; counter-reset: st; padding: 0; margin: 0 0 12px; display: grid; gap: 10px; }
.sheet-steps li { counter-increment: st; display: flex; gap: 12px; align-items: center; background: var(--paper); border-radius: 14px; padding: 12px 14px; line-height: 1.4; }
.sheet-steps li::before { content: counter(st); flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: #fff; font: 800 .85rem/26px var(--display); text-align: center; }
.sheet-steps .si { flex: none; width: 40px; height: 40px; border-radius: 10px; background: #fff; display: grid; place-items: center; box-shadow: var(--sh); }
.sheet-note { font-size: .84rem; color: var(--muted); text-align: center; margin: 0 0 14px; }
.sheet-close { width: 100%; justify-content: center; min-height: 48px; }
.sheet[dir="rtl"] .sheet-langs { justify-content: flex-start; }

/* Session + homework on phones / tablets: one column, chat before the memory card and legend */
@media (max-width: 960px) {
  .sess { display: flex; flex-direction: column; align-items: stretch; gap: 14px; padding-top: 20px; }
  .sess-side { display: contents; }
  .sess-side > * { order: 2; margin-bottom: 0; }
  .sess-side > .mode-tabs { order: 1; }
  .sess-main { order: 4; min-width: 0; }
  .sess-side > .memcard { order: 5; }
  .sess-side > .legend { order: 6; }
  .notions { order: 3; flex-direction: row; overflow-x: auto; scroll-snap-type: x proximity; gap: 8px; padding: 2px 2px 8px; margin: 0 -2px; -webkit-overflow-scrolling: touch; }
  .notions li { flex: 0 0 auto; width: 196px; scroll-snap-align: start; }
  .notion { height: 100%; }
  .notion:hover { transform: none; }
  .log { max-height: min(62vh, 560px); min-height: 280px; }
  .hw-mode .sess-side > .hw-side { display: none; }
}
@media (max-width: 600px) {
  .panel-head { padding: 12px 14px; gap: 8px; }
  .panel-head > :first-child { flex: 1 1 100%; }
  .badge { min-width: 0; flex: 1 1 auto; padding: 6px 12px; }
  .clock { padding: 5px 10px; }
  .log { padding: 14px; }
  .composer { padding: 10px 12px; gap: 6px; }
  .composer .btn { padding-left: 14px; padding-right: 14px; }
}
@media (max-width: 600px) {
  .panel-head { flex-direction: column; align-items: stretch; }
  .ph-meta { display: grid !important; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.1fr) minmax(0, 1fr); gap: 6px; }
  .badge .b-n { display: none; }
  .badge .b-c { font-size: .92rem; overflow: hidden; text-overflow: ellipsis; }
  .badge .b-l, .clock span { font-size: .58rem; letter-spacing: .06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .clock strong { font-size: 1rem; }
  .log { max-height: calc(100svh - 330px); min-height: 240px; }
}

#msgIn { text-overflow: ellipsis; }   /* long placeholder on narrow phones */
@media (max-width: 420px) {   /* phones: full-width answer field, Hint + Send underneath */
  .composer { flex-wrap: wrap; }
  .composer input { flex: 1 1 100%; }
  .composer .btn { flex: 1 1 0; justify-content: center; text-align: center; }
  .log { max-height: calc(100svh - 384px); }
}
