/* Assistant chat, shown as a dialog. Each site sets --chat-accent, --chat-accent-ink, --chat-soft. */
dialog.chat {
  padding: 0;
  border: 0;
  width: min(440px, calc(100vw - 32px));
  height: min(640px, calc(100vh - 48px));
  max-width: none;
  max-height: none;
  border-radius: 20px;
  overflow: hidden;
  color: #0f172a;
  background: #fff;
  box-shadow: 0 30px 80px rgba(2, 12, 32, 0.45);
}
dialog.chat[open] { display: flex; flex-direction: column; animation: chat-in 0.22s ease-out; }
dialog.chat::backdrop { background: rgba(2, 12, 32, 0.55); backdrop-filter: blur(2px); }
@keyframes chat-in { from { opacity: 0; transform: translateY(16px) scale(0.98); } to { opacity: 1; transform: none; } }
html.chat-is-open { overflow: hidden; }
.chat-close {
  margin-left: 8px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: #f1f5f9;
  color: #334155;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.chat-close:hover { background: #e2e8f0; }
@media (max-width: 600px) {
  dialog.chat { width: 100vw; height: 100dvh; border-radius: 0; }
}
.chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #e5e9f0;
}
.chat-head img {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  object-fit: cover;
}
.chat-head div { display: flex; flex-direction: column; line-height: 1.25; }
.chat-head strong { font-size: 16px; }
.chat-head span { font-size: 13px; color: #64748b; }
.chat-head span::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: #22c55e;
}
.demo-tag {
  margin-left: auto;
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #92400e;
  background: #fef3c7;
  border-radius: 999px;
  padding: 3px 8px;
}
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f8fafc;
  overscroll-behavior: contain;
}
.bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.45;
  animation: bubble-in 0.18s ease-out;
}
.bubble.bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e5e9f0;
  border-bottom-left-radius: 4px;
}
.bubble.visitor {
  align-self: flex-end;
  background: var(--chat-accent);
  color: var(--chat-accent-ink);
  border-bottom-right-radius: 4px;
  font-weight: 600;
}
.bubble.typing { display: flex; gap: 4px; padding: 14px; }
.bubble.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  animation: dot 1s infinite;
}
.bubble.typing span:nth-child(2) { animation-delay: 0.15s; }
.bubble.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
@keyframes bubble-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.chat-controls {
  padding: 12px 16px 16px;
  border-top: 1px solid #e5e9f0;
  background: #fff;
}
.chat-controls:empty { display: none; }
.chat-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.chat-choice {
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: 999px;
  border: 2px solid var(--chat-accent);
  background: var(--chat-soft);
  color: #0f172a;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.chat-choice:hover, .chat-choice:focus-visible { background: var(--chat-accent); color: var(--chat-accent-ink); }
.chat-choice.primary { background: var(--chat-accent); color: var(--chat-accent-ink); }
.chat-form { display: flex; gap: 8px; flex-wrap: wrap; }
.chat-input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 16px; /* stops iOS zoom */
  padding: 11px 14px;
  border: 2px solid #cbd5e1;
  border-radius: 12px;
  background: #fff;
}
.chat-input:focus { outline: none; border-color: var(--chat-accent); }
.chat-send {
  font: inherit;
  font-weight: 700;
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  background: var(--chat-accent);
  color: var(--chat-accent-ink);
  cursor: pointer;
}
.chat-error { flex-basis: 100%; margin: 0; color: #b91c1c; font-size: 14px; }
.chat-consent .consent-text {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.45;
  color: #334155;
  background: #f8fafc;
  border: 1px solid #e5e9f0;
  border-radius: 10px;
  padding: 10px 12px;
}
.chat-note { margin: 8px 0 0; font-size: 13px; color: #64748b; }
.chat-restart {
  font: inherit;
  font-size: 14px;
  background: none;
  border: 0;
  color: #64748b;
  text-decoration: underline;
  cursor: pointer;
}
@media (prefers-reduced-motion: reduce) {
  .bubble, .bubble.typing span { animation: none; }
}
