/*
 * EasyMath — оформление исходного EasyEnglish в стиле Apple iOS.
 * Системные шрифты SF, цвета iOS, light/dark по системной теме,
 * учёт safe-area (чёлка и Home Indicator iPhone).
 */

/* ---------- Палитра и переменные (светлая тема по умолчанию) ---------- */
:root {
  color-scheme: light;
  --bg: #f2f2f7;            /* системный фон iOS (grouped) */
  --bg-elevated: #ffffff;   /* карточки/строки */
  --separator: rgba(60, 60, 67, 0.18);
  --label: #000000;         /* основной текст */
  --label-2: rgba(60, 60, 67, 0.6);   /* вторичный текст */
  --label-3: rgba(60, 60, 67, 0.3);   /* третичный */
  --tint: #007aff;          /* системный синий iOS */
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9500;
  --fill: rgba(120, 120, 128, 0.12);  /* заливка кнопок-чипов */
  --seg-thumb: #ffffff;               /* активный сегмент segmented control */
  --radius: 14px;
  --radius-lg: 22px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
          "Segoe UI", system-ui, sans-serif;
}

/* ---------- Тёмная тема ----------
   Применяется автоматически по системной теме (если пользователь не выбрал
   светлую вручную) ИЛИ принудительно через data-theme="dark". */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #000000;
    --bg-elevated: #1c1c1e;
    --separator: rgba(84, 84, 88, 0.6);
    --label: #ffffff;
    --label-2: rgba(235, 235, 245, 0.6);
    --label-3: rgba(235, 235, 245, 0.3);
    --tint: #0a84ff;
    --green: #30d158;
    --red: #ff453a;
    --orange: #ff9f0a;
    --fill: rgba(120, 120, 128, 0.24);
    --seg-thumb: #636366;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --bg-elevated: #1c1c1e;
  --separator: rgba(84, 84, 88, 0.6);
  --label: #ffffff;
  --label-2: rgba(235, 235, 245, 0.6);
  --label-3: rgba(235, 235, 245, 0.3);
  --tint: #0a84ff;
  --green: #30d158;
  --red: #ff453a;
  --orange: #ff9f0a;
  --fill: rgba(120, 120, 128, 0.24);
  --seg-thumb: #636366;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  /* Окно само НЕ скроллится — прокрутка живёт внутри .content каждого экрана */
  overflow: hidden;
  /* Отключаем двойной тап-зум (pinch-зум для доступности остаётся) */
  touch-action: manipulation;
  background: var(--bg);
  color: var(--label);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

/* Запрет выделения текста на интерфейсных элементах (нативное ощущение) */
button, .row, .nav, .option, .chip { user-select: none; -webkit-user-select: none; }

/* Контейнер приложения — точно во весь видимый вьюпорт.
   position:fixed + inset:0 надёжнее, чем height:100vh: на iOS в standalone-PWA
   100vh бывает больше реального экрана, и низ (кнопки) уходит за край. */
#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

/* ---------- Экран: шапка + скролл-контент + футер ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Непрозрачный фон: при переходе верхний экран полностью перекрывает нижний */
  background: var(--bg);
}

/* Плавные кривые в духе iOS (заточено под 120 Гц / ProMotion) */
:root { --ease-ios: cubic-bezier(0.22, 0.61, 0.36, 1); }

/* Переходы между экранами с наложением (нативный push/pop) */
/* Чистый кросс-фейд без вертикального сдвига — чтобы шапка не «съезжала» при входе */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
/* translate3d форсирует GPU-слой — убирает «белую вспышку» при переходе на iOS */
@keyframes scrInRight  { from { transform: translate3d(100%, 0, 0); }              to { transform: translate3d(0, 0, 0); } }
@keyframes scrOutLeft  { from { transform: translate3d(0, 0, 0); opacity: 1; }     to { transform: translate3d(-28%, 0, 0); opacity: 0.55; } }
@keyframes scrInLeft   { from { transform: translate3d(-28%, 0, 0); opacity: 0.55; } to { transform: translate3d(0, 0, 0); opacity: 1; } }
@keyframes scrOutRight { from { transform: translate3d(0, 0, 0); }                 to { transform: translate3d(100%, 0, 0); } }
.anim-fade     { animation: fade 0.3s var(--ease-ios); }
.scr-in-right, .scr-out-left, .scr-in-left, .scr-out-right {
  will-change: transform; backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.scr-in-right  { animation: scrInRight 0.36s var(--ease-ios); }
.scr-out-left  { animation: scrOutLeft 0.36s var(--ease-ios) forwards; }
.scr-in-left   { animation: scrInLeft 0.36s var(--ease-ios); }
.scr-out-right { animation: scrOutRight 0.36s var(--ease-ios) forwards; }

/* Экраны и так всегда position:absolute (см. .screen), наложение бесплатно. */

/* Интерактивный свайп-назад: drag — без перехода (едет за пальцем),
   snap — плавная доводка/отскок, shadow — тень у края верхнего экрана. */
.screen-drag { transition: none !important; will-change: transform; }
.screen-snap { transition: transform 0.32s var(--ease-ios); will-change: transform; }
.screen-shadow { box-shadow: -6px 0 24px rgba(0, 0, 0, 0.18); }

/* Каскадное появление списка «Fast waterfall» (сверху вниз) */
@keyframes fastWaterfall {
  from { opacity: 0; filter: blur(10px); transform: translateY(-10px); }
  to   { opacity: 1; filter: blur(0);    transform: translateY(0); }
}
.waterfall { animation: fastWaterfall 0.48s cubic-bezier(0.25, 0.85, 0.25, 1) both; }
@media (prefers-reduced-motion: reduce) {
  .waterfall { animation: none; opacity: 1; filter: none; transform: none; }
}

/* Появление элементов «лесенкой» */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pop  { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-11px); } 30% { transform: translateX(11px); }
  45% { transform: translateX(-8px); } 60% { transform: translateX(8px); }
  75% { transform: translateX(-4px); } 90% { transform: translateX(4px); }
}
@keyframes correctPulse {
  0% { transform: scale(1); }
  35% { transform: scale(1.07); }
  70% { transform: scale(0.98); }
  100% { transform: scale(1); }
}
@keyframes confetti {
  0% { opacity: 1; transform: translate(0, 0) scale(1) rotate(0deg); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.4) rotate(240deg); }
}

/* ---------- Навигационная панель (фиксированная шапка экрана) ---------- */
.nav {
  flex: none;
  padding: calc(8px + var(--safe-top)) 16px 8px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  background: var(--bg);
}
.nav__title { text-align: center; font-weight: 600; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Тап-цели с запасом (комфортнее стандартных iOS 44px) */
.nav__btn {
  background: none; border: none; color: var(--tint);
  font-size: 18px; font-weight: 500; cursor: pointer;
  min-width: 56px; min-height: 50px; padding: 0 10px;
  display: inline-flex; align-items: center; gap: 3px;
  transition: opacity 0.15s ease, transform 0.12s var(--ease-ios);
}
.nav__btn:active { opacity: 0.4; transform: scale(0.88); }
.nav__btn--right { justify-content: flex-end; }
/* Иконочная кнопка (шестерёнка) — центрированная SVG без подложки */
.nav__btn--icon { justify-content: flex-end; min-width: 56px; }
.nav__btn--icon svg { width: 27px; height: 27px; display: block; }
.nav__btn--icon:active svg { transform: scale(0.86); }

/* Крупный заголовок (large title) */
.large-title { flex: none; font-size: 34px; font-weight: 700; letter-spacing: 0.2px; padding: 4px 20px 12px; }

/* ---------- Контент: единственная скролл-область экрана ---------- */
.content {
  flex: 1;
  min-height: 0;                 /* обязательно, иначе flex-ребёнок не скроллится */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overflow-anchor: none;         /* не дёргать прокрутку при появлении/анимации элементов */
  scrollbar-gutter: stable;      /* не сдвигать контент, когда появляется скроллбар */
  padding: 0 16px calc(16px + var(--safe-bottom));
}
.subtitle { color: var(--label-2); font-size: 15px; padding: 0 20px 16px; }

/* ---------- Сгруппированные списки (Settings-style) ---------- */
.group { background: var(--bg-elevated); border-radius: var(--radius); overflow: hidden; margin-bottom: 24px; }
.group__header { color: var(--label-2); font-size: 13px; text-transform: uppercase; letter-spacing: 0.4px; padding: 8px 16px; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; min-height: 48px;
  border-bottom: 0.5px solid var(--separator);
  cursor: pointer; background: var(--bg-elevated);
}
.row:last-child { border-bottom: none; }
.row:active { background: var(--fill); }
.row__icon { width: 29px; height: 29px; border-radius: 7px; display: grid; place-items: center; font-size: 17px; color: #fff; flex: none; }
.row__text { flex: 1; }
.row__title { font-size: 17px; }
.row__sub { font-size: 13px; color: var(--label-2); }
.row__value { color: var(--label-2); }
.row__chevron { color: var(--label-3); font-size: 17px; }

/* ---------- Кнопки ---------- */
.btn {
  display: block; width: 100%; border: none; cursor: pointer;
  font-family: var(--font); font-size: 17px; font-weight: 600;
  padding: 15px; border-radius: var(--radius);
  transition: transform 0.13s var(--ease-ios), opacity 0.15s, filter 0.15s;
}
.btn:active { transform: scale(0.96); filter: brightness(0.94); }
.btn--primary { background: var(--tint); color: #fff; }
.btn--tinted { background: var(--fill); color: var(--tint); }
.btn--ghost { background: none; color: var(--tint); font-weight: 500; }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn-stack { display: flex; flex-direction: column; gap: 12px; padding: 8px 4px; }

/* ---------- Вход, регистрация и личный аккаунт ---------- */
[hidden] { display: none !important; }
.nav__actions { display: flex; justify-content: flex-end; align-items: center; }
.nav__actions .nav__btn { min-width: 44px; padding: 0 6px; }
.nav__btn--account svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.65; }
.auth-content { display: flex; padding: 0 22px calc(30px + var(--safe-bottom)); }
.auth-wrap { width: min(100%, 420px); margin: auto; padding-top: 20px; }
.auth-hero { text-align: center; padding: 12px 0 28px; }
.auth-hero--compact { padding-top: 24px; }
.auth-app-icon { display: block; margin: 0 auto 23px; border-radius: 19px; box-shadow: 0 8px 24px rgba(0, 122, 255, 0.15); }
.auth-title { margin: 0; font-size: clamp(27px, 7.3vw, 34px); font-weight: 700; letter-spacing: -1px; line-height: 1.15; }
.auth-subtitle { margin: 12px auto 0; color: var(--label-2); font-size: 15px; line-height: 1.5; max-width: 330px; }
.auth-form { width: 100%; }
.auth-tabs { margin-bottom: 22px; }
.auth-tabs .segment__item { min-height: 42px; }
.auth-fields { overflow: hidden; border-radius: 18px; background: var(--bg-elevated); border: 0.5px solid var(--separator); }
.auth-field { padding: 12px 16px 8px; border-bottom: 0.5px solid var(--separator); }
.auth-field:last-child { border-bottom: none; }
.auth-field__label { display: block; font-size: 12px; font-weight: 600; color: var(--label-2); }
.auth-field__control { display: flex; align-items: center; min-height: 40px; gap: 6px; }
.auth-field__input {
  width: 100%; min-width: 0; border: 0; outline: 0; padding: 8px 0;
  font: inherit; font-size: 17px; color: var(--label); background: var(--bg-elevated);
  appearance: none; -webkit-appearance: none;
  caret-color: var(--label); -webkit-text-fill-color: var(--label);
  /* Внутренняя заливка перекрывает жёлтый фон всех вариантов автозаполнения Safari. */
  box-shadow: inset 0 0 0 1000px var(--bg-elevated);
}
.auth-field:focus-within { box-shadow: inset 3px 0 0 var(--tint); }
.auth-field__input::placeholder { color: var(--label-3); -webkit-text-fill-color: var(--label-3); }
.auth-field__reveal { border: 0; background: none; color: var(--label-2); cursor: pointer; min-width: 44px; min-height: 44px; display: grid; place-items: center; padding: 8px; }
.auth-field__reveal svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.auth-field__reveal[aria-pressed="true"] { color: var(--tint); }
.auth-form__hint { font-size: 13px; color: var(--label-2); line-height: 1.5; margin: 12px 3px 18px; }
.auth-submit { margin-top: 22px; min-height: 54px; display: flex; justify-content: center; align-items: center; gap: 10px; }
.auth-submit__spinner { display: none; width: 17px; height: 17px; border: 2px solid rgba(255,255,255,0.4); border-top-color: white; border-radius: 50%; animation: loaderSpin 0.7s linear infinite; }
.auth-submit--busy .auth-submit__spinner { display: inline-block; }
.auth-message { margin: 16px 0; padding: 12px 14px; border-radius: 12px; color: var(--red); background: color-mix(in srgb, var(--red) 8%, var(--bg-elevated)); font-size: 14px; line-height: 1.45; }
.auth-message--info { color: var(--tint); background: color-mix(in srgb, var(--tint) 8%, var(--bg-elevated)); }
.auth-footnote { color: var(--label-2); text-align: center; font-size: 13px; line-height: 1.5; margin: 25px 12px 8px; }
.account-hero { text-align: center; padding: 30px 10px; }
.account-avatar { width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 18px; font-size: 32px; font-weight: 600; color: var(--tint); background: color-mix(in srgb, var(--tint) 12%, var(--bg-elevated)); }
.account-email { font-size: 23px; font-weight: 600; letter-spacing: -0.5px; overflow-wrap: anywhere; margin: 0; }
.account-action { display: flex; justify-content: space-between; gap: 12px; width: 100%; background: var(--bg-elevated); border: 0; padding: 16px; min-height: 52px; color: var(--tint); font: inherit; text-align: left; cursor: pointer; }
.account-action--profile { color: var(--label); }
.account-action--profile span:first-child { overflow: hidden; text-overflow: ellipsis; }
.account-action:active { background: var(--fill); }
.account-action:disabled { opacity: 0.45; cursor: default; }
.account-logout-all { color: var(--red); }
.auth-screen button:focus-visible, .account-action:focus-visible { outline: 2px solid var(--tint); outline-offset: 3px; }
@media (max-height: 650px) {
  .auth-wrap { padding-top: 8px; }
  .auth-hero { padding: 8px 0 20px; }
  .auth-app-icon { width: 60px; height: 60px; margin-bottom: 16px; }
}

/* ---------- Прогресс-бар сессии ---------- */
.progress { height: 6px; background: var(--fill); border-radius: 3px; overflow: hidden; margin: 4px 4px 18px; }
.progress__fill { height: 100%; background: var(--green); border-radius: 3px; transition: width 0.35s ease; }

/* ---------- Карточка задания ---------- */
.task { padding: 4px; flex: 1; display: flex; flex-direction: column; }
.task__prompt { font-size: 15px; color: var(--label-2); margin-bottom: 8px; }
.task__sentence { font-size: 24px; font-weight: 500; line-height: 1.35; margin-bottom: 8px; }
.task__translation { font-size: 17px; color: var(--label-2); margin-bottom: 20px; }
.blank { display: inline-block; min-width: 64px; border-bottom: 2px dashed var(--tint); color: var(--tint); text-align: center; }
.blank--filled { border-bottom-style: solid; color: var(--label); }

/* Варианты ответа (квиз) */
.options { display: flex; flex-direction: column; gap: 12px; }
.option {
  display: block;
  padding: 16px; border-radius: var(--radius); background: var(--bg-elevated);
  border: 1.5px solid transparent; font-size: 19px; text-align: center; cursor: pointer;
  transition: transform 0.13s var(--ease-ios), border-color 0.2s, background 0.2s;
}
.option:active { transform: scale(0.97); }
.option--correct { border-color: var(--green); background: color-mix(in srgb, var(--green) 16%, var(--bg-elevated)); color: var(--green); font-weight: 600; }
.option--wrong { border-color: var(--red); background: color-mix(in srgb, var(--red) 16%, var(--bg-elevated)); color: var(--red); font-weight: 600; }
.option--disabled { pointer-events: none; opacity: 0.55; }
/* Экзамен: выбранный вариант без раскрытия правильности (нейтрально) */
.option--picked { border-color: var(--tint); background: color-mix(in srgb, var(--tint) 12%, var(--bg-elevated)); font-weight: 600; opacity: 1; }

/* Поле ввода (fill-in) */
.field {
  width: 100%; padding: 16px; font-size: 19px; font-family: var(--font);
  background: var(--bg-elevated); border: 1.5px solid var(--separator);
  border-radius: var(--radius); color: var(--label); outline: none; text-align: center;
}
.field:focus { border-color: var(--tint); }
.field--correct { border-color: var(--green); color: var(--green); }
.field--wrong { border-color: var(--red); color: var(--red); }

/* Чипы слов (ребус / перевод) */
.answer-line {
  min-height: 56px; border-radius: var(--radius); background: var(--fill);
  padding: 10px; display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px;
}
.answer-line--correct { outline: 2px solid var(--green); outline-offset: 1px; }
.answer-line--wrong { outline: 2px solid var(--red); outline-offset: 1px; }
.bank { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 11px 15px; border-radius: 10px; background: var(--bg-elevated);
  border: 1px solid var(--separator); font-size: 17px; cursor: pointer;
  transition: transform 0.15s var(--ease-ios), opacity 0.2s, background 0.2s, color 0.2s;
}
.chip:active { transform: scale(0.9); }
/* Использованное слово остаётся видимым, но явно помечено как выбранное */
.chip--used {
  opacity: 0.3; pointer-events: none; transform: scale(0.92);
  background: var(--fill); border-style: dashed; color: var(--label-3);
}
.chip--placed { background: var(--tint); color: #fff; border-color: transparent; }

/* ---------- Подсказка и разбор ---------- */
.hint {
  background: color-mix(in srgb, var(--orange) 14%, var(--bg-elevated));
  border-radius: var(--radius); padding: 12px 14px; font-size: 15px;
  color: var(--label); margin: 12px 0;
}
.explain {
  border-radius: var(--radius); padding: 14px; margin: 12px 0;
  font-size: 15px; line-height: 1.45;
}
.explain--ok { background: color-mix(in srgb, var(--green) 14%, var(--bg-elevated)); }
.explain--bad { background: color-mix(in srgb, var(--red) 12%, var(--bg-elevated)); }
.explain__title { font-weight: 600; margin-bottom: 6px; }
.explain__rule { color: var(--label-2); margin-top: 8px; }

/* ---------- Нижняя панель действий (фиксированный футер экрана) ---------- */
.footer {
  flex: none;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: var(--bg);
  border-top: 0.5px solid var(--separator);
}

/* ---------- Segmented control (сложность) ---------- */
.segment {
  display: flex; gap: 2px; padding: 2px; border-radius: 11px;
  background: var(--fill);
}
.segment__item {
  flex: 1; border: none; background: transparent; color: var(--label);
  font-family: var(--font); font-size: 15px; font-weight: 500;
  padding: 9px 6px; border-radius: 9px; cursor: pointer;
  transition: transform 0.13s var(--ease-ios), background 0.2s;
}
.segment__item:active { transform: scale(0.95); }
.segment__item--on {
  background: var(--seg-thumb); font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
}

/* ---------- Кнопки выбора размера урока ---------- */
.size-btn {
  border: none; background: var(--fill); color: var(--tint);
  font-family: var(--font); font-size: 17px; font-weight: 600;
  min-width: 48px; padding: 8px 14px; border-radius: 10px; cursor: pointer;
  transition: transform 0.13s var(--ease-ios), background 0.2s, color 0.2s;
}
.size-btn:active { transform: scale(0.92); }
.size-btn--on { background: var(--tint); color: #fff; }

/* ---------- Список тем: тап-зона чекбокса и подсказка кликабельности ---------- */
.check-tap {
  min-width: 44px; min-height: 44px; display: grid; place-items: center;
  margin: -6px -8px -6px 0; cursor: pointer;
}
/* Заголовок темы один раз «подмигивает», показывая, что он кликабелен */
@keyframes tapHint {
  0%, 100% { transform: translateX(0); color: var(--label); }
  20% { color: var(--tint); }
  35% { transform: translateX(7px); }
  60% { transform: translateX(0); color: var(--tint); }
}
.row__title--hint { animation: tapHint 1.2s var(--ease-ios) 0.45s 1; }

/* ---------- Страница темы ---------- */
.rule-card {
  background: var(--bg-elevated); border-radius: var(--radius);
  padding: 16px; margin-bottom: 24px; position: relative;
}
.rule-card__badge {
  position: absolute; top: 14px; right: 14px; background: var(--fill);
  color: var(--label-2); font-size: 13px; font-weight: 600;
  padding: 2px 9px; border-radius: 8px;
}
.rule-card__title {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--label-2); margin-bottom: 6px;
}
.rule-card__text { font-size: 17px; line-height: 1.45; padding-right: 48px; }
.example { padding: 12px 16px; border-bottom: 0.5px solid var(--separator); }
.example:last-child { border-bottom: none; }
.example__en { font-size: 17px; }
.example__target { color: var(--tint); font-weight: 600; }
.example__ru { font-size: 14px; color: var(--label-2); margin-top: 2px; }

/* ---------- Чекбоксы тем ---------- */
.check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--label-3); display: grid; place-items: center; flex: none; }
.check--on { background: var(--tint); border-color: var(--tint); }
.check--on::after { content: "✓"; color: #fff; font-size: 15px; font-weight: 700; }

/* ---------- Экран результата ---------- */
.result-hero { flex: none; text-align: center; padding: 40px 20px 24px; }
.result-score { font-size: 64px; font-weight: 800; color: var(--tint); }
.result-label { font-size: 17px; color: var(--label-2); }
.result-emoji { font-size: 72px; }

/* ---------- Стрик/бейджи на главной ---------- */
.stats { display: flex; gap: 12px; padding: 0 4px 24px; }
.stat { flex: 1; background: var(--bg-elevated); border-radius: var(--radius); padding: 16px; text-align: center; }
.stat__num { font-size: 28px; font-weight: 700; }
.stat__cap { font-size: 13px; color: var(--label-2); }

/* ---------- Баннер «на домашний экран» ---------- */
.install-banner { background: var(--bg-elevated); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 20px; font-size: 15px; color: var(--label-2); }
.install-banner b { color: var(--label); }

.center-msg { text-align: center; color: var(--label-2); padding: 60px 20px; }

/* ---------- Тактильные кнопки (label со скрытым switch для iOS-haptic) ---------- */
/* Без display — чтобы класс компоновался с .option (block) и .btn (block). */
.haptic-button {
  position: relative; cursor: pointer;
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
/* Скрытый switch перекрывает ВСЮ площадь кнопки, чтобы реальный тап на iOS
   всегда попадал по нему и срабатывал системный haptic. appearance НЕ трогаем —
   иначе элемент перестанет быть «switch» и haptic пропадёт. */
.haptic-switch {
  position: absolute; inset: 0; width: 100%; height: 100%;
  margin: 0; opacity: 0; cursor: pointer; z-index: 1;
}
.haptic-content { position: relative; z-index: 0; display: inline; pointer-events: none; }

/* ---------- Кольцо прогресса ---------- */
.ring-wrap { position: relative; display: grid; place-items: center; flex: none; }
.ring__bg { stroke: var(--fill); }
.ring__fg { transition: stroke-dashoffset 0.7s var(--ease-ios); }
.ring__label { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; line-height: 1.05; }
.ring__label b { font-size: 22px; font-weight: 700; display: block; }
.ring__label span { font-size: 10px; color: var(--label-2); }

/* ---------- Герой уровня на главной ---------- */
.level-hero {
  display: flex; gap: 16px; align-items: center;
  background: var(--bg-elevated); border-radius: var(--radius-lg);
  padding: 18px; margin-bottom: 16px;
}
.level-hero__info { flex: 1; min-width: 0; }
.level-hero__badge { display: inline-block; color: #fff; font-weight: 700; font-size: 12px; padding: 2px 9px; border-radius: 6px; }
.level-hero__title { font-size: 22px; font-weight: 700; margin-top: 6px; }
.level-hero__sub { font-size: 13px; color: var(--label-2); margin-top: 2px; }
.level-hero__streak { font-size: 14px; margin-top: 10px; }

/* Кнопка-CTA с подзаголовком */
.cta { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.cta__label { font-size: 17px; font-weight: 600; }
.cta__sub { font-size: 13px; font-weight: 500; opacity: 0.9; }

/* Тонкий прогресс-бар (мини) */
.minibar { height: 8px; background: var(--fill); border-radius: 4px; overflow: hidden; }
.minibar__fill { height: 100%; border-radius: 4px; background: var(--tint); transition: width 0.6s var(--ease-ios); }

/* Обзор уровней на главной */
.lvl-list { background: var(--bg-elevated); border-radius: var(--radius); overflow: hidden; }
.lvl-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 0.5px solid var(--separator); cursor: pointer; }
.lvl-row:last-child { border-bottom: none; }
.lvl-row:active { background: var(--fill); }
.lvl-row__tag { color: #fff; font-weight: 700; font-size: 12px; padding: 3px 8px; border-radius: 6px; flex: none; }
.lvl-row__body { flex: 1; min-width: 0; }
.lvl-row__top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; }
.lvl-row__name { font-size: 15px; font-weight: 500; }
.lvl-row__count { font-size: 13px; color: var(--label-2); }

/* ---------- Лестница (экран Урок) ---------- */
.ladder-section { margin-bottom: 28px; }
.ladder-head { display: flex; gap: 14px; align-items: center; padding: 6px 4px 14px; }
.ladder-head__body { flex: 1; min-width: 0; }
.ladder-head__title { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.ladder-head__sub { font-size: 13px; color: var(--label-2); margin-top: 3px; }

.ladder-path { position: relative; }
.ladder-path::before {
  content: ""; position: absolute; left: 21px; top: 22px; bottom: 22px;
  width: 2px; background: var(--separator);
}
.trow { display: flex; align-items: center; gap: 14px; padding: 9px 4px; cursor: pointer; }
.trow--locked { cursor: default; }
.trow:not(.trow--locked):active { transform: scale(0.99); }
.tnode {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  font-size: 20px; flex: none; position: relative; z-index: 1;
  background: var(--bg-elevated); border: 2px solid var(--separator);
  transition: transform 0.12s var(--ease-ios);
}
.tnode--open { border-color: var(--node); background: color-mix(in srgb, var(--node) 15%, var(--bg-elevated)); }
.tnode--done { background: var(--node); color: #fff; border-color: var(--node); font-weight: 700; }
.tnode--locked { color: var(--label-3); }
.trow:active .tnode--open { transform: scale(0.9); }
.trow__body { flex: 1; min-width: 0; }
.trow__title { font-size: 16px; font-weight: 500; margin-bottom: 6px; }
.trow__title--locked { color: var(--label-3); margin-bottom: 0; }
.trow__soon { font-size: 12px; color: var(--label-3); background: var(--fill); padding: 3px 9px; border-radius: 8px; flex: none; }

/* Прогресс темы в карточке правила */
.rule-card__progress { margin-top: 14px; }
.rule-card__progresslbl { font-size: 12px; color: var(--label-2); margin-top: 6px; }

/* ---------- Анимации интерфейса (120 Гц) ---------- */

/* Варианты квиза появляются «лесенкой» */
.options .option { animation: rise 0.32s var(--ease-ios) both; }
.options .option:nth-child(2) { animation-delay: 0.04s; }
.options .option:nth-child(3) { animation-delay: 0.08s; }
.options .option:nth-child(4) { animation-delay: 0.12s; }

/* Слова-чипы тоже всплывают по очереди */
.bank .chip { animation: rise 0.3s var(--ease-ios) both; }
.bank .chip:nth-child(even) { animation-delay: 0.05s; }
.chip--placed { animation: pop 0.18s var(--ease-ios); }

/* Разбор ответа мягко «выскакивает» */
.explain { animation: pop 0.3s var(--ease-ios); }

/* Неверный ответ — заметная тряска */
.option--wrong, .field--wrong, .answer-line--wrong { animation: shake 0.5s; }
/* Верный ответ — пульс */
.option--correct, .field--correct, .answer-line--correct { animation: correctPulse 0.5s var(--ease-ios); }

/* Конфетти при верном ответе */
.confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 1000; }
.confetti-piece {
  position: fixed; width: 10px; height: 10px; border-radius: 2px; opacity: 0;
  animation: confetti 0.85s var(--ease-ios) forwards;
}

/* ---------- Загрузка контента ---------- */
.content-loader {
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe-top)) 24px calc(24px + var(--safe-bottom));
  background: color-mix(in srgb, var(--bg) 86%, transparent);
}
.content-loader__blur {
  position: absolute;
  inset: 0;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.content-loader__card {
  position: relative;
  z-index: 1;
  width: min(100%, 330px);
  padding: 30px 24px 22px;
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.14);
  text-align: center;
}
.content-loader__ring {
  width: 58px;
  height: 58px;
  margin: 0 auto 18px;
  color: var(--tint);
  animation: loaderSpin 0.95s linear infinite;
}
.content-loader__ring svg { width: 100%; height: 100%; }
.content-loader__ring circle {
  fill: none;
  stroke: currentColor;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 82 44;
}
.content-loader__title { font-size: 20px; font-weight: 700; }
.content-loader__message {
  min-height: 40px;
  margin-top: 7px;
  color: var(--label-2);
  font-size: 14px;
}
.content-loader__actions { margin-top: 18px; }
.content-loader__actions .btn + .btn { margin-top: 8px; }
@keyframes loaderSpin { to { transform: rotate(360deg); } }

/* ---------- Полностью исчерпанный контент ---------- */
.content-complete {
  min-height: 48vh;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
}
.content-complete__mark {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--green) 16%, var(--bg-elevated));
  color: var(--green);
  font-size: 34px;
  font-weight: 700;
}
.content-complete__title { margin-top: 18px; font-size: 22px; font-weight: 700; }
.content-complete__text { margin-top: 7px; color: var(--label-2); font-size: 14px; }

/* Уважаем системную настройку «уменьшить движение» */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
  .content-loader__ring { animation: none; }
}
