/* ЯДРО: общая вёрстка оболочки, экранов и диалогов. Порядок файлов: 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);
}
.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);
}
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.96fr) minmax(0, 1fr);
  min-height: 100dvh;
}
.learning-pane {
  min-width: 0;
}
/* ---------- Оболочка экрана ----------
   Ширина содержимого приходит из темы двумя ступенями (docs/theme.md):
   --shell-wide для обложки и практики, --shell-content для остальных экранов.
   Шапка стоит в той же ступени, что и содержимое, поэтому её левый край совпадает
   с левым краем текста: раньше четыре шапки держали свой отступ, а широкие экраны
   тянулись от края окна и текст уезжал вправо на четверть кадра. */
.shell-header {
  width: 100%;
  max-width: var(--shell-content);
  margin-inline: auto;
  padding-inline: var(--gutter-x);
}
.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;
}
.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;
}
.lesson-main {
  padding: var(--space-30) var(--gutter-x) var(--space-24);
}
/* Первый шаг: письмо слева, окно агента справа; планшета на этом шаге нет. */
.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;
}
/* В компактной практике окно чата обычно без рамки, но здесь оно стоит рядом с письмом. */
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-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-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;
}
.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-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);
}
#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-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);
}
.choices {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-8);
}
.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);
}
.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;
}
.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;
}
.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);
}
@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);
}
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);
}
@media (min-width: 1750px) {
  .route button {
    font-size: var(--text-small);
    padding: var(--space-11) var(--space-10);
    min-height: 61px;
  }
  .lesson-main {
    padding: var(--space-32);
  }
}
@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .route button {
    font-size: var(--text-small);
  }
  .story-content h1 {
    font-size: var(--text-title);
  }
  .story-shell {
    padding: 0 var(--gutter-x) var(--space-24);
  }
}
@media (max-width: 720px) {
  .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 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 {
    padding: var(--space-24) var(--space-20);
  }
  .lesson-main h1 {
    font-size: var(--text-title);
  }
  .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);
  }
  .lesson-footer {
    gap: var(--space-10);
  }
  .lesson-footer .quiet {
    max-width: 190px;
  }
}
@media (max-width: 380px) {
  .lesson-main {
    padding: var(--space-22) var(--space-16);
  }
  .route {
    gap: var(--space-10);
  }
  .route li:not(:last-child):after {
    right: -9px;
  }
  .route button {
    font-size: var(--text-caption);
  }
  .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;
  }
  .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);
  }
}
@media (max-width: 1180px) {
  .toast {
    bottom: 80px;
  }
}
@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);
}
.lesson-footer {
  flex-wrap: wrap;
}
.story-content {
  container-type: inline-size;
}
@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;
  }
  .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-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);
  }
  .choices {
    gap: var(--space-6);
  }
  .reward {
    padding: var(--space-7) var(--space-10);
  }
  .reward strong {
    font-size: var(--text-body);
  }
  .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);
  }
}
@media (min-width: 1100px) and (min-height: 650px) and (max-height: 740px) {
  .lesson-main {
    padding-top: var(--space-14);
    padding-bottom: var(--space-10);
  }
  .choices {
    gap: var(--space-4);
  }
  .lesson-footer {
    margin-top: var(--space-8);
  }
}
.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);
  }
}
.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;
}
.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;
}
.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-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-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);
}
#prompt-dialog {
  width: 640px;
  max-width: calc(100% - 28px);
  padding: var(--space-24);
  background: var(--paper);
}
#prompt-dialog > .quiet {
  margin-bottom: var(--space-24);
}
#prompt-dialog .choices {
  gap: var(--space-8);
}
#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);
}
@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);
  }
  .chat-heading {
    padding: var(--space-9) var(--space-14);
  }
  .chat-message {
    font-size: var(--text-small);
    margin-bottom: var(--space-16);
  }
}
@media (max-width: 1099px) {
  .chat-main {
    padding: var(--space-14) var(--space-16) var(--space-10);
    gap: var(--space-10);
  }
  .chat-main > h1 {
    font-size: var(--text-title);
  }
}
@media (max-width: 720px) {
  .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);
  }
  .chat-window {
    min-height: 220px;
  }
  .chat-heading {
    padding: var(--space-9) var(--space-11);
  }
  .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;
  }
  .chat-main .lesson-footer .quiet {
    display: none;
  }
  .chat-main .lesson-footer .back-button {
    min-height: 36px;
  }
  #prompt-dialog {
    padding: var(--space-18);
  }
  #prompt-dialog .dialog-actions {
    bottom: -18px;
  }
  #prompt-dialog .dialog-actions button {
    width: 100%;
    min-height: 44px;
  }
}
#prompt-dialog .choices {
  align-items: stretch;
}
.chat-main > .chat-window {
  flex: none;
}
.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 {
  font-size: var(--text-caption);
}
@media (max-width: 720px) {
  .chat-message {
    font-size: var(--text-body);
  }
}
@media (max-width: 1099px) {
  html {
    scroll-padding-bottom: 74px;
  }
  .chat-main button {
    scroll-margin-block: 74px;
  }
}
/* 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 .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);
  }
}
@media (max-height: 450px) and (min-width: 700px) {
  #prompt-dialog {
    padding: var(--space-12);
  }
  #prompt-dialog[open] {
    gap: var(--space-8);
  }
}
#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);
}
@media (max-width: 699px) {
  #import-dialog {
    padding: var(--space-20);
  }
}
