:root {
  --roxo: #4A1A8C;
  --roxo-escuro: #2E0F5C;
  --roxo-claro: #7B45D6;
  --amarelo: #FFC928;
  --amarelo-escuro: #E0A800;
  --fundo-chat: #F6F3FB;
  --texto: #1F1630;
  --texto-suave: #6B6380;
  --borda: #E6E0F0;
  --erro: #C62828;
  --raio: 22px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--texto);
  background: radial-gradient(120% 120% at 0% 0%, var(--roxo-claro) 0%, var(--roxo) 45%, var(--roxo-escuro) 100%);
  background-color: var(--roxo);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
svg { width: 1em; height: 1em; fill: currentColor; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }

/* Formas decorativas */
.bg-shapes { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.shape { position: absolute; border-radius: 50%; filter: blur(2px); }
.s1 { width: 520px; height: 520px; right: -160px; top: -180px; background: var(--amarelo); opacity: .16; }
.s2 { width: 320px; height: 320px; left: -120px; bottom: -120px; background: var(--amarelo); opacity: .12; }
.s3 { width: 140px; height: 140px; left: 38%; top: 12%; border: 18px solid var(--amarelo); opacity: .10; }

/* Layout */
.layout {
  position: relative;
  height: 100dvh;
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr minmax(380px, 520px);
  gap: 56px;
  align-items: center;
  padding: 32px 40px;
}

/* Lado da marca */
.brand-side { color: #fff; max-width: 480px; }
.logo { display: flex; align-items: center; gap: 12px; margin-bottom: 48px; }
.logo-mark {
  width: 56px; height: 56px; border-radius: 16px;
  display: grid; place-items: center;
  background: #fff; color: var(--roxo-escuro);
  font-weight: 800; font-size: 26px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.logo-mark img { width: 42px; height: auto; display: block; }
.avatar img { width: 30px; height: auto; display: block; }
.logo-text { font-size: 26px; font-weight: 500; letter-spacing: -.5px; }
.logo-text strong { font-weight: 800; color: var(--amarelo); }
.logo-big { display: block; width: 260px; max-width: 100%; height: auto; margin: 0 0 40px -6px; }
.brand-side h1 { font-size: clamp(38px, 4.6vw, 58px); line-height: 1.02; font-weight: 800; letter-spacing: -1.5px; }
.hl { color: var(--amarelo); }
.lead { margin-top: 18px; font-size: 17px; line-height: 1.55; color: rgba(255,255,255,.82); max-width: 400px; }
.features { list-style: none; margin-top: 36px; display: grid; gap: 14px; }
.features li {
  display: flex; gap: 14px; align-items: center;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12);
  padding: 14px 16px; border-radius: 16px; backdrop-filter: blur(6px);
}
.f-icon {
  flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--amarelo); color: var(--roxo-escuro); font-size: 20px;
}
.f-icon svg, .quick .q-icon svg { width: 22px; height: 22px; }
.features strong { display: block; font-size: 15px; }
.features span { font-size: 13px; color: rgba(255,255,255,.72); }
.foot { margin-top: 40px; font-size: 12px; color: rgba(255,255,255,.5); }

/* Card do chat */
.chat-card {
  height: min(780px, calc(100dvh - 64px));
  background: #fff;
  border-radius: var(--raio);
  box-shadow: 0 30px 80px rgba(20, 5, 45, .45);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: rise .5s cubic-bezier(.2,.8,.2,1);
}
@keyframes rise { from { opacity: 0; transform: translateY(24px) scale(.98); } to { opacity: 1; transform: none; } }

.chat-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, var(--roxo) 0%, var(--roxo-claro) 100%);
  color: #fff;
  border-bottom: 4px solid var(--amarelo);
  flex: none;
}
.avatar {
  position: relative; width: 44px; height: 44px; border-radius: 50%;
  background: #fff; color: var(--roxo-escuro);
  display: grid; place-items: center; font-weight: 800; font-size: 20px;
}
.dot {
  position: absolute; right: 0; bottom: 0; width: 12px; height: 12px; border-radius: 50%;
  background: #2ECC71; border: 2px solid var(--roxo);
}
.dot.off { background: #B0A8C0; }
.hd-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.hd-text strong { font-size: 16px; }
.hd-text span { font-size: 12.5px; color: rgba(255,255,255,.8); }
.hd-btn {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: rgba(255,255,255,.12); font-size: 18px; transition: background .2s;
}
.hd-btn:hover { background: rgba(255,255,255,.22); }

/* Etapa 1 - identificação */
.intake { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--fundo-chat); }
.messages {
  flex: 1; overflow-y: auto; padding: 22px 18px 8px;
  display: flex; flex-direction: column; gap: 10px;
  scroll-behavior: smooth;
}
.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-thumb { background: #D8CFE8; border-radius: 3px; }

.msg {
  max-width: 82%; padding: 11px 15px; border-radius: 18px;
  font-size: 15px; line-height: 1.45; word-wrap: break-word;
  animation: pop .28s cubic-bezier(.2,.8,.2,1);
}
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg.bot { align-self: flex-start; background: #fff; border: 1px solid var(--borda); border-bottom-left-radius: 6px; }
.msg.user { align-self: flex-end; background: var(--roxo); color: #fff; border-bottom-right-radius: 6px; }
.msg.err { align-self: flex-start; background: #FDECEC; color: var(--erro); border: 1px solid #F5C6C6; border-bottom-left-radius: 6px; }
.msg strong { font-weight: 700; }

.typing { align-self: flex-start; background: #fff; border: 1px solid var(--borda); border-radius: 18px; border-bottom-left-radius: 6px; padding: 14px 16px; display: flex; gap: 5px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--roxo-claro); opacity: .4; animation: blink 1.1s infinite; }
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.quick { padding: 6px 18px 12px; display: grid; gap: 10px; }
.quick button {
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 14px 16px; border-radius: 16px; background: #fff;
  border: 2px solid var(--borda); transition: border-color .2s, transform .15s, box-shadow .2s;
  animation: pop .3s cubic-bezier(.2,.8,.2,1) both;
}
.quick button:hover, .quick button:focus-visible { border-color: var(--amarelo); box-shadow: 0 6px 18px rgba(74,26,140,.12); transform: translateY(-1px); outline: none; }
.quick .q-icon { flex: none; width: 40px; height: 40px; border-radius: 12px; background: var(--roxo); color: var(--amarelo); display: grid; place-items: center; font-size: 20px; }
.quick strong { display: block; font-size: 15px; color: var(--roxo-escuro); }
.quick span { font-size: 13px; color: var(--texto-suave); }
.quick .q-arrow { margin-left: auto; color: var(--roxo-claro); font-size: 18px; }

.composer {
  flex: none; display: flex; gap: 10px; align-items: center;
  margin: 8px 14px 6px; padding: 6px 6px 6px 18px;
  background: #fff; border: 2px solid var(--borda); border-radius: 999px;
  transition: border-color .2s, box-shadow .2s;
}
.composer:focus-within { border-color: var(--roxo-claro); box-shadow: 0 0 0 4px rgba(123,69,214,.12); }
.composer input { flex: 1; min-width: 0; border: 0; outline: 0; font: inherit; font-size: 16px; background: transparent; color: var(--texto); padding: 8px 0; }
.composer.disabled { opacity: .5; pointer-events: none; }
.send {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  background: var(--amarelo); color: var(--roxo-escuro); display: grid; place-items: center; font-size: 20px;
  transition: transform .15s, background .2s;
}
.send:hover { background: var(--amarelo-escuro); }
.send:active { transform: scale(.92); }
.privacy { flex: none; text-align: center; font-size: 11.5px; color: var(--texto-suave); padding: 2px 16px 12px; }

/* Etapa 2 - chat do Upchat */
.live { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--fundo-chat); }
.live-bar {
  flex: none; display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 8px 14px; font-size: 12.5px; color: var(--texto-suave);
  background: #fff; border-bottom: 1px solid var(--borda);
}
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: #F1EAFB; color: var(--roxo); font-weight: 600; }
.tag.y { background: #FFF4D1; color: #7A5A00; }
.frame-wrap { position: relative; flex: 1; min-height: 0; }
.frame-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.connecting {
  position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; gap: 14px;
  align-items: center; justify-content: center; background: var(--fundo-chat); color: var(--texto-suave); font-size: 14px; text-align: center; padding: 24px;
  transition: opacity .35s;
}
.connecting.hide { opacity: 0; pointer-events: none; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid #E3D8F5; border-top-color: var(--roxo); border-right-color: var(--amarelo); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Tablet */
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; gap: 0; padding: 24px; justify-items: center; }
  .brand-side { display: none; }
  .chat-card { width: 100%; max-width: 560px; height: calc(100dvh - 48px); }
}

/* Celular: chat em tela cheia */
@media (max-width: 600px) {
  body { background: var(--roxo); }
  .bg-shapes { display: none; }
  .layout { padding: 0; height: 100dvh; }
  .chat-card { max-width: none; height: 100dvh; border-radius: 0; box-shadow: none; animation: none; }
  .chat-header { padding: calc(12px + env(safe-area-inset-top)) 14px 12px; }
  .msg { max-width: 88%; }
  .composer { margin: 8px 10px calc(4px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Logo no topo do chat (sem fundo) */
.hd-logo { height: 40px; width: auto; display: block; }
.hd-status { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: rgba(255,255,255,.85); text-align: right; }
.hd-status .dot { position: static; flex: none; width: 10px; height: 10px; border: 0; box-shadow: 0 0 0 3px rgba(46,204,113,.25); }
.hd-status .dot.off { box-shadow: 0 0 0 3px rgba(176,168,192,.25); }
@media (max-width: 600px) { .hd-logo { height: 34px; } .hd-status { font-size: 11.5px; max-width: 60%; } }

/* Lado esquerdo centralizado ao lado do chat */
.brand-side { justify-self: center; text-align: center; display: flex; flex-direction: column; align-items: center; }
.brand-side .logo-big { margin: 0 0 40px; width: 300px; }
.brand-side .lead { margin-left: auto; margin-right: auto; }
@media (max-width: 960px) { .brand-side { display: none; } }
