:root {
  --fundo: #f5f4ef; --cartao: #ffffff; --texto: #1b1d22; --suave: #5f6672; --linha: #e2dfd5;
  --ouro: #9a7421; --ouro-fundo: #f3ead3; --verde: #1c8a52; --amarelo: #a86d12; --vermelho: #c23636; --azul: #2a66a8; --cinza: #8a909b;
  --minha: #1f2a3a; --minha-texto: #f4f5f7;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #0f1115; --cartao: #171a20; --texto: #eceef2; --suave: #9aa3b2; --linha: #272c35;
    --ouro: #dcb65f; --ouro-fundo: #2a2416; --verde: #3fc27f; --amarelo: #e3a43c; --vermelho: #f06a6a; --azul: #6aa7e8; --cinza: #7c8491;
    --minha: #2a3547; --minha-texto: #f4f5f7;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--fundo); color: var(--texto);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column; min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
}
h1, h2 { margin: 0; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 1.5rem; }
h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ouro); }
p { margin: 0 0 0.6em; }
[hidden] { display: none !important; }
.suave { color: var(--suave); font-size: 0.875rem; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--ouro); outline-offset: 2px; }

.placa { background: #fff; border-radius: 10px; padding: 3px 6px; display: inline-flex; line-height: 0; flex: none; }
.placa img { width: 58px; height: auto; }
.placa.grande { padding: 8px 14px; border: 1px solid var(--linha); }
.placa.grande img { width: 150px; }

.botao { border: 1px solid var(--linha); background: var(--cartao); border-radius: 10px; padding: 0.55em 0.9em; min-height: 44px; }
.botao.cheio { background: var(--ouro); border-color: var(--ouro); color: #14110a; font-weight: 600; }
@media (prefers-color-scheme: light) { .botao.cheio { color: #fff; } }
.botao.discreto { border-color: transparent; background: none; color: var(--suave); }
.botao:disabled { opacity: 0.5; cursor: default; }
.icone { border: 0; background: none; font-size: 1.4rem; min-width: 44px; min-height: 44px; border-radius: 10px; }

/* topo */
.topo { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--linha); background: var(--cartao); position: sticky; top: 0; z-index: 3; padding-top: max(10px, env(safe-area-inset-top)); }
.titulo { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.titulo strong { font-size: 1.05rem; letter-spacing: 0.02em; }
.pulso { font-size: 0.8rem; color: var(--suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pulso::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--cinza); margin-right: 6px; }
.pulso.bom::before { background: var(--verde); }
.pulso.ruim { color: var(--vermelho); font-weight: 600; }
.pulso.ruim::before { background: var(--vermelho); }

/* menu */
.menu { position: fixed; inset: 0 0 0 auto; width: min(340px, 88vw); background: var(--cartao); border-left: 1px solid var(--linha); z-index: 5; padding: 76px 16px 16px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; box-shadow: -12px 0 40px rgb(0 0 0 / 0.25); }
.lista-conversas { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.item-conversa { width: 100%; text-align: left; border: 0; background: none; padding: 10px 8px; border-radius: 8px; display: flex; flex-direction: column; min-height: 44px; }
.item-conversa:hover { background: var(--fundo); }
.item-conversa span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-fim { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
#btn-menu { position: relative; z-index: 6; }

/* abas */
main { flex: 1; min-height: 0; display: flex; }
.aba { display: none; flex: 1; min-width: 0; flex-direction: column; padding: 16px; max-width: 760px; margin: 0 auto; width: 100%; }
.aba.ativa { display: flex; }
.abas { display: flex; border-top: 1px solid var(--linha); background: var(--cartao); position: sticky; bottom: 0; z-index: 3; padding-bottom: env(safe-area-inset-bottom); }
.abas button { flex: 1; border: 0; background: none; padding: 12px 4px; min-height: 52px; color: var(--suave); border-top: 2px solid transparent; }
.abas button.ativa { color: var(--texto); font-weight: 600; border-top-color: var(--ouro); }
.selo { background: var(--vermelho); color: #fff; border-radius: 999px; font-size: 0.75rem; padding: 1px 7px; margin-left: 4px; }

/* conversa */
#aba-conversa { padding-bottom: 0; }
.falas { flex: 1; display: flex; flex-direction: column; gap: 12px; padding-bottom: 12px; }
.fala { max-width: 92%; }
.fala .corpo { padding: 10px 14px; border-radius: 16px; overflow-wrap: anywhere; }
.fala.efraim { align-self: flex-end; }
.fala.efraim .corpo { background: var(--minha); color: var(--minha-texto); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.fala.maestro { align-self: flex-start; }
.fala.maestro .corpo { background: var(--cartao); border: 1px solid var(--linha); border-bottom-left-radius: 4px; }
.fala.maestro .corpo:empty { display: none; }
.fala .corpo p:last-child, .fala .corpo ul:last-child { margin-bottom: 0; }
.fala .corpo ul { margin: 0 0 0.6em; padding-left: 1.2em; }
.fala .corpo li { margin-bottom: 0.25em; }
.fala .corpo code { font-family: ui-monospace, Consolas, monospace; font-size: 0.9em; background: var(--fundo); padding: 1px 5px; border-radius: 5px; }
.titulo-fala { font-weight: 700; }
.estado { font-size: 0.8rem; color: var(--ouro); padding: 4px 6px; }
.sugestoes { display: flex; flex-wrap: wrap; gap: 8px; margin: auto 0 16px; }
.sugestoes p { width: 100%; color: var(--suave); margin: 0 0 4px; }
.chip { border: 1px solid var(--linha); background: var(--cartao); border-radius: 999px; padding: 8px 14px; min-height: 40px; text-align: left; }
.chip:hover { border-color: var(--ouro); }
.escrever { display: flex; gap: 8px; align-items: flex-end; position: sticky; bottom: 53px; background: var(--fundo); padding: 10px 0 12px; }
.escrever textarea { flex: 1; resize: none; border: 1px solid var(--linha); background: var(--cartao); border-radius: 14px; padding: 10px 14px; min-height: 44px; max-height: 160px; }
.escrever .botao { min-width: 48px; }

/* equipe */
.barra { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.barra input { flex: 1; min-width: 0; border: 1px solid var(--linha); background: var(--cartao); border-radius: 10px; padding: 0.55em 0.8em; min-height: 44px; }
.grupo { margin-bottom: 24px; }
.grupo > p { margin-bottom: 8px; }
.agente { background: var(--cartao); border: 1px solid var(--linha); border-left: 4px solid var(--cinza); border-radius: 10px; margin-bottom: 8px; }
.agente summary { padding: 12px 14px; list-style: none; cursor: pointer; }
.agente summary::-webkit-details-marker { display: none; }
.agente .linha { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.agente .ponto { width: 10px; height: 10px; border-radius: 50%; background: var(--cinza); flex: none; }
.etiqueta { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; border: 1px solid var(--linha); border-radius: 999px; padding: 1px 8px; color: var(--suave); white-space: nowrap; }
.agente .linha .etiqueta { margin-left: auto; }
.agente .papel { color: var(--suave); font-size: 0.9rem; }
.agente .resumo { font-size: 0.875rem; font-variant-numeric: tabular-nums; margin-top: 2px; }
.agente .descricao, .agente .detalhes { margin: 0 14px 12px; font-size: 0.9rem; color: var(--suave); }
.agente .detalhes { padding-left: 1.1em; }
.agente.no_ar { border-left-color: var(--verde); } .agente.no_ar .ponto { background: var(--verde); }
.agente.agendado { border-left-color: var(--azul); } .agente.agendado .ponto { background: var(--azul); }
.agente.pausado { border-left-color: var(--amarelo); } .agente.pausado .ponto { background: var(--amarelo); }
.agente.falha { border-left-color: var(--vermelho); } .agente.falha .ponto { background: var(--vermelho); }
.agente.falha .resumo { color: var(--vermelho); font-weight: 600; }
.agente.sob_demanda { border-left-color: var(--ouro); } .agente.sob_demanda .ponto { background: var(--ouro); }
.sub { margin: 8px 0; }
.mudancas, .memorias { list-style: none; margin: 0; padding: 0; }
.mudancas li { font-size: 0.875rem; color: var(--suave); padding: 4px 0; border-bottom: 1px solid var(--linha); font-variant-numeric: tabular-nums; }
.rodape { margin: 16px 0; }
.memorias li { background: var(--cartao); border: 1px solid var(--linha); border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; }
.memorias li p { margin: 6px 0 0; overflow-wrap: anywhere; }

/* telas de acesso */
body.acesso { align-items: center; justify-content: center; padding: 16px; }
.cartao-acesso { background: var(--cartao); border: 1px solid var(--linha); border-radius: 16px; padding: 28px 24px; width: 100%; max-width: 380px; text-align: center; }
.cartao-acesso.largo { max-width: 460px; }
.cartao-acesso h1 { margin-top: 14px; }
.cartao-acesso h2 { margin: 22px 0 6px; text-align: left; }
.cartao-acesso form { text-align: left; margin-top: 18px; display: flex; flex-direction: column; gap: 6px; }
.cartao-acesso label { font-size: 0.875rem; color: var(--suave); margin-top: 8px; }
.cartao-acesso input { border: 1px solid var(--linha); background: var(--fundo); border-radius: 10px; padding: 0.65em 0.8em; min-height: 46px; width: 100%; }
.cartao-acesso .botao { margin-top: 16px; }
.erro { color: var(--vermelho); font-weight: 600; margin: 8px 0 0; }
.qr { background: #fff; border-radius: 12px; padding: 10px; width: 240px; max-width: 100%; margin: 6px auto; line-height: 0; }
.qr svg { width: 100%; height: auto; }
.segredo { font-family: ui-monospace, Consolas, monospace; font-size: 1.05rem; letter-spacing: 0.06em; text-align: center; background: var(--fundo); border-radius: 10px; padding: 10px; overflow-wrap: anywhere; user-select: all; }

@media (min-width: 720px) {
  .aba { padding: 24px 16px; }
  .fala { max-width: 80%; }
}
