:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --card2: #f1f4fa;
  --line: #e2e7f1;
  --text: #182033;
  --muted: #66708a;
  --brand: #1f3fbf;
  --math: #2563eb; --math-soft: #e6eeff;
  --phys: #f5a300; --phys-ink: #8a5b00; --phys-soft: #fff4d6;
  --eng: #e5344d; --eng-soft: #ffe7ea;
  --ok: #16a34a; --ok-soft: #e3f7ea;
  --bad: #dc2626; --bad-soft: #fde8e8;
  --gold: #f5b301;
  --radius: 18px;
  --head: 'Unbounded', 'Manrope', system-ui, sans-serif;
  --body: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --c: var(--brand); --c-soft: #e8ecff; --c-ink: var(--brand);
}
.s-math { --c: var(--math); --c-soft: var(--math-soft); --c-ink: var(--math); }
.s-phys { --c: var(--phys); --c-soft: var(--phys-soft); --c-ink: var(--phys-ink); }
.s-eng { --c: var(--eng); --c-soft: var(--eng-soft); --c-ink: var(--eng); }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--body); }
body { min-height: 100vh; min-height: 100dvh; overflow-x: hidden; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, select { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--head); margin: 0; letter-spacing: .01em; }
.hidden { display: none !important; }
#app { max-width: 760px; margin: 0 auto; padding: 0 16px 120px; position: relative; z-index: 1; }

/* мягкие цветные пятна на фоне: синий, жёлтый, зелёный */
#blobs { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
#blobs i { position: absolute; width: 60vmax; height: 60vmax; border-radius: 50%; filter: blur(60px); opacity: .22; }
#blobs i:nth-child(1) { background: #3b82f6; top: -30vmax; right: -25vmax; }
#blobs i:nth-child(2) { background: #facc15; bottom: -35vmax; left: -25vmax; }
#blobs i:nth-child(3) { background: #22c55e; bottom: -40vmax; right: -30vmax; opacity: .14; }

/* шапка: закреплена и низкая */
.top { position: sticky; top: 0; z-index: 20; margin: 0 -16px; padding: 8px 16px 6px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: rgba(255, 255, 255, .9); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line); }
.top-row { display: flex; align-items: center; gap: 8px; min-height: 36px; }
.logo { font-family: var(--head); font-weight: 800; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.logo b { color: var(--c); }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px;
  background: var(--card2); border: 1px solid var(--line); font-size: 13px; font-weight: 700; white-space: nowrap; }
.chip.c { background: var(--c); border-color: var(--c); color: #fff; }
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.no { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.chip.timer { font-variant-numeric: tabular-nums; }
.chip.timer.low { background: var(--bad); color: #fff; border-color: var(--bad); }
.spacer { flex: 1; }
.iconbtn { width: 36px; height: 36px; border-radius: 12px; background: var(--card2); border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 17px; flex: none; }
.bar { height: 6px; border-radius: 99px; background: var(--card2); overflow: hidden; margin-top: 6px; }
.bar > span { display: block; height: 100%; border-radius: 99px; background: var(--c); transition: width .5s ease; }
.bar.tri > span { background: linear-gradient(90deg, var(--math), var(--gold), var(--ok)); }
.top small { color: var(--muted); font-size: 12px; }

/* карточки */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-top: 14px;
  box-shadow: 0 1px 2px rgba(20, 30, 60, .04); }
.card h3 { font-size: 15px; margin-bottom: 10px; }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mini { background: var(--card2); border-radius: 14px; padding: 10px 12px; }
.mini b { display: block; font-size: 20px; font-family: var(--head); }
.mini small { color: var(--muted); font-size: 12px; }
.hello { font-size: 24px; margin: 18px 0 2px; }
.hello span { color: var(--brand); }
.btn { display: block; width: 100%; padding: 13px 16px; border-radius: 14px; background: var(--c); color: #fff;
  font-weight: 800; font-size: 16px; text-align: center; }
.btn:disabled { opacity: .45; }
.btn.ghost { background: var(--card2); color: var(--text); border: 1px solid var(--line); }
.btn.small { padding: 8px 12px; font-size: 14px; width: auto; display: inline-block; }
.link { text-decoration: underline; }

/* предметы на главной */
.subj { display: block; width: 100%; text-align: left; margin-top: 14px; border-radius: var(--radius); padding: 16px;
  background: var(--card); border: 1px solid var(--line); border-left: 8px solid var(--c); position: relative; }
.subj h2 { font-size: 19px; color: var(--c-ink); }
.subj .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.subj .pct { position: absolute; right: 16px; top: 14px; text-align: right; }
.subj .pct b { font-family: var(--head); font-size: 24px; color: var(--c-ink); display: block; }
.subj .pct small { color: var(--muted); font-size: 11px; }
.subj .bar { margin-top: 12px; }

/* прогноз */
.predict { background: var(--c-soft); border-radius: var(--radius); padding: 16px; margin-top: 14px; }
.predict .big { font-family: var(--head); font-size: 40px; font-weight: 800; color: var(--c-ink); line-height: 1.1; }
.predict .range { font-weight: 700; color: var(--c-ink); }
.gauge { height: 14px; border-radius: 99px; background: rgba(255, 255, 255, .8); position: relative; margin: 12px 0 4px; overflow: hidden; }
.gauge .rng { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--c) 35%, transparent); }
.gauge .pt { position: absolute; top: -2px; bottom: -2px; width: 4px; border-radius: 2px; background: var(--c); }
.gauge .pass { position: absolute; top: 0; bottom: 0; left: 30%; width: 2px; background: rgba(0, 0, 0, .25); }

/* список тем и экзаменов */
.tlist { display: flex; flex-direction: column; gap: 8px; }
.tlist button { display: flex; align-items: center; gap: 10px; text-align: left; padding: 11px 12px; border-radius: 14px;
  background: var(--card2); border: 1px solid transparent; }
.tlist button:active { border-color: var(--c); }
.tlist .tn { flex: 1; min-width: 0; }
.tlist .tn b { display: block; font-size: 14px; }
.tlist .tn small { color: var(--muted); font-size: 12px; }
.tlist .acc { font-weight: 800; font-size: 14px; min-width: 44px; text-align: right; }
.tlist .bar { margin-top: 5px; height: 4px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; }
.tabs .chip.on { background: var(--c); color: #fff; border-color: var(--c); }

/* задание */
.qtag { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 12px 0 8px; font-size: 13px; font-weight: 700; color: var(--muted); }
.qtag .rep { color: var(--c-ink); background: var(--c-soft); border-radius: 99px; padding: 3px 9px; }
.zbar { display: flex; gap: 6px; justify-content: flex-end; align-items: center; margin: 2px 0 4px; }
.zbar button { min-width: 34px; height: 30px; padding: 0 8px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); font-size: 14px; font-weight: 800; }
.zbar .zv { font-size: 12px; color: var(--muted); min-width: 38px; text-align: center; }
.pz { overflow: auto; border-radius: 12px; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); background: #fff; margin-bottom: 8px; max-height: 78vh; }
.pz.zoomed { touch-action: pan-x pan-y; }
.paper { position: relative; width: 100%; }
.paper img { display: block; width: 100%; height: auto; }
.paper .w { position: absolute; border-radius: 3px; cursor: pointer; }
.paper .w.on { background: rgba(229, 52, 77, .25); outline: 1px solid var(--eng); }
.ctxlabel { font-size: 12px; color: var(--muted); margin: 6px 0 4px; font-weight: 700; }
.ask { background: var(--c-soft); border-radius: 12px; padding: 10px 12px; margin: 8px 0; font-weight: 700; font-size: 14px; color: var(--c-ink); }
audio { width: 100%; margin: 6px 0 8px; }
.audiobox { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; margin: 6px 0 10px; }
.audiobox small { color: var(--muted); }

/* поля ответа */
.answers { position: sticky; bottom: 0; z-index: 15; margin: 10px -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
.fields { display: flex; flex-direction: column; gap: 8px; max-height: 40vh; overflow: auto; }
.fields.many { display: grid; grid-template-columns: 1fr 1fr; }
.fld { display: flex; align-items: center; gap: 8px; }
.fld label { font-weight: 800; font-size: 14px; white-space: nowrap; max-width: 45%; overflow: hidden; text-overflow: ellipsis; }
.fld input { flex: 1; min-width: 0; padding: 11px 12px; border-radius: 12px; border: 2px solid var(--line); background: #fff; font-size: 17px; }
.fld input:focus { outline: none; border-color: var(--c); }
.fld .unit { font-weight: 700; color: var(--muted); font-size: 14px; white-space: nowrap; }
.fld.ok input { border-color: var(--ok); background: var(--ok-soft); }
.fld.no input { border-color: var(--bad); background: var(--bad-soft); }
.fld.mid input { border-color: var(--gold); background: var(--phys-soft); }
.fld .mk { font-weight: 900; width: 18px; text-align: center; }
.fld.ok .mk { color: var(--ok); } .fld.no .mk { color: var(--bad); } .fld.mid .mk { color: var(--phys-ink); }
.keys { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 2px; scrollbar-width: none; }
.keys button { flex: none; min-width: 40px; height: 36px; border-radius: 10px; background: var(--card2); border: 1px solid var(--line); font-weight: 800; font-size: 16px; padding: 0 10px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 6px; }
.feedback { margin-top: 10px; border-radius: 14px; padding: 12px; font-weight: 700; }
.feedback.ok { background: var(--ok-soft); color: var(--ok); }
.feedback.no { background: var(--bad-soft); color: var(--bad); }
.feedback.mid { background: var(--phys-soft); color: var(--phys-ink); }
.feedback .acts { display: flex; gap: 8px; margin-top: 10px; }
.feedback .acts .btn { flex: 1; }
.keyrow { font-size: 14px; color: var(--text); font-weight: 600; margin-top: 4px; }
.keyrow b { color: var(--ok); }
.selfcheck { background: var(--card); border: 1px dashed var(--gold); border-radius: 12px; padding: 10px; margin-top: 8px; color: var(--text); font-weight: 600; font-size: 14px; }
.selfcheck .acts .btn { font-size: 14px; padding: 9px; }

/* решение */
.expl { line-height: 1.6; font-size: 15px; }
.expl p { margin: 0 0 8px; }
.expl ul { margin: 0 0 8px; padding-left: 20px; }
.expl .katex { font-size: 1.05em; }
.expl .tw { cursor: pointer; border-radius: 4px; }
.expl .tw.on { background: rgba(229, 52, 77, .2); }
.zas { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 8px; background: #fff; }
.zas img { display: block; width: 100%; height: auto; }
details.sol { margin-top: 10px; }
details.sol summary { cursor: pointer; font-weight: 800; color: var(--c-ink); padding: 8px 0; }

/* итоги, ошибки */
.result-hero { text-align: center; padding: 22px 10px 6px; }
.score-big { font-family: var(--head); font-size: 40px; font-weight: 800; color: var(--c-ink); }
.rlist { display: flex; flex-direction: column; gap: 6px; }
.rlist button { display: flex; align-items: center; gap: 10px; text-align: left; padding: 10px 12px; border-radius: 12px; background: var(--card2); }
.mark { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; flex: none; }
.mark.ok { background: var(--ok-soft); color: var(--ok); }
.mark.no { background: var(--bad-soft); color: var(--bad); }
.mark.mid { background: var(--phys-soft); color: var(--phys-ink); }
.yours { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.yours .r { display: flex; gap: 8px; align-items: baseline; font-size: 14px; flex-wrap: wrap; }

/* значки */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.badge { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; border-radius: 14px;
  background: var(--card2); font-size: 11.5px; font-weight: 700; text-align: center; color: var(--muted); filter: grayscale(1); opacity: .7; }
.badge .i { font-size: 26px; }
.badge.got { filter: none; opacity: 1; color: var(--text); background: linear-gradient(160deg, #fff7d6, #e7f0ff); border: 1px solid #f3dc8a; }
.bbar { width: 80%; height: 4px; background: var(--line); border-radius: 9px; overflow: hidden; }
.bbar span { display: block; height: 100%; background: var(--brand); }
.bdone { color: var(--ok); font-weight: 900; }
.goal { padding: 10px 0; border-bottom: 1px solid var(--line); }
.goal:last-child { border-bottom: 0; }
.goal.done b { color: var(--ok); }

/* нижняя шторка */
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; max-height: 70vh; overflow: auto; background: #fff;
  border-radius: 20px 20px 0 0; padding: 16px 18px calc(18px + env(safe-area-inset-bottom)); box-shadow: 0 -10px 40px rgba(20, 30, 60, .18);
  max-width: 760px; margin: 0 auto; }
.sheet .word { font-family: var(--head); font-size: 20px; }
.sheet .pos { margin-top: 10px; color: var(--muted); font-size: 13px; font-weight: 700; }
.sheet ol { margin: 4px 0 0; padding-left: 20px; }
.counter { display: inline-flex; gap: 4px; vertical-align: middle; margin-left: 6px; }
.counter i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.counter i.on { background: var(--eng); }
.warn { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--phys-soft); color: var(--phys-ink); font-weight: 700; }
.warn.block { background: var(--bad-soft); color: var(--bad); }
.phrase { font-size: 16px; margin-top: 6px; }
.toast { position: fixed; left: 50%; top: 18%; transform: translateX(-50%); z-index: 60; background: var(--text); color: #fff;
  padding: 12px 18px; border-radius: 14px; font-weight: 800; animation: pop 1.6s ease forwards; max-width: 90vw; text-align: center; }
@keyframes pop { 0% { opacity: 0; transform: translate(-50%, 10px); } 12% { opacity: 1; transform: translate(-50%, 0); } 85% { opacity: 1; } 100% { opacity: 0; } }
.confetti { position: fixed; z-index: 55; font-size: 22px; pointer-events: none; animation: fly 1.8s ease-out forwards; }
@keyframes fly { to { transform: translate(var(--dx), -60vh) rotate(var(--rot)); opacity: 0; } }

/* таблицы: своя прокрутка, шапка закреплена */
.scroll { max-height: 320px; overflow: auto; border-radius: 10px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { position: sticky; top: 0; background: var(--card2); text-align: left; padding: 7px 8px; font-weight: 800; }
.tbl td { padding: 7px 8px; border-top: 1px solid var(--line); }
.field { margin-top: 10px; }
.field label { display: block; font-size: 13px; margin-bottom: 4px; }
.field input, .field select { width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.wlist { display: flex; flex-direction: column; }
.wi { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }

/* вход и знакомство */
.login { min-height: 80vh; display: flex; flex-direction: column; justify-content: center; gap: 14px; max-width: 380px; margin: 0 auto; }
.login .big { font-family: var(--head); font-size: 34px; font-weight: 800; line-height: 1.15; }
.login .big b { color: var(--brand); }
.login input { padding: 14px; border-radius: 14px; border: 2px solid var(--line); background: #fff; font-size: 17px; }
.tri3 { display: flex; gap: 6px; }
.tri3 i { flex: 1; height: 6px; border-radius: 9px; }
.intro ol { padding-left: 20px; line-height: 1.55; }
.intro li { margin-bottom: 8px; }
.resume { border: 2px solid var(--c); }
@media (max-width: 420px) { .fields.many { grid-template-columns: 1fr 1fr; } .subj .pct b { font-size: 20px; } .hello { font-size: 21px; } }
.fld { min-width: 0; }
.fields.many { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
#app:has(.answers) { padding-bottom: 0; }
.answers.done { position: static; margin-bottom: 24px; }
