:root {
  --ink: #292238;
  --muted: #6d6577;
  --lavender: #7654ad;
  --lavender-dark: #5c3d86;
  --lavender-soft: #f0e8fa;
  --lavender-pale: #faf7fd;
  --pink: #f6dce9;
  --mint: #dff3e9;
  --mint-dark: #28755f;
  --gold: #efbd52;
  --paper: #fffefd;
  --line: #ded2ec;
  --danger: #a74454;
  --danger-soft: #fff0f2;
  --shadow: 0 16px 42px rgba(73, 50, 105, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: #f7f3fb;
}

body {
  min-width: 300px;
  margin: 0;
  color: var(--ink);
  font: 16px/1.52 system-ui, -apple-system, "Segoe UI", sans-serif;
  background-color: #f7f3fb;
  background-image:
    linear-gradient(rgba(118, 84, 173, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(118, 84, 173, 0.045) 1px, transparent 1px);
  background-size: 28px 28px;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

a {
  color: var(--lavender-dark);
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 10px;
  padding: 9px 13px;
  border-radius: 10px;
  background: var(--ink);
  color: white;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 10px max(18px, calc((100vw - 1160px) / 2));
  border-bottom: 1px solid rgba(118, 84, 173, 0.18);
  background: rgba(255, 254, 253, 0.94);
  backdrop-filter: blur(14px);
}

.back-link {
  justify-self: start;
  font-weight: 800;
  text-decoration: none;
}

.brand {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-align: center;
}

.mode-switch {
  justify-self: end;
  min-height: 42px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 800;
}

.mode-switch[aria-pressed="true"] {
  border-color: var(--lavender);
  background: var(--lavender);
  color: white;
}

main,
footer {
  width: min(1160px, calc(100% - 24px));
  margin-inline: auto;
}

.hero,
.theory,
.trainer-shell,
.finish-card,
.source-card {
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgba(255, 254, 253, 0.98);
  box-shadow: var(--shadow);
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  align-items: center;
  min-height: 350px;
  margin-top: 18px;
  overflow: hidden;
  padding: clamp(26px, 5vw, 54px);
  background:
    radial-gradient(circle at 88% 18%, rgba(239, 189, 82, 0.23), transparent 19%),
    linear-gradient(135deg, #fffefd 48%, #eee4f8);
}

.hero::after {
  position: absolute;
  right: 11%;
  bottom: 20px;
  width: 80px;
  height: 80px;
  border: 12px solid rgba(118, 84, 173, 0.09);
  border-radius: 50%;
  content: "";
}

.hero-copy {
  position: relative;
  z-index: 2;
}

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  color: var(--lavender);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 780px;
  margin: 0;
  font-size: clamp(2.15rem, 6vw, 4.6rem);
  line-height: 1;
}

.lead {
  max-width: 720px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: clamp(1.03rem, 2vw, 1.2rem);
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.hero-stats span {
  padding: 9px 12px;
  border: 1px solid rgba(118, 84, 173, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: #524a5d;
  font-size: 0.9rem;
}

.hero-stats strong {
  color: var(--lavender-dark);
}

.hero-art {
  position: relative;
  z-index: 1;
  align-self: end;
  justify-self: center;
}

.hero-art img {
  display: block;
  width: min(215px, 25vw);
  max-height: 235px;
  object-fit: contain;
}

.theory {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 165px;
  gap: 22px;
  margin-top: 18px;
  padding: clamp(22px, 4vw, 38px);
  overflow: hidden;
}

.theory h2,
.trainer-shell h2,
.finish-card h2,
.source-card h2 {
  margin: 0;
  font-size: clamp(1.55rem, 4vw, 2.35rem);
  line-height: 1.12;
}

.theory-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.theory-grid article {
  position: relative;
  min-height: 138px;
  padding: 18px 18px 18px 58px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--lavender-pale);
}

.step-number {
  position: absolute;
  top: 17px;
  left: 17px;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 10px;
  background: var(--lavender);
  color: white;
  font-weight: 900;
}

.theory-grid h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.theory-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 0.93rem;
}

.exam-note {
  margin-top: 14px;
  padding: 14px 16px;
  border-left: 5px solid var(--gold);
  border-radius: 14px;
  background: #fff6da;
  color: #69521c;
}

.thinking-mascot {
  align-self: end;
  width: 155px;
  max-height: 190px;
  object-fit: contain;
}

.trainer-shell {
  margin-top: 18px;
  padding: clamp(20px, 4vw, 36px);
}

.trainer-heading {
  display: grid;
  grid-template-columns: 1fr minmax(240px, 330px);
  align-items: end;
  gap: 24px;
}

.progress-copy {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.86rem;
}

.progress-copy strong {
  color: var(--ink);
  font-size: 1rem;
}

.progress-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9e1f2;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--lavender), #b777b9);
  transition: width 0.25s ease;
}

.block-tabs {
  display: flex;
  gap: 9px;
  margin-top: 25px;
  padding-bottom: 4px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.block-tab {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  color: var(--muted);
  font-weight: 850;
}

.block-tab[aria-current="true"] {
  border-color: var(--lavender);
  background: var(--lavender);
  color: white;
}

.block-tab .tab-count {
  display: inline-grid;
  min-width: 24px;
  min-height: 24px;
  margin-left: 6px;
  place-items: center;
  border-radius: 999px;
  background: rgba(118, 84, 173, 0.12);
  font-size: 0.76rem;
}

.block-tab[aria-current="true"] .tab-count {
  background: rgba(255, 255, 255, 0.2);
}

.teacher-note {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid #d7c6eb;
  border-radius: 15px;
  background: var(--lavender-soft);
  color: #533d6e;
}

.task-block {
  margin-top: 25px;
}

.task-block + .task-block {
  padding-top: 28px;
  border-top: 2px dashed #ded2ec;
}

.block-header {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 13px;
  align-items: start;
  margin-bottom: 16px;
}

.block-index {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 14px;
  background: var(--lavender-soft);
  color: var(--lavender-dark);
  font-weight: 950;
}

.block-header h3 {
  margin: 0;
  font-size: clamp(1.18rem, 3vw, 1.55rem);
}

.block-header p {
  max-width: 780px;
  margin: 5px 0 0;
  color: var(--muted);
}

.task-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.task-card {
  position: relative;
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: white;
  box-shadow: 0 8px 22px rgba(73, 50, 105, 0.06);
}

.task-card.correct {
  border-color: #72b29f;
  background: #fbfffd;
}

.task-card.incorrect {
  border-color: #dda8b1;
}

.task-topline {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.task-number {
  display: inline-grid;
  min-width: 34px;
  height: 30px;
  padding-inline: 8px;
  place-items: center;
  border-radius: 10px;
  background: var(--lavender-soft);
  color: var(--lavender-dark);
  font-weight: 900;
}

.task-prompt {
  margin: 16px 0 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

.expression {
  display: flex;
  min-height: 88px;
  align-items: center;
  justify-content: center;
  padding: 12px;
  border-radius: 15px;
  background: var(--lavender-pale);
  font-family: "Cambria Math", Cambria, Georgia, serif;
  font-size: clamp(1.55rem, 4vw, 2.15rem);
  font-weight: 650;
  text-align: center;
}

.frac {
  display: inline-grid;
  grid-template-rows: auto auto;
  margin-inline: 0.12em;
  vertical-align: middle;
  text-align: center;
  line-height: 1.08;
}

.frac > span:first-child {
  padding: 0 0.16em 0.06em;
  border-bottom: 1.6px solid currentColor;
}

.frac > span:last-child {
  padding: 0.06em 0.16em 0;
}

.frac-large {
  font-size: 0.86em;
}

.answer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
  align-items: end;
  margin-top: 15px;
}

.answer-row label {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.answer-input {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid #cfc2de;
  border-radius: 12px;
  background: white;
  color: var(--ink);
  outline: none;
}

.answer-input:focus {
  border-color: var(--lavender);
  box-shadow: 0 0 0 3px rgba(118, 84, 173, 0.13);
}

.check-button,
.primary-button,
.secondary-button,
.quiet-button,
.hint-button,
.solution-button {
  min-height: 44px;
  padding: 9px 13px;
  border-radius: 12px;
  font-weight: 850;
}

.check-button,
.primary-button {
  border: 1px solid var(--lavender);
  background: var(--lavender);
  color: white;
}

.check-button:hover,
.primary-button:hover {
  background: var(--lavender-dark);
}

.secondary-button,
.hint-button,
.solution-button {
  border: 1px solid var(--line);
  background: var(--lavender-pale);
  color: var(--lavender-dark);
}

.quiet-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.feedback {
  min-height: 24px;
  margin: 8px 0 0;
  font-size: 0.86rem;
  font-weight: 850;
}

.correct .feedback {
  color: var(--mint-dark);
}

.incorrect .feedback {
  color: var(--danger);
}

.task-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.hint-button,
.solution-button {
  min-height: 38px;
  padding: 7px 10px;
  font-size: 0.82rem;
}

.hint-panel,
.solution-panel {
  margin-top: 10px;
  padding: 12px 13px;
  border-radius: 12px;
  font-size: 0.88rem;
}

.hint-panel {
  border: 1px solid #ead590;
  background: #fff8df;
  color: #6e551b;
}

.solution-panel {
  border: 1px solid #d6c5e8;
  background: var(--lavender-soft);
  color: #4f3c65;
}

.teacher-answer {
  margin-bottom: 7px;
  color: var(--lavender-dark);
  font-weight: 950;
}

.block-navigation {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  margin-top: 24px;
}

.block-navigation .primary-button {
  justify-self: end;
}

.block-navigation button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.finish-card {
  display: grid;
  grid-template-columns: 1fr 180px;
  align-items: center;
  gap: 18px;
  margin-top: 18px;
  padding: clamp(22px, 4vw, 36px);
  background: linear-gradient(135deg, #fffdf6, #f2e9fb);
}

.finish-card[hidden] {
  display: none;
}

.finish-card p:not(.section-kicker) {
  max-width: 720px;
  margin: 10px 0 0;
  color: var(--muted);
}

.finish-card img {
  width: 170px;
  max-height: 190px;
  object-fit: contain;
}

.source-card {
  margin-top: 18px;
  padding: clamp(22px, 4vw, 34px);
}

.source-card p {
  max-width: 850px;
  color: var(--muted);
}

.source-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.source-links a {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--lavender-pale);
  font-size: 0.86rem;
  font-weight: 800;
  text-decoration: none;
}

footer {
  padding: 24px 0 36px;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

body.teacher-mode .block-tabs,
body.teacher-mode .block-navigation,
body.teacher-mode .progress-box {
  display: none;
}

body.teacher-mode .answer-row,
body.teacher-mode .feedback,
body.teacher-mode .task-actions,
body.teacher-mode .hint-panel {
  display: none;
}

body.teacher-mode .solution-panel {
  display: block;
}

/* Компактная раскладка применяется только к № 6: task6.css используют и другие тренажёры. */
.task6-page .task-block {
  margin-top: 18px;
}

.task6-page .block-header {
  margin-bottom: 12px;
}

.task6-page .task-grid {
  gap: 10px;
}

.task6-page .task-card {
  padding: 14px 15px;
  border-radius: 18px;
}

.task6-page .task-prompt {
  margin: 10px 0 4px;
}

.task6-page .expression {
  min-height: 64px;
  padding: 8px 10px;
}

.task6-page .answer-row {
  gap: 8px;
  margin-top: 10px;
}

.task6-page .feedback {
  min-height: 20px;
  margin-top: 5px;
}

.task6-page .task-actions {
  margin-top: 5px;
}

.task6-page .hint-panel,
.task6-page .solution-panel {
  margin-top: 7px;
  padding: 10px 12px;
}

@media (max-width: 820px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .brand {
    display: none;
  }

  .hero {
    grid-template-columns: minmax(0, 1fr) 155px;
  }

  .theory {
    grid-template-columns: 1fr;
  }

  .thinking-mascot {
    position: absolute;
    right: 17px;
    bottom: 15px;
    width: 95px;
    opacity: 0.9;
  }

  .theory-copy {
    position: relative;
    z-index: 1;
  }

  .exam-note {
    padding-right: 105px;
  }

  .task-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .topbar {
    padding-inline: 12px;
  }

  .back-link,
  .mode-switch {
    font-size: 0.8rem;
  }

  .mode-switch {
    padding-inline: 10px;
  }

  .hero {
    grid-template-columns: 1fr;
    min-height: 0;
    padding: 25px;
  }

  .hero-art {
    position: absolute;
    right: 15px;
    bottom: 8px;
    opacity: 0.28;
  }

  .hero-art img {
    width: 120px;
  }

  .hero-stats {
    padding-right: 30px;
  }

  .theory-grid {
    grid-template-columns: 1fr;
  }

  .theory-grid article {
    min-height: 0;
  }

  .trainer-heading {
    grid-template-columns: 1fr;
  }

  .answer-row {
    grid-template-columns: 1fr;
  }

  .check-button {
    width: 100%;
  }

  .block-navigation {
    grid-template-columns: 1fr 1fr;
  }

  .quiet-button {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .finish-card {
    grid-template-columns: 1fr 100px;
  }

  .finish-card img {
    width: 100px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
