/* Layout: one centered column (max 760px); exam view adds a sticky top bar with timer. */
:root {
  --bg: #EEF3F4;
  --surface: #FFFFFF;
  --ink: #0E2830;
  --muted: #587079;
  --line: #D3DFE3;
  --accent: #0B6B80;       /* steppe sky, deepened */
  --accent-ink: #FFFFFF;
  --sun: #E3A21A;          /* gold of the flag, used sparingly */
  --sun-soft: #FBF0D4;
  --good: #1E7F4F;
  --good-soft: #E1F2E8;
  --bad: #B83A33;
  --bad-soft: #F8E3E1;
  --font-display: "Unbounded", "Arial Black", system-ui, sans-serif;
  --font-body: "PT Sans", "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0A1A1F; --surface: #11262D; --ink: #E4EFF1; --muted: #8FA7AF; --line: #22404A;
    --accent: #4BBFD6; --accent-ink: #062027; --sun: #F0B93A; --sun-soft: #3A2F12;
    --good: #4CC28A; --good-soft: #12352A; --bad: #F07A72; --bad-soft: #3D1C1A;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0A1A1F; --surface: #11262D; --ink: #E4EFF1; --muted: #8FA7AF; --line: #22404A;
  --accent: #4BBFD6; --accent-ink: #062027; --sun: #F0B93A; --sun-soft: #3A2F12;
  --good: #4CC28A; --good-soft: #12352A; --bad: #F07A72; --bad-soft: #3D1C1A;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding-block: 20px 56px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 28px;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; text-wrap: balance; margin: 0; line-height: 1.2; }
h1 { font-size: clamp(1.6rem, 4.5vw, 2.3rem); letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; font-weight: 500; }
p { margin: 0; }
.muted { color: var(--muted); }
.eyebrow { font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.num { font-variant-numeric: tabular-nums; }

/* Top bar */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; color: var(--ink); background: none; border: 0; padding: 0; cursor: pointer; font: inherit; }
.brand b { font-family: var(--font-display); font-size: 1.35rem; color: var(--accent); }
.brand span { font-size: 0.9rem; color: var(--muted); }
.lang { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface); }
.lang button { border: 0; background: none; color: var(--muted); font: 700 0.8rem var(--font-body); letter-spacing: 0.05em; padding: 7px 12px; cursor: pointer; }
.lang button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 700 1rem var(--font-body); padding: 12px 20px; border-radius: var(--r);
  border: 1px solid transparent; cursor: pointer; text-align: center;
  background: var(--accent); color: var(--accent-ink);
}
.btn:hover { filter: brightness(1.07); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; filter: none; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--accent); }
.btn.sun { background: var(--sun); color: #2A1E00; }
.btn.small { padding: 8px 14px; font-size: 0.9rem; }
.linkbtn { background: none; border: 0; color: var(--accent); font: 700 0.95rem var(--font-body); cursor: pointer; padding: 4px 0; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; border-radius: 6px; }

/* Hero */
.hero { display: flex; flex-direction: column; gap: 12px; padding-top: 8px; }
.hero p { max-width: 58ch; color: var(--muted); font-size: 1.05rem; }
.stats { display: flex; flex-wrap: wrap; gap: 8px 28px; padding-top: 6px; }
.stat b { font-family: var(--font-display); font-size: 1.4rem; display: block; line-height: 1.1; }
.stat span { font-size: 0.85rem; color: var(--muted); }

/* Feature: mock exam (the one bordered, colored block on home) */
.exam-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 22px; display: grid; gap: 16px; grid-template-columns: 1fr auto; align-items: center;
}
.exam-card .score { font-family: var(--font-display); font-size: 2.6rem; color: var(--sun); line-height: 1; text-align: right; }
.exam-card .score small { display: block; font-family: var(--font-body); font-size: 0.8rem; color: var(--muted); font-weight: 400; }
.exam-card .actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.exam-card p { color: var(--muted); }
.note { font-size: 0.88rem; color: var(--muted); }

/* Subject list */
.section { display: flex; flex-direction: column; gap: 12px; }
.subjects { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.subj {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; align-items: center;
  padding: 16px 4px; border-bottom: 1px solid var(--line);
  background: none; border-left: 0; border-right: 0; border-top: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; width: 100%;
}
.subj:hover h3 { color: var(--accent); }
.subj .meta { font-size: 0.88rem; color: var(--muted); }
.subj .tag { font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 700; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); margin-left: 8px; vertical-align: 2px; }
.subj .tag.profile { border-color: var(--sun); color: var(--ink); background: var(--sun-soft); }
.meter { width: 96px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); }
.subj .right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 0.8rem; color: var(--muted); }

.mist { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; justify-content: space-between; }

/* Subject page */
.topics { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.topic { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 4px; border-bottom: 1px solid var(--line); }
.topic div { min-width: 0; }
.topic .meta { font-size: 0.85rem; color: var(--muted); }

/* Quiz */
.qbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--bg);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-block: 10px; border-bottom: 1px solid var(--line);
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
.qbar .where { min-width: 0; display: flex; flex-direction: column; }
.qbar .where b { font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qbar .where span { font-size: 0.82rem; color: var(--muted); }
.timer { font-family: var(--font-mono); font-size: 1.05rem; padding: 6px 10px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); }
.timer.low { color: var(--bad); border-color: var(--bad); }
.progress { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width .25s; }

.palette { display: flex; flex-wrap: wrap; gap: 6px; }
.palette button {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); font: 700 0.8rem var(--font-body); cursor: pointer; font-variant-numeric: tabular-nums;
}
.palette button.done { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.palette button.cur { outline: 2px solid var(--sun); outline-offset: 1px; }

.context { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; }
.context .eyebrow { margin-bottom: 6px; }
.context p { white-space: pre-line; max-width: 68ch; }
.context details summary { cursor: pointer; font-weight: 700; color: var(--accent); }

.qtext { font-size: 1.2rem; line-height: 1.45; font-weight: 700; max-width: 62ch; }
.hint { font-size: 0.85rem; color: var(--muted); margin-top: 6px; }
.hint.multi { color: var(--ink); background: var(--sun-soft); display: inline-block; padding: 2px 8px; border-radius: 6px; }

.options { display: flex; flex-direction: column; gap: 10px; }
.opt {
  display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: center;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface);
  color: var(--ink); font: inherit; text-align: left; cursor: pointer; width: 100%;
}
.opt:hover:not([disabled]) { border-color: var(--accent); }
.opt[disabled] { cursor: default; }
/* Answer-sheet bubble, like the ENT бланк */
.bubble {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line);
  display: grid; place-items: center; font: 700 0.85rem var(--font-mono); color: var(--muted);
}
.opt.multi .bubble { border-radius: 8px; }
.opt.sel { border-color: var(--accent); }
.opt.sel .bubble { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.opt.right { border-color: var(--good); background: var(--good-soft); }
.opt.right .bubble { background: var(--good); border-color: var(--good); color: var(--surface); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .bubble { background: var(--bad); border-color: var(--bad); color: var(--surface); }

.verdict { border-radius: var(--r); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--line); background: var(--surface); }
.verdict b { font-family: var(--font-display); font-size: 1rem; font-weight: 500; }
.verdict.ok b { color: var(--good); }
.verdict.no b { color: var(--bad); }
.verdict.part b { color: var(--sun); }
.verdict p { max-width: 68ch; }

.qnav { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; }
.qnav .grow { display: flex; gap: 10px; flex-wrap: wrap; }

.confirm { background: var(--sun-soft); border: 1px solid var(--sun); border-radius: var(--r); padding: 14px 16px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }

/* Result */
.result-head { display: flex; flex-direction: column; gap: 8px; }
.bigscore { font-family: var(--font-display); font-size: clamp(2.6rem, 9vw, 3.6rem); line-height: 1; color: var(--accent); }
.bigscore small { font-size: 0.4em; color: var(--muted); font-weight: 500; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
th { font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
td.r, th.r { text-align: right; }
.review { display: flex; flex-direction: column; gap: 8px; }
.review details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.review summary { cursor: pointer; display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; }
.review summary .mark { font: 700 0.8rem var(--font-mono); padding: 2px 6px; border-radius: 6px; }
.mark.ok { background: var(--good-soft); color: var(--good); }
.mark.no { background: var(--bad-soft); color: var(--bad); }
.mark.part { background: var(--sun-soft); color: var(--ink); }
.review .body { padding-top: 10px; display: flex; flex-direction: column; gap: 6px; font-size: 0.95rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.foot { font-size: 0.85rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 16px; display: flex; flex-direction: column; gap: 4px; }

@media (max-width: 520px) {
  body { font-size: 16px; }
  .exam-card { grid-template-columns: 1fr; }
  .exam-card .score { text-align: left; }
  .qtext { font-size: 1.1rem; }
  .meter { width: 64px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Matching tasks: left items A/B, each with its own numbered option list */
.match { display: flex; flex-direction: column; gap: 18px; }
.mrow { display: flex; flex-direction: column; gap: 8px; }
.mleft { display: flex; align-items: center; gap: 12px; font-weight: 700; }
.mleft .bubble { border-color: var(--sun); color: var(--ink); background: var(--sun-soft); }
.mrow .options { padding-left: 46px; gap: 6px; }
.opt.compact { padding: 8px 12px; grid-template-columns: 28px 1fr; font-size: 0.95rem; }
.opt.compact .bubble { width: 28px; height: 28px; font-size: 0.78rem; }
@media (max-width: 520px) { .mrow .options { padding-left: 0; } }

.palsubj { flex-basis: 100%; font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 700; padding-top: 6px; }
.palsubj:first-child { padding-top: 0; }
.secno { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line); font: 700 0.75rem var(--font-mono); color: var(--muted); margin-right: 10px; vertical-align: 2px; }
.note.wide { grid-column: 1 / -1; }

/* Images in tasks (maps, photos, charts) and the official-sample badge */
.qimg { display: block; max-width: 100%; height: auto; margin-block: 10px; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.srcbadge { display: inline-block; font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 700; color: var(--accent); border: 1px solid var(--accent); border-radius: 999px; padding: 2px 8px; margin-bottom: 8px; }
.qtext { white-space: pre-line; }

/* Cheat sheets (шпаргалки) */
.topic-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.th-block { display: flex; flex-direction: column; gap: 10px; }
.th-block p { max-width: 68ch; }
.th-dates td { vertical-align: top; }
.th-dates td:first-child { white-space: nowrap; font-weight: 700; color: var(--accent); width: 1%; padding-right: 16px; }
.th-dl { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 8px 16px; margin: 0; }
.th-dl dt { font-weight: 700; }
.th-dl dd { margin: 0; color: var(--ink); }
.th-tips { background: var(--sun-soft); border: 1px solid var(--sun); border-radius: var(--r); padding: 14px 18px; }
.th-tips ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
@media (max-width: 520px) {
  .th-dl { grid-template-columns: 1fr; gap: 2px; }
  .th-dl dd { margin-bottom: 8px; }
  .topic { flex-wrap: wrap; }
}
