/* Математика — токени round2/round3-designer.md. Без мережевих шрифтів. */
:root {
  color-scheme: light;
  --bg: #EAF3FF; --surface: #FFFFFF; --text: #1B1F3B; --muted: #4E5577;
  --bg-art: radial-gradient(60rem 30rem at 110% -10%, #F1E8FF 0, transparent 60%), radial-gradient(50rem 30rem at -20% 110%, #E3F8EC 0, transparent 60%);
  --brand: #4C5BD4; --on-brand: #FFFFFF; --brand-soft: #E9EBFB;
  --ok: #16704A; --ok-bg: #E3F5EB;
  --look: #8A5A00; --look-bg: #FFF1CC;
  --unsure: #4F5D80; --unsure-bg: #E8ECF6;
  --neutral: #4F5D80; --neutral-bg: #EEF0F6;
  --focus: #4C5BD4; --border: #C9CDE4;
  --shadow: 0 1px 2px rgba(27, 31, 59, .06), 0 6px 20px rgba(27, 31, 59, .07);
  --r-sm: 12px; --r-md: 18px; --r-lg: 28px; --r-pill: 999px;
  --tap: 3.5rem; --tap-main: 4rem; --gap: 1rem;
  --fs-base: 1.125rem; --fs-step: 1.375rem; --fs-math: 1.5rem; --lh: 1.5;
  --font: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "JetBrains Mono", Menlo, monospace;
  /* категорії (DECISION №7 + референси для дітей): пастельний фон, насичений акцент; текст завжди --text */
  --paper: #FFFFFF; --star: #FFB321; --hint-bg: #FFF3CC; --hint-ink: #6E4A00;
  --kr-bg: #FFE3EA; --kr-c: #E0456B; --kr-ink: #9C1D3E;
  --sr-bg: #ECE5FF; --sr-c: #8466EE; --sr-ink: #4F33B8;
  --practice-bg: #DDF6E5; --practice-c: #2FAE62; --practice-ink: #146B3D;
  --guide-bg: #DCEFFF; --guide-c: #2F8FE0; --guide-ink: #1A5791;
  /* маскот-олівець */
  --m-body: #FFC93C; --m-band: #B9C0DE; --m-eraser: #FF8FA8; --m-wood: #F6D7A7; --m-ink: #1B1F3B; --m-cheek: #FF9DB3; --m-spark: #4C5BD4;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #14172B; --surface: #1E2240; --text: #EEF0FF; --muted: #A9B0D6;
    --brand: #8E9BFF; --on-brand: #14172B; --brand-soft: #262C4A;
    --ok: #6FD3A3; --ok-bg: #1C3A2E; --look: #FFCF66; --look-bg: #3D3216;
    --unsure: #A9B6D9; --unsure-bg: #262C4A; --neutral: #A9B6D9; --neutral-bg: #262C4A;
    --focus: #8E9BFF; --border: #3A4070;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    --bg-art: none; --paper: #2B3157; --star: #FFCF66; --hint-bg: #3D3216; --hint-ink: #FFCF66;
    --kr-bg: #3A2333; --kr-c: #FF819C; --kr-ink: #FFB3C3;
    --sr-bg: #2D2752; --sr-c: #B6A1FF; --sr-ink: #D3C7FF;
    --practice-bg: #1C3A2E; --practice-c: #6FD3A3; --practice-ink: #A6E9C8;
    --guide-bg: #1C3049; --guide-c: #7CC1FF; --guide-ink: #B5DBFF;
    --m-band: #6D76A8; --m-spark: #8E9BFF;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14172B; --surface: #1E2240; --text: #EEF0FF; --muted: #A9B0D6;
  --brand: #8E9BFF; --on-brand: #14172B; --brand-soft: #262C4A;
  --ok: #6FD3A3; --ok-bg: #1C3A2E; --look: #FFCF66; --look-bg: #3D3216;
  --unsure: #A9B6D9; --unsure-bg: #262C4A; --neutral: #A9B6D9; --neutral-bg: #262C4A;
  --focus: #8E9BFF; --border: #3A4070;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  --bg-art: none; --paper: #2B3157; --star: #FFCF66; --hint-bg: #3D3216; --hint-ink: #FFCF66;
  --kr-bg: #3A2333; --kr-c: #FF819C; --kr-ink: #FFB3C3;
  --sr-bg: #2D2752; --sr-c: #B6A1FF; --sr-ink: #D3C7FF;
  --practice-bg: #1C3A2E; --practice-c: #6FD3A3; --practice-ink: #A6E9C8;
  --guide-bg: #1C3049; --guide-c: #7CC1FF; --guide-ink: #B5DBFF;
  --m-band: #6D76A8; --m-spark: #8E9BFF;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; touch-action: manipulation; overscroll-behavior-x: none; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  background: var(--bg-art, none), var(--bg); background-color: var(--bg); color: var(--text);
  font: 400 var(--fs-base)/var(--lh) var(--font);
  overflow-wrap: anywhere;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
button, input, label, a { font: inherit; color: inherit; touch-action: manipulation; }
img { max-width: 100%; display: block; }
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }
.ico { flex: none; display: block; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- каркас ---------- */
.app { max-width: 32rem; margin: 0 auto; padding: max(var(--gap), env(safe-area-inset-top)) var(--gap) calc(var(--gap) * 2 + env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; gap: .5rem; padding: .25rem 0 1rem; min-width: 0; }
.back-btn {
  flex: none; display: inline-flex; align-items: center; gap: .3rem; min-height: var(--tap-main); padding: .5rem 1.1rem .5rem .7rem;
  border: 0; border-radius: var(--r-pill); background: var(--surface); color: var(--text); box-shadow: var(--shadow);
  font-weight: 800; font-size: 1.125rem; cursor: pointer; touch-action: manipulation; user-select: none;
}
.back-btn .ico { width: 1.75rem; height: 1.75rem; color: var(--brand); }
.topbar:has(.back-btn:not([hidden])) .logo span { display: none; }
.logo { display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.375rem; letter-spacing: -.01em; min-width: 0; }
.logo svg { width: 2.25rem; height: 2.25rem; }
.topbar .spacer { flex: 1; }
.topbar .logo span { white-space: nowrap; }
.teacher-link { display: inline-flex; align-items: center; min-height: var(--tap); max-width: 7rem; padding: 0 .4rem; font-size: .9rem; line-height: 1.15; text-align: right; font-weight: 700; color: var(--muted); text-decoration: none; }
.teacher-link:active { color: var(--brand); }
.topbar:has(.back-btn:not([hidden])) .teacher-link { display: none; } /* лише на головній, щоб не відволікати в роботі */
.icon-btn {
  min-width: var(--tap); min-height: var(--tap); border-radius: var(--r-pill);
  display: inline-grid; place-items: center; border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--brand-soft); color: var(--text); }
.screen { display: grid; grid-template-columns: minmax(0, 1fr); gap: calc(var(--gap) * 1.25); }
.screen-title { font-size: 1.75rem; font-weight: 800; line-height: 1.2; letter-spacing: -.015em; }
.muted { color: var(--muted); }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .6rem;
  min-height: var(--tap); padding: .75rem 1.5rem; width: 100%;
  border-radius: var(--r-pill); border: 2px solid transparent; cursor: pointer;
  font-weight: 800; font-size: var(--fs-base); line-height: 1.25; text-align: center; text-decoration: none;
  transition: background-color .15s, transform .08s, box-shadow .15s;
  touch-action: manipulation; user-select: none;
}
.btn:active, .btn[data-pressed], [data-pressed] { transform: scale(.97); }
.btn[data-pressed] { filter: brightness(.93); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-main { background: var(--brand); color: var(--on-brand); box-shadow: var(--shadow); }
.btn-main:hover { background: color-mix(in srgb, var(--brand) 92%, #000); }
.btn-hero { min-height: var(--tap-main); font-size: 1.25rem; border-radius: var(--r-pill); padding: 1rem 1.5rem; }
.btn-hero .ico { width: 1.9rem; height: 1.9rem; }
.btn-second { background: var(--surface); color: var(--brand); border-color: var(--border); }
.btn-second:hover { background: var(--brand-soft); }
.btn-quiet { background: transparent; color: var(--brand); border-color: transparent; }
.btn-quiet:hover { background: var(--brand-soft); }
.link-btn {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: .25rem .5rem;
  background: none; border: 0; color: var(--brand); font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}

/* ---------- поля ---------- */
.field { display: grid; gap: .4rem; }
.field label { font-weight: 700; }
.input {
  min-height: var(--tap); padding: .75rem 1rem; width: 100%;
  border: 2px solid var(--border); border-radius: var(--r-sm); background: var(--surface); color: var(--text);
  font-family: var(--mono); font-size: 1rem;
}
.input:focus-visible { border-color: var(--focus); outline-offset: 1px; }
.hint { font-size: var(--fs-base); color: var(--muted); }

/* ---------- онбординг ---------- */
.steps-dots { display: flex; gap: .5rem; justify-content: center; }
.steps-dots span { width: .6rem; height: .6rem; border-radius: 50%; background: var(--border); }
.steps-dots span[data-on="true"] { background: var(--brand); width: 1.6rem; border-radius: var(--r-pill); }
.illus { display: grid; place-items: center; padding: 1.25rem; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.illus svg { width: min(100%, 14rem); height: auto; }
.os-list { display: grid; gap: .75rem; padding: 0; margin: 0; list-style: none; }
.os-list li { background: var(--surface); border: 2px solid var(--border); border-radius: var(--r-md); padding: .9rem 1rem; }
.os-list b { display: block; }

/* ---------- головна ---------- */
.mode {
  display: grid; grid-template-columns: 1fr 1fr; gap: .25rem; padding: .25rem;
  background: var(--neutral-bg); border-radius: var(--r-pill); border: 0; margin: 0;
}
.mode legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.mode label {
  position: relative; display: grid; place-items: center; min-height: var(--tap); padding: .4rem .75rem;
  border-radius: var(--r-pill); font-weight: 700; text-align: center; line-height: 1.2; cursor: pointer; color: var(--muted);
}
.mode input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.mode label:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.mode label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.capture-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.queue-line { display: flex; align-items: center; gap: .5rem; color: var(--muted); font-weight: 700; }
.queue-line .dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--look); }
.feed { display: grid; gap: .75rem; padding: 0; margin: 0; list-style: none; }
.feed-empty { text-align: center; color: var(--muted); padding: 1.5rem 1rem; border: 2px dashed var(--border); border-radius: var(--r-lg); }
.feed-item > button {
  width: 100%; display: grid; grid-template-columns: 4rem minmax(0, 1fr) auto; gap: .9rem; align-items: center;
  min-height: 5rem; padding: .6rem; text-align: left; cursor: pointer;
  background: var(--surface); border: 2px solid transparent; border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.feed-item > button:hover { border-color: var(--border); }
.feed-thumb { width: 4rem; height: 4rem; border-radius: var(--r-sm); object-fit: cover; background: var(--neutral-bg); }
.feed-thumb-ph { display: grid; place-items: center; color: var(--muted); }
.feed-main { min-width: 0; display: grid; gap: .1rem; }
.feed-title { font-weight: 700; overflow-wrap: anywhere; } /* робота · варіант · завдання — повністю, у кілька рядків */
.feed-meta { font-size: var(--fs-base); color: var(--muted); }
.status {
  display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .7rem .3rem .45rem;
  border-radius: var(--r-pill); font-size: var(--fs-base); font-weight: 800; white-space: nowrap;
}
.status .ico { width: 1.25rem; height: 1.25rem; }
.status[data-s="all_ok"] { background: var(--ok-bg); color: var(--ok); }
.status[data-s="attention"] { background: var(--look-bg); color: var(--look); }
.status[data-s="unclear"] { background: var(--unsure-bg); color: var(--unsure); }
.status[data-s="error"], .status[data-s="technical_failure"], .status[data-s="offline"], .status[data-s="auth"] { background: var(--neutral-bg); color: var(--neutral); }
.status[data-s="checking"] { background: var(--brand-soft); color: var(--brand); }

/* ---------- перегляд ---------- */
.preview-photo { padding: .5rem; background: var(--surface); border: 2px solid var(--border); border-radius: var(--r-lg); }
.preview-photo img { width: 100%; max-height: 50vh; object-fit: contain; border-radius: var(--r-md); }
.pass-line { display: flex; gap: .6rem; align-items: center; padding: .9rem 1rem; border-radius: var(--r-md); background: var(--ok-bg); color: var(--ok); font-weight: 700; }

/* ---------- картка ---------- */
.card {
  --tone: var(--brand); --tone-bg: var(--brand-soft);
  display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap);
  background: var(--surface); border-radius: var(--r-lg); padding: 1.25rem; box-shadow: var(--shadow);
  border-top: 6px solid var(--tone);
}
.card[data-card="all_ok"] { --tone: var(--ok); --tone-bg: var(--ok-bg); }
.card[data-card="attention"] { --tone: var(--look); --tone-bg: var(--look-bg); }
.card[data-card="unclear"] { --tone: var(--unsure); --tone-bg: var(--unsure-bg); }
.card[data-card="error"], .card[data-card="technical_failure"], .card[data-card="offline"] { --tone: var(--neutral); --tone-bg: var(--neutral-bg); }
.card[data-card="filter_rejected"] { --tone: var(--look); --tone-bg: var(--look-bg); }
.card-head { display: flex; gap: .9rem; align-items: flex-start; }
.card-icon { flex: none; width: 3.5rem; height: 3.5rem; border-radius: var(--r-md); display: grid; place-items: center; background: var(--tone-bg); color: var(--tone); }
.card-icon .ico { width: 2.25rem; height: 2.25rem; }
.card-titles { display: grid; gap: .25rem; min-width: 0; padding-top: .15rem; }
.card-title { font-size: 1.375rem; font-weight: 800; line-height: 1.3; }
.card-sub { color: var(--muted); }
.card-actions { display: grid; gap: .75rem; }
.chip {
  justify-self: start; display: inline-flex; align-items: center; gap: .4rem;
  padding: .25rem .75rem; border-radius: var(--r-pill); background: var(--neutral-bg); color: var(--neutral);
  font-size: var(--fs-base); font-weight: 700;
}
.chip-mono { font-family: var(--mono); font-weight: 600; letter-spacing: .02em; }
.chip-formal { background: var(--ok-bg); color: var(--ok); }
.label { font-size: var(--fs-base); font-weight: 700; color: var(--muted); text-transform: none; }
.task { display: grid; gap: .2rem; }
.task-text { font-weight: 700; font-size: 1.2rem; }
.lead { font-weight: 700; color: var(--muted); font-size: var(--fs-base); margin-bottom: -.4rem; }

.math, code.math {
  font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: var(--fs-math); line-height: 1.35;
  white-space: pre; color: var(--text);
}
.math-scroll { overflow-x: auto; max-width: 100%; padding: .1rem 0 .25rem; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }

.steps { display: grid; grid-template-columns: minmax(0, 1fr); gap: .75rem; padding: 0; margin: 0; list-style: none; }
.step {
  --s: var(--ok); --s-bg: var(--ok-bg);
  display: grid; grid-template-columns: minmax(0, 1fr); gap: .4rem; padding: .85rem 1rem; border-radius: var(--r-md);
  background: var(--bg); border-left: 5px solid var(--s);
}
.step[data-step="attention"] { --s: var(--look); --s-bg: var(--look-bg); background: var(--look-bg); }
.step[data-step="unclear"] { --s: var(--unsure); --s-bg: var(--unsure-bg); background: var(--unsure-bg); }
.step[data-step="model_only"] { --s: var(--ok); }
.step-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.step-badge { display: inline-flex; align-items: center; gap: .4rem; color: var(--s); font-weight: 800; font-size: var(--fs-base); min-width: 0; }
.step-num { flex: none; font-family: var(--mono); color: var(--muted); font-size: var(--fs-base); min-width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--border); }
.step .math { font-size: var(--fs-step); }
.step-body { display: grid; gap: .4rem; }
.step-note { font-weight: 700; color: var(--look); }
.step-comment { font-size: var(--fs-base); }
.step-src { font-size: var(--fs-base); color: var(--muted); }
.step-toggle { justify-self: start; }
.more-steps {
  display: flex; align-items: center; gap: .5rem; padding: .6rem 1rem; border-radius: var(--r-md);
  color: var(--look); background: transparent; border: 2px dashed var(--look); font-weight: 700;
}
.final { display: grid; gap: .1rem; padding-top: .25rem; border-top: 2px solid var(--neutral-bg); }

.example { display: grid; gap: .6rem; padding: 1rem; border-radius: var(--r-md); background: var(--brand-soft); }
.example-title { font-size: 1.15rem; font-weight: 800; }
.example > .math-scroll .math { white-space: pre-wrap; } /* завдання — речення з формулою: переносимо за пробілами */
.solution { display: grid; gap: .4rem; }
.sol-steps { margin: 0; padding-left: 1.5rem; display: grid; gap: .2rem; overflow-x: auto; }
.sol-steps .math, .sol-answer .math { font-size: 1.2rem; }
.sol-answer { font-weight: 700; }

.card-foot { display: grid; gap: .35rem; padding-top: .75rem; border-top: 2px solid var(--neutral-bg); font-size: var(--fs-base); }
.foot-line { display: flex; gap: .45rem; align-items: flex-start; color: var(--muted); }
.foot-line .ico { margin-top: .2rem; }
.foot-line[data-foot="formal"] { color: var(--ok); font-weight: 700; }
.foot-muted { padding-left: 1.6rem; }

.tips { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: .5rem; padding: 0; margin: 0; list-style: none; }
.tip { display: flex; gap: .45rem; align-items: center; padding: .6rem .75rem; border-radius: var(--r-md); background: var(--neutral-bg); color: var(--muted); font-weight: 700; font-size: var(--fs-base); min-width: 0; }
.tip[data-active="true"] { background: var(--look-bg); color: var(--look); outline: 2px solid var(--look); }

.progress { height: .5rem; border-radius: var(--r-pill); background: var(--neutral-bg); overflow: hidden; }
.progress span { display: block; height: 100%; width: 40%; border-radius: inherit; background: var(--brand); animation: slide 1.6s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }
.card[data-card="checking"] .card-icon .pencil-body { animation: write 1.2s ease-in-out infinite alternate; transform-origin: 6px 18px; }
.card[data-card="checking"] .card-icon .pencil-line { stroke-dasharray: 9; animation: line 1.2s ease-in-out infinite alternate; }
@keyframes write { from { transform: rotate(-6deg) translateX(-1px); } to { transform: rotate(4deg) translateX(1px); } }
@keyframes line { from { stroke-dashoffset: 9; } to { stroke-dashoffset: 0; } }

.toast { position: fixed; left: 50%; bottom: calc(1rem + env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: calc(100% - 2rem); padding: .8rem 1.1rem; border-radius: var(--r-md); background: var(--text); color: var(--bg); font-weight: 700; box-shadow: var(--shadow); z-index: 10; }

/* ---------- категорії, роботи, завдання (ітерація 2) ---------- */
[data-cat="kr"] { --cat-bg: var(--kr-bg); --cat-c: var(--kr-c); --cat-ink: var(--kr-ink); }
[data-cat="sr"] { --cat-bg: var(--sr-bg); --cat-c: var(--sr-c); --cat-ink: var(--sr-ink); }
[data-cat="practice"] { --cat-bg: var(--practice-bg); --cat-c: var(--practice-c); --cat-ink: var(--practice-ink); }
[data-cat="guide"] { --cat-bg: var(--guide-bg); --cat-c: var(--guide-c); --cat-ink: var(--guide-ink); }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.tile {
  display: grid; justify-items: start; align-content: start; gap: .35rem; min-height: 10rem; padding: 1rem;
  border: 0; border-radius: var(--r-lg); background: var(--cat-bg); color: var(--text); box-shadow: var(--shadow);
  text-align: left; cursor: pointer; transition: transform .08s; user-select: none; min-width: 0;
}
.tile-art { width: 4.25rem; height: 4.25rem; }
.tile-title { font-size: 1.25rem; font-weight: 800; line-height: 1.15; overflow-wrap: anywhere; }
.tile-count { font-size: var(--fs-base); font-weight: 700; color: var(--cat-ink); }
.tile[data-pressed], .work-card[data-pressed], .row-btn[data-pressed] { filter: brightness(.95); }

.row-btn {
  width: 100%; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: .8rem; align-items: center;
  min-height: var(--tap-main); padding: .6rem 1rem .6rem .6rem; border: 0; border-radius: var(--r-lg);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow); text-align: left; cursor: pointer; user-select: none;
}
.row-ico { display: grid; place-items: center; width: 3rem; height: 3rem; border-radius: var(--r-md); background: var(--cat-bg, var(--brand-soft)); color: var(--cat-ink, var(--brand)); }
.row-main { display: grid; min-width: 0; }
.row-title { font-weight: 800; font-size: 1.2rem; }
.row-sub { color: var(--muted); font-weight: 700; }
.row-arrow { font-size: 2rem; line-height: 1; color: var(--muted); font-weight: 400; }

.screen-head { display: flex; align-items: center; gap: .9rem; padding: 1rem; border-radius: var(--r-lg); background: var(--cat-bg, var(--brand-soft)); min-width: 0; }
.head-art { flex: none; width: 4rem; height: 4rem; }
.head-main { display: grid; gap: .3rem; min-width: 0; }
.screen-sub { color: var(--muted); font-weight: 700; }
.section-title { font-size: 1.3rem; font-weight: 800; }
.instructions { padding: .9rem 1rem; border-radius: var(--r-md); background: var(--surface); border: 2px dashed var(--border); }

.cards { display: grid; gap: .75rem; padding: 0; margin: 0; list-style: none; }
.book { display: grid; gap: .6rem; }
.work-card {
  width: 100%; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .9rem; align-items: start;
  padding: 1rem; border: 0; border-radius: var(--r-lg); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow); text-align: left; cursor: pointer; user-select: none; border-left: 8px solid var(--cat-c);
}
.work-art { width: 3.25rem; height: 3.25rem; padding: .3rem; border-radius: var(--r-md); background: var(--cat-bg); }
.work-main { display: grid; gap: .4rem; min-width: 0; }
.work-title { font-size: 1.25rem; font-weight: 800; line-height: 1.2; }
.work-topic { color: var(--muted); }
.badges { display: flex; flex-wrap: wrap; gap: .4rem; }
.badge {
  display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .75rem; border-radius: var(--r-pill);
  background: var(--cat-bg, var(--brand-soft)); color: var(--cat-ink, var(--brand)); font-weight: 800; font-size: var(--fs-base);
  max-width: 100%; overflow-wrap: anywhere;
}
.badge-hint { background: var(--hint-bg); color: var(--hint-ink); }
.meter { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.meter-bar { flex: 1; height: .9rem; border-radius: var(--r-pill); background: var(--neutral-bg); overflow: hidden; min-width: 3rem; }
.meter-fill { display: block; height: 100%; border-radius: inherit; background: var(--cat-c, var(--brand)); min-width: .9rem; }
.meter-num { font-weight: 800; white-space: nowrap; }

.tasks { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.task-card {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: .8rem; padding: 1.1rem; border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--shadow); border-top: 6px solid var(--cat-c, var(--brand));
}
.task-head { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.task-num {
  flex: none; display: grid; place-items: center; min-width: 3rem; height: 3rem; padding: 0 .4rem; border-radius: var(--r-pill);
  background: var(--cat-bg, var(--brand-soft)); color: var(--cat-ink, var(--brand)); font-weight: 800; font-size: 1.35rem;
}
.task-title { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; font-size: 1.25rem; font-weight: 800; line-height: 1.2; min-width: 0; }
.task-star { display: inline-flex; color: var(--star); }
.task-items { display: grid; gap: .4rem; padding: 0; margin: 0; list-style: none; }
.task-items li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .5rem; align-items: baseline; padding: .4rem .75rem; border-radius: var(--r-md); background: var(--bg); }
.item-label { font-weight: 800; color: var(--muted); }
.task-items .math { font-size: 1.3rem; white-space: pre-wrap; } /* умова — переносимо за пробілами, щоб нічого не ховалося в прокрутку */
.task-status { display: flex; }
button.status { border: 0; min-height: var(--tap); padding: .3rem 1rem .3rem .6rem; cursor: pointer; }
.status[data-s="none"] { background: var(--neutral-bg); color: var(--neutral); }
.hints { display: grid; gap: .5rem; padding: 0; margin: 0; list-style: none; }
.hint-item { display: grid; gap: .2rem; padding: .75rem .9rem; border-radius: var(--r-md); background: var(--hint-bg); border-left: 5px solid var(--star); }
.hint-head { display: inline-flex; align-items: center; gap: .35rem; font-weight: 800; color: var(--hint-ink); }
.hints-done { align-self: center; color: var(--muted); font-weight: 700; }
.task-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); gap: .6rem; }
.task-actions .btn { padding-inline: 1rem; }
/* текстова відповідь тренування (web/answer.js) */
.answers { display: grid; grid-template-columns: minmax(0, 1fr); gap: .6rem; min-width: 0; }
.answer-box { display: grid; grid-template-columns: minmax(0, 1fr); gap: .5rem; min-width: 0; }
.answer-box[hidden] { display: none; }
.answer-label { font-weight: 800; }
.answer-input {
  font-family: var(--font); font-size: max(18px, var(--fs-base)); line-height: var(--lh);
  min-height: 9rem; max-width: 100%; resize: vertical; overflow-wrap: anywhere;
}
.answer-row { display: flex; justify-content: flex-end; }
.answer-count { color: var(--muted); font-size: var(--fs-base); font-variant-numeric: tabular-nums; }
.answer-msg:empty { display: none; }
.answer-msg[data-error] { color: var(--look); background: var(--look-bg); border-radius: var(--r-sm); padding: .6rem .8rem; font-weight: 700; }
.answer-sent { color: var(--ok); font-weight: 800; }
.answers-title { font-size: var(--fs-base); font-weight: 800; color: var(--muted); }
.answers-list { display: grid; gap: .5rem; padding: 0; margin: 0; list-style: none; }
.answer-item { display: grid; gap: .15rem; padding: .6rem .8rem; border-radius: var(--r-md); background: var(--bg); min-width: 0; }
.answer-time { color: var(--muted); font-size: var(--fs-base); }
.answer-text { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; }

.last-try { display: grid; grid-template-columns: minmax(0, 1fr); gap: .6rem; }
.last-try:empty { display: none; }

.card-work { display: flex; align-items: flex-start; gap: .4rem; color: var(--muted); font-weight: 800; }
.card-work .ico { margin-top: .15rem; flex: none; }
.card-work-out { padding: 0 .25rem; }
.mascot { display: flex; align-items: center; gap: .75rem; }
.mascot-svg { flex: none; }
.mascot-say { padding: .6rem 1rem; border-radius: var(--r-lg); background: var(--tone-bg); color: var(--text); font-weight: 800; font-size: 1.25rem; }
.empty { display: grid; justify-items: center; gap: .75rem; padding: 1.5rem 1rem; text-align: center; color: var(--muted); font-weight: 700; border-radius: var(--r-lg); background: var(--surface); }
.empty .mascot-svg { width: 4.5rem; height: 4.5rem; }
.preview-thumb { max-width: 9rem; }
.guide-links { display: grid; gap: .6rem; }
.guide-body { display: grid; gap: .8rem; padding: 1.1rem; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow); }
.guide-h { font-size: 1.25rem; font-weight: 800; }
.guide-pre { margin: 0; padding: .6rem .9rem; border-radius: var(--r-md); background: var(--bg); font-size: 1.25rem; white-space: pre; width: max-content; }
.guide-ul { margin: 0; padding-left: 1.4rem; display: grid; gap: .3rem; }

@media (max-width: 26rem) {
  .feed-item > button { grid-template-columns: 3.5rem minmax(0, 1fr); }
  .feed-thumb { width: 3.5rem; height: 3.5rem; }
  .feed-item .status { grid-column: 2; justify-self: start; }
  .tiles { gap: .6rem; }
  .tile { padding: .85rem; min-height: 9.5rem; }
  .tile-art { width: 3.5rem; height: 3.5rem; }
  .tile-title { font-size: 1.1rem; overflow-wrap: normal; hyphens: auto; }
  .tile { padding: .8rem .7rem; }
  .screen-title { font-size: 1.5rem; }
  .work-card { grid-template-columns: minmax(0, 1fr); }
  .work-art { display: none; }
  .head-art { width: 3rem; height: 3rem; }
}

/* демо */
.demo-grid { display: grid; gap: 1.5rem; }
.demo-block { display: grid; gap: .5rem; }
.demo-block > h2 { font-family: var(--mono); font-size: 1rem; color: var(--muted); }

@media (min-width: 48rem) {
  .app { padding-top: 2rem; }
  .demo-grid { grid-template-columns: repeat(auto-fill, minmax(24rem, 1fr)); align-items: start; max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .progress span { width: 100%; opacity: .35; }
}

/* ---------- вхід кодом (дитячий екран) ---------- */
.screen-code { text-align: center; padding-top: 1rem; }
.screen-code .illus { display: flex; justify-content: center; }
.code-title { font-size: 2rem; }
.input-code {
  min-height: 4.5rem; text-align: center; font-size: 2.25rem; font-weight: 800; letter-spacing: .12em;
  text-transform: uppercase; border-radius: var(--r-md);
}
.input-code::placeholder { color: var(--border); letter-spacing: .12em; }
.code-hint { text-align: center; }
.code-hint[data-error] { color: var(--look); background: var(--look-bg); border-radius: var(--r-sm); padding: .6rem .8rem; font-weight: 700; }

/* ---------- «Вийти» внизу «Моїх робіт»: непомітно й з підтвердженням ---------- */
.lesson { display: grid; gap: .5rem; padding: 1rem; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow); }
.lesson-on { font-weight: 800; font-size: 1.15rem; }
.app-download { justify-self: center; margin-top: 1.5rem; width: auto; }
.logout { margin-top: 2.5rem; display: grid; gap: .5rem; justify-items: center; }
.logout .btn-small { width: auto; min-height: var(--tap); font-size: 1rem; font-weight: 700; color: var(--muted); }
.logout-row { display: grid; gap: .5rem; width: 100%; }
.logout .hint { text-align: center; }

/* ---------- «Надіслати всі фото»: мініатюри з хрестиком ---------- */
.batch-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); gap: .6rem; }
.batch-item { position: relative; border-radius: var(--r-sm); overflow: hidden; background: var(--paper); border: 2px solid var(--border); aspect-ratio: 3 / 4; }
.batch-item[data-filter]:not([data-filter="pass"]) { border-color: var(--look); }
.batch-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.batch-warn { position: absolute; left: .3rem; bottom: .3rem; padding: .1rem .45rem; border-radius: var(--r-pill); background: var(--look-bg); color: var(--look); font-size: .85rem; font-weight: 800; }
.batch-remove {
  position: absolute; top: .25rem; right: .25rem; width: var(--tap); height: var(--tap); border-radius: 50%;
  border: 0; background: var(--surface); color: var(--text); font-size: 1.25rem; font-weight: 800; box-shadow: var(--shadow); cursor: pointer;
}
.batch-status { text-align: center; font-weight: 700; min-height: 1.5em; }
