/* ==========================================================================
   Курс ООП на C++ — тесты. Оформление.
   ========================================================================== */

:root {
  --bg: #f3f6fc;
  --bg-soft: #e9eefa;
  --surface: #ffffff;
  --surface-2: #f7f9fe;
  --text: #14203b;
  --muted: #5b6a8b;
  --line: #d9e2f2;
  --line-strong: #c3d0e8;
  --accent: #2f5bea;
  --accent-soft: #e6ecff;
  --accent-ink: #1d3fae;
  --teal: #0f766e;
  --teal-soft: #dcf5f1;
  --good: #15803d;
  --good-soft: #e4f7ea;
  --bad: #b42318;
  --bad-soft: #fdeae8;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --code-bg: #101a32;
  --code-text: #e6edfb;
  --code-muted: #8fa3c8;
  --shadow-sm: 0 1px 2px rgba(20, 32, 59, .06);
  --shadow: 0 12px 32px rgba(20, 32, 59, .09);
  --shadow-lg: 0 24px 70px rgba(20, 32, 59, .16);
  --radius: 18px;
  --radius-sm: 12px;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
          "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1222;
    --bg-soft: #101a2f;
    --surface: #131d33;
    --surface-2: #17233d;
    --text: #e9eefb;
    --muted: #9aabc9;
    --line: #263554;
    --line-strong: #34466a;
    --accent: #7f9dff;
    --accent-soft: #1c2c55;
    --accent-ink: #b9c9ff;
    --teal: #5eead4;
    --teal-soft: #11312f;
    --good: #6ee7a2;
    --good-soft: #12301f;
    --bad: #ff9b91;
    --bad-soft: #3a1715;
    --warn: #fbbf6e;
    --warn-soft: #35240f;
    --code-bg: #0a1224;
    --code-text: #e6edfb;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 12px 32px rgba(0, 0, 0, .35);
    --shadow-lg: 0 24px 70px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }

/* ---------- Шапка главной ---------- */

.hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(900px 380px at 12% -10%, rgba(47, 91, 234, .28), transparent 60%),
    radial-gradient(700px 340px at 92% 0%, rgba(15, 118, 110, .24), transparent 55%),
    linear-gradient(135deg, #101c39 0%, #172a55 55%, #0e3a3a 100%);
  color: #f2f6ff;
  padding: 56px 0 64px;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, #000 20%, transparent 90%);
  pointer-events: none;
}

.hero .wrap { position: relative; z-index: 1; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: #b9cbf4;
  margin-bottom: 18px;
}

.eyebrow::before {
  content: "";
  width: 26px;
  height: 2px;
  background: #5eead4;
  border-radius: 2px;
}

.hero h1 {
  margin: 0 0 16px;
  font-size: clamp(30px, 4.6vw, 54px);
  line-height: 1.08;
  letter-spacing: -.02em;
  max-width: 900px;
}

.hero .lead {
  margin: 0;
  max-width: 760px;
  color: #c8d6f2;
  font-size: clamp(15px, 1.6vw, 18px);
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 30px;
}

.stat-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  padding: 9px 14px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 999px;
  background: rgba(255, 255, 255, .07);
  color: #dbe6fb;
  font-size: 13.5px;
  backdrop-filter: blur(6px);
}

.stat-pill b { font-size: 17px; color: #fff; }

/* ---------- Секции ---------- */

main { padding: 42px 0 72px; }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin: 0 0 22px;
}

.section-head h2 {
  margin: 0;
  font-size: 26px;
  letter-spacing: -.015em;
}

.section-head p { margin: 6px 0 0; color: var(--muted); font-size: 14.5px; }

.rules {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 0 0 42px;
}

.rule {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}

.rule .num {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 12px;
}

.rule h3 { margin: 0 0 6px; font-size: 16px; }
.rule p { margin: 0; color: var(--muted); font-size: 14px; }

/* ---------- Карточки тем ---------- */

.topic-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.topic-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.topic-card:hover {
  transform: translateY(-3px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}

.topic-top { display: flex; align-items: flex-start; gap: 16px; }

.topic-num {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--accent), #1d3fae);
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  box-shadow: 0 6px 14px rgba(47, 91, 234, .28);
}

.topic-card h3 {
  margin: 0;
  font-size: 19px;
  line-height: 1.25;
  letter-spacing: -.01em;
}

.topic-sub { margin: 3px 0 0; color: var(--muted); font-size: 13.5px; }

.topic-desc { margin: 0; color: var(--muted); font-size: 14.5px; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.chip b { color: var(--text); font-weight: 600; }

.topic-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: auto;
  padding-top: 4px;
}

.best {
  font-size: 12.5px;
  color: var(--muted);
}

.best b { color: var(--good); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 10px 18px;
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .15s, box-shadow .15s;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 16px rgba(47, 91, 234, .25);
}

.btn.primary:hover { background: var(--accent-ink); text-decoration: none; }

.btn.ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line-strong);
}

.btn.ghost:hover { background: var(--surface-2); text-decoration: none; }

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  box-shadow: none;
}

.notice {
  margin-top: 26px;
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
}

.notice b { color: var(--text); }

.notice code {
  font-family: var(--mono);
  font-size: .92em;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 5px;
}

.loading, .error-box {
  grid-column: 1 / -1;
  padding: 34px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

.error-box { color: var(--bad); border-color: var(--bad); }

footer.site-foot {
  border-top: 1px solid var(--line);
  padding: 26px 0 38px;
  color: var(--muted);
  font-size: 13px;
}

footer.site-foot .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  justify-content: space-between;
}

/* ---------- Страница теста ---------- */

.testbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.testbar-inner {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 0;
}

.back {
  flex: 0 0 auto;
  font-size: 13.5px;
  color: var(--muted);
  padding: 7px 11px;
  border-radius: 9px;
  border: 1px solid transparent;
}

.back:hover { background: var(--surface-2); text-decoration: none; }

.test-title { flex: 1 1 auto; min-width: 0; }

.test-title .kicker {
  display: block;
  font-size: 11.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.test-title h1 {
  margin: 0;
  font-size: 17.5px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.test-meta { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }

.timer {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  padding: 7px 11px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  min-width: 78px;
  text-align: center;
}

.timer.warn { color: var(--warn); background: var(--warn-soft); border-color: var(--warn); }
.timer.danger { color: var(--bad); background: var(--bad-soft); border-color: var(--bad); }

.progress-text { font-size: 13px; color: var(--muted); white-space: nowrap; }

.progress-track {
  height: 3px;
  background: var(--line);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--teal));
  transition: width .25s ease;
}

.test-layout {
  width: min(1280px, calc(100% - 32px));
  margin: 26px auto 70px;
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  gap: 26px;
  align-items: start;
}

.navigator {
  position: sticky;
  top: 84px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.nav-head {
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.nav-group { margin-bottom: 14px; }

.nav-group-title {
  font-size: 11.5px;
  color: var(--muted);
  margin: 0 0 7px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.nav-dot.fill { background: var(--teal); }
.nav-dot.out { background: var(--warn); }

.nav-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.nav-btn {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 8px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .13s;
}

.nav-btn:hover { border-color: var(--accent); color: var(--accent); }

.nav-btn.answered {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  color: var(--accent-ink);
}

.nav-btn.current {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.nav-btn.correct {
  background: var(--good-soft);
  border-color: var(--good);
  color: var(--good);
}

.nav-btn.incorrect {
  background: var(--bad-soft);
  border-color: var(--bad);
  color: var(--bad);
}

.nav-legend {
  border-top: 1px solid var(--line);
  margin-top: 4px;
  padding-top: 11px;
  display: grid;
  gap: 5px;
  font-size: 11.5px;
  color: var(--muted);
}

.nav-legend span { display: flex; align-items: center; gap: 7px; }

.legend-swatch {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  display: inline-block;
}

.legend-swatch.answered { background: var(--accent-soft); border-color: var(--accent); }
.legend-swatch.good { background: var(--good-soft); border-color: var(--good); }
.legend-swatch.bad { background: var(--bad-soft); border-color: var(--bad); }

.questions { display: flex; flex-direction: column; gap: 26px; min-width: 0; }

.part-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  padding: 4px 2px 0;
}

.part-head h2 {
  margin: 0;
  font-size: 19px;
  letter-spacing: -.01em;
}

.part-head .part-note { color: var(--muted); font-size: 13px; }

.part-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.part-badge.fill { background: var(--teal-soft); color: var(--teal); }
.part-badge.out { background: var(--warn-soft); color: var(--warn); }

.question {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 26px 22px;
  box-shadow: var(--shadow-sm);
  scroll-margin-top: 96px;
  transition: border-color .15s, box-shadow .15s;
}

.question:focus-within {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
  box-shadow: var(--shadow);
}

.question-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.q-num {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  font-family: var(--mono);
}

.question.is-correct .q-num { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.question.is-wrong .q-num { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }

.q-body { flex: 1 1 auto; min-width: 0; }

.q-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.q-level {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .04em;
}

.q-level .bar { display: inline-flex; gap: 2px; margin-left: 4px; vertical-align: middle; }
.q-level .bar i {
  width: 4px;
  height: 9px;
  border-radius: 2px;
  background: var(--line-strong);
  display: inline-block;
}
.q-level .bar i.on { background: var(--accent); }

.q-prompt {
  margin: 0;
  font-size: 15.5px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.q-code {
  margin: 14px 0 4px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid #24365c;
  background: var(--code-bg);
}

.q-code pre {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  color: var(--code-text);
  tab-size: 4;
}

.q-code pre::selection { background: #2f5bea; }

.options {
  display: grid;
  gap: 9px;
  margin: 16px 0 0;
}

.option {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color .13s, background .13s, transform .13s;
  font-size: 14.5px;
}

.option:hover { border-color: var(--line-strong); background: var(--surface); }

.option.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.option.correct {
  border-color: var(--good);
  background: var(--good-soft);
}

.option.incorrect {
  border-color: var(--bad);
  background: var(--bad-soft);
}

.option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.option .marker {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  position: relative;
  transition: border-color .13s;
}

.option.multi .marker { border-radius: 5px; }

.option.selected .marker { border-color: var(--accent); }

.option.selected .marker::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--accent);
}

.option.multi.selected .marker::after { border-radius: 2px; }

.option-text {
  flex: 1 1 auto;
  min-width: 0;
  word-break: break-word;
}

.option-text.code { font-family: var(--mono); font-size: 13px; }

.option-key {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 5px;
  margin-left: 4px;
}

.answer-row { margin: 16px 0 0; }

.answer-label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.answer-input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  outline: none;
  transition: border-color .13s, box-shadow .13s;
}

.answer-input::placeholder { color: var(--muted); opacity: .75; }

.answer-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
  background: var(--surface);
}

.answer-input:disabled { opacity: .85; }

.q-hint {
  margin: 9px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.q-status {
  margin: 12px 0 0;
  font-size: 13px;
  font-weight: 600;
  display: none;
}

.q-status.show { display: block; }
.q-status.ok { color: var(--good); }
.q-status.no { color: var(--bad); }

.q-ref {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  display: none;
}

.q-ref.show { display: block; }

.question.locked { opacity: 1; }
.question.locked .option { cursor: default; }
.question.locked .option:hover { transform: none; }

/* ---------- Результаты ---------- */

.result-panel {
  width: min(1280px, calc(100% - 32px));
  margin: 26px auto 0;
  scroll-margin-top: 90px;
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.result-hero {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 26px;
  align-items: center;
  padding: 28px 30px;
  background:
    radial-gradient(700px 240px at 0% 0%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 70%),
    var(--surface-2);
  border-bottom: 1px solid var(--line);
}

.score-ring {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
  background: conic-gradient(var(--accent) calc(var(--score) * 1%), var(--line) 0);
  flex: 0 0 auto;
}

.score-ring::before {
  content: "";
  position: absolute;
  inset: 10px;
  background: var(--surface);
  border-radius: 50%;
}

.score-ring .score-val {
  position: relative;
  z-index: 1;
  text-align: center;
  line-height: 1.05;
}

.score-ring .score-val b { display: block; font-size: 34px; letter-spacing: -.03em; }
.score-ring .score-val span { font-size: 12px; color: var(--muted); }

.result-summary h2 { margin: 0 0 6px; font-size: 26px; letter-spacing: -.02em; }
.result-summary .grade { font-size: 15px; font-weight: 600; }
.result-summary .grade.g5 { color: var(--good); }
.result-summary .grade.g4 { color: var(--teal); }
.result-summary .grade.g3 { color: var(--warn); }
.result-summary .grade.g2 { color: var(--bad); }
.result-summary p { margin: 8px 0 0; color: var(--muted); font-size: 14px; }

.result-breakdown {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  border-bottom: 1px solid var(--line);
}

.breakdown-item {
  padding: 18px 24px;
  border-right: 1px solid var(--line);
}

.breakdown-item:last-child { border-right: none; }

.breakdown-item .label { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.breakdown-item .value { font-size: 20px; font-weight: 700; }
.breakdown-item .value small { font-size: 13px; color: var(--muted); font-weight: 500; }

.review {
  padding: 24px 30px 28px;
}

.review h3 { margin: 0 0 4px; font-size: 18px; }
.review .review-note { margin: 0 0 16px; color: var(--muted); font-size: 13.5px; }

.review-list { display: grid; gap: 10px; }

.review-item {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 12px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
}

.review-item .rn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--bad-soft);
  color: var(--bad);
  font-weight: 700;
  font-size: 12.5px;
  font-family: var(--mono);
}

.review-item .rt { font-size: 14px; }
.review-item .rr { font-size: 12px; color: var(--muted); margin-top: 3px; }
.review-item .ra { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.review-item .ra code { font-family: var(--mono); color: var(--text); }

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 20px 30px 28px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

.score-note {
  margin: 14px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

/* ---------- Модальное окно ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 14, 28, .55);
  backdrop-filter: blur(4px);
}

.modal[hidden] { display: none; }

.modal-card {
  width: min(460px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 26px;
}

.modal-card h3 { margin: 0 0 8px; font-size: 20px; }
.modal-card p { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- Служебное ---------- */

[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.fade-in { animation: fadeIn .35s ease both; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 980px) {
  .rules { grid-template-columns: 1fr; }
  .topic-grid { grid-template-columns: 1fr; }
  .test-layout { grid-template-columns: 1fr; }
  .navigator {
    position: static;
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding: 12px 14px;
  }
  .nav-head { display: none; }
  .nav-group { margin: 0; flex: 0 0 auto; }
  .nav-grid { grid-template-columns: repeat(10, 28px); }
  .nav-legend { display: none; }
  .result-hero { grid-template-columns: 1fr; justify-items: start; }
  .result-breakdown { grid-template-columns: 1fr; }
  .breakdown-item { border-right: none; border-bottom: 1px solid var(--line); }
  .breakdown-item:last-child { border-bottom: none; }
}

@media (max-width: 640px) {
  .wrap { width: calc(100% - 28px); }
  .hero { padding: 40px 0 46px; }
  .testbar-inner { flex-wrap: wrap; gap: 8px 12px; }
  .test-title { order: 3; flex-basis: 100%; }
  .test-meta { margin-left: auto; }
  .test-meta .progress-text { display: none; }
  .question { padding: 20px 18px; }
  .result-hero, .review, .result-actions { padding-left: 20px; padding-right: 20px; }
  .nav-grid { grid-template-columns: repeat(10, 26px); }
}

@media print {
  .testbar, .navigator, .result-actions, .modal { display: none !important; }
  body { background: #fff; }
  .question { break-inside: avoid; box-shadow: none; }
}

/* ==========================================================================
   Итоговый тест по всему курсу
   ========================================================================== */

.exam-pending .test-layout { grid-template-columns: minmax(0, 1fr); }
.exam-pending .navigator { display: none; }
.exam-pending .timer,
.exam-pending .progress-text { visibility: hidden; }

.exam-student {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.topic-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .02em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
}

.exam-intro {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px 34px;
  box-shadow: var(--shadow);
  max-width: 760px;
}

.exam-intro h2 { margin: 0 0 12px; font-size: 26px; letter-spacing: -.02em; }

.exam-lead { margin: 0 0 12px; color: var(--muted); font-size: 15px; max-width: 62ch; }

.exam-form {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin: 22px 0 8px;
}

.field { display: flex; flex-direction: column; gap: 6px; flex: 1 1 220px; }
.field span { font-size: 12.5px; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.field input {
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  font-family: var(--sans);
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.exam-error { color: var(--bad); font-weight: 600; margin: 6px 0 14px; }
.exam-note { color: var(--muted); font-size: 13px; margin: 18px 0 0; max-width: 62ch; }

.exam-save {
  margin: 0 34px 22px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 14px;
}

.exam-save-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
}

.exam-save.saved { border-color: var(--good); background: var(--good-soft); color: var(--good); }
.exam-save.saved .exam-save-dot { background: var(--good); }
.exam-save.local { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.exam-save.local .exam-save-dot { background: var(--warn); }

.exam-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  padding: 26px 30px;
  margin: 0 0 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(600px 200px at 0% 0%, var(--accent-soft), transparent 70%),
    var(--surface);
  box-shadow: var(--shadow-sm);
}

.exam-cta-body { max-width: 74ch; }
.exam-cta h2 { margin: 8px 0 8px; font-size: 23px; letter-spacing: -.02em; }
.exam-cta p { margin: 0 0 12px; color: var(--muted); font-size: 15px; }

.exam-points {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 14px;
  display: grid;
  gap: 4px;
}

@media (max-width: 640px) {
  .exam-intro { padding: 24px 20px; }
  .exam-save { margin-left: 20px; margin-right: 20px; }
  .exam-cta { padding: 22px 20px; }
}

