/* Owlie Learn: kid-friendly theme. Colours come from variables; each grade has its own accent. */
:root {
  color-scheme: light dark;
  --font: "Baloo 2", "Fredoka", "Nunito", "Arial Rounded MT Bold", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  --bg1: #d9f1ff; --bg2: #fff6e0; --card: #ffffff; --ink: #1d2a4d; --muted: #5b6a8f;
  --brand: #ff7a1a; --brand-d: #d85f00; --brand-ink: #ffffff; --brand-soft: #fff0e0;
  --accent: #ffc83d; --ok: #12a150; --ok-soft: #dcf8e8; --bad: #e0446b; --bad-soft: #ffe4ec;
  --line: #e3e9f7; --shadow: 0 4px 0 rgba(29, 42, 77, .09), 0 8px 22px rgba(29, 42, 77, .09);
  --radius: 22px; --pop: cubic-bezier(.34, 1.56, .64, 1);
}
body[data-grade="g1"] { --brand: #ff7a1a; --brand-d: #d85f00; --brand-soft: #fff0e0; }
body[data-grade="g2"] { --brand: #19b36b; --brand-d: #0e8a50; --brand-soft: #dcf8ea; }
body[data-grade="g3"] { --brand: #2f8bff; --brand-d: #1769d6; --brand-soft: #e1efff; }
body[data-grade="g4"] { --brand: #0fa3a3; --brand-d: #0a7c7c; --brand-soft: #dcf6f6; }
body[data-grade="g5"] { --brand: #e8507a; --brand-d: #c22f5a; --brand-soft: #ffe3eb; }
body[data-grade="g6"] { --brand: #8a5cf6; --brand-d: #6a3fd6; --brand-soft: #eee6ff; }
@media (prefers-color-scheme: dark) {
  :root {
    --bg1: #101a38; --bg2: #1c1740; --card: #1b2447; --ink: #eef2ff; --muted: #a9b6dd; --brand-ink: #101a38;
    --accent: #ffd45c; --ok: #4be08c; --ok-soft: #123a2a; --bad: #ff7f9f; --bad-soft: #3d1a2b;
    --line: #2e3a6b; --shadow: 0 4px 0 rgba(0, 0, 0, .3), 0 8px 22px rgba(0, 0, 0, .3);
  }
  body[data-grade="g1"] { --brand: #ff9a4d; --brand-d: #ff9a4d; --brand-soft: #3b2616; }
  body[data-grade="g2"] { --brand: #3fd48c; --brand-d: #3fd48c; --brand-soft: #143a2a; }
  body[data-grade="g3"] { --brand: #5aa6ff; --brand-d: #5aa6ff; --brand-soft: #16305c; }
  body[data-grade="g4"] { --brand: #3fd4d4; --brand-d: #3fd4d4; --brand-soft: #123a3a; }
  body[data-grade="g5"] { --brand: #ff7f9f; --brand-d: #ff7f9f; --brand-soft: #3d1a2b; }
  body[data-grade="g6"] { --brand: #b394ff; --brand-d: #b394ff; --brand-soft: #2c2358; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); font: 500 18px/1.45 var(--font);
  background: radial-gradient(circle at 12% 8%, rgba(255, 255, 255, .7) 0 60px, transparent 61px),
    radial-gradient(circle at 88% 14%, rgba(255, 255, 255, .55) 0 46px, transparent 47px),
    linear-gradient(180deg, var(--bg1), var(--bg2)) fixed;
  padding: 0 14px calc(32px + env(safe-area-inset-bottom)); max-width: 1000px; margin-inline: auto; overflow-wrap: anywhere;
}
@media (prefers-color-scheme: dark) { body { background: linear-gradient(180deg, var(--bg1), var(--bg2)) fixed; } }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .5rem; font-weight: 800; }
h2 { font-size: 1.55rem; } h3 { font-size: 1.15rem; }
p { margin: 0 0 .7rem; }
.muted { color: var(--muted); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: var(--card); padding: 8px 12px; border-radius: 12px; z-index: 30; }
svg, img { max-width: 100%; }
:focus-visible { outline: 4px solid var(--accent); outline-offset: 2px; }

/* ---------- top bar ---------- */
.top { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; padding: 14px 0 6px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.7rem; letter-spacing: -.01em; }
.brand svg { width: 52px; height: 52px; flex: none; filter: drop-shadow(0 3px 0 rgba(29, 42, 77, .15)); }
.brand .w b { display: inline-block; }
.brand .w b:nth-child(5n+1) { color: #ff5d73; } .brand .w b:nth-child(5n+2) { color: #ff9f1c; } .brand .w b:nth-child(5n+3) { color: #2ec4b6; }
.brand .w b:nth-child(5n+4) { color: #3a86ff; } .brand .w b:nth-child(5n) { color: #8a5cf6; }
.learners { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; flex: 1 1 380px; max-width: 760px; }
.lbtn {
  display: flex; flex-direction: column; align-items: center; gap: 0; min-width: 0; padding: 6px 4px 7px; font: inherit; cursor: pointer;
  background: var(--card); color: var(--ink); border: 3px solid transparent; border-radius: 20px; box-shadow: var(--shadow); transition: transform .15s var(--pop);
}
.lbtn:hover { transform: translateY(-2px); }
.lbtn .av { font-size: 1.9rem; line-height: 1.1; }
.lbtn .ln { font-weight: 700; font-size: .9rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.15; }
.lbtn .lg { font-size: .72rem; font-weight: 800; color: var(--brand-ink); background: var(--gc, var(--brand)); border-radius: 99px; padding: 0 9px; margin-top: 2px; }
.lbtn[data-g="g1"] { --gc: #ff7a1a; } .lbtn[data-g="g2"] { --gc: #19b36b; } .lbtn[data-g="g3"] { --gc: #2f8bff; } .lbtn[data-g="g4"] { --gc: #0fa3a3; } .lbtn[data-g="g5"] { --gc: #e8507a; } .lbtn[data-g="g6"] { --gc: #8a5cf6; }
.lbtn .lg { color: #fff; }
.lbtn.on { border-color: var(--gc); background: color-mix(in srgb, var(--gc) 14%, var(--card)); transform: translateY(-2px); }

/* ---------- hero / stats ---------- */
.stats { display: grid; grid-template-columns: auto 1fr; gap: 12px 16px; background: var(--card); border-radius: 28px; padding: 16px; box-shadow: var(--shadow); margin-top: 8px; position: relative; overflow: hidden; }
.stats::after { content: ""; position: absolute; right: -40px; top: -40px; width: 150px; height: 150px; border-radius: 50%; background: var(--brand-soft); z-index: 0; }
.stats > * { position: relative; z-index: 1; }
.me { display: flex; align-items: center; gap: 12px; grid-column: 1 / -1; }
.me .avbig { font: inherit; font-size: 3rem; line-height: 1; width: 78px; height: 78px; border-radius: 50%; border: 4px solid var(--brand); background: var(--brand-soft); cursor: pointer; flex: none; transition: transform .2s var(--pop); position: relative; }
.me .avbig:hover { transform: rotate(-8deg) scale(1.06); }
.me .avbig::after { content: "✎"; position: absolute; right: -4px; bottom: -4px; font-size: .8rem; width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; }
.me .hi { font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.me .say { color: var(--muted); font-size: 1rem; }
.pills { display: flex; flex-wrap: wrap; gap: 10px; grid-column: 1 / -1; }
.stat { flex: 1 1 130px; background: var(--brand-soft); border-radius: 18px; padding: 8px 12px; min-width: 0; }
.stat b { display: block; font-size: 1.45rem; line-height: 1.2; }
.stat small { display: block; color: var(--muted); font-size: .8rem; line-height: 1.25; }
.stat.starbox b { color: var(--brand-d); }
.goal { grid-column: 1 / -1; }
.goal-top { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-weight: 700; margin-bottom: 6px; }
.bar { height: 22px; background: var(--brand-soft); border-radius: 99px; overflow: hidden; border: 3px solid var(--line); position: relative; }
.bar i { display: block; height: 100%; background: repeating-linear-gradient(45deg, var(--brand) 0 12px, color-mix(in srgb, var(--brand) 82%, #fff) 12px 24px); border-radius: 99px; transition: width .7s var(--pop); }
.hint { font-size: .9rem; color: var(--muted); margin: 8px 0 0; }

/* ---------- navigation ---------- */
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0; }
.tabs button {
  font: inherit; font-weight: 800; font-size: 1rem; padding: 10px 4px; border-radius: 18px; border: 3px solid transparent; min-width: 0;
  background: var(--card); color: var(--ink); cursor: pointer; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; line-height: 1.15;
}
.tabs button .ti { font-size: 1.5rem; }
.tabs button[aria-selected="true"] { background: var(--brand); color: var(--brand-ink); }
@media (prefers-color-scheme: light) { .tabs button[aria-selected="true"], .btn.primary, .chip[aria-pressed="true"], .seg button[aria-pressed="true"] { color: #fff; } }

/* ---------- cards & controls ---------- */
.view { display: none; }
.view.active { display: block; animation: rise .35s var(--pop); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.card { background: var(--card); border-radius: 26px; padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.step { display: flex; align-items: center; gap: 10px; margin: 4px 0 10px; font-size: 1.15rem; font-weight: 800; }
.step .n { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 1rem; flex: none; }
.step + .tiles, .step + .seg { margin-bottom: 16px; }
select, input[type=text], input[type=password], input[type=number], input:not([type]) {
  font: inherit; color: var(--ink); background: var(--card); border: 3px solid var(--line); border-radius: 14px; padding: 9px 12px; min-width: 0; width: 100%;
}
select:disabled { opacity: .55; }
.btn {
  font: inherit; font-weight: 800; border-radius: 18px; border: 3px solid var(--brand); background: var(--card); color: var(--brand-d);
  padding: 10px 20px; cursor: pointer; min-height: 50px; box-shadow: 0 4px 0 var(--brand); transition: transform .12s, box-shadow .12s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 0 0 var(--brand); }
.btn.primary { background: var(--brand); color: var(--brand-ink); box-shadow: 0 4px 0 var(--brand-d); border-color: var(--brand-d); }
.btn.big { font-size: 1.25rem; padding: 12px 26px; min-height: 58px; }
.btn.danger { border-color: var(--bad); color: var(--bad); box-shadow: 0 4px 0 var(--bad); }
.btn:disabled { opacity: .5; cursor: default; box-shadow: none; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile {
  --c: var(--brand); font: inherit; cursor: pointer; text-align: center; color: var(--ink); min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 12px 8px; border-radius: 22px;
  background: color-mix(in srgb, var(--c) 12%, var(--card)); border: 3px solid color-mix(in srgb, var(--c) 30%, var(--card)); box-shadow: 0 4px 0 color-mix(in srgb, var(--c) 40%, var(--card));
  transition: transform .15s var(--pop);
}
.tile:hover { transform: translateY(-3px) rotate(-1deg); }
.tile .ic { font-size: 2.4rem; line-height: 1.1; }
.tile .nm { font-weight: 800; font-size: 1.02rem; line-height: 1.15; }
.tile .sm { font-size: .74rem; color: var(--muted); font-weight: 600; line-height: 1.2; }
.tile[aria-pressed="true"] { background: var(--c); border-color: color-mix(in srgb, var(--c) 70%, #000); color: #fff; box-shadow: 0 4px 0 color-mix(in srgb, var(--c) 65%, #000); transform: translateY(-3px); }
.tile[aria-pressed="true"] .sm { color: rgba(255, 255, 255, .9); }
.tiles.topics { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.tiles.topics .tile { flex-direction: row; text-align: left; gap: 10px; padding: 10px 12px; justify-content: flex-start; }
.tiles.topics .tile .ic { font-size: 1.8rem; }
.tile .tag { display: inline-block; font-size: .68rem; font-weight: 800; background: var(--accent); color: #3b2a00; border-radius: 99px; padding: 0 7px; margin-top: 2px; }
.s-mat { --c: #2f8bff; } .s-eng { --c: #ef476f; } .s-afr { --c: #12a150; } .s-lo, .s-ls { --c: #ff8a1f; } .s-his { --c: #b5651d; } .s-geo { --c: #0fa3a3; } .s-nst { --c: #8a5cf6; }
@media (prefers-color-scheme: dark) { .tile[aria-pressed="true"] { color: #fff; } .s-his { --c: #d08a4a; } }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button, .chip {
  font: inherit; font-weight: 800; cursor: pointer; color: var(--ink); background: var(--card); border: 3px solid var(--line); border-radius: 99px; padding: 8px 18px; min-height: 46px; box-shadow: 0 3px 0 var(--line);
}
.seg button[aria-pressed="true"], .chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand-d); color: var(--brand-ink); box-shadow: 0 3px 0 var(--brand-d); }
.seg button:disabled { opacity: .45; cursor: default; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.opt-row { display: flex; flex-wrap: wrap; gap: 6px 26px; }
.opt-row > div { min-width: 0; }
.termbar { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin: 0 0 12px; font-weight: 700; }
.termbar label { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.termbar input { width: 22px; height: 22px; accent-color: var(--brand); }
.area-tag { font-size: .85rem; color: var(--muted); font-weight: 600; }

/* ---------- mascot ---------- */
.mascot { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.mascot svg { width: 64px; height: 64px; flex: none; animation: bob 3s ease-in-out infinite; }
.mascot .bubble { position: relative; background: var(--brand-soft); border-radius: 18px; padding: 10px 14px; font-weight: 700; }
.mascot .bubble::before { content: ""; position: absolute; left: -9px; top: 50%; margin-top: -8px; border: 8px solid transparent; border-right-color: var(--brand-soft); border-left: 0; }
@keyframes bob { 50% { transform: translateY(-5px) rotate(-3deg); } }

/* ---------- worksheet ---------- */
.sheet-head { border-bottom: 4px dashed var(--line); padding-bottom: 10px; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; color: var(--brand-d); }
.sheet-meta { color: var(--muted); font-size: .95rem; font-weight: 600; }
.sheet-who { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-top: 8px; font-weight: 700; }
.line { display: inline-block; min-width: 9rem; border-bottom: 3px solid currentColor; font-weight: 500; padding: 0 4px; }
.qs { list-style: none; padding: 0; margin: 0; counter-reset: q; display: grid; gap: 14px; }
.q { padding: 14px 16px 16px; border: 3px solid var(--line); border-radius: 22px; counter-increment: q; background: var(--card); }
.qtext { display: flex; gap: 12px; align-items: flex-start; font-weight: 700; font-size: 1.15rem; }
.qtext::before { content: counter(q); flex: none; width: 2em; height: 2em; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: .95rem; margin-top: -.1em; }
.qpic { margin: 8px 0 2px 3em; color: var(--ink); }
.qpic svg { width: 140px; height: 140px; }
.qpic .emo { font-size: 2rem; line-height: 1.35; letter-spacing: .08em; }
.opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; margin: 10px 0 0 3em; }
.opt { display: flex; gap: 10px; align-items: center; border: 3px solid var(--line); border-radius: 18px; padding: 8px 12px; cursor: pointer; background: var(--card); min-height: 52px; font-weight: 600; transition: transform .12s var(--pop); }
.opt:hover { transform: scale(1.02); }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt .lt { flex: none; width: 2em; height: 2em; border-radius: 50%; border: 3px solid var(--muted); display: grid; place-items: center; font-size: .85rem; font-weight: 800; color: var(--muted); }
.opt:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); transform: scale(1.02); }
.opt:has(input:checked) .lt { background: var(--brand); border-color: var(--brand); color: #fff; }
.opt:has(input:focus-visible) { outline: 4px solid var(--accent); }
.ans-in { max-width: 15rem; margin: 10px 0 0 3em; width: calc(100% - 3em); font-size: 1.2rem; font-weight: 700; }
.key, .mark { margin: 8px 0 0 3em; font-size: 1rem; display: none; }
.sheet.checked .key, .sheet.checked .mark { display: block; }
.q.right { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 6%, var(--card)); }
.q.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 5%, var(--card)); }
.q.right .mark { color: var(--ok); font-weight: 800; }
.q.wrong .mark { color: var(--bad); font-weight: 800; }
.q.right .key { display: none; }
.q.right .opt:has(input:checked) { border-color: var(--ok); background: var(--ok-soft); }
.q.wrong .opt:has(input:checked) { border-color: var(--bad); background: var(--bad-soft); }
.q.right .ans-in { border-color: var(--ok); background: var(--ok-soft); }
.q.wrong .ans-in { border-color: var(--bad); background: var(--bad-soft); }
.q.wrong .key b { color: var(--ok); }
.result { border: 4px solid var(--brand); border-radius: 26px; padding: 16px; margin-top: 16px; background: var(--brand-soft); animation: rise .5s var(--pop); }
.result .score { font-size: 2.4rem; font-weight: 800; color: var(--brand-d); line-height: 1.1; }
.result .stars-got { font-size: 1.25rem; margin-top: 6px; }
.result ul { margin: 6px 0 0; padding-left: 1.2rem; }
.note { background: var(--brand-soft); border-radius: 14px; padding: 8px 12px; font-size: .95rem; margin-bottom: 10px; font-weight: 600; }
/* younger grades get bigger writing */
body[data-grade="g1"] .qtext, body[data-grade="g2"] .qtext { font-size: 1.4rem; }
body[data-grade="g1"] .opt, body[data-grade="g2"] .opt { font-size: 1.2rem; }
body[data-grade="g1"] .ans-in, body[data-grade="g2"] .ans-in { font-size: 1.5rem; }

/* ---------- speed round ---------- */
.speed-hud { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-weight: 800; font-size: 1.3rem; }
.speed-q { font-size: clamp(2.4rem, 12vw, 4rem); font-weight: 800; text-align: center; margin: 18px 0 10px; letter-spacing: .02em; color: var(--brand-d); }
.speed-in { font-size: 2.2rem; text-align: center; max-width: 12rem; display: block; margin: 0 auto; font-weight: 800; }
.speed-in.bad { border-color: var(--bad); background: var(--bad-soft); }
.speed-in.good { border-color: var(--ok); background: var(--ok-soft); }
.timer { height: 18px; }
.pb { color: var(--muted); font-weight: 600; }

/* ---------- report ---------- */
table.rep { width: 100%; border-collapse: collapse; font-size: 1rem; }
.rep th, .rep td { text-align: left; padding: 8px; border-bottom: 2px solid var(--line); vertical-align: middle; }
.rep th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.rep .pct { white-space: nowrap; font-weight: 800; }
.mini { display: inline-block; width: 90px; max-width: 100%; height: 12px; background: var(--brand-soft); border-radius: 9px; overflow: hidden; vertical-align: middle; margin-right: 6px; }
.mini i { display: block; height: 100%; background: var(--brand); }
.tbl-wrap { overflow-x: auto; }
.rgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 10px 0 14px; }
.rbox { background: var(--brand-soft); border-radius: 18px; padding: 10px 12px; font-weight: 600; }
.rbox b { display: block; font-size: 1.4rem; }
.good-list li { color: var(--ok); font-weight: 700; } .bad-list li { color: var(--bad); font-weight: 700; }
.good-list, .bad-list { margin: 4px 0 12px; padding-left: 1.2rem; }

/* ---------- dialog, toast, confetti ---------- */
dialog.dlg { border: 0; border-radius: 26px; padding: 22px; background: var(--card); color: var(--ink); width: min(92vw, 440px); box-shadow: 0 14px 50px rgba(0, 0, 0, .4); font-family: var(--font); }
dialog.dlg::backdrop { background: rgba(10, 14, 40, .6); }
dialog.dlg .err { color: var(--bad); font-weight: 700; min-height: 1.3em; margin: 6px 0 0; }
dialog.dlg label { display: block; margin: 8px 0 2px; font-size: .9rem; font-weight: 700; color: var(--muted); }
.dlg-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.avgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 8px 0; }
.avgrid button { font-size: 2.2rem; line-height: 1.2; border: 3px solid var(--line); border-radius: 18px; background: var(--card); cursor: pointer; padding: 4px 0; }
.avgrid button[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 30px); background: var(--ink); color: var(--card); padding: 12px 20px; border-radius: 99px; opacity: 0; pointer-events: none; transition: .25s; max-width: 90vw; z-index: 50; font-weight: 700; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.confetti { position: fixed; top: -30px; font-size: 1.8rem; z-index: 40; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); opacity: .9; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .confetti { display: none; }
}

/* ---------- small screens: nav moves to the bottom like an app ---------- */
@media (max-width: 700px) {
  body { font-size: 17px; padding-inline: 10px; padding-bottom: calc(104px + env(safe-area-inset-bottom)); }
  .brand { font-size: 1.4rem; } .brand svg { width: 42px; height: 42px; }
  .learners { flex-basis: 100%; max-width: none; }
  .lbtn .av { font-size: 1.5rem; } .lbtn .ln { display: none; } .lbtn .lg { font-size: .62rem; padding: 0 6px; } .learners { gap: 5px; }
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; z-index: 20; gap: 6px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: var(--card); border-top: 3px solid var(--line); box-shadow: 0 -6px 20px rgba(29, 42, 77, .12); }
  .tabs button { font-size: .78rem; padding: 6px 2px; box-shadow: none; border-radius: 14px; }
  .tabs button .ti { font-size: 1.4rem; }
  .stats { padding: 14px; }
  .me .avbig { width: 66px; height: 66px; font-size: 2.5rem; } .me .hi { font-size: 1.35rem; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tiles.topics { grid-template-columns: 1fr; }
  .opts { margin-left: 0; grid-template-columns: 1fr; }
  .ans-in, .key, .mark, .qpic { margin-left: 0; }
  .ans-in { width: 100%; max-width: none; }
  .qtext { font-size: 1.1rem; }
  .toast { bottom: 100px; }
}

/* ---------- sign-up ---------- */
.signup { display: none; margin-top: 12px; }
.signing .signup { display: block; }
.signing .top .learners, .signing .stats, .signing .tabs, .signing main { display: none; }
.su-title { font-size: 1.9rem; color: var(--brand-d); }
.signup h2 { margin-top: 18px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
.signup label.f { display: flex; flex-direction: column; gap: 4px; font-weight: 700; color: var(--muted); font-size: .95rem; }
.grow { display: grid; grid-template-columns: minmax(130px, 190px) 1fr 84px; gap: 10px; align-items: center; padding: 8px 10px; border: 3px solid var(--line); border-radius: 18px; margin-bottom: 10px; background: var(--card); }
.grow.on { border-color: var(--brand); background: var(--brand-soft); }
.grow .gl { display: flex; gap: 10px; align-items: center; cursor: pointer; font-weight: 700; }
.grow .gl small { display: block; color: var(--muted); font-weight: 600; font-size: .75rem; }
.grow input[type=checkbox] { width: 26px; height: 26px; accent-color: var(--brand); flex: none; }
.grow select { font-size: 1.4rem; padding: 4px; }
.signup .err { color: var(--bad); font-weight: 700; min-height: 1.3em; margin: 8px 0 0; }
@media (max-width: 700px) { .row2 { grid-template-columns: 1fr; } .grow { grid-template-columns: 1fr 84px; } .grow .gl { grid-column: 1 / -1; } }

.foot { margin-top: 26px; padding: 14px 4px; border-top: 3px dashed var(--line); display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: space-between; color: var(--muted); font-size: .85rem; font-weight: 600; }
.foot a { color: var(--brand-d); font-weight: 800; }

/* ---------- print (plain black and white worksheet) ---------- */
@media print {
  :root { --bg1: #fff; --bg2: #fff; --card: #fff; --ink: #000; --muted: #333; --brand: #000; --brand-d: #000; --brand-soft: #fff; --line: #999; --ok: #000; --bad: #000; --ok-soft: #fff; --bad-soft: #fff; --brand-ink: #000; --shadow: none; }
  body, body[data-grade] { background: #fff !important; color: #000; font-size: 12pt; max-width: none; padding: 0; font-family: Arial, "Trebuchet MS", sans-serif; }
  .noprint, .foot, .top, .tabs, .stats, .toast, .skip, dialog, .confetti, .mascot { display: none !important; }
  .view:not(.active) { display: none !important; }
  .card { box-shadow: none; padding: 0; border-radius: 0; background: #fff; }
  .q { break-inside: avoid; border: 0; border-bottom: 1px dashed #999; border-radius: 0; background: #fff !important; padding: 10px 0; }
  .qs { gap: 0; }
  .qtext { font-size: 12.5pt; }
  .qtext::before { background: #fff; color: #000; border: 2px solid #000; }
  .sheet-head { border-bottom: 3px solid #000; }
  .sheet-head h2 { color: #000; }
  .opts { grid-template-columns: repeat(2, 1fr); }
  .opt { border: 0; background: none; padding: 2px 0; min-height: 0; transform: none; }
  .opt .lt { border-color: #000; color: #000; background: none !important; }
  .opt input:checked + .lt { background: none; }
  .ans-in { border: 0 !important; border-bottom: 1.5px solid #000 !important; border-radius: 0 !important; background: none !important; color: #000; }
  body.pm-plain .key, body.pm-plain .mark { display: none !important; }
  body.pm-plain .ans-in { color: transparent; }
  body.pm-plain .opt:has(input:checked) { background: none; border: 0; }
  body.pm-plain .opt:has(input:checked) .lt { background: none; color: #000; border-color: #000; }
  body.pm-ans .key { display: block !important; }
  body.pm-ans .q.right .key { display: block !important; }
  body.pm-ans .mark { display: none !important; }
  body.pm-ans .ans-in { color: transparent; }
  body.pm-ans .opt:has(input:checked) { background: none; border: 0; }
  body.pm-ans .opt:has(input:checked) .lt { background: none; color: #000; border-color: #000; }
  body.pm-ans .key b { color: #000; text-decoration: underline; }
  .qpic svg { width: 110px; height: 110px; }
  .rep th, .rep td { border-color: #999; }
  .mini { border: 1px solid #666; background: #fff; } .mini i { background: #666; }
  .rbox { border: 1px solid #999; }
}
