:root {
  color-scheme: light;
  --bg: #ffb53a; --card: #ffffff; --ink: #2a2342; --muted: #6a6481; --line: #e8dfd0; --soft: #faf6ee;
  /* text on the sunny background, and the bottom edge of a white surface that lies on a coloured background */
  --on-sun: #3d3357; --edge: rgba(70, 35, 0, .18);
  --primary: #5b4fe9; --primary-dark: #4338ca; --primary-tint: #efedff; --focus: #4338ca;
  --ok: #1e9e58; --ok-bg: #e4f7ea; --part: #c98a00; --part-bg: #fff4d1;
  --no: #e8732e; --no-bg: #ffeadb; --idk: #2f7de1; --idk-bg: #e6f0ff;
  /* darker shades of the verdict colours: a fill under white text, and a sign on white */
  --ok-dark: #16864b; --part-dark: #8a5d00; --no-dark: #c4500b; --idk-dark: #1653ad;
  --warn: #b4451a; --note: #f0d77a; --note-bg: #fff8d8;
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans", sans-serif;
  font-size: 18px;
  color: var(--ink);
  background: var(--bg);
  --column: 860px;
}
/* grades 1 and 2: larger type and shorter lines, the same look */
:root.young { font-size: 21px; --column: 760px; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
/* the side margins: 16px, or more beside a notch on a phone held sideways */
body {
  margin: 0; padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); min-height: 100vh; line-height: 1.45;
  background: linear-gradient(165deg, #ffdc5c 0%, #ffbe3d 55%, #ffa23f 100%);
}
/* the finish screen: the same sun, brighter, behind the helper */
body:has(.finish) { background: radial-gradient(1000px circle at 50% 150px, #fff3a0 0, #ffdc4a 28%, #ffb236 68%, #ff9440 100%); }
/* during a test the page has the colour of the question's subject; the script sets --page and --page-dark.
   White surfaces lie on it, and the focus ring is white outside them. */
:root.testing { background: var(--page-dark); --focus: #fff; }
.testing body { background: linear-gradient(170deg, var(--page) 35%, var(--page-dark) 135%); }
.testing .masthead { color: #fff; }
.testing .mark { background: #fff; color: var(--page-dark); }
.testing :is(.question-card, .end-confirmation, .previous-questions) { --focus: #4338ca; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

.shell { max-width: var(--column); margin: 0 auto; padding: 18px 0 80px; }
.masthead { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; font-weight: 800; }
.mark { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 12px; background: var(--primary); color: #fff; }
.masthead .title { flex: none; }
/* the child's name stands at the right, beside the sound button; a long name is cut with "…" and never breaks the bar.
   It is a white button that opens the results. While a test runs it cannot be pressed and is plain text
   in the masthead's colour: dark on the sunny background, white during a test. */
.profile { min-width: 0; min-height: 48px; margin-left: auto; padding: 0 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 2px solid #fff; box-shadow: 0 3px 0 var(--edge); border-radius: 14px; background: var(--card); color: var(--ink); font-weight: 700; }
.profile:disabled { padding: 0 2px; border-color: transparent; box-shadow: none; background: none; color: inherit; cursor: default; }
.profile:not([hidden]) + .icon-btn { margin-left: 0; }
.icon-btn { flex: none; width: 48px; height: 48px; margin-left: auto; padding: 0; border: 2px solid #fff; box-shadow: 0 3px 0 var(--edge); border-radius: 14px; background: var(--card); font-size: 22px; line-height: 1; }
.intro { margin: 0 0 22px; }
h1 { margin: 0 0 6px; font-size: 2rem; line-height: 1.15; letter-spacing: -.02em; overflow-wrap: anywhere; }
.intro-text { margin: 0; color: var(--on-sun); font-weight: 600; }
.back { min-height: 44px; margin: 0 0 14px; padding: 8px 14px 8px 10px; border: 2px solid #fff; box-shadow: 0 3px 0 var(--edge); border-radius: 99px; background: var(--card); font-weight: 700; }
.empty { margin: 0; padding: 20px 22px; border: 2px solid #fff; border-radius: 20px; background: var(--card); color: var(--muted); }

/* buttons */
.primary, .secondary {
  min-height: 56px; padding: 10px 26px; border-radius: 18px; font-weight: 800; font-size: 1.05rem; line-height: 1.2;
  transition: transform .08s, box-shadow .08s;
}
.primary { min-width: 190px; border: 0; background: var(--primary); color: #fff; box-shadow: 0 5px 0 var(--primary-dark); }
.secondary { border: 3px solid var(--line); background: var(--card); color: var(--ink); box-shadow: 0 5px 0 var(--line); }
/* on the sunny background the white button has no beige line */
:is(.wait-actions, .summary-actions) .secondary { border-color: #fff; box-shadow: 0 5px 0 var(--edge); }
.primary:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--primary-dark); }
.secondary:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--line); }
:is(.wait-actions, .summary-actions) .secondary:active:not(:disabled) { box-shadow: 0 1px 0 var(--edge); }
.primary:disabled, .secondary:disabled { opacity: .45; cursor: not-allowed; }

/* big tiles: grades and books. Solid colour (--c) with white text and a bottom edge in its darker shade (--d). */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 16px; }
.tile {
  position: relative; display: flex; align-items: center; gap: 14px; min-height: 96px; padding: 16px 18px; text-align: left;
  border: 3px solid var(--c); border-radius: 22px; background: var(--c); color: #fff; box-shadow: 0 5px 0 var(--d); transition: transform .08s, box-shadow .08s;
}
.tile:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--d); }
.tile .ico { display: grid; place-items: center; flex: none; width: 58px; height: 58px; border-radius: 18px; background: #fff; color: var(--d); font-size: 30px; font-weight: 800; line-height: 1; }
.tile-text { min-width: 0; overflow-wrap: anywhere; }
.tile .name { display: block; font-size: 1.15rem; font-weight: 800; line-height: 1.2; }
.tile .sub { display: block; margin-top: 2px; font-size: .85rem; font-weight: 600; }
.tile .tick { position: absolute; top: -12px; right: -10px; display: none; place-items: center; width: 34px; height: 34px; border: 3px solid #fff; border-radius: 50%; background: var(--ok); color: #fff; font-weight: 800; line-height: 1; }
/* a chosen book: pressed in, a dark ring round it and the tick */
.tile[aria-pressed="true"], .tile[aria-pressed="true"]:active { transform: translateY(3px); box-shadow: 0 0 0 3px #fff, 0 0 0 7px var(--ink); }
.tile[aria-pressed="true"] .tick { display: grid; }
.grade .ico { width: 70px; height: 70px; font-size: 38px; }
.helpers { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 34px; padding: 16px 18px; border: 2px solid #fff; border-radius: 22px; background: var(--card); }
.helpers-label { margin-right: 4px; font-weight: 800; }
.pick { display: grid; place-items: center; flex: none; width: 60px; height: 60px; padding: 0; border: 3px solid var(--line); border-radius: 50%; background: var(--card); font-size: 32px; line-height: 1; transition: transform .08s; }
/* each helper on its own pale colour; the chosen one is larger and has a ring */
.pick:nth-of-type(1) { border-color: #ffd0a1; background: #ffe6cc; }
.pick:nth-of-type(2) { border-color: #d5c8ff; background: #ebe4ff; }
.pick:nth-of-type(3) { border-color: #b8d8ff; background: #dcecff; }
.pick:nth-of-type(4) { border-color: #b4e6c8; background: #dcf5e6; }
.pick[aria-pressed="true"] { border-color: var(--primary); box-shadow: 0 0 0 4px #fff, 0 0 0 7px var(--primary); transform: scale(1.08); }

/* lessons */
.pill { flex: none; padding: 3px 12px; border-radius: 99px; background: var(--primary-tint); color: var(--primary-dark); font-size: .85rem; font-weight: 700; white-space: nowrap; }
/* a drawn checkbox: the real one is inside the label, out of sight */
.check { position: relative; display: flex; align-items: center; gap: 14px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.check .box { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border: 3px solid #b5aa97; border-radius: 12px; background: var(--card); color: #fff; font-weight: 800; line-height: 1; }
.check input:is(:checked, :indeterminate) + .box { border-color: var(--ok); background: var(--ok); }
.check input:checked + .box::after { content: "✓"; }
.check input:indeterminate + .box::after { content: "–"; }
.check input:focus-visible + .box { outline: 4px solid var(--focus); outline-offset: 3px; }
.select-all { min-height: 64px; margin: 0 0 14px; padding: 10px 18px; border: 2px solid var(--primary); border-radius: 20px; background: var(--primary); color: #fff; box-shadow: 0 4px 0 var(--primary-dark); font-weight: 800; --focus: #fff; }
.select-all .pill { background: #fff; }
/* on a coloured row the box is white, and the tick in it is green */
:is(.select-all, .section-check) .box { border-color: #fff; }
:is(.select-all, .section-check) input:is(:checked, :indeterminate) + .box { border-color: #fff; background: #fff; color: var(--ok-dark); }
.check-text { flex: 1; min-width: 0; }
.book-heading { display: flex; margin: 24px 0 0; font-size: 1.15rem; }
/* a section has its book's subject colour: the script sets --c, --d and --t on the card */
.section-card { margin: 12px 0; border: 2px solid var(--c, var(--line)); border-radius: 20px; background: var(--card); overflow: hidden; }
.section-card.has-selection .section-toggle .pill { background: var(--ok-bg); color: #14693b; }
.section-header { display: flex; align-items: stretch; background: var(--c, var(--muted)); color: #fff; --focus: #fff; }
.section-header .pill { background: #fff; color: var(--d, var(--ink)); }
.section-check { padding: 0 6px 0 18px; }
.section-toggle { display: flex; flex: 1; align-items: center; gap: 12px; min-width: 0; min-height: 64px; padding: 10px 18px 10px 8px; border: 0; background: none; font-weight: 800; text-align: left; }
.section-toggle:focus-visible { outline-offset: -4px; border-radius: 18px; }
.section-title { flex: 1; min-width: 0; line-height: 1.3; overflow-wrap: anywhere; }
.arrow { flex: none; font-size: 1.3rem; line-height: 1; transition: transform .15s; }
.section-toggle[aria-expanded="true"] .arrow { transform: rotate(180deg); }
.lesson-list { border-top: 2px solid var(--line); }
.lesson-row { min-height: 62px; padding: 10px 18px; border-top: 2px solid var(--line); }
.lesson-row:first-child { border-top: 0; }
.lesson-row:has(input:checked) { background: var(--ok-bg); }
.lesson-title { flex: 1; min-width: 0; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.lesson-pages { flex: none; padding: 3px 10px; border-radius: 99px; background: var(--t, #f3ede1); color: var(--d, var(--muted)); font-size: .8rem; font-weight: 700; white-space: nowrap; }
.lesson-row:has(input:checked) .lesson-pages { background: var(--card); }
.suggestion { margin: 0 0 14px; padding: 12px 16px; border: 2px solid var(--note); border-radius: 18px; background: var(--note-bg); }

/* the bar fixed to the bottom of the window on the books and the lessons screens */
html:has(.startbar) { scroll-padding-bottom: 150px; }
.shell:has(.startbar) { padding-bottom: 24px; }
.startbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 3;
  padding: 12px max(16px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  border-top: 2px solid var(--line); background: #fffdf8; box-shadow: 0 -6px 20px rgba(60, 40, 0, .08);
}
.startbar-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; width: min(var(--column), 100%); margin: 0 auto; padding-bottom: 5px; }
.startbar-info { flex: 1; min-width: 0; margin: 0; font-weight: 700; }
.chips { display: flex; align-items: center; gap: 8px; min-width: 0; margin: 0; padding: 0; border: 0; }
.chips-label { margin-right: 2px; color: var(--muted); font-size: .85rem; font-weight: 700; }
.chip { position: relative; display: grid; place-items: center; min-width: 58px; height: 56px; padding: 0 12px; border: 3px solid var(--line); border-radius: 16px; background: var(--card); font-weight: 800; cursor: pointer; }
.chip:has(input:checked) { border-color: var(--primary); background: var(--primary); color: #fff; box-shadow: 0 3px 0 var(--primary-dark); }
.chip:has(input:focus-visible) { outline: 4px solid var(--focus); outline-offset: 3px; }
.startbar .suggestion { flex-basis: 100%; margin: 0; padding: 0; border: 0; background: none; color: var(--muted); font-size: .8rem; font-weight: 700; }
.select-all + .suggestion { display: none; }
.form-error { margin: 14px 0 0; color: var(--warn); font-weight: 700; }
.form-error:empty { margin: 0; }

/* waiting */
.wait { padding: 40px 0 20px; text-align: center; }
.helper-button { display: block; margin: 0 auto 18px; padding: 0; border: 0; border-radius: 50%; background: none; animation: bob 1.3s ease-in-out infinite; -webkit-tap-highlight-color: transparent; }
.helper-button .helper { width: 130px; height: 130px; border-color: var(--primary); font-size: 72px; }
.helper.hop { animation: hop .5s; }
.wait-line { margin: 0; font-size: 1.6rem; font-weight: 800; line-height: 1.2; }
.wait-bar { width: min(440px, 100%); height: 16px; margin: 22px auto; border-radius: 99px; background: rgba(255, 255, 255, .8); overflow: hidden; }
.wait-bar b { display: block; width: 0; height: 100%; border-radius: 99px; background: var(--primary); transition: width 5s linear; }
.wait-tip { display: inline-block; max-width: 520px; margin: 0; padding: 14px 20px; border: 2px solid #fff; border-radius: 18px; background: var(--card); }
.wait-notice { margin: 0 0 18px; color: var(--on-sun); font-weight: 700; }
.wait-notice:empty { margin: 0; }
.wait.failed .helper-button { animation: none; }
.wait.failed .form-error { display: inline-block; margin: 0; padding: 10px 18px; border-radius: 16px; background: var(--card); font-size: 1.15rem; }
.wait-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 24px; padding-bottom: 5px; }
.card-wait { display: flex; align-items: center; gap: 14px; margin-top: 24px; scroll-margin: 16px 0 24px; }
.card-wait .helper { --bob: -6px; border-color: var(--primary); animation: bob 1.3s ease-in-out infinite; }
.card-wait p { margin: 0; font-size: 1.05rem; font-weight: 800; }

/* test screen */
.testbar { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.subject-chip { flex: 0 1 auto; min-width: 0; padding: 6px 14px; border: 2px solid var(--c); border-radius: 99px; background: var(--c); color: #fff; font-size: .85rem; font-weight: 800; overflow-wrap: anywhere; }
/* the test bar lies on the subject's colour: a white chip, a white path with dark empty steps, white count */
.testbar .subject-chip { border-color: #fff; background: #fff; color: var(--d); }
.path { display: flex; flex: 1 1 0; align-items: center; gap: 5px; min-width: 300px; }
.path i { flex: 1; min-width: 0; height: 14px; border-radius: 99px; background: rgba(20, 10, 50, .3); }
.path i.done { background: #fff; }
.path i.now { background: #ffd84a; box-shadow: 0 0 0 2px #fff; animation: pulse 1.4s infinite; }
.path .flag { margin-left: 4px; font-size: 22px; line-height: 1; }
.path-count { flex: none; margin-left: 6px; color: #fff; font-size: .85rem; font-weight: 800; white-space: nowrap; }
.end-button { flex: none; min-height: 44px; padding: 8px 12px; border: 2px solid #fff; border-radius: 12px; background: var(--card); color: var(--ink); box-shadow: 0 3px 0 rgba(20, 10, 50, .25); font-size: .8rem; font-weight: 800; white-space: nowrap; }
.end-button[aria-expanded="true"] { background: var(--soft); }
.end-button:disabled { opacity: .45; cursor: not-allowed; }
.end-confirmation { margin: 0 0 18px; padding: 18px 20px 8px; border: 2px solid var(--note); border-radius: 20px; background: var(--note-bg); }
.end-confirmation p:first-child { margin: 0 0 16px; }
.end-confirmation .secondary { margin: 0 12px 12px 0; }
.end-confirmation .form-error { margin: 0 0 12px; }
.question-card { padding: 26px; border: 2px solid #fff; border-radius: 26px; background: var(--card); box-shadow: 0 10px 30px rgba(20, 10, 50, .18); }
.question-prompt { margin: 0 0 22px; font-size: 1.65rem; font-weight: 800; line-height: 1.25; letter-spacing: -.01em; overflow-wrap: anywhere; white-space: pre-line; }
.answer-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; min-width: 0; margin: 0; padding: 0 0 5px; border: 0; }
.answer-options.pairs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.answer-options.stacked { grid-template-columns: minmax(0, 1fr); }
.answer-tile {
  position: relative; display: flex; align-items: center; gap: 14px; min-height: 72px; padding: 12px 16px;
  border: 3px solid var(--c); border-radius: 20px; background: var(--c); color: #fff; box-shadow: 0 5px 0 var(--d);
  font-size: 1.15rem; font-weight: 800; line-height: 1.25; cursor: pointer; overflow-wrap: anywhere; transition: transform .08s, box-shadow .08s;
}
.answer-tile input, .check input, .chip input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.answer-tile .badge { display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 13px; background: #fff; color: var(--d); line-height: 1; }
.answer-tile:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--d); }
/* the chosen tile: pressed in, a dark ring round it and a tick on its corner */
.answer-tile:has(input:checked) { transform: translateY(3px); box-shadow: 0 0 0 3px #fff, 0 0 0 7px var(--ink); }
.answer-tile:has(input:checked):not(.right, .wrong)::after {
  content: "✓"; position: absolute; top: -13px; right: -11px; display: grid; place-items: center; width: 34px; height: 34px;
  border: 3px solid #fff; border-radius: 50%; background: var(--ink); color: #fff; font-size: 1rem; line-height: 1;
}
/* the other tiles turn pale once one is chosen, and stay easy to read */
.answer-options:has(input:checked) .answer-tile:not(.right, :has(input:checked)), .answer-tile:not(.right):has(input:disabled:not(:checked)) { background: var(--t); color: var(--ink); }
:is(.answer-options:has(input:checked) .answer-tile:not(.right, :has(input:checked)), .answer-tile:not(.right):has(input:disabled:not(:checked))) .badge { background: var(--c); color: #fff; }
.answer-tile:has(input:focus-visible) { outline: 4px solid var(--focus); outline-offset: 3px; }
/* after the answer is sent: nothing can be pressed, and the tiles that were not chosen lie flat */
.answer-tile:has(input:disabled) { transform: none; cursor: default; }
.answer-tile:has(input:disabled:not(:checked)) { box-shadow: none; }
.answer-tile:not(.right):has(input:disabled:not(:checked)) { border-color: var(--t); }
/* the verdict on a tile: solid green with ✓ for the right option, solid orange with ✗ for a wrong choice */
.answer-options .answer-tile:is(.right, .wrong) { border-color: var(--v); background: var(--v); color: #fff; }
.answer-options .answer-tile:is(.right, .wrong) .badge { background: #fff; color: var(--v); }
.answer-tile.right { --v: var(--ok-dark); animation: pop .4s; }
.answer-tile.wrong { --v: var(--no-dark); }
.answer-tile .sign { flex: none; margin-left: auto; font-size: 1.5rem; line-height: 1; }
.answer-label { display: block; margin-bottom: 10px; font-weight: 800; }
textarea { display: block; width: 100%; padding: 14px 16px; border: 3px solid var(--line); border-radius: 18px; background: #fffdf8; font-size: 1.15rem; line-height: 1.4; resize: vertical; }
textarea:focus { border-color: var(--primary); outline: 0; }
textarea:disabled { background: var(--soft); color: var(--ink); opacity: 1; }
.hint-text { margin: 16px 0 0; padding: 14px 16px; border: 2px solid var(--note); border-radius: 18px; background: var(--note-bg); }
/* the button that reads aloud, in the larger size only */
.say { display: block; min-height: 48px; margin: 12px 0 0; padding: 8px 18px; border: 2px solid var(--line); border-radius: 99px; background: var(--card); font-size: .85rem; font-weight: 800; }
.say[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-tint); color: var(--primary-dark); }
.question-prompt + .say { margin: -8px 0 22px; }
.question-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 22px; padding-bottom: 5px; }
.question-actions .hint-button { margin-left: auto; }
/* the verdict: grey when the answer could not be graded */
[data-verdict] { --v: #a8a3b8; --vb: #f3f1f6; --vd: var(--muted); }
[data-verdict="correct"] { --v: var(--ok); --vb: var(--ok-bg); --vd: var(--ok-dark); }
[data-verdict="partial"] { --v: var(--part); --vb: var(--part-bg); --vd: var(--part-dark); }
[data-verdict="incorrect"] { --v: var(--no); --vb: var(--no-bg); --vd: var(--no-dark); }
[data-verdict="not_yet"] { --v: var(--idk); --vb: var(--idk-bg); --vd: var(--idk-dark); }
.after-answer, .next-button { scroll-margin: 16px 0 24px; }
.feedback { display: flex; align-items: flex-start; gap: 14px; margin-top: 24px; }
.feedback:focus-visible { outline: 0; }
.helper { display: grid; place-items: center; flex: none; width: 66px; height: 66px; border: 3px solid var(--v, var(--line)); border-radius: 50%; background: var(--card); font-size: 36px; line-height: 1; }
.feedback[data-verdict="correct"] .helper { animation: hop .6s; }
/* the hop stays in the list, so it does not start again when the wait ends */
.feedback.waiting .helper { --bob: -6px; animation: bob 1.3s ease-in-out infinite; }
.feedback[data-verdict="correct"].waiting .helper { animation: hop .6s, bob 1.3s ease-in-out infinite; }
.bubble { flex: 1; min-width: 0; padding: 16px 20px; border: 3px solid var(--v); border-radius: 6px 22px 22px 22px; background: var(--vb); overflow-wrap: anywhere; }
.bubble p { margin: 0; font-size: 1.05rem; }
.source-reference { display: inline-block; margin-top: 12px; padding: 4px 12px; border-radius: 14px; background: #f3ede1; color: var(--muted); font-size: .8rem; font-weight: 800; }
.bubble .source-reference { background: var(--card); }
.next-button { margin: 20px 14px 5px 0; }
.next-wait { display: inline-block; padding: 8px 0; font-size: 1.05rem; font-weight: 800; vertical-align: middle; scroll-margin: 16px 0 24px; }
.previous-questions { margin: 18px 0; border: 2px solid #fff; border-radius: 20px; background: var(--card); overflow: hidden; }
.previous-questions summary { padding: 15px 18px; color: var(--primary-dark); font-weight: 800; cursor: pointer; }
.previous-questions summary:focus-visible { outline-offset: -4px; border-radius: 18px; }
.past-question { padding: 16px 18px; border-top: 2px solid var(--line); border-left: 6px solid var(--v); }
.past-question h3 { margin: 0 0 8px; font-size: 1rem; white-space: pre-line; }
.past-question p { margin: 6px 0 0; }
.past-question :is(h3, p) { overflow-wrap: anywhere; }

/* „Моите резултати“: each test is a row that opens. The date, the points and the arrow stand in one line;
   the lessons and the tokens lie under them. */
.results .previous-questions { margin: 0 0 12px; }
.test-row summary { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 8px 10px; color: var(--ink); list-style: none; }
.test-row summary::-webkit-details-marker { display: none; }
.test-row .arrow { transition: none; }
.test-row[open] .arrow { transform: rotate(180deg); }
.test-date { font-size: 1.05rem; }
.pill.early { background: #f0eef4; color: var(--muted); }
.test-lessons { grid-column: 1 / -1; color: var(--muted); font-size: .9rem; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
/* the same tokens as on the finish screen, smaller and flat */
.test-row .tokens { grid-column: 1 / -1; justify-content: flex-start; gap: 6px; margin: 0; }
.test-row .tokens span { width: 32px; height: 32px; border-width: 2px; border-radius: 10px; box-shadow: none; font-size: 16px; }

/* summary */
.summary-card { margin: 0 0 16px; padding: 22px 26px; border: 2px solid #fff; border-radius: 22px; background: var(--card); }
.summary-card h2 { margin: 0 0 8px; font-size: 1.15rem; }
.summary-card p { margin: 8px 0 0; }
.summary-list { margin: 8px 0 0; padding-left: 26px; }
.summary-list li { margin: 12px 0 0; overflow-wrap: anywhere; }
.summary-list .source-reference { display: block; width: fit-content; margin-top: 8px; }
.summary-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin: 24px 0; padding-bottom: 5px; }

/* finish */
.finish { margin: 0 0 22px; text-align: center; }
.finish .helper { width: 110px; height: 110px; margin: 0 auto 12px; border-color: var(--primary); font-size: 62px; animation: hop .7s; }
.tokens { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 20px 0 12px; }
/* the tokens lie on the sunny background: white, with the sign and the edges in the verdict's colour */
.tokens span { display: grid; place-items: center; width: 48px; height: 48px; border: 3px solid var(--v); border-radius: 16px; background: var(--card); color: var(--vd); box-shadow: 0 4px 0 var(--v); font-size: 22px; font-weight: 800; line-height: 1; }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 18px; width: fit-content; max-width: 100%; margin: 0 auto; padding: 6px 16px; border-radius: 16px; background: var(--card); color: var(--muted); font-size: .85rem; font-weight: 700; }
.legend span { white-space: nowrap; }
.legend b { color: var(--vd); font-size: 1rem; }
.points { margin: 12px 0 0; color: var(--ink); font-size: 1.1rem; font-weight: 800; }
.summary-note { margin: 8px 0 0; color: var(--on-sun); font-size: .8rem; font-weight: 600; }
.confetti { position: fixed; inset: 0; z-index: 5; overflow: hidden; pointer-events: none; }
.confetti i { position: absolute; top: -20px; width: 12px; height: 18px; border-radius: 3px; animation: fall linear both; }

@media (hover: hover) {
  .back:hover, .end-button:hover:not(:disabled), .icon-btn:hover, .profile:hover:not(:disabled), .pick:hover:not([aria-pressed="true"]), .say:hover:not([aria-pressed="true"]) { background: var(--soft); }
  .primary:hover:not(:disabled) { background: #6a60ee; }
  .secondary:hover:not(:disabled) { background: var(--soft); }
  .tile:hover:not([aria-pressed="true"]) { transform: translateY(-2px); box-shadow: 0 7px 0 var(--d); }
  .tile:active:not([aria-pressed="true"]) { transform: translateY(4px); box-shadow: 0 1px 0 var(--d); }
  .lesson-row:hover:not(:has(input:checked)), .chip:hover:not(:has(input:checked)) { background: var(--soft); }
  .select-all:hover { background: #6a60ee; }
  .section-header:hover { filter: brightness(1.08); }
  .answer-tile:hover:not(:has(input:disabled, input:checked)) { transform: translateY(-2px); box-shadow: 0 7px 0 var(--d); }
  .answer-tile:active:not(:has(input:disabled, input:checked)) { transform: translateY(4px); box-shadow: 0 1px 0 var(--d); }
}
@keyframes pulse { 50% { background: #fff; } }
@keyframes pop { 40% { transform: scale(1.04); } }
@keyframes bob { 50% { transform: translateY(var(--bob, -12px)); } }
@keyframes fall { to { transform: translateY(calc(100vh + 40px)) rotate(540deg); } }
@keyframes hop { 30% { transform: translateY(-12px) rotate(-6deg); } 60% { transform: translateY(0) rotate(5deg); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-width: 720px) {
  .testbar { flex-wrap: wrap; row-gap: 10px; }
  .subject-chip { margin-right: auto; }
  .path { order: 3; flex-basis: 100%; min-width: 0; }
  .answer-options, .answer-options.pairs { grid-template-columns: minmax(0, 1fr); }
  .question-actions .primary { flex-basis: 100%; }
  /* the lessons bar in two rows: a small caption above the chips and above the button */
  .startbar:has(.chips) { padding-top: 8px; }
  .startbar-inner:has(.chips) { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: end; gap: 4px 12px; }
  .chips ~ .primary { grid-area: 2 / 2; min-width: 0; padding: 10px 14px; }
  .startbar-info:has(+ .chips) { grid-area: 1 / 2; font-size: .85rem; line-height: 1.25; }
  .chips { display: grid; grid-area: 1 / 1 / span 2; grid-template-columns: repeat(3, auto); gap: 4px 6px; }
  .chips-label { grid-column: 1 / -1; margin: 0; line-height: 1.25; }
  .startbar .suggestion { display: none; }
  .select-all + .suggestion { display: block; }
}
@media (max-width: 560px) {
  .helpers-label { flex-basis: 100%; }
  .path { gap: 3px; }
  .question-prompt { font-size: 1.4rem; }
  .question-card { padding: 18px; }
  .answer-options.stacked .answer-tile { font-size: 1rem; }
  .question-actions { flex-direction: column; align-items: stretch; }
  .question-actions .primary { flex-basis: auto; }
  .question-actions .hint-button { margin-left: 0; }
  .wait-actions { flex-direction: column; align-items: stretch; }
  .card-wait { gap: 10px; }
  .feedback { gap: 10px; }
  .helper { width: 48px; height: 48px; font-size: 26px; }
  .bubble { padding: 14px 16px; }
  .summary-card { padding: 18px; }
  .summary-actions { flex-direction: column; align-items: stretch; }
  .finish .helper { width: 96px; height: 96px; font-size: 54px; }
  .tokens { gap: 8px; }
  .tokens span { width: 42px; height: 42px; border-radius: 14px; font-size: 20px; }
  .startbar-info:not(:has(+ .chips)) { display: none; }
  .startbar-info + .primary { flex: 1; }
  .select-all, .lesson-row { gap: 12px; padding: 10px 14px; }
  .section-check { padding-left: 14px; }
  .section-toggle { gap: 8px; padding-right: 14px; }
}
/* the larger size on a phone: the count in the bar stays on one line; a long title gets the whole line, and the pill goes under it */
@media (max-width: 560px) {
  .young .startbar-info:has(+ .chips) { font-size: .75rem; }
  .young .lesson-row, .young .section-toggle { flex-wrap: wrap; row-gap: 4px; }
  .young .lesson-title { flex-basis: calc(100% - 48px); }
  .young .lesson-pages { margin-left: 48px; }
  .young .section-title { flex-basis: 100%; }
  .young .section-toggle .arrow { margin-left: auto; }
}
