:root {
  --ink: #151a22;
  --ink-soft: #2c3442;
  --muted: #68717e;
  --line: #d9dce2;
  --paper: #f4f4f1;
  --card: #ffffff;
  --ok: #1c7a4f;
  --bad: #b23b3b;
  --accent: #3f55c8;
  --accent-soft: #e7eafa;
  --shadow: 0 1px 2px rgba(18, 22, 30, 0.04), 0 8px 24px -18px rgba(18, 22, 30, 0.5);
}

body[data-subject="geo"] {
  --accent: #2c7d5a;
  --accent-soft: #e3f1ea;
}
body[data-subject="inf"] {
  --accent: #0f6f8c;
  --accent-soft: #e0f0f5;
}
body[data-subject="rus"] {
  --accent: #a63c5b;
  --accent-soft: #f7e6eb;
}
body[data-subject="math"] {
  --accent: #3f55c8;
  --accent-soft: #e7eafa;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

p,
ul,
ol {
  margin: 0;
}

button {
  font: inherit;
  color: inherit;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.fx {
  font-family: Cambria, "Times New Roman", Georgia, serif;
  font-size: 1.04em;
  color: var(--ink);
}

/* ---------- top bar ---------- */

.bar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--ink);
  color: #fff;
  border-bottom: 1px solid #000;
}

.bar-in {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 22px;
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 22px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-family: Cambria, Georgia, serif;
  font-size: 19px;
  line-height: 1;
}

.brand-name b {
  color: #7d8796;
  font-weight: 400;
  padding: 0 1px;
}

.subjects {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.subject-btn {
  background: transparent;
  border: 1px solid transparent;
  color: #aeb6c3;
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}

.subject-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
}

.subject-btn[aria-selected="true"] {
  color: #fff;
  background: rgba(255, 255, 255, 0.11);
  border-color: rgba(255, 255, 255, 0.16);
}

.bar-score {
  margin-left: auto;
  font-size: 13px;
  color: #8e98a6;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- hero ---------- */

.hero {
  background-color: var(--paper);
  background-image: linear-gradient(rgba(21, 26, 34, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(21, 26, 34, 0.045) 1px, transparent 1px);
  background-size: 26px 26px;
  background-position: -1px -1px;
  border-bottom: 1px solid var(--line);
}

.hero-in {
  max-width: 1180px;
  margin: 0 auto;
  padding: 54px 22px 46px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 48px;
  align-items: center;
}

.eyebrow {
  color: var(--accent);
  font-weight: 650;
  font-size: 14px;
  margin-bottom: 14px;
}

h1 {
  font-size: clamp(2.1rem, 5.2vw, 3.5rem);
  line-height: 1.02;
  letter-spacing: -0.035em;
  font-weight: 800;
  margin: 0 0 18px;
}

.lede {
  font-size: 18px;
  color: var(--ink-soft);
  max-width: 56ch;
}

.hero-points {
  list-style: none;
  padding: 0;
  margin-top: 26px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  font-size: 14px;
  color: var(--muted);
}

.hero-points li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hero-points li::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: var(--accent);
}

.hero-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 18px 40px -28px rgba(18, 22, 30, 0.75), 0 2px 4px rgba(18, 22, 30, 0.05);
  transform: rotate(-1.4deg);
  position: relative;
}

.hero-card::after {
  content: "+1 балл";
  position: absolute;
  top: -12px;
  right: -10px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 9px;
  border-radius: 999px;
  box-shadow: 0 6px 14px -6px rgba(18, 22, 30, 0.7);
}

.hc-cap {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.hc-formula {
  font-family: Cambria, Georgia, serif;
  font-size: 27px;
  line-height: 1.25;
  margin: 12px 0 22px;
  color: var(--ink);
}

.hc-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px dashed var(--line);
  padding-top: 10px;
  margin-bottom: 10px;
}

.hc-ticks {
  display: flex;
  gap: 4px;
}

.hc-ticks span {
  height: 6px;
  flex: 1;
  border-radius: 2px;
  background: #e6e8ec;
}

.hc-ticks span.on {
  background: var(--accent);
}

/* ---------- shell ---------- */

.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 34px 22px 80px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 28px;
  align-items: start;
}

.viewtabs {
  display: inline-flex;
  gap: 2px;
  background: #e7e8e4;
  border: 1px solid #dedfdb;
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 18px;
}

.viewtabs button {
  border: 0;
  background: transparent;
  padding: 8px 18px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.viewtabs button[aria-selected="true"] {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(18, 22, 30, 0.12);
}

.subject-head {
  margin-bottom: 18px;
}

.subject-head h2 {
  font-size: 24px;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}

.subject-head p {
  color: var(--muted);
  font-size: 15px;
  max-width: 68ch;
}

/* ---------- cheat sheets ---------- */

.sheets {
  display: grid;
  gap: 8px;
}

.sheet {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.sheet summary {
  list-style: none;
  cursor: pointer;
  padding: 13px 16px;
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 10px;
}

.sheet summary::-webkit-details-marker {
  display: none;
}

.sheet summary::after {
  content: "+";
  margin-left: auto;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-weight: 500;
  font-size: 16px;
  line-height: 1;
}

.sheet[open] summary::after {
  content: "−";
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.sheet[open] summary {
  border-radius: 10px 10px 0 0;
}

.sheet-body {
  border-top: 1px dashed var(--line);
  padding: 6px 16px 14px;
}

.rules {
  list-style: none;
  padding: 0;
  margin: 0;
}

.rules li {
  position: relative;
  padding-left: 16px;
  margin: 9px 0;
  font-size: 15px;
  color: var(--ink-soft);
}

.rules li::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 9px;
  width: 5px;
  height: 5px;
  border-radius: 1px;
  background: var(--accent);
}

/* ---------- trainer ---------- */

.trainer {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.task-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}

.points-chip {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 3px 10px;
  font-weight: 650;
  font-size: 12px;
  white-space: nowrap;
}

.progress-line {
  height: 4px;
  background: #ebedf0;
  border-radius: 999px;
  margin-top: 12px;
  overflow: hidden;
}

.progress-line span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.task-q {
  font-size: 19px;
  line-height: 1.5;
  margin: 18px 0 20px;
  letter-spacing: -0.005em;
}

.options {
  display: grid;
  gap: 8px;
}

.opt {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  text-align: left;
  padding: 11px 13px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1.4;
  transition: border-color 0.12s, background 0.12s;
}

.opt:hover:not([disabled]) {
  border-color: #b6bcc6;
  background: #fbfbf9;
}

.opt .key {
  flex: none;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #eef0f3;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.opt[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: var(--accent-soft);
}

.opt[aria-pressed="true"] .key {
  background: var(--accent);
  color: #fff;
}

.opt.correct {
  border-color: var(--ok);
  box-shadow: inset 0 0 0 1px var(--ok);
  background: #ecf6f0;
}

.opt.correct .key {
  background: var(--ok);
  color: #fff;
}

.opt.wrong {
  border-color: var(--bad);
  box-shadow: inset 0 0 0 1px var(--bad);
  background: #fbeeec;
}

.opt.wrong .key {
  background: var(--bad);
  color: #fff;
}

.opt[disabled] {
  cursor: default;
}

.answer-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.answer-line label {
  font-size: 15px;
  color: var(--muted);
}

.answer-line input {
  width: 190px;
  max-width: 100%;
  font: inherit;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.answer-line input:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent-soft);
}

.answer-line input[aria-invalid="true"] {
  border-color: var(--bad);
  background: #fdf6f5;
}

.unit {
  color: var(--muted);
  font-size: 15px;
}

.feedback {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.5;
  display: none;
}

.feedback.show {
  display: block;
}

.feedback.ok {
  background: #ecf6f0;
  border-left: 3px solid var(--ok);
  color: #14563a;
}

.feedback.bad {
  background: #fbeeec;
  border-left: 3px solid var(--bad);
  color: #7c2a26;
}

.feedback.hint {
  background: #f1f2ef;
  border-left: 3px solid var(--line);
  color: var(--muted);
}

.feedback .answer {
  font-weight: 700;
}

.task-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: filter 0.15s;
}

.btn:hover {
  filter: brightness(0.93);
}

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-soft);
}

.btn.ghost:hover {
  background: #f2f3f0;
  filter: none;
}

.btn.small {
  padding: 7px 12px;
  font-size: 13px;
  width: 100%;
}

/* ---------- result ---------- */

.result-top {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.result-score {
  font-size: 54px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.result-score small {
  font-size: 20px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
}

.result-caption {
  color: var(--muted);
  font-size: 14px;
}

.mark-pill {
  margin-left: auto;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 8px 14px;
  border-radius: 10px;
  text-align: center;
}

.mark-pill b {
  display: block;
  font-size: 24px;
  line-height: 1.1;
}

.mark-pill span {
  font-size: 11px;
  color: var(--muted);
}

.review {
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
  border-top: 1px solid var(--line);
}

.review li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 2px 10px;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 14px;
}

.review .dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  margin-top: 1px;
}

.review .dot.ok {
  background: var(--ok);
}

.review .dot.bad {
  background: var(--bad);
}

.review .q {
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.review .ans {
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.review .ans b {
  color: var(--ink);
}

/* ---------- rail ---------- */

.rail {
  position: sticky;
  top: 84px;
  display: grid;
  gap: 14px;
}

.rail-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.rail-cap {
  font-size: 13px;
  color: var(--muted);
}

.rail-subject {
  font-size: 18px;
  font-weight: 700;
  margin: 2px 0 10px;
  letter-spacing: -0.01em;
}

.rail-score {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.rail-score #railScore {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.rail-of {
  font-size: 14px;
  color: var(--muted);
}

.ticks {
  display: flex;
  gap: 3px;
  margin: 14px 0 4px;
}

.tick {
  height: 24px;
  flex: 1;
  border-radius: 2px;
  background: #e8eaee;
}

.tick.ok {
  background: var(--ok);
}

.tick.bad {
  background: #d9a3a0;
}

.tick.now {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.rail-note {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  margin-top: 12px;
}

.rail-card .btn {
  margin-top: 12px;
}

.exam-facts {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: grid;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-soft);
}

.exam-facts li {
  position: relative;
  padding-left: 14px;
}

.exam-facts li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 7px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

/* ---------- footer ---------- */

.foot {
  border-top: 1px solid var(--line);
  background: #efefec;
}

.foot-in {
  max-width: 1180px;
  margin: 0 auto;
  padding: 26px 22px 34px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

.foot-in p + p {
  margin-top: 6px;
}

/* ---------- responsive ---------- */

@media (max-width: 980px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .rail {
    position: static;
    grid-template-columns: 1fr 1fr;
  }

  .hero-in {
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: 30px;
  }
}

@media (max-width: 820px) {
  .hero-card {
    display: none;
  }

  .hero-in {
    grid-template-columns: minmax(0, 1fr);
    padding-top: 38px;
  }
}

@media (max-width: 640px) {
  .bar-in {
    flex-wrap: wrap;
    gap: 8px 12px;
    padding: 10px 16px;
    min-height: 0;
  }

  .brand {
    font-size: 15px;
  }

  .bar-score {
    font-size: 12px;
  }

  .subjects {
    order: 3;
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .subjects::-webkit-scrollbar {
    display: none;
  }

  .subject-btn {
    white-space: nowrap;
  }

  .shell {
    padding: 22px 16px 60px;
  }

  .rail {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero-in {
    padding: 30px 16px 34px;
  }

  .lede {
    font-size: 16px;
  }

  .task-q {
    font-size: 17px;
  }

  .result-score {
    font-size: 44px;
  }

  .mark-pill {
    margin-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  * {
    transition: none !important;
  }
}

@media print {
  .bar,
  .rail,
  .viewtabs,
  .hero-card {
    display: none;
  }

  .shell,
  .hero-in {
    display: block;
    max-width: none;
    padding: 0;
  }

  body {
    background: #fff;
  }

  .sheet {
    break-inside: avoid;
  }
}
