:root {
  --bg: #f6f5f2; --card: #ffffff; --card2: #f1efea; --line: #e4e1da; --text: #1d1d22; --muted: #6d6a73;
  --red: #d4213d; --red2: #f4d9de; --ok: #148a5a; --ok2: #d9f2e6; --bad: #c62a3a; --bad2: #fbe1e4; --warn: #a66a00; --warn2: #fbefd6;
  --radius: 16px; --sans: 'Inter', -apple-system, system-ui, 'Segoe UI', Roboto, sans-serif; --serif: 'Lora', Georgia, serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121319; --card: #1b1c24; --card2: #23252f; --line: #2f313d; --text: #ecebf0; --muted: #9a98a6;
    --red: #ff5a72; --red2: #3a1d25; --ok: #3fd391; --ok2: #15322a; --bad: #ff6f7e; --bad2: #3b1c22; --warn: #f2b84b; --warn2: #3a2d14; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 16px; }
body { min-height: 100vh; min-height: 100dvh; overflow-x: hidden; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, select, textarea { font: inherit; color: var(--text); }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
.hidden { display: none !important; }
#app { max-width: 760px; margin: 0 auto; padding: 0 16px 120px; }

.top { position: sticky; top: 0; z-index: 20; margin: 0 -16px; padding: 10px 16px 8px; padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line); }
.top-row { display: flex; align-items: center; gap: 10px; min-height: 36px; }
.logo { font-weight: 800; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.logo b { color: var(--red); }
.spacer { flex: 1; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; background: var(--card2);
  font-size: 13px; font-weight: 600; white-space: nowrap; }
.chip.red { background: var(--red); color: #fff; }
.chip.ok { background: var(--ok2); color: var(--ok); }
.chip.bad { background: var(--bad2); color: var(--bad); }
.chip.warn { background: var(--warn2); color: var(--warn); }
.iconbtn { width: 36px; height: 36px; border-radius: 11px; background: var(--card2); display: grid; place-items: center; font-size: 17px; flex: none; }
.bar { height: 6px; border-radius: 99px; background: var(--card2); overflow: hidden; margin-top: 8px; }
.bar > span { display: block; height: 100%; background: var(--red); border-radius: 99px; transition: width .4s; }
.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; }
.card h3 { font-size: 16px; margin-bottom: 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hello { margin: 20px 2px 0; font-size: 26px; font-weight: 800; }
.hello span { color: var(--red); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 18px; border-radius: 14px;
  background: var(--red); color: #fff; font-weight: 700; font-size: 16px; width: 100%; }
.btn.ghost { background: var(--card2); color: var(--text); }
.btn.small { width: auto; padding: 9px 14px; font-size: 14px; border-radius: 11px; }
.btn:disabled { opacity: .45; }
.row { display: flex; gap: 10px; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 > * { min-width: 0; }
.link { color: var(--red); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

.sec { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 14px; border-radius: 16px;
  background: var(--card); border: 1px solid var(--line); margin-top: 10px; }
.sec .ic { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 22px; background: var(--red2); flex: none; }
.sec .t { flex: 1; min-width: 0; }
.sec b { display: block; font-size: 17px; }
.sec .pct { font-weight: 800; font-size: 20px; }

.task { margin-top: 16px; }
.task h2 { font-size: 15px; font-weight: 700; color: var(--red); text-transform: uppercase; letter-spacing: .04em; }
.instr { font-family: var(--serif); font-size: 17px; line-height: 1.45; margin-top: 6px; }
.instr-ru { font-size: 14px; color: var(--muted); margin-top: 4px; }
.passage { font-family: var(--serif); font-size: 17px; line-height: 1.6; white-space: pre-wrap; background: var(--card2); border-radius: 14px; padding: 14px; margin-top: 10px; }
.gap { display: inline-block; min-width: 34px; padding: 0 7px; border-radius: 8px; background: var(--red); color: #fff; font-family: var(--sans);
  font-size: 13px; font-weight: 700; text-align: center; line-height: 22px; vertical-align: 1px; }
.gap.filled { background: var(--ok2); color: var(--ok); }
.opts-list { margin-top: 10px; display: grid; gap: 6px; }
.opts-list div { font-family: var(--serif); font-size: 16px; line-height: 1.4; padding: 8px 10px; border-radius: 10px; background: var(--card2); }
.opts-list b { font-family: var(--sans); color: var(--red); margin-right: 6px; }
.item { padding: 12px 0; border-top: 1px solid var(--line); }
.item:first-of-type { border-top: 0; }
.item .q { font-family: var(--serif); font-size: 17px; line-height: 1.45; margin-bottom: 8px; }
.item .num { font-family: var(--sans); font-weight: 800; color: var(--red); margin-right: 6px; }
.choices { display: grid; gap: 6px; }
.choice { display: flex; gap: 10px; align-items: flex-start; text-align: left; width: 100%; padding: 10px 12px; border-radius: 12px; background: var(--card2);
  font-family: var(--serif); font-size: 16px; line-height: 1.4; border: 2px solid transparent; }
.choice .k { font-family: var(--sans); font-weight: 800; color: var(--muted); }
.choice.on { border-color: var(--red); background: var(--red2); }
.choice.on .k { color: var(--red); }
.inline-choices { display: flex; flex-wrap: wrap; gap: 6px; }
.inline-choices .choice { width: auto; }
.tf { display: flex; gap: 8px; }
.tf button { flex: 1; padding: 11px; border-radius: 12px; background: var(--card2); font-weight: 700; border: 2px solid transparent; }
.tf button.on { border-color: var(--red); background: var(--red2); color: var(--red); }
select, .inp { width: 100%; height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); padding: 0 12px; font-size: 16px; }
.inp:focus, select:focus, textarea:focus { outline: 2px solid var(--red); border-color: transparent; }
textarea { width: 100%; min-height: 300px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); padding: 14px;
  font-family: var(--serif); font-size: 17px; line-height: 1.55; resize: vertical; }

.player { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; background: var(--card2); margin-top: 10px; }
.player button.play { width: 48px; height: 48px; border-radius: 50%; background: var(--red); color: #fff; font-size: 18px; flex: none; }
.player .ptrack { flex: 1; min-width: 0; }
.player .pbar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.player .pbar span { display: block; height: 100%; background: var(--red); width: 0; }

.submit { position: sticky; bottom: 0; z-index: 10; margin: 18px -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, var(--bg) 35%); }

.score-hero { text-align: center; padding: 24px 0 6px; }
.score-hero .big { font-size: 52px; font-weight: 800; letter-spacing: -.03em; }
.rv { padding: 12px 0; border-top: 1px solid var(--line); }
.rv .mark { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; font-weight: 800; margin-right: 6px; font-size: 14px; }
.rv .mark.ok { background: var(--ok2); color: var(--ok); }
.rv .mark.no { background: var(--bad2); color: var(--bad); }
.rv .ans { font-size: 14px; margin-top: 6px; }
.rv .why { font-size: 14px; margin-top: 6px; padding: 8px 10px; border-radius: 10px; background: var(--card2); line-height: 1.45; }
.rv .said { font-family: var(--serif); font-style: italic; font-size: 15px; margin-top: 6px; color: var(--muted); }
details { margin-top: 10px; }
details summary { cursor: pointer; font-weight: 600; color: var(--red); }
details pre { white-space: pre-wrap; font-family: var(--serif); font-size: 16px; line-height: 1.5; margin: 8px 0 0; }

.login { min-height: 88vh; display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.login .big { font-size: 44px; font-weight: 800; line-height: 1.05; letter-spacing: -.03em; }
.login .big b { color: var(--red); }
.flag { display: inline-block; width: 40px; height: 26px; border-radius: 5px; overflow: hidden; vertical-align: middle; box-shadow: 0 0 0 1px var(--line); }
.flag i { display: block; height: 50%; background: #fff; }
.flag i + i { background: #d4213d; }

.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 6px 4px; position: sticky; top: 0; background: var(--card); }
.tbl td { padding: 8px 4px; border-top: 1px solid var(--line); vertical-align: top; }
.scroll { max-height: 420px; overflow: auto; }
.cell { display: inline-block; min-width: 38px; text-align: center; padding: 3px 6px; border-radius: 8px; background: var(--card2); font-weight: 600; font-size: 13px; }
.cell.ok { background: var(--ok2); color: var(--ok); }
.cell.bad { background: var(--bad2); color: var(--bad); }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.field label { font-size: 13px; color: var(--muted); }
.range { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.range input { flex: 1; accent-color: var(--red); }
.range b { width: 34px; text-align: right; }
.rec { display: flex; gap: 10px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.rec .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--red); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.phr { display: grid; gap: 4px; margin-top: 8px; }
.phr div { font-size: 14px; padding: 6px 8px; border-radius: 8px; background: var(--card2); }
.phr b { font-family: var(--serif); font-weight: 600; }
.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
  padding: 12px 18px; border-radius: 14px; background: var(--text); color: var(--bg); font-weight: 600; max-width: 90vw; text-align: center; }
.speak-img { width: 100%; border-radius: 14px; margin-top: 10px; background: #fff; }
.timer { font-variant-numeric: tabular-nums; }
