:root {
  --bg: #ebe9e4;
  --card: #f7f6f2;
  --paper: #fbfaf7;
  --ink: #171713;
  --ink-2: #3a3933;
  --muted: #6f6c63;
  --line: #d8d4ca;
  --line-2: #c4bfb3;
  --accent: #ff6b35;
  --accent-ink: #b8400f;
  --accent-soft: #ffe8dd;
  --ok: #2e7d4f;
  --r-xl: 28px;
  --r-lg: 22px;
  --r: 16px;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --serif: Georgia, 'Times New Roman', serif;
}

* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button,
input,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.wrap {
  max-width: 600px;
  margin: 0 auto;
  padding: 14px 16px calc(116px + env(safe-area-inset-bottom));
  min-height: 100dvh;
}
.screen {
  animation: rise 0.35s ease both;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ── Шапка теста ─────────────────────────── */
.top {
  padding: 4px 2px 14px;
}
.brand {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.brand small {
  color: var(--muted);
  font-weight: 500;
  font-size: inherit;
}
.ladder {
  display: flex;
  gap: 6px;
  list-style: none;
  margin: 12px 0 10px;
  padding: 0;
}
.ladder li {
  flex: 1;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 0;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  color: var(--muted);
}
.ladder li.is-done {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.ladder li.is-current {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--ink);
}
.progress {
  height: 4px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
}
.progress span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.4s ease;
}
.meta {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

/* ── Карточки ────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
}
.stack {
  display: grid;
  gap: 12px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.chip::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot, var(--accent));
}
.chip--vocab {
  --dot: #e3a234;
}
.chip--grammar {
  --dot: #ff6b35;
}
.chip--reading {
  --dot: #4f7cac;
}
.chip--listening {
  --dot: #8a63b8;
}
.task {
  margin: 8px 0 8px;
  color: var(--muted);
  font-size: 15px;
}
.prompt {
  margin: 0;
  font-size: 22px;
  line-height: 1.5;
  font-weight: 600;
  letter-spacing: -0.01em;
  outline: none;
  overflow-wrap: anywhere;
}
.verb {
  margin: 10px 0 0;
  font-size: 15px;
  color: var(--muted);
}
.verb b {
  color: var(--ink);
  font-weight: 600;
}
.blank {
  display: inline-block;
  min-width: 3.2em;
  border-bottom: 2px solid var(--accent);
  margin: 0 2px;
  text-align: center;
  color: var(--accent-ink);
  line-height: 1.25;
}

/* Варианты ответа */
.options {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}
.opt {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border-radius: var(--r);
  background: #fff;
  border: 1.5px solid var(--line);
  font-size: 17px;
  line-height: 1.35;
  transition:
    border-color 0.15s,
    background 0.15s,
    transform 0.1s;
}
.opt:hover {
  border-color: var(--line-2);
}
.opt:active {
  transform: scale(0.99);
}
.opt__mark {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--line-2);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.opt.is-on {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.opt.is-on .opt__mark {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--ink);
}

/* Открытые ответы */
.gap {
  font-weight: 600;
  border: 0;
  border-bottom: 2px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 8px 8px 0 0;
  padding: 0 6px;
  margin: 0 3px;
  text-align: center;
  outline: none;
  color: var(--ink);
  max-width: 100%;
}
.gap:focus {
  background: #ffd8c6;
}
.gap--block {
  display: block;
  width: 100%;
  margin: 18px 0 0;
  text-align: left;
  padding: 14px 16px;
  font-size: 18px;
  border: 1.5px solid var(--line);
  border-radius: var(--r);
  background: #fff;
}
.gap--block:focus {
  border-color: var(--accent);
  background: #fff;
}
/* Текст для чтения */
.passage {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px 20px;
}
.label {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px;
}
.passage__text {
  margin: 0;
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.65;
  white-space: pre-line;
}

/* Аудио */
.audio {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--ink);
  color: #fff;
  border-radius: var(--r-lg);
  padding: 16px 18px;
}
.audio__btn {
  flex: none;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: var(--ink);
  display: grid;
  place-items: center;
  transition: transform 0.1s;
}
.audio__btn:active {
  transform: scale(0.95);
}
.audio__btn svg {
  width: 24px;
  height: 24px;
}
.audio__btn:disabled {
  background: #45443e;
  color: #8d8a80;
  cursor: not-allowed;
}
.audio__body {
  flex: 1;
  min-width: 0;
}
.audio__title {
  font-weight: 600;
}
.audio__meta {
  font-size: 13px;
  color: #b9b6ac;
  margin: 2px 0 10px;
}
.audio__track {
  height: 4px;
  background: #3a3933;
  border-radius: 4px;
  overflow: hidden;
}
.audio__track span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
}

/* ── Кнопки ─────────────────────────────── */
.actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding: 18px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 72%, rgba(235, 233, 228, 0));
}
.actions__in {
  max-width: 568px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
}
.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 15px 22px;
  min-height: 54px;
  font-size: 17px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition:
    opacity 0.15s,
    transform 0.1s,
    background 0.15s;
}
.btn svg {
  width: 20px;
  height: 20px;
}
.btn:active {
  transform: scale(0.98);
}
.btn--primary {
  flex: 1;
  background: var(--ink);
  color: #fff;
}
.btn--accent {
  flex: 1;
  background: var(--accent);
  color: var(--ink);
}
.btn--ghost {
  background: transparent;
  border: 1.5px solid var(--line-2);
  color: var(--ink-2);
}
.btn--wide {
  width: 100%;
}
.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}
.btn--link {
  background: none;
  min-height: auto;
  padding: 10px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ── Старт ──────────────────────────────── */
.hero {
  position: relative;
  overflow: hidden;
  background: var(--ink);
  color: #fff;
  border-radius: var(--r-xl);
  padding: 26px 24px 26px;
}
.hero__word {
  position: absolute;
  right: -10px;
  bottom: -26px;
  font: italic 500 118px/1 var(--serif);
  letter-spacing: -0.06em;
  color: rgba(255, 255, 255, 0.07);
  pointer-events: none;
  user-select: none;
}
.hero .brand {
  color: #fff;
}
.hero .brand small {
  color: #a9a69c;
}
.hero h1 {
  position: relative;
  font-size: 31px;
  line-height: 1.12;
  letter-spacing: -0.025em;
  margin: 18px 0 10px;
  outline: none;
}
.hero p {
  position: relative;
  color: #cfccc2;
  margin: 0;
}
.hero__levels {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: 20px 0 0;
}
.hero__levels li {
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #ebe8de;
}
.rules {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
  display: grid;
  gap: 10px;
}
.rules li {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 16px;
  font-size: 15px;
  color: var(--ink-2);
}
.rules svg {
  flex: none;
  width: 22px;
  height: 22px;
  color: var(--accent-ink);
  margin-top: 1px;
}
.rules b {
  color: var(--ink);
}
.field {
  display: block;
  margin-top: 18px;
}
.field span {
  display: block;
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 6px 4px;
}
.input {
  width: 100%;
  padding: 15px 16px;
  font-size: 17px;
  border: 1.5px solid var(--line);
  border-radius: var(--r);
  background: #fff;
  outline: none;
}
.input:focus {
  border-color: var(--accent);
}

/* ── Промежуточные экраны ───────────────── */
.stage {
  text-align: center;
  padding: 48px 8px 0;
}
.stage__badge {
  position: relative;
  width: 124px;
  height: 124px;
  margin: 0 auto 22px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
  font: italic 500 54px/1 var(--serif);
  letter-spacing: -0.03em;
}
.stage__tick {
  position: absolute;
  right: -2px;
  bottom: 4px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--ink);
  display: grid;
  place-items: center;
  border: 3px solid var(--bg);
}
.stage__tick svg {
  width: 20px;
  height: 20px;
}
.stage h1 {
  font-size: 27px;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 10px;
  outline: none;
}
.stage p {
  color: var(--muted);
  margin: 0 auto;
  max-width: 420px;
}
.stage .score {
  display: inline-block;
  margin-top: 18px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 14px;
  font-weight: 600;
}

/* ── Выбор языка ────────────────────────── */
.langs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
}
.langs__btn {
  flex: 1;
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 9px 6px;
  background: transparent;
  color: var(--ink-2);
  font: 600 14px/1.2 var(--sans);
}
.langs__btn[aria-checked='true'] {
  background: var(--ink);
  color: #fff;
}

.passage__title {
  margin: 0 0 8px;
  font: italic 600 19px/1.3 var(--serif);
}

/* ── Результат ──────────────────────────── */
.res-level {
  position: relative;
  font: italic 500 104px/0.9 var(--serif);
  letter-spacing: -0.05em;
  margin: 14px 0 12px;
}
.res-level em {
  font-style: inherit;
  color: var(--accent);
}
.res-title {
  position: relative;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
  outline: none;
}
.res-text {
  position: relative;
  color: #cfccc2;
  margin: 8px 0 0;
}
.res-course {
  position: relative;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 18px;
  background: rgba(255, 255, 255, 0.09);
  border-radius: 999px;
  padding: 8px 15px;
  font-size: 14px;
  color: #e3e0d6;
}
.res-course b {
  color: var(--accent);
}
.rows {
  display: grid;
  grid-template-columns: max-content 1fr auto;
  align-items: center;
  gap: 12px 14px;
  font-size: 15px;
}
.row {
  display: contents;
}
.row__name {
  white-space: nowrap;
}
.row__bar {
  height: 8px;
  border-radius: 8px;
  background: var(--line);
  overflow: hidden;
}
.row__bar span {
  display: block;
  height: 100%;
  border-radius: 8px;
  background: var(--ink);
}
.row__bar span.is-low {
  background: var(--accent);
}
.row__val {
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.topics {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.topics li {
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 14px;
  font-weight: 550;
}
.sendstate {
  margin: 0;
  padding: 12px 16px;
  border-radius: var(--r);
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 15px;
  color: var(--muted);
}
.sendstate.is-ok {
  color: var(--ok);
}
.sendstate.is-err {
  color: #a3341a;
}
.sendstate .btn--link {
  padding: 0 0 0 4px;
  font-size: 15px;
  color: inherit;
}
.hint--center {
  text-align: center;
  margin: -2px 0 4px;
}
.hint {
  font-size: 14px;
  color: var(--muted);
  margin: 6px 0 0;
}
.hint.is-ok {
  color: var(--ok);
}
.res-actions {
  display: grid;
  gap: 10px;
  margin-top: 6px;
}
.note {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin: 18px 12px 0;
}
.center {
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translate(-50%, 8px);
  width: max-content;
  max-width: calc(100vw - 40px);
  text-align: center;
  z-index: 20;
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s,
    transform 0.2s;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 380px) {
  .prompt {
    font-size: 20px;
  }
  .hero h1 {
    font-size: 27px;
  }
  .res-level {
    font-size: 88px;
  }
  .rows {
    font-size: 14px;
    column-gap: 10px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .screen {
    animation: none;
  }
  * {
    transition: none !important;
  }
}

/* ── Текст с пропусками ─────────────────── */
.cg {
  display: inline-block;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--card);
  border: 1px dashed var(--line-2);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.5;
  color: var(--muted);
}
.cg.is-current {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: var(--ink);
}
.cg.is-ok {
  background: #e3f1e8;
  border: 1px solid #b9dcc6;
  color: var(--ok);
}
.cg.is-bad {
  background: #fbe5dc;
  border: 1px solid #f1c3b1;
  color: #a3341a;
}

/* ── Разбор ответа ──────────────────────── */
.feedback {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--r);
  font-size: 16px;
  line-height: 1.45;
}
.feedback svg {
  flex: none;
  width: 22px;
  height: 22px;
}
.feedback.is-ok {
  background: #e3f1e8;
  color: var(--ok);
}
.feedback.is-bad {
  background: #fbe5dc;
  color: #7a2611;
}
.feedback b[lang] {
  color: var(--ink);
}
.opt:disabled {
  cursor: default;
}
.opt.is-right {
  border-color: var(--ok);
  background: #e3f1e8;
}
.opt.is-right .opt__mark {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}
.opt.is-wrong {
  border-color: #c9572f;
  background: #fbe5dc;
}
.opt.is-wrong .opt__mark {
  background: #c9572f;
  border-color: #c9572f;
  color: #fff;
}
.opt.is-dim {
  opacity: 0.55;
}
.gap:disabled {
  opacity: 1;
  -webkit-text-fill-color: currentColor;
}
.gap.is-right {
  border-color: var(--ok);
  background: #e3f1e8;
  color: var(--ok);
}
.gap.is-wrong {
  border-color: #c9572f;
  background: #fbe5dc;
  color: #a3341a;
  text-decoration: line-through;
}
.blank.is-right {
  color: var(--ok);
  border-color: var(--ok);
}

/* ── Итог уровня ────────────────────────── */
.score-big {
  margin: 4px 0 0;
  font: italic 500 64px/1 var(--serif);
  letter-spacing: -0.03em;
}
.score-big span {
  font-size: 34px;
  color: var(--muted);
}
.stage p.score-label {
  margin: 4px 0 14px;
  font-size: 15px;
}
.breakdown {
  list-style: none;
  margin: 0 auto 16px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-width: 340px;
  width: 100%;
}
.breakdown li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 14px;
}
