:root {
  --bg: #0b0910; --surface: #15111d; --surface2: #1e1829; --line: #2c2439;
  --txt: #f3effa; --muted: #a59bb8; --roxo: #8b5cf6; --roxo2: #6d28d9; --roxo-claro: #c4b5fd;
  --erro: #f87171; --raio: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--txt); font-family: 'Sora', system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.tela { height: 100dvh; display: flex; flex-direction: column; }

/* marca */
.og { display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; background: linear-gradient(135deg, var(--roxo), var(--roxo2)); font-weight: 800; letter-spacing: -.04em; font-size: 20px; box-shadow: 0 8px 30px #7c3aed55; }
.og.pequeno { width: 38px; height: 38px; border-radius: 12px; font-size: 15px; flex: none; }

/* login */
#tela-login { justify-content: center; padding: 24px 16px calc(24px + var(--safe-b)); background: radial-gradient(120% 60% at 50% 0%, #2a174a 0%, var(--bg) 60%); overflow-y: auto; }
.login-box { width: 100%; max-width: 400px; margin: 0 auto; }
.marca { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; }
.marca b { display: block; letter-spacing: .18em; font-size: 15px; }
.marca small { color: var(--muted); letter-spacing: .14em; font-size: 10px; }
h1 { font-size: 28px; line-height: 1.15; margin: 0 0 8px; letter-spacing: -.02em; }
.sub { color: var(--muted); margin: 0 0 28px; line-height: 1.5; font-size: 15px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 16px; font-weight: 600; }
.opc { font-weight: 400; }
input { display: block; width: 100%; margin-top: 6px; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-size: 16px; outline: none; transition: border-color .15s; }
input:focus { border-color: var(--roxo); }
#in-codigo { letter-spacing: .12em; text-transform: uppercase; font-weight: 600; }
.btn { width: 100%; padding: 15px; border: 0; border-radius: 14px; background: var(--roxo); font-weight: 700; font-size: 16px; cursor: pointer; transition: transform .1s, background .15s; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; }
.btn.mini { width: auto; padding: 8px 14px; font-size: 14px; border-radius: 10px; }
.erro { color: var(--erro); font-size: 14px; min-height: 1em; margin: 0 0 12px; }

/* chat */
.topo { display: flex; align-items: center; gap: 12px; padding: calc(12px + var(--safe-t)) 16px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.topo-txt { flex: 1; min-width: 0; }
.topo-txt b { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topo-txt small { color: var(--muted); font-size: 12px; }
.icone { background: none; border: 0; font-size: 22px; padding: 4px 8px; cursor: pointer; color: var(--muted); }

.menu { position: absolute; right: 12px; top: calc(64px + var(--safe-t)); z-index: 10; background: var(--surface2); border: 1px solid var(--line); border-radius: 14px; padding: 6px; display: flex; flex-direction: column; min-width: 240px; box-shadow: 0 12px 40px #0008; }
.menu button { background: none; border: 0; text-align: left; padding: 12px 14px; border-radius: 10px; cursor: pointer; font-size: 15px; }
.menu button:hover { background: var(--line); }

.aviso { display: flex; align-items: center; gap: 10px; margin: 10px 16px 0; padding: 10px 10px 10px 14px; border-radius: 14px; background: #2a174a; border: 1px solid #4c2d85; font-size: 14px; }
.aviso span { flex: 1; line-height: 1.4; }

.lista { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; overscroll-behavior: contain; }
.dia { align-self: center; font-size: 12px; color: var(--muted); background: var(--surface); padding: 4px 12px; border-radius: 99px; margin: 10px 0 6px; }
.msg { max-width: 82%; padding: 10px 14px 6px; border-radius: var(--raio); line-height: 1.45; font-size: 15px; white-space: pre-wrap; word-wrap: break-word; animation: entra .2s ease-out; }
.msg time { display: block; text-align: right; font-size: 11px; opacity: .6; margin-top: 2px; }
.msg .quem { display: block; font-size: 12px; font-weight: 700; margin-bottom: 2px; }
.msg.cliente { align-self: flex-end; background: var(--roxo2); border-bottom-right-radius: 6px; }
.msg.ia { align-self: flex-start; background: var(--surface2); border-bottom-left-radius: 6px; }
.msg.equipe { align-self: flex-start; background: #1d1430; border: 1px solid var(--roxo); border-bottom-left-radius: 6px; }
.msg.equipe .quem { color: var(--roxo-claro); }
.msg.outro-contato { opacity: .75; }
.msg.falhou { background: #4a1d2a; }
.digitando { align-self: flex-start; background: var(--surface2); padding: 14px 16px; border-radius: var(--raio); border-bottom-left-radius: 6px; display: flex; gap: 4px; }
.digitando i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: pula 1.2s infinite; }
.digitando i:nth-child(2) { animation-delay: .15s; } .digitando i:nth-child(3) { animation-delay: .3s; }
.vazio { margin: auto; text-align: center; color: var(--muted); max-width: 300px; line-height: 1.55; font-size: 15px; }
.vazio b { color: var(--txt); display: block; font-size: 18px; margin-bottom: 6px; }

.barra { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px calc(10px + var(--safe-b)); border-top: 1px solid var(--line); background: var(--surface); }
.barra textarea { flex: 1; resize: none; border: 1px solid var(--line); background: var(--bg); border-radius: 22px; padding: 12px 16px; font-size: 16px; line-height: 1.35; max-height: 140px; outline: none; }
.barra textarea:focus { border-color: var(--roxo); }
.btn-enviar { flex: none; width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--roxo); font-size: 18px; cursor: pointer; }
.btn-enviar:disabled { opacity: .45; }

@keyframes entra { from { opacity: 0; transform: translateY(6px); } }
@keyframes pula { 0%, 60%, 100% { transform: translateY(0); opacity: .5 } 30% { transform: translateY(-4px); opacity: 1 } }
@media (min-width: 720px) { #tela-chat { max-width: 720px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); position: relative; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
