/* Переписка с «ИИ» (chat, урок 4). Телефон первым: пузыри во всю ширину, таблица плана без
   горизонтальной прокрутки (время узкой колонкой), поле ввода и кнопки внизу крупные. */
.chat-log { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.chat-msg { max-width: 92%; background: #fff; border-radius: 16px; padding: 10px 14px;
  box-shadow: 0 2px 8px rgba(28,35,64,.08); overflow-wrap: anywhere; }
.chat-msg.friend { align-self: flex-start; background: #fff8ec; }
.chat-msg.friend.bonus { border: 3px dashed #f5a623; }
.chat-msg.ai { align-self: flex-start; background: #fff; }
.chat-msg.kid { align-self: flex-end; background: #eef2ff; }
.chat-msg.kid.sending { opacity: 1; }
.chat-msg.kid.failed { border: 2px solid #c0392b; }
.chat-who { font-size: 13px; font-weight: 800; color: #4f5675; margin-bottom: 2px; }
.chat-bonus-mark { margin-left: 8px; padding: 1px 8px; border-radius: 999px; background: #9a5a00; color: #fff;
  font-size: 12px; }
.chat-text { font-size: 17px; line-height: 1.4; white-space: pre-wrap; color: #2b3150; }
.chat-status { font-size: 14px; font-weight: 700; color: #2b3150; margin-top: 4px; }
.chat-msg.failed .chat-status { color: #c0392b; }
.chat-done { align-self: stretch; background: #e3f6ea; border-left: 4px solid #1e8449; border-radius: 12px;
  padding: 10px 14px; font-size: 17px; font-weight: 800; color: #145a32; }
.chat-note { align-self: center; font-size: 14px; font-weight: 700; color: #4f5675; padding: 4px 0; }

.chat-plan { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 15px; }
.chat-plan th { text-align: left; font-size: 13px; color: #4f5675; padding: 4px 6px; border-bottom: 2px solid #e3e8f7; }
.chat-plan td { padding: 6px; border-bottom: 1px solid #eef1fa; vertical-align: top; color: #2b3150; }
.chat-plan .chat-time { white-space: nowrap; font-variant-numeric: tabular-nums; width: 1%; }
/* изменилось с прошлого плана: фон и полоса слева, не цвет одного текста */
.chat-plan tr.changed td { background: #fff3c4; font-weight: 700; }
.chat-plan tr.changed td:first-child { box-shadow: inset 4px 0 0 #f5a623; }

.chat-cond { background: #fff; border: 3px solid #3450d2; border-radius: 16px; padding: 12px 14px; margin-bottom: 12px; }
.chat-cond-title { font-weight: 800; color: #3450d2; margin-bottom: 4px; }
.chat-cond ul { margin: 0 0 6px; padding-left: 20px; font-size: 17px; line-height: 1.5; }
.chat-cond-text { font-weight: 700; }

.chat-input { position: sticky; bottom: 0; z-index: 4; background: #f0f4ff; border-radius: 18px 18px 0 0;
  padding: 10px; margin: 0 -6px; box-shadow: 0 -4px 14px rgba(28,35,64,.08); }
.chat-field { width: 100%; box-sizing: border-box; font: inherit; font-size: 17px; line-height: 1.4; padding: 10px 12px;
  border: 3px solid #dfe5f5; border-radius: 14px; resize: vertical; min-height: 84px; background: #fff; color: #2b3150; }
.chat-field:focus { outline: none; border-color: #3450d2; }
.chat-field:disabled { background: #f4f6fb; color: #4f5675; }
.chat-row, .chat-decide { padding-right: 96px; }  /* кнопка «Поднять руку» (64 + 16 + зазор) не лежит на кнопках */
.chat-row { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.chat-meta { display: flex; flex-wrap: wrap; gap: 0 12px; font-size: 13px; color: #4f5675; }
.chat-send { width: 100%; min-height: 48px; }
.chat-send:disabled { opacity: .5; }
.chat-closed { font-size: 17px; line-height: 1.4; font-weight: 800; color: #3450d2; text-align: center; padding: 6px 0; }
.chat-decide-q { font-weight: 800; text-align: center; margin-bottom: 8px; }
/* «да» и «нет» по краям и крупно: на телефоне не промахнуться */
.chat-decide { display: flex; justify-content: space-between; gap: 16px; }
.chat-decide-btn { flex: 1 1 0; min-height: 56px; font-size: 20px; }

/* ИИ-модель (спека gigachat-moderation): статус под сообщением ребёнка, пока ответ готовится или проверяется;
   цитата вопроса над ответом, пришедшим позже */
.chat-wait { font-size: 14px; font-weight: 700; color: #4f5675; margin-top: 4px; }
.chat-wait.skipped { font-weight: 600; }
.chat-quote { font-size: 14px; color: #4f5675; margin-bottom: 2px; border-left: 3px solid #c9d4fb; padding-left: 8px; }

/* урок 4, графика: аватар у подписи, картинка места в строке плана, кнопка прошлой переписки */
.chat-who { display: flex; align-items: center; gap: 8px; }
.chat-av { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: 0 0 32px; background: #f6ead0; }
.chat-place { display: flex; align-items: center; gap: 8px; }
.chat-place > span { min-width: 0; overflow-wrap: break-word; hyphens: auto; }
/* пузырь с планом во всю ширину: таблице нужно место под картинку места */
.chat-msg.ai:has(.chat-plan) { max-width: 100%; align-self: stretch; }
.chat-pic { flex: 0 0 44px; width: 44px; min-height: 24px; display: flex; align-items: center; justify-content: center; }
.chat-pic img.place { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: #f6ead0; }
.chat-pic img.move { width: 26px; height: 26px; border-radius: 7px; object-fit: cover; background: #f6ead0; }
.chat-history { display: block; width: 100%; min-height: 48px; margin: 0 0 12px; padding: 8px 12px; font: inherit;
  font-size: 16px; font-weight: 600; color: #4f5675; background: #f8f9fc; border: 1px solid #b9c4d9; border-radius: 12px; cursor: pointer; }
.chat-history:focus-visible { outline: 3px solid #f5a623; outline-offset: 2px; }
/* телефон: строка плана в два этажа — время мелкой строкой сверху, ниже картинка и название во всю
   ширину; переносы только по словам (по слогам названия мест читались хуже) */
@media (max-width: 420px) {
  .chat-plan tr:first-child:has(th) { display: none; }
  .chat-plan tr { display: block; border-bottom: 1px solid #eef1fa; padding: 6px 4px; }
  .chat-plan td { display: block; border: 0; padding: 0; }
  .chat-plan .chat-time { width: auto; font-size: 13px; color: #4f5675; margin-bottom: 2px; }
  .chat-plan tr.changed { background: #fff3c4; box-shadow: inset 4px 0 0 #f5a623; padding-left: 10px; }
  .chat-plan tr.changed td, .chat-plan tr.changed td:first-child { background: none; box-shadow: none; }
  .chat-plan { font-size: 16px; }
  .chat-place > span { hyphens: manual; }
}
/* раскрытая прошлая переписка: фон и аватар приглушены (текст читается полностью), перед текущей
   практикой — черта */
.chat-msg.past, .chat-done.past { background: #f4f6fb; box-shadow: none; }
.chat-done.past { border-left-color: #b9c4e8; color: #4f5675; font-weight: 600; }
.chat-msg.past .chat-av { opacity: .55; }
.chat-msg.friend.bonus.past { border-color: #d9c39a; }
.chat-log > .now-start { margin-top: 10px; padding-top: 14px; border-top: 2px dashed #b9c4e8; }
.chat-log > .now-start { align-self: stretch; }

/* Переписка демонстрации: те же пузыри, карточка первого запроса под верхней панелью. */
.chat-msg.host { align-self: flex-end; background: #eef2ff; }
.slide.dialog-slide { background: transparent; box-shadow: none; padding: 0; }
/* вопрос ведущей к классу под перепиской (урок 6, s05): акцентная строка на всю ширину, не пузырь говорящего */
.dialog-slide .dialog-question { margin: 4px 0 0; background: #fff; border-radius: 14px; padding: 14px 18px;
  box-shadow: inset 5px 0 0 #3450d2, 0 2px 8px rgba(28,35,64,.08); font-size: 22px; font-weight: 700; line-height: 1.35; color: #1c2340; }
.chat-context { position: static; z-index: 5; background: #fff8ec; border: 1px solid #e8d7b9;
  border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; box-shadow: 0 2px 8px rgba(28,35,64,.08); }
.chat-context-title { font-size: 14px; font-weight: 800; color: #4f5675; margin-bottom: 4px; }
/* Общие стили markdown-таблиц слайда не должны менять таблицу переписки. */
.dialog-slide .chat-plan { font-size: 15px; line-height: 1.4; margin-top: 8px; }
.dialog-slide .chat-plan th, .dialog-slide .chat-plan td { padding: 6px; }
.dialog-slide .chat-plan tr:nth-child(even) { background: transparent; }
.dialog-slide .chat-plan tr.changed td { background: #fff3c4; }
@media (max-width: 420px) {
  .dialog-slide .chat-plan { font-size: 16px; }
  .dialog-slide .chat-plan td { padding: 0; }
  .dialog-slide .chat-plan tr.changed td { background: none; }
}
@media (max-height: 500px) { .chat-context { position: static; } }

.chat-context-title { display: flex; align-items: center; gap: 8px; }
.chat-context[data-sticky], .chat-context-stack[data-sticky] { position: sticky; z-index: 5; }
.chat-context[data-sticky].unstuck, .chat-context-stack[data-sticky].unstuck { position: static; }
.chat-context.bonus { border: 3px dashed #f5a623; }
.chat-context-stack { margin-bottom: 14px; }
.chat-context-stack .chat-context:last-child { margin-bottom: 0; }
.chat-part.past { background: #f4f6fa; border: 1px solid #bac4d6; border-radius: 14px; padding: 12px; margin-bottom: 16px; }
.chat-part.past .chat-text, .chat-part.past .chat-plan td { color: #535d75; }
.chat-title { font-size: 17px; margin: 12px 0 8px; color: #4f5675; }
@media (max-height: 500px) {
  .chat-context[data-sticky], .chat-context-stack[data-sticky] { position: static; }
}

.chat-thinking-dots { display: flex; gap: 6px; padding: 8px 0; }
.chat-thinking-dots span { width: 8px; height: 8px; border-radius: 50%; background: #4f5675;
  animation: chat-dot 900ms infinite alternate; }
.chat-thinking-dots span:nth-child(2) { animation-delay: 150ms; }
.chat-thinking-dots span:nth-child(3) { animation-delay: 300ms; }
@keyframes chat-dot { from { opacity: .35; transform: translateY(0); } to { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .chat-thinking-dots span { animation: none; } }

.chat-thinking .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
/* Мелкие подписи ролей: обычные заглавные глифы вместо системного жирного начертания. */
.chat-who, .bubble-who { font-family: Arial, sans-serif; font-size: 14px; font-weight: 700;
  font-style: normal; font-variant: normal; text-transform: none; }
.chat-context:not([data-card]) { background: #f6f7fa; border-color: #e4e7ef; box-shadow: none; }
.chat-context:not([data-card]) .chat-text { font-size: 15px; color: #4f5675; }
/* тренажёр: подсказки и «готово» — не реплика ИИ, без аватара */
.chat-msg.guide { align-self: stretch; background: #eefaf3; border: 1px solid #bfe6cf; color: #1d4d33; }
.chat-done .chat-who { margin-bottom: 4px; color: #1d4d33; }
.chat-links { margin: 8px 0 0; padding-left: 20px; }
.chat-links li { margin: 4px 0; }
.chat-links a { color: #1f4fd1; text-decoration: underline; overflow-wrap: anywhere; }
/* fix: постоянные блоки в липкой панели над полем ввода — «Что мы нашли» и «Условия друга»,
   компактно; заголовок — кнопка сворачивания */
.chat-fixed { display: grid; gap: 6px; margin: 0 0 8px; }
.chat-fixed .chat-cond { margin: 0; padding: 4px 10px 6px; background: #fff; }
.chat-fixed .chat-cond.folded { padding-top: 0; padding-bottom: 0; }
/* на широком экране блоки рядом: панель ниже, переписке остаётся больше места */
@media (min-width: 600px) { .chat-fixed { grid-template-columns: 1fr 1fr; align-items: start; } }
.chat-fixed ul { margin: 0; padding-left: 18px; font-size: 15px; line-height: 1.35; color: #2b3150; }
.chat-fixed .chat-fixed-toggle { display: flex; align-items: center; width: 100%; min-height: 40px; padding: 0; margin: 0;
  font: inherit; font-size: 15px; font-weight: 700; color: #3450d2; text-align: left; background: none; border: 0; cursor: pointer; }
.chat-fixed .chat-fixed-toggle::before { content: ""; flex: 0 0 auto; width: 7px; height: 7px; margin: 0 10px 0 2px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); }
.chat-fixed .chat-fixed-toggle[aria-expanded="false"]::before { transform: rotate(-45deg); }
.chat-fixed .chat-fixed-toggle:focus-visible { outline: 3px solid #3450d2; outline-offset: 2px; }
.chat-part { position: relative; }
.chat-part-title { font-size: 19px; font-weight: 700; color: #535d75; margin: 0 0 12px; }
.chat-plan-toggle { display: block; width: 100%; min-height: 44px; padding: 10px 12px;
  text-align: left; font: inherit; font-size: 15px; color: #4f5675; background: #f8f9fc; border: 1px solid #b9c4d9; border-radius: 10px; cursor: pointer; }
.chat-plan-toggle:focus-visible { outline: 3px solid #3450d2; outline-offset: 2px; }
.chat-cond { border: 1px solid #e1e5ee; background: #f8f9fc; padding: 10px 12px; }
.chat-cond-title, .chat-cond-text { font-weight: 400; color: #4f5675; }
.chat-cond ul { font-size: 16px; }
.chat-plan .chat-time { font-size: inherit; font-weight: inherit; color: inherit; }
.dialog-slide .chat-plan th { font-size: 13px; font-weight: 700; color: #4f5675; }
@media (max-width: 420px) {
  .chat-plan .chat-time { font-size: 16px; color: #2b3150; font-weight: inherit; }
  .chat-input.compact .chat-meta { flex-direction: row; gap: 4px 12px; }
  .chat-input .chat-row { gap: 4px; margin-top: 4px; }
  .chat-input { padding-top: 8px; }
  .chat-input .chat-meta { min-height: 16px; flex-wrap: nowrap; align-items: center; gap: 8px; font-size: 11px; white-space: nowrap; }
  .chat-input.compact .chat-meta { gap: 8px; }
  /* пустое поле без фокуса — в одну строку: над ним помещаются блоки «Что мы нашли» и «Условия друга» */
  .chat-input.compact .chat-field { min-height: 50px; height: 50px; }
  .chat-closed, .chat-decide-q { padding-right: 84px; }
}

/* Шеврон нарисован рамкой: декоративный знак не попадает в доступное имя кнопки. */
.chat-plan-toggle::before { content: ""; display: inline-block; width: 7px; height: 7px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); margin-right: 10px; vertical-align: 2px; }
.chat-plan-toggle[aria-expanded="true"]::before { transform: rotate(45deg); }
.chat-context-expand { display: none; font: inherit; font-size: 14px; min-height: 44px;
  padding: 6px 12px; margin-top: 4px; color: #4f5675; background: #fff8ec;
  border: 1px solid #c4b79e; border-radius: 8px; cursor: pointer; }
.chat-context.sticky-short .chat-context-expand { display: block; }
.chat-context.sticky-short:not(.text-expanded) .chat-text { max-height: 4.2em; overflow: hidden;
  mask-image: linear-gradient(to bottom, #000 65%, transparent); }
.chat-context-expand:focus-visible { outline: 3px solid #3450d2; outline-offset: 2px; }

/* Редакторская строка условий заменяет полный текст только после ответа ребёнка. */
.chat-short-row { display: none; }
@media (max-width: 420px) {
  .chat-context.editor-short.sticky-short:not(.text-expanded) { padding: 4px 8px; }
  .chat-context.editor-short.sticky-short:not(.text-expanded) .chat-context-title,
  .chat-context.editor-short.sticky-short:not(.text-expanded) .chat-text,
  .chat-context.editor-short.sticky-short:not(.text-expanded) .chat-expand-label { display: none; }
  .chat-context.editor-short.sticky-short:not(.text-expanded) .chat-context-expand {
    display: block; width: 100%; min-height: 44px; padding: 4px; margin: 0; border: 0; }
  .chat-context.editor-short.sticky-short:not(.text-expanded) .chat-short-row {
    display: flex; align-items: center; gap: 6px; min-width: 0; }
  .chat-short-row .chat-av { width: 24px; height: 24px; flex-basis: 24px; }
  .chat-short-text { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
    white-space: normal; min-width: 0; font-size: 14px; line-height: 20px; text-align: left; }
}

/* Запас до панели ввода и плавающей руки: последний пузырь можно прокрутить целиком над ними. */
@media (max-width: 420px) {
  .chat-part:last-of-type .chat-log { padding-bottom: 88px; }
}


/* Закрываем просвет до шапки, не меняя высоту карточки и её липкий отступ 8 px. */
@media (min-height: 501px) {
  .chat-context[data-sticky]:not(.unstuck)::before,
  .chat-context-stack[data-sticky]:not(.unstuck)::before {
    content: ""; position: absolute; bottom: 100%; left: -3px; right: -3px; height: 11px;
    background: #f5f8ff; pointer-events: none;
  }
}

/* Урок 5, режим fix (корень .chat-fix по step.found): нейтральная база и один цвет состояния
   (docs/kid-screen-principles.md, правила 1, 3, 4). Ведущая — белая карточка с серой рамкой, Тренажёр — короткая
   серая строка статуса, а не зелёный собеседник; правки плана — бледно-жёлтый фон и полоса, без жирного. */
.chat-fix .chat-context[data-card] { background: #fff; border-color: #dfe3ec; }
.chat-fix .chat-context.bonus { border: 1px solid #dfe3ec; }
.chat-fix .chat-bonus-mark { background: #eef0f5; color: #4f5675; }
.chat-fix .chat-msg.guide { background: #f6f7fa; border-color: #e4e7ef; color: #2b3150; }
.chat-fix .chat-msg.guide .chat-who { color: #4f5675; }
.chat-fix .chat-plan tr.changed td { font-weight: 400; }
