/* Тренажёр слов */
.trainer {
  width: min(720px, calc(100vw - 24px));
  max-width: none;
  height: min(860px, calc(100dvh - 24px));
  max-height: none;
  padding: 0;
  border: 0;
  border-radius: var(--r-lg);
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}
.trainer[open] { display: block; }
.trainer::backdrop { background: var(--scrim); }
@media (max-width: 600px) {
  .trainer { width: 100vw; height: 100dvh; border-radius: 0; }
}

.tr-shell { display: flex; flex-direction: column; height: 100%; }
.tr-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px 8px; }
.tr-titles { flex: 1; min-width: 0; }
.tr-title { margin: 0; font-size: var(--fs-lead); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-mode-name { color: var(--muted); font-size: var(--fs-ui); min-height: 1.2em; }
.tr-head .icon-btn { font-size: var(--fs-2xl); width: 44px; height: 44px; }

.tr-progress { display: flex; align-items: center; gap: 12px; padding: 4px 16px 12px; }
.tr-progress[hidden] { display: none; }
.tr-bar { flex: 1; height: 10px; border-radius: 999px; background: var(--border); overflow: hidden; }
.tr-bar-fill { height: 100%; width: 0; border-radius: 999px; background: var(--accent); transition: width var(--dur-base) var(--ease-out); }
.tr-progress-text { color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; }

.tr-body { flex: 1; overflow-y: auto; padding: 8px 16px 24px; outline: none; }
.tr-stage { display: flex; flex-direction: column; align-items: stretch; gap: 16px; }
/* Этап тренажёра — подпись-«eyebrow» между двумя короткими золотыми чертами, а не таблетка. */
.tr-stage-label { align-self: center; display: flex; align-items: center; gap: var(--sp-3); color: var(--accent); font: 700 var(--fs-xs) / 1.3 var(--font-text); letter-spacing: 0.16em; text-transform: uppercase; }
.tr-stage-label::before, .tr-stage-label::after { content: ''; width: var(--sp-6); height: 1px; background: var(--frame); }
.tr-center { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 40px 0; text-align: center; }
.tr-empty, .tr-lead { margin: 0; font-size: var(--fs-lg); }
.tr-note { margin: 8px 0; padding: 10px 14px; border-radius: var(--radius); background: var(--warn-soft); }

/* Выбор режима */
.tr-modes { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-top: 12px; }
.tr-mode-card {
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start; text-align: left;
  min-height: 96px; padding: 14px 16px; font: inherit; color: inherit; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.tr-mode-card:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.tr-mode-card:disabled { opacity: 0.55; cursor: not-allowed; }
.tr-mode-title { font-weight: 700; font-size: var(--fs-lg); }
.tr-mode-desc { color: var(--muted); font-size: var(--fs-ui); }
.tr-mode-problem { color: var(--bad); font-size: var(--fs-sm); font-weight: 600; }

/* Задания */
.tr-prompt-label { text-align: center; color: var(--muted); font-size: var(--fs-ui); }
.tr-prompt { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; text-align: center; font-size: var(--fs-glyph); font-weight: 800; overflow-wrap: anywhere; }
.tr-prompt-trans { color: var(--accent); }
.tr-equals { text-align: center; color: var(--muted); font-size: var(--fs-heading); line-height: 1; }
.tr-example { text-align: center; color: var(--muted); font-style: italic; }
.tr-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.tr-row .btn { min-height: 48px; }
.tr-big { flex: 1 1 140px; max-width: 260px; font-size: var(--fs-lg); }
.tr-speak { font-size: var(--fs-xl); width: 44px; height: 44px; }

.tr-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  min-height: 240px; padding: 24px; text-align: center; cursor: pointer; user-select: none;
  background: var(--surface); border: 2px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.tr-card:focus-visible { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.tr-card.flipped { background: var(--accent-soft); border-color: var(--accent); }
/* Крупные размеры тренажёра (1.5–3rem) — отдельная «экранная» шкала карточек и слов, вне --fs-*. */
.tr-card-word { font-size: 2.4rem; font-weight: 800; overflow-wrap: anywhere; }
.tr-card-trans { font-size: var(--fs-3xl); font-weight: 800; overflow-wrap: anywhere; }
.tr-card-example { color: var(--muted); font-style: italic; }
.tr-card-orig { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.tr-hint { color: var(--muted); font-size: var(--fs-sm); }

.tr-opts { display: grid; gap: 10px; }
.tr-opt {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 16px; text-align: left;
  font: inherit; font-weight: 600; color: inherit; cursor: pointer;
  background: var(--surface); border: 2px solid var(--border); border-radius: var(--r-lg);
}
.tr-opt:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.tr-opt-key { flex: none; display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: var(--r-sm); background: var(--bg); color: var(--muted); font-size: var(--fs-sm); }
.tr-opt:disabled { cursor: default; color: inherit; }
.tr-opt.ok, .tr-tile.ok, .tr-pair.ok, .tr-input.ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.tr-opt.bad, .tr-tile.bad, .tr-pair.bad, .tr-input.bad { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }

/* Плитки */
.tr-tiles { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.tr-built { min-height: 68px; padding: 10px; align-items: center; background: var(--surface); border: 2px dashed var(--border); border-radius: var(--r-lg); }
.tr-placeholder { color: var(--muted); font-size: var(--fs-ui); }
.tr-tile {
  min-width: 48px; min-height: 48px; padding: 8px 14px; font: inherit; font-size: var(--fs-xl); font-weight: 800;
  color: var(--accent); cursor: pointer; background: var(--accent-soft); border: 2px solid transparent; border-radius: var(--r-md);
}
.tr-tile:hover:not(:disabled) { border-color: var(--accent); }
.tr-tile.placed { background: var(--surface); border-color: var(--accent); }
.tr-tile:disabled { cursor: default; }

/* Ввод */
.tr-input {
  width: 100%; min-height: 56px; padding: 10px 16px; font: inherit; font-size: var(--fs-xl); text-align: center; color: var(--text);
  background: var(--surface); border: 2px solid var(--border); border-radius: var(--r-lg); box-sizing: border-box;
}
.tr-input:focus { outline: none; border-color: var(--accent); }
.tr-mask { text-align: center; font-family: var(--mono); font-size: 1.5rem; letter-spacing: 2px; color: var(--accent); min-height: 1.6em; overflow-wrap: anywhere; }
.tr-listen-btn {
  align-self: center; width: 120px; height: 120px; font-size: 3rem; cursor: pointer;
  color: var(--accent); background: var(--accent-soft); border: 3px solid var(--accent); border-radius: 50%;
}
.tr-listen-btn:active { transform: scale(0.96); }

/* Пары */
.tr-pairs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.tr-col { display: flex; flex-direction: column; gap: 10px; }
.tr-pair {
  min-height: 56px; padding: 8px 12px; font: inherit; font-weight: 700; color: inherit; cursor: pointer; overflow-wrap: anywhere;
  background: var(--surface); border: 2px solid var(--border); border-radius: var(--r-lg); transition: opacity var(--dur-base) var(--ease-out);
}
.tr-pair:hover { border-color: var(--accent); }
.tr-pair.selected { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.tr-pair.gone { opacity: 0; pointer-events: none; }

/* Обратная связь */
.tr-feedback-slot { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.tr-feedback { padding: 14px 16px; border-radius: var(--r-lg); font-size: var(--fs-lg); }
.tr-feedback.ok { background: var(--ok-soft); color: var(--ok); }
.tr-feedback.bad { background: var(--bad-soft); color: var(--bad); }
.tr-feedback-title { font-weight: 800; }
.tr-answer { margin-top: 4px; color: var(--text); }
.tr-next { min-height: 52px; font-size: var(--fs-lg); }

/* Итоги */
.tr-summary { display: flex; flex-direction: column; gap: 20px; padding-top: 12px; }
.tr-score { text-align: center; font-size: var(--fs-3xl); font-weight: 800; color: var(--accent); }
.tr-perfect { text-align: center; color: var(--ok); font-weight: 700; margin: 0; }
.tr-mistakes { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 12px 16px; }
.tr-mistakes h3 { margin: 0 0 8px; font-size: var(--fs-base); }
.tr-mistakes ul { list-style: none; margin: 0; padding: 0; }
.tr-mistakes li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-top: 1px solid var(--border); }
.tr-mistakes li:first-child { border-top: 0; }
.tr-actions { display: flex; flex-direction: column; gap: 10px; }
.tr-actions .btn { min-height: 52px; font-size: var(--fs-lg); }

@media (max-width: 400px) {
  .tr-prompt { font-size: var(--fs-2xl); }
  .tr-card-word, .tr-card-trans { font-size: 1.8rem; }
  .tr-tile { min-width: 42px; padding: 8px 10px; }
}

/* Шрифты и радиусы из DESIGN.md */
.trainer { border-radius: var(--r-lg); }
/* На телефоне тренажёр во весь экран — без скруглённых углов (правило выше перебивало мобильное). */
@media (max-width: 600px) {
  .trainer { border-radius: 0; }
}
.tr-title, .tr-mode-title, .tr-prompt, .tr-card-word, .tr-card-trans, .tr-score { font-family: var(--font-display); font-weight: 700; }
.tr-mode-card, .tr-opt, .tr-built, .tr-input, .tr-pair, .tr-feedback, .tr-mistakes { border-radius: var(--r-lg); }
.tr-card { border-radius: var(--r-lg); }
.tr-tile { border-radius: var(--r-md); }
.tr-mode-card, .tr-opt, .tr-tile, .tr-pair, .tr-listen-btn {
  transition: transform var(--dur-release) var(--ease-spring), background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.tr-mode-card:active:not(:disabled), .tr-opt:active:not(:disabled), .tr-tile:active:not(:disabled), .tr-pair:active { transform: scale(0.97); transition-duration: var(--dur-press); }
.tr-card { transition: background-color var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out); }
.trainer[open] { animation: pop-in var(--dur-base) var(--ease-out); }
@media (prefers-reduced-motion: reduce) {
  .tr-mode-card:active, .tr-opt:active, .tr-tile:active, .tr-pair:active { transform: none; }
}