:root {
  --fundo: #ffffff;
  --lateral: #f9f9f9;
  --hover: #ececec;
  --ativo: #e3e3e3;
  --borda: #e5e5e5;
  --texto: #0d0d0d;
  --texto-2: #5d5d5d;
  --texto-3: #8f8f8f;
  --balao: #f4f4f4;
  --perigo: #e02e2a;
  --aviso: #9a5b00;
  --sombra: 0 4px 24px rgba(0, 0, 0, .08), 0 0 1px rgba(0, 0, 0, .2);
  --raio: 12px;
  --largura: 768px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--fundo); color: var(--texto);
  font: 16px/1.65 "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
svg { width: 20px; height: 20px; flex: none; }
[hidden] { display: none !important; }

/* ---------- telas de login ---------- */
.tela-central { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.cartao { width: 100%; max-width: 380px; text-align: center; }
.marca-grande { font-weight: 700; font-size: 20px; margin-bottom: 40px; letter-spacing: -.01em; }
.cartao h1 { font-size: 30px; font-weight: 600; margin: 0 0 8px; letter-spacing: -.02em; }
.cartao .sub { color: var(--texto-2); margin: 0 0 20px; }
.cartao input {
  width: 100%; padding: 14px 16px; font: inherit; border: 1px solid #c5c5c5; border-radius: 999px; margin: 6px 0 12px;
  outline: none;
}
.cartao input:focus { border-color: var(--texto); }
.botao-primario, .botao-secundario { width: 100%; padding: 14px 16px; border-radius: 999px; font-weight: 500; }
.botao-primario { background: var(--texto); color: #fff; }
.botao-primario:hover { background: #2d2d2d; }
.botao-secundario { border: 1px solid #c5c5c5; }
.botao-secundario:hover { background: var(--lateral); }
.aviso { color: var(--texto-2); min-height: 1.6em; }

/* ---------- estrutura do app ---------- */
.app { display: flex; height: 100%; }
.lateral {
  width: 260px; flex: none; background: var(--lateral); display: flex; flex-direction: column;
  padding: 8px; transition: margin-left .2s ease; border-right: 1px solid #f0f0f0;
}
.app.lateral-fechada .lateral { margin-left: -260px; }
.lateral-topo { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 8px 10px; }
.marca { display: inline-flex; align-items: center; }
.marca img { height: 12px; width: auto; display: block; }
.marca-grande img { height: 17px; width: auto; }
.icone { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px; color: var(--texto-2); }
.icone:hover { background: var(--hover); color: var(--texto); }
.item-acao {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; width: 100%; text-align: left;
  font-size: 14px;
}
.item-acao:hover { background: var(--hover); }
.busca {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 10px; color: var(--texto-2);
  font-size: 14px; margin-bottom: 8px;
}
.busca:hover, .busca:focus-within { background: var(--hover); }
.busca input { border: 0; background: none; font: inherit; outline: none; width: 100%; color: var(--texto); }
.lista { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.grupo { font-size: 12px; font-weight: 500; color: var(--texto-3); padding: 14px 10px 6px; }
.conversa-item {
  position: relative; display: flex; align-items: center; border-radius: 10px; font-size: 14px;
}
.conversa-item a {
  flex: 1; min-width: 0; padding: 8px 10px; color: var(--texto); text-decoration: none; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; mask-image: linear-gradient(90deg, #000 85%, transparent);
}
.conversa-item:hover, .conversa-item.menu-aberto { background: var(--hover); }
.conversa-item.ativa { background: var(--ativo); }
.conversa-item .mais {
  position: absolute; right: 4px; width: 28px; height: 28px; border-radius: 6px; display: none; place-items: center;
  color: var(--texto-2);
}
.conversa-item:hover .mais, .conversa-item.ativa .mais, .conversa-item.menu-aberto .mais { display: grid; }
.conversa-item:hover a, .conversa-item.ativa a, .conversa-item.menu-aberto a { padding-right: 36px; }
.conversa-item .mais:hover { color: var(--texto); }
.conversa-item input {
  flex: 1; margin: 3px 4px; padding: 5px 6px; font: inherit; border: 1px solid #9a9a9a; border-radius: 6px; outline: none;
}
.vazio-lista { font-size: 13px; color: var(--texto-3); padding: 12px 10px; }
.lateral-rodape { border-top: 1px solid #ececec; padding-top: 6px; }
.uso { font-size: 12px; color: var(--texto-3); padding: 4px 10px 6px; }
.uso.alto { color: var(--aviso); }
.usuario { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border-radius: 10px; text-align: left; }
.usuario:hover { background: var(--hover); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: #1f1f1f; color: #fff; display: grid; place-items: center;
  font-size: 13px; font-weight: 600; flex: none; text-transform: uppercase;
}
.usuario-email { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- área principal ---------- */
.principal { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100%; position: relative; }
.topo { height: 56px; display: flex; align-items: center; gap: 4px; padding: 0 10px; flex: none; }
.app:not(.lateral-fechada) #abrir-lateral { display: none; }
.titulo-produto { font-size: 17px; font-weight: 500; padding: 6px 10px; color: var(--texto); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topo-direita { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.botao-topo { display: flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; font-size: 14px; border: 1px solid var(--borda); }
.botao-topo:hover { background: var(--lateral); }
.botao-topo svg { width: 17px; height: 17px; }

.rolagem { flex: 1; overflow-y: auto; }
.mensagens { max-width: var(--largura); margin: 0 auto; padding: 16px 24px 32px; display: flex; flex-direction: column; gap: 24px; }
.msg-usuario { align-self: flex-end; max-width: 75%; background: var(--balao); border-radius: 22px; padding: 10px 18px; white-space: pre-wrap; word-wrap: break-word; }
.msg-assistente { width: 100%; }
.msg-assistente .corpo { word-wrap: break-word; }
.msg-assistente .corpo > :first-child { margin-top: 0; }
.msg-assistente .corpo > :last-child { margin-bottom: 0; }
.msg-assistente h1, .msg-assistente h2, .msg-assistente h3 { line-height: 1.3; margin: 1.4em 0 .5em; font-weight: 600; }
.msg-assistente h1 { font-size: 1.5em; } .msg-assistente h2 { font-size: 1.25em; } .msg-assistente h3 { font-size: 1.1em; }
.msg-assistente p { margin: 0 0 1em; }
.msg-assistente ul, .msg-assistente ol { padding-left: 1.6em; margin: 0 0 1em; }
.msg-assistente li { margin: .25em 0; }
.msg-assistente hr { border: 0; border-top: 1px solid var(--borda); margin: 1.5em 0; }
.msg-assistente blockquote { margin: 0 0 1em; padding-left: 1em; border-left: 3px solid var(--borda); color: var(--texto-2); }
.msg-assistente code { background: var(--balao); padding: .15em .35em; border-radius: 5px; font-size: .9em; }
.msg-assistente pre { background: #f7f7f7; border: 1px solid var(--borda); padding: 14px; border-radius: var(--raio); overflow-x: auto; }
.msg-assistente pre code { background: none; padding: 0; }
.msg-assistente table { border-collapse: collapse; margin: 0 0 1em; font-size: .95em; display: block; overflow-x: auto; }
.msg-assistente th, .msg-assistente td { border: 1px solid var(--borda); padding: 6px 10px; text-align: left; }
.msg-assistente th { background: var(--lateral); font-weight: 600; }
.msg-assistente.erro .corpo { color: var(--aviso); }
.acoes-msg { display: flex; gap: 2px; margin-top: 6px; opacity: 0; transition: opacity .15s; }
.msg-assistente:hover .acoes-msg, .msg-assistente:last-child .acoes-msg { opacity: 1; }
.acoes-msg .icone { width: 32px; height: 32px; }
.acoes-msg svg { width: 17px; height: 17px; }
.digitando { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--texto); animation: pulsar 1s infinite ease-in-out; }
@keyframes pulsar { 0%, 100% { transform: scale(.6); opacity: .5; } 50% { transform: scale(1); opacity: 1; } }

/* ---------- compositor ---------- */
.area-envio { flex: none; padding: 0 16px 8px; }
.saudacao { display: none; text-align: center; font-size: 28px; font-weight: 500; letter-spacing: -.02em; margin: 0 0 28px; }
.app.vazio .rolagem { flex: 0 1 auto; }
.app.vazio .area-envio { flex: 1; display: flex; flex-direction: column; justify-content: center; padding-bottom: 12vh; }
.app.vazio .saudacao { display: block; }
.compositor {
  max-width: var(--largura); margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; background: var(--fundo);
  border-radius: 28px; padding: 10px 10px 10px 20px; box-shadow: var(--sombra); width: 100%;
}
.compositor textarea {
  flex: 1; resize: none; border: 0; outline: none; font: inherit; line-height: 1.5; padding: 6px 0; max-height: 220px;
  background: none; color: var(--texto);
}
.enviar { width: 36px; height: 36px; border-radius: 50%; background: var(--texto); color: #fff; display: grid; place-items: center; flex: none; }
.enviar:disabled { background: #d7d7d7; cursor: default; }
.enviar svg { width: 18px; height: 18px; }
.sugestoes { display: none; max-width: var(--largura); margin: 16px auto 0; flex-wrap: wrap; justify-content: center; gap: 8px; }
.app.vazio .sugestoes { display: flex; }
.sugestoes button { border: 1px solid var(--borda); border-radius: 999px; padding: 8px 14px; font-size: 14px; color: var(--texto-2); background: var(--fundo); }
.sugestoes button:hover { background: var(--lateral); color: var(--texto); }
.acoes-msg .icone.marcado { color: var(--texto); }
.acoes-msg .icone.marcado svg path { fill: currentColor; fill-opacity: .12; }
.modal-corpo textarea { width: 100%; min-height: 90px; border: 1px solid var(--borda); border-radius: 12px; padding: 10px 12px; font: inherit; resize: vertical; outline: none; }
.modal-corpo textarea:focus { border-color: var(--texto-2); }
.rodape { text-align: center; font-size: 12px; color: var(--texto-3); margin: 8px 0 0; }
.rodape a, .legal-login a, .compartilhado-sub a { color: inherit; }
.legal-login { font-size: 12px; color: var(--texto-3); margin-top: 24px; }
.legal-login a { color: var(--texto-2); }

/* ---------- menus, modal, aviso ---------- */
.menu {
  position: fixed; z-index: 50; min-width: 200px; background: var(--fundo); border-radius: 16px; padding: 6px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .14), 0 0 1px rgba(0, 0, 0, .25);
}
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 10px; font-size: 14px; text-align: left; }
.menu button:hover { background: var(--lateral); }
.menu button svg { width: 18px; height: 18px; }
.menu .perigo { color: var(--perigo); }
.menu .separador { height: 1px; background: var(--borda); margin: 4px 8px; }
.modal-fundo { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 60; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--fundo); border-radius: 18px; width: 100%; max-width: 480px; box-shadow: var(--sombra); }
.modal-topo { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 8px 24px; }
.modal-topo h3 { margin: 0; font-size: 18px; font-weight: 600; }
.modal-corpo { padding: 4px 24px 8px; color: var(--texto-2); }
.modal-corpo p { margin: 0 0 12px; }
.modal-botoes { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 24px 20px; }
.modal-botoes button { padding: 9px 16px; border-radius: 999px; font-size: 14px; font-weight: 500; border: 1px solid var(--borda); }
.modal-botoes .primario { background: var(--texto); color: #fff; border-color: var(--texto); }
.modal-botoes .perigo { background: var(--perigo); color: #fff; border-color: var(--perigo); }
.link-copia { display: flex; gap: 8px; border: 1px solid var(--borda); border-radius: 999px; padding: 6px 6px 6px 16px; align-items: center; }
.link-copia input { flex: 1; border: 0; outline: none; font: inherit; font-size: 14px; color: var(--texto-2); min-width: 0; background: none; }
.link-copia button { background: var(--texto); color: #fff; border-radius: 999px; padding: 8px 14px; font-size: 14px; white-space: nowrap; }
.arquivadas-lista { max-height: 50vh; overflow-y: auto; margin: 0 -8px; }
.arquivada { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 10px; }
.arquivada:hover { background: var(--lateral); }
.arquivada span { flex: 1; color: var(--texto); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--texto); color: #fff; z-index: 70;
  padding: 10px 18px; border-radius: 999px; font-size: 14px; box-shadow: var(--sombra);
}
.veu { display: none; }

/* ---------- celular ---------- */
@media (max-width: 768px) {
  .lateral { position: fixed; z-index: 40; inset: 0 auto 0 0; box-shadow: var(--sombra); }
  .app.lateral-fechada .lateral { margin-left: -280px; }
  .app:not(.lateral-fechada) .veu { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .3); z-index: 30; }
  #abrir-lateral { display: grid !important; }
  .mensagens { padding: 12px 16px 24px; }
  .msg-usuario { max-width: 88%; }
  .botao-topo span { display: none; }
  .saudacao { font-size: 24px; }
}
