/* app.css — оболочка приложения Valya.
   Применяется ПОСЛЕ engine/chat.css: переопределения ниже сильнее (тот же порядок, но позже).
   Задача: чат занимает экран целиком, страница не прокручивается. */

html, body { height: 100%; }

body {
  /* без !important: он заглушал бы padding-top/bottom с safe-area (аудит 14.10) */
  padding: 0;                         /* в chat.css остался сайтовый padding-bottom:60px */
  height: 100dvh;                     /* НЕ 100vh: на телефонах vh больше видимой области */
  min-height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-text-size-adjust: 100%;
}

/* ── Шапка ── */
.app-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-card, #28231f);
  border-bottom: 1px solid var(--border-color, #423831);
}
.app-brand { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 auto; }
.app-logo { width: 28px; height: 28px; border-radius: 7px; flex: 0 0 auto; }
.app-titles { display: flex; flex-direction: column; min-width: 0; }
.app-name {
  font-weight: 700; font-size: 1rem; line-height: 1.15;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-tag { font-size: .72rem; color: var(--text-muted, #b8ac9f); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.app-icon {
  background: transparent; border: 1px solid var(--border-color, #423831);
  color: var(--text-main, #f4efe9); border-radius: 8px;
  min-width: 36px; min-height: 36px; font-size: 1rem; cursor: pointer; flex: 0 0 auto;
}
.app-icon:hover { background: var(--bg-card-hover, #312b26); }
.net-badge {
  font-size: .72rem; color: #f3c98b; background: rgba(230,126,34,.14);
  border: 1px solid rgba(230,126,34,.5); border-radius: 999px; padding: 3px 8px; white-space: nowrap;
}

/* ── Рабочая область: только тело диалога сжимается ── */
.app-main {
  flex: 1 1 auto; min-height: 0;
  display: flex; padding: 6px 8px 8px;
}
.app-main > .chat-card {
  min-height: 0 !important;           /* отменяем сайтовые min/max-height */
  max-height: none !important;
  width: 100%; flex: 1 1 auto;
  display: flex; flex-direction: column;
}
.chat-card > .chat-body { flex: 1 1 auto; min-height: 0; }
.chat-card > .valya-lang-bar,
.chat-card > .chat-input { flex: 0 0 auto; }

/* Поле ввода: не даём iOS зумить страницу при фокусе */
.chat-input textarea { font-size: 16px; }
.chat-input button, .chat-input .chat-exp { min-height: 42px; }

/* ── Меню ── */
.sheet { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; }
.sheet[hidden] { display: none; }
.sheet-card {
  width: 100%; max-height: 80vh; background: var(--bg-card, #28231f);
  border-top-left-radius: 14px; border-top-right-radius: 14px;
  border-top: 1px solid var(--border-color, #423831);
  display: flex; flex-direction: column; overflow: hidden;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border-color, #423831); }
.sheet-body { padding: 10px 14px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.sheet-btn {
  text-align: left; background: #201b18; color: var(--text-main, #f4efe9);
  border: 1px solid var(--border-color, #423831); border-radius: 8px;
  padding: 12px 14px; font-size: .95rem; font-family: inherit; cursor: pointer; min-height: 44px;
}
.sheet-btn:hover { background: var(--bg-card-hover, #312b26); }
.sheet-text { font-size: .85rem; color: var(--text-muted, #b8ac9f); line-height: 1.5; }
.sheet-text a { color: var(--accent-gold, #f1c40f); }
.sheet-ver { margin-top: 6px; font-size: .75rem; }

/* ── Уведомление о новой версии ── */
/* ВАЖНО: тост НЕ ставим внизу — он перекрывает поле ввода и кнопку «Отправить»
   (клик по кнопке уходил в тост, отправка «не работала»). Место — под шапкой. */
.sw-toast {
  position: fixed; left: 10px; right: 10px; top: calc(56px + env(safe-area-inset-top));
  z-index: 70; background: var(--bg-card-hover, #312b26); border: 1px solid var(--accent-sun, #e67e22);
  border-radius: 10px; padding: 10px 14px; display: flex; align-items: center; gap: 10px;
  font-size: .9rem; box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
.sw-toast button { background: var(--accent-sun, #e67e22); color: #fff; border: 0; border-radius: 6px; padding: 8px 12px; font-weight: 700; cursor: pointer; }

/* Без анимаций у тех, кто просил — но заставку не выключаем (решение владельца) */
@media (prefers-reduced-motion: reduce) {
  .chat-body { scroll-behavior: auto; }
}
