:root {
  /* Base dark premium — paleta da referência */
  --bg-base: #08090d;
  --bg-gradient-center: #1a1d2a;
  --bg-gradient-edge: #05060a;

  /* Glass */
  --glass-bg: rgba(28, 31, 42, 0.55);
  --glass-bg-solid: rgba(28, 31, 42, 0.92);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-highlight: rgba(255, 255, 255, 0.04);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.45), inset 0 1px 0 var(--glass-highlight);

  /* Texto */
  --text-primary: #f0f1f5;
  --text-secondary: #a5a9b8;
  --text-strong: #ffffff;

  /* Marca — laranja como destaque, igual à referência */
  --accent: #ff8e21;
  --accent-soft: #ffa147;
  --accent-3: #ffb968;
  --accent-glow: rgba(255, 142, 33, 0.28);

  /* CTA azul */
  --btn-bg: linear-gradient(135deg, #1e5cff 0%, #0042da 100%);
  --btn-bg-hover: linear-gradient(135deg, #2f6bff 0%, #0a4fea 100%);
  --btn-glow: 0 8px 24px rgba(0, 66, 218, 0.35);
  --btn-glow-hover: 0 10px 28px rgba(0, 66, 218, 0.5);
  --btn-color: #ffffff;

  --typing-dot: #8a8f9c;
  --radius: 20px;
  --max-width: 620px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  color: var(--text-primary);
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(ellipse at top, var(--bg-gradient-center) 0%, var(--bg-gradient-edge) 70%) fixed,
    var(--bg-base);
}

/* ===== Área da conversa ===== */
.chat {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 16px 12px;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding-top: calc(24px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px));
}

.chat::-webkit-scrollbar { width: 6px; }
.chat::-webkit-scrollbar-track { background: transparent; }
.chat::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.08); border-radius: 3px; }
.chat::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.16); }

.msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 100%;
  animation: bubbleIn 380ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.msg--host { justify-content: flex-start; }
.msg--guest { justify-content: flex-end; margin-right: -12px; }

/* Avatar só na última mensagem consecutiva do host (estilo WhatsApp) */
.msg--host:has(+ .msg--host) .avatar { visibility: hidden; }

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 34px;
  background: #1a140c;
  align-self: flex-end;
  border: 1.5px solid var(--glass-border);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.bubble {
  padding: 12px 16px;
  border-radius: var(--radius);
  max-width: calc(84% - 42px);
  word-wrap: break-word;
  overflow-wrap: anywhere;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom-left-radius: 6px;
  font-size: 15.5px;
}
.bubble strong, .bubble b { color: var(--text-strong); font-weight: 700; }
.bubble em { color: var(--accent-3); font-style: normal; font-weight: 600; }
.bubble u { text-decoration-color: var(--accent); text-underline-offset: 3px; }

.msg--guest .bubble {
  background: linear-gradient(135deg, var(--accent-soft) 0%, var(--accent) 100%);
  border-color: rgba(255, 255, 255, 0.12);
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: 6px;
  color: #ffffff;
  max-width: 78%;
  box-shadow: 0 8px 24px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* Mídia */
.bubble--media { padding: 5px; overflow: hidden; }
.bubble--media img,
.bubble--media video {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 16px;
}
.bubble--media audio { width: 100%; min-width: 240px; display: block; }
.media-cap {
  padding: 8px 11px 5px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Card de oferta */
.bubble--pitch {
  padding: 5px 5px 0;
  border-color: rgba(255, 138, 31, 0.34);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--accent-glow),
              inset 0 1px 0 var(--glass-highlight);
  max-width: calc(92% - 42px);
}
.bubble--pitch img { display: block; width: 100%; height: auto; border-radius: 16px; }
.bubble--pitch .pitch-text { padding: 12px 12px 14px; font-size: 15px; }
.bubble--pitch .pitch-text strong { color: var(--accent-3); }

/* Typing */
.typing {
  display: inline-flex;
  gap: 5px;
  padding: 14px 18px;
  background: var(--glass-bg-solid);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  border-bottom-left-radius: 6px;
  align-items: center;
}
.typing span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--typing-dot);
  animation: typingBounce 1.3s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.18s; }
.typing span:nth-child(3) { animation-delay: 0.36s; }

.typing.is-morphing-out { opacity: 0; transform: scale(0.96); transition: opacity 180ms ease, transform 180ms ease; }
.bubble.is-morphing-in { opacity: 0; transform: translateY(4px); }
.bubble { transition: opacity 320ms ease, transform 320ms ease; }

/* Botões — sempre encostados à direita, com largura de conteúdo (nunca 100%,
   senão em telas estreitas o texto centralizado parece um botão "do meio"). */
.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
  max-width: 100%;
  padding: 2px 0 4px;
  animation: bubbleIn 380ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.button {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  color: var(--btn-color);
  background: var(--btn-bg);
  padding: 13px 20px;
  border-radius: 22px;
  box-shadow: var(--btn-glow);
  transition: background 140ms ease, transform 120ms ease, box-shadow 200ms ease;
  max-width: 100%;
  text-align: left;
  line-height: 1.35;
  letter-spacing: 0.01em;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.button:focus-visible { outline: 2px solid #9cb5ff; outline-offset: 2px; }
.button:hover { background: var(--btn-bg-hover); box-shadow: var(--btn-glow-hover); transform: translateY(-1px); }
.button:active { transform: translateY(0) scale(0.985); }
.button:disabled { opacity: 0.45; cursor: default; transform: none; }
/* Alternativa de menor peso (ex.: "tenho uma dúvida") */
.button--ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--glass-border);
  box-shadow: none;
  font-weight: 600;
}
.button--ghost:hover { background: rgba(255, 255, 255, 0.04); color: var(--text-primary); box-shadow: none; }

@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@keyframes typingBounce {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

@media (prefers-reduced-motion: reduce) {
  .msg, .buttons { animation: none; }
  .bubble, .typing.is-morphing-out { transition: none; }
  .typing span { animation: none; opacity: 0.6; }
  .chat { scroll-behavior: auto; }
}

@media (max-width: 480px) {
  .bubble { font-size: 15px; max-width: calc(88% - 42px); }
  .bubble--pitch { max-width: calc(94% - 42px); }
  .button { font-size: 14.5px; padding: 12px 18px; max-width: 92%; }
}
