/* ЯДРО: общая вёрстка оболочки, экранов и диалогов. Порядок файлов: theme → core → compact → engines/*. */
* {
  box-sizing: border-box;
  touch-action: manipulation;
}
body {
  margin: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.7' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.035'/%3E%3C/svg%3E");
  font-size: var(--text-body);
  line-height: 1.5;
}
button,
input,
textarea,
select {
  font: inherit;
}
button,
select,
a {
  -webkit-tap-highlight-color: var(--accent-pale);
}
button {
  cursor: pointer;
  border: var(--border-hairline) solid var(--border-control);
  /* Брендбук: у кнопок прямые углы. */
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  padding: var(--space-10) var(--space-16);
  min-height: 44px;
  font-weight: var(--weight-bold);
  transition:
    background 0.15s,
    transform 0.15s;
}
button:hover {
  background: var(--surface-hover);
}
button:active {
  transform: translateY(1px);
}
button:disabled {
  cursor: default;
  opacity: 0.4;
  transform: none;
}
button.primary {
  background: var(--red);
  color: var(--ink-on-dark);
  border-color: var(--red);
}
button.primary:hover {
  background: var(--accent-dark);
}
button.secondary {
  border-color: var(--red);
  color: var(--red);
}
button.link {
  border: 0;
  background: none;
  color: var(--accent-strong);
  font-size: var(--text-small);
  padding: var(--space-8);
  font-weight: var(--weight-regular);
}
button.link:hover {
  color: var(--accent-dark);
}
/* Ссылка «Скачать» над таблицей — обычный <a download> (файл из assets/data/), выглядит как button.link. */
a.link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: var(--space-8);
  border-radius: var(--radius-control);
  color: var(--accent-strong);
  font-size: var(--text-small);
  font-weight: var(--weight-regular);
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: var(--accent-pale);
}
a.link:hover {
  color: var(--accent-dark);
}
button.icon-button {
  width: 42px;
  min-height: 40px;
  padding: var(--space-8);
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: inherit;
}
button svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
button.inline-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-10);
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 4px;
}
input,
textarea,
select {
  max-width: 100%;
  color: var(--ink);
  border: var(--border-hairline) solid var(--border);
  border-radius: var(--radius-5);
  background: var(--surface);
}
input[type='number'],
select {
  min-height: 44px;
  padding: var(--space-9) var(--space-12);
}
input[type='checkbox'] {
  width: 18px;
  height: 18px;
  accent-color: var(--red);
  margin: 0;
  flex-shrink: 0;
}
textarea {
  width: 100%;
  resize: vertical;
  min-height: 96px;
  padding: var(--space-12);
  font-size: var(--text-small);
  line-height: 1.55;
}
a {
  color: var(--blue);
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1,
h2,
h3 {
  line-height: 1.15;
}
h1 {
  font-family: var(--font-title);
  font-weight: var(--weight-bold);
  font-size: var(--text-title);
}
h2 {
  font-family: var(--font-title);
  font-size: var(--text-title);
}
h3 {
  font-size: var(--text-body);
  font-weight: var(--weight-bold);
}
p + p {
  margin-top: var(--space-12);
}
[hidden] {
  display: none !important;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip-link {
  position: fixed;
  top: -100px;
  left: var(--space-16);
  z-index: 20;
  padding: var(--space-12);
  background: var(--surface);
}
.skip-link:focus {
  top: var(--space-12);
}
.brand {
  font-size: var(--text-body);
  font-weight: var(--weight-bold);
  line-height: 1.25;
  display: block;
}
.quiet {
  font-size: var(--text-caption);
  color: var(--muted);
}
.blue {
  color: var(--blue);
}
.check-icon {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-round);
  background: var(--green);
  color: var(--ink-on-dark);
  flex-shrink: 0;
}
.check-icon svg {
  width: 15px;
  height: 15px;
}
.xp {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  font-size: var(--text-body);
  white-space: nowrap;
  font-weight: var(--weight-bold);
}
.coin {
  display: inline-grid;
  place-items: center;
  background: var(--gold-light);
  color: var(--gold);
  border: var(--border-hairline) solid var(--gold);
  width: 29px;
  height: 29px;
  border-radius: var(--radius-round);
  flex-shrink: 0;
}
.coin svg {
  width: 22px;
  height: 22px;
}
.toast {
  pointer-events: none;
  position: fixed;
  left: 50%;
  bottom: var(--space-22);
  transform: translateX(-50%);
  max-width: min(560px, calc(100% - 32px));
  background: var(--stage-bg);
  color: var(--ink-on-dark);
  border-radius: var(--radius-8);
  box-shadow: var(--shadow-toast);
  padding: var(--space-12) var(--space-20);
  z-index: 30;
  font-size: var(--text-small);
}
/* Награда отличается от служебных сообщений: у неё акцентная рамка.
   Служебные подсказки живут у своего действия, а не в общем тосте. */
.toast.is-award {
  border: var(--border-hairline) solid var(--gold);
  box-shadow: var(--shadow-toast), inset 0 0 0 var(--border-hairline) var(--gold-dark);
}
.storage-warning {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--warn-bg);
  border-top: var(--border-hairline) solid var(--gold);
  padding: var(--space-8) var(--space-16);
  font-size: var(--text-caption);
  z-index: 29;
}
.workspace {
  display: grid;
  /* Правая колонка не уже планшета с его полями: иначе макет приложения
     вылезает за панель и обрезается по краю окна. */
  grid-template-columns:
    minmax(0, 1.96fr)
    minmax(calc(var(--tablet-width) + 2 * var(--space-18) + var(--rule-accent) + var(--border-hairline)), 1fr);
  min-height: 100dvh;
}
.learning-pane {
  min-width: 0;
}
/* ---------- Оболочка экрана ----------
   Ширина содержимого приходит из темы двумя ступенями (docs/theme.md):
   --shell-wide для обложки и практики, --shell-content для остальных экранов.
   Шапка стоит в той же ступени, что и содержимое, поэтому её левый край совпадает
   с левым краем текста: раньше четыре шапки держали свой отступ, а широкие экраны
   тянулись от края окна и текст уезжал вправо на четверть кадра. */
.shell-container,
.shell-header {
  width: 100%;
  max-width: var(--shell-content);
  margin-inline: auto;
  padding-inline: var(--gutter-x);
}
.shell-container.is-wide,
.shell-header.is-wide {
  max-width: var(--shell-wide);
}
/* Шапка: одна геометрия на все экраны. Оформление каждой шапки — только её содержимое:
   маршрут этапов у практики, подпись ветки у теории, «Начать заново» у карты. */
.shell-header {
  display: flex;
  align-items: center;
  gap: var(--space-16);
  flex-wrap: wrap;
  position: relative;
  padding-block: var(--space-22);
}
/* Пунктир идёт по ступени контейнера, а не по краю окна. */
.shell-header:after {
  content: '';
  height: 1px;
  background: repeating-linear-gradient(90deg, var(--rule-dash) 0 2px, transparent 2px 7px);
  position: absolute;
  bottom: 0;
  left: var(--gutter-x);
  right: var(--gutter-x);
}
/* Шапка внутри контейнера, у которого уже есть боковое поле (сцена практики),
   своего отступа не добавляет: иначе её край уезжал от текста на величину поля. */
.story-shell > .shell-header {
  max-width: none;
  padding-inline: 0;
}
.story-shell > .shell-header:after {
  left: 0;
  right: 0;
}
.lesson-header {
  display: flex;
  align-items: center;
  gap: var(--space-18);
  min-height: 102px;
}
.lesson-header .brand {
  width: 145px;
  flex-shrink: 0;
}
.route {
  padding: 0;
  margin: 0;
  display: flex;
  list-style: none;
  gap: var(--space-18);
  align-items: center;
  flex: 1;
  min-width: 0;
}
.route li {
  flex: 1;
  min-width: 0;
  position: relative;
}
.route li:not(:last-child):after {
  content: '›';
  position: absolute;
  right: -14px;
  top: var(--space-9);
  font-size: var(--text-title);
}
.route button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-8);
  width: 100%;
  font-size: var(--text-caption);
  line-height: 1.25;
  padding: var(--space-8) var(--space-6);
  border-color: var(--accent-secondary);
  font-weight: var(--weight-regular);
  min-height: 52px;
}
.route .step-number {
  border: var(--border-hairline) solid var(--blue);
  color: var(--blue);
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-round);
  font-weight: var(--weight-bold);
  flex-shrink: 0;
}
.route button.active {
  background: var(--red);
  border-color: var(--red);
  color: var(--ink-on-dark);
}
.route button.active .step-number {
  background: var(--surface);
  border-color: var(--surface);
  color: var(--red);
}
.route button.completed {
  background: var(--green-light);
  border-color: var(--green);
}
.route button:disabled {
  opacity: 0.72;
}
.route-label {
  text-align: left;
}
.lesson-header .xp {
  font-size: var(--text-body);
}
.lesson-header .coin {
  width: 27px;
  height: 27px;
}
.lesson-main {
  padding: var(--space-30) var(--gutter-x) var(--space-24);
}
.subtitle {
  color: var(--blue);
  margin: var(--space-10) 0 var(--space-28);
  font-size: var(--text-small);
}
.learning-grid {
  display: grid;
  grid-template-columns: minmax(215px, 0.83fr) minmax(0, 1.8fr);
  gap: var(--space-28);
  align-items: start;
}
/* Первый шаг: письмо слева, окно агента справа; планшета на этом шаге нет. */
.workspace.attach-workspace {
  grid-template-columns: minmax(0, 1fr);
}
.attach-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.85fr) minmax(0, 1.15fr);
  gap: var(--space-22);
  align-items: stretch;
  min-height: 0;
  margin-top: var(--space-16);
}
/* На широком окне письмо и чат делят свободную высоту экрана: страница не прокручивается,
   а окно чата тянется до низа, не выходя за сетку. Высоту задаёт раскладка, а не fitChat. */
@media (min-width: 901px) {
  .attach-workspace > .learning-pane {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
  }
  .attach-workspace .lesson-main {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
  }
  .attach-workspace .attach-grid {
    flex: 1;
    min-height: 0;
  }
  .attach-workspace .chat-main.attach-chat {
    min-height: 0;
  }
  .attach-workspace .attach-grid .chat-window {
    flex: 1 1 auto;
    height: auto;
    min-height: 320px;
  }
  /* Письмо и окно чата заканчиваются на одной линии: колонка письма тянется до сетки,
     карточка письма забирает остаток высоты. На узком окне правило не работает. */
  .attach-workspace .attach-grid .letter-column {
    align-self: stretch;
  }
  .attach-workspace .attach-grid .letter-column .letter {
    flex: 1 1 auto;
  }
}
/* Обёртка чата гасит стили .chat-main: раскладку задаёт сетка первого шага. */
.attach-grid .chat-main.attach-chat {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  min-height: 0;
}
.attach-grid .chat-window {
  min-height: 380px;
}
.attach-grid .composer-bottom {
  justify-content: flex-end;
}
/* В компактной практике окно чата обычно без рамки, но здесь оно стоит рядом с письмом. */
body.is-compact .attach-grid .chat-window {
  border: var(--border-hairline) solid var(--border);
  border-radius: var(--radius-8);
  box-shadow: var(--shadow-panel);
}
.attach-grid .letter-column {
  display: flex;
  flex-direction: column;
  gap: var(--space-10);
  min-width: 0;
  align-self: start;
}
/* Письмо подано окном почты: строка приложения, отправитель, кому, тема и вложение. */
.letter {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
  border: var(--border-hairline) solid var(--border);
  border-radius: var(--radius-8);
  box-shadow: var(--shadow-card);
}
.mail-bar {
  display: flex;
  align-items: center;
  gap: var(--space-10);
  padding: var(--space-8) var(--space-14);
  background: var(--surface-tint);
  border-bottom: var(--border-hairline) solid var(--line-soft);
}
.mail-dots {
  display: flex;
  gap: var(--space-5);
}
.mail-dots i {
  display: block;
  width: 9px;
  height: 9px;
  border-radius: var(--radius-round);
  background: var(--border-strong);
}
.mail-bar-title {
  font-size: var(--text-caption);
  font-weight: var(--weight-bold);
  color: var(--muted);
}
.mail-head {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  padding: var(--space-14) var(--space-18) var(--space-8);
}
.mail-avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: var(--radius-round);
  background: var(--accent-pale);
  color: var(--accent-strong);
  font-weight: var(--weight-bold);
}
.mail-who {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}
.mail-who strong {
  font-size: var(--text-small);
}
.mail-who span {
  font-size: var(--text-caption);
  color: var(--muted);
}
.mail-date {
  margin-left: auto;
  font-size: var(--text-caption);
  color: var(--muted);
  white-space: nowrap;
}
.mail-to {
  margin: 0;
  padding: 0 var(--space-18) var(--space-8);
  font-size: var(--text-caption);
  color: var(--muted);
}
.mail-to b {
  font-weight: var(--weight-bold);
}
.mail-subject {
  padding: 0 var(--space-18);
  font-family: var(--font-body);
  font-size: var(--text-lead);
  line-height: 1.3;
}
.mail-body {
  display: grid;
  gap: var(--space-10);
  padding: var(--space-10) var(--space-18) var(--space-14);
  font-size: var(--text-small);
  line-height: 1.55;
}
.mail-hint {
  margin: 0;
  padding: 0 var(--space-4);
  font-size: var(--text-caption);
  color: var(--muted);
}
.letter-file {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  margin: 0 var(--space-18) var(--space-18);
  padding: var(--space-10) var(--space-12);
  border: var(--border-hairline) solid var(--border-soft);
  border-radius: 0;
  background: var(--surface-tint);
  text-align: left;
  cursor: grab;
}
.letter-file:hover {
  background: var(--accent-pale);
  border-color: var(--accent);
}
.letter-file.is-dragging {
  cursor: grabbing;
  opacity: 0.65;
}
.letter-file-text {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}
.letter-file-text strong {
  font-size: var(--text-small);
  overflow-wrap: anywhere;
}
.letter-file-text small {
  font-size: var(--text-caption);
  color: var(--muted);
}
.letter-file-open {
  margin-left: auto;
  font-size: var(--text-caption);
  color: var(--accent-secondary);
  white-space: nowrap;
}
.chat-window.is-over,
body.is-compact .attach-grid .chat-window.is-over {
  border-color: var(--accent);
  background: var(--accent-pale);
  outline: 2px dashed var(--accent);
  outline-offset: -4px;
}
.chat-window.is-over .chat-log,
.chat-window.is-over .chat-composer {
  background: var(--accent-pale);
}
.chat-attachment-file > .attachment-meta {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: 0;
  border-radius: 0;
  background: none;
  color: inherit;
  font-weight: var(--weight-regular);
}
.chat-attachment-file > .attachment-meta strong {
  font-size: var(--text-caption);
  font-weight: var(--weight-bold);
}
.chat-attachment-file > .attachment-meta small {
  font-size: var(--text-caption);
  color: var(--muted);
}
#file-dialog {
  width: min(760px, calc(100vw - 32px));
  max-width: none;
}
@media (max-width: 900px) {
  .attach-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .attach-grid .chat-window {
    min-height: 320px;
  }
}
.file-badge {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  margin: var(--space-22) 0;
}
.file-icon {
  width: 36px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--positive-pale);
  color: var(--ink-on-dark);
  flex-shrink: 0;
}
.file-icon b {
  display: grid;
  place-items: center;
  background: var(--positive-dark);
  width: 25px;
  height: 30px;
  font-size: var(--text-lead);
}
.file-badge strong {
  display: block;
  font-size: var(--text-small);
  overflow-wrap: anywhere;
}
.file-badge small {
  font-size: var(--text-caption);
  color: var(--blue);
}
.table-container {
  border: var(--border-hairline) solid var(--task-border);
  border-radius: var(--radius-5);
  background: var(--surface);
  overflow: hidden;
  margin-bottom: var(--space-20);
}
.table-title {
  padding: var(--space-10) var(--space-14);
  background: var(--task-note-bg);
  font-weight: var(--weight-bold);
  font-size: var(--text-small);
  display: flex;
  gap: var(--space-10);
  align-items: center;
}
.table-title button,
.table-title a.link {
  margin-left: auto;
}
.data-table {
  border-collapse: collapse;
  width: 100%;
  font-size: var(--text-small);
  table-layout: fixed;
}
.data-table th,
.data-table td {
  border-top: var(--border-hairline) solid var(--line-soft);
  border-right: var(--border-hairline) solid var(--line-soft);
  padding: var(--space-14) var(--space-10);
  text-align: left;
  font-weight: var(--weight-regular);
  overflow-wrap: break-word;
}
.data-table th:last-child,
.data-table td:last-child {
  border-right: 0;
}
.data-table th {
  font-weight: var(--weight-bold);
}
.data-table label {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  cursor: pointer;
  min-height: 24px;
}
.data-table .chosen {
  background: var(--task-ok-bg);
}
.success-line {
  display: flex;
  align-items: center;
  gap: var(--space-10);
  padding: var(--space-12) 0;
  font-size: var(--text-small);
}
.award-strip {
  background: var(--green-light);
  padding: var(--space-14) var(--space-16);
  display: flex;
  gap: var(--space-24);
  align-items: center;
  border-radius: var(--radius-sm);
  margin-top: var(--space-14);
}
.award-strip strong {
  font-size: var(--text-lead);
}
.award-strip small {
  font-size: var(--text-caption);
}
.controls {
  border: 0;
  padding: 0;
  margin: 0 0 var(--space-22);
}
.controls legend {
  font-weight: var(--weight-bold);
  font-size: var(--text-small);
  margin-bottom: var(--space-10);
}
.choices {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-8);
}
.choice {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  padding: var(--space-9) var(--space-10);
  border: var(--border-hairline) solid var(--accent-secondary);
  border-radius: var(--radius-5);
  background: var(--surface);
  cursor: pointer;
  font-size: var(--text-caption);
  min-height: 44px;
  color: var(--blue);
}
.choice:has(input:checked) {
  background: var(--pink);
  border-color: var(--accent-line);
  color: var(--ink);
}
.choice:focus-within {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}
.prompt-card {
  background: linear-gradient(135deg, var(--tablet-bg), var(--tablet-bg));
  border-radius: var(--radius-control);
  color: var(--ink-on-dark);
  padding: var(--space-16) var(--space-18);
  margin: var(--space-8) 0 var(--space-14);
}
.prompt-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-caption);
  letter-spacing: 0.04em;
  margin-bottom: var(--space-15);
}
.prompt-text {
  font-size: var(--text-small);
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.prompt-text mark {
  background: var(--red);
  color: var(--ink-on-dark);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-3);
}
.prompt-tools {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--space-18);
}
.prompt-tools button {
  font-size: var(--text-caption);
  min-height: 40px;
  padding: var(--space-8) var(--space-12);
  background: var(--surface);
}
.paste-slot {
  padding: var(--space-14);
  border: var(--border-hairline) solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-control);
  margin: var(--space-14) 0;
}
.paste-slot label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-caption);
  font-weight: var(--weight-bold);
  margin-bottom: var(--space-9);
  gap: var(--space-10);
}
.paste-slot.empty {
  border-style: dashed;
}
.paste-slot.empty p {
  font-size: var(--text-caption);
  color: var(--muted);
}
.paste-state {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  color: var(--positive);
  font-size: var(--text-caption);
}
.paste-state .check-icon {
  width: 16px;
  height: 16px;
}
.paste-state .check-icon svg {
  width: 11px;
  height: 11px;
}
.action-row {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: var(--space-22);
}
.reward {
  display: flex;
  align-items: center;
  gap: var(--space-9);
  padding: var(--space-7) var(--space-12);
  min-height: 49px;
  background: var(--surface);
  border: var(--border-hairline) solid var(--ink);
  border-radius: var(--radius-control);
}
.reward strong {
  font-size: var(--text-body);
  display: block;
  line-height: 1.2;
}
.reward small {
  font-size: var(--text-caption);
  color: var(--blue);
}
.action-row .primary {
  font-size: var(--text-small);
}
.help {
  font-size: var(--text-caption);
  color: var(--blue);
  margin-top: var(--space-20);
}
.help summary {
  cursor: pointer;
  min-height: 40px;
  display: list-item;
  padding: var(--space-8) 0;
}
.help p {
  background: var(--surface);
  border-left: var(--border-frame) solid var(--accent-secondary);
  padding: var(--space-12) var(--space-14);
  color: var(--ink);
  line-height: 1.6;
}
.feedback {
  padding: var(--space-12) var(--space-14);
  border-radius: var(--radius-5);
  background: var(--warn-bg);
  border: var(--border-hairline) solid var(--gold-light);
  font-size: var(--text-small);
  margin: var(--space-14) 0;
}
.feedback.ok {
  background: var(--green-light);
  border-color: var(--positive);
}
.error {
  color: var(--accent-dark);
  font-size: var(--text-small);
  padding: var(--space-12) 0;
}
.verification {
  margin: var(--space-18) 0;
}
.verification legend {
  font-weight: var(--weight-bold);
  font-size: var(--text-body);
  margin-bottom: var(--space-15);
}
.verification fieldset,
.verification {
  border: 0;
  padding: 0;
}
.answer-row {
  display: grid;
  grid-template-columns: 1fr minmax(110px, 44%);
  align-items: center;
  gap: var(--space-12);
  margin: var(--space-10) 0;
}
.answer-row label {
  font-size: var(--text-small);
}
.answer-row input {
  width: 100%;
  min-width: 0;
}
.answer-row .invalid {
  border: var(--border-frame) solid var(--red);
}
/* Сообщение об ошибке ввода стоит под своим полем, а не общей строкой в задании. */
.field-error {
  margin: var(--space-4) 0 0;
  font-size: var(--text-caption);
  line-height: 1.4;
  color: var(--accent-strong);
}
.answer-row > .field-error {
  grid-column: 2;
}
.growth-check {
  padding: var(--space-18);
  background: var(--surface);
  border: var(--border-hairline) solid var(--border-soft);
  border-radius: var(--radius-5);
  margin-top: var(--space-18);
}
.growth-check h3 {
  margin-bottom: var(--space-10);
}
.growth-check label {
  display: block;
  font-size: var(--text-caption);
  margin-bottom: var(--space-9);
}
.growth-field {
  display: flex;
  align-items: center;
  gap: var(--space-10);
  max-width: 180px;
}
.growth-field input {
  width: 130px;
}
.lesson-footer {
  margin: var(--space-30) 0 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-16);
  font-size: var(--text-caption);
  color: var(--muted);
}
/* Подвал без кнопок не занимает места: «Назад» и «Начать заново» переехали в шапку. */
.lesson-footer:empty {
  display: none;
}
.result-pane {
  background: linear-gradient(135deg, var(--tablet-bg), var(--tablet-bg-light));
  border-left: var(--rule-accent) solid var(--red);
  min-width: 0;
}
.result-sticky {
  position: sticky;
  top: 0;
  padding: var(--space-32) var(--space-24) var(--space-32);
}
.result-title {
  font-size: var(--text-title);
  color: var(--ink-on-dark);
  font-weight: var(--weight-bold);
  line-height: 1.3;
  text-align: center;
  margin: 0 0 48px;
}
.tablet {
  border: 2px solid var(--tablet-frame);
  border-radius: 29px;
  background: linear-gradient(135deg, var(--tablet-bg-light), var(--tablet-bg) 12%, var(--tablet-bg) 80%, var(--tablet-bg-light));
  padding: var(--space-24) 17px 19px;
  position: relative;
  max-width: 490px;
  margin: auto;
}
.camera {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: var(--radius-round);
  background: var(--border-control);
  top: var(--space-11);
  left: calc(50% - 2px);
}
.dashboard {
  border-radius: var(--radius-8);
  background: var(--screen-bg);
  padding: var(--space-20);
  min-height: 620px;
  overflow: hidden;
}
.dash-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-10);
  margin-bottom: var(--space-24);
}
.dash-head h2 {
  font-size: var(--text-title);
}
.dash-head p {
  font-size: var(--text-caption);
  color: var(--blue);
  margin-top: var(--space-7);
}
.dash-head select {
  font-size: var(--text-caption);
  min-height: 38px;
  width: 122px;
  padding: var(--space-6) var(--space-10);
}
.kpi {
  border: 1px solid var(--screen-kpi);
  border-radius: var(--radius-12);
  background: var(--surface);
  padding: var(--space-15) var(--space-16);
}
.kpi h3 {
  font-size: 15px;
  margin-bottom: var(--space-12);
}
.kpi .value {
  font-size: clamp(30px, 2.5vw, 45px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  white-space: nowrap;
}
.submetrics {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: var(--space-16);
  align-items: center;
  margin: var(--space-16) 0;
}
.plan .value {
  font-size: clamp(19px, 1.65vw, 29px);
}
.donut {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-7);
  min-width: 0;
}
.donut-ring {
  position: relative;
  aspect-ratio: 1;
  width: 100%;
}
.donut-caption {
  display: block;
  max-width: 100%;
  font-size: var(--text-caption);
  line-height: 1.3;
  color: var(--muted);
  text-align: center;
  font-weight: 500;
}
.donut svg {
  display: block;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.donut-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
}
.donut-label strong {
  font-size: var(--text-title);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.comparison {
  display: flex;
  align-items: center;
  gap: var(--space-18);
  background: var(--accent-pale);
  border-radius: var(--radius-md);
  padding: var(--space-12);
  margin: var(--space-12) 0 var(--space-20);
}
.comparison strong {
  font-size: var(--text-title);
  white-space: nowrap;
}
.comparison p {
  font-size: var(--text-caption);
  line-height: 1.5;
}
.comparison small {
  display: block;
  color: var(--blue);
  font-size: var(--text-caption);
  margin-top: var(--space-6);
}
.comparison.missing strong {
  font-size: var(--text-body);
}
.chart-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-12);
  margin: var(--space-22) 0 var(--space-10);
}
.chart-title h3 {
  font-size: 14px;
}
.chart-title small {
  font-size: 10px;
  color: var(--blue);
}
.chart {
  width: 100%;
  height: 150px;
  display: block;
}
.chart text {
  font-family: var(--font-body);
}
.upload-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-8);
  width: 100%;
  border-color: var(--screen-chart);
  background: var(--screen-muted-bg);
  font-size: var(--text-small);
  min-height: 42px;
  margin-top: var(--space-16);
}
.dash-empty {
  min-height: 620px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  gap: var(--space-18);
  padding: var(--space-30) var(--space-16);
}
.empty-chart {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: var(--space-15);
  width: 82%;
  height: 140px;
  border: var(--border-hairline) dashed var(--screen-dash);
  background: var(--surface);
  padding: var(--space-24);
}
.empty-chart i {
  width: 28px;
  background: var(--screen-gray);
  height: 40%;
}
.empty-chart i:nth-child(2) {
  height: 65%;
}
.empty-chart i:nth-child(3) {
  height: 90%;
}
.dash-empty h3 {
  font-size: var(--text-lead);
  line-height: 1.3;
}
.dash-empty p {
  font-size: var(--text-caption);
  color: var(--blue);
}
.dataset-note {
  font-size: var(--text-caption);
  color: var(--blue);
  margin-top: var(--space-12);
}
.presentation {
  min-height: 100dvh;
  padding: var(--space-24);
  background: var(--paper);
}
.presentation-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-20);
  max-width: 1000px;
  margin: 0 auto var(--space-24);
}
.presentation .dashboard {
  max-width: 780px;
  margin: auto;
  border: 1px solid var(--screen-kpi);
  min-height: 0;
  padding: var(--space-32);
}
.presentation .kpi .value {
  font-size: 52px;
}
.presentation .plan .value {
  font-size: 33px;
}
.presentation .submetrics {
  grid-template-columns: 1fr 170px;
}
.presentation .dash-head h2 {
  font-size: 44px;
}
.presentation .chart {
  max-height: 270px;
}
.presentation .donut-label strong {
  font-size: 36px;
}
.story-shell {
  min-height: 100dvh;
  max-width: var(--shell-wide);
  margin: auto;
  padding: 0 var(--gutter-x) var(--space-30);
}
.story-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 100px;
}
.story-header .right {
  display: flex;
  align-items: center;
  gap: var(--space-20);
}
/* Шапка ветки: «Назад», бренд, подпись места, XP и «Карта».
   Общая для теории, ветки «сам» и итогового теста: три типа блоков не рисуют три разных шапки.
   Геометрию даёт .shell-header, здесь остаётся только содержимое.
   Практика остаётся на своей шапке с маршрутом этапов (.practice-header). */
.branch-header {
  display: flex;
  align-items: center;
  gap: var(--space-18);
}
/* Название курса в шапке — одной строкой: перенос раздувал шапку и добавлял прокрутку. */
.branch-header .brand {
  white-space: nowrap;
  flex-shrink: 0;
}
.branch-label {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-caption);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.branch-actions {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  margin-left: auto;
}
.branch-main {
  max-width: var(--shell-content);
  margin-inline: auto;
  padding: var(--space-30) var(--gutter-x) var(--space-24);
}
.branch-main.is-wide {
  max-width: var(--shell-wide);
}
.branch-main h1 {
  font-size: var(--text-title);
  margin: 0 0 var(--space-16);
}
.branch-lead {
  color: var(--muted);
  font-size: var(--text-lead);
  line-height: 1.45;
  margin: 0 0 var(--space-18);
}
/* Заглушка фазы 1: на её месте встанет текст раздела, карточки формата или шаг «сам». */
.branch-stub {
  color: var(--muted);
  font-size: var(--text-body);
  margin: 0 0 var(--space-24);
}
@media (max-width: 820px) {
  .branch-header {
    gap: var(--space-10);
  }
  .branch-main {
    padding: var(--space-20) var(--gutter-x) var(--space-18);
  }
  .branch-actions .xp {
    display: none;
  }
}
.story-content {
  padding: var(--space-28) 0 0;
}
.story-content h1 {
  font-size: var(--text-title);
  margin: 0 0 var(--space-30);
}
.comic {
  min-height: 555px;
  position: relative;
  background: var(--paper);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  overflow: hidden;
}
.comic .scene-art {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: auto;
  display: block;
  mask-image: linear-gradient(transparent, black 12%);
  -webkit-mask-image: linear-gradient(transparent, black 12%);
}
.bubble {
  position: relative;
  background: var(--surface);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-lg);
  padding: var(--space-20) 25px;
  line-height: 1.6;
  font-size: var(--text-lead);
  box-shadow: 0 2px 0 var(--shadow-hairline);
}
.bubble.manager {
  position: absolute;
  top: 24px;
  right: 40px;
  width: 54%;
}
.bubble.employee {
  position: absolute;
  top: 85px;
  left: 40px;
  width: 31%;
}
.bubble .speaker {
  font-size: var(--text-caption);
  letter-spacing: 0.05em;
  display: block;
  color: var(--red);
  font-weight: var(--weight-bold);
  margin-bottom: var(--space-8);
}
/* Кнопка перехода в сцене стоит под кадром отдельным рядом: внутри пузыря она
   раздувала реплику и ломала раскладку на телефоне. Ряд прижат вправо на широком
   окне, на узком растягивается на всю ширину. */
.story-next-row {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--space-14);
}
.story-next-row .primary {
  min-width: 190px;
  min-height: 52px;
  font-size: var(--text-lead);
}
.story-next-row .primary svg {
  width: 18px;
  height: 18px;
}
@media (max-width: 720px) {
  /* На телефоне кнопка шага занимает всю ширину: палец попадает без прицела,
     а строка реплики больше не упирается в край кнопки. */
  .story-next-row {
    justify-content: stretch;
    margin-top: var(--space-12);
  }
  .story-next-row .primary {
    width: 100%;
    min-width: 0;
    min-height: 48px;
    font-size: var(--text-body);
  }
}
.bubble:after {
  content: '';
  position: absolute;
  bottom: -16px;
  left: 70%;
  width: 22px;
  height: 22px;
  border-bottom: 1.5px solid var(--ink);
  border-right: 1.5px solid var(--ink);
  background: var(--surface);
  transform: skewY(35deg) rotate(20deg);
}
.bubble.employee:after {
  left: 48%;
}
.bubble.thought {
  position: absolute;
  right: 34px;
  top: 35px;
  width: 59%;
  border-radius: 25px;
}
.bubble.thought:after {
  border: 1px solid var(--ink);
  width: 13px;
  height: 13px;
  border-radius: var(--radius-round);
  left: -33px;
  bottom: 16px;
  transform: none;
  box-shadow:
    -21px 13px 0 -2px var(--surface),
    -21px 13px 0 -1px var(--ink);
}
.bubble.thought.second {
  top: auto;
  bottom: 80px;
}
/* Развилка в кадре (comic с полем choices): картинка и реплики — в .comic-stage, кнопки выбора —
   в той же рамке. На широком окне кнопки лежат поверх картинки под репликами, на среднем —
   полосой под картинкой, на телефоне — в потоке после реплик. */
.comic-stage {
  position: relative;
  min-height: inherit;
}
.comic-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-12);
  padding: var(--space-16) var(--space-20) var(--space-20);
  border-top: 1px solid var(--border-strong);
  background: var(--paper);
}
.comic-choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-12);
  min-height: 0;
  padding: var(--space-14) var(--space-18);
  text-align: left;
  font-size: var(--text-body);
  font-weight: var(--weight-bold);
  line-height: 1.4;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--red);
  border-radius: var(--radius-8);
}
.comic-choice svg {
  flex-shrink: 0;
  color: var(--red);
}
.comic-choice:hover {
  background: var(--red);
  color: var(--ink-on-dark);
}
.comic-choice:hover svg {
  color: var(--ink-on-dark);
}
@media (min-width: 1400px) {
  .comic-choices {
    position: absolute;
    left: calc(23.2cqw + 60px);
    right: 34px;
    bottom: var(--space-24);
    padding: 0;
    border: 0;
    background: none;
  }
}
@media (max-width: 720px) {
  .comic-stage {
    display: contents;
  }
  .comic-choices {
    grid-template-columns: 1fr;
    padding: 0;
    border: 0;
    background: none;
  }
}
.story-file {
  position: absolute;
  right: 27%;
  bottom: var(--space-28);
  width: 320px;
  background: var(--surface);
  border: var(--border-hairline) solid var(--border);
  border-radius: var(--radius-5);
  padding: 0 var(--space-16);
}
.story-file .file-badge {
  margin: var(--space-14) 0;
}
.story-file small {
  font-size: var(--text-caption);
}
.story-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-12);
  margin-top: var(--space-24);
}
/* Кнопка перехода теперь стоит в углу последней реплики, поэтому пустой ряд под кадром
   не занимает место. */
.story-actions:empty {
  display: none;
}
.story-actions .primary {
  min-width: 230px;
}
.finale-main {
  padding: var(--space-30) var(--space-28) var(--space-24);
}
.finale-main .subtitle {
  margin-bottom: var(--space-24);
}
.final-comic {
  min-height: 565px;
}
.final-comic .scene-art {
  bottom: 0;
  object-fit: cover;
  height: 100%;
  object-position: center;
}
.final-comic .bubble.manager {
  top: 16px;
  right: 18px;
  width: 67%;
  font-size: var(--text-body);
  line-height: 1.55;
  padding: var(--space-16) var(--space-20);
}
.mission-card {
  position: absolute;
  bottom: var(--space-32);
  left: 31%;
  width: 39%;
  background: var(--surface);
  border: var(--border-width) solid var(--ink);
  box-shadow: var(--shadow-ink);
  border-radius: var(--radius-control);
  padding: var(--space-20);
  text-align: center;
}
.mission-card h2 {
  font-family: var(--font-body);
  font-size: var(--text-caption);
  margin-bottom: var(--space-16);
}
.mission-score {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-15);
  font-family: var(--font-title);
  font-size: var(--text-display);
  line-height: 1.1;
  margin-bottom: var(--space-20);
}
.mission-score .coin {
  width: 35px;
  height: 35px;
}
.achievement {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  text-align: left;
  font-size: var(--text-caption);
  margin: var(--space-10) 0;
}
.achievement .check-icon {
  width: 18px;
  height: 18px;
}
.final-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--space-10);
  margin-top: var(--space-22);
}
dialog {
  border: var(--border-width) solid var(--ink);
  border-radius: var(--radius-lg);
  background: var(--paper);
  padding: var(--space-28);
  max-width: min(550px, calc(100% - 30px));
  color: var(--ink);
  overscroll-behavior: contain;
  max-height: 90dvh;
  overflow: auto;
}
dialog::backdrop {
  background: var(--stage-panel);
}
dialog h2 {
  font-size: var(--text-title);
  margin-bottom: var(--space-18);
}
dialog p {
  font-size: var(--text-small);
  line-height: 1.6;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--space-10);
  margin-top: var(--space-24);
}
.dialog-actions button {
  font-size: var(--text-caption);
}
.sample-files {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-10);
  margin: var(--space-20) 0;
}
.sample-files button {
  font-size: var(--text-caption);
}
.file-picker {
  display: flex;
  flex-direction: column;
  gap: var(--space-10);
  font-size: var(--text-small);
  font-weight: var(--weight-bold);
  margin: var(--space-20) 0;
}
.file-picker input {
  padding: var(--space-8);
  max-width: 100%;
  font-size: var(--text-caption);
}
.file-picker input::file-selector-button {
  padding: var(--space-10);
  background: var(--surface);
  border: var(--border-hairline) solid var(--border-control);
  border-radius: var(--radius-sm);
  margin-right: var(--space-10);
}
@media (min-width: 1750px) {
  .lesson-header {
    padding: var(--space-26) var(--space-32);
    min-height: 114px;
  }
  .lesson-header .brand {
    width: 170px;
  }
  .route button {
    font-size: var(--text-small);
    padding: var(--space-11) var(--space-10);
    min-height: 61px;
  }
  .lesson-main,
  .finale-main {
    padding: var(--space-32);
  }
  .learning-grid {
    grid-template-columns: minmax(250px, 0.8fr) minmax(0, 1.85fr);
    gap: var(--space-32);
  }
  .prompt-text {
    font-size: var(--text-body);
  }
  .choice {
    font-size: var(--text-small);
  }
  .subtitle {
    font-size: var(--text-body);
  }
  .result-sticky {
    padding: var(--space-32) var(--space-32);
  }
  .result-title {
    font-size: var(--text-title);
  }
  .dashboard {
    min-height: 680px;
    padding: var(--space-24);
  }
  .dash-empty {
    min-height: 680px;
  }
  .final-comic {
    min-height: 660px;
  }
  .final-comic .bubble.manager {
    font-size: var(--text-lead);
  }
  .mission-card {
    padding: var(--space-24);
  }
  .mission-card h2 {
    font-size: var(--text-small);
  }
  .achievement {
    font-size: var(--text-small);
  }
}
@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .result-pane {
    border-left: 0;
    border-top: var(--rule-accent) solid var(--red);
  }
  .result-sticky {
    position: static;
    padding: var(--space-30) var(--space-20);
  }
  .result-title {
    margin-bottom: var(--space-26);
  }
  .lesson-header {
    gap: var(--space-20);
  }
  .learning-grid {
    grid-template-columns: minmax(240px, 0.8fr) minmax(0, 1.8fr);
  }
  .lesson-header .brand {
    width: 150px;
  }
  .route button {
    font-size: var(--text-small);
  }
  .dashboard,
  .dash-empty {
    min-height: 580px;
  }
  .kpi .value {
    font-size: 40px;
  }
  .plan .value {
    font-size: var(--text-title);
  }
  .final-comic {
    min-height: 620px;
  }
  .final-comic .bubble.manager {
    font-size: var(--text-lead);
  }
  .final-comic .scene-art {
    height: auto;
  }
  .mission-card {
    bottom: var(--space-32);
    width: 34%;
    left: 33%;
  }
  .story-content h1 {
    font-size: var(--text-title);
  }
  .story-shell {
    padding: 0 var(--gutter-x) var(--space-24);
  }
  .comic:not(.final-comic) {
    min-height: 520px;
  }
  .bubble {
    font-size: var(--text-body);
  }
  .bubble.manager {
    right: 24px;
  }
  .bubble.employee {
    left: 24px;
  }
}
@media (max-width: 720px) {
  .lesson-header {
    flex-wrap: wrap;
    padding: var(--space-20);
    gap: var(--space-18);
  }
  .lesson-header .brand {
    flex: 1;
    width: auto;
  }
  .lesson-header .xp {
    margin-left: auto;
  }
  .lesson-header:after {
    left: var(--space-20);
    right: var(--space-20);
  }
  .route {
    flex: 0 0 100%;
    order: 3;
    gap: var(--space-14);
  }
  .route button {
    font-size: var(--text-caption);
    min-height: 52px;
    flex-direction: column;
    padding: var(--space-7) var(--space-3);
    gap: var(--space-5);
  }
  .route-label {
    text-align: center;
  }
  .route li:not(:last-child):after {
    right: -11px;
    top: var(--space-22);
    font-size: var(--text-body);
  }
  .route .step-number {
    width: 22px;
    height: 22px;
  }
  .route .check-icon {
    width: 22px;
    height: 22px;
  }
  .lesson-main,
  .finale-main {
    padding: var(--space-24) var(--space-20);
  }
  .lesson-main h1,
  .finale-main h1 {
    font-size: var(--text-title);
  }
  .subtitle {
    font-size: var(--text-small);
    margin-bottom: var(--space-22);
  }
  .learning-grid {
    grid-template-columns: 1fr;
    gap: var(--space-24);
  }
  .choice {
    font-size: var(--text-small);
    flex-grow: 1;
  }
  .prompt-text {
    font-size: var(--text-small);
  }
  .prompt-card {
    padding: var(--space-16);
  }
  .action-row {
    gap: var(--space-10);
  }
  .action-row .primary {
    flex: 1;
  }
  .action-row .reward {
    flex-shrink: 0;
  }
  .action-row button {
    font-size: var(--text-small);
  }
  .result-title {
    font-size: var(--text-title);
  }
  .tablet {
    max-width: 450px;
  }
  .dashboard {
    padding: var(--space-18);
  }
  .presentation {
    padding: var(--space-16);
  }
  .presentation-bar {
    align-items: flex-start;
    font-size: 12px;
  }
  .presentation-bar button {
    font-size: 12px;
  }
  .presentation .dashboard {
    padding: var(--space-20);
  }
  .presentation .kpi .value {
    font-size: 36px;
  }
  .presentation .plan .value {
    font-size: 24px;
  }
  .presentation .submetrics {
    grid-template-columns: 1fr 112px;
  }
  .presentation .dash-head h2 {
    font-size: 32px;
  }
  .presentation .donut-label strong {
    font-size: 26px;
  }
  .story-shell {
    padding: 0 var(--gutter-x) var(--space-24);
  }
  .story-header {
    padding-block: var(--space-20);
    min-height: 85px;
  }
  .story-header .right {
    gap: var(--space-5);
  }
  .story-header .right button {
    font-size: var(--text-caption);
  }
  .story-content {
    padding-top: var(--space-24);
  }
  .story-content h1 {
    font-size: var(--text-title);
    margin-bottom: var(--space-24);
  }
  .comic,
  .comic:not(.final-comic) {
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0 var(--space-15) var(--space-22);
    gap: var(--space-18);
  }
  .comic .scene-art {
    position: relative;
    display: block;
    order: -1;
    width: calc(100% + 30px);
    margin: 0 -15px;
    mask-image: none;
    -webkit-mask-image: none;
    height: auto;
    object-fit: contain;
  }
  .bubble,
  .bubble.manager,
  .bubble.employee,
  .bubble.thought,
  .bubble.thought.second,
  .final-comic .bubble.manager {
    position: relative;
    inset: auto;
    width: 100%;
    font-size: var(--text-body);
    padding: 17px var(--space-18);
    border-radius: var(--radius-8);
    line-height: 1.6;
    box-shadow: none;
  }
  .bubble:after,
  .bubble.thought:after {
    display: none;
  }
  .bubble .speaker {
    font-size: var(--text-caption);
  }
  .story-file {
    position: static;
    width: 100%;
    padding: 0 var(--space-12);
    order: 4;
  }
  .story-actions {
    margin-top: var(--space-20);
  }
  .story-actions .primary {
    width: 100%;
    min-width: 0;
  }
  .final-comic {
    min-height: 0;
    gap: var(--space-20);
    padding-bottom: var(--space-20);
  }
  .final-comic .scene-art {
    height: auto;
  }
  .mission-card {
    position: relative;
    inset: auto;
    width: 100%;
    padding: var(--space-22);
    margin: 0;
    box-shadow: var(--shadow-ink-sm);
  }
  .mission-score {
    font-size: var(--text-display);
  }
  .achievement {
    font-size: var(--text-small);
    justify-content: center;
  }
  .mission-card h2 {
    font-size: var(--text-small);
  }
  .final-actions button {
    flex: 1;
    font-size: var(--text-caption);
  }
  .lesson-footer {
    gap: var(--space-10);
  }
  .lesson-footer .quiet {
    max-width: 190px;
  }
}
@media (max-width: 380px) {
  .lesson-main,
  .finale-main {
    padding: var(--space-22) var(--space-16);
  }
  .lesson-header {
    padding: var(--space-18) var(--space-16);
    gap: var(--space-14);
  }
  .route {
    gap: var(--space-10);
  }
  .route li:not(:last-child):after {
    right: -9px;
  }
  .route button {
    font-size: var(--text-caption);
  }
  .route-label {
    font-size: var(--text-caption);
  }
  .data-table {
    font-size: var(--text-caption);
  }
  .data-table th,
  .data-table td {
    padding: var(--space-12) var(--space-6);
  }
  .choice {
    font-size: var(--text-caption);
    padding: var(--space-8);
  }
  .reward {
    padding: var(--space-7) var(--space-8);
    gap: var(--space-6);
  }
  .reward strong {
    font-size: var(--text-small);
  }
  .reward .coin {
    width: 25px;
    height: 25px;
  }
  .action-row .primary {
    padding: var(--space-10);
    font-size: var(--text-caption);
  }
  .tablet {
    padding: var(--space-22) var(--space-10) 13px;
    border-radius: var(--radius-24);
  }
  .dashboard {
    padding: 13px;
  }
  .kpi {
    padding: 13px;
  }
  .kpi .value {
    font-size: 32px;
  }
  .plan .value {
    font-size: var(--text-lead);
  }
  .submetrics {
    gap: var(--space-10);
    grid-template-columns: 1fr 95px;
  }
  .donut-label strong {
    font-size: var(--text-title);
  }
  .comparison {
    gap: var(--space-12);
    padding: var(--space-11);
  }
  .comparison strong {
    font-size: var(--text-lead);
  }
  .dash-head h2 {
    font-size: var(--text-title);
  }
  .dash-head select {
    width: 112px;
    font-size: var(--text-caption);
  }
  .story-header .brand {
    font-size: var(--text-body);
  }
  .story-header .right {
    gap: 0;
  }
  .story-header .right button {
    font-size: var(--text-caption);
    padding: var(--space-8) var(--space-3);
  }
  .presentation .submetrics {
    grid-template-columns: 1fr 95px;
  }
  .presentation .dashboard {
    padding: var(--space-14);
  }
}
.data-table label {
  min-height: 44px;
}
.help summary {
  min-height: 44px;
}
.mobile-switch {
  display: none;
}
@media (max-width: 1180px) {
  /* Нижний отступ нужен только там, где снизу стоит закреплённая панель переходов.
     Там, где панели нет, он добавлял странице прокрутку при свободном месте. */
  .workspace:has(> .mobile-switch) {
    padding-bottom: 68px;
  }
  .mobile-switch {
    display: flex;
    position: fixed;
    z-index: 15;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--paper);
    border-top: var(--border-hairline) solid var(--border);
    padding: var(--space-8) var(--space-16) calc(var(--space-8) + env(safe-area-inset-bottom));
    gap: var(--space-10);
    box-shadow: var(--shadow-dock);
  }
  .mobile-switch button {
    flex: 1;
    border-color: var(--stage-line);
    color: var(--blue);
    font-size: var(--text-small);
  }
  .toast {
    bottom: 80px;
  }
}
@media (min-width: 721px) and (max-width: 900px) {
  .lesson-header {
    flex-wrap: wrap;
  }
  .lesson-header .brand {
    flex: 1;
  }
  .lesson-header .route {
    order: 3;
    flex-basis: 100%;
  }
}
@media (max-width: 720px) {
  .submetrics {
    grid-template-columns: minmax(0, 1fr) 95px;
    gap: var(--space-12);
  }
  .plan {
    padding: var(--space-14) var(--space-12);
  }
  .plan .value {
    font-size: var(--text-lead);
  }
}
@media (max-width: 380px) {
  .submetrics {
    grid-template-columns: minmax(0, 1fr) 80px;
    gap: var(--space-8);
  }
  .plan {
    padding: var(--space-12) var(--space-8);
  }
  .plan .value {
    font-size: var(--text-lead);
    letter-spacing: -0.03em;
  }
  .donut-label strong {
    font-size: var(--text-lead);
  }
  .presentation .submetrics {
    grid-template-columns: minmax(0, 1fr) 80px;
    gap: var(--space-8);
  }
  .presentation .plan .value {
    font-size: 18px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

.back-button {
  font-size: var(--text-small);
  flex-shrink: 0;
}
.back-button svg {
  transform: rotate(180deg);
}
.story-actions .primary {
  margin-left: auto;
}
.lesson-footer {
  flex-wrap: wrap;
}
.quest-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-24);
  margin-top: var(--space-28);
  padding: var(--space-24) var(--space-28);
  background: var(--stage-bg);
  color: var(--ink-on-dark);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-5);
  box-shadow: var(--shadow-ink);
}
.quest-emblem {
  color: var(--gold);
  display: block;
  width: 58px;
  height: 58px;
}
.quest-emblem svg {
  display: block;
  width: 100%;
  height: 100%;
}
.quest-label {
  display: block;
  font-size: var(--text-caption);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--stage-accent);
  margin-bottom: var(--space-8);
}
.quest-copy h2 {
  font-size: var(--text-title);
  margin-bottom: var(--space-9);
}
.quest-copy p {
  font-size: var(--text-body);
  line-height: 1.5;
}
.quest-copy > small {
  display: block;
  font-size: var(--text-caption);
  color: var(--stage-muted);
  margin-top: var(--space-5);
}
.quest-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-16);
}
.quest-reward {
  display: flex;
  align-items: center;
  gap: var(--space-10);
}
.quest-reward strong {
  display: block;
  font-size: var(--text-lead);
  line-height: 1.2;
}
.quest-reward small {
  display: block;
  font-size: var(--text-caption);
  color: var(--stage-muted);
  margin-top: var(--space-4);
}
.quest-actions button {
  font-size: var(--text-small);
  min-width: 190px;
}
@media (max-width: 720px) {
  .quest-card {
    grid-template-columns: 40px minmax(0, 1fr);
    gap: var(--space-16);
    padding: var(--space-20) var(--space-18);
    margin-top: var(--space-24);
    align-items: start;
  }
  .quest-emblem {
    width: 40px;
    height: 44px;
  }
  .quest-copy h2 {
    font-size: var(--text-title);
  }
  .quest-copy p {
    font-size: var(--text-small);
  }
  .quest-copy > small {
    font-size: var(--text-caption);
  }
  .quest-actions {
    grid-column: 1/-1;
    gap: var(--space-16);
  }
  .quest-actions button {
    width: 100%;
    min-width: 0;
  }
}
.kpi.deals {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-12);
  margin-top: var(--space-14);
  padding: var(--space-12) var(--space-16);
}
.kpi.deals h3 {
  margin: 0;
}
.kpi.deals .value {
  font-size: 26px;
}
@media (max-width: 720px) {
  /* Таблица данных на телефоне на ступень мельче: при 14 px числа «1 000 000» рвутся по разрядам. */
  .data-table {
    font-size: var(--text-caption);
  }
  .data-table label {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-6);
  }
  .data-table label span {
    max-width: 100%;
    overflow-wrap: anywhere;
  }
}
@media (max-width: 380px) {
  .data-table {
    font-size: var(--text-caption);
  }
  .data-table th,
  .data-table td {
    padding: var(--space-12) var(--space-4);
  }
}
.story-content,
.finale-main {
  container-type: inline-size;
}
/* Anchor balloons to the heads in the fixed illustration compositions as their width changes. */
@media (min-width: 721px) {
  .comic {
    container-type: inline-size;
  }
  .story-shell .comic {
    min-height: max(555px, calc(27cqw + 230px));
  }
  .dialogue-comic .bubble.employee {
    top: auto;
    bottom: calc(27cqw + 40px);
  }
  .dialogue-comic .bubble.manager {
    top: auto;
    bottom: calc(24cqw + 40px);
  }
  .decision-comic .bubble.thought {
    left: calc(23.2cqw + 60px);
    right: 34px;
    width: auto;
    top: auto;
    bottom: calc(22cqw + 40px);
  }
  .decision-comic .bubble.thought:after {
    left: -22px;
    bottom: -4px;
    box-shadow:
      -19px 13px 0 -2px var(--surface),
      -19px 13px 0 -1px var(--ink),
      -38px 26px 0 -4px var(--surface),
      -38px 26px 0 -3px var(--ink);
  }
  .decision-comic .bubble.thought.second {
    top: calc(100% - 22cqw + 20px);
    bottom: auto;
  }
  .decision-comic .bubble.thought.second:after {
    top: 20px;
    bottom: auto;
    box-shadow:
      -19px -13px 0 -2px var(--surface),
      -19px -13px 0 -1px var(--ink),
      -38px -26px 0 -4px var(--surface),
      -38px -26px 0 -3px var(--ink);
  }
  .final-comic {
    min-height: max(630px, calc(40cqw + 270px));
  }
  .final-comic .scene-art {
    height: auto;
    object-fit: contain;
  }
  .final-comic .bubble.manager {
    top: auto;
    bottom: calc(40cqw + 40px);
  }
  .final-comic .bubble.manager:after {
    left: 77%;
  }
}
@media (max-width: 720px) {
  .story-actions {
    flex-wrap: wrap;
  }
  .story-actions .primary {
    width: auto;
    flex: 1;
  }
}

.paste-slot > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-12);
  cursor: pointer;
  min-height: 30px;
  font-size: var(--text-caption);
}
.paste-slot > summary > span:last-child {
  color: var(--blue);
  font-size: var(--text-caption);
}
.paste-slot[open] textarea {
  margin-top: var(--space-10);
}
.prompt-editor {
  background: var(--surface);
  border: var(--border-hairline) solid var(--border);
  border-radius: var(--radius-control);
  margin: var(--space-14) 0;
}
.prompt-editor > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-14);
  flex-wrap: wrap;
  padding: var(--space-12);
  min-height: 48px;
  cursor: pointer;
}
.prompt-editor > summary > span:first-child {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  font-size: var(--text-small);
  font-weight: var(--weight-bold);
  color: var(--positive);
}
.prompt-editor > summary > span:last-child {
  color: var(--blue);
  font-size: var(--text-caption);
}
.prompt-editor > summary > span:last-child:after {
  content: ' ▾';
}
.prompt-editor[open] > summary > span:last-child:after {
  content: ' ▴';
}
.prompt-editor[open] > summary {
  border-bottom: var(--border-hairline) solid var(--line-soft);
}
.editor-content {
  padding: var(--space-14);
}
@media (min-width: 1100px) and (min-height: 650px) {
  .lesson-workspace {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    grid-template-columns: minmax(0, 1.95fr) minmax(340px, 1fr);
  }
  .lesson-workspace > .learning-pane {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  .lesson-header {
    flex-shrink: 0;
    min-height: 72px;
    padding: var(--space-14) var(--space-20);
    gap: var(--space-14);
  }
  .lesson-header .brand {
    width: 120px;
    font-size: var(--text-body);
  }
  .route {
    gap: var(--space-14);
  }
  .route button {
    min-height: 44px;
    padding: var(--space-6);
    font-size: var(--text-caption);
  }
  .route .step-number,
  .route .check-icon {
    width: 20px;
    height: 20px;
  }
  .route li:not(:last-child):after {
    right: -11px;
    top: var(--space-5);
    font-size: var(--text-lead);
  }
  .lesson-header .xp {
    font-size: var(--text-small);
  }
  .lesson-header .coin {
    width: 25px;
    height: 25px;
  }
  .lesson-main {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding: var(--space-18) var(--space-20) var(--space-12);
  }
  .lesson-main h1 {
    font-size: var(--text-title);
  }
  .lesson-main > .subtitle {
    font-size: var(--text-caption);
    margin: var(--space-6) 0 var(--space-18);
  }
  .learning-grid {
    grid-template-columns: clamp(190px, 17vw, 230px) minmax(0, 1fr);
    gap: var(--space-20);
    min-height: 0;
    height: 100%;
  }
  .prompt-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-14);
    align-items: start;
  }
  .controls {
    margin-bottom: var(--space-12);
  }
  .controls legend {
    font-size: var(--text-caption);
    margin-bottom: var(--space-8);
  }
  .choices {
    gap: var(--space-6);
  }
  .choice {
    font-size: var(--text-caption);
    min-height: 38px;
    padding: var(--space-7) var(--space-8);
  }
  .prompt-card {
    padding: var(--space-12) var(--space-14);
    margin: var(--space-6) 0 var(--space-10);
  }
  .prompt-title {
    margin-bottom: var(--space-8);
  }
  .prompt-title .icon-button {
    width: 32px;
    min-height: 30px;
    padding: var(--space-5);
  }
  .prompt-text {
    font-size: var(--text-small);
    line-height: 1.5;
  }
  .prompt-tools {
    margin-top: var(--space-10);
  }
  .prompt-tools button {
    min-height: 36px;
    font-size: var(--text-caption);
    padding: var(--space-7) var(--space-11);
  }
  .paste-slot {
    padding: var(--space-10);
    margin: var(--space-10) 0;
  }
  .paste-slot > summary {
    min-height: 24px;
  }
  .paste-slot.empty p {
    font-size: var(--text-caption);
  }
  .paste-slot textarea {
    min-height: 82px;
    max-height: 160px;
  }
  .action-row {
    margin-top: var(--space-14);
    gap: var(--space-10);
  }
  .action-row .primary {
    font-size: var(--text-caption);
  }
  .reward {
    padding: var(--space-7) var(--space-10);
  }
  .reward strong {
    font-size: var(--text-body);
  }
  .help {
    margin-top: var(--space-10);
  }
  .help summary {
    min-height: 36px;
  }
  .growth-check {
    margin-top: var(--space-14);
    padding: var(--space-16);
  }
  .growth-check h3 {
    font-size: var(--text-body);
  }
  .growth-check .action-row {
    margin-top: var(--space-16);
  }
  .lesson-footer {
    margin-top: var(--space-12);
    padding-top: var(--space-4);
    font-size: var(--text-caption);
  }
  .lesson-footer .back-button {
    font-size: var(--text-caption);
    min-height: 36px;
  }
  .lesson-footer .link {
    font-size: var(--text-caption);
  }
  .lesson-footer .quiet {
    font-size: var(--text-caption);
  }
  .data-table {
    font-size: var(--text-caption);
  }
  .data-table th,
  .data-table td {
    padding: var(--space-10) var(--space-8);
  }
  .data-table label {
    min-height: 36px;
  }
  .table-container {
    margin-bottom: var(--space-14);
  }
  .verification {
    margin: var(--space-14) 0;
  }
  .verification legend {
    font-size: var(--text-small);
    margin-bottom: var(--space-10);
  }
  .answer-row {
    margin: var(--space-8) 0;
  }
  .answer-row input {
    min-height: 40px;
  }
  .success-line {
    font-size: var(--text-caption);
    padding: var(--space-10) 0;
  }
  .result-sticky {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    gap: var(--space-14);
    padding: var(--space-16);
  }
  .lesson-workspace .result-sticky {
    position: static;
  }
  .result-title {
    font-size: var(--text-body);
    line-height: 1.3;
    margin: 0;
  }
  .result-title br {
    display: none;
  }
  .tablet {
    display: flex;
    flex-direction: column;
    min-height: 0;
    width: 100%;
    max-width: 370px;
    max-height: calc(100dvh - 76px);
    padding: var(--space-20) var(--space-12) var(--space-12);
    border-radius: var(--radius-24);
    margin: 0 auto;
  }
  .camera {
    top: var(--space-8);
  }
  .tablet .dashboard {
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
  }
  .tablet .dashboard:not(.dash-empty) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 78px;
    gap: var(--space-8);
    align-content: start;
    padding: var(--space-12);
  }
  .tablet .dashboard > .dash-head {
    grid-column: 1/-1;
    margin-bottom: var(--space-2);
  }
  .tablet .dash-head h2 {
    font-size: 26px;
  }
  .tablet .dash-head p {
    font-size: 10px;
    margin-top: var(--space-4);
  }
  .tablet .dash-head select {
    font-size: 11px;
    width: 116px;
    min-height: 34px;
    padding: var(--space-6) var(--space-8);
  }
  .tablet .dashboard .kpi {
    padding: var(--space-10);
    border-radius: var(--radius-8);
  }
  .tablet .dashboard .kpi h3 {
    font-size: 12px;
    margin-bottom: var(--space-6);
  }
  .tablet .dashboard .kpi .value {
    font-size: 30px;
  }
  .tablet .dashboard > .kpi:not(.deals) {
    grid-column: 1;
    grid-row: 2;
  }
  .tablet .dashboard .submetrics {
    display: contents;
  }
  .tablet .dashboard .plan {
    grid-column: 1;
    grid-row: 3;
  }
  .tablet .dashboard .plan .value {
    font-size: 22px;
  }
  .tablet .dashboard .donut {
    grid-column: 2;
    grid-row: 2 / span 2;
    width: 78px;
    height: auto;
    align-self: center;
    justify-self: end;
  }
  .tablet .donut-label strong {
    font-size: 22px;
  }
  .tablet .dashboard > .kpi.deals {
    grid-column: 1/-1;
    margin: 0;
    padding: var(--space-8) var(--space-10);
    min-height: 40px;
  }
  .tablet .dashboard .kpi.deals h3 {
    margin: 0;
  }
  .tablet .dashboard .kpi.deals .value {
    font-size: 22px;
  }
  .tablet .comparison {
    grid-column: 1/-1;
    margin: 0;
    padding: var(--space-8) var(--space-10);
    gap: var(--space-12);
  }
  .tablet .comparison strong {
    font-size: 20px;
  }
  .tablet .comparison p {
    font-size: 10px;
  }
  .tablet .comparison small {
    font-size: 9px;
    margin-top: var(--space-4);
  }
  .tablet .chart-title {
    grid-column: 1/-1;
    margin: var(--space-6) 0 0;
  }
  .tablet .chart-title h3 {
    font-size: 12px;
  }
  .tablet .chart-title small {
    font-size: 9px;
  }
  .tablet .chart {
    grid-column: 1/-1;
  }
  .tablet .upload-button {
    grid-column: 1/-1;
    position: sticky;
    bottom: 0;
    z-index: 2;
    min-height: 44px;
    font-size: 12px;
    margin-top: 0;
  }
  .tablet .dataset-note {
    grid-column: 1/-1;
    margin-top: 0;
    font-size: 9px;
  }
  .tablet .dash-empty {
    min-height: min(540px, calc(100dvh - 150px));
  }
}
@media (min-width: 1100px) and (min-height: 650px) and (max-height: 740px) {
  .lesson-header {
    min-height: 64px;
    padding-top: var(--space-10);
    padding-bottom: var(--space-10);
  }
  .lesson-main {
    padding-top: var(--space-14);
    padding-bottom: var(--space-10);
  }
  .lesson-main > .subtitle {
    margin-bottom: var(--space-12);
  }
  .choice {
    min-height: 34px;
    padding: var(--space-6) var(--space-8);
  }
  .choices {
    gap: var(--space-4);
  }
  .controls {
    margin-bottom: var(--space-6);
  }
  .prompt-card {
    padding: var(--space-8) var(--space-12);
  }
  .prompt-title {
    margin-bottom: var(--space-4);
  }
  .prompt-title .icon-button {
    min-height: 26px;
  }
  .prompt-text {
    font-size: var(--text-caption);
    line-height: 1.45;
  }
  .prompt-tools {
    margin-top: var(--space-6);
  }
  .prompt-tools button {
    min-height: 34px;
  }
  .paste-slot {
    padding: var(--space-6);
    margin: var(--space-6) 0;
  }
  .paste-slot > summary {
    min-height: 22px;
  }
  .lesson-footer {
    margin-top: var(--space-8);
  }
  .result-sticky {
    padding: var(--space-12);
    gap: var(--space-12);
  }
  .tablet {
    padding-top: var(--space-18);
    padding-bottom: var(--space-10);
  }
  .tablet .dashboard:not(.dash-empty) {
    gap: var(--space-6);
    padding: var(--space-10);
  }
  .tablet .dashboard .kpi {
    padding: var(--space-8);
  }
  .tablet .dashboard .kpi h3 {
    font-size: 11px;
    margin-bottom: var(--space-4);
  }
  .tablet .dashboard .kpi .value {
    font-size: 28px;
  }
  .tablet .dashboard .plan .value {
    font-size: 22px;
  }
  .tablet .dashboard > .kpi.deals {
    padding: var(--space-6) var(--space-8);
    min-height: 36px;
  }
  .tablet .dashboard .kpi.deals .value {
    font-size: 20px;
  }
  .tablet .comparison {
    padding: var(--space-6) var(--space-8);
  }
}

.month-control {
  position: relative;
  display: block;
  flex-shrink: 0;
}
.dash-head .month-control select {
  display: block;
  appearance: none;
  -webkit-appearance: none;
  padding-right: var(--space-32);
}
.month-control:after {
  content: '';
  position: absolute;
  right: var(--space-12);
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: var(--border-width) solid currentColor;
  border-bottom: var(--border-width) solid currentColor;
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

@media (min-width: 900px) {
  .presentation {
    padding: var(--space-18) var(--space-24);
  }
  .presentation-bar {
    margin-bottom: var(--space-16);
  }
  .presentation .dashboard {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)) 104px;
    gap: var(--space-12);
    max-width: 1000px;
    padding: var(--space-20);
  }
  .presentation .dashboard:has(.deals) {
    grid-template-columns: repeat(3, minmax(0, 1fr)) 104px;
  }
  .presentation .dashboard > *,
  .presentation .chart-title,
  .presentation .upload-button {
    grid-column: 1/-1;
    margin: 0;
  }
  .presentation .dash-head {
    align-items: center;
  }
  .presentation .dash-head h2 {
    font-size: 32px;
  }
  .presentation .dash-head p {
    margin-top: var(--space-4);
  }
  .presentation .dashboard .metrics-grid > .kpi {
    grid-column: 1;
    grid-row: 2;
  }
  .presentation .submetrics {
    display: contents;
  }
  .presentation .plan {
    grid-column: 2;
    grid-row: 2;
  }
  .presentation .dashboard > .kpi.deals {
    grid-column: 3;
    grid-row: 2;
    display: block;
  }
  .presentation .kpi {
    padding: var(--space-12);
    align-self: stretch;
  }
  .presentation .kpi h3 {
    font-size: 13px;
    margin-bottom: var(--space-10);
  }
  .presentation .kpi .value {
    font-size: 36px;
  }
  .presentation .plan .value {
    font-size: 28px;
  }
  .presentation .kpi.deals .value {
    font-size: 32px;
  }
  .presentation .donut {
    grid-column: -2/-1;
    grid-row: 2;
    width: 104px;
    height: auto;
    align-self: center;
  }
  .presentation .donut-label strong {
    font-size: 26px;
  }
  .presentation .comparison {
    padding: var(--space-9) var(--space-12);
  }
  .presentation .chart {
    height: clamp(140px, calc(100dvh - 510px), 250px);
    max-height: none;
  }
  .presentation .chart text {
    font-size: 12px;
  }
  .presentation .upload-button {
    min-height: 44px;
  }
}
@media (max-width: 380px) {
  .presentation .donut-label strong {
    font-size: 21px;
  }
}

.quest-copy .file-badge {
  display: inline-flex;
  background: var(--overlay-light);
  border: 1px solid var(--overlay-line);
  border-radius: var(--radius-control);
  padding: var(--space-10) var(--space-14);
  margin: var(--space-16) 0 0;
}
.quest-copy .file-badge small {
  color: var(--stage-muted);
}

.cover-shell {
  min-height: 100dvh;
  max-width: var(--shell-wide);
  margin-inline: auto;
  padding: var(--space-20);
  display: grid;
}
.cover-poster {
  position: relative;
  isolation: isolate;
  min-width: 0;
  min-height: calc(100dvh - 40px);
  overflow: hidden;
  border: var(--border-frame) solid var(--ink);
  background: var(--paper);
  box-shadow: var(--shadow-ink);
}
.cover-poster:after {
  content: '';
  position: absolute;
  inset: var(--space-10);
  border: var(--border-hairline) solid var(--frame-line);
  z-index: 2;
  pointer-events: none;
}
.cover-art {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
}
.cover-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}
.cover-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: min(900px, 74%);
  margin: clamp(64px, 14dvh, 170px) auto 48px;
}
.cover-title {
  font-size: clamp(60px, 6.6vw, 112px);
  line-height: 1;
  letter-spacing: -0.025em;
  margin: 0;
}
.cover-title span {
  display: block;
  font-size: 0.5em;
  line-height: 1.25;
  letter-spacing: 0;
  margin-bottom: var(--space-8);
}
.cover-description {
  font-size: var(--text-lead);
  line-height: 1.4;
  max-width: var(--measure);
  margin-top: var(--space-26);
  /* Перенос задан в контенте строками: «…с помощью ИИ / без навыков программирования».
     Подложки нет: короткие строки стоят на светлой части иллюстрации. */
  max-width: none;
}
.cover-start {
  margin-top: var(--space-30);
  min-width: 240px;
  min-height: 66px;
  font-size: var(--text-title);
  padding: var(--space-12) var(--space-32);
  border: var(--border-frame) solid var(--ink);
  border-radius: 0;
  box-shadow: var(--shadow-button);
}
.cover-start:active {
  box-shadow: var(--shadow-ink-sm);
}
@media (max-aspect-ratio: 1/1) {
  .cover-shell {
    padding: var(--space-12);
  }
  .cover-poster {
    min-height: calc(100dvh - 24px);
  }
  .cover-poster:after {
    inset: var(--space-8);
  }
  .cover-content {
    width: calc(100% - 52px);
    margin-top: clamp(72px, 14dvh, 160px);
  }
  .cover-title {
    font-size: clamp(44px, 13vw, 84px);
  }
  .cover-title span {
    font-size: 0.52em;
  }
  .cover-description {
    font-size: var(--text-lead);
    max-width: 30ch;
    margin-top: var(--space-24);
  }
  .cover-start {
    min-width: 200px;
    min-height: 58px;
    font-size: var(--text-lead);
    margin-top: var(--space-26);
  }
}
@media (max-height: 500px) and (min-aspect-ratio: 1/1) {
  .cover-shell {
    padding: var(--space-12);
  }
  .cover-poster {
    min-height: calc(100dvh - 24px);
  }
  .cover-poster:after {
    inset: var(--space-8);
  }
  .cover-content {
    width: 80%;
    margin-top: var(--space-28);
    margin-bottom: var(--space-24);
  }
  .cover-title {
    font-size: clamp(44px, 6.5vw, 64px);
  }
  .cover-title span {
    margin-bottom: var(--space-4);
  }
  .cover-description {
    font-size: var(--text-body);
    margin-top: var(--space-14);
    max-width: 40ch;
  }
  .cover-start {
    min-width: 190px;
    min-height: 48px;
    font-size: var(--text-lead);
    margin-top: var(--space-18);
  }
}

/* The lesson owns the assignment; the assistant owns only the conversation. */
.chat-workspace {
  /* Правая колонка не уже планшета с полями панели: иначе макет приложения
     вылезает за неё и обрезается правым краем окна. */
  grid-template-columns:
    minmax(0, 1.65fr)
    minmax(calc(var(--tablet-width) + 2 * var(--space-18) + var(--rule-accent) + var(--border-hairline)), 1fr);
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}
/* Шаг с работой: форма стоит в переписке, и планшет уступает ей ширину колонки.
   Нижняя граница колонки — сам планшет с полями панели: при 29% он не влезал,
   и правый край обрезался. */
.chat-workspace:has(.chat-frame-work):has(> .result-pane) {
  grid-template-columns:
    minmax(0, 1fr)
    minmax(calc(var(--tablet-width) + 2 * var(--space-18) + var(--rule-accent) + var(--border-hairline)), 29%);
}
.chat-workspace > .learning-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.chat-workspace .lesson-header {
  min-height: 72px;
  padding: var(--space-12) var(--space-20);
  gap: var(--space-14);
  flex-shrink: 0;
}
.chat-workspace .lesson-header .brand {
  width: 115px;
  font-size: var(--text-small);
}
.chat-workspace .route {
  gap: var(--space-12);
}
.chat-workspace .route li:not(:last-child):after {
  right: -10px;
  top: var(--space-8);
  font-size: var(--text-lead);
}
.chat-workspace .route button {
  font-size: var(--text-caption);
  min-height: 46px;
  padding: var(--space-6);
  gap: var(--space-5);
}
.chat-workspace .route .step-number,
.chat-workspace .route .check-icon {
  width: 20px;
  height: 20px;
}
.chat-workspace .lesson-header .xp {
  font-size: var(--text-small);
}
.chat-workspace .lesson-header .coin {
  width: 24px;
  height: 24px;
}
.chat-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
  padding: var(--space-18) var(--space-20) var(--space-12);
}
.chat-main > h1 {
  font-size: var(--text-title);
  flex-shrink: 0;
}
.chat-main > .subtitle {
  display: none;
}
.training-panel {
  background: var(--surface);
  border: var(--border-hairline) solid var(--border-panel);
  border-radius: var(--radius-control);
  flex-shrink: 0;
  overflow: hidden;
}
.training-panel > summary {
  display: flex;
  align-items: center;
  gap: var(--space-10);
  padding: var(--space-12) var(--space-14);
  cursor: pointer;
  list-style: none;
  min-height: 48px;
}
.training-panel > summary::-webkit-details-marker {
  display: none;
}
.training-panel > summary strong {
  font-size: var(--text-small);
  line-height: 1.4;
  flex: 1;
}
/* Ярлык задания стоит первой строкой раскрытой панели, а не плашкой в заголовке. */
.task-eyebrow {
  margin: 0 0 var(--space-6);
  font-size: var(--text-caption);
  font-weight: var(--weight-bold);
  letter-spacing: 0.02em;
  color: var(--muted);
}
.disclosure {
  width: 7px;
  height: 7px;
  flex-shrink: 0;
  border-right: var(--border-width) solid currentColor;
  border-bottom: var(--border-width) solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 150ms;
}
.training-panel[open] .disclosure {
  transform: translateY(1px) rotate(-135deg);
}
.training-content {
  padding: 0 var(--space-14) var(--space-14);
  max-height: 180px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  font-size: var(--text-caption);
}
.training-content > p {
  margin: var(--space-2) 0 var(--space-12);
}
.training-content .file-badge {
  margin: var(--space-10) 0;
}
.training-content .file-badge small {
  color: var(--muted);
}
.training-content .table-container {
  margin: var(--space-8) 0 var(--space-12);
}
.training-content .table-title {
  padding: var(--space-2) var(--space-10);
}
.training-content .data-table {
  font-size: var(--text-caption);
}
.training-content .data-table th,
.training-content .data-table td {
  padding: var(--space-7) var(--space-8);
}
.training-content .verification {
  margin: var(--space-8) 0;
}
.training-content .verification legend {
  font-size: var(--text-caption);
  margin-bottom: var(--space-6);
}
.training-content .answer-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-14);
  margin: var(--space-6) 0;
}
.training-content .answer-row input {
  width: 100%;
  min-height: 36px;
  padding: var(--space-5) var(--space-8);
  font-size: var(--text-small);
}
.training-content .action-row {
  margin: var(--space-10) 0 0;
  padding: 0;
  position: static;
}
.training-content .reward {
  padding: var(--space-5) var(--space-8);
}
.training-content .reward strong {
  font-size: var(--text-small);
}
.training-content .reward small {
  font-size: var(--text-caption);
}
.training-content .action-row button {
  font-size: var(--text-caption);
  min-height: 38px;
  padding: var(--space-8) var(--space-12);
}
.training-content .growth-check {
  padding: 0;
  border: 0;
  margin: var(--space-10) 0 0;
  background: none;
}
.training-content .growth-field {
  margin: var(--space-8) 0;
}
.training-content .growth-field input {
  min-height: 38px;
  padding: var(--space-6);
}
.chat-window {
  flex: 1;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  border: var(--border-hairline) solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-8);
  overflow: hidden;
  box-shadow: var(--shadow-panel);
}
.chat-heading {
  display: flex;
  align-items: center;
  gap: var(--space-10);
  flex-shrink: 0;
  padding: var(--space-11) var(--space-16);
  border-bottom: var(--border-hairline) solid var(--line-soft);
  background: var(--surface);
}
.assistant-avatar {
  background: var(--ink);
  color: var(--surface);
  width: 30px;
  height: 30px;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  font-size: var(--text-title);
  line-height: 1;
  flex-shrink: 0;
}
.chat-heading h2 {
  font-family: var(--font-body);
  font-size: var(--text-small);
  line-height: 1.3;
}
.chat-heading div > span {
  display: block;
  color: var(--muted);
  font-size: var(--text-caption);
  margin-top: var(--space-2);
}
.chat-heading-status {
  margin-left: auto;
  font-size: var(--text-caption);
  color: var(--muted);
}
.chat-log {
  flex: 1;
  min-height: 60px;
  overflow: auto;
  padding: var(--space-20) var(--space-20) var(--space-8);
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-gutter: stable;
}
.chat-message {
  font-size: var(--text-small);
  line-height: 1.55;
  max-width: 93%;
  margin-bottom: var(--space-22);
  overflow-wrap: anywhere;
}
.chat-message p {
  white-space: pre-line;
}
.chat-message p + p {
  margin-top: var(--space-7);
}
.message-author {
  display: block;
  font-size: var(--text-caption);
  font-weight: var(--weight-bold);
  color: var(--muted);
  margin-bottom: var(--space-7);
}
.chat-message.user {
  background: var(--chat-user-bg);
  border: var(--border-hairline) solid var(--accent-line);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-3) var(--radius-lg);
  padding: var(--space-12) var(--space-16);
  margin-left: auto;
  max-width: 86%;
}
.chat-message.user .message-author {
  color: var(--red);
}
.chat-message.assistant {
  margin-right: var(--space-20);
}
.chat-message.welcome {
  color: var(--ink-soft);
}
.chat-attachment {
  display: inline-flex;
  align-items: center;
  gap: var(--space-7);
  font-size: var(--text-caption);
  line-height: 1.3;
  color: var(--ink-soft);
  white-space: nowrap;
}
/* Контекст переписки: файл, прикреплённый на предыдущем шаге, виден и здесь. */
.chat-context {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  margin: 0 0 var(--space-20);
  color: var(--muted);
  font-size: var(--text-caption);
}
.chat-attachment > span {
  background: var(--file-green);
  color: var(--ink-on-dark);
  border-radius: var(--radius-3);
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-caption);
  font-weight: var(--weight-bold);
}
.user .chat-attachment {
  margin-top: var(--space-10);
  background: var(--surface);
  border: var(--border-hairline) solid var(--border-soft);
  padding: var(--space-5) var(--space-8);
  border-radius: var(--radius-5);
}
.artifact-card {
  display: flex;
  gap: var(--space-12);
  align-items: center;
  margin-top: var(--space-14);
  padding: var(--space-14);
  border: var(--border-hairline) solid var(--artifact-border);
  border-left: var(--rule-accent) solid var(--red);
  border-radius: var(--radius-control);
  text-decoration: none;
  background: var(--surface);
  color: var(--ink);
  transition:
    background 180ms,
    border-color 180ms;
}
.artifact-card:hover {
  background: var(--accent-pale);
  border-color: var(--red);
}
.artifact-card strong {
  display: block;
  font-size: var(--text-small);
}
.artifact-card small {
  display: block;
  color: var(--muted);
  font-size: var(--text-caption);
  margin-top: var(--space-3);
}
.artifact-link {
  display: block;
  color: var(--red);
  font-size: var(--text-caption);
  font-weight: var(--weight-bold);
  margin-top: var(--space-9);
}
.artifact-symbol {
  width: 34px;
  height: 40px;
  background: var(--artifact-bg);
  display: grid;
  place-items: center;
  border-radius: var(--radius-5);
  flex-shrink: 0;
}
.artifact-symbol svg {
  width: 21px;
  height: 21px;
}
.ai-progress {
  list-style: none;
  margin: var(--space-10) 0;
  padding: 0;
  display: grid;
  gap: var(--space-9);
  font-size: var(--text-caption);
  color: var(--muted);
}
.ai-progress li {
  display: flex;
  align-items: center;
  gap: var(--space-9);
}
.ai-progress li.waiting {
  opacity: 0.5;
}
.ai-progress li.running {
  color: var(--ink);
}
.ai-progress li.done {
  color: var(--positive-dark);
}
.progress-dot {
  width: 15px;
  height: 15px;
  border: var(--border-hairline) solid var(--border);
  border-radius: var(--radius-round);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.progress-dot svg {
  display: block;
  width: 11px;
  height: 11px;
}
.progress-dot svg path {
  transform: translateY(1px);
}
.running .progress-dot {
  border: var(--border-frame) solid var(--accent-line);
  border-top-color: var(--red);
  animation: chat-spin 900ms linear infinite;
}
.done .progress-dot {
  background: var(--positive-bg);
  border-color: var(--positive);
}
.streaming-answer {
  animation: chat-appear 200ms ease-out;
}
.typing-cursor {
  display: inline-block;
  width: 6px;
  height: 13px;
  background: var(--red);
  animation: chat-cursor 800ms ease-in-out infinite;
  margin-top: var(--space-6);
}
.interrupted {
  color: var(--muted);
}
.retry-button {
  font-size: var(--text-caption);
  margin-top: var(--space-10);
  padding: var(--space-7) var(--space-12);
}
.chat-composer {
  flex-shrink: 0;
  border-top: var(--border-hairline) solid var(--line-soft);
  padding: var(--space-12) var(--space-16);
  background: var(--surface-tint);
}
.composer-top,
.composer-bottom {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  justify-content: space-between;
}
.composer-top {
  margin-bottom: var(--space-8);
}
.composer-bottom {
  margin-top: var(--space-8);
}
.composer-bottom .quiet {
  font-size: var(--text-caption);
}
.composer-bottom button {
  font-size: var(--text-caption);
  min-height: 38px;
  padding: var(--space-8) var(--space-18);
}
.builder-button {
  min-height: 32px;
  padding: var(--space-5) var(--space-10);
  font-size: var(--text-caption);
  border-color: var(--border-soft);
  background: var(--surface);
  font-weight: var(--weight-bold);
}
.chat-composer textarea {
  display: block;
  resize: none;
  min-height: 0;
  height: 82px;
  max-height: 120px;
  font-size: var(--text-caption);
  line-height: 1.5;
  padding: var(--space-9) var(--space-11);
  background: var(--surface);
  border-color: var(--border-input);
  cursor: text;
}
.chat-composer textarea:placeholder-shown {
  height: 46px;
}
.composer-note {
  font-size: var(--text-caption);
  color: var(--muted);
  padding: var(--space-4) 0;
}
.chat-main .lesson-footer {
  margin: 0;
  padding: 0;
  flex-shrink: 0;
  font-size: var(--text-caption);
  min-height: 36px;
}
.chat-main .lesson-footer .back-button {
  min-height: 36px;
  font-size: var(--text-caption);
}
.chat-main .lesson-footer .link {
  font-size: var(--text-caption);
}
.chat-main .lesson-footer .quiet {
  font-size: var(--text-caption);
}
.chat-workspace .result-pane {
  min-height: 0;
  border-top: 0;
  border-left: var(--rule-accent) solid var(--red);
  overflow: auto;
}
.chat-workspace .result-sticky {
  position: static;
  min-height: 100%;
  height: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-16);
  padding: var(--space-18);
}
.chat-workspace .result-title {
  font-size: var(--text-lead);
  line-height: 1.3;
  text-align: center;
  margin: 0;
}
.preview-version {
  display: block;
  font-family: var(--font-body);
  font-size: var(--text-caption);
  font-weight: var(--weight-regular);
  color: var(--ink-on-dark-muted);
  margin-top: var(--space-6);
}
.chat-workspace .tablet {
  margin: 0 auto;
  width: 100%;
  max-width: 370px;
  max-height: calc(100dvh - 106px);
}
.chat-tabs {
  display: none;
}
#prompt-dialog {
  width: 640px;
  max-width: calc(100% - 28px);
  padding: var(--space-24);
  background: var(--paper);
}
.builder-heading {
  display: flex;
  gap: var(--space-14);
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-8);
}
.builder-heading h2 {
  margin: 0;
  font-size: var(--text-title);
}
.builder-heading button {
  font-size: var(--text-caption);
  min-height: 36px;
  padding: var(--space-6) var(--space-10);
}
#prompt-dialog > .quiet {
  margin-bottom: var(--space-24);
}
#prompt-dialog .controls {
  margin-bottom: var(--space-20);
}
#prompt-dialog .controls legend {
  font-size: var(--text-small);
  margin-bottom: var(--space-10);
}
#prompt-dialog .choices {
  gap: var(--space-8);
}
#prompt-dialog .choice {
  font-size: var(--text-small);
  padding: var(--space-9) var(--space-12);
  min-height: 42px;
}
#prompt-dialog .prompt-card {
  padding: var(--space-16);
  margin-bottom: 0;
}
#prompt-dialog .prompt-title {
  margin-bottom: var(--space-12);
}
#prompt-dialog .prompt-text {
  font-size: var(--text-small);
}
#prompt-dialog .dialog-actions {
  position: sticky;
  bottom: -24px;
  background: var(--paper);
  padding: var(--space-12) 0 0;
  margin-top: var(--space-12);
}
#prompt-dialog .feedback {
  margin-top: var(--space-12);
  padding: var(--space-12);
  font-size: var(--text-small);
}
@keyframes chat-spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes chat-cursor {
  50% {
    opacity: 0;
  }
}
@keyframes chat-appear {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@media (min-width: 1100px) and (max-height: 740px) {
  .chat-main {
    padding-top: var(--space-12);
    gap: var(--space-9);
  }
  .chat-main > h1 {
    font-size: var(--text-title);
  }
  .training-content {
    max-height: 116px;
  }
  .chat-composer {
    padding: var(--space-9) var(--space-14);
  }
  .chat-heading {
    padding: var(--space-9) var(--space-14);
  }
  .chat-log {
    padding: var(--space-14) var(--space-16) var(--space-6);
  }
  .chat-message {
    font-size: var(--text-small);
    margin-bottom: var(--space-16);
  }
  .chat-workspace .lesson-header {
    min-height: 64px;
  }
}
@media (max-width: 1099px) {
  .chat-workspace {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
  }
  /* Место под закреплённые вкладки «Чат / Приложение» есть только тогда, когда они на экране. */
  .chat-workspace:has(> .chat-tabs) {
    padding-bottom: 58px;
  }
  .chat-workspace > .learning-pane {
    flex: 1;
    min-height: 0;
  }
  .chat-main {
    padding: var(--space-14) var(--space-16) var(--space-10);
    gap: var(--space-10);
  }
  .chat-main > h1 {
    font-size: var(--text-title);
  }
  .training-content {
    max-height: 180px;
  }
  .chat-workspace[data-tab='app'] > .learning-pane {
    display: none;
  }
  .chat-workspace[data-tab='chat'] > .result-pane {
    display: none;
  }
  .chat-workspace > .result-pane {
    flex: 1;
    min-height: 0;
    border: 0;
    overflow: auto;
  }
  .chat-workspace .result-sticky {
    min-height: 100%;
    padding: var(--space-22) var(--space-16);
    gap: var(--space-14);
  }
  .chat-workspace .tablet {
    max-height: none;
  }
  .chat-tabs {
    position: fixed;
    display: flex;
    gap: var(--space-8);
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--space-7) var(--space-16);
    background: var(--paper);
    border-top: var(--border-hairline) solid var(--border);
    z-index: 8;
  }
  .chat-tabs button {
    flex: 1;
    min-height: 42px;
    font-size: var(--text-small);
    border-color: transparent;
    background: none;
    color: var(--muted);
  }
  .chat-tabs button[aria-pressed='true'] {
    background: var(--ink);
    color: var(--surface);
  }
  .chat-workspace .lesson-header .brand {
    width: 120px;
  }
  .chat-workspace .lesson-header .route {
    flex-basis: auto;
    order: initial;
  }
  .chat-workspace .route button {
    flex-direction: row;
  }
  .chat-workspace .route-label {
    text-align: left;
  }
}
@media (max-width: 720px) {
  .chat-workspace .lesson-header {
    padding: var(--space-12) var(--space-14);
    gap: var(--space-10);
    flex-wrap: wrap;
  }
  .chat-workspace .lesson-header .brand {
    font-size: var(--text-small);
    flex: 1;
  }
  .chat-workspace .lesson-header .route {
    order: 3;
    flex: 0 0 100%;
    gap: var(--space-10);
  }
  .chat-workspace .route button {
    min-height: 42px;
    font-size: var(--text-caption);
    padding: var(--space-5);
    gap: var(--space-4);
  }
  .chat-workspace .route .step-number,
  .chat-workspace .route .check-icon {
    width: 17px;
    height: 17px;
    font-size: var(--text-caption);
  }
  .chat-workspace .route .check-icon svg {
    width: 12px;
    height: 12px;
  }
  .chat-workspace .route li:not(:last-child):after {
    top: var(--space-8);
    right: -9px;
  }
  .chat-workspace .route-label {
    font-size: var(--text-caption);
  }
  .chat-main {
    padding: var(--space-12) var(--space-12) var(--space-8);
    gap: var(--space-8);
  }
  .chat-main > h1 {
    font-size: var(--text-title);
  }
  .training-panel > summary {
    padding: var(--space-10);
    gap: var(--space-7);
  }
  .training-panel > summary strong {
    font-size: var(--text-caption);
  }
  .training-content {
    padding: 0 var(--space-10) var(--space-12);
    max-height: 155px;
  }
  .training-content .data-table {
    font-size: var(--text-caption);
  }
  .training-content .data-table th,
  .training-content .data-table td {
    padding: var(--space-6) var(--space-4);
  }
  .training-content .answer-row {
    gap: var(--space-8);
    font-size: var(--text-caption);
  }
  .training-content .action-row {
    flex-wrap: wrap;
  }
  .training-content .reward small {
    display: none;
  }
  .chat-window {
    min-height: 220px;
  }
  .chat-heading {
    padding: var(--space-9) var(--space-11);
  }
  .chat-heading-status {
    display: none;
  }
  .chat-log {
    padding: var(--space-14) var(--space-12) var(--space-6);
  }
  .chat-message {
    font-size: var(--text-small);
    max-width: 100%;
    margin-bottom: var(--space-16);
  }
  .chat-message.user {
    max-width: 96%;
    padding: var(--space-10) var(--space-12);
  }
  .chat-message.assistant {
    margin-right: 0;
  }
  .artifact-card {
    padding: var(--space-11);
    gap: var(--space-9);
  }
  .artifact-card strong {
    font-size: var(--text-caption);
  }
  .artifact-card small {
    font-size: var(--text-caption);
  }
  .chat-composer {
    padding: var(--space-10) var(--space-11);
  }
  .chat-composer textarea {
    height: 76px;
    font-size: var(--text-caption);
  }
  .composer-top {
    gap: var(--space-8);
  }
  .composer-top .chat-attachment {
    font-size: var(--text-caption);
  }
  .builder-button {
    font-size: var(--text-caption);
    padding: var(--space-5) var(--space-8);
    min-height: 36px;
  }
  .composer-bottom {
    gap: var(--space-8);
  }
  .composer-bottom .quiet {
    max-width: 145px;
    line-height: 1.35;
  }
  .composer-bottom button {
    min-height: 42px;
    font-size: var(--text-caption);
    padding: var(--space-8) var(--space-12);
  }
  .chat-main .lesson-footer .quiet {
    display: none;
  }
  .chat-main .lesson-footer .back-button {
    min-height: 36px;
  }
  #prompt-dialog {
    padding: var(--space-18);
  }
  #prompt-dialog .choice {
    font-size: var(--text-caption);
    min-height: 44px;
  }
  #prompt-dialog .dialog-actions {
    bottom: -18px;
  }
  #prompt-dialog .dialog-actions button {
    width: 100%;
    min-height: 44px;
  }
}
@media (max-width: 1099px) and (max-height: 600px) {
  .chat-workspace {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }
  .chat-workspace .chat-window {
    height: 400px;
    flex: none;
  }
  .chat-workspace[data-tab='app'] {
    height: 100dvh;
  }
  .training-content {
    max-height: 160px;
  }
  .chat-workspace .tablet {
    max-width: 340px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .running .progress-dot,
  .typing-cursor,
  .streaming-answer {
    animation: none;
  }
  .artifact-card {
    transition: none;
  }
}

.chat-workspace .tablet .upload-button {
  position: static;
}
@media (min-width: 1100px) and (max-height: 740px) {
  .chat-workspace .tablet .chart {
    height: 120px;
  }
}

@media (max-width: 1099px) {
  .chat-workspace .tablet {
    max-width: 450px;
  }
  .chat-workspace .tablet .plan .value {
    font-size: 22px;
  }
}
@media (max-width: 380px) {
  .chat-workspace .tablet .plan .value {
    font-size: 19px;
  }
}

@media (max-width: 380px) {
  .chat-workspace .tablet .submetrics {
    grid-template-columns: minmax(0, 1fr) 74px;
    gap: var(--space-8);
  }
  .chat-workspace .tablet .donut {
    width: 74px;
    height: auto;
  }
  .chat-workspace .tablet .donut-label strong {
    font-size: 20px;
  }
  .chat-workspace .tablet .plan {
    padding: var(--space-10);
  }
}

/* Verification keeps its instructions and inputs together; only chat history scrolls. */
.chat-workspace.is-review {
  height: auto;
  min-height: 100dvh;
  overflow: visible;
}
.is-review > .learning-pane {
  min-height: 100dvh;
}
.is-review .training-content {
  max-height: none;
  overflow: visible;
  scrollbar-gutter: auto;
  padding: 0 var(--space-16) var(--space-16);
}
.is-review .review-instruction {
  font-size: var(--text-small);
  line-height: 1.5;
  margin: 0 0 var(--space-6);
}
.review-month {
  color: var(--muted);
  font-size: var(--text-caption);
  margin-bottom: var(--space-14) !important;
}
.review-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-20);
  align-items: start;
}
.review-grid .table-container,
.review-grid .verification,
.review-grid .growth-check {
  margin: 0;
}
.review-grid .table-title button,
.review-grid .table-title a.link {
  min-height: 30px;
  padding: var(--space-4) 0;
  font-size: var(--text-caption);
}
.review-grid .verification legend {
  font-size: var(--text-small);
  font-weight: var(--weight-bold);
  margin-bottom: var(--space-6);
}
.review-grid .answer-row {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-8);
  margin: var(--space-5) 0;
}
.review-formula {
  font-size: var(--text-caption);
  color: var(--muted);
  line-height: 1.4;
  margin-top: var(--space-8);
}
.is-review .training-content .action-row {
  margin-top: var(--space-14);
}
.is-review .lesson-footer {
  margin-top: auto;
  padding-top: var(--space-8);
}
@media (min-width: 1100px) {
  .is-review .result-pane {
    overflow: visible;
  }
  .is-review .result-sticky {
    position: sticky;
    top: 0;
    height: 100dvh;
    min-height: 0;
  }
}
@media (min-width: 1100px) and (max-width: 1249px) {
  .review-grid {
    grid-template-columns: 1fr;
  }
  .review-grid .verification {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-8);
  }
  .review-grid .answer-row {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
  }
  .review-formula {
    grid-column: 1/-1;
    margin-top: 0;
  }
}
@media (max-width: 1099px) {
  /* Задание шага теперь стоит в шапке панелью, а не в колонке чата: разбор проверки
     больше не растягивает страницу, и прокрутка остаётся только внутри переписки. */
  .chat-workspace.is-review[data-tab='chat'],
  .chat-workspace.is-review[data-tab='app'] {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }
  .is-review > .learning-pane {
    min-height: calc(100dvh - 58px);
  }
  .is-review .result-sticky {
    min-height: 100%;
  }
  .review-grid {
    gap: var(--space-16);
  }
}
@media (max-width: 719px) {
  .review-grid {
    grid-template-columns: 1fr;
    gap: var(--space-16);
  }
  .is-review .training-content {
    padding: 0 var(--space-12) var(--space-14);
  }
  .is-review .review-instruction {
    font-size: var(--text-small);
  }
  .is-review .training-content .action-row {
    justify-content: space-between;
    gap: var(--space-8);
  }
  .is-review .training-content .action-row button {
    min-height: 44px;
  }
  .is-review .training-content .data-table {
    font-size: var(--text-caption);
  }
  .is-review .training-content .answer-row {
    font-size: var(--text-caption);
  }
  .is-review .training-content .answer-row input {
    min-height: 40px;
  }
}

/* Branch feedback belongs to the lesson, separate from assistant messages. */
#prompt-dialog .optional-role {
  margin-bottom: var(--space-20);
}
#prompt-dialog .choices {
  align-items: stretch;
}
#prompt-dialog .choice {
  max-width: 100%;
  align-items: flex-start;
}
#prompt-dialog .choice input {
  flex-shrink: 0;
  margin-top: var(--space-2);
}
.attempt-review {
  display: grid;
  gap: var(--space-12);
}
.attempt-review > button {
  justify-self: start;
}
.learning-feedback {
  border-left: var(--rule-accent) solid var(--red);
  background: var(--chat-review-bg);
  padding: var(--space-14) var(--space-16);
  border-radius: 0 var(--radius-control) var(--radius-control) 0;
  font-size: var(--text-small);
  line-height: 1.5;
}
.learning-feedback strong {
  display: block;
  margin-bottom: var(--space-6);
}
.learning-feedback p + p {
  margin-top: var(--space-8);
}
.learning-feedback blockquote {
  margin: var(--space-12) 0 0;
  padding: var(--space-12);
  background: var(--surface);
  border: var(--border-hairline) solid var(--accent-soft-line);
  border-radius: var(--radius-5);
}
.repair-actions {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  flex-wrap: wrap;
}
.repair-actions button {
  min-height: 44px;
}
.update-check {
  display: grid;
  gap: var(--space-12);
  margin: var(--space-14) 0;
  max-width: 560px;
}
.update-check button {
  justify-self: start;
}
.update-check input {
  width: min(100%, 280px);
  min-height: 44px;
}
.demo-data {
  background: var(--warn-soft);
  border: var(--border-hairline) solid var(--warn-line);
  border-radius: var(--radius-8);
  padding: var(--space-12);
  font-size: var(--text-caption);
  margin-bottom: var(--space-12);
}
.demo-data strong {
  display: block;
  margin-bottom: var(--space-6);
}
.demo-data small {
  display: block;
  margin-top: var(--space-5);
  line-height: 1.4;
}
.fixed-month {
  font-size: var(--text-small);
  color: var(--ink-medium);
  align-self: center;
  white-space: nowrap;
}
@media (max-width: 719px) {
  .learning-feedback {
    font-size: var(--text-small);
    padding: var(--space-12);
  }
  .repair-actions button {
    width: 100%;
  }
  .attempt-review > button {
    width: 100%;
  }
}
.tablet .demo-data {
  grid-column: 1/-1;
  margin: 0;
}
@media (min-width: 900px) {
  .presentation .dashboard:has(.dataset-note) .chart {
    height: clamp(110px, calc(100dvh - 540px), 250px);
  }
}

/* Let the whole prompt use the space previously reserved for an empty transcript. */
.chat-workspace:not(.is-review) {
  height: auto;
  min-height: 100dvh;
  overflow: visible;
}
.chat-main > .chat-window {
  flex: none;
}
.chat-composer textarea,
.chat-composer textarea:placeholder-shown {
  height: auto;
  max-height: none;
  min-height: 52px;
  overflow: hidden;
  font-size: var(--text-body);
  line-height: 1.5;
  padding: var(--space-11) var(--space-12);
}
.chat-message {
  font-size: var(--text-body);
  line-height: 1.6;
}
.message-author {
  font-size: var(--text-caption);
}
.chat-heading h2 {
  font-size: var(--text-body);
}
.chat-heading div > span,
.chat-heading-status {
  font-size: var(--text-caption);
}
.chat-attachment,
.composer-top .chat-attachment {
  font-size: var(--text-caption);
}
.builder-button {
  font-size: var(--text-small);
  min-height: 44px;
  padding: var(--space-8) var(--space-12);
}
.composer-bottom button {
  font-size: var(--text-small);
  min-height: 44px;
}
.composer-bottom .quiet,
.composer-note {
  font-size: var(--text-caption);
}
.artifact-card strong {
  font-size: var(--text-body);
}
.artifact-card small,
.artifact-link {
  font-size: var(--text-small);
}
.ai-progress {
  font-size: var(--text-body);
}
.progress-dot {
  width: 18px;
  height: 18px;
}
.progress-dot svg {
  width: 13px;
  height: 13px;
}
.learning-feedback h2 {
  font-family: inherit;
  font-size: var(--text-lead);
  line-height: 1.4;
  margin: var(--space-5) 0 var(--space-10);
}
.review-verdict {
  display: block;
  color: var(--red);
  font-size: var(--text-caption);
  font-weight: var(--weight-bold);
}
.request-excerpt {
  padding: var(--space-9) var(--space-11);
  background: var(--surface);
  border: var(--border-hairline) solid var(--accent-line);
  border-radius: var(--radius-5);
  margin-bottom: var(--space-10);
}
.repair-hint {
  padding: var(--space-12);
  background: var(--paper);
  border-radius: var(--radius-5);
  font-size: var(--text-small);
  line-height: 1.5;
}
.repair-hint blockquote {
  margin: var(--space-10) 0 0;
  padding: var(--space-10);
  background: var(--surface);
  border: var(--border-hairline) solid var(--border);
  border-radius: var(--radius-5);
}
@media (max-width: 1099px) {
  .chat-workspace:not(.is-review)[data-tab='app'] {
    height: 100dvh;
    overflow: hidden;
  }
}
@media (max-width: 720px) {
  .chat-message {
    font-size: var(--text-body);
  }
  .composer-bottom .quiet {
    max-width: none;
    flex: 1;
  }
  .composer-bottom {
    align-items: center;
  }
  .learning-feedback h2 {
    font-size: var(--text-body);
  }
  .chat-composer .composer-top .chat-attachment {
    font-size: var(--text-caption);
  }
  .builder-button {
    font-size: var(--text-small);
  }
}
@media (min-width: 1100px) {
  .chat-workspace {
    padding-bottom: 0;
  }
  .chat-workspace:not(.is-review) .result-pane {
    overflow: visible;
  }
  .chat-workspace:not(.is-review) .result-sticky {
    position: sticky;
    top: 0;
    height: 100dvh;
    min-height: 0;
  }
}
@media (max-width: 1099px) {
  html {
    scroll-padding-bottom: 74px;
  }
  .chat-main button {
    scroll-margin-block: 74px;
  }
}

/* Разбор попытки живёт рамкой в переписке, отдельного экрана у него нет.
   Внутренние карточки пришли с доски: они остаются, но читаются внутри чата. */
.board-report.learning-feedback {
  display: contents;
  background: none;
  border: 0;
  border-radius: 0;
  padding: 0;
  color: inherit;
  font-size: var(--text-body);
}
.board-kicker {
  font-size: var(--text-caption);
  color: var(--gold-light);
  margin-bottom: var(--space-8);
}
.board-report h1 {
  font-size: var(--text-title);
  line-height: 1.1;
  color: var(--surface);
  margin: 0 0 var(--space-32);
  max-width: 1100px;
}
.board-card {
  position: relative;
  min-width: 0;
  padding: var(--space-32) var(--space-24) var(--space-24);
  background: var(--board-bg);
  color: var(--board-ink);
  border: var(--border-width) solid var(--border-strong);
  box-shadow: 5px 5px 0 var(--tablet-bg);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-20);
}
.board-label {
  align-self: flex-start;
  background: var(--red);
  color: var(--surface);
  font-weight: var(--weight-bold);
  font-size: var(--text-caption);
  padding: var(--space-6) var(--space-10);
  transform: rotate(-2deg);
  margin-top: -46px;
  margin-bottom: var(--space-4);
}.board-report .board-card h2 {
  font-size: var(--text-title);
  line-height: 1.08;
  margin: 0;
  font-family: var(--font-title);
}
.board-report .board-card p {
  margin: 0;
  font-size: var(--text-body);
  line-height: 1.45;
}
.board-comparison {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 26px minmax(0, 1fr);
  gap: var(--space-10);
  align-items: center;
  margin: var(--space-15) 0;
}
.board-comparison > div {
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
}
.board-comparison span,
.board-cause span {
  font-size: var(--text-caption);
  line-height: 1.3;
  color: var(--ink-medium);
}
.board-comparison strong {
  font-size: var(--text-lead);
  line-height: 1.2;
  white-space: nowrap;
  margin: 0;
  font-variant-numeric: tabular-nums;
}
.board-comparison b {
  font-size: var(--text-display);
  line-height: 1;
  color: var(--positive-dark);
}
.board-comparison .wrong-number {
  color: var(--red);
}
.board-comparison .comparison-sign {
  font-size: var(--text-title);
  color: var(--accent-muted);
  text-align: center;
}
.board-cause {
  display: grid;
  gap: var(--space-22);
  margin: var(--space-10) 0;
}
.board-cause > div {
  border-left: 3px solid var(--rose);
  padding-left: var(--space-14);
  display: grid;
  gap: var(--space-8);
}
.board-cause strong {
  font-size: var(--text-lead);
  line-height: 1.15;
  margin: 0;
}
.board-symbol {
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  border: 2px solid var(--accent-strong);
  border-radius: var(--radius-round);
  color: var(--accent-strong);
  width: 64px;
  height: 64px;
  font-size: var(--text-display);
  font-weight: var(--weight-bold);
}
.board-details {
  margin-top: auto;
  padding-top: var(--space-12);
  border-top: var(--border-width) solid var(--border);
}
.board-details summary {
  cursor: pointer;
  min-height: 44px;
  font-size: var(--text-small);
  font-weight: var(--weight-bold);
  padding: var(--space-10) 0;
}
.board-report .board-details p {
  font-size: var(--text-body);
  line-height: 1.5;
  margin-top: var(--space-8);
}
.board-next {
  background: var(--paper-deep);
}
.board-next > .primary {
  margin-top: auto;
  min-height: 52px;
  width: 100%;
  font-size: var(--text-body);
  padding: var(--space-12);
}
.board-checklist {
  display: grid;
  gap: var(--space-12);
  font-size: var(--text-body);
  line-height: 1.35;
}
.board-target {
  font-weight: 700;
  border-top: 1px solid var(--board-line);
  padding-top: var(--space-16);
}
.board-report .board-note {
  font-size: 16px;
  color: var(--board-note);
  margin-top: var(--space-26);
}
.board-hints {
  display: flex;
  align-items: start;
  gap: var(--space-16);
  margin-top: var(--space-28);
}
.board-hints .repair-hint {
  max-width: 750px;
  color: var(--board-ink);
  font-size: var(--text-body);
}
.retest-note {
  padding: var(--space-16);
  border: var(--border-hairline) solid var(--positive-pale);
  background: var(--positive-bg);
  margin-bottom: var(--space-16);
  border-radius: var(--radius-control);
  font-size: var(--text-body);
}
.retest-note p {
  margin-top: var(--space-8);
}
@media (max-width: 1099px) {
  .board-evidence {
    grid-column: 1/-1;
  }
  .board-comparison {
    max-width: 540px;
    margin: var(--space-10) auto;
    width: 100%;
  }
  .board-report h1 {
    font-size: var(--text-title);
  }
}
@media (max-width: 600px) {
  .board-card {
    padding: var(--space-26) var(--space-18) var(--space-20);
  }
  .board-label {
    margin-top: -40px;
  }
  .board-report h1 {
    font-size: var(--text-title);
    margin-bottom: var(--space-32);
  }
  .board-report .board-card h2 {
    font-size: var(--text-title);
  }
  .board-comparison {
    gap: var(--space-6);
    grid-template-columns: minmax(0, 1fr) 20px minmax(0, 1fr);
  }
  .board-comparison strong {
    font-size: var(--text-lead);
  }
  .board-comparison b {
    font-size: var(--text-display);
  }
  .board-comparison span {
    font-size: var(--text-caption);
  }
  .board-hints {
    flex-direction: column;
  }
  .board-report .board-card p {
    font-size: var(--text-body);
  }
}
@media (min-width: 1100px) and (max-height: 740px) {
  .board-report h1 {
    font-size: var(--text-title);
    margin-bottom: var(--space-26);
  }
  .board-card {
    padding: var(--space-24) var(--space-20) var(--space-18);
    gap: var(--space-14);
  }
  .board-label {
    margin-top: -38px;
  }
  .board-comparison {
    margin: var(--space-8) 0;
  }
  .board-report .board-card h2 {
    font-size: var(--text-lead);
  }
  .board-symbol {
    width: 50px;
    height: 50px;
    font-size: var(--text-title);
  }
  .board-checklist {
    gap: var(--space-8);
  }
  .board-report .board-note {
    margin-top: var(--space-18);
  }
}
.review-error {
  outline: 3px solid var(--focus-ring-warn) !important;
  outline-offset: 3px;
  background-color: var(--accent-soft) !important;
  border-radius: var(--radius-md);
}
.error-label {
  display: block;
  font-family: var(--font-body);
  font-size: var(--text-caption);
  font-weight: var(--weight-bold);
  line-height: 1.3;
  color: var(--accent-deep);
  white-space: normal;
  margin-bottom: var(--space-7);
}
.missing-feature,
.error-callout {
  padding: var(--space-16);
  margin: var(--space-16) 0 var(--space-5);
  font-size: var(--text-small);
  line-height: 1.5;
  color: var(--accent-deep);
  font-weight: var(--weight-bold);
}
.review-unbuilt {
  display: block !important;
  min-height: 280px !important;
}
.review-unbuilt h2 {
  font-size: var(--text-title);
  line-height: 1.1;
  margin-bottom: var(--space-24);
}

/* Choices and their live result have independent scrolling within one dialog. */
#prompt-dialog {
  width: min(1260px, calc(100vw - 32px));
  max-width: calc(100vw - 24px);
  height: min(820px, 94dvh);
  max-height: 94dvh;
  padding: var(--space-24);
  overflow: hidden;
}
#prompt-dialog[open] {
  display: flex;
  flex-direction: column;
  gap: var(--space-18);
}
#prompt-dialog .builder-heading {
  flex: none;
  margin: 0;
}
#prompt-dialog .builder-heading h2 {
  font-size: var(--text-title);
}
#prompt-dialog .builder-heading button {
  min-height: 44px;
  font-size: var(--text-small);
}
.builder-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
  gap: var(--space-24);
  min-height: 0;
  flex: 1;
}
.builder-options {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  scrollbar-gutter: stable;
  padding: var(--space-2) var(--space-16) var(--space-12) var(--space-2);
}
.builder-options > .quiet {
  font-size: var(--text-body);
  line-height: 1.5;
  margin: 0 0 var(--space-22);
}
#prompt-dialog .controls legend {
  font-size: var(--text-body);
  margin-bottom: var(--space-12);
}
#prompt-dialog .choice {
  font-size: var(--text-body);
  line-height: 1.4;
  min-height: 44px;
}
.builder-preview {
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
  min-width: 0;
  min-height: 0;
  border-left: var(--border-hairline) solid var(--border);
  padding-left: var(--space-24);
}
.builder-output {
  overflow: auto;
  min-height: 0;
  flex: 1;
  scrollbar-gutter: stable;
}
#prompt-dialog .prompt-card {
  padding: var(--space-20);
  min-height: 100%;
  margin: 0;
  border-radius: var(--radius-8);
}
#prompt-dialog .prompt-text {
  font-size: var(--text-body);
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
#prompt-dialog .prompt-title {
  font-size: var(--text-caption);
  margin-bottom: var(--space-20);
}
#prompt-dialog .dialog-actions {
  position: static;
  flex: none;
  margin: 0;
  padding: 0;
  background: none;
}
#prompt-dialog .dialog-actions button {
  width: 100%;
  min-height: 48px;
  font-size: var(--text-body);
}
@media (max-width: 699px) {
  #prompt-dialog {
    height: 96dvh;
    max-height: 96dvh;
    padding: var(--space-14);
  }
  #prompt-dialog[open] {
    gap: var(--space-12);
  }
  #prompt-dialog .builder-heading h2 {
    font-size: var(--text-title);
  }
  .builder-columns {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--space-12);
  }
  .builder-options {
    padding-right: var(--space-6);
  }
  .builder-preview {
    padding: var(--space-12) 0 0;
    border-left: 0;
    border-top: var(--border-hairline) solid var(--border-soft);
    gap: var(--space-8);
  }
  #prompt-dialog .controls legend {
    font-size: var(--text-body);
  }
  #prompt-dialog .choice {
    font-size: var(--text-small);
  }
  #prompt-dialog .prompt-card {
    padding: var(--space-14);
  }
  #prompt-dialog .prompt-text {
    font-size: var(--text-body);
    line-height: 1.5;
  }
  #prompt-dialog .prompt-title {
    margin-bottom: var(--space-12);
  }
  .builder-options > .quiet {
    font-size: var(--text-small);
  }
}
@media (max-height: 450px) and (min-width: 700px) {
  #prompt-dialog {
    padding: var(--space-12);
  }
  #prompt-dialog[open] {
    gap: var(--space-8);
  }
  #prompt-dialog .builder-heading h2 {
    font-size: var(--text-title);
  }
  .builder-columns {
    gap: var(--space-14);
  }
  .builder-preview {
    padding-left: var(--space-14);
  }
  #prompt-dialog .prompt-card {
    padding: var(--space-14);
  }
}

.repair-guide {
  border: var(--border-hairline) solid var(--warn-line);
  border-left: var(--rule-accent) solid var(--accent-deep);
  border-radius: var(--radius-8);
  background: var(--warn-soft);
  padding: var(--space-16);
  margin: 0 0 var(--space-22);
  display: grid;
  gap: var(--space-10);
}
.guide-label {
  font-size: var(--text-caption);
  font-weight: var(--weight-bold);
  color: var(--ink-medium);
}
.repair-guide > strong {
  font-size: var(--text-lead);
}
.repair-guide p {
  font-size: var(--text-body);
  line-height: 1.5;
  margin: 0;
}
.repair-guide .quiet {
  font-size: var(--text-small);
}
.repair-guide.ready {
  background: var(--positive-bg);
  border-color: var(--positive);
}
.resolved {
  color: var(--positive-dark);
}
.repair-guide summary {
  cursor: pointer;
  font-size: var(--text-small);
  font-weight: var(--weight-bold);
  min-height: 32px;
}
.repair-guide ul {
  padding-left: var(--space-20);
  font-size: var(--text-small);
  line-height: 1.5;
}
.effective-prompt {
  border-top: var(--border-hairline) solid var(--overlay-strong);
  margin-top: var(--space-20);
  padding-top: var(--space-14);
}
.effective-prompt summary {
  cursor: pointer;
  font-size: var(--text-body);
  min-height: 40px;
}
.effective-prompt p {
  white-space: pre-line;
  font-size: var(--text-body);
  line-height: 1.6;
  margin: var(--space-10) 0 0;
}

/* The device belongs to the viewport, not to the amount of application content. */
:root {
  --tablet-width: min(600px, calc(33.333vw - 44px), calc((100dvh - 132px) * 0.7225));
}
.workspace .tablet {
  position: relative;
  display: block;
  width: var(--tablet-width);
  height: auto;
  aspect-ratio: 578/800;
  min-height: 0;
  max-height: none;
  max-width: none;
  flex: none;
  margin: 0 auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  overflow: visible;
  scrollbar-gutter: auto;
}
.tablet-frame {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
  user-select: none;
}
.tablet-screen {
  position: absolute;
  left: 5.19%;
  right: 5.19%;
  top: 3.75%;
  bottom: 3.75%;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--screen-bg);
  border-radius: 2%;
  scrollbar-width: thin;
  container: tablet-content / inline-size;
}
.tablet-screen:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: -4px;
}
.tablet .tablet-screen > .dashboard {
  min-height: 100%;
  max-height: none;
  height: auto;
  overflow: visible;
  border-radius: 0;
}
.tablet .tablet-screen > .review-unbuilt {
  min-height: 100% !important;
  padding: var(--space-18);
}
.tablet .review-unbuilt h2 {
  font-size: 26px;
}
.tablet .review-unbuilt .error-callout {
  padding: 0;
  margin-top: var(--space-24);
}
.workspace .result-title {
  min-height: 46px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.workspace .result-sticky {
  align-items: center;
  gap: var(--space-12);
}
.draft-problem {
  padding: var(--space-10) var(--space-12);
  margin-top: var(--space-10);
  border-left: var(--rule-accent) solid var(--red);
  background: var(--warn-soft);
  font-size: var(--text-small);
  line-height: 1.5;
}
@media (min-width: 700px) and (max-width: 1099px) {
  :root {
    --tablet-width: min(310px, calc((100dvh - 150px) * 0.7225));
  }
}
@media (max-width: 699px) {
  :root {
    --tablet-width: min(340px, calc(100vw - 32px), calc((100dvh - 150px) * 0.7225));
  }
  .workspace .result-title {
    font-size: var(--text-body);
  }
}
@container tablet-content (max-width:310px) {
  .tablet .dashboard:not(.dash-empty) {
    display: flex;
    flex-direction: column;
    gap: var(--space-10);
    padding: var(--space-12);
  }
  .tablet .dashboard .submetrics {
    display: flex;
    flex-direction: column;
    gap: var(--space-10);
    align-items: stretch;
    margin: 0;
  }
  .tablet .dashboard .donut {
    width: 78px;
    align-self: center;
  }
  .tablet .dashboard .dash-head {
    flex-wrap: wrap;
  }
  .tablet .dash-head h2 {
    font-size: 24px;
  }
  .tablet .dashboard .kpi .value {
    font-size: clamp(18px, 8cqw, 26px);
    white-space: normal;
  }
  .tablet .dashboard .plan .value {
    font-size: clamp(16px, 7cqw, 21px);
  }
  .tablet .month-control {
    width: 100%;
    min-width: 0;
  }
  .tablet .dash-head .month-control select {
    width: 100%;
    min-width: 0;
  }
  .tablet .dashboard .kpi.deals {
    flex-wrap: wrap;
    gap: var(--space-4);
  }
  .tablet .dashboard .comparison {
    flex-wrap: wrap;
    gap: var(--space-5);
  }
  .tablet .dashboard .chart {
    height: 140px;
    flex: none;
    padding-left: var(--space-12);
  }
  .tablet .review-unbuilt h2 {
    font-size: 23px;
  }
  .tablet .review-unbuilt .error-callout {
    font-size: 13px;
  }
  .tablet .dash-empty h3 {
    font-size: 20px;
  }
  .tablet .dash-empty {
    padding: var(--space-20) var(--space-10);
  }
}

/* Application design: shared by the device, the debrief and the presentation. */
.dashboard {
  --app-ink: var(--ink-deep);
  --app-muted: var(--ink-medium);
  --app-accent: var(--accent-strong);
  background: var(--surface-tint);
  color: var(--app-ink);
}
.dashboard .dash-head {
  align-items: center;
}
.dashboard .dash-head h2 {
  font-family: var(--font-body);
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--app-ink);
}
.dashboard .dash-head p {
  display: inline-block;
  color: var(--accent-muted);
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-line);
  border-radius: var(--radius-control);
  padding: var(--space-4) var(--space-7);
  font-size: 11px;
  line-height: 1.3;
}
.dashboard .month-control {
  color: var(--app-ink);
}
.dashboard .month-control select {
  min-height: 44px;
  border: 1px solid var(--accent-soft-line);
  background: var(--surface);
  color: var(--app-ink);
  border-radius: var(--radius-lg);
  padding: var(--space-10) var(--space-32) var(--space-10) var(--space-12);
  font-size: 13px;
  cursor: pointer;
}
.dashboard .kpi {
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-14);
  background: var(--surface);
  box-shadow: 0 2px 0 var(--kpi-shadow);
}
.dashboard .kpi h3 {
  color: var(--kpi-label);
  font-weight: 400;
}
.dashboard .kpi .value {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.035em;
  line-height: 1.15;
  color: var(--app-ink);
}
.dashboard .revenue {
  border-left: 4px solid var(--app-accent);
}
.dashboard .revenue .value {
  color: var(--accent-deep);
}
.dashboard .donut-caption {
  color: var(--kpi-label);
  line-height: 1.4;
  font-size: 12px;
}
.dashboard .donut-label strong {
  color: var(--app-ink);
}
.dashboard .comparison {
  background: var(--positive-bg);
  border: 1px solid var(--positive-pale);
  border-radius: var(--radius-12);
  color: var(--positive-dark);
}
.dashboard .comparison strong,
.dashboard .comparison small {
  color: var(--positive-dark);
}
.dashboard .comparison.missing {
  background: var(--paper-deep);
  border-color: var(--border);
  color: var(--ink-medium);
}
.dashboard .chart-panel {
  grid-column: 1/-1;
  min-width: 0;
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-14);
  background: var(--surface);
  padding: var(--space-14) var(--space-12) var(--space-8);
}
.dashboard .chart-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-8);
  margin: 0;
}
.dashboard .chart-title h3 {
  font-size: 14px;
  color: var(--app-ink);
}
.dashboard .chart-title small {
  color: var(--app-muted);
  white-space: nowrap;
  font-size: 11px;
}
.dashboard .chart {
  height: 180px;
  margin: 0;
}
.dashboard .upload-button {
  min-height: 44px;
  border: 1px solid var(--accent-deep);
  background: var(--accent-strong);
  color: var(--surface);
  border-radius: var(--radius-lg);
  font-size: 13px;
  transition:
    background-color 0.2s,
    border-color 0.2s;
}
.dashboard .upload-button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}
.dashboard .dataset-note {
  color: var(--positive-dark);
  font-size: 12px;
}
.dashboard .fixed-month {
  padding: var(--space-10) var(--space-12);
  border: 1px solid var(--accent-soft-line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--kpi-label);
  font-size: 13px;
}
.tablet-screen {
  background: var(--surface-tint);
}
.workspace .result-title {
  font-size: var(--text-title);
  line-height: 1.15;
  min-height: 54px;
  width: 100%;
  margin: 0;
  text-wrap: balance;
}
.workspace .preview-version {
  font-size: var(--text-small);
  color: var(--accent-soft-line);
  margin-top: var(--space-8);
  line-height: 1.3;
}
.workspace .result-sticky {
  padding: var(--space-16);
  gap: var(--space-12);
}
.tablet .tablet-screen > .dashboard:not(.dash-empty):not(.review-unbuilt) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(80px, 23cqw, 128px);
  gap: var(--space-12);
  padding: clamp(var(--space-12), 4cqw, var(--space-24));
  align-content: start;
}
.tablet .dashboard .dash-head {
  gap: var(--space-8);
  margin: 0 0 var(--space-6);
  flex-wrap: nowrap;
}
.tablet .dashboard .dash-head h2 {
  font-size: clamp(24px, 6.6cqw, 36px);
}
.tablet .dashboard .dash-head p {
  font-size: 11px;
  margin-top: var(--space-6);
}
.tablet .dashboard .month-control {
  width: auto;
  min-width: 0;
}
.tablet .dashboard .month-control select {
  font-size: 13px;
  min-height: 44px;
  width: 128px;
  min-width: 0;
}
.tablet .dashboard .kpi {
  padding: clamp(var(--space-12), 3.5cqw, var(--space-20));
  border-radius: var(--radius-14);
}
.tablet .dashboard .kpi h3 {
  font-size: 13px;
  line-height: 1.4;
  margin-bottom: var(--space-8);
}
.tablet .dashboard .kpi .value {
  font-size: clamp(24px, 8cqw, 44px);
  white-space: nowrap;
}
.tablet .dashboard .submetrics {
  display: contents;
}
.tablet .dashboard .plan .value {
  font-size: clamp(20px, 6cqw, 32px);
}
.tablet .dashboard .donut {
  width: 100%;
  height: auto;
  align-self: center;
  justify-self: center;
}
.tablet .dashboard .donut-label strong {
  font-size: clamp(22px, 6.5cqw, 34px);
}
.tablet .dashboard .donut-caption {
  font-size: 12px;
}
.tablet .dashboard .kpi.deals {
  padding: var(--space-12) var(--space-16);
  min-height: 52px;
  align-items: center;
}
.tablet .dashboard .kpi.deals h3 {
  margin: 0;
}
.tablet .dashboard .kpi.deals .value {
  font-size: 28px;
}
.tablet .dashboard .chart-title {
  margin: 0;
}
.tablet .dashboard .chart-title h3 {
  font-size: 14px;
}
.tablet .dashboard .chart-title small {
  font-size: 11px;
}
.tablet .dashboard .chart {
  height: clamp(145px, 43cqw, 220px);
  padding-left: 0;
}
.tablet .dashboard .upload-button {
  position: static;
  font-size: 13px;
  min-height: 44px;
  margin: 0;
}
.tablet .dashboard .comparison {
  padding: var(--space-12);
  gap: var(--space-10);
}
.tablet .dashboard .comparison strong {
  font-size: 26px;
}
.tablet .dashboard .comparison p {
  font-size: 12px;
}
.tablet .dashboard .comparison small {
  font-size: 11px;
}
.tablet .dashboard .demo-data {
  padding: var(--space-14);
}
.tablet .dashboard.dash-empty {
  background: var(--surface-tint);
}
.tablet .dash-empty .empty-chart {
  border-color: var(--accent-soft-line);
  border-radius: var(--radius-12);
  background: var(--surface);
}
.tablet .dash-empty .empty-chart i {
  background: var(--accent-soft-line);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.tablet .dash-empty .empty-chart i:last-child {
  background: var(--accent-strong);
}
.tablet .dash-empty p {
  color: var(--accent-muted);
}
.presentation .dashboard {
  max-width: 1120px;
  border-color: var(--accent-line);
  border-radius: 18px;
  box-shadow: 0 4px 0 var(--kpi-shadow);
}
.presentation .dashboard .chart-panel {
  grid-column: 1/-1;
}
.presentation .dashboard .chart {
  height: clamp(150px, 30dvh, 300px);
}
@container tablet-content (max-width:310px) {
  .tablet .tablet-screen > .dashboard:not(.dash-empty):not(.review-unbuilt) {
    display: flex;
    flex-direction: column;
    gap: var(--space-12);
    padding: var(--space-14);
  }
  .tablet .dashboard .dash-head {
    flex-wrap: wrap;
  }
  .tablet .dashboard .month-control,
  .tablet .dashboard .month-control select {
    width: 100%;
  }
  .tablet .dashboard .submetrics {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 88px;
    gap: var(--space-10);
    align-items: center;
    margin: 0;
  }
  .tablet .dashboard .submetrics .plan {
    grid-column: 1;
    grid-row: auto;
    padding: var(--space-12) var(--space-10);
  }
  .tablet .dashboard .submetrics .donut {
    grid-column: 2;
    grid-row: auto;
    width: 88px;
  }
  .tablet .dashboard .kpi .value {
    font-size: clamp(24px, 10cqw, 34px);
  }
  .tablet .dashboard .plan .value {
    font-size: clamp(17px, 6.5cqw, 22px);
    white-space: normal;
  }
  .tablet .dashboard .donut-label strong {
    font-size: 24px;
  }
  .tablet .dashboard .chart-panel {
    padding: var(--space-12) var(--space-8) var(--space-6);
  }
  .tablet .dashboard .chart {
    height: 160px;
    padding-left: var(--space-12);
  }
}
@media (max-width: 699px) {
  .workspace .result-title {
    font-size: var(--text-lead);
    min-height: 46px;
  }
  .workspace .preview-version {
    font-size: var(--text-caption);
  }
  .workspace .result-sticky {
    padding: var(--space-12);
  }
}
@media (prefers-reduced-motion: reduce) {
  .dashboard .upload-button {
    transition: none;
  }
}
@container tablet-content (max-width:240px) {
  .tablet .tablet-screen > .dashboard:not(.dash-empty):not(.review-unbuilt) {
    padding: var(--space-10);
    gap: var(--space-10);
  }
  .tablet .dashboard .submetrics {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }
  .tablet .dashboard .submetrics .donut {
    align-self: center;
  }
  .tablet .dashboard .kpi {
    padding: var(--space-10) var(--space-8);
  }
  .tablet .dashboard .kpi .value,
  .tablet .dashboard .plan .value {
    font-size: 18px;
    white-space: normal;
  }
  .tablet .dashboard .kpi.deals {
    padding: var(--space-10) var(--space-8);
  }
  .tablet .dashboard .chart-title {
    flex-wrap: wrap;
  }
  .tablet .dashboard .upload-button {
    padding: var(--space-10) var(--space-6);
    flex-wrap: wrap;
  }
}
@media (min-width: 900px) and (max-height: 850px) {
  .presentation .dashboard {
    padding: var(--space-16);
    gap: var(--space-10);
  }
  .presentation .dashboard .chart-panel {
    padding: var(--space-10) var(--space-12) var(--space-4);
  }
  .presentation .dashboard .chart {
    height: clamp(110px, calc(100dvh - 550px), 250px);
  }
  .presentation .dashboard:has(.dataset-note) .chart {
    height: clamp(100px, calc(100dvh - 560px), 250px);
  }
}

/* Fit the content, not just the device: the chart gets the remaining height. */
.metrics-grid {
  display: contents;
}
:root {
  --tablet-width: min(600px, calc(33.333vw - 44px));
  --tablet-height: min(calc(var(--tablet-width) * 1.6), calc(100dvh - 104px));
}
.workspace .tablet {
  height: var(--tablet-height);
  aspect-ratio: auto;
}
.tablet-screen {
  container: tablet-content / size;
}
.tablet .tablet-screen > .dashboard:not(.dash-empty):not(.review-unbuilt) {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding: clamp(var(--space-8), 2cqh, var(--space-20));
  gap: clamp(var(--space-4), 1cqh, var(--space-10));
}
.tablet .dashboard > * {
  flex-shrink: 0;
  min-width: 0;
}
.tablet .dashboard .dash-head {
  flex-wrap: nowrap;
  margin: 0;
  gap: var(--space-6);
}
.tablet .dashboard .dash-head h2 {
  font-size: clamp(22px, 4.5cqh, 36px);
}
.tablet .dashboard .dash-head p {
  font-size: 11px;
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-5);
}
.tablet .dashboard .month-control,
.tablet .dashboard .month-control select {
  width: 116px;
}
.tablet .dashboard .metrics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(72px, 20cqw, 116px);
  gap: clamp(var(--space-5), 1.2cqh, var(--space-12));
  align-items: center;
}
.tablet .dashboard .submetrics {
  display: contents;
}
.tablet .dashboard .metrics-grid > .kpi {
  grid-column: 1;
  grid-row: 1;
}
.tablet .dashboard .metrics-grid .plan {
  grid-column: 1;
  grid-row: 2;
}
.tablet .dashboard .metrics-grid .donut {
  grid-column: 2;
  grid-row: 1 / span 2;
  width: 100%;
  justify-self: center;
  align-self: center;
  gap: var(--space-5);
}
.tablet .dashboard .kpi {
  padding: clamp(var(--space-6), 1.5cqh, var(--space-16));
  border-radius: var(--radius-lg);
}
.tablet .dashboard .kpi h3 {
  font-size: 12px;
  line-height: 1.2;
  margin-bottom: var(--space-3);
}
.tablet .dashboard .kpi .value {
  font-size: clamp(23px, 4.8cqh, 40px);
  white-space: nowrap;
  line-height: 1.1;
}
.tablet .dashboard .plan .value {
  font-size: clamp(20px, 4cqh, 32px);
}
.tablet .dashboard .donut-label strong {
  font-size: clamp(22px, 6cqw, 32px);
}
.tablet .dashboard .donut-caption {
  font-size: 11px;
  line-height: 1.2;
}
.tablet .dashboard .kpi.deals {
  padding: var(--space-5) var(--space-10);
  min-height: 32px;
  flex-wrap: nowrap;
  margin: 0;
}
.tablet .dashboard .kpi.deals .value {
  font-size: 24px;
}
.tablet .dashboard .comparison {
  padding: var(--space-6) var(--space-9);
  gap: var(--space-8);
  margin: 0;
  flex-wrap: nowrap;
}
.tablet .dashboard .comparison strong {
  font-size: 23px;
}
.tablet .dashboard .comparison p {
  font-size: 11px;
  line-height: 1.3;
}
.tablet .dashboard .comparison small {
  font-size: 10px;
  margin-top: var(--space-2);
}
.tablet .dashboard .chart-panel {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 94px;
  padding: var(--space-8) var(--space-8) var(--space-4);
}
.tablet .dashboard .chart-title {
  flex: none;
  flex-wrap: nowrap;
}
.tablet .dashboard .chart-title h3 {
  font-size: 12px;
}
.tablet .dashboard .chart-title small {
  font-size: 10px;
}
.tablet .dashboard .chart {
  flex: 1 1 0;
  min-height: 68px;
  height: 0;
  width: 100%;
  padding: 0;
}
.tablet .dashboard .upload-button {
  min-height: 44px;
  height: 44px;
  padding: var(--space-6);
  font-size: 13px;
  flex-wrap: nowrap;
}
.tablet .dashboard .dataset-note {
  font-size: 10px;
  line-height: 1.3;
  margin: 0;
}
.tablet .dashboard .demo-data {
  padding: var(--space-7) var(--space-9);
  margin: 0;
  font-size: 12px;
  line-height: 1.3;
}
.tablet .dashboard .demo-data p {
  margin: var(--space-4) 0;
  font-size: 12px;
}
.tablet .dashboard .demo-data small {
  font-size: 11px;
}
.tablet .dashboard .error-label {
  font-size: 10px;
  margin-bottom: var(--space-3);
}
.tablet .dashboard .missing-feature {
  margin: 0;
  padding: var(--space-7);
  font-size: 12px;
  line-height: 1.3;
}
@media (min-width: 700px) and (max-width: 1099px) {
  :root {
    --tablet-width: clamp(320px, calc(100vw - 408px), 440px);
    --tablet-height: min(704px, calc(100dvh - 150px));
  }
}
@media (max-width: 699px) {
  :root {
    --tablet-width: calc(100vw - 32px);
    --tablet-height: calc(100dvh - 150px);
  }
}
@container tablet-content (max-width:300px) {
  .tablet .dashboard .dash-head {
    flex-wrap: wrap;
  }
  .tablet .dashboard .dash-head > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-6);
    width: 100%;
  }
  .tablet .dashboard .dash-head p {
    font-size: 10px;
    white-space: nowrap;
  }
  .tablet .dashboard .month-control,
  .tablet .dashboard .month-control select {
    width: 100%;
  }
  .tablet .dashboard .metrics-grid {
    grid-template-columns: minmax(0, 1fr) 72px;
  }
  .tablet .dashboard .kpi .value {
    font-size: 23px;
  }
  .tablet .dashboard .plan .value {
    font-size: 19px;
  }
}
@media (max-height: 600px) and (min-width: 700px) and (max-width: 1099px) {
  :root {
    --tablet-width: min(720px, calc(100vw - 48px));
    --tablet-height: calc(100dvh - 104px);
  }
  .workspace .result-title {
    min-height: 30px;
    font-size: var(--text-lead);
    flex-direction: row;
    align-items: center;
    gap: var(--space-8);
  }
  .workspace .preview-version {
    margin: 0;
  }
  .workspace .result-sticky {
    padding: var(--space-8);
    gap: var(--space-6);
  }
  .tablet .tablet-screen > .dashboard:not(.dash-empty):not(.review-unbuilt) {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 44px minmax(0, 1fr) auto 44px auto;
    gap: var(--space-4);
    padding: var(--space-6);
  }
  .tablet .dashboard .dash-head {
    grid-column: 1;
    grid-row: 1;
  }
  .tablet .dashboard .dash-head > div {
    display: flex;
    align-items: center;
    gap: var(--space-4);
  }
  .tablet .dashboard .dash-head p {
    display: block;
    font-size: 9px;
    margin: 0;
  }
  .tablet .dashboard .dash-head h2 {
    font-size: 20px;
  }
  .tablet .dashboard .metrics-grid {
    grid-column: 1;
    grid-row: 2 / span 2;
    grid-template-columns: 1fr 70px;
    gap: var(--space-4);
  }
  .tablet .dashboard .kpi {
    padding: var(--space-4) var(--space-6);
  }
  .tablet .dashboard .kpi .value {
    font-size: 22px;
  }
  .tablet .dashboard .plan .value {
    font-size: 19px;
  }
  .tablet .dashboard .donut-label strong {
    font-size: 22px;
  }
  .tablet .dashboard .chart-panel {
    grid-column: 2;
    grid-row: 1 / span 2;
    min-height: 0;
  }
  .tablet .dashboard .upload-button {
    grid-column: 2;
    grid-row: 4;
  }
  .tablet .dashboard .kpi.deals {
    grid-column: 1;
    grid-row: 4;
  }
  .tablet .dashboard .comparison,
  .tablet .dashboard .demo-data {
    grid-column: 2;
    grid-row: 3;
    padding: var(--space-4) var(--space-6);
  }
  .tablet .dashboard .dataset-note,
  .tablet .dashboard .missing-feature {
    grid-column: 1/-1;
    grid-row: 5;
  }
}

@media (min-width: 1100px) and (max-height: 620px) {
  .workspace .result-title {
    min-height: 40px;
    font-size: var(--text-lead);
  }
  .workspace .preview-version {
    margin-top: var(--space-4);
  }
  .workspace .result-sticky {
    padding: var(--space-10);
    gap: var(--space-8);
  }
}
.tablet .dashboard .demo-data .error-label,
.tablet .dashboard .demo-data strong {
  display: inline;
  margin: 0 var(--space-6) 0 0;
}
.tablet .dashboard .demo-data small {
  margin-top: var(--space-2);
}
@media (min-width: 1100px) and (max-height: 620px) {
  :root {
    --tablet-height: min(calc(var(--tablet-width) * 1.6), calc(100dvh - 90px));
  }
}
@container tablet-content (max-height:450px) and (max-width:500px) {
  .tablet .tablet-screen > .dashboard:not(.dash-empty):not(.review-unbuilt) {
    padding: var(--space-8);
    gap: var(--space-4);
  }
  .tablet .dashboard .metrics-grid {
    gap: var(--space-4);
  }
  .tablet .dashboard .metrics-grid .kpi {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-6);
    padding: var(--space-6);
  }
  .tablet .dashboard .metrics-grid .kpi h3 {
    margin: 0;
  }
  .tablet .dashboard .metrics-grid .kpi .value {
    font-size: 20px;
  }
  .tablet .dashboard .metrics-grid .donut {
    width: 64px;
  }
  .tablet .dashboard .donut-label strong {
    font-size: 20px;
  }
}

/* Keep the opened application alongside the story between working stages. */
.story-workspace > .learning-pane {
  min-width: 0;
}
.story-workspace .story-shell {
  padding: 0 var(--space-24) var(--space-24);
}
.story-workspace .result-sticky {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
@media (min-width: 1100px) {
  .story-workspace {
    /* Планшет и его поля задают нижнюю границу правой колонки: иначе макет
       приложения выходит за панель и обрезается правым краем окна. */
    grid-template-columns:
      minmax(0, 1.96fr)
      minmax(calc(var(--tablet-width) + 2 * var(--space-24) + var(--rule-accent) + var(--border-hairline)), 1fr);
  }
}
@media (max-width: 1099px) {
  .story-workspace {
    grid-template-columns: 1fr;
  }
  .story-workspace .result-sticky {
    position: static;
  }
  .story-workspace .story-shell {
    padding: 0 var(--space-18) 76px;
  }
}

/* A received file belongs to the task, separate from the AI conversation. */
.manager-update {
  padding: var(--space-18);
  border: var(--border-hairline) solid var(--accent-line);
  border-left: var(--rule-accent) solid var(--red);
  border-radius: var(--radius-lg);
  background: var(--paper-warm);
  margin-bottom: var(--space-18);
}
.manager-update > .speaker {
  font-weight: var(--weight-bold);
  color: var(--red);
  font-size: var(--text-small);
}
.manager-update > p {
  font-size: var(--text-lead);
  line-height: 1.5;
  margin: var(--space-10) 0 var(--space-16);
}
.received-file > summary {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  cursor: pointer;
  min-height: 48px;
  padding: var(--space-10);
  border: var(--border-hairline) solid var(--accent-line);
  border-radius: var(--radius-8);
  background: var(--surface);
  overflow-wrap: anywhere;
}
.received-file small,
.received-choice small {
  display: block;
  font-size: var(--text-small);
  line-height: 1.5;
  color: var(--ink-medium);
  margin-top: var(--space-4);
}
.received-file .table-container {
  margin-top: var(--space-12);
}
.received-file .file-icon {
  flex-shrink: 0;
}
.received-file[open] > summary {
  margin-bottom: var(--space-12);
}
.received-choice {
  display: flex;
  align-items: center;
  gap: var(--space-14);
  padding: var(--space-16);
  border: var(--border-hairline) solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  margin: var(--space-12) 0;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.received-choice input {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  accent-color: var(--red);
}
.received-choice:has(input:checked) {
  border-color: var(--red);
  background: var(--accent-soft);
}
#import-dialog {
  width: min(720px, calc(100vw - 32px));
  max-width: none;
}
#import-dialog h2 {
  font-size: var(--text-title);
}
#import-dialog .dialog-actions {
  flex-wrap: wrap;
}
#import-dialog .dialog-actions button {
  min-height: 44px;
}
#import-dialog .quiet {
  font-size: var(--text-small);
}
.update-success {
  display: flex;
  align-items: flex-start;
  gap: var(--space-10);
  padding: var(--space-14) var(--space-16);
  margin: 0 0 var(--space-20);
  background: var(--positive-bg);
  border: var(--border-hairline) solid var(--positive-pale);
  border-radius: var(--radius-8);
  font-size: var(--text-body);
  line-height: 1.5;
}
.update-success svg {
  flex-shrink: 0;
}
@media (max-width: 699px) {
  .manager-update {
    padding: var(--space-12);
  }
  .manager-update > p {
    font-size: var(--text-body);
  }
  .received-file strong,
  .received-choice strong {
    font-size: var(--text-body);
  }
  #import-dialog {
    padding: var(--space-20);
  }
  .received-file .data-table {
    font-size: var(--text-caption);
  }
  .received-file .data-table th,
  .received-file .data-table td {
    padding: var(--space-8) var(--space-5);
  }
}

.received-file .data-table td {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* The mentor occupies a separate conversation stage; trainer screens keep their own layout. */
.mentor-session {
  height: 100dvh;
  min-height: 340px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: var(--space-18);
  padding: var(--space-24) clamp(var(--space-16), 3vw, 60px);
  background:
    radial-gradient(var(--shadow-hairline) 0.8px, transparent 0.8px) 0 0/8px 8px,
    var(--paper);
  overflow: hidden;
}
.mentor-header {
  display: flex;
  gap: var(--space-20);
  align-items: center;
  justify-content: space-between;
  border-bottom: var(--border-hairline) dashed var(--mentor-line);
  padding-bottom: var(--space-16);
  min-width: 0;
}
.mentor-header h1 {
  font-size: clamp(28px, 3vw, 46px);
  line-height: 1.1;
  margin: var(--space-6) 0 0;
}
.mentor-progress {
  margin: 0;
  color: var(--accent-deep);
  font-size: var(--text-body);
  font-weight: 700;
}
.mentor-header button {
  flex-shrink: 0;
}
.mentor-stage {
  display: grid;
  grid-template-columns: minmax(180px, 25%) minmax(0, 1fr);
  gap: clamp(var(--space-18), 3vw, 48px);
  min-height: 0;
  min-width: 0;
}
.mentor-person {
  min-width: 0;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  isolation: isolate;
  border-bottom: var(--rule-accent) solid var(--mentor-extra-ink);
}
.mentor-person:before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 12% 0 0;
  background: var(--paper-deep);
  border: var(--border-hairline) solid var(--border);
  border-radius: 48% 48% 0 0;
}
.mentor-person img {
  display: block;
  object-fit: contain;
  object-position: bottom;
  width: 100%;
  height: calc(100% - 68px);
  min-height: 0;
  filter: drop-shadow(3px 2px 0 var(--shadow-hairline));
}
.mentor-name {
  width: 100%;
  padding: var(--space-12) var(--space-14);
  background: var(--warn-bg);
  border: var(--border-hairline) solid var(--border);
  border-bottom: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  text-align: center;
  transform: rotate(-1deg);
}
.mentor-name strong {
  font-size: var(--text-lead);
}
.mentor-name span {
  font-size: var(--text-small);
  color: var(--ink-medium);
}
.mentor-conversation {
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: var(--space-6) var(--space-18) var(--space-24) var(--space-18);
  scroll-padding: 18px;
}
.mentor-bubble {
  position: relative;
  border: var(--border-width) solid var(--mentor-bubble-border);
  border-radius: var(--radius-14);
  padding: var(--space-18) var(--space-22);
  margin: 0 var(--space-20) var(--space-20) 0;
  background: var(--surface);
  box-shadow: var(--shadow-hairline-offset);
  max-width: 100%;
  font-size: clamp(18px, 1.35vw, 21px);
  line-height: 1.5;
}
.mentor-bubble:before {
  content: '';
  position: absolute;
  top: var(--space-26);
  left: -8px;
  width: 14px;
  height: 14px;
  background: inherit;
  border-left: var(--border-width) solid var(--mentor-bubble-border);
  border-bottom: var(--border-width) solid var(--mentor-bubble-border);
  transform: rotate(45deg);
}
.mentor-speaker {
  display: block;
  font-size: var(--text-small);
  font-weight: 700;
  color: var(--accent-deep);
  margin-bottom: var(--space-6);
}
.mentor-bubble p {
  margin: 0;
  overflow-wrap: anywhere;
}
.mentor-user {
  margin: var(--space-10) 0 var(--space-20) 48px;
  background: var(--mentor-user-bg);
  border-color: var(--mentor-user-border);
}
.mentor-user:before {
  left: auto;
  right: -8px;
  border: 0;
  border-right: var(--border-width) solid var(--mentor-user-border);
  border-top: var(--border-width) solid var(--mentor-user-border);
}
.mentor-user .mentor-speaker {
  color: var(--accent-muted);
}
.mentor-road {
  list-style: none;
  padding: 0;
  margin: var(--space-4) var(--space-20) var(--space-24) 0;
  display: flex;
  gap: var(--space-10);
}
.mentor-road li {
  flex: 1;
  min-width: 0;
  padding: var(--space-14);
  background: var(--paper-deep);
  border: var(--border-hairline) solid var(--border);
  border-radius: var(--radius-sm);
  line-height: 1.35;
  font-size: var(--text-body);
  font-weight: 700;
}
.mentor-road li span {
  display: block;
  color: var(--accent-deep);
  font-size: var(--text-small);
  margin-bottom: var(--space-6);
}
.mentor-choices {
  margin: var(--space-12) 0 0 48px;
  display: grid;
  gap: var(--space-10);
}
.mentor-choices h2 {
  font:
    700 15px var(--font-body);
  color: var(--accent-muted);
  margin: 0 0 var(--space-2);
}
.mentor-choices button {
  display: flex;
  align-items: flex-start;
  gap: var(--space-12);
  white-space: normal;
  text-align: left;
  font-weight: 400;
  font-size: var(--text-lead);
  line-height: 1.45;
  background: var(--mentor-extra-bg);
  border: var(--border-hairline) solid var(--mentor-extra-border);
  padding: var(--space-14) var(--space-18);
  min-height: 48px;
  color: var(--mentor-extra-ink);
  transition:
    background 180ms,
    border-color 180ms;
}
.mentor-choices button:hover {
  background: var(--accent-soft);
  border-color: var(--accent-deep);
}
.mentor-choices button span {
  flex: 0 0 26px;
  border: var(--border-hairline) solid var(--accent-soft-line);
  border-radius: var(--radius-round);
  font-size: var(--text-small);
  line-height: 24px;
  text-align: center;
  color: var(--accent-deep);
}
.mentor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-14);
  border-top: var(--border-hairline) dashed var(--mentor-line);
  padding-top: var(--space-14);
}
.mentor-footer-note {
  font-size: var(--text-small);
  color: var(--ink-medium);
  text-align: center;
}
.mentor-footer button {
  min-height: 48px;
}
.mentor-examples {
  display: grid;
  grid-template-columns: minmax(0, 0.75fr) minmax(0, 1.25fr);
  gap: var(--space-16);
  margin: var(--space-4) var(--space-20) var(--space-24) 0;
  align-items: start;
}
.mentor-example {
  padding: var(--space-20);
  background: var(--warn-bg);
  border: var(--border-hairline) solid var(--border);
  box-shadow: var(--shadow-hairline-offset);
  border-radius: var(--radius-sm);
}
.mentor-example h2 {
  font:
    700 18px var(--font-body);
  margin: 0 0 var(--space-12);
  color: var(--accent-muted);
}
.mentor-example p {
  font-size: var(--text-lead);
  line-height: 1.55;
  margin: 0;
  overflow-wrap: anywhere;
}
.mentor-annotated .mentor-fragment {
  display: block;
  border-left: var(--rule-accent) solid var(--accent-deep);
  padding-left: var(--space-12);
  margin: var(--space-12) 0;
}
.mentor-fragment strong {
  display: block;
  font-size: var(--text-small);
  color: var(--accent-deep);
  margin-bottom: var(--space-3);
}
.mentor-exchange.is-new {
  animation: mentor-arrive 200ms ease-out;
}
.mentor-exchange [tabindex='-1']:focus {
  outline: 0;
}
.mentor-exchange [tabindex='-1']:focus-visible .mentor-bubble {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}
@keyframes mentor-arrive {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@media (min-width: 1600px) {
  .mentor-session {
    max-width: 1920px;
    margin: auto;
  }
  .mentor-conversation {
    padding-right: var(--space-32);
  }
  .mentor-bubble {
    padding: var(--space-22) var(--space-26);
  }
}
@media (max-width: 700px) {
  .mentor-session {
    padding: var(--space-12);
    gap: var(--space-10);
  }
  .mentor-header {
    padding-bottom: var(--space-10);
    gap: var(--space-10);
    align-items: flex-start;
  }
  .mentor-header h1 {
    font-size: var(--text-title);
  }
  .mentor-header button {
    font-size: var(--text-small);
    padding: var(--space-8);
    min-height: 44px;
  }
  .mentor-progress {
    font-size: var(--text-caption);
  }
  .mentor-stage {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 100px minmax(0, 1fr);
    gap: var(--space-10);
  }
  .mentor-person {
    flex-direction: row;
    justify-content: center;
    gap: var(--space-12);
    border-bottom: var(--border-hairline) solid var(--border);
  }
  .mentor-person:before {
    inset: 0;
    background: var(--paper-deep);
    border-radius: var(--radius-12);
  }
  .mentor-person img {
    height: 100%;
    width: 88px;
    object-fit: cover;
    object-position: top;
  }
  .mentor-name {
    width: auto;
    background: transparent;
    border: 0;
    text-align: left;
    transform: none;
  }
  .mentor-name strong {
    font-size: var(--text-lead);
  }
  .mentor-name span {
    font-size: var(--text-caption);
  }
  .mentor-conversation {
    padding: var(--space-6) var(--space-10) var(--space-18);
    scrollbar-gutter: auto;
  }
  .mentor-bubble {
    font-size: var(--text-lead);
    padding: var(--space-14);
    margin-right: var(--space-8);
  }
  .mentor-user {
    margin-left: var(--space-20);
    margin-right: var(--space-3);
  }
  .mentor-choices {
    margin-left: var(--space-12);
  }
  .mentor-choices button {
    font-size: var(--text-body);
    padding: var(--space-12);
    gap: var(--space-9);
  }
  .mentor-road {
    flex-direction: column;
    margin-right: var(--space-8);
    gap: var(--space-6);
  }
  .mentor-road li {
    display: flex;
    align-items: center;
    gap: var(--space-10);
    padding: var(--space-10);
    font-size: var(--text-body);
  }
  .mentor-road li span {
    margin: 0;
  }
  .mentor-examples {
    grid-template-columns: 1fr;
    margin-right: var(--space-8);
  }
  .mentor-example {
    padding: var(--space-16);
  }
  .mentor-footer {
    gap: var(--space-8);
    padding-top: var(--space-10);
  }
  .mentor-footer-note {
    display: none;
  }
  .mentor-footer button {
    font-size: var(--text-small);
    padding: var(--space-10) var(--space-12);
  }
  .mentor-footer .primary {
    margin-left: auto;
    max-width: 68%;
  }
}
@media (max-height: 500px) and (min-width: 701px) {
  .mentor-session {
    padding: var(--space-12) var(--space-20);
    gap: var(--space-8);
  }
  .mentor-header {
    padding-bottom: var(--space-8);
  }
  .mentor-header h1 {
    font-size: var(--text-title);
  }
  .mentor-stage {
    grid-template-columns: 160px minmax(0, 1fr);
    gap: var(--space-20);
  }
  .mentor-person img {
    height: calc(100% - 53px);
  }
  .mentor-name {
    padding: var(--space-7);
  }
  .mentor-name strong {
    font-size: var(--text-body);
  }
  .mentor-name span {
    font-size: var(--text-caption);
  }
  .mentor-footer {
    padding-top: var(--space-8);
  }
  .mentor-examples {
    grid-template-columns: 1fr;
  }
  .mentor-bubble {
    padding: var(--space-14) var(--space-18);
  }
}
@media (prefers-reduced-motion: reduce) {
  .mentor-exchange.is-new {
    animation: none;
  }
  .mentor-choices button {
    transition: none;
  }
}

.mentor-bubble.is-new {
  animation: mentor-arrive 200ms ease-out;
}
.mentor-footer-note {
  margin-right: auto;
  text-align: left;
}
.mentor-footer > .primary,
.mentor-footer > [data-action='mentor-choices'] {
  margin-left: auto;
}
@media (max-width: 700px) {
  .mentor-footer-note {
    display: block;
    font-size: var(--text-caption);
    max-width: 48%;
  }
  .mentor-sound {
    max-width: 110px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .mentor-bubble.is-new {
    animation: none;
  }
}

