:root {
  --bg: #f4f2ec; --panel: #ffffff; --text: #1e261c; --muted: #6d7566; --line: #e3e0d6;
  --accent: #3f6b35; --accent-text: #ffffff; --user: #e3ecdc; --bot: #ffffff; --price: #b0361f;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141912; --panel: #1b2219; --text: #e6eadf; --muted: #9aa392; --line: #2c3529;
    --accent: #6f9d5f; --accent-text: #0f140d; --user: #2a3a24; --bot: #1f281c; --price: #ff8a6e;
  }
}
:root[data-theme="dark"] {
  --bg: #141912; --panel: #1b2219; --text: #e6eadf; --muted: #9aa392; --line: #2c3529;
  --accent: #6f9d5f; --accent-text: #0f140d; --user: #2a3a24; --bot: #1f281c; --price: #ff8a6e;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.app { max-width: 760px; height: 100dvh; margin: 0 auto; display: flex; flex-direction: column; }

.top { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line);
  background: var(--panel); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: var(--accent-text);
  display: grid; place-items: center; font-weight: 700; font-size: 18px; flex: none; }
.who { flex: 1; min-width: 0; }
.name { font-weight: 650; }
.role { color: var(--muted); font-size: 13px; }
.ghost { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 8px;
  padding: 6px 10px; font: inherit; font-size: 13px; cursor: pointer; }
.ghost:hover { color: var(--text); }

.log { position: relative; overflow-anchor: none; flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; flex-direction: column; gap: 8px; max-width: 92%; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.bubble { padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word;
  background: var(--bot); border: 1px solid var(--line); }
.msg.user .bubble { background: var(--user); border-color: transparent; }
.bubble.error { color: var(--price); }
/* «Михалыч думает»: пузырь с тремя прыгающими точками и подписью этапа */
.thinking { display: flex; align-items: center; gap: 10px; animation: fade-in .25s ease-out; }
.thinking .dots { display: inline-flex; gap: 5px; padding: 12px 14px; border-radius: 14px;
  background: var(--bot); border: 1px solid var(--line); }
.thinking .dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
  animation: dot 1.2s infinite ease-in-out; }
.thinking .dots span:nth-child(2) { animation-delay: .15s; }
.thinking .dots span:nth-child(3) { animation-delay: .3s; }
.thinking-label { color: var(--muted); font-size: 14px; font-style: italic; }
@keyframes dot { 0%, 60%, 100% { transform: translateY(0); opacity: .35; } 30% { transform: translateY(-5px); opacity: 1; } }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .thinking .dots span, .thinking, .typing::after { animation: none; }
  .thinking .dots span { opacity: .7; }
}
.typing::after { content: "▍"; animation: blink 1s steps(2) infinite; color: var(--muted); }
@keyframes blink { 50% { opacity: 0; } }

.starters { display: flex; flex-wrap: wrap; gap: 8px; }
.starters button { background: var(--panel); border: 1px solid var(--line); color: var(--text); border-radius: 999px;
  padding: 7px 12px; font: inherit; font-size: 14px; cursor: pointer; }
.starters button:hover { border-color: var(--accent); }

.product { display: flex; gap: 12px; padding: 10px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; text-decoration: none; color: inherit; max-width: 460px; }
.product:hover { border-color: var(--accent); }
.product img { width: 84px; height: 84px; object-fit: contain; border-radius: 8px; background: #fff; flex: none; }
.product .info { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.product .title { font-size: 14px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden; }
.product .price { font-weight: 700; color: var(--price); }
.product .old { color: var(--muted); text-decoration: line-through; font-weight: 400; margin-left: 6px; font-size: 13px; }
.product .meta { color: var(--muted); font-size: 12px; }

.rate { display: flex; gap: 6px; }
.rate button { background: none; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; padding: 2px 8px; }
.rate button.on { border-color: var(--accent); }

.composer { display: flex; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); background: var(--panel); }
.composer textarea { flex: 1; resize: none; max-height: 160px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; }
.composer button { width: 46px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-text);
  font-size: 18px; cursor: pointer; }
.composer button:disabled { opacity: .5; cursor: default; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 4px 16px calc(8px + env(safe-area-inset-bottom));
  background: var(--panel); }
