/* O atributo hidden sempre esconde, mesmo em elementos com display próprio (ex.: o chat). */
[hidden] { display: none !important; }

:root {
  --fundo: #f7f6f3;
  --texto: #1d1d1f;
  --suave: #5c5c63;
  --destaque: #1f5f8b;
  --destaque-texto: #ffffff;
  --borda: #d6d4cf;
  --erro: #a3261c;
  --cartao: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #141416;
    --texto: #ececef;
    --suave: #a6a6ad;
    --destaque: #5fa8d8;
    --destaque-texto: #0b1a24;
    --borda: #35353b;
    --erro: #ff8a80;
    --cartao: #1e1e22;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--fundo);
  color: var(--texto);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 30rem; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
h2 { font-size: 1.2rem; }
.aviso-teste, .pequeno { color: var(--suave); font-size: .9rem; }
section { background: var(--cartao); border: 1px solid var(--borda); border-radius: 12px; padding: 1.25rem; margin-top: 1rem; }
label { display: block; margin-bottom: .9rem; font-weight: 600; }
input {
  display: block; width: 100%; margin-top: .3rem; padding: .75rem;
  font: inherit; color: inherit; background: var(--fundo);
  border: 1px solid var(--borda); border-radius: 8px;
}
button {
  font: inherit; font-weight: 600; cursor: pointer; border: 0; border-radius: 10px;
  padding: .8rem 1.1rem; background: var(--destaque); color: var(--destaque-texto); width: 100%;
}
button:disabled { opacity: .55; cursor: not-allowed; }
button.secundario { background: transparent; color: var(--destaque); border: 1px solid var(--borda); margin-top: .75rem; }
button.link { background: none; color: var(--destaque); padding: 0; width: auto; text-decoration: underline; }
button.falar { padding: 1.4rem; font-size: 1.15rem; border-radius: 999px; margin: .5rem 0; }
details { margin-top: 1rem; }
.erro { color: var(--erro); font-weight: 600; min-height: 1.5em; }

/* ---------- Chat ---------- */
:root { --bolha-minha: #1f5f8b; --bolha-minha-texto: #ffffff; --bolha-parceiro: #ffffff; }
@media (prefers-color-scheme: dark) {
  :root { --bolha-minha: #2b6f9e; --bolha-minha-texto: #ffffff; --bolha-parceiro: #26262b; }
}
body.modo-chat main { max-width: 40rem; padding: 0; height: 100dvh; display: flex; flex-direction: column; }
body.modo-chat main > h1, body.modo-chat main > .aviso-teste { display: none; }
section.chat {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  margin: 0; border: 0; border-radius: 0; padding: 0; background: var(--fundo);
}
.chat-topo {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1rem; border-bottom: 1px solid var(--borda); background: var(--cartao); font-weight: 600;
}
.menu { position: relative; margin: 0; }
.menu summary { list-style: none; cursor: pointer; font-size: 1.4rem; line-height: 1; padding: .2rem .5rem; }
.menu summary::-webkit-details-marker { display: none; }
.menu-itens {
  position: absolute; right: 0; top: 2.2rem; width: 16rem; z-index: 5;
  background: var(--cartao); border: 1px solid var(--borda); border-radius: 12px; padding: .9rem;
  box-shadow: 0 6px 24px rgb(0 0 0 / .15); font-weight: 400;
}
.mensagens {
  flex: 1; min-height: 0; overflow-y: auto; padding: 1rem;
  display: flex; flex-direction: column; gap: .6rem; overscroll-behavior: contain;
}
#mais-antigas { align-self: center; font-size: .9rem; }
.bolha {
  max-width: 85%; padding: .65rem .9rem; border-radius: 16px;
  white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45;
}
.bolha.minha { align-self: flex-end; background: var(--bolha-minha); color: var(--bolha-minha-texto); border-bottom-right-radius: 4px; }
.bolha.parceiro { align-self: flex-start; background: var(--bolha-parceiro); border: 1px solid var(--borda); border-bottom-left-radius: 4px; }
.bolha[data-modo="voz"]::before { content: "🎤 "; }
.bolha.digitando:empty::after { content: "digitando…"; color: var(--suave); font-style: italic; }
.bolha.falha { color: var(--erro); }
.compositor {
  display: flex; align-items: flex-end; gap: .5rem;
  padding: .6rem .75rem calc(.6rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--borda); background: var(--cartao);
}
.compositor textarea {
  flex: 1; resize: none; min-height: 2.75rem; max-height: 140px; padding: .65rem .8rem;
  font: inherit; color: inherit; background: var(--fundo); border: 1px solid var(--borda); border-radius: 20px;
}
button.icone { width: 2.75rem; height: 2.75rem; padding: 0; border-radius: 50%; flex: none; font-size: 1.1rem; }
#falar.icone { background: transparent; border: 1px solid var(--borda); }
.estado { margin: 0; padding: 0 1rem .4rem; background: var(--cartao); }
.estado:empty { display: none; }

/* Campo de senha com botão Mostrar/Ocultar */
.campo-senha { display: flex; gap: .4rem; align-items: stretch; margin-top: .3rem; }
.campo-senha input { margin-top: 0; flex: 1; }
button.ver-senha {
  width: auto; flex: none; padding: 0 .8rem; font-size: .9rem; font-weight: 600;
  background: transparent; color: var(--destaque); border: 1px solid var(--borda); border-radius: 8px;
}
