/* =========================================================
   Токены дизайна — светлый стиль A.
   Источник правды: docs/design-spec.md.
   Тёмно-зелёная «доска с маркерами» удалена целиком вместе
   со своими токенами: ни одно правило их больше не использовало.
   ========================================================= */
* { box-sizing: border-box; }

/* ПРАВИЛО ВМЕСТО ПЕРЕЧНЯ (02.09): любой авторский display (flex/grid/block)
   перебивает браузерное [hidden]{display:none} — элемент с атрибутом hidden
   остаётся виден. Раньше это лечилось частными страховками X[hidden] (их
   накопилось восемь, девятая — .task-edit — была пропущена и дала живой баг:
   поле «Исправить условие» раскрыто без нажатия). Одно правило закрывает
   класс целиком, включая будущие элементы.
   Безопасность проверена фактами: все восемь частных правил были чистым
   display:none без исключений; style.display в app.js не используется нигде
   (видимостью управляет только .hidden); правил, показывающих [hidden],
   в проекте нет. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--l-bg);
  color: var(--l-text);
  font-family: var(--font-system);
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  /* svh — «малый» вьюпорт (02.09): честная высота при видимой системной UI;
     с interactive-widget=resizes-content (index.html) сжимается и под
     клавиатуру в Chromium-вебвью. Строка с vh — fallback для старых. */
  min-height: 100vh;
  min-height: 100svh;
  position: relative;
  overflow: hidden;
}

.screen {
  display: none;
  min-height: 100vh;
  min-height: 100svh;
  flex-direction: column;
  position: relative;
  z-index: 1;
}
.screen[data-active="true"] { display: flex; }

/* =========================================================
   Экран решения — светлый стиль A (docs/design-spec.md).
   Свайпа больше нет: всё решение одним вертикальным списком.
   ========================================================= */
:root {
  /* Тема D «glass-пастель» (редизайн 12.09, выбор Ильи из 4 направлений):
     пастельные пятна фона + стеклянные карточки, фиолет→розовый акцент,
     Unbounded (заголовки) + Manrope (текст), обе с кириллицей. */
  --l-bg: transparent;             /* фон рисует body (пастельные пятна) */
  --l-surface: rgba(255, 255, 255, 0.62);
  --l-text: #1c1c22;
  --l-text-2: #3f3f49;
  --l-muted: #6d6f7c;
  --l-accent: #7c3aed;
  --l-accent-soft: rgba(139, 92, 246, 0.12);
  --l-accent-deep: #4c1d95;
  --l-success: #0f766e;
  --l-danger: #be123c;
  --l-line: rgba(28, 28, 34, 0.10);
  --grad: linear-gradient(135deg, #8b5cf6, #ec4899);
  --glass: rgba(255, 255, 255, 0.62);
  --glass-border: rgba(255, 255, 255, 0.95);
  --glass-shadow: 0 10px 26px rgba(124, 58, 237, 0.10);
  --font-system: Manrope, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: Unbounded, Manrope, -apple-system, sans-serif;
}

.screen-light {
  background: var(--l-bg);
  color: var(--l-text);
  font-family: var(--font-system);
  font-weight: 400;
}

.sheet-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 0.5px solid var(--l-line);
}

.sheet-back {
  border: 0.5px solid var(--l-line);
  background: var(--l-bg);
  color: var(--l-text);
  border-radius: 10px;
  width: 30px;
  height: 30px;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.sheet-title { font-size: 15px; font-weight: 500; color: var(--l-text); }

.sheet-task {
  margin-left: auto;
  font-size: 13px;
  color: var(--l-muted);
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-scroll { flex: 1; overflow-y: auto; padding: 18px 16px 8px; }

/* --- список шагов --- */
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 18px; }

.step { display: flex; gap: 12px; align-items: flex-start; }

.step-num {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--l-accent-soft);
  color: var(--l-accent);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-body { flex: 1; min-width: 0; }
.step-title { margin: 3px 0 4px; font-size: 15px; font-weight: 500; color: var(--l-text); }
/* pre-line: solver отдаёт списки и «Дано» переносами строк — без этого браузер
   схлопывал ВСЮ структуру шага в одну строку (жило с правки «пункты списком»). */
.step-text { margin: 0; font-size: 14px; line-height: 1.6; color: var(--l-text-2); white-space: pre-line; overflow-x: auto; }
/* Длинная формула KaTeX не переносится — пусть шаг скроллится вбок, а не режет её краем. */
.answer-value { overflow-x: auto; }
/* Ответ из нескольких строк (перечисление/перенос по ';'): столбик с зазором. */
.answer-value + .answer-value { margin-top: 6px; }
/* Моноширинный блок: запись столбиком/уголком из ```-ограждений солвера. */
.step-pre { display: block; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; line-height: 1.45; white-space: pre; overflow-x: auto; background: var(--l-bg-soft, #F4F3EC); border-radius: 8px; padding: 8px 10px; margin: 6px 0; }
.step-text .katex { color: var(--l-accent); }

/* --- таблицы в шагах (сравнение, образец записи) --- */
.step-table-wrap { overflow-x: auto; margin: 6px 0; white-space: normal; }
.step-table { border-collapse: collapse; font-size: 13px; min-width: 60%; }
.step-table th, .step-table td { border: 1px solid var(--l-border, #DDDCD4); padding: 5px 9px; text-align: left; vertical-align: top; }
.step-table th { background: var(--l-bg-soft, #F4F3EC); font-weight: 600; }

/* Плашка-резерв на месте будущего блока ответа при стриминге шагов. */
.answer-pending { margin: 22px 0 4px; padding: 14px; border-radius: 12px; background: var(--l-bg-soft, #F4F3EC); color: var(--l-muted, #888780); font-size: 14px; }

/* --- блок ответа --- */
.answer-block {
  margin: 22px 0 4px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--l-accent-soft);
}

.answer-label {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--l-accent);
}

.answer-value {
  margin: 0;
  font-size: 24px;
  font-weight: 500;
  color: var(--l-accent-deep);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.answer-value .katex { color: var(--l-accent-deep); }

/* Ответ списком: пункты читаются как пункты, а не как одна длинная строка. */
.answer-list {
  margin: 6px 0 0;
  padding-left: 22px;
  font-size: 17px;
  line-height: 1.45;
  color: var(--l-accent-deep);
}
.answer-list.answer-value--text { font-size: 16px; }
.answer-item { margin: 4px 0; }

/* Длинный ответ (предложение, а не «x = 5») — обычным шрифтом и мельче:
   24px моноширинным он превращался в нечитаемую простыню. */
.answer-value--mid { font-size: 19px; }
.answer-value--text {
  font-size: 16px;
  font-family: inherit;
  font-weight: 400;
  line-height: 1.45;
}

/* Выносная формула внутри шага — своей строкой, с воздухом вокруг. */
.step-formula {
  display: block;
  margin: 6px 0;
  padding-left: 2px;
  overflow-x: auto;
  overflow-y: hidden;
  font-variant-numeric: tabular-nums;
}

/* Карточка условия над решением (20.09). Светлая, с тонкой рамкой — чтобы
   читалась как переписанное в тетрадь условие, а не как ещё один шаг. */
.task-card {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--l-bg-soft, #F4F3EC);
  border: 1px solid var(--l-border, #DDDCD4);
}
.task-card-label {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--l-muted, #888780);
}
.task-card-text { font-size: 14px; line-height: 1.5; color: var(--l-text); }
.task-card-text--clamped {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.task-card-more {
  margin-top: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--l-accent);
  font-size: 13px;
  cursor: pointer;
}

/* «Дано» — плотный столбик, как в тетради: величина под величиной, без
   воздуха между строками (живой экран физики 20.09 занимал треть экрана). */
.step--given .step-text { line-height: 1.45; }
.step--given .step-formula { margin: 1px 0; }

.answer-verify {
  margin: 10px 0 0;
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 13px;
}
/* Галочка — подтверждённая верификация; warn/alert — честная плашка (12.09):
   на вычислимом предмете false больше не молчит. */
.answer-verify[data-verified="true"] { color: var(--l-success); }
.answer-verify--warn { color: #8a6d1a; }
.answer-verify--alert { color: #b3261e; font-weight: 600; }

/* --- нижние кнопки --- */
.sheet-actions {
  display: flex;
  gap: 10px;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  border-top: 0.5px solid var(--l-line);
}

.btn-light {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 12px;
  border: 0.5px solid var(--l-line);
  border-radius: 10px;
  background: var(--l-bg);
  color: var(--l-text);
  font-family: var(--font-system);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.btn-report { color: var(--l-danger); }

/* Кнопки под решением: синяя «Скинуть другу» во всю ширину сверху,
   под ней ряд из двух btn-light. Подписи не рвём. Скоуп только на экран решения. */
#screen-solution .sheet-actions { flex-wrap: wrap; }
#screen-solution .sheet-actions .btn-light { white-space: nowrap; }
#screen-solution .sheet-actions .cta {
  flex-basis: 100%;
  padding: 13px 16px;
  border: none;
  border-radius: 10px;
  background: var(--l-accent);
  color: #fff;
  font-family: var(--font-system);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}


/* =========================================================
   Экран выбора класса и предмета — светлый стиль A
   (docs/design-spec.md). Имена классов chip/chip-row/setup
   сохранены: их создаёт и читает app.js, логика не менялась.
   ========================================================= */
.brand-topbar {
  display: flex;
  align-items: center;
  padding: 16px 20px 12px;
}

.brand-logo { height: 22px; width: auto; display: block; }

/* ===== Конкурс (06.09) ===== */
/* Зелёная CTA конкурса: существующий токен --l-success из палитры,
   специфичность равная #screen-setup .cta — правило ниже, выигрывает каскадом. */
#screen-setup .cta-success { background: var(--l-success); }
#screen-contest .setup-lead { font-size: 15px; line-height: 1.45; margin-top: 10px; }
#screen-contest .cta {
  width: 100%;
  padding: 13px 16px;
  border: none;
  border-radius: 10px;
  background: var(--l-success);
  color: #fff;
  font-family: var(--font-system);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}
#screen-contest .cta:disabled { opacity: 0.55; }
.contest-form { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.contest-input {
  width: 100%;
  padding: 12px 14px;
  border: 0.5px solid var(--l-line);
  border-radius: 10px;
  background: var(--l-bg);
  color: var(--l-text);
  font-family: var(--font-system);
  font-size: 15px;
}
.contest-error { margin: 0; font-size: 14px; color: var(--l-danger); }
/* Дисклеймер про накрутку: мельче и приглушённее основного текста. */
.contest-fineprint { margin-top: 10px; font-size: 12px; line-height: 1.4; color: var(--l-muted); }
.contest-done { margin-top: 16px; font-size: 16px; font-weight: 500; color: var(--l-success); }

/* Кружок профиля в шапке настройки: фото из MAX либо инициалы-фолбэк.
   margin-left: auto — прижат к правому краю, напротив лого. */
.avatar {
  margin-left: auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--l-accent-soft);
  color: var(--l-accent);
  font-family: var(--font-system);
  font-size: 13px;
  font-weight: 600;
  flex: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.setup {
  flex: 1;
  padding: 6px 20px 28px;
  display: flex;
  flex-direction: column;
  font-family: var(--font-system);
}

.setup-lead {
  margin: 0 0 22px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--l-text-2);
}

.setup-title {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--l-muted);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 24px;
}

.chip {
  padding: 8px 14px;
  border: 0.5px solid var(--l-line);
  border-radius: 10px;
  background: var(--l-bg);
  color: var(--l-text);
  font-family: var(--font-system);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.2;
  cursor: pointer;
}

.chip[data-selected="true"] {
  background: var(--l-accent-soft);
  border-color: var(--l-accent);
  color: var(--l-accent-deep);
  font-weight: 500;
}

/* Кнопка «Дальше» перекрашивается только на этом экране: класс .cta
   продолжает использоваться тёмными экранами capture и confirm. */
.setup-actions { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }

#screen-setup .cta {
  width: 100%;
  padding: 13px 16px;
  border: none;
  border-radius: 10px;
  background: var(--l-accent);
  color: #fff;
  font-family: var(--font-system);
  font-size: 15px;
  font-weight: 500;
  transform: none;
  box-shadow: none;
  cursor: pointer;
}

#screen-setup .cta:disabled {
  background: var(--l-surface);
  color: var(--l-muted);
  opacity: 1;
  cursor: not-allowed;
}

#screen-setup .cta-secondary {
  background: var(--l-bg);
  color: var(--l-text);
  border: 0.5px solid var(--l-line);
}

#screen-setup .cta-secondary:disabled { background: var(--l-surface); color: var(--l-muted); border-color: transparent; }

/* =========================================================
   Экран съёмки — светлый стиль A (docs/design-spec.md).
   Имя .capture-actions сохранено: перед ним app.js вставляет
   сообщение об ошибке.
   ========================================================= */
.brand-topbar--back { gap: 10px; }

.capture {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 6px 20px calc(20px + env(safe-area-inset-bottom));
  font-family: var(--font-system);
}

.capture-frame {
  flex: 1;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 24px;
  border: 1px dashed var(--l-line);
  border-radius: 12px;
  background: var(--l-surface);
  color: var(--l-muted);
  text-align: center;
  cursor: pointer;
}

.capture-icon { color: var(--l-accent); margin-bottom: 4px; }

.capture-hint {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  color: var(--l-text);
}

.capture-sub { margin: 0; font-size: 13px; color: var(--l-muted); }

.capture-actions {
  display: flex;
  gap: 10px;
  padding-top: 16px;
  margin-top: auto; /* кнопка у низа экрана (03.09), как setup-actions */
}

/* Кнопки перекрашиваются только на этом экране: классы .cta и .cta-outline
   ещё используются тёмным экраном confirm. */
#screen-capture .cta {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 16px;
  border: none;
  border-radius: 10px;
  background: var(--l-accent);
  color: #fff;
  font-family: var(--font-system);
  font-size: 15px;
  font-weight: 500;
  transform: none;
  box-shadow: none;
  cursor: pointer;
}

#screen-capture .cta:disabled { background: var(--l-surface); color: var(--l-muted); opacity: 1; cursor: not-allowed; }

#screen-capture .cta-outline {
  background: var(--l-bg);
  color: var(--l-text);
  border: 0.5px solid var(--l-line);
}

/* =========================================================
   Экран подтверждения условия — светлый стиль A (docs/design-spec.md).
   Класс .recognized-text и id textarea сохранены: на них завязаны
   updateConfirmCta и сравнение текста с распознанным в app.js.
   ========================================================= */
.confirm {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 6px 20px calc(20px + env(safe-area-inset-bottom));
  font-family: var(--font-system);
}

.confirm-title,
.tasks-title {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 500;
  color: var(--l-text);
}

.confirm-lead,
.tasks-lead {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--l-text-2);
}

.recognized-view {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  border: 0.5px solid var(--l-line);
  border-radius: 12px;
  background: var(--l-bg);
  color: var(--l-text);
  font-family: var(--font-system);
  font-size: 15px;
  line-height: 1.6;
}


/* Каждая строка условия — своим абзацем: в контрольной из нескольких заданий
   формулы не должны слипаться в одну простыню. */
.recognized-line { margin: 0 0 6px; }
.recognized-line:last-child { margin-bottom: 0; }
.recognized-line:empty { height: 10px; }
.recognized-line .katex { color: var(--l-accent); }

/* Вторичная кнопка: большинство её не тронет. */
.confirm-edit {
  /* .btn-light несёт flex: 1, а .confirm — колонка: без сброса кнопка растянулась бы во всю высоту. */
  flex: 0 0 auto;
  align-self: flex-start;
  margin-top: 12px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--l-accent);
}

.recognized-text {
  flex: 1;
  min-height: 180px;
  width: 100%;
  padding: 14px 16px;
  border: 0.5px solid var(--l-line);
  border-radius: 12px;
  background: var(--l-bg);
  color: var(--l-text);
  font-family: var(--font-system);
  font-size: 15px;
  line-height: 1.6;
  resize: none;
}

.recognized-text::placeholder { color: var(--l-muted); }
.recognized-text:focus { outline: none; border-color: var(--l-accent); }

/* Классы .cta ещё общие для всех экранов — перекрашиваем адресно. */
#screen-confirm .cta {
  margin-top: 16px;
  width: 100%;
  padding: 13px 16px;
  border: none;
  border-radius: 10px;
  background: var(--l-accent);
  color: #fff;
  font-family: var(--font-system);
  font-size: 15px;
  font-weight: 500;
  transform: none;
  box-shadow: none;
  cursor: pointer;
}

#screen-confirm .cta:disabled { background: var(--l-surface); color: var(--l-muted); opacity: 1; cursor: not-allowed; }

/* =========================================================
   Выделение области задания на фото — светлый стиль A.
   ========================================================= */
/* Окно превью (02.09, заход 2): фото — во всю ШИРИНУ (страница учебника
   должна быть разборчивой для точного кропа), высота ограничена окном
   с вертикальной прокруткой. Потолок по высоте на самом изображении
   (прежний 50svh) давал вертикальному кадру узкую полоску по центру.
   Жест однозначен: свободное поле фото = pan-y (прокрутка), рамка и ручки
   несут touch-action:none — во время их жеста прокрутка невозможна,
   дельта-математика кропа не тронута. */
.photo-viewport {
  width: 100%;
  /* Высота ВЫВОДИТСЯ из экрана (03.09, решение Ильи), а не константой:
     210px — фикс-хром (шапка ~50 + отступы капчера ~46 + подсказка ~28 +
     кнопка ~68 + рамка 16). Жёсткая height, не max-: при фото ниже окна
     max- схлопнул бы окно и центрировать было бы не в чем. */
  height: calc(100vh - 210px);   /* fallback для старых вебвью без svh */
  height: calc(100svh - 210px);
  overflow-y: auto;
  touch-action: pan-y;
  overscroll-behavior: contain;
  border-radius: 8px;
  /* Центр по вертикали при фото ниже окна: margin:auto у crop-frame внутри
     flex-колонки; при переполнении margin схлопывается — скролл как был. */
  display: flex;
  flex-direction: column;
}
.photo-viewport .crop-frame { margin: auto 0; }

.crop-frame { position: relative; line-height: 0; touch-action: pan-y; }

.crop-image {
  display: block;
  width: 100%;
  /* pan-y: жест по свободному полю снимка прокручивает окно превью (и только
     вертикально); в прокрутку СТРАНИЦЫ он не уезжает — overscroll-behavior
     contain на окне. Рамка кропа безопасна: хранится в долях (cropNorm),
     пересчитывается от фактического clientWidth/Height. */
  touch-action: pan-y;
  user-select: none;
  -webkit-user-drag: none;
}

/* Затемняем всё, кроме выделенного: рамка сама рисует «окно» тенью наружу. */
.crop-box {
  position: absolute;
  border: 2px solid var(--l-accent);
  border-radius: 4px;
  box-shadow: 0 0 0 9999px rgba(44, 44, 42, 0.45);
  cursor: move;
  touch-action: none;
}

.crop-handle {
  position: absolute;
  width: 18px;
  height: 18px;
  background: var(--l-bg);
  border: 2px solid var(--l-accent);
  border-radius: 50%;
  touch-action: none;
}

/* Тап-зона у углов заметно больше самой точки. */
.crop-handle::after { content: ""; position: absolute; inset: -12px; }

.crop-handle[data-handle="nw"] { top: -9px; left: -9px; cursor: nwse-resize; }
.crop-handle[data-handle="ne"] { top: -9px; right: -9px; cursor: nesw-resize; }
.crop-handle[data-handle="sw"] { bottom: -9px; left: -9px; cursor: nesw-resize; }
.crop-handle[data-handle="se"] { bottom: -9px; right: -9px; cursor: nwse-resize; }


/* =========================================================
   Экран проверки домашней работы — светлый стиль A.
   Тон подачи спокойный: учебная ошибка это не провал, красный
   #993C1D здесь не используется, он остаётся для крайних случаев.
   ========================================================= */
.verdict {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: 12px;
  margin-bottom: 18px;
}

.verdict[data-ok="true"] { background: #eaf4f0; color: var(--l-success); }
.verdict[data-ok="false"] { background: var(--l-accent-soft); color: var(--l-accent-deep); }

.verdict-title { margin: 0; font-size: 16px; font-weight: 500; }
.verdict-sub { margin: 4px 0 0; font-size: 13px; line-height: 1.4; opacity: 0.85; }

.check-section {
  margin: 22px 0 10px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--l-muted);
}
.check-section:first-of-type { margin-top: 0; }

/* --- работа ученика --- */
.student-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.student-step {
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 0.5px solid transparent;
  font-size: 14px;
  line-height: 1.5;
  color: var(--l-text-2);
}

.student-step-num { flex: 0 0 20px; color: var(--l-muted); font-size: 13px; }

/* Шаг, с которого началась ошибка, — подсвечен спокойно, а не тревожно. */
.student-step[data-first-mistake="true"] {
  background: var(--l-accent-soft);
  border-color: var(--l-accent);
  color: var(--l-accent-deep);
}

/* --- разбор --- */
.mistake {
  border: 0.5px solid var(--l-line);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
}

.mistake-where { margin: 0 0 10px; font-size: 15px; font-weight: 500; color: var(--l-text); }
.mistake-label {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--l-muted);
}
.mistake-text { margin: 0 0 12px; font-size: 14px; line-height: 1.6; color: var(--l-text-2); }
.mistake-text:last-child { margin-bottom: 0; }
.mistake-better { color: var(--l-accent-deep); }

/* --- строки сверки, нечитаемого и расхождения --- */
.check-note {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--l-surface);
  font-size: 13px;
  line-height: 1.5;
  color: var(--l-text-2);
}

.check-note[data-kind="verified"] { background: #eaf4f0; color: var(--l-success); }
.check-note[data-kind="conflict"] { background: var(--l-accent-soft); color: var(--l-accent-deep); }
.check-note ul { margin: 6px 0 0; padding-left: 18px; }

/* --- эталон, свёрнут по умолчанию --- */
.reference {
  margin: 22px 0 4px;
  border: 0.5px solid var(--l-line);
  border-radius: 12px;
  overflow: hidden;
}

.reference-summary {
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 500;
  color: var(--l-accent);
  cursor: pointer;
  list-style: none;
}
.reference-summary::-webkit-details-marker { display: none; }
.reference-summary::before { content: "▸ "; }
.reference[open] .reference-summary::before { content: "▾ "; }

.reference-body { padding: 0 16px 16px; border-top: 0.5px solid var(--l-line); }
.reference-body .steps { margin-top: 16px; }

/* =========================================================
   Экран съёмки: одно фото за раз, крупно, рамка выделения
   прямо на снимке (docs/design-spec.md).
   ========================================================= */
.capture-photo {
  /* Без flex:1 (02.09): растяжение на весь остаток экрана давало большое
     серое поле вокруг маленького превью. Теперь контейнер — по содержимому
     (окну photo-viewport, до 55svh). */
  position: relative;
  touch-action: pan-y;
  overscroll-behavior: contain;
  padding: 8px;
  border-radius: 12px;
  background: var(--l-surface);
  overflow: hidden;
}


.photo-remove {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0.5px solid var(--l-line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--l-text);
  cursor: pointer;
}

.crop-tip {
  margin: 12px 0 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--l-muted);
  text-align: center;
}


/* =========================================================
   Переспрос о режиме. Спокойная плашка, а не модальное окно:
   пользователь всегда может настоять на своём выборе.
   ========================================================= */
.mode-prompt {
  margin: 12px 0 0;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--l-accent-soft);
  color: var(--l-accent-deep);
  font-family: var(--font-system);
}


.mode-prompt-text { margin: 0 0 10px; font-size: 14px; line-height: 1.5; }

.mode-prompt-actions { display: flex; gap: 8px; }

.mode-prompt-actions .btn-light { flex: 1; padding: 10px 12px; font-size: 14px; }

.mode-prompt-yes { background: var(--l-accent); border-color: var(--l-accent); color: #fff; }

/* =========================================================
   Форма сообщения об ошибке в ответе или проверке.
   ========================================================= */
.feedback {
  margin: 0;
  padding: 14px 16px;
  border-top: 0.5px solid var(--l-line);
  background: var(--l-surface);
  font-family: var(--font-system);
}

.feedback-title { margin: 0 0 8px; font-size: 14px; font-weight: 500; color: var(--l-text); }

.feedback-text {
  width: 100%;
  padding: 10px 12px;
  border: 0.5px solid var(--l-line);
  border-radius: 10px;
  background: var(--l-bg);
  color: var(--l-text);
  font-family: var(--font-system);
  font-size: 14px;
  line-height: 1.5;
  resize: none;
}

.feedback-text::placeholder { color: var(--l-muted); }
.feedback-text:focus { outline: none; border-color: var(--l-accent); }

.feedback-actions { display: flex; gap: 8px; margin-top: 10px; }
.feedback-actions .btn-light { flex: 1; padding: 10px 12px; }
.feedback-send { background: var(--l-accent); border-color: var(--l-accent); color: #fff; }

.feedback-status {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--l-danger);
}

.feedback-done {
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
  color: var(--l-success);
}

/* Пока палец тянет рамку выделения, страница не должна ехать.
   touch-action на самих элементах не спасает от прокрутки предков и от
   pull-to-refresh, поэтому на время перетаскивания замораживаем документ. */
body.crop-dragging {
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

/* =========================================================
   Экран выбора задачи, когда на фото их несколько.
   ========================================================= */
.tasks {
  flex: 1;
  overflow-y: auto;
  padding: 6px 20px calc(20px + env(safe-area-inset-bottom));
  font-family: var(--font-system);
}

.task-list { display: flex; flex-direction: column; gap: 10px; }

.task-cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }

/* Заголовок варианта — неброский разделитель, а не второй уровень навигации. */
.task-group {
  margin: 8px 0 0;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--l-muted);
}
.task-group:first-child { margin-top: 0; }

.task-card {
  padding: 14px 16px;
  border: 0.5px solid var(--l-line);
  border-radius: 12px;
  background: var(--l-bg);
  cursor: pointer;
}

/* Подсветка тапа — только на шапке (аккордеон) и на кнопках check-списка:
   раньше .task-card:active вспыхивал и при тапах по раскрытому решению. */
.task-card-head:active,
button.task-card:active { background: var(--l-accent-soft); }

/* №2 (02.09): раскрытая карточка выделена акцентной рамкой — видно, к какой
   задаче относится решение и где граница с соседями. */
.task-card--open { border-color: var(--l-accent); border-width: 1.5px; }

.task-card-num {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--l-accent);
}

.task-card-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  color: var(--l-text-2);
}

.task-card-line { margin: 0 0 4px; }
.task-card-line:last-child { margin-bottom: 0; }
.task-card-text .katex { color: var(--l-accent); }

/* Заглушки чипов на время загрузки списка предметов */
.chip-skeleton {
  height: 34px;
  border-color: transparent;
  background: var(--l-panel, #F1EFE8);
  animation: chip-pulse 1.1s ease-in-out infinite;
}
@keyframes chip-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

/* Ошибка загрузки списка предметов: сообщение + кнопка повтора */
.subject-error {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
  font-size: 13px;
  color: var(--l-muted, #888780);
}

/* Карточка графика функции: между шагами и блоком ответа */
/* Подпись НАД рисунком из условия: «График из условия» — ученик должен
   сразу понять, что это перерисовка его картинки, а не наш вывод. */
.graph-caption {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #888780;
}

.graph-card {
  background: #fff;
  border: 0.5px solid var(--l-border, #DFDED8);
  border-radius: 12px;
  padding: 14px 12px 10px;
  margin: 4px 0 16px;
}
.graph-card svg {
  display: block;
  width: 100%;
  height: auto;
}
.graph-comment {
  margin: 8px 4px 2px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--l-muted, #888780);
  overflow-wrap: break-word;
}

/* Карточки выбора задачи для проверки */
.task-card--muted { opacity: 0.55; }
.task-badge {
  margin-left: auto;
  font-size: 11px;
  color: var(--l-muted, #888780);
  border: 0.5px solid var(--l-border, #DFDED8);
  border-radius: 8px;
  padding: 2px 8px;
  white-space: nowrap;
  align-self: center;
}

/* Версия фронта на экране настройки: видно с телефона, что фронт свежий. */
.app-version { margin: 14px 0 0; text-align: center; font-size: 11px; color: var(--l-muted, #B0AFA8); }

/* Экран подписки (gating): текст в центре, крупные кнопки внизу. */
#screen-subscribe .setup { text-align: center; }
.subscribe-body { margin: auto 0; }
.subscribe-body .setup-lead { font-size: 16px; line-height: 1.45; margin-top: 10px; }
.subscribe-actions { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
#screen-subscribe .cta {
  width: 100%;
  padding: 15px 16px;
  border: none;
  border-radius: 12px;
  background: var(--l-accent);
  color: #fff;
  font-family: var(--font-system);
  font-size: 16px;
  font-weight: 600;
}
#screen-subscribe .cta-secondary {
  background: var(--l-bg);
  color: var(--l-text);
  border: 0.5px solid var(--l-line);
}
#screen-subscribe .cta:disabled { opacity: 0.55; }
.subscribe-status { margin-bottom: 4px; font-size: 14px; color: #5b5a54; }

/* ---------- композер «опиши словами» (03.09; заменил пунктирную рамку) ----------
   Поле-капсула у низа экрана, отправка кнопкой внутри справа. Место под
   микрофон — слева от отправки, появится только если зонд подтвердит запись
   звука (дырки в вёрстке до тех пор нет: кнопки лежат flex-рядом). */
.composer { margin-top: auto; padding-top: 12px; }
.composer-field {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  border: 1px solid var(--l-line);
  border-radius: 22px;
  background: #fff;
  padding: 8px 8px 8px 16px;
  box-shadow: 0 2px 10px rgba(44, 44, 42, 0.07);
}
.composer-field:focus-within { border-color: var(--l-accent); }
.composer-input {
  flex: 1;
  border: none;
  outline: none;
  background: none;
  font: inherit;
  font-size: 15px;
  line-height: 1.4;
  color: var(--l-text);
  resize: none;
  padding: 6px 0;
  min-height: 24px;
  max-height: 96px;
}
.composer-send {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--l-accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.composer-send:disabled { background: var(--l-line); color: var(--l-muted); cursor: default; }
/* Оверлей-плейсхолдер с переливом (№4): настоящий ::placeholder ненадёжен
   для background-clip:text — анимируем свой span поверх пустого поля. */
.composer-ph {
  position: absolute;
  left: 17px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  font-size: 15px;
  background: linear-gradient(90deg, var(--l-muted) 30%, var(--l-accent) 50%, var(--l-muted) 70%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: ph-wave 2.4s linear infinite;
}
@keyframes ph-wave {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .composer-ph { animation: none; background: none; color: var(--l-muted); }
  .pending-pen svg { animation: none; }
  .pending-dots span { animation: none; opacity: 1; }
}
.capture-text-hint {
  margin: 6px 2px 0;
  font-size: 12.5px;
  line-height: 1.35;
  color: #8a6d1f; /* мягкое предупреждение, не ошибка */
}

/* ---------- клавиатура на экране съёмки (02.09) ----------
   У MAX Bridge НЕТ событий клавиатуры (проверено по докам: только разовый
   getViewportSize) — обходимся чистым CSS: клавиатура открыта ⇔ поле в
   фокусе, значит :focus-within. Тап-цель съёмки сжимается до одной строки,
   поле и кнопка поднимаются в верхнюю половину экрана — над клавиатурой.
   Закрыл клавиатуру — вернулось само. */
.capture:focus-within .capture-frame {
  flex: 0 0 auto;
  min-height: 0;
  padding: 12px 24px;
}
.capture:focus-within .capture-icon,
.capture:focus-within .capture-sub { display: none; }
/* iOS (WebKit): svh не реагирует на клавиатуру — при фокусе поля высота
   экрана съёмки берётся из --vvh (реальная видимая высота, пишет JS-хук
   visualViewport в app.js). Без JS/на Chromium fallback = 100svh, поведение
   прежнее. Только capture: у confirm жалоб нет, не трогаем. */
#screen-capture:focus-within {
  min-height: 0;
  height: var(--vvh, 100svh);
}

/* ---------- аккордеон решений в списке задач (02.09) ---------- */
.task-card-head { cursor: pointer; }
/* №2 (02.09): решение — «вложенный лист» на тёплом фоне, растянутый до краёв
   карточки отрицательными полями (padding карточки 14px 16px). Белые
   graph-card и голубой answer-block читаются на нём как вложенные блоки. */
.task-acc {
  margin: 12px -16px -14px;
  padding: 12px 16px 14px;
  background: var(--l-surface);
  border-top: 0.5px solid var(--l-line);
  border-radius: 0 0 12px 12px;
}
.task-acc .steps { margin-top: 10px; }
.task-busy {
  margin: 0;
  font-size: 13px;
  color: var(--l-muted);
}
.task-edit-link {
  border: none;
  background: none;
  padding: 0;
  font-size: 12.5px;
  color: var(--l-accent);
  cursor: pointer;
  text-decoration: underline;
}
.task-edit { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.task-edit-text {
  width: 100%;
  box-sizing: border-box;
  border: 0.5px solid var(--l-line);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
}
.task-edit-go { align-self: flex-start; }
.task-actions { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.task-actions .task-report { align-self: flex-start; }

/* ---------- №1 (02.09): признак прокручиваемости окна превью ----------
   Overlay-скроллбары в мобильных вебвью невидимы. Градиентные кромки
   включаются JS-классами, пока сверху/снизу скрыта часть фото. */
.capture-photo::before,
.capture-photo::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  height: 34px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 1;
}
.capture-photo::before {
  top: 8px;
  background: linear-gradient(to bottom, rgba(44, 44, 42, 0.35), transparent);
  border-radius: 8px 8px 0 0;
}
.capture-photo::after {
  bottom: 8px;
  background: linear-gradient(to top, rgba(44, 44, 42, 0.35), transparent);
  border-radius: 0 0 8px 8px;
}
.capture-photo.scroll-up::before { opacity: 1; }
.capture-photo.scroll-down::after { opacity: 1; }

/* ---------- №4 (02.09): плашка «идёт работа» — карандаш + многоточие ---------- */
.answer-pending--busy {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--l-accent);
}
.pending-pen svg {
  display: block;
  animation: pen-write 1.1s ease-in-out infinite;
}
@keyframes pen-write {
  0%, 100% { transform: translate(0, 0) rotate(-6deg); }
  50% { transform: translate(5px, 2px) rotate(5deg); }
}
.pending-dots span {
  opacity: 0;
  animation: dot-blink 1.2s infinite;
}
.pending-dots span:nth-child(2) { animation-delay: 0.2s; }
.pending-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-blink {
  0% { opacity: 0; }
  30% { opacity: 1; }
  60% { opacity: 0; }
}

/* ---------- микрофон в композере (03.09) ---------- */
.composer-mic {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--l-line);
  border-radius: 50%;
  background: #fff;
  color: var(--l-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.composer-mic.recording {
  background: #b91c1c;
  border-color: #b91c1c;
  color: #fff;
  animation: mic-pulse 1.1s ease-in-out infinite;
}
.composer-mic.busy { opacity: 0.5; }
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(185, 28, 28, 0.35); }
  50% { box-shadow: 0 0 0 7px rgba(185, 28, 28, 0); }
}
@media (prefers-reduced-motion: reduce) { .composer-mic.recording { animation: none; } }

/* ================== AI-разделы: рейл + чат-экран (12.09.2026) ================== */
/* Плашки справа на экране съёмки; видны только при включённых фичах. */
.ai-rail {
  position: absolute;
  right: 0;
  top: 45%; /* пустая зона главного экрана: ниже чипов класса, выше кнопок */
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 5;
}
.ai-rail-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 10px 7px;
  border: 1px solid var(--l-line);
  border-right: none;
  border-radius: 14px 0 0 14px;
  background: var(--l-bg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  font: inherit;
  cursor: pointer;
}
.ai-rail-ico { font-size: 20px; line-height: 1; }
.ai-rail-cap { font-size: 11px; color: var(--l-muted); }

/* Экран AI: лента + композер у низа (высота из --vvh — клавиатура iOS). */
.ai-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.ai-feed {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ai-empty {
  margin: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  text-align: center;
}
.ai-empty-title { font-size: 20px; font-weight: 700; color: var(--l-text); margin-bottom: 6px; }
.ai-suggest {
  padding: 12px 16px;
  border: 1px solid var(--l-line);
  border-radius: 14px;
  background: var(--l-bg);
  font: inherit;
  font-size: 15px;
  color: var(--l-text-2);
  text-align: left;
  cursor: pointer;
}
.ai-msg {
  max-width: 86%;
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.45;
  color: var(--l-text);
  overflow-wrap: break-word;
}
.ai-msg--user {
  align-self: flex-end;
  background: var(--l-accent-soft);
  border-bottom-right-radius: 6px;
}
.ai-msg--assistant {
  align-self: flex-start;
  background: var(--l-surface);
  border-bottom-left-radius: 6px;
}
.ai-msg-photo { max-width: 120px; border-radius: 10px; display: block; margin-bottom: 6px; }
.ai-msg-media { max-width: 100%; border-radius: 12px; display: block; }
.ai-enhanced { margin-top: 6px; font-size: 12px; color: var(--l-muted); }
.ai-wait { color: var(--l-muted); }
.ai-error { color: var(--l-danger); }

/* Композер */
.ai-composer-zone {
  padding: 6px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--l-line);
  background: var(--l-bg);
}
.ai-mode-chips { display: flex; gap: 8px; margin-bottom: 6px; }
.ai-chip {
  padding: 6px 12px;
  border: 1px solid var(--l-line);
  border-radius: 999px;
  background: var(--l-bg);
  font: inherit;
  font-size: 13px;
  color: var(--l-text-2);
  cursor: pointer;
}
.ai-chip[data-on="true"] {
  background: var(--l-accent-soft);
  border-color: var(--l-accent);
  color: var(--l-accent);
}
.ai-attach { position: relative; width: 64px; margin-bottom: 6px; }
.ai-attach img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; display: block; }
.ai-attach button {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px; border-radius: 50%;
  border: none; background: var(--l-text); color: var(--l-bg);
  font-size: 11px; line-height: 20px; padding: 0; cursor: pointer;
}
.ai-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border: 1px solid var(--l-line);
  border-radius: 22px;
  padding: 6px 6px 6px 10px;
  background: var(--l-bg);
}
.ai-plus {
  width: 32px; height: 32px; flex: none;
  border: none; border-radius: 50%;
  background: var(--l-surface); color: var(--l-text-2);
  font-size: 20px; line-height: 1; cursor: pointer;
}
#ai-input {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font: inherit;
  font-size: 15px;
  max-height: 96px;
  background: transparent;
  color: var(--l-text);
}
.ai-send {
  width: 34px; height: 34px; flex: none;
  border: none; border-radius: 50%;
  background: var(--l-accent); color: #fff;
  font-size: 15px; cursor: pointer;
}
.ai-send:disabled { opacity: 0.5; }
/* ================== END AI-разделы ================== */

/* «✨ Улучшить» (12.09): усиленный промпт возвращается в поле для правки. */
.ai-chip--enhance { margin-left: auto; border-color: var(--l-accent); color: var(--l-accent); }

/* Поделиться генерацией + «печатается» (12.09) */
.ai-share { margin-top: 8px; }
.ai-share-btn {
  padding: 6px 12px;
  border: 1px solid var(--l-accent);
  border-radius: 999px;
  background: transparent;
  color: var(--l-accent);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.ai-typing::after { content: "▍"; animation: ai-blink 0.9s steps(2) infinite; color: var(--l-muted); }
@keyframes ai-blink { to { visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .ai-typing::after { animation: none; } }


/* ================================================================
   ТЕМА D «glass-пастель» — слой поверх (редизайн 12.09).
   Принцип: существующие правила не трогаем, каскад переопределяет
   только внешний вид; вся механика (кроп, стрим, KaTeX) как была.
   ================================================================ */
body {
  /* пастельные пятна БЕЗ filter:blur — radial-gradient бесплатен для GPU
     слабых андроидов, визуально то же самое */
  background:
    radial-gradient(420px 420px at -10% -5%, rgba(165, 180, 252, 0.55), transparent 70%),
    radial-gradient(460px 460px at 110% 40%, rgba(249, 168, 212, 0.45), transparent 70%),
    radial-gradient(500px 500px at 30% 110%, rgba(253, 230, 138, 0.35), transparent 70%),
    linear-gradient(180deg, #eef1ff 0%, #fdf2f8 60%, #fff7ed 100%);
  background-attachment: fixed;
}
.screen-light { background: transparent; }

/* Заголовки и крупные акценты — дисплейный шрифт */
.setup-title, .setup-lead, .cta, .ai-empty-title, .answer-label, .sheet-title, h1, h2 {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}
.setup-lead { font-size: 19px; font-weight: 700; line-height: 1.3; }

/* Стеклянные поверхности */
.brand-topbar, .chip, .btn-light, .composer-field, .task-card, .step-card,
.ai-rail-btn, .ai-suggest, .ai-chip, .ai-composer, .ai-msg--assistant,
.answer-block, .capture-frame, .mode-prompt, .feedback, .recognized-card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.brand-topbar { border-radius: 0 0 18px 18px; }
.chip { border-radius: 14px; font-weight: 700; }
.chip[data-selected="true"], .chip.selected, .chip[aria-pressed="true"] {
  background: var(--grad); color: #fff; border-color: transparent;
  box-shadow: 0 6px 16px rgba(139, 92, 246, 0.35);
}

/* Главные кнопки — градиент */
.cta {
  background: var(--grad);
  color: #fff;
  border: none;
  border-radius: 18px;
  box-shadow: 0 8px 22px rgba(139, 92, 246, 0.35);
  font-weight: 700;
}
.cta:disabled { background: rgba(28,28,34,0.12); color: var(--l-muted); box-shadow: none; }
.cta-secondary { background: var(--glass); color: var(--l-text); border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow); }
.cta-success { background: linear-gradient(135deg, #10b981, #06b6d4); }

/* AI-чат в стекле */
.ai-msg--user { background: linear-gradient(135deg, rgba(139,92,246,.16), rgba(236,72,153,.14)); }
.ai-send, .ai-rail-btn:active { background: var(--grad); }
.ai-send { box-shadow: 0 6px 16px rgba(139, 92, 246, 0.35); }
.ai-chip[data-on="true"] { background: var(--grad); color: #fff; border-color: transparent; }
.ai-chip--enhance { color: var(--l-accent); }
.ai-share-btn { border-color: var(--l-accent); color: var(--l-accent); }

/* Ответ и вердикты */
.answer-block { border-radius: 20px; }
.answer-value { font-family: var(--font-display); }

/* Нижние вкладки (тема D) */
.tab-bar {
  position: fixed;
  left: 14px; right: 14px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 40;
  display: flex;
  padding: 6px;
  border-radius: 22px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}
.tab-btn {
  flex: 1;
  border: none;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font: inherit;
  font-size: 10.5px;
  font-weight: 800;
  color: var(--l-muted);
  padding: 7px 0 6px;
  border-radius: 16px;
  cursor: pointer;
}
.tab-i { font-size: 20px; line-height: 1; }
.tab-btn[data-on="true"] {
  color: #fff;
  background: var(--grad);
  box-shadow: 0 6px 16px rgba(139, 92, 246, 0.35);
}
/* Отступ под бар — БЕЗУСЛОВНЫЙ (12.09 вечер): вариант с body-классом от JS
   на телефоне не активировался (композер уезжал под бар, скрин 21:50);
   бар на этих экранах есть всегда, лишний отступ при спрятанном баре
   (клавиатура) не виден под ней. Простота надёжнее. */
#screen-capture .capture { padding-bottom: calc(112px + env(safe-area-inset-bottom)) !important; }
#screen-setup .setup { padding-bottom: calc(104px + env(safe-area-inset-bottom)) !important; }
#screen-ai .ai-composer-zone { padding-bottom: calc(100px + env(safe-area-inset-bottom)) !important; }

/* Клавиатура открыта (фокус в композере) — бар внизу спрятан, и запас под
   него превращается в пустую полосу МЕЖДУ полем и клавиатурой (скрин Ильи
   19:49, Android: поле висело сантиметром выше клавиатуры). Убираем запас
   ровно на это время. Класс ставится на фокусе поля; если он вдруг не
   проставится, останется прежнее поведение — композер не уедет под бар. */
body.kb-open #screen-capture .capture { padding-bottom: calc(12px + env(safe-area-inset-bottom)) !important; }
body.kb-open #screen-setup .setup { padding-bottom: calc(12px + env(safe-area-inset-bottom)) !important; }
body.kb-open #screen-ai .ai-composer-zone { padding-bottom: calc(10px + env(safe-area-inset-bottom)) !important; }

/* Рейл полностью заменён нижними вкладками (скрин Ильи 21:01 — двойная навигация) */
.ai-rail { display: none !important; }

/* Setup: большие кнопки-дубли убраны — их роль на нижних вкладках (12.09) */
#btn-mode-solve, #btn-mode-check { display: none !important; }

/* Пилюля контекста на камере */
.context-pill {
  align-self: flex-start;
  margin: 4px 20px 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  background: var(--glass);
  box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--l-text);
  cursor: pointer;
}
.context-pill-edit { color: var(--l-accent); font-weight: 800; }

/* ================== Пакет редизайна №2 (12.09 вечер) ================== */

/* Видоискатель: тёмный кадр с уголками и затвором */
#screen-capture .capture-frame {
  background: radial-gradient(140% 110% at 50% 0%, #454050, #262230) !important;
  border: none !important;
  border-radius: 26px;
  color: #fff;
  position: relative;
  overflow: hidden;
  /* Кадр — эластичный: занимает свободное место и СЖИМАЕТСЯ на низких
     экранах (наезды на бар, скрины Ильи 22:27); экран влезает без скролла. */
  flex: 1 1 auto;
  min-height: 170px;
  max-height: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 14px 34px rgba(38, 34, 48, 0.35);
}
#screen-capture .capture-frame::before {
  content: "";
  position: absolute;
  inset: 18px;
  border: 2px dashed rgba(255, 255, 255, 0.28);
  border-radius: 18px;
  pointer-events: none;
}
#screen-capture .capture-frame .capture-icon { color: #d8b4fe; }
#screen-capture .capture-hint { color: #fff; font-family: var(--font-display); font-size: 15px; }
#screen-capture .capture-sub { color: #bdb7cb; }
.snap-ring {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 5px solid #fff;
  background: var(--grad);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
  margin-top: 6px;
}
.capture-alts { display: none; } /* ряд удалён: дублировал композер и кадр (Илья 22:16) */
.capture-alts button {
  border: 1px solid var(--glass-border);
  background: var(--glass);
  box-shadow: var(--glass-shadow);
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--l-text-2);
  padding: 10px 14px;
  min-height: 40px;
  cursor: pointer;
}

/* Шторка класса/предмета */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(28, 28, 34, 0.4);
  display: flex;
  align-items: flex-end;
}
.sheet-panel {
  width: 100%;
  max-height: 78svh;
  overflow-y: auto;
  background: var(--l-bg, #fff);
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-radius: 26px 26px 0 0;
  padding: 12px 16px calc(20px + env(safe-area-inset-bottom));
  animation: sheetUp 0.25s ease;
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.sheet-grab { width: 44px; height: 5px; border-radius: 99px; background: rgba(28,28,34,.18); margin: 0 auto 12px; }
.sheet-h { font-family: var(--font-display); font-size: 15px; margin: 10px 2px 8px; }

/* Ответ: зелёная плашка при подтверждённом ответе */
.answer-block.answer-ok {
  background: linear-gradient(135deg, rgba(220, 252, 231, 0.9), rgba(187, 247, 208, 0.85));
  border-color: rgba(22, 163, 74, 0.25);
}
.solution-share { margin: 10px 20px 0; min-height: 42px; align-self: flex-start; }

/* «Печать» шагов решения: каскадное проявление (KaTeX уже отрендерен) */
#screen-solution .steps > li { animation: stepIn 0.4s ease both; }
#screen-solution .steps > li:nth-child(1) { animation-delay: 0.05s; }
#screen-solution .steps > li:nth-child(2) { animation-delay: 0.35s; }
#screen-solution .steps > li:nth-child(3) { animation-delay: 0.65s; }
#screen-solution .steps > li:nth-child(4) { animation-delay: 0.95s; }
#screen-solution .steps > li:nth-child(5) { animation-delay: 1.25s; }
#screen-solution .steps > li:nth-child(6) { animation-delay: 1.55s; }
#screen-solution .steps > li:nth-child(7) { animation-delay: 1.85s; }
#screen-solution .steps > li:nth-child(n+8) { animation-delay: 2.1s; }
@keyframes stepIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Переходы экранов + микро-анимации вкладок */
.screen[data-active="true"] { animation: screenIn 0.22s ease; }
@keyframes screenIn { from { opacity: 0.35; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.tab-i { width: 21px; height: 21px; transition: transform 0.2s ease; }
.tab-btn[data-on="true"] .tab-i { transform: scale(1.12); }
.tab-btn:active { transform: scale(0.95); }
.tab-btn { transition: color 0.2s ease, transform 0.15s ease; }

/* Тач-цели ≥40px (чек-лист) */
.ai-share-btn { min-height: 40px; }
.context-pill { min-height: 42px; }

@media (prefers-reduced-motion: reduce) {
  .screen[data-active="true"], #screen-solution .steps > li, .sheet-panel { animation: none; }
}

/* Тёмная тема (авто из системы) */
@media (prefers-color-scheme: dark) {
  :root {
    --l-text: #ececf1;
    --l-text-2: #c9c9d3;
    --l-muted: #8f8f9e;
    --l-line: rgba(255, 255, 255, 0.12);
    --l-surface: rgba(44, 44, 60, 0.6);
    --l-accent-soft: rgba(139, 92, 246, 0.22);
    --glass: rgba(34, 34, 48, 0.62);
    --glass-border: rgba(255, 255, 255, 0.13);
    --glass-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
  }
  body {
    background:
      radial-gradient(420px 420px at -10% -5%, rgba(76, 66, 160, 0.5), transparent 70%),
      radial-gradient(460px 460px at 110% 40%, rgba(150, 60, 110, 0.35), transparent 70%),
      linear-gradient(180deg, #14141c 0%, #191420 60%, #1c1822 100%);
    background-attachment: fixed;
  }
  .brand-logo { filter: brightness(1.7) saturate(0.9); }
  .composer-field, .sheet-panel { background: rgba(34, 34, 48, 0.9); }
  .answer-block.answer-ok { background: linear-gradient(135deg, rgba(20, 83, 45, 0.55), rgba(22, 101, 52, 0.45)); }
  .ai-msg--user { background: linear-gradient(135deg, rgba(139, 92, 246, 0.3), rgba(236, 72, 153, 0.24)); }
}
/* ================== END пакет №2 ================== */

/* Скелетоны (12.09): силуэты контента с бегущим бликом */
.skel {
  display: block;
  border-radius: 10px;
  background: linear-gradient(100deg, rgba(28,28,34,0.07) 30%, rgba(28,28,34,0.14) 50%, rgba(28,28,34,0.07) 70%);
  background-size: 220% 100%;
  animation: skelShine 1.3s ease-in-out infinite;
}
@keyframes skelShine { from { background-position: 130% 0; } to { background-position: -90% 0; } }
.skel-line { height: 14px; margin: 8px 0; }
.skel-step { list-style: none; padding: 12px 0; }
.skel-media { width: min(78vw, 300px); height: 190px; border-radius: 14px; margin-bottom: 8px; }
@media (prefers-color-scheme: dark) {
  .skel { background: linear-gradient(100deg, rgba(255,255,255,0.08) 30%, rgba(255,255,255,0.16) 50%, rgba(255,255,255,0.08) 70%); background-size: 220% 100%; }
}
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

/* Экран съёмки = ровно вьюпорт: без скролла, низ никогда не под баром */
#screen-capture[data-active="true"] {
  height: 100svh;
  min-height: 0;
  overflow: hidden;
}
#screen-capture .capture { min-height: 0; }

.sheet-version { text-align: center; color: var(--l-muted); font-size: 12px; margin-top: 14px; }

/* Фон за пределами страницы (панорама клавиатуры оголяла белое) */
html { background: #eef1ff; }
@media (prefers-color-scheme: dark) { html { background: #14141c; } }

/* Чат-экран = ровно видимая область (капитальный фикс клавиатуры 12.09):
   документ не выше вьюпорта → WKWebView НЕЧЕГО панорамировать. --vvh пишет
   visualViewport-хук; без него фолбэк 100svh (Chromium сжимает сам). */
#screen-ai[data-active="true"] {
  height: var(--vvh, 100svh);
  min-height: 0;
  overflow: hidden;
}

/* Тёмная тема: читаемый ответ в зелёной плашке (фиолетовые формулы на
   тёмно-зелёном были нечитаемы — скрин 23:38) + светлые формулы в шагах. */
@media (prefers-color-scheme: dark) {
  .answer-block.answer-ok { color: #eafff3; }
  .answer-block.answer-ok .answer-value,
  .answer-block.answer-ok .answer-value .katex { color: #eafff3; }
  .answer-block.answer-ok .answer-label { color: #6ee7b7; }
  .answer-block:not(.answer-ok) .answer-value .katex { color: #d8ccff; }
  .step-text .katex { color: #c4b5fd; }
}

/* Блок ожидания над скелетонами (18.09, вид как у Perplexity): свёрнутый —
   одна строка с пульсирующей точкой и шевроном; развёрнутый — весь ход с
   галочками у пройденных фаз. Ребёнок видит, что идёт работа, а любопытный
   может посмотреть, что именно делается. */
.think-box {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  border-radius: 16px;
  background: var(--l-accent-soft);
  overflow: hidden;
}
.think-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border: none;
  background: none;
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--l-accent-deep, #4c1d95);
  text-align: left;
  cursor: pointer;
}
.think-text { flex: 1; transition: opacity 0.18s ease; }
.think-chev { flex: none; opacity: 0.6; transition: transform 0.22s ease; }
.think-box--open .think-chev { transform: rotate(180deg); }
.think-dot {
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 50%;
  background: var(--grad);
  animation: think-pulse 1.6s ease-out infinite;
}
.think-dot--ok { background: linear-gradient(135deg, #10b981, #06b6d4); animation: none; }
.think-list {
  margin: 0;
  padding: 0 14px 12px 14px;
  list-style: none;
  font-size: 13px;
  color: var(--l-muted);
}
.think-list li { display: flex; gap: 8px; padding: 3px 0; }
.think-mark { width: 14px; flex: none; }
.think-list .think-done { opacity: 0.65; }
.think-list .think-now { color: var(--l-accent-deep, #4c1d95); font-weight: 600; }
/* Строка «уточнил шаги N» после правки критиком — тем же языком, но спокойным
   зелёным: это не тревога, а честность. */
.think-line--fixed {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin: 0 0 10px;
  border-radius: 14px;
  background: rgba(16, 185, 129, 0.12);
  font-size: 13px;
  font-weight: 700;
  color: #0f766e;
}
/* Шаг, который критик переписал: мягкая подсветка, гаснет сама. */
.step-updated { animation: step-fixed 2.4s ease-out 1; border-radius: 12px; }
@keyframes step-fixed {
  0%   { background: rgba(16, 185, 129, 0.16); }
  100% { background: transparent; }
}
@keyframes think-pulse {
  0%   { transform: scale(0.85); opacity: 0.75; }
  70%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.85); opacity: 0.75; }
}
@media (prefers-reduced-motion: reduce) {
  .think-dot, .step-updated { animation: none; }
}
@media (prefers-color-scheme: dark) {
  .think-head { color: #ddd6fe; }
  .think-list .think-now { color: #ddd6fe; }
  .think-line--fixed { color: #6ee7b7; background: rgba(16, 185, 129, 0.16); }
}
