/*
 * Оформление демо-чата. Палитра снята с сайта клиента: оранжевый #e8661f —
 * их фирменный акцент, кремовый #fdf8ec — фон блоков. Логотип не используем,
 * чтобы не выдавать демо за их официальный сервис.
 *
 * Верстка на flex с динамической высотой экрана: тестировать будут с телефона,
 * а там адресная строка съезжает и 100vh врёт.
 */
:root {
  --accent: #e8661f;
  --accent-dark: #cf560f;
  --ink: #201918;
  --muted: #6f6560;
  --line: #e2ddd6;
  --bg: #f7f5f2;
  --card: #ffffff;
  --cream: #fdf8ec;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

.app {
  max-width: 760px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--card);
}

.head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.head-main { flex: 1; min-width: 0; }
.title { font-weight: 700; font-size: 17px; letter-spacing: -0.2px; }
.subtitle { color: var(--muted); font-size: 13px; }

.ghost {
  font: inherit;
  font-size: 14px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
.ghost:hover { border-color: var(--accent); color: var(--accent); }

.demo-note {
  padding: 8px 16px;
  background: var(--cream);
  border-bottom: 1px solid var(--line);
  color: #7a5a33;
  font-size: 13px;
}

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.msg { max-width: 86%; }
.msg .bubble {
  padding: 10px 13px;
  border-radius: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg.bot { align-self: flex-start; }
.msg.bot .bubble {
  background: var(--cream);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}
.msg.me { align-self: flex-end; }
.msg.me .bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg.error .bubble { background: #fdeeee; border: 1px solid #f0c2bd; color: #8c2016; }

/* Ссылки внутри ответов бота: карта 2ГИС, страницы правил, покупка билета. */
.msg .bubble a { color: var(--accent-dark); }
.msg.me .bubble a { color: #fff; }

.typing { display: flex; gap: 4px; padding: 4px 2px; }
.typing i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted); opacity: 0.45;
  animation: blink 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 0.9; } }

@media (prefers-reduced-motion: reduce) {
  .typing i { animation: none; }
  .chat { scroll-behavior: auto; }
}

.chips {
  display: flex;
  gap: 8px;
  padding: 0 16px 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
/* Без этого атрибут hidden не работает: display:flex перебивает его. */
.chips[hidden] { display: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  font: inherit;
  font-size: 14px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

.composer {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  background: var(--card);
}
#input {
  flex: 1;
  font: inherit;
  /* 16px обязательны: на iOS меньший размер заставляет Safari зумить страницу. */
  font-size: 16px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  resize: none;
  max-height: 140px;
  background: #fff;
  color: var(--ink);
}
#input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.send {
  width: 46px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  flex: none;
}
.send:hover { background: var(--accent-dark); }
.send:disabled { background: #d8d2cc; cursor: default; }

.foot {
  padding: 0 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}
.counter:empty { display: none; }
.consent a { color: var(--muted); }

@media (max-width: 480px) {
  .subtitle { display: none; }
  .title { font-size: 16px; }
  .demo-note { font-size: 12px; }
  .msg { max-width: 92%; }
}
