:root {
  --ink: #11161C;
  --ink-soft: #5B6570;
  --accent: #0F6B5C;
  --accent-tint: #E7F2EF;
  --bg: #FFFFFF;
  --surface: #F3F5F6;
  --line: #E4E8EA;
  --radius: 18px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; margin: 0; }

html, body { height: 100%; background: var(--bg); }


.chat {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  max-width: 480px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
}

@media (min-width: 520px) {
  body { background: var(--surface); padding: 24px 16px; }
  .chat {
    height: calc(100dvh - 48px);
    border: 1px solid var(--line);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(17, 22, 28, 0.06);
  }
}

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  padding-top: max(14px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
}
.avatar {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 18px;
}
.biz { flex: 1; min-width: 0; }
.biz h1 { font-size: 16px; font-weight: 650; line-height: 1.25; }
.status {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}
.dot { width: 7px; height: 7px; margin-top: 5px; border-radius: 50%; background: #22A06B; flex: none; }
.demo-pill {
  flex: none;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: var(--accent-tint);
  padding: 5px 10px;
  border-radius: 999px;
}

/* Messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}
.msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  animation: pop 0.18s ease-out;
}
.msg.bot {
  align-self: flex-start;
  background: var(--surface);
  border-bottom-left-radius: 6px;
}
.msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.msg.error {
  align-self: flex-start;
  background: #FDF1EE;
  color: #8A2F1D;
  border-bottom-left-radius: 6px;
}
/* pre-wrap only on the text node so HTML indentation doesn't add blank lines */
.msg p { white-space: pre-wrap; }
@keyframes pop {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* Typing indicator */
.typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-soft);
  opacity: 0.4;
  animation: blink 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 0.9; transform: translateY(-3px); }
}

/* Suggestion chips */
.chips {
  display: flex;
  gap: 8px;
  padding: 0 16px 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chips[hidden] { display: none; }
.chip {
  flex: none;
  font: inherit;
  font-size: 13.5px;
  color: var(--accent);
  background: var(--bg);
  border: 1px solid #BFD9D3;
  border-radius: 999px;
  padding: 8px 13px;
  cursor: pointer;
}
.chip:hover { background: var(--accent-tint); }

/* Composer */
.composer {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}
.composer input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 16px; /* 16px stops iOS zoom on focus */
  color: var(--ink);
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 11px 16px;
  outline: none;
}
.composer input:focus { border-color: var(--accent); background: var(--bg); }
.composer button {
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.composer button:disabled { opacity: 0.45; cursor: default; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.foot {
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-soft);
  padding: 2px 16px 10px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}
.foot strong { color: var(--ink); font-weight: 600; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .msg, .typing span { animation: none; }
  .messages { scroll-behavior: auto; }
}
