/* ---------------- tela de login ----------------
   Tela dividida: metade da marca com o degrade em tamanho grande, metade do
   formulario. E o unico lugar onde a marca grita - e a primeira coisa que um
   amigo convidado ve. Dentro do app ela fica quieta. Abaixo de 900px vira
   uma coluna so e o painel da marca encolhe para uma faixa.
   ------------------------------------------------ */
#auth-screen { overflow: auto; background: var(--chat); }

.auth-split { min-height: 100%; display: flex; }

.auth-marca {
  width: 56%;
  flex: 0 0 56%;
  position: relative;
  overflow: hidden;
  padding: 64px 72px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 40px;
  background:
    radial-gradient(circle at 16% 14%, rgba(228, 149, 249, 0.55) 0%, transparent 44%),
    radial-gradient(circle at 84% 82%, rgba(76, 28, 212, 0.7) 0%, transparent 52%),
    linear-gradient(148deg, #9545f3 0%, #7c2ff0 34%, #4c1cd4 66%, #14102a 100%);
}
/* dois halos: profundidade sem precisar de imagem */
.auth-marca::before,
.auth-marca::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}
.auth-marca::before {
  left: -80px; top: 120px; width: 380px; height: 380px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 62%);
}
.auth-marca::after {
  right: -60px; bottom: 40px; width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(228, 149, 249, 0.16) 0%, transparent 64%);
}

.auth-logo {
  position: relative;
  display: flex; align-items: center; gap: 16px;
  font-family: var(--font-display);
  font-size: 30px; font-weight: 700; letter-spacing: 0.06em;
  color: #fff;
}
.auth-logo .mark {
  width: 56px; height: 56px;
  border-radius: 18px;
  display: block;
}

.auth-promessa { position: relative; max-width: 560px; }
.auth-promessa h1 {
  font-family: var(--font-display);
  font-size: 54px; line-height: 1.08; font-weight: 700;
  color: #fff; letter-spacing: -0.02em;
  text-wrap: balance;
}
.auth-promessa p {
  margin-top: 20px;
  font-size: 18px; line-height: 1.5;
  color: rgba(255, 255, 255, 0.78);
  max-width: 460px;
  text-wrap: pretty;
}

.auth-vitrine { position: relative; }
.auth-vitrine .vitrine-linha { display: flex; align-items: center; gap: 22px; }
.auth-vitrine .vitrine-item {
  position: relative;
  display: inline-block;
  width: 62px; height: 62px;
  flex: 0 0 62px;
}
.auth-vitrine .vitrine-item .avatar { width: 62px; height: 62px; }
.auth-vitrine .vitrine-item .moldura {
  position: absolute;
  left: 50%; top: 50%;
  width: min(calc(100% / var(--furo, .65)), 160%);
  height: min(calc(100% / var(--furo, .65)), 160%);
  max-width: none;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.auth-vitrine p {
  margin-top: 26px;
  font-size: var(--fs-ui); font-weight: 500;
  color: rgba(255, 255, 255, 0.72);
}

.auth-lado {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 48px;
  min-width: 0;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  animation: pop-in 0.25s ease;
}
.auth-brand { margin-bottom: 28px; }
.auth-brand h1 {
  font-family: var(--font-display);
  font-size: var(--fs-display); font-weight: 700; color: var(--text-bright);
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.auth-brand p { color: var(--text-muted); font-size: var(--fs-msg); margin-top: 8px; }

@media (max-width: 900px) {
  .auth-split { flex-direction: column; }
  .auth-marca {
    width: 100%; flex: 0 0 auto;
    padding: 40px 32px;
    gap: 24px;
  }
  .auth-marca::before, .auth-marca::after { display: none; }
  .auth-promessa h1 { font-size: 34px; }
  .auth-promessa p { font-size: 16px; margin-top: 14px; }
  .auth-vitrine { display: none; }
  .auth-lado { padding: 32px 24px 48px; }
}

.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: var(--fs-sm); font-weight: 600;
  color: var(--text); margin-bottom: 6px;
}
.field label .req { color: var(--red); }
.field input, .field textarea, .field select {
  width: 100%;
  background: var(--input-alt);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--text-bright);
  font-size: var(--fs-ui);
  outline: none;
  transition: border-color var(--t-toque) ease, box-shadow var(--t-toque) ease;
}
.field input::placeholder, .field textarea::placeholder { color: var(--text-faint); }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(149, 69, 243, 0.18);
}
.field textarea { resize: vertical; min-height: 72px; font-family: inherit; line-height: 1.45; }
.field .help { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 6px; }
.field.invalid label { color: var(--red); }
.field.invalid input { border-color: var(--red); }

/* um so botao cheio por tela, solido; o resto e secundario */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border-radius: var(--radius);
  background: var(--brand); color: #fff;
  font-size: var(--fs-ui); font-weight: 600;
  transition: background var(--t-toque) ease, filter var(--t-toque) ease;
  white-space: nowrap;
}
.btn:hover { background: var(--brand-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }
.btn.block { width: 100%; }
.btn.sm { height: 32px; font-size: var(--fs-sm); padding: 0 12px; }
.btn.secondary { background: var(--input); color: var(--text-bright); }
.btn.secondary:hover { background: var(--active); }
.btn.ghost { background: none; color: var(--text-bright); }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: var(--danger-hover); }
.btn.green { background: var(--green); }
.btn.green:hover { filter: brightness(1.1); }

.auth-switch { margin-top: 12px; font-size: var(--fs-sm); color: var(--text-muted); }
.auth-switch button { color: var(--link); font-size: var(--fs-sm); font-weight: 500; }
.auth-switch button:hover { text-decoration: underline; }

.form-error {
  background: rgba(239, 75, 79, 0.1);
  border: 1px solid rgba(239, 75, 79, 0.5);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--red);
  font-size: var(--fs-sm);
  margin-bottom: 16px;
}

/* ---------------- modais ---------------- */
#modal-root {
  position: fixed; inset: 0;
  z-index: 100;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(8, 9, 11, 0.72);
  padding: 24px;
  animation: fade-in 0.15s ease;
}
:root[data-theme="light"] #modal-root { background: rgba(15, 16, 19, 0.4); }
#modal-root.open { display: flex; }

.modal {
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  background: var(--modal);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-high);
  display: flex; flex-direction: column;
  animation: pop-in 0.2s var(--curva-saida);
  overflow: hidden;
}
/*
 * Os paineis sao nomeados um a um de proposito: o botao de fechar tambem e
 * filho direto do modal, e um "> *" pintaria um quadrado solido atras dele.
 * O :first-of-type resolve o canto de cima sozinho - se o cabecalho existe,
 * ele e a primeira div e o corpo nao pega o arredondamento.
 */
.modal-head, .modal-body { background: var(--modal); }
.modal-head, .modal-body:first-of-type { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.modal-body:last-of-type { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.modal.wide { max-width: 660px; }
.modal-head { padding: 24px 24px 4px; text-align: center; }
.modal-head.left { text-align: left; }
.modal-head h2 { font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--text-bright); letter-spacing: -0.01em; }
.modal-head p { font-size: var(--fs-ui); color: var(--text-muted); margin-top: 6px; }
.modal-body { padding: 16px 24px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 14px 24px;
  background: var(--modal-alt);
  border-top: 1px solid var(--divider);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
}
.modal-foot .spacer { flex: 1; }

.modal-close {
  position: absolute; top: 12px; right: 12px;
  width: 32px; height: 32px; border-radius: var(--radius);
  display: grid; place-items: center;
  color: var(--text-muted);
  transition: background var(--t-toque) ease, color var(--t-toque) ease;
}
.modal-close:hover { color: var(--text-bright); background: var(--hover); }
.modal { position: relative; }

.choice-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--modal-alt);
  border: 1px solid var(--divider);
  border-radius: var(--radius-lg);
  margin-bottom: 8px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background var(--t-toque) ease, border-color var(--t-toque) ease;
}
.choice-row:hover { background: var(--hover); border-color: var(--text-faint); }
.choice-row .icon { width: 40px; height: 40px; border-radius: var(--radius); background: var(--input); display: grid; place-items: center; color: var(--text-bright); flex: 0 0 40px; }
.choice-row .txt { flex: 1; min-width: 0; }
.choice-row .txt strong { display: block; color: var(--text-bright); font-size: var(--fs-msg); font-weight: 600; }
.choice-row .txt span { font-size: var(--fs-sm); color: var(--text-muted); }

.radio-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius); cursor: pointer;
}
.radio-row:hover { background: var(--hover); }
.radio-row input { accent-color: var(--brand); width: 18px; height: 18px; }

.copy-row { display: flex; gap: 8px; }
.copy-row input {
  flex: 1; background: var(--input-alt); border: 1px solid var(--divider); border-radius: var(--radius);
  padding: 9px 12px; color: var(--text-bright); font-family: var(--mono); font-size: var(--fs-sm);
}

.color-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.color-swatch {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid transparent;
}
.color-swatch.active { border-color: var(--text-bright); }

/* ---------------- menu de contexto / popovers ---------------- */
.popover {
  position: fixed;
  z-index: 200;
  background: var(--modal);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-high);
  padding: 4px;
  min-width: 200px;
  animation: abre-popover var(--t-abre) var(--curva-saida);
  transform-origin: top left;
}
@keyframes abre-popover {
  from { opacity: 0; transform: scale(0.96) translateY(-4px); }
  to { opacity: 1; transform: none; }
}
.popover .item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-row);
  font-size: var(--fs-ui); font-weight: 500;
  color: var(--text);
  text-align: left;
  transition: background var(--t-toque) ease, color var(--t-toque) ease;
}
.popover .item:hover { background: var(--active); color: var(--text-bright); }
.popover .item.danger { color: var(--red); }
.popover .item.danger:hover { background: rgba(239, 75, 79, 0.12); color: var(--red); }
.popover .item .icon { margin-left: auto; opacity: 0.6; }
.popover .sep { height: 1px; background: var(--divider); margin: 4px 6px; }
.popover .head {
  font-size: var(--fs-xs); font-weight: 600;
  color: var(--text-faint); padding: 6px 10px 2px;
}

/* ---------------- cartao de perfil ---------------- */
.profile-card {
  position: fixed;
  z-index: 200;
  width: 300px;
  background: var(--modal-alt);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-high);
  overflow: hidden;
  animation: abre-popover var(--t-abre) var(--curva-saida);
}
.profile-card .banner { height: 60px; }
/*
 * Com imagem a faixa cresce: 60px mostraria quase nada do que a pessoa
 * escolheu. 100px casa com a proporcao 3 por 1 do editor de recorte (o
 * cartao tem 300px de largura), entao a foto aparece exatamente como foi
 * enquadrada, sem cortar de novo.
 */
.profile-card .banner.com-imagem {
  height: 100px;
  background-size: cover;
  background-position: center;
}

/* previa do banner na tela de ajustes */
.banner-previa {
  height: 110px;
  border-radius: var(--radius);
  background-size: cover;
  background-position: center;
  background-color: var(--input);
  margin-bottom: 12px;
}
.banner-previa.vazio {
  display: grid;
  place-items: center;
  color: var(--text-faint);
  font-size: 13px;
  border: 1px dashed var(--divider);
}
.profile-card .inner { padding: 0 16px 16px; }
.profile-card .profile-avatar {
  position: relative;
  display: block;
  margin-top: -40px;
  margin-bottom: 12px;
  width: 80px; height: 80px;
  border-radius: 50%;
  border: 6px solid var(--modal-alt);
  background: var(--modal-alt);
  box-sizing: content-box;
}
/* o avatarHtml traz o proprio .avatar-wrap: aqui ele so preenche a moldura */
.profile-card .profile-avatar .avatar-wrap { display: block; width: 100%; height: 100%; }
.profile-card .profile-avatar .avatar { width: 100%; height: 100%; font-size: 30px; }
.profile-card .profile-avatar .presence-dot {
  right: 2px; bottom: 2px;
  width: 16px; height: 16px;
  border-width: 4px;
}
.profile-card .card-body { background: var(--modal); border-radius: var(--radius); padding: 12px; }
.profile-card .tag { font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--text-bright); letter-spacing: -0.01em; }
.profile-card .handle { font-size: var(--fs-sm); color: var(--text-muted); }
.profile-card .section { margin-top: 12px; }
.profile-card .section h4 {
  font-size: var(--fs-xs); font-weight: 600;
  color: var(--text-faint); margin-bottom: 4px;
}
.profile-card .section p { font-size: var(--fs-ui); color: var(--text); white-space: pre-wrap; word-break: break-word; }
.profile-card .actions { margin-top: 12px; display: flex; gap: 8px; }

/* ---------------- seletor de emoji ---------------- */
.emoji-picker {
  position: fixed;
  z-index: 200;
  width: 340px;
  height: 380px;
  background: var(--modal);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-high);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: pop-in 0.12s ease;
}
.emoji-picker .search { padding: 10px; }
.emoji-picker .search input {
  width: 100%; height: 34px;
  background: var(--input-alt); border: 1px solid var(--divider); border-radius: var(--radius);
  padding: 0 10px; color: var(--text-bright); outline: none; font-size: var(--fs-ui);
}
.emoji-picker .search input:focus { border-color: var(--brand); }
.emoji-picker .grid { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.emoji-picker .cat-name {
  font-size: var(--fs-xs); font-weight: 600;
  color: var(--text-faint); padding: 8px 4px 4px;
  position: sticky; top: 0; background: var(--modal);
}
.emoji-picker .cat-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-picker .emoji {
  width: 100%; aspect-ratio: 1;
  font-size: 22px; border-radius: var(--radius);
  display: grid; place-items: center;
}
.emoji-picker .emoji:hover { background: var(--hover); }
/* os do servidor sao imagem, nao caractere: precisam caber na mesma celula */
.emoji-picker .emoji.proprio { padding: 4px; }
.emoji-picker .emoji.proprio img { width: 100%; height: 100%; object-fit: contain; }
.emoji-picker .empty { padding: 24px; text-align: center; color: var(--text-muted); font-size: 14px; }

/* ---------------- visualizador de imagem ---------------- */
#lightbox {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  align-items: center; justify-content: center;
  flex-direction: column; gap: 12px;
  padding: 40px;
  animation: fade-in 0.15s ease;
}
#lightbox.open { display: flex; }
#lightbox img { max-width: 100%; max-height: calc(100% - 48px); object-fit: contain; border-radius: 4px; }
#lightbox .lb-bar { display: flex; gap: 16px; font-size: 14px; }

/* ---------------- notificacoes ---------------- */
#toast-root {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  display: flex; flex-direction: column; gap: 8px;
  align-items: center;
  pointer-events: none;
}
/*
 * O aviso subia com uma barra colorida grudada na esquerda - o recurso mais
 * batido que existe para dizer "isto e um aviso". Aqui a cor vira um ponto
 * antes do texto, do mesmo tamanho do indicador de presenca que o app ja usa,
 * e o cartao ganha uma borda inteira em vez de meia.
 */
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--modal);
  color: var(--text-bright);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-high);
  padding: 10px 16px 10px 14px;
  font-size: var(--fs-ui);
  font-weight: 500;
  animation: sobe-aviso var(--t-abre) var(--curva-saida);
  max-width: 90vw;
}
.toast::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  flex: 0 0 8px;
  background: var(--brand-soft);
}
.toast.error::before { background: var(--red); }
.toast.success::before { background: var(--green); }

@keyframes sobe-aviso {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

/* ---------------- configuracoes ---------------- */
#settings-screen {
  position: fixed; inset: 0; z-index: 150;
  background: var(--chat);
  display: none;
}
#settings-screen.open { display: flex; }
.settings-nav {
  width: 232px; flex: 0 0 232px;
  background: var(--sidebar);
  padding: 60px 6px 60px 20px;
  overflow-y: auto;
}
.settings-nav .group {
  font-size: var(--fs-xs); font-weight: 600;
  color: var(--text-faint); padding: 16px 10px 6px;
}
.settings-nav .nav-item {
  position: relative;
  display: block; width: 100%; text-align: left;
  padding: 7px 10px; margin-bottom: 1px;
  border-radius: var(--radius-row); font-size: var(--fs-ui); color: var(--text-muted);
  transition: background var(--t-toque) ease, color var(--t-toque) ease;
}
.settings-nav .nav-item:hover { background: var(--hover); color: var(--text); }
.settings-nav .nav-item.active { background: var(--active); color: var(--text-bright); font-weight: 500; }
.settings-nav .nav-item.danger { color: var(--red); }
.settings-main { flex: 1; padding: 60px 40px; overflow-y: auto; max-width: 740px; }
.settings-main h2 {
  font-family: var(--font-display);
  font-size: 24px; font-weight: 700; color: var(--text-bright);
  letter-spacing: -0.02em; margin-bottom: 20px;
}
.settings-main h3 {
  font-size: var(--fs-sm); font-weight: 600;
  color: var(--text-muted); margin: 28px 0 10px;
}
.settings-card { background: var(--modal-alt); border: 1px solid var(--divider); border-radius: var(--radius-lg); padding: 4px 16px; }
.settings-row {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--divider);
}
.settings-row:last-child { border-bottom: 0; }
.settings-row .grow { flex: 1; min-width: 0; }
.settings-row .label { font-size: var(--fs-ui); color: var(--text-bright); font-weight: 500; }
.settings-row .desc { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 2px; }
.settings-close {
  position: absolute; top: 60px; right: 40px;
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--divider);
  color: var(--text-muted);
  display: grid; place-items: center;
  transition: background var(--t-toque) ease, color var(--t-toque) ease;
}
.settings-close:hover { background: var(--hover); color: var(--text-bright); }

/* ligado usa a cor de acao da marca, como o resto dos controles */
.switch { width: 36px; height: 20px; border-radius: 10px; background: var(--input); box-shadow: inset 0 0 0 1px var(--divider); position: relative; transition: background var(--t-toque) ease; flex: 0 0 36px; cursor: pointer; }
.switch.on { background: var(--brand); box-shadow: none; }
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 14px; height: 14px; border-radius: 50%; background: var(--text-muted);
  transition: transform var(--t-abre) var(--curva-saida), background var(--t-toque) ease;
}
.switch.on::after { transform: translateX(16px); background: #fff; }
/* desligado por outra escolha, nao pela pessoa: fica visivel mas fora de alcance */
.switch.suspenso { opacity: 0.4; cursor: not-allowed; }


/* ---------------- seletor de tela (aplicativo de desktop) ---------------- */
.grupo-fontes { margin-bottom: 16px; }
.grupo-fontes h4 {
  font-size: var(--fs-sm); font-weight: 600;
  color: var(--text-muted); margin-bottom: 8px;
}
.grade-fontes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}
.fonte-tela {
  display: flex; flex-direction: column; gap: 6px;
  padding: 6px; border-radius: var(--radius-lg);
  background: var(--modal-alt);
  border: 2px solid transparent;
  text-align: left; width: 100%;
}
.fonte-tela:hover { background: var(--hover); }
.fonte-tela.ativa { border-color: var(--brand); background: var(--mention-bg); }
.fonte-tela .miniatura {
  display: block; width: 100%; aspect-ratio: 16 / 9;
  background: var(--input-alt); border-radius: var(--radius); overflow: hidden;
  display: grid; place-items: center;
}
.fonte-tela .miniatura img { width: 100%; height: 100%; object-fit: contain; }
.fonte-tela .miniatura .vazia { color: var(--text-faint); }
.fonte-tela .rotulo {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text); min-width: 0;
}
.fonte-tela.ativa .rotulo { color: var(--text-bright); font-weight: 500; }
.fonte-tela .icone-app { width: 16px; height: 16px; flex: 0 0 16px; border-radius: 3px; }

/* no aplicativo de desktop a barra de titulo e escondida: sobra espaco */
:root[data-desktop="sim"] .settings-nav { padding-top: 40px; }
:root[data-desktop="sim"] .settings-main { padding-top: 40px; }
:root[data-desktop="sim"] .settings-close { top: 40px; }

/* ---------------- chamada ---------------- */
.chamada-cartao {
  display: flex; flex-direction: column;
  align-items: center; gap: 12px;
  padding: 16px 0 8px;
  text-align: center;
}
.chamada-cartao .avatar-wrap { animation: respirar 2.4s ease-in-out infinite; }
@keyframes respirar {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
.chamada-nome { font-family: var(--font-display); font-size: 22px; font-weight: 700; color: var(--text-bright); letter-spacing: -0.01em; }
.chamada-estado {
  display: flex; align-items: center; gap: 8px;
  font-size: var(--fs-ui); color: var(--text-muted);
}
.chamada-estado .ondas { display: inline-flex; gap: 3px; align-items: flex-end; height: 14px; }
.chamada-estado .ondas i {
  width: 3px; height: 6px; border-radius: 2px;
  background: var(--green);
  animation: onda 1s ease-in-out infinite;
}
.chamada-estado .ondas i:nth-child(2) { animation-delay: 0.15s; }
.chamada-estado .ondas i:nth-child(3) { animation-delay: 0.3s; }
@keyframes onda {
  0%, 100% { height: 5px; opacity: 0.5; }
  50% { height: 14px; opacity: 1; }
}

/* botao de ligar no cabecalho da conversa */
#chat-header .header-btn.ligando { color: var(--red); }
#chat-header .header-btn.ligando:hover { background: rgba(239, 75, 79, 0.12); color: var(--red); }

/* convite ja reconhecido: confirma sem poluir o formulario */
.convite-aplicado {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; margin-bottom: 20px;
  background: rgba(46, 165, 103, 0.1);
  border: 1px solid rgba(46, 165, 103, 0.45);
  border-radius: var(--radius);
  font-size: var(--fs-sm); color: var(--text);
}
.convite-aplicado .marca { display: inline-flex; color: var(--green); }
.convite-aplicado .trocar {
  margin-left: auto; font-size: var(--fs-xs); color: var(--text-muted);
  text-decoration: underline; background: none;
}
.convite-aplicado .trocar:hover { color: var(--text-bright); }

/* ---------------- controle de volume individual ---------------- */
.controle-volume { min-width: 230px; }
.controle-volume .linha-volume {
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
}
.controle-volume .linha-volume .icone {
  color: var(--text-muted); display: inline-flex; cursor: pointer;
}
.controle-volume .linha-volume .icone:hover { color: var(--red); }
.controle-volume input[type="range"] {
  flex: 1; accent-color: var(--brand); cursor: pointer;
}
.controle-volume .valor {
  font-size: 12px; color: var(--text-muted);
  min-width: 38px; text-align: right; font-variant-numeric: tabular-nums;
}

/* ---------------- aviso de versao nova ---------------- */
/*
 * A posicao final e o padrao, e a entrada e so uma animacao por cima. Se o
 * aplicativo estiver minimizado quando o aviso aparecer, o navegador nao
 * desenha quadros e nenhuma animacao roda - mas a barra ja esta no lugar
 * certo, entao ela simplesmente aparece quando a janela volta.
 */
#barra-atualizacao {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  z-index: 350;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 8px 8px 14px;
  background: var(--modal);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-high);
  font-size: var(--fs-ui); color: var(--text);
  max-width: calc(100vw - 32px);
}
/* so entra com classe: em janela minimizada nenhum quadro e desenhado e a
   animacao ficaria travada no primeiro frame, fora da tela */
#barra-atualizacao.animar { animation: subir-barra 0.28s cubic-bezier(.2,.8,.3,1); }
@keyframes subir-barra {
  from { transform: translate(-50%, 140%); opacity: 0; }
  to { transform: translateX(-50%); opacity: 1; }
}
#barra-atualizacao .texto { display: flex; align-items: center; gap: 8px; }
#barra-atualizacao .texto svg { color: var(--brand-soft); flex: 0 0 auto; }
#barra-atualizacao .depois {
  width: 28px; height: 28px; border-radius: var(--radius);
  display: grid; place-items: center; color: var(--text-muted);
}
#barra-atualizacao .depois:hover { background: var(--hover); color: var(--text-bright); }

/* ---- ajustes do servidor: abas e cargos ---- */
.settings-tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--divider);
  margin-bottom: 18px;
}
.settings-tabs .tab-item {
  background: none; border: none; cursor: pointer;
  padding: 8px 2px; margin-right: 16px; margin-bottom: -1px;
  font: inherit; font-size: var(--fs-ui); font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: color var(--t-toque) ease, border-color var(--t-toque) ease;
}
.settings-tabs .tab-item:hover { color: var(--text-bright); }
.settings-tabs .tab-item.active { color: var(--text-bright); border-bottom-color: var(--brand); }

/* ---------------- emojis do servidor ---------------- */
.emoji-form {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 18px;
}
.emoji-arquivo {
  display: inline-flex; align-items: center;
  height: 36px; padding: 0 14px;
  border-radius: var(--radius-row);
  border: 1px dashed var(--divider);
  background: var(--input-alt);
  color: var(--text-muted);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  max-width: 190px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.emoji-arquivo:hover { border-color: var(--brand); color: var(--text-bright); }
.emoji-form input[type="text"] {
  flex: 1; min-width: 0;
  height: 36px; padding: 0 12px;
  background: var(--input-alt);
  border: 1px solid var(--divider);
  border-radius: var(--radius-row);
  color: var(--text-bright);
  font-size: 14px; outline: none;
}
.emoji-form input[type="text"]:focus { border-color: var(--brand); }

.emoji-grade {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
}
.emoji-cartao {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 6px 9px;
  background: var(--modal-alt);
  border: 1px solid var(--divider);
  border-radius: var(--radius-lg);
  font-size: 11px; color: var(--text-muted);
}
.emoji-cartao img { width: 36px; height: 36px; object-fit: contain; }
.emoji-cartao .ellipsis { max-width: 100%; }
.emoji-apagar {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border-radius: 6px;
  color: var(--text-faint);
  opacity: 0;
  transition: opacity var(--t-toque) ease, color var(--t-toque) ease;
}
.emoji-cartao:hover .emoji-apagar { opacity: 1; }
.emoji-apagar:hover { color: var(--red); background: rgba(239, 75, 79, 0.12); }

/* ---------------- registro de auditoria ---------------- */
.registro-lista { display: flex; flex-direction: column; gap: 2px; }
.registro-linha {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 11px 10px;
  border-radius: var(--radius-row);
  transition: background var(--t-toque) ease;
}
.registro-linha:hover { background: var(--hover); }
.registro-texto { flex: 1; min-width: 0; font-size: 14px; line-height: 1.45; }
.registro-texto strong { color: var(--text-bright); font-weight: 700; }
.registro-detalhe { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.registro-quando {
  flex: 0 0 auto;
  font-size: 12px; color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}

/* paragrafo de ajuda solto, fora de um .field */
p.help { font-size: 12px; color: var(--text-muted); margin: 0 0 14px; }

.cargos-lista { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.cargo-linha {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius);
  background: var(--input); cursor: pointer;
}
.cargo-linha:hover { background: var(--hover); }
.cargo-cor { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.cargo-nome { color: var(--text-bright); font-weight: 500; }
.cargo-badge {
  font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 4px;
  background: rgba(149, 69, 243, 0.16); color: var(--brand-soft);
}
.cargo-contagem { font-size: 12px; color: var(--text-muted); }
.cargo-seta { margin-left: auto; color: var(--text-muted); }

/* pega de arrastar: o icone 'more' deitado, com o cursor certo para o gesto */
.cargo-grip { flex: none; color: var(--text-faint); cursor: grab; transform: rotate(90deg); }
.cargo-linha[draggable="true"]:active { cursor: grabbing; }
.cargo-linha.arrastando { opacity: 0.4; }
/* linha de insercao: mostra ANTES ou DEPOIS de qual cargo o solto vai cair */
.cargo-linha.sobre-linha { box-shadow: inset 0 2px 0 var(--brand); }
.cargo-linha.sobre-linha-baixo { box-shadow: inset 0 -2px 0 var(--brand); }

.cargo-form .switch-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 8px; cursor: pointer;
  font-size: 14px; color: var(--text-bright);
}
.cargo-form > [data-voltar-cargos] { margin-bottom: 14px; }

.cargo-membros {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 220px; overflow-y: auto;
  border: 1px solid var(--divider); border-radius: var(--radius);
  padding: 6px;
}
.cargo-membro {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 4px;
  font-size: 14px; color: var(--text-bright);
  cursor: pointer;
}
.cargo-membro:hover { background: var(--hover); }
.cargo-membro input[type="checkbox"] { flex: none; }

/* fichas de cargo no cartao de perfil */
.cargos-do-perfil .fichas { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ficha-cargo {
  display: inline-flex; align-items: center; gap: 6px;
  max-width: 100%;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--input);
  border: 1px solid var(--divider);
  font-size: 12px;
  color: var(--text);
}
.ficha-cargo .ponto { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }
.ficha-cargo .tirar {
  display: grid; place-items: center;
  width: 16px; height: 16px; padding: 0;
  border: none; border-radius: 50%;
  background: transparent; color: var(--text-faint);
  cursor: pointer;
}
.ficha-cargo .tirar:hover { background: var(--hover); color: var(--text-bright); }
.ficha-cargo.adicionar {
  cursor: pointer;
  color: var(--text-muted);
  padding: 3px 9px;
}
.ficha-cargo.adicionar:hover { background: var(--hover); color: var(--text-bright); }

/* imagem do servidor, nos ajustes */
.linha-icone { display: flex; align-items: center; gap: 14px; }
.linha-botoes { display: flex; gap: 8px; flex-wrap: wrap; }
.previa-icone {
  width: 64px; height: 64px; flex: 0 0 64px;
  border-radius: 20px;
  display: grid; place-items: center;
  overflow: hidden;
  color: #fff; font-weight: 700; font-size: 20px;
  font-family: var(--font-display);
}
.previa-icone img { width: 100%; height: 100%; object-fit: cover; }

/* grade de escolha das placas de identificacao */
.grade-placas {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  padding: 4px 12px 12px;
}
.opcao-placa {
  padding: 3px;
  border: 2px solid transparent;
  border-radius: 10px;
  background: var(--input);
  cursor: pointer;
  line-height: 0;
}
.opcao-placa img { width: 100%; height: auto; border-radius: 7px; }
.opcao-placa:hover { border-color: var(--divider); }
.opcao-placa.ativa { border-color: var(--brand); }

/*
 * Camada propria, fora do #modal-root: precisa poder abrir por cima de um
 * modal ja aberto (o editor de icone abre de dentro dos Ajustes do
 * servidor) sem apagar o que esta por tras.
 *
 * O z-index precisa vencer o do proprio #settings-screen (150) - e o
 * avatar abre o editor de DENTRO dos ajustes. Sem isso o editor desenha
 * atras da tela de ajustes, invisivel, e so aparece quando ela fecha (o que
 * pareceu, de fora, "o editor so abre quando eu saio das configuracoes").
 * Fica logo abaixo do #toast-root (400), que precisa continuar por cima de
 * tudo mesmo com o editor aberto.
 */
.recorte-overlay {
  position: fixed;
  inset: 0;
  z-index: 390;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 9, 11, 0.72);
  padding: 24px;
  animation: fade-in 0.15s ease;
}

/* editor de recorte de imagem (avatar e icone de servidor) */
.recorte-area {
  /* largura e altura vem inline, do JS: cada forma tem uma proporcao (o
     avatar e o icone sao quadrados, o banner e 3 por 1) */
  position: relative;
  margin: 0 auto;
  border-radius: var(--radius);
  overflow: hidden;
  background:
    repeating-conic-gradient(#2a2b30 0% 25%, #222328 0% 50%) 50% / 20px 20px;
  touch-action: none;
}
.recorte-tela { display: block; cursor: grab; touch-action: none; }
.recorte-tela:active { cursor: grabbing; }

.recorte-mascara {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(8, 9, 11, 0.62);
  border: 2px solid rgba(255, 255, 255, 0.92);
}
.recorte-circulo .recorte-mascara { border-radius: 50%; }
.recorte-squircle .recorte-mascara { border-radius: 28%; }
/*
 * No banner a area inteira e o recorte final - nao ha canto sobrando para
 * escurecer, ao contrario do circulo/quadrado dentro de uma caixa maior.
 * So uma borda fina para marcar o limite.
 */
.recorte-retangulo .recorte-mascara { box-shadow: none; border-radius: inherit; }

.recorte-controles {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}
.recorte-zoom-btn {
  display: grid;
  place-items: center;
  width: 28px; height: 28px; flex: 0 0 28px;
  border: none;
  border-radius: 50%;
  background: var(--input);
  color: var(--text-muted);
  cursor: pointer;
}
.recorte-zoom-btn:hover { background: var(--hover); color: var(--text-bright); }
.recorte-slider {
  flex: 1;
  accent-color: var(--brand);
}

.recorte-redefinir {
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}
.recorte-redefinir:hover { color: var(--text-bright); text-decoration: underline; }
.modal-foot .spacer { flex: 1; }
