/* ============================================================
   ÁREA DE CHAT
   ============================================================ */
#chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-primary);
}

#chat-header {
  height: 48px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-color);
  font-weight: 700;
  font-size: calc(16px * var(--font-scale));
  flex-shrink: 0;
}

#channel-hash { color: var(--text-muted); font-weight: 400; }

.chat-topic {
  color: var(--text-muted);
  font-weight: 400;
  font-size: calc(13px * var(--font-scale));
  margin-left: 8px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ---------- Sala de chamada (voz/vídeo) ---------- */
#call-container {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 12px;
}

.call-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.call-connecting {
  color: var(--red);
  font-size: calc(12px * var(--font-scale));
  font-weight: 700;
  animation: pulse 1.5s infinite;
}

.call-connecting.connected {
  color: var(--green);
  animation: none;
}

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.call-title { font-weight: 700; font-size: calc(14px * var(--font-scale)); }

.call-buttons { display: flex; gap: 6px; }

/* Seletor de dispositivos (mic/câmera) */
.call-devices {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.call-devices select {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: none;
  border-radius: 4px;
  background: var(--bg-input);
  color: var(--text-normal);
  font-size: calc(12px * var(--font-scale));
  cursor: pointer;
}

.call-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--bg-primary);
  color: var(--text-normal);
  font-size: calc(16px * var(--font-scale));
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.call-btn:hover { transform: scale(1.05); background: var(--bg-input); }
.call-btn:active { transform: scale(0.95); }

.call-btn.active { background: var(--green); }
.call-btn.leave { background: var(--red); color: #fff; }
.call-btn.muted { background: var(--red); }

#video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  grid-auto-rows: 1fr;
  gap: 12px;
  padding: 6px;
  overflow: hidden;
}

/* Foco/spotlight num tile: expande p/ a região inteira da call (esconde os demais) */
#video-grid.spotlight {
  grid-template-columns: 1fr;
  grid-auto-rows: 1fr;
  gap: 0;
  padding: 6px;
}
#video-grid.spotlight .video-tile { display: none; }
#video-grid.spotlight .video-tile.tile-focused { display: block; }
/* Sem vídeo (avatar/foto), o foco mantém a centralização (não desloca p/ o canto) */
#video-grid.spotlight .video-tile.no-video.tile-focused {
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-tile {
  position: relative;
  background: #000;
  border-radius: 8px;
  padding: 4px; /* moldura da janela: espaço p/ a borda de fala aparecer com destaque */
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  /* Redimensionamento com filtro bilinear de alta qualidade (sem pixelado/borrão) */
  image-rendering: auto;
}

html:not(.android-app) .video-tile.self video { transform: scaleX(-1); }
html.android-app .video-tile.self.android-selfie-camera video { transform: scaleX(-1); }

/* Áudio oculto de voz/tela — offscreen (não display:none) p/ o autoplay funcionar no iOS/mobile */
.peer-audio-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  left: -9999px;
  top: 0;
  opacity: 0;
  pointer-events: none;
}

/* Borda verde quando o usuário está falando */
.video-tile.speaking {
  box-shadow: 0 0 0 3px var(--green), 0 0 10px rgba(35, 165, 90, 0.5);
}
.video-tile.speaking .tile-label {
  background: var(--green);
}

/* Tile da tela compartilhada — tela é HORIZONTAL (16:9 etc.): NÃO corta as laterais.
   Ajusta à largura máxima e deixa bordas pretas em cima/embaixo (contain). */
.video-tile.screen video {
  object-fit: contain;
  object-position: center;
  background: #000;
  image-rendering: auto;
}

/* Corpo da call: grade + painel de participantes (altura fixa, tela divide o espaço) */
#call-body {
  display: flex;
  gap: 10px;
  height: min(46vh, 420px);
  min-height: 200px;
}

#call-body #video-grid {
  flex: 1;
  min-width: 0;
  height: 100%;
}

/* Alça de redimensionamento: divisão ajustável entre a call e o chat.
   Arraste para a call não tampar o texto — funciona com mouse e toque. */
#call-resizer {
  height: 8px;
  margin: 8px -12px -12px; /* expande até as bordas do #call-container (padding 12px) */
  cursor: ns-resize;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

#call-resizer::before {
  content: '';
  width: 48px;
  height: 4px;
  border-radius: 3px;
  background: var(--text-muted);
  opacity: 0.4;
  transition: background 0.15s, opacity 0.15s;
}

#call-resizer:hover::before,
#call-resizer.dragging::before {
  background: var(--blurple);
  opacity: 1;
}

/* Durante o arraste: evita seleção de texto e scroll acidental (mobile) */
body.resizing-call {
  cursor: ns-resize;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
  touch-action: none;
}

/* Modo popout (?call=1): mostra apenas a seção da call, sem o resto da página */
#app.popout-mode > nav,
#app.popout-mode > aside,
#app.popout-mode #chat-header,
#app.popout-mode #messages-container,
#app.popout-mode #message-input-wrap {
  display: none !important;
}

#app.popout-mode #chat-area {
  width: 100%;
  padding: 0;
}

#app.popout-mode #call-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  border-bottom: none;
}

#app.popout-mode #call-body {
  height: auto;
  flex: 1;
  min-height: 0;
}

/* No modo popout a call ocupa a janela toda — sem alça de redimensionamento */
#app.popout-mode #call-resizer {
  display: none !important;
}

#call-participants {
  width: 220px;
  max-height: 340px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

/* Lista "quem está na call" (abaixo da call) */
#call-users {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}

.call-user-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-input);
  border-radius: 16px;
  padding: 3px 10px 3px 4px;
  font-size: calc(12px * var(--font-scale));
  color: var(--text-normal);
  max-width: 100%;
}

.call-user-chip .avatar {
  width: 22px;
  height: 22px;
  font-size: calc(10px * var(--font-scale));
  flex-shrink: 0;
}

.call-user-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.call-user-multi {
  color: var(--yellow);
  font-weight: 700;
  flex-shrink: 0;
}

.call-part {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-input);
  padding: 6px 8px;
  border-radius: 6px;
}

.call-part-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.call-part-thumb {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.call-part-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.call-part-thumb .avatar {
  width: 100%;
  height: 100%;
  font-size: calc(16px * var(--font-scale));
}

/* Overlays de estado (SEM fundo) na miniatura do participante: mic cortado / fone cortado */
.call-part-thumb .call-part-state {
  position: absolute;
  bottom: 0;
  font-size: calc(12px * var(--font-scale));
  line-height: 1;
  color: var(--red);
  text-shadow: 0 0 2px #000, 0 0 2px #000;
  pointer-events: none;
  z-index: 2;
}
.call-part-thumb .call-part-state .mi { font-size: calc(12px * var(--ui-scale)); }
.call-part-thumb .call-part-state.mic { left: 1px; }
.call-part-thumb .call-part-state.deaf { left: auto; right: 1px; }

/* Vermelho mais escuro = mute/deafen por ADMIN do servidor */
.call-part-thumb .call-part-state.admin { color: #a01215; }

/* Indicador de fala no painel de participantes */
.call-part.speaking .call-part-thumb {
  box-shadow: 0 0 0 3px var(--green);
}
.call-part.speaking .call-part-info {
  color: var(--green-bright);
}

.call-part-info {
  flex: 1;
  min-width: 0;
  font-size: calc(13px * var(--font-scale));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Toggles de visibilidade (câmera/tela) e áudio por participante */
.call-part-prefs {
  display: flex;
  gap: 4px;
}

.call-pref {
  flex: 1;
  background: none;
  border: 1px solid var(--bg-primary);
  color: var(--text-muted);
  border-radius: 4px;
  padding: 2px 0;
  font-size: calc(13px * var(--font-scale));
  cursor: pointer;
}

.call-pref.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.call-pref:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Sliders de volume da voz e da tela por participante */
.call-part-sliders {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
}

.call-vol {
  display: flex;
  align-items: center;
  gap: 6px;
}

.call-vol-label {
  flex: 0 0 auto;
  font-size: calc(11px * var(--font-scale));
  color: var(--text-muted);
  width: 52px;
  cursor: pointer;
}
.call-vol-label:hover { color: var(--text-normal); }

.call-vol input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--green);
}

/* Volume em 0 (zerado pelo clique no ícone/texto ou no próprio slider) -> vermelho */
.call-vol.zero .call-vol-label { color: var(--red); }
.call-vol.zero input[type="range"] { accent-color: var(--red); }

/* Ações de moderação do admin (tirar da call / silenciar / ensurdecer) */
.call-part-mods {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.call-mod {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--bg-primary);
  color: var(--text-normal);
  border-radius: 4px;
  padding: 2px 0;
  font-size: calc(13px * var(--font-scale));
  cursor: pointer;
}

.call-mod:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.call-mod.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.video-tile .tile-label {
  position: absolute;
  bottom: 9px;
  left: 9px;
  background: rgba(0, 0, 0, 0.6);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: calc(12px * var(--font-scale));
  color: #fff;
}

/* Ícones de estado (mudo / fone cortado / alto-falante cortado) no CANTO SUPERIOR DIREITO.
   O botão de denunciar fica no canto superior ESQUERDO (ver modals.css). */
.video-tile .tile-mic-off {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(237, 66, 69, 0.8);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(12px * var(--font-scale));
}

/* "Alto-falante cortado" no tile de VOZ: o OUVINTE zerou o volume da voz (mute é de quem ouve) */
.video-tile .tile-volume-off {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(237, 66, 69, 0.8);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(12px * var(--font-scale));
}

/* "Fone cortado" vermelho quando o visualizador NÃO ouve o participante — lado do mic cortado */
.video-tile .tile-deafen-off {
  position: absolute;
  top: 6px;
  right: 34px;
  background: rgba(237, 66, 69, 0.8);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(12px * var(--font-scale));
}

/* "Alto-falante cortado" na tela: sem som no share ou volume da tela zerado */
.video-tile .tile-screen-muted {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(237, 66, 69, 0.8);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(12px * var(--font-scale));
}

/* Vermelho mais ESCURO = mute/deafen veio de um ADMIN do servidor */
.video-tile .tile-mic-off.admin,
.video-tile .tile-volume-off.admin,
.video-tile .tile-deafen-off.admin,
.video-tile .tile-screen-muted.admin {
  background: rgba(122, 14, 18, 0.95);
}

.video-tile.no-video {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
}

.video-tile.no-video .avatar { width: 64px; height: 64px; font-size: calc(24px * var(--font-scale)); }

/* Placeholder do tile da própria tela no app (evita loop de vídeo ao capturar o app) */
.video-tile .screen-tile-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  font-size: calc(13px * var(--font-scale));
  text-align: center;
  opacity: 0.85;
  padding: 8px;
}
.video-tile .screen-tile-placeholder .material-symbols-outlined {
  font-size: calc(40px * var(--ui-scale));
}

/* ---------- Mensagens ---------- */
#messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.message {
  display: flex;
  gap: 16px;
  padding-top: 8px;
  border-radius: 4px;
  position: relative;
}

.message:hover,
.message.long-press {
  /* Transparente: deixa o fundo do chat aparecer; sem fundo, escurece suavemente */
  background: rgba(0, 0, 0, 0.28);
}

/* Mensagens agrupadas (mesmo autor, até 1 min, estilo Discord): SEM espaçamento
   vertical (sem line spacing) entre as do grupo; o avatar só aparece na 1ª do grupo
   (posicionado no canto, fora do fluxo) e o texto mantém o MESMO recuo das demais */
.message.grouped { padding-top: 0; padding-bottom: 0; }

/* Destaque temporário ao rolar até a mensagem respondida */
@keyframes msg-flash {
  0% { background: rgba(88, 101, 242, 0.35); }
  100% { background: transparent; }
}
.message.msg-highlight {
  animation: msg-flash 1.4s ease-out;
  border-radius: 4px;
}

/* Barra de ações (responder/editar/apagar) no hover */
.message .msg-actions {
  position: absolute;
  top: -10px;
  right: 16px;
  display: flex;
  gap: 2px;
  background: var(--bg-elevated);
  border-radius: 6px;
  padding: 2px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
  z-index: 5;
}

.message:hover .msg-actions { opacity: 1; pointer-events: auto; }

.msg-action {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: calc(14px * var(--font-scale));
  width: 28px;
  height: 24px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.msg-action:hover { background: var(--bg-hover); color: var(--text-normal); }

/* Resposta a uma mensagem (barra acima do texto) */
.message .msg-reply {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: calc(13px * var(--font-scale));
  color: var(--text-muted);
  margin-bottom: 2px;
  cursor: pointer;
  padding-left: 8px;
  margin-left: -8px;
}

.message .msg-reply-icon { flex-shrink: 0; }

.message .msg-reply-author {
  font-weight: 600;
  color: var(--blurple, #5865F2);
  flex-shrink: 0;
}

.message .msg-reply-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message .msg-edited {
  font-size: calc(11px * var(--font-scale));
  color: var(--text-muted);
  font-style: italic;
}

/* Emblema colorido do cargo (igual ao TEMP, com a cor definida no cargo) */
.role-badge {
  font-size: calc(10px * var(--font-scale));
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #fff;
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 6px;
  flex-shrink: 0;
  user-select: none;
  vertical-align: middle;
  white-space: nowrap;
}

/* No perfil o nome é em coluna: o emblema fica abaixo do nome, sem margem lateral */
.profile-username .role-badge {
  margin-left: 0;
  margin-top: 4px;
}

/* App-badge (ícone) do cargo do JD Auth */
.app-badge {
  font-size: calc(13px * var(--font-scale));
  line-height: 1;
  margin-left: 6px;
  flex-shrink: 0;
  user-select: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.app-badge .material-symbols-outlined {
  font-size: calc(14px * var(--ui-scale));
}

/* Cargo do servidor (server-role): etiqueta colorida ao lado do nome */
.server-role-badge {
  display: inline-flex;
  align-items: center;
  font-size: calc(10px * var(--font-scale));
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 6px;
  flex-shrink: 0;
  user-select: none;
  white-space: nowrap;
  border: 1px solid rgba(255,255,255,0.18);
}

.profile-username .server-role-badge,
#profile-role .server-role-badge {
  margin-left: 0;
  margin-top: 4px;
}

/* Barra acima do input: resposta pendente / modo de edição */
#compose-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 16px 8px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: calc(13px * var(--font-scale));
  color: var(--text-normal);
  background: var(--bg-input, #1e1f22);
}

#compose-bar.reply { border-left: 4px solid var(--blurple, #5865F2); }
#compose-bar.editing { border-left: 4px solid var(--green, #23a55a); }

#compose-bar .compose-reply-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  flex: 1;
}

.compose-cancel {
  margin-left: auto;
  border: none;
  background: var(--bg-hover);
  color: var(--text-normal);
  font-size: calc(12px * var(--font-scale));
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
}

.compose-cancel:hover { filter: brightness(1.2); }

.message .msg-avatar {
  /* Foto no CANTO (fora do fluxo): não empurra nem cria espaço nas linhas */
  position: absolute;
  left: 8px;
  top: 4px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
}

.message .msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.message .msg-content {
  flex: 1;
  min-width: 0;
  /* Recuo fixo p/ o texto não passar por baixo da foto (que fica no canto, fora do fluxo) */
  margin-left: 56px;
}

/* Mensagem sem acesso à chave de descriptografia (não é destinatário) */
.message .msg-protected {
  font-size: calc(13px * var(--font-scale));
  color: var(--text-muted, #9aa0a6);
  font-style: italic;
  padding: 2px 0;
  user-select: none;
}

/* ---------- Automod: conteúdo oculto (expansível) ---------- */
.automod-card {
  border: 1px solid var(--border-color, #2b2d31);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
  max-width: 520px;
}
.automod-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: none;
  background: none;
  color: var(--text-normal, #f2f3f5);
  padding: 8px 12px;
  cursor: pointer;
  font-size: calc(13px * var(--font-scale));
  text-align: left;
  border-radius: 8px;
  transition: background 0.15s;
}
.automod-head:hover { background: rgba(255, 255, 255, 0.05); }
.automod-icon {
  font-size: calc(18px * var(--font-scale));
  color: var(--yellow, #faa61a);
  flex-shrink: 0;
  line-height: 1;
}
.automod-label {
  color: var(--text-muted, #9aa0a6);
  flex-shrink: 0;
}
.automod-chip {
  font-size: calc(11px * var(--font-scale));
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.automod-card[data-category="underage"] .automod-chip { background: rgba(250, 166, 26, 0.2); color: var(--yellow, #faa61a); }
.automod-card[data-category="scam"] .automod-chip { background: rgba(237, 66, 69, 0.18); color: #ff6b6b; }
.automod-card[data-category="profanity"] .automod-chip { background: rgba(250, 166, 26, 0.14); color: #e8c15a; }
.automod-card[data-category="aggressive"] .automod-chip { background: rgba(237, 66, 69, 0.18); color: #ff8a8a; }
.automod-card[data-category="other"] .automod-chip { background: rgba(88, 101, 242, 0.18); color: #aab2ff; }
.automod-toggle {
  margin-left: auto;
  flex-shrink: 0;
  font-size: calc(12px * var(--font-scale));
  font-weight: 600;
  color: var(--text-link, #00aff4);
  background: rgba(0, 175, 244, 0.12);
  padding: 3px 10px;
  border-radius: 6px;
  transition: background 0.15s;
}
.automod-head:hover .automod-toggle { background: rgba(0, 175, 244, 0.25); }
.automod-body {
  border-top: 1px solid var(--border-color, #2b2d31);
  padding: 8px 12px;
}
.automod-body.hidden { display: none; }
.automod-reason {
  font-size: calc(12px * var(--font-scale));
  color: var(--text-muted, #9aa0a6);
  font-style: italic;
  margin-top: 4px;
  word-wrap: break-word;
}
/* Card travado (automod pessoal estrito: não permite expandir) */
.automod-locked .automod-toggle { cursor: not-allowed; }
.automod-locked .automod-head { cursor: not-allowed; }
.automod-locked .automod-head:hover { background: none; }
/* Aviso de que a mensagem foi aprovada por um admin (quem não confia vê assim) */
.automod-approved-note {
  font-size: calc(12px * var(--font-scale));
  color: var(--green, #23a55a);
  font-weight: 600;
  margin-bottom: 4px;
}
/* Botão "Aprovar (falso-positivo)" */
.automod-approve {
  border: none;
  background: rgba(35, 165, 90, 0.15);
  color: var(--green, #23a55a);
  font-size: calc(12px * var(--font-scale));
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  margin-top: 6px;
  transition: background 0.15s;
}
.automod-approve:hover { background: rgba(35, 165, 90, 0.3); }
.automod-head .automod-approve { margin-top: 0; margin-left: 4px; }
/* Anexo (imagem) oculto INDIVIDUALMENTE pelo automod: mesmo card, um pouco menor */
.automod-card-attachment { max-width: 420px; }
.automod-card-attachment .automod-icon { color: var(--red, #ed4245); }
.automod-card-attachment .automod-body .msg-attachment { margin: 0; }
/* Anexo em ANÁLISE pela IA (imagem ainda não verificada): placeholder com spinner */
.msg-attachment.automod-pending {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  min-width: 200px;
  max-width: 320px;
  border: 1px dashed var(--border-color, #2b2d31);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-muted, #9aa0a6);
  font-size: calc(12px * var(--font-scale));
}
.automod-pending-icon { color: var(--yellow, #faa61a); font-size: calc(18px * var(--font-scale)); line-height: 1; }
.automod-pending-label { flex: 1; }
.automod-pending-spinner {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--text-link, #00aff4);
  border-radius: 50%;
  animation: automod-spin 0.8s linear infinite;
}
@keyframes automod-spin { to { transform: rotate(360deg); } }
/* Aviso p/ o AUTOR: a mensagem dele pode não estar visível p/ todos */
.automod-flagged-note {
  font-size: calc(11px * var(--font-scale));
  color: var(--red, #ed4245);
  margin-top: 3px;
  user-select: none;
}

.message .msg-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.message .msg-author { font-weight: 600; font-size: calc(15px * var(--font-scale)); }

.message .msg-time {
  font-size: calc(11px * var(--font-scale));
  color: var(--text-muted);
}

/* Hora no hover (estilo Discord): coluna esquerda (gutter), na linha da mensagem.
   1ª msg do grupo: abaixo da foto; agrupadas: alinhada com a linha do texto. */
.message .msg-time-hover {
  position: absolute;
  left: 8px;
  top: 2px;
  font-size: calc(10px * var(--font-scale));
  color: var(--text-muted);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
  z-index: 2;
}
/* 1ª msg do grupo (tem foto): a hora fica ABAIXO da foto (foto = 40px + 4px do topo) */
.message:not(.grouped) .msg-time-hover { top: 46px; }
.message:hover .msg-time-hover,
.message.long-press .msg-time-hover { opacity: 1; }

/* Divisória de data entre mensagens (quando muda o dia) */
.day-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 12px;
  color: var(--text-muted);
  font-size: calc(11px * var(--font-scale));
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  user-select: none;
}
.day-divider::before,
.day-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}
.day-divider-label { flex-shrink: 0; }

/* Avatar do Sistema (DM de banimento/avisos) */
.system-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.system-avatar .material-symbols-outlined {
  font-size: 1.25em;
  line-height: 1;
}

/* ---------- Menções (@usuario) ---------- */
.msg-mention {
  color: var(--text-link);
  background: rgba(0, 175, 244, 0.15);
  border-radius: 4px;
  padding: 0 3px;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}
.msg-mention:hover { background: rgba(0, 175, 244, 0.3); }
.msg-mention.mention-self {
  color: var(--yellow);
  background: rgba(250, 166, 26, 0.2);
  border-radius: 4px;
  padding: 0 3px;
}
.msg-mention.mention-self:hover { background: rgba(250, 166, 26, 0.35); }

/* ---------- Markdown nas mensagens (negrito/itálico/código/spoiler) ---------- */
.md-bold { font-weight: 700; }
.md-italic { font-style: italic; }
.md-underline { text-decoration: underline; }
.md-strike { text-decoration: line-through; }
/* Links clicáveis no markdown (mensagens + biografia) */
.md-link {
  color: var(--accent, #5865f2);
  text-decoration: none;
  cursor: pointer;
  word-break: break-all;
}
.md-link:hover { text-decoration: underline; }
.md-code {
  font-family: var(--font-mono, Consolas, 'Courier New', monospace);
  font-size: 0.9em;
  background: var(--bg-elevated);
  border-radius: 3px;
  padding: 0 4px;
}
.md-codeblock {
  background: var(--bg-elevated);
  border-radius: 6px;
  padding: 8px 10px;
  margin: 6px 0;
  overflow-x: auto;
}
.md-codeblock code {
  font-family: var(--font-mono, Consolas, 'Courier New', monospace);
  font-size: 0.9em;
  white-space: pre;
}

/* Spoiler: frase oculta que só aparece ao clicar */
.spoiler {
  background: var(--bg-tertiary);
  color: transparent;
  border-radius: 3px;
  padding: 0 3px;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s, background 0.15s;
}
.spoiler.revealed {
  color: inherit;
  background: rgba(255, 255, 255, 0.06);
  user-select: text;
}

/* Banner persistente de menção (fica até o usuário ver) */
.mention-banner {
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--yellow);
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: calc(13px * var(--font-scale));
  color: var(--text-normal);
  z-index: 20;
}
.mention-banner-item {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.mention-banner-item .material-symbols-outlined { color: var(--yellow); font-size: calc(18px * var(--ui-scale)); }
.mention-banner-text {
  color: var(--text-muted);
  font-size: calc(12px * var(--font-scale));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 55%;
}
.mention-banner-go {
  margin-left: auto;
  border: none;
  background: var(--yellow);
  color: #000;
  font-weight: 700;
  font-size: calc(12px * var(--font-scale));
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
}
.mention-banner-go:hover { filter: brightness(1.1); }

/* Autocomplete de menção */
.mention-autocomplete {
  position: absolute;
  left: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  max-height: 240px;
  overflow-y: auto;
  width: 260px;
  z-index: 260;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.mention-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: calc(13px * var(--font-scale));
  color: var(--text-normal);
}
.mention-opt.active { background: var(--blurple); color: #fff; }
.mention-opt .avatar { width: 22px; height: 22px; font-size: calc(9px * var(--font-scale)); flex-shrink: 0; }
.mention-opt-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message .msg-text {
  font-size: calc(15px * var(--font-scale));
  line-height: 1.4;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.message.system {
  justify-content: center;
  color: var(--text-muted);
  font-size: calc(13px * var(--font-scale));
  padding: 8px;
}

/* ---------- Input de mensagem ---------- */
#message-input-wrap {
  position: relative; /* menu de emojis posiciona acima do input */
  padding: 0 16px 24px;
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

/* Botões de anexar e emojis (mesmo visual) */
#attach-btn,
#emoji-btn {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: none;
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text-normal);
  font-size: calc(18px * var(--ui-scale));
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

#attach-btn:hover,
#emoji-btn:hover { background: var(--bg-hover); }

#attach-btn:disabled,
#emoji-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#message-input-box {
  flex: 1;
  background: var(--bg-input);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--text-normal);
  font-size: calc(15px * var(--font-scale));
  outline: none;
  max-height: 160px;
  overflow-y: auto;
  min-height: 44px;
  cursor: text;
}

#message-input-box:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
}

#message-send {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 8px;
  background: var(--blurple);
  color: #fff;
  font-size: calc(18px * var(--font-scale));
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}

#message-send:hover { background: var(--blurple-hover); }
#message-send:disabled { opacity: 0.5; cursor: not-allowed; }
#message-input-box:not([contenteditable="true"]) { opacity: 0.5; }

/* ---------- Anexos (upload MinIO) ---------- */
#attach-preview {
  padding: 8px 16px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: calc(13px * var(--font-scale));
  color: var(--text-normal);
  flex-shrink: 0;
}

.attach-preview-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border-radius: 8px;
  padding: 6px 10px;
  max-width: 320px;
}

.attach-preview-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attach-preview-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: calc(14px * var(--font-scale));
  line-height: 1;
  flex-shrink: 0;
}

.attach-preview-remove:hover { color: var(--red); }

/* Progresso de upload inline (nome + % na frente + barrinha verde abaixo) */
.attach-preview-item.uploading {
  flex-wrap: wrap;
  padding-bottom: 8px;
}
.attach-progress-pct {
  font-weight: 700;
  font-size: calc(12px * var(--font-scale));
  color: var(--text-muted);
  flex-shrink: 0;
}
.attach-progress-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  overflow: hidden;
}
.attach-progress-bar {
  height: 100%;
  width: 0;
  background: var(--green);
  border-radius: 2px;
  transition: width 0.1s linear;
}
.attach-preview-item.uploading.error .attach-progress-bar { background: var(--red); }

/* Anexo dentro da mensagem */
.msg-attachment {
  margin-top: 6px;
  position: relative;
}

.msg-attachment img,
.msg-attachment video {
  max-width: 100%;
  max-height: 360px;
  border-radius: 8px;
  display: block;
  background: #000;
}

.msg-attachment audio {
  width: 100%;
  max-width: 420px;
  display: block;
}

.msg-attachment.file {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  border-radius: 8px;
  padding: 8px 12px;
  max-width: 420px;
}

.msg-attachment.file .file-icon {
  font-size: calc(22px * var(--font-scale));
  flex-shrink: 0;
}

.msg-attachment.file .file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-link);
  text-decoration: none;
}

.msg-attachment.file .file-name:hover { text-decoration: underline; }

.msg-attachment.file .file-download {
  flex-shrink: 0;
  padding: 5px 10px;
  border-radius: 6px;
  background: var(--blurple);
  color: #fff;
  font-size: calc(12px * var(--font-scale));
  font-weight: 600;
  text-decoration: none;
}

.msg-attachment.file .file-download:hover { background: var(--blurple-hover); }

/* Figurinha (sticker) enviada — menor que um anexo comum */
.msg-attachment.sticker img {
  max-width: 160px;
  max-height: 160px;
  background: none;
}

/* Placeholder de carregamento do anexo — do tamanho do ASSET, não do chat/mensagem */
.msg-attachment.loading {
  width: min(320px, 70vw);
  height: 180px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  overflow: hidden;
  /* A classe .loading daria um SPINNER girando; no anexo fica só a barrinha de progresso */
  animation: none;
}
.msg-attachment.loading img,
.msg-attachment.loading video { width: 100%; height: 100%; object-fit: cover; }

/* Vídeo lazy: só carrega ao clicar em play (elemento escondido até lá) */
.msg-attachment.video-lazy video { display: none; }
/* A classe .loading dá o tamanho do placeholder, mas NÃO deve girar no vídeo */
.msg-attachment.video-lazy { animation: none; }
.msg-video-play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4;
  animation: none;
  transition: transform 0.15s, background 0.15s;
}
.msg-video-play:hover { transform: scale(1.08); background: var(--blurple); }
.msg-video-play .mi { font-size: calc(34px * var(--ui-scale)); }

/* Clique na imagem abre a tela cheia (lightbox) — figurinhas não */
.msg-attachment img { cursor: zoom-in; }
.msg-attachment.sticker img { cursor: default; }

/* Botão expandir (tela cheia) sobre imagens/vídeos — canto superior direito */
.msg-attachment .attach-expand {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.12s, background 0.15s, transform 0.15s;
  z-index: 6;
}
.msg-attachment:hover .attach-expand,
.msg-attachment .attach-expand:focus-visible { opacity: 1; }
.msg-attachment .attach-expand:hover { background: var(--blurple); transform: scale(1.08); }
.msg-attachment .attach-expand .mi { font-size: calc(18px * var(--ui-scale)); }
/* Toque (sem hover): mantém o expand sempre visível */
@media (hover: none) {
  .msg-attachment .attach-expand { opacity: 1; }
}

/* Card "formato não reproduzível — baixe para visualizar" */
.msg-attachment.file.unsupported {
  display: block;
  max-width: 420px;
}
.msg-attachment.file.unsupported .unsup-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.msg-attachment.file.unsupported .unsup-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-normal);
}
.msg-attachment.file.unsupported .file-download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.msg-attachment.file.unsupported .file-download .mi { font-size: calc(16px * var(--ui-scale)); }
.msg-attachment.file.unsupported .file-note {
  margin-top: 6px;
  font-size: calc(12px * var(--font-scale));
  color: var(--text-muted);
}

/* ---------- Anexo em tela cheia (lightbox p/ imagem/vídeo) ---------- */
.attach-lightbox.modal-backdrop {
  z-index: 400;
  background: rgba(0, 0, 0, 0.92);
  cursor: zoom-out;
}
.attach-lightbox .lightbox-media {
  max-width: 94vw;
  max-height: 92vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.attach-lightbox .lightbox-media img,
.attach-lightbox .lightbox-media video {
  max-width: 94vw;
  max-height: 92vh;
  width: auto;
  height: auto;
  border-radius: 8px;
  background: #000;
  object-fit: contain;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
  cursor: default;
}
.attach-lightbox .lightbox-top {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 10px;
  z-index: 5;
}
.attach-lightbox .lightbox-icon-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.15s;
}
.attach-lightbox .lightbox-icon-btn:hover { background: var(--blurple); transform: scale(1.06); }
.attach-lightbox .lightbox-icon-btn .mi { font-size: calc(22px * var(--ui-scale)); }
.attach-lightbox .lightbox-name {
  position: absolute;
  left: 14px;
  bottom: 14px;
  max-width: 70%;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: calc(13px * var(--font-scale));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  z-index: 5;
}
.attach-lightbox .lightbox-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 40px;
  color: #fff;
  font-size: calc(15px * var(--font-scale));
  text-align: center;
}
.attach-lightbox .lightbox-dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border: none;
  border-radius: 8px;
  background: var(--blurple);
  color: #fff;
  font-size: calc(14px * var(--font-scale));
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.attach-lightbox .lightbox-dl-btn:hover { background: var(--blurple-hover); }

/* ---------- Menu de emojis / GIFs / figurinhas ---------- */
#emoji-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: min(360px, 92vw);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  z-index: 150;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.emoji-menu-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
}

.emoji-tab {
  flex: 1;
  padding: 8px 2px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: calc(11px * var(--ui-scale));
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.emoji-tab.active {
  color: #fff;
  box-shadow: inset 0 -2px 0 var(--blurple);
}

/* Sub-aba "Minhas / Do servidor" (dentro de GIFs/Figurinhas) */
.asset-source-tabs {
  display: flex;
  gap: 6px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-color);
}

.asset-source-tab {
  flex: 1;
  padding: 4px 8px;
  background: var(--bg-input);
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: calc(12px * var(--font-scale));
  font-weight: 600;
  cursor: pointer;
}

.asset-source-tab.active {
  background: var(--blurple);
  color: #fff;
}

.emoji-grid {
  height: 260px;
  display: flex;
  overflow: hidden;
  padding: 0;
}
.asset-grid {
  height: 220px;
  overflow-y: auto;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  gap: 2px;
  align-content: start;
}
/* Navegação por categorias (barra lateral esquerda dos emojis) */
.emoji-empty {
  padding: 24px 8px;
  text-align: center;
  color: var(--text-muted);
  font-size: calc(13px * var(--ui-scale));
}
.emoji-nav {
  flex: 0 0 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  overflow-y: auto;
  border-right: 1px solid var(--border-color);
  background: var(--bg-tertiary);
}
.emoji-nav-btn {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: calc(20px * var(--ui-scale));
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, transform 0.1s;
}
.emoji-nav-btn:hover { background: var(--bg-hover); }
.emoji-nav-btn.active { background: var(--blurple); }
.emoji-nav-btn:active { transform: scale(0.92); }
.emoji-sections {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 4px 8px 8px;
  position: relative;
}
.emoji-section-title {
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: calc(11px * var(--ui-scale));
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 6px 2px 4px;
  background: var(--bg-secondary);
}
.emoji-section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  gap: 2px;
}

.emoji-item {
  background: none;
  border: none;
  font-size: calc(24px * var(--ui-scale));
  line-height: 1;
  padding: 4px;
  border-radius: 6px;
  cursor: pointer;
}

.emoji-item:hover { background: var(--bg-hover); }

.asset-grid {
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 6px;
}

.asset-item {
  position: relative;
  background: var(--bg-input);
  border: none;
  border-radius: 8px;
  padding: 4px;
  cursor: pointer;
  overflow: hidden;
}

.asset-item img {
  width: 100%;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}

.asset-item.sticker img {
  object-fit: contain;
  background: none;
}

.asset-del {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: calc(12px * var(--font-scale));
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

.asset-item:hover .asset-del { opacity: 1; }

/* Overlay de envio de GIF/figurinha: círculo -> check -> some */
.asset-item.sending { cursor: default; }
.asset-send-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 8px;
}
.asset-send-spin {
  width: 22px;
  height: 22px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: asset-spin 0.8s linear infinite;
}
@keyframes asset-spin { to { transform: rotate(360deg); } }
.asset-send-overlay.ok .mi { font-size: calc(28px * var(--ui-scale)); color: var(--green-bright); }

.asset-empty {
  grid-column: 1 / -1;
  color: var(--text-muted);
  font-size: calc(13px * var(--font-scale));
  text-align: center;
  padding: 24px 8px;
}

.emoji-menu-footer {
  border-top: 1px solid var(--border-color);
  padding: 6px 8px;
  display: flex;
  justify-content: flex-end;
}

.emoji-menu-footer .btn-secondary {
  font-size: calc(12px * var(--ui-scale));
  padding: 4px 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ---------- Reações ---------- */
.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: calc(13px * var(--ui-scale));
  color: var(--text-normal);
  cursor: pointer;
  user-select: none;
}

.reaction-chip:hover { border-color: var(--text-muted); }

.reaction-chip.self {
  background: rgba(88, 101, 242, 0.25);
  border-color: var(--blurple);
}

.reaction-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: calc(14px * var(--ui-scale));
  cursor: pointer;
  align-self: center;
  /* Só aparece no hover da mensagem (desktop) ou no long-press (mobile) */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
}

.reaction-add:hover { background: var(--bg-hover); color: #fff; }

.message:hover .reaction-add,
.message.long-press .reaction-add { opacity: 1; pointer-events: auto; }

/* Mobile: segurar a mensagem também revela a barra de ações (responder/editar/apagar) */
.message.long-press .msg-actions { opacity: 1; pointer-events: auto; }

/* ============================================================
   DM COM USUÁRIO INEXISTENTE (conta excluída)
   Substitui o compositor de mensagens: só o chat, sem envio,
   sem call e sem painel de membros (ver js/dm-gone.js).
   ============================================================ */
#message-input-wrap.dm-gone-mode > :not(#dm-gone-notice) { display: none !important; }

.dm-gone {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--bg-input2, rgba(0, 0, 0, 0.25));
  border: 1px solid rgba(240, 71, 71, 0.35);
}
.dm-gone-text { display: flex; align-items: center; gap: 10px; min-width: 0; }
.dm-gone-text .mi { font-size: calc(26px * var(--ui-scale)); color: var(--text-muted, #aaa); flex-shrink: 0; }
.dm-gone-texts { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dm-gone-label { font-size: calc(14px * var(--font-scale)); font-weight: 600; color: var(--text-normal, #f2f3f5); }
.dm-gone-sub { font-size: calc(12px * var(--font-scale)); color: var(--text-muted, #aaa); }
.dm-gone-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dm-gone-actions button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: none;
  border-radius: var(--radius);
  font-size: calc(13px * var(--font-scale));
  font-weight: 600;
  cursor: pointer;
}
.dm-gone-actions button .mi { font-size: calc(18px * var(--ui-scale)); }
.dm-gone-actions .btn-secondary { background: var(--bg-primary); color: var(--text-normal); }
.dm-gone-actions .btn-secondary:hover { background: var(--bg-input); }
.dm-gone-actions .btn-danger { background: var(--red, #ed4245); color: #fff; }
.dm-gone-actions .btn-danger:hover { filter: brightness(1.1); }

/* Cabeçalho "Conversas arquivadas" na lista de DMs */
.dm-archive-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
}
.dm-archive-toggle:hover { color: var(--text-normal, #f2f3f5); }
.dm-archive-toggle .mi { font-size: calc(16px * var(--ui-scale)); }


/* Painel de reação (todos os emojis) — posição é controlada pelo JS (abre no clique) */
#reaction-picker {
  position: fixed;
  bottom: 8px;
  left: 8px;
  width: min(360px, 92vw);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  z-index: 160;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#reaction-picker .emoji-grid {
  height: 260px;
  padding: 0;
}

/* ============================================================
   NOTIFICAÇÕES E MENSAGENS NÃO LIDAS
   ============================================================ */
/* Badge no ícone de servidor (e no Início) */
.server-icon-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--red, #ed4245);
  color: #fff;
  font-size: calc(11px * var(--font-scale));
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-sizing: border-box;
  z-index: 3;
  pointer-events: none;
}

/* Badge na conversa direta (lista de DMs) */
.dm-unread-badge {
  margin-left: auto;
  flex-shrink: 0;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--red, #ed4245);
  color: #fff;
  font-size: calc(11px * var(--font-scale));
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-sizing: border-box;
}

/* Botão de rolar para baixo (fica fixo no fim do container de mensagens) */
#scroll-down-btn {
  position: sticky;
  bottom: 16px;
  display: inline-flex;
  margin-left: auto;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--bg-elevated);
  color: var(--text-normal, #dbdee1);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  z-index: 10;
}
#scroll-down-btn:hover { background: var(--blurple, #5865f2); color: #fff; }
#scroll-down-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--red, #ed4245);
  color: #fff;
  font-size: calc(11px * var(--font-scale));
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-sizing: border-box;
}

/* Banner de nova mensagem no topo da página */
#new-msg-banner {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  max-width: min(420px, 92vw);
  background: var(--bg-elevated);
  color: var(--text-normal, #dbdee1);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--blurple, #5865f2);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: calc(14px * var(--font-scale));
  font-weight: 500;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  animation: banner-in 0.25s ease-out;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#new-msg-banner.hidden { display: none; }
@keyframes banner-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}


/* ---------- Fundo do chat (semi-transparente) + banner do servidor ---------- */
#chat-area { position: relative; }
#chat-bg-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.55;
  display: none;
  pointer-events: none;
}
#chat-bg-layer.active { display: block; }
#chat-bg-layer.theme-screen-bg { opacity: 0.7; }
/* Com fundo de chat ativo, a área fica transparente atrás da camada: uma imagem
   de fundo TRANSPARENTE mostra o fundo do app (body) atrás, em vez do bg sólido.
   (`.has-chat-bg` via JS p/ compat; `:has()` cobre o fundo de tema também.) */
#chat-area.has-chat-bg,
#chat-area:has(#chat-bg-layer.active) { background: transparent; }
/* Transparência TOTAL: remove também o fundo do BODY/HTML atrás da área de chat —
   uma imagem de fundo transparente revela o que está ATRÁS do app (janela/WebView).
   (classe `chat-bg-clear` no <html> p/ compat; `:has` cobre sem ela também.) */
html.chat-bg-clear,
html.chat-bg-clear body { background: transparent; }
html:has(#chat-area.has-chat-bg),
html:has(#chat-area.has-chat-bg) body { background: transparent; }
#chat-header, #messages-container, #message-input-wrap, #call-container,
#new-msg-banner, #mention-banner { position: relative; z-index: 1; }

/* ---------- Overlay de arrastar/soltar arquivo no chat ---------- */
#chat-drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  pointer-events: none; /* o drop é tratado na área de chat (evento sobe pelo bubble) */
}
.chat-drop-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 32px;
  border: 2px dashed var(--blurple, #5865F2);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.45);
  color: var(--text-normal);
  font-size: calc(16px * var(--font-scale));
  font-weight: 600;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}
.chat-drop-box .mi { font-size: calc(34px * var(--ui-scale)); color: var(--blurple, #5865F2); }

/* Fundos de tela do tema (app/login) quando "usar assets do tema" */
#app.theme-screen-bg, #login-screen.theme-screen-bg {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
