:root {
  /* Tema CLARO REFINADO — passa confiança, mas com acabamento profissional:
     verde esmeralda mais rico, neutros mais limpos, sombras suaves e realistas
     (nada de sombra preta pesada), raios e gradiente sutil. */
  --bg: #eceff3;
  --panel: #ffffff;
  --panel-2: #f4f6f8;
  --panel-3: #e7ebef;
  --accent: #0aa17c;
  --accent-dark: #07805f;
  --accent-2: #14b98c;
  --accent-grad: linear-gradient(180deg, #14b98c 0%, #0a9c78 100%);
  --accent-soft: #e6f6f0;
  --on-accent: #ffffff;
  --text: #0e1621;
  --text-dim: #64757f;
  --bubble-out: #d7f4d0;
  --bubble-in: #ffffff;
  --divider: #edeff2;
  --danger: #e0454f;
  --chat-bg: #eae6df;

  /* Elevação — sombras suaves em camadas (tom azulado-escuro, não preto puro). */
  --shadow-sm: 0 1px 2px rgba(16,32,45,.06), 0 1px 1px rgba(16,32,45,.04);
  --shadow-md: 0 4px 12px rgba(16,32,45,.08), 0 2px 4px rgba(16,32,45,.05);
  --shadow-lg: 0 14px 40px rgba(16,32,45,.16), 0 4px 10px rgba(16,32,45,.06);
  --shadow-accent: 0 4px 14px rgba(10,161,124,.32);

  /* Raios consistentes. */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: "Inter", "SF Pro Text", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01";
  letter-spacing: -0.006em;
  overflow: hidden;
}
h1, h2, h3, .sidebar-title, .chat-header-title { letter-spacing: -0.018em; }

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; font-size: 15px; }

/* ---------- AUTH ---------- */
.auth-screen {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(1200px 600px at 50% -10%, #d7f3ea 0%, var(--bg) 55%);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-logo { width: 64px; height: 64px; }
.auth-brand h1 { font-size: 28px; margin-top: 8px; letter-spacing: .5px; }
.auth-tagline { color: var(--text-dim); font-size: 14px; margin-top: 4px; }
.auth-tabs {
  display: flex;
  background: var(--panel-2);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 18px;
}
.auth-tab {
  flex: 1;
  padding: 9px;
  border-radius: 8px;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 14px;
}
.auth-tab.active { background: var(--accent); color: #04130e; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form input {
  background: var(--panel-2);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 13px 14px;
  color: var(--text);
  outline: none;
}
.auth-form input:focus { border-color: var(--accent); }
.btn-primary {
  background: var(--accent);
  color: #04130e;
  font-weight: 700;
  padding: 13px;
  border-radius: 10px;
  margin-top: 4px;
}
.btn-primary:hover { background: var(--accent-dark); }
.auth-sep { display: flex; align-items: center; gap: 10px; color: var(--text-dim); margin: 18px 0 14px; font-size: 13px; }
.auth-sep::before, .auth-sep::after { content: ""; flex: 1; height: 1px; background: var(--divider); }
.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: #fff; color: #1f1f1f; font-weight: 600;
  padding: 12px; border-radius: 10px; text-decoration: none;
}
.btn-google:hover { background: #f3f3f3; }
.auth-hint { color: var(--text-dim); font-size: 13px; text-align: center; margin-top: 10px; }
.btn-link-device { width: 100%; margin-top: 12px; background: transparent; color: var(--text-dim);
  border: 1px solid var(--divider); border-radius: 10px; padding: 11px; font-size: 14px; }
.btn-link-device:hover { color: var(--text); border-color: var(--accent); }
.auth-link-btn { width: 100%; margin-top: 10px; background: transparent; color: var(--accent);
  border: 0; padding: 6px; font-size: 14px; cursor: pointer; }
.auth-link-btn:hover { text-decoration: underline; }
.link-qr { width: 200px; margin: 0 auto 14px; background: #fff; padding: 10px; border-radius: 12px; }
.link-qr svg { display: block; width: 100%; height: auto; }
.link-code { font-size: 34px; font-weight: 700; letter-spacing: 8px; color: var(--accent);
  background: var(--panel-2); border-radius: 12px; padding: 18px; margin: 8px 0 14px; font-family: monospace; }
.auth-error { color: var(--danger); font-size: 13px; text-align: center; min-height: 18px; margin-top: 10px; }
.auth-foot { color: var(--text-dim); font-size: 12px; margin-top: 18px; text-align: center; }

/* ---------- APP LAYOUT ---------- */
.app { display: flex; height: 100%; height: 100dvh; max-width: 1600px; margin: 0 auto; }
.sidebar {
  width: 30%;
  min-width: 300px;
  max-width: 460px;
  background: var(--panel);
  border-right: 1px solid var(--divider);
  display: flex;
  flex-direction: column;
  position: relative;
}
.sidebar-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--panel-2);
}
.sidebar-title { font-weight: 700; font-size: 17px; flex: 1; }
.sidebar-actions { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 17px; color: var(--text-dim);
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--panel-3); color: var(--text); }
.icon-btn svg { width: 22px; height: 22px; }

/* Floating action button — prominent "new conversation" entry point. */
.fab {
  position: absolute; right: 20px; bottom: 20px;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: #04130e;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(0,0,0,.45);
  z-index: 20; transition: transform .12s ease, background .12s;
}
.fab:hover { background: var(--accent-dark); transform: translateY(-2px); }
.fab:active { transform: translateY(0); }
.fab svg { width: 26px; height: 26px; }
.avatar-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent) center/cover no-repeat;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; color: #04130e;
}
.net-indicator { font-size: 12px; color: var(--accent); }
.net-indicator.offline { color: var(--danger); }
.net-indicator.mesh { color: #f0b232; }

/* Emergency SOS */
.sos-btn { background: var(--danger); font-weight: 700; }
.sos-banner {
  position: fixed; left: 50%; top: 16px; transform: translateX(-50%);
  z-index: 9999; max-width: 92vw; min-width: 280px;
  background: var(--danger); color: #fff; border-radius: 14px;
  padding: 14px 16px; box-shadow: 0 10px 40px rgba(0,0,0,.5);
  display: flex; flex-direction: column; gap: 6px;
  animation: sos-pulse 1s ease-in-out infinite alternate;
}
@keyframes sos-pulse { from { box-shadow: 0 10px 40px rgba(0,0,0,.5); } to { box-shadow: 0 0 0 4px rgba(255,80,80,.6), 0 10px 40px rgba(0,0,0,.5); } }
.sos-title { font-size: 18px; font-weight: 800; }
.sos-text { font-size: 14px; opacity: .95; }
.sos-map { color: #fff; text-decoration: underline; font-weight: 600; }
.sos-close {
  align-self: flex-end; margin-top: 4px; background: rgba(0,0,0,.25);
  color: #fff; border: none; border-radius: 8px; padding: 6px 14px; cursor: pointer;
}

/* PWA install button */
.install-app-btn {
  position: fixed; right: 16px; bottom: 16px; z-index: 9998;
  background: var(--accent); color: #04130e; font-weight: 700;
  border: none; border-radius: 24px; padding: 12px 20px; cursor: pointer;
  box-shadow: 0 6px 24px rgba(0,0,0,.45);
}
.install-app-btn:disabled { opacity: .6; }

/* Offline mode + mesh diagnostics */
.offline-state {
  background: var(--panel-2); border-radius: 10px; padding: 12px 14px;
  margin-bottom: 12px; font-weight: 600;
}
.offline-transport { margin: 8px 0; font-size: 14px; }
.diag-h { margin: 14px 0 6px; font-size: 13px; text-transform: uppercase; opacity: .7; letter-spacing: .04em; }
.diag-row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--panel-2); font-size: 14px; }
.diag-k { opacity: .8; }
.diag-v { font-weight: 600; text-align: right; word-break: break-all; }
.diag-test { background: var(--panel-2); border-radius: 10px; padding: 10px 12px; }
.diag-test-head { font-weight: 700; margin-bottom: 6px; }
.diag-step { font-size: 13px; opacity: .9; padding: 2px 0; }
.diag-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.diag-actions button { margin: 0; }

.search-bar { padding: 8px 12px; background: var(--panel); }
.search-bar input {
  width: 100%; background: var(--panel-2); border: none;
  border-radius: 10px; padding: 10px 14px; color: var(--text); outline: none;
}

.chat-list { list-style: none; overflow-y: auto; flex: 1; }
.chat-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; cursor: pointer; border-bottom: 1px solid var(--divider);
  position: relative;
}
.chat-item:hover { background: var(--panel-2); }
.chat-item-menu { position: absolute; top: 8px; right: 8px; opacity: 0;
  width: 26px; height: 26px; border-radius: 50%; color: var(--text-dim); font-size: 16px; }
.chat-item:hover .chat-item-menu { opacity: 1; }
.chat-item-menu:hover { background: var(--panel-3); color: var(--text); }
.badge.muted { background: var(--text-dim); color: var(--panel); }
.archived-toggle { padding: 12px 16px; color: var(--text-dim); cursor: pointer;
  font-size: 14px; border-bottom: 1px solid var(--divider); }
.archived-toggle:hover { background: var(--panel-2); }
.search-section-head { padding: 12px 16px 6px; color: var(--accent); font-size: 13px;
  font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.popup-menu { position: fixed; z-index: 120; background: var(--panel-2);
  border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.5); padding: 6px; min-width: 160px; }
.popup-item { padding: 10px 14px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.popup-item:hover { background: var(--panel-3); }
.chat-item.active { background: var(--panel-3); }
.avatar {
  width: 49px; height: 49px; border-radius: 50%; flex-shrink: 0;
  background: var(--panel-3) center/cover no-repeat;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--text); font-size: 18px;
}
.avatar.sm { width: 40px; height: 40px; font-size: 15px; }
.chat-item-body { flex: 1; min-width: 0; }
.chat-item-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.chat-item-name { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-time { font-size: 12px; color: var(--text-dim); flex-shrink: 0; }
.chat-item-preview { display: flex; justify-content: space-between; gap: 8px; margin-top: 3px; }
.chat-item-last { font-size: 14px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  background: var(--accent); color: #04130e; font-size: 12px; font-weight: 700;
  min-width: 20px; height: 20px; border-radius: 10px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* ---------- CONVERSATION ---------- */
.conversation {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  background: var(--chat-bg);
  position: relative;
  overflow: hidden;
}
.empty-state {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 40px; color: var(--text-dim);
  border-bottom: 4px solid var(--accent);
}
.empty-logo { width: 120px; opacity: .5; margin-bottom: 20px; }
.empty-state h2 { color: var(--text); font-weight: 500; margin-bottom: 10px; }
.empty-state p { max-width: 420px; font-size: 14px; line-height: 1.5; }

.chat-view {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  overflow: hidden;
}
.pinned-bar { display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  background: var(--panel-2); border-bottom: 1px solid var(--divider); border-left: 4px solid var(--accent); }
.pinned-icon { font-size: 16px; }
.pinned-body { flex: 1; min-width: 0; display: flex; flex-direction: column; cursor: pointer; }
.pinned-label { font-size: 12px; color: var(--accent); font-weight: 600; }
.pinned-text { font-size: 13px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mention { color: var(--accent); font-weight: 600; }
.star-label { color: #f0b232; font-size: 11px; }
.msg.flash { animation: flash 1.2s ease; }
@keyframes flash { 0%, 100% { background: var(--bubble-in); } 30% { background: #3a4a52; } }
.msg.out.flash { animation: flashOut 1.2s ease; }
@keyframes flashOut { 0%, 100% { background: var(--bubble-out); } 30% { background: #0a7d68; } }
.mention-suggest { position: absolute; bottom: 64px; left: 14px; right: 14px; max-width: 360px;
  background: var(--panel-2); border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.5);
  overflow: hidden; z-index: 20; }
.mention-opt { display: flex; align-items: center; gap: 10px; padding: 9px 12px; cursor: pointer; }
.mention-opt:hover { background: var(--panel-3); }
.mention-user { color: var(--text-dim); font-size: 13px; margin-left: auto; }
.chat-header {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; background: var(--panel-2); border-left: 1px solid var(--divider);
}
.back-btn { display: none; font-size: 26px; }
.chat-header-info { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; text-align: left; }
.chat-header-title, .chat-header-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-header-actions { flex-shrink: 0; }
.chat-header-text { display: flex; flex-direction: column; }
.chat-header-title { font-weight: 600; font-size: 16px; }
.chat-header-sub { font-size: 12px; color: var(--text-dim); }
.chat-header-sub.typing { color: var(--accent); }

.messages {
  flex: 1; overflow-y: auto; padding: 16px 6%;
  display: flex; flex-direction: column; gap: 2px;
  /* Fundo estilo WhatsApp (claro): bege + padrão de doodles bem sutil. */
  background-color: var(--chat-bg);
  background-image: url('/icons/chat-bg.svg');
  background-repeat: repeat;
  background-size: 360px auto;
}
.day-divider { align-self: center; background: var(--panel-2); color: var(--text-dim);
  font-size: 12px; padding: 5px 12px; border-radius: 8px; margin: 12px 0; }
.system-msg { align-self: center; background: var(--panel-2); color: var(--text-dim);
  font-size: 13px; padding: 6px 14px; border-radius: 8px; margin: 8px 0; text-align: center; }

.call-log { align-self: center; display: flex; align-items: center; gap: 10px;
  background: var(--panel-2); border-radius: 10px; padding: 8px 14px; margin: 6px 0;
  font-size: 14px; max-width: 80%; }
.call-log-icon { font-size: 18px; }
.call-log.missed .call-log-icon, .call-log.missed .call-log-text { color: var(--danger); }
.call-log-text { flex: 1; }
.call-log-time { color: var(--text-dim); font-size: 12px; }
.call-log-btn { width: 34px; height: 34px; border-radius: 50%; background: var(--accent);
  color: #04130e; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; }
.call-log-btn:hover { background: var(--accent-dark); }

.msg { max-width: 75%; padding: 6px 9px 8px; border-radius: 8px; position: relative;
  font-size: 14.5px; line-height: 1.4; word-wrap: break-word; }
.msg.in { align-self: flex-start; background: var(--bubble-in); border-top-left-radius: 2px; }
.msg.out { align-self: flex-end; background: var(--bubble-out); border-top-right-radius: 2px; }
.msg + .msg { margin-top: 2px; }
.msg-sender { font-size: 12.5px; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.msg-reply {
  border-left: 3px solid var(--accent); background: rgba(0,0,0,.05);
  padding: 4px 8px; border-radius: 4px; margin-bottom: 4px; font-size: 13px;
}
.msg-reply .rname { color: var(--accent); font-weight: 600; display: block; }
.msg-reply .rtext { color: var(--text-dim); }
.msg-body { white-space: pre-wrap; }
.msg-media img { max-width: 260px; border-radius: 6px; display: block; margin-bottom: 4px; cursor: pointer; }
.msg-file { display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,.05);
  padding: 10px; border-radius: 6px; margin-bottom: 4px; text-decoration: none; color: var(--text); }
.msg-file .file-ic { font-size: 24px; }
.msg-deleted { font-style: italic; color: var(--text-dim); }
.msg-encrypted { font-style: italic; color: var(--text-dim); }
.msg-forwarded { font-size: 12.5px; color: var(--text-dim); font-style: italic; margin-bottom: 2px; }
.edited-label { font-style: italic; opacity: .8; }
.msg-meta { display: flex; align-items: center; justify-content: flex-end; gap: 4px;
  font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.msg.out .msg-meta { color: rgba(17,27,33,.45); }
.tick { font-size: 13px; }
.tick.read { color: #53bdeb; }
.tick.failed { color: var(--danger); cursor: pointer; }
.msg-reactions { display: flex; gap: 3px; position: absolute; bottom: -10px;
  right: 6px; background: var(--panel-3); border-radius: 10px; padding: 1px 6px; font-size: 12px;
  cursor: pointer; border: 1px solid var(--panel); }
.msg-reactions.mine { background: var(--bubble-out); }
.emoji-popup { position: fixed; z-index: 140; background: var(--panel-2); border-radius: 24px;
  box-shadow: 0 8px 28px rgba(0,0,0,.5); padding: 6px 8px; display: flex; flex-wrap: wrap;
  gap: 2px; max-width: 280px; }
.emoji-opt { font-size: 22px; width: 38px; height: 38px; border-radius: 50%; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; }
.emoji-opt:hover { background: var(--panel-3); transform: scale(1.15); }
.msg-actions { position: absolute; top: 2px; right: 4px; opacity: 0; display: flex; gap: 2px; }
.msg:hover .msg-actions { opacity: 1; }
.msg-actions button { font-size: 13px; width: 24px; height: 22px; border-radius: 5px;
  background: rgba(0,0,0,.06); }
.msg-actions button:hover { background: rgba(0,0,0,.14); }

/* reply preview + composer */
.reply-preview { display: flex; align-items: center; gap: 8px; padding: 8px 16px;
  background: var(--panel-2); border-left: 3px solid var(--accent); }
.reply-preview-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.reply-preview-name { color: var(--accent); font-weight: 600; font-size: 13px; }
.reply-preview-text { color: var(--text-dim); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.block-banner { display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 16px; background: var(--panel-2); color: var(--text-dim); font-size: 14px; }
.block-banner button { color: var(--accent); font-weight: 600; }
.block-banner button:hover { text-decoration: underline; }
.composer {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--panel-2);
  flex-wrap: nowrap;
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}
.composer textarea {
  flex: 1;
  width: 0;
  min-width: 0;
  resize: none;
  max-height: 120px;
  min-height: 40px;
  background: var(--panel-3);
  border: none;
  border-radius: 10px;
  padding: 11px 14px;
  color: var(--text);
  outline: none;
  line-height: 1.4;
}
.send-btn {
  background: var(--accent);
  color: #04130e;
  font-size: 18px;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,168,132,.28);
}
.send-btn:hover { background: var(--accent-dark); color: #04130e; }

/* ---------- MODALS ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal { background: var(--panel); border-radius: 14px; width: 100%; max-width: 420px;
  max-height: 85vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-header { padding: 16px 20px; background: var(--panel-2); display: flex;
  align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 17px; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-body input[type=text], .modal-body input[type=search] {
  width: 100%; background: var(--panel-2); border: none; border-radius: 10px;
  padding: 12px 14px; color: var(--text); outline: none; margin-bottom: 12px;
}
.user-result { display: flex; align-items: center; gap: 12px; padding: 10px 6px;
  border-radius: 8px; cursor: pointer; }
.user-result:hover { background: var(--panel-2); }
.user-result-body { flex: 1; min-width: 0; }
.user-result-name { font-weight: 600; }
.user-result-sub { font-size: 13px; color: var(--text-dim); }
.user-result .check { color: var(--accent); font-size: 18px; }
.modal-footer { padding: 14px 20px; background: var(--panel); display: flex; gap: 10px; justify-content: flex-end; }
.modal-footer .btn-primary { margin: 0; padding: 10px 20px; }
.profile-avatar-big { width: 110px; height: 110px; border-radius: 50%; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center; font-size: 42px; font-weight: 700;
  background: var(--accent) center/cover no-repeat; color: #04130e; }
.field-label { font-size: 13px; color: var(--accent); margin-bottom: 4px; }
.select-input { width: 100%; background: var(--panel-2); border: none; border-radius: 10px;
  padding: 11px 14px; color: var(--text); outline: none; }
.field-row { margin-bottom: 16px; }
.settings-section { font-size: 15px; color: var(--text); margin: 18px 0 10px;
  padding-bottom: 6px; border-bottom: 1px solid var(--panel-3); }
.settings-section:first-child { margin-top: 0; }

/* ---------- HEADER ACTIONS / VOICE ---------- */
.chat-header-actions { display: flex; gap: 2px; }
.composer.recording textarea { display: none; }
.rec-indicator { flex: 1; display: flex; align-items: center; gap: 8px; color: var(--danger);
  font-size: 14px; padding: 0 8px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger);
  animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
#mic-btn.recording { background: var(--danger); color: #fff; }
.msg-audio audio { height: 40px; max-width: 240px; }

/* ---------- CALL OVERLAY ---------- */
.call-overlay { position: fixed; inset: 0; z-index: 200; background: #04130e;
  display: flex; flex-direction: column; align-items: center; justify-content: center; }
.call-remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  background: #04130e; display: none; }
.call-overlay.video-call .call-remote { display: block; }
.call-local { position: absolute; bottom: 110px; right: 18px; width: 110px; height: 150px;
  object-fit: cover; border-radius: 12px; border: 2px solid rgba(255,255,255,.25);
  background: #000; display: none; z-index: 2; }
.call-overlay.video-call .call-local { display: block; }
.call-info { position: relative; z-index: 1; text-align: center; color: #fff; }
.call-overlay.video-call .call-info { position: absolute; top: 40px; }
.call-avatar { width: 130px; height: 130px; border-radius: 50%; margin: 0 auto 18px;
  background: var(--accent) center/cover no-repeat; display: flex; align-items: center;
  justify-content: center; font-size: 48px; font-weight: 700; color: #04130e; }
.call-overlay.video-call .call-avatar { display: none; }
.call-name { font-size: 24px; font-weight: 600; }
.call-status { font-size: 15px; color: var(--text-dim); margin-top: 6px; min-height: 20px; }
.call-controls { position: absolute; bottom: 36px; z-index: 3; display: flex; gap: 18px; }
.call-btn { width: 60px; height: 60px; border-radius: 50%; font-size: 24px;
  background: rgba(255,255,255,.18); color: #fff; display: flex; align-items: center; justify-content: center; }
.call-btn:hover { background: rgba(255,255,255,.3); }
.call-btn.off { background: #fff; color: #04130e; }
.call-btn.accept { background: var(--accent); }
.call-btn.hangup { background: var(--danger); }

/* ---------- GROUP CALLS ---------- */
.gcall-overlay { position: fixed; inset: 0; z-index: 200; background: #04130e;
  display: flex; flex-direction: column; }
.gcall-grid { flex: 1; display: grid; gap: 6px; padding: 10px; align-content: center; }
.gcall-tile { position: relative; background: #000; border-radius: 12px; overflow: hidden;
  aspect-ratio: 3/4; max-height: 100%; }
.gcall-tile video { width: 100%; height: 100%; object-fit: cover; }
.gcall-name { position: absolute; bottom: 6px; left: 8px; color: #fff; font-size: 13px;
  background: rgba(0,0,0,.4); padding: 2px 8px; border-radius: 8px; }
.gcall-controls { display: flex; justify-content: center; gap: 18px; padding: 18px; }
.gcall-incoming { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 210; background: var(--panel-3); color: var(--text); padding: 14px 18px;
  border-radius: 14px; display: flex; align-items: center; gap: 12px; box-shadow: 0 8px 28px rgba(0,0,0,.5);
  flex-wrap: wrap; max-width: 92vw; }
.gcall-incoming .btn-primary { margin: 0; padding: 8px 18px; }
.gcall-dismiss { color: var(--text-dim); padding: 8px 14px; }

/* ---------- STATUS / STORIES ---------- */
.net-indicator.has-status, #status-btn.has-status { color: var(--accent); }
#status-btn.has-status { position: relative; }
.status-ring { display: inline-flex; border-radius: 50%; padding: 2px;
  background: var(--accent); }
.status-ring.seen { background: var(--panel-3); }
.status-ring .avatar { border: 2px solid var(--panel); }

.status-compose-preview { min-height: 200px; border-radius: 12px; display: flex;
  align-items: center; justify-content: center; padding: 16px; color: #fff; }
.status-compose-text { background: transparent; border: none; outline: none; color: #fff;
  text-align: center; font-size: 22px; width: 100%; resize: none; }
.status-compose-text::placeholder { color: rgba(255,255,255,.7); }
.status-swatches { display: flex; gap: 6px; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255,255,255,.3); }

.status-viewer { position: fixed; inset: 0; z-index: 200; background: #000;
  display: flex; flex-direction: column; }
.status-bars { display: flex; gap: 4px; padding: 10px 12px 4px; }
.status-bar { flex: 1; height: 3px; background: rgba(255,255,255,.3); border-radius: 2px; overflow: hidden; }
.status-bar-fill { display: block; height: 100%; width: 0; background: #fff; }
.status-viewer-head { display: flex; align-items: center; gap: 10px; padding: 6px 14px; color: #fff; }
.status-time { font-size: 12px; color: rgba(255,255,255,.7); }
.status-viewer-content { flex: 1; display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden; cursor: pointer; }
.status-text { color: #fff; font-size: 26px; text-align: center; padding: 24px; white-space: pre-wrap; }
.status-img { max-width: 100%; max-height: 100%; object-fit: contain; }
.status-caption { position: absolute; bottom: 24px; left: 0; right: 0; text-align: center;
  color: #fff; padding: 0 20px; text-shadow: 0 1px 4px rgba(0,0,0,.7); }
.status-viewer-foot { display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 14px; }
.status-viewers-btn, .status-del-btn { color: #fff; background: rgba(255,255,255,.18);
  padding: 8px 18px; border-radius: 20px; font-size: 15px; }
.status-viewers-btn:hover, .status-del-btn:hover { background: rgba(255,255,255,.3); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel-3); color: var(--text); padding: 12px 20px; border-radius: 24px;
  font-size: 14px; z-index: 100; box-shadow: 0 6px 24px rgba(0,0,0,.4); }

/* ---------- MEDIA DOWNLOAD PLACEHOLDER ---------- */
.media-download-btn {
  background: rgba(0,0,0,.25); color: var(--text);
  border: 1px solid rgba(255,255,255,.12);
  padding: 22px 18px; border-radius: 8px; font-size: 14px; font-weight: 600;
  width: 220px; max-width: 60vw; display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .12s ease;
}
.media-download-btn:hover { background: rgba(0,0,0,.42); }

/* ---------- FOLDER TABS (Telegram-style chat filters) ---------- */
.folder-tabs { display: flex; gap: 6px; padding: 2px 12px 8px; overflow-x: auto; background: var(--panel); }
.folder-tab { padding: 6px 14px; border-radius: 16px; font-size: 13px; font-weight: 600;
  color: var(--text-dim); background: var(--panel-2); white-space: nowrap; flex-shrink: 0;
  transition: background .12s, color .12s; }
.folder-tab.active { background: var(--accent); color: #04130e; }

/* ---------- POLLS ---------- */
.poll { min-width: 220px; max-width: 320px; }
.poll-q { font-weight: 600; margin-bottom: 8px; }
.poll-opt { position: relative; padding: 9px 34px 9px 12px; border-radius: 8px; margin-bottom: 6px;
  background: rgba(0,0,0,.05); cursor: pointer; overflow: hidden; }
.poll-opt.voted { outline: 1px solid var(--accent); }
.poll-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: rgba(0,168,132,.28);
  transition: width .3s ease; }
.poll-opt-label { position: relative; z-index: 1; font-size: 14px; }
.poll-opt-count { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); z-index: 1;
  font-size: 12px; color: var(--text-dim); }
.poll-total { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* ---------- PREMIUM POLISH ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--panel-3); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #3a4a52; }
::-webkit-scrollbar-track { background: transparent; }

.msg { box-shadow: 0 1px 1px rgba(0,0,0,.13); }
.chat-item { transition: background .12s ease; }
.send-btn, .btn-primary, .auth-tab, .call-btn, .fab { transition: background .12s ease, transform .1s ease, color .12s; }
.send-btn:active, .fab:active { transform: scale(.93); }
.modal { box-shadow: 0 24px 70px rgba(0,0,0,.55); }
.sidebar-header { box-shadow: 0 1px 0 rgba(0,0,0,.25); position: relative; z-index: 2; }
.avatar-btn { transition: box-shadow .15s ease; }
.avatar-btn:hover { box-shadow: 0 0 0 2px rgba(0,168,132,.55); }
.auth-card { border: 1px solid rgba(255,255,255,.04); }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 768px) {
  .sidebar { width: 100%; max-width: none; min-width: 0; }
  .app.in-chat .sidebar { display: none; }
  .app:not(.in-chat) .conversation { display: none; }
  .back-btn { display: inline-flex; }
  .msg { max-width: 85%; }
}

/* ---------- SEGURANÇA / CRIPTOGRAFIA ---------- */
/* Banner de "ponta a ponta" no topo da conversa (estilo WhatsApp). */
.e2ee-banner { align-self: center; max-width: 90%; text-align: center;
  background: #fdf3c9; color: #6b5b00; font-size: 12.5px; line-height: 1.45;
  padding: 8px 14px; border-radius: 8px; margin: 10px 0 14px; }
.e2ee-banner .lock { margin-right: 4px; }
/* Selo de segurança (login / apresentação). */
.trust-badge { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px;
  font-size: 12.5px; color: var(--text-dim); }
.trust-badge .lock { color: var(--accent); font-size: 14px; }

/* ---------- PRÉVIA DE LINKS (notícias) ---------- */
.msg-link { color: #027eb5; text-decoration: underline; word-break: break-all; }
.msg.out .msg-link { color: #056b2e; }
.link-preview {
  display: block; margin-top: 8px; border-radius: 14px; overflow: hidden;
  background: var(--panel-3); text-decoration: none; color: inherit;
  max-width: 360px; border: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 4px 20px rgba(0,0,0,.22);
  transition: transform .15s ease, box-shadow .15s ease;
}
.link-preview:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(0,0,0,.3); }
.link-preview img { width: 100%; max-height: 200px; object-fit: cover; display: block; }
.link-preview-body { padding: 10px 12px 12px; }
.link-preview-site {
  font-size: 11px; color: var(--accent); margin-bottom: 4px;
  text-transform: uppercase; letter-spacing: .6px; font-weight: 700;
}
.link-preview-title {
  font-weight: 700; font-size: 14.5px; color: var(--text); line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.link-preview-desc {
  font-size: 12.5px; color: var(--text-2); margin-top: 4px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.link-preview-loading { padding: 14px 14px; font-size: 13px; color: var(--text-dim); display: flex; align-items: center; gap: 8px; }

/* Composer live link preview card */
#composer-link-preview {
  border-radius: 12px 12px 0 0; overflow: hidden;
  background: var(--panel-3); border-top: 3px solid var(--accent);
  display: none; flex-direction: row; align-items: stretch;
  max-height: 90px; border-bottom: 1px solid rgba(255,255,255,.06);
}
#composer-link-preview img { width: 90px; object-fit: cover; flex-shrink: 0; }
.composer-preview-body { padding: 8px 10px; flex: 1; overflow: hidden; }
.composer-preview-title { font-weight: 700; font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer-preview-site { font-size: 11px; color: var(--accent); font-weight: 700; margin-bottom: 2px; text-transform: uppercase; letter-spacing: .5px; }
.composer-preview-desc { font-size: 11.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#composer-preview-close { background: none; border: none; cursor: pointer; color: var(--text-dim); font-size: 18px; padding: 0 8px; flex-shrink: 0; align-self: center; }

/* ---------- VÍDEO ---------- */
.msg-video { max-width: 280px; max-height: 360px; border-radius: 8px; display: block;
  margin-bottom: 4px; background: #000; }

/* ---------- BANHO DE LOJA: ícones com mais destaque ---------- */
/* Ícones dos menus deixam de ser "apagados": tom mais forte e contraste no hover. */
.icon-btn { color: #54656f; }
.icon-btn:hover { background: rgba(0,0,0,.06); color: #111b21; }
.chat-header-actions .icon-btn,
.sidebar-actions .icon-btn { color: #3b4a54; }
.chat-header-actions .icon-btn:hover,
.sidebar-actions .icon-btn:hover { background: rgba(0,168,132,.12); color: var(--accent-dark); }
.sidebar-header { box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.chat-header { box-shadow: 0 1px 3px rgba(0,0,0,.06); position: relative; z-index: 2; }

/* Cartão de arquivo mais elegante (ícone num quadradinho colorido). */
.msg-file { gap: 12px; background: rgba(0,0,0,.04); padding: 10px 12px; }
.msg-file .file-ic { display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px; background: var(--accent);
  color: #fff; font-size: 20px; flex-shrink: 0; }

/* Call log repaginado: ícone colorido em círculo + seta de direção. */
.call-log { gap: 12px; padding: 9px 12px; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.call-log-icon { display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 50%; background: rgba(0,168,132,.14);
  color: var(--accent-dark); font-size: 17px; }
.call-log.missed .call-log-icon { background: rgba(229,83,95,.14); color: var(--danger); }
.call-log-dir { font-size: 12px; }
.call-log-btn { width: 40px; height: 40px; box-shadow: 0 2px 6px rgba(0,168,132,.35); }

/* Botões do composer com mais presença. */
.composer .icon-btn {
  color: #54656f;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 40px;
  width: 40px;
  min-width: 40px;
  height: 40px;
  min-height: 40px;
  line-height: 1;
}
.composer .icon-btn:hover { color: var(--accent-dark); background: rgba(0,168,132,.1); }
.composer .send-btn,
.composer .send-btn:hover {
  background: var(--accent);
  color: #04130e;
}
.composer .send-btn:hover { background: var(--accent-dark); }

/* ---------- BLOQUEIO DO APP (PIN / digital) ---------- */
.applock-overlay { position: fixed; inset: 0; z-index: 10000;
  background: radial-gradient(1200px 600px at 50% -10%, #d7f3ea 0%, #f0f2f5 55%);
  display: flex; align-items: center; justify-content: center; padding: 24px; }
.applock-card { width: 100%; max-width: 340px; background: #fff; border-radius: 18px;
  padding: 30px 24px; text-align: center; box-shadow: 0 24px 70px rgba(0,0,0,.18);
  display: flex; flex-direction: column; align-items: center; }
.applock-logo { width: 72px; height: 72px; margin-bottom: 14px; }
.applock-title { font-size: 20px; font-weight: 700; color: #111b21; }
.applock-sub { font-size: 14px; color: #667781; margin: 4px 0 18px; }
.applock-pin { width: 100%; text-align: center; font-size: 24px; letter-spacing: 8px;
  background: #f0f2f5; border: 2px solid transparent; border-radius: 12px; padding: 14px;
  color: #111b21; outline: none; }
.applock-pin:focus { border-color: #00a884; }
.applock-error { color: #e5535f; font-size: 13px; min-height: 18px; margin: 8px 0; }
.applock-unlock { width: 100%; background: #00a884; color: #04130e; font-weight: 700;
  font-size: 16px; padding: 13px; border-radius: 12px; }
.applock-unlock:hover { background: #008f6f; }
.applock-bio { margin-top: 12px; background: transparent; color: #00a884; font-weight: 600;
  font-size: 15px; padding: 8px; }

/* ============================================================
   PREMIUM AUDIO PLAYER
   ============================================================ */
.msg-audio-player { padding: 8px 10px 6px; border-radius: 14px; width: 100%; max-width: 320px; }
.ap-row { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.ap-play {
  width: 36px; height: 36px; border-radius: 50%; border: none; cursor: pointer; flex-shrink: 0;
  background: var(--accent); color: #fff; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .1s;
  box-shadow: 0 2px 8px rgba(0,168,132,.4);
}
.ap-play:hover { background: var(--accent-dark); transform: scale(1.08); }
.ap-play.playing { background: var(--accent-dark); }
.ap-time, .ap-dur { font-size: 11px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; flex-shrink: 0; }
.ap-track {
  flex: 1; height: 4px; background: rgba(0,0,0,.12); border-radius: 2px; position: relative;
  cursor: pointer; margin: 0 2px;
}
.ap-fill { height: 100%; background: var(--accent); border-radius: 2px; width: 0; transition: width .08s linear; }
.ap-knob {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 12px; height: 12px; border-radius: 50%; background: var(--accent);
  left: -6px; box-shadow: 0 1px 4px rgba(0,0,0,.22); transition: left .08s linear;
}
.ap-speed {
  font-size: 10px; font-weight: 700; background: rgba(0,0,0,.06); border: none; border-radius: 4px;
  padding: 2px 5px; cursor: pointer; color: var(--text-2); flex-shrink: 0;
}
.ap-speed:hover { background: rgba(0,168,132,.14); color: var(--accent-dark); }
.ap-name {
  font-size: 11.5px; color: var(--text-2); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; margin-bottom: 2px; max-width: 280px;
}
.ap-audio-el { display: none; } /* Hidden – we control playback via JS */

/* ============================================================
   IMAGE LIGHTBOX
   ============================================================ */
.lightbox-overlay {
  position: fixed; inset: 0; z-index: 99000; background: rgba(0,0,0,.88);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .22s ease; pointer-events: none;
}
.lightbox-overlay.open { opacity: 1; pointer-events: all; }
.lightbox-img {
  max-width: 92vw; max-height: 90vh; border-radius: 8px; object-fit: contain;
  box-shadow: 0 12px 60px rgba(0,0,0,.6);
  user-select: none; -webkit-user-drag: none;
}
.lightbox-close {
  position: absolute; top: 16px; right: 20px; background: rgba(255,255,255,.12);
  border: none; color: #fff; font-size: 22px; cursor: pointer; border-radius: 50%;
  width: 42px; height: 42px; display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px); transition: background .15s;
}
.lightbox-close:hover { background: rgba(255,255,255,.25); }
.lightbox-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,.14); border: none; color: #fff; font-size: 36px;
  cursor: pointer; border-radius: 50%; width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px); transition: background .15s; z-index: 1;
}
.lightbox-nav:hover { background: rgba(255,255,255,.28); }
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }
.lightbox-counter {
  position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,.7); font-size: 13px; font-weight: 600; letter-spacing: .5px;
}
.msg-img { cursor: zoom-in; }

/* ============================================================
   FILE ATTACHMENT CARD (upgraded)
   ============================================================ */
.msg-file {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel-3); padding: 10px 12px; border-radius: 12px;
  text-decoration: none; color: inherit; max-width: 280px;
  border: 1px solid rgba(0,0,0,.06);
  transition: background .15s;
}
.msg-file:hover { background: rgba(0,168,132,.07); }
.msg-file .file-ic {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 10px; background: var(--accent);
  color: #fff; font-size: 20px; flex-shrink: 0;
}
.msg-file .file-info { flex: 1; overflow: hidden; }
.msg-file .file-name { font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.msg-file .file-size { font-size: 11px; color: var(--text-2); }
.msg-file .file-dl { font-size: 16px; color: var(--accent); flex-shrink: 0; }

/* ============================================================
   UPLOAD PROGRESS TOAST
   ============================================================ */
.upload-progress-toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--panel-2); border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.25);
  padding: 12px 16px; min-width: 220px; display: flex; flex-direction: column; gap: 8px;
  z-index: 9000; opacity: 0; transition: opacity .25s, transform .25s;
  font-size: 13px; color: var(--text); font-weight: 500;
}
.upload-progress-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.upload-progress-bar {
  height: 4px; border-radius: 2px; background: var(--accent);
  width: 0; transition: width .15s ease;
}

/* SpeedVox status visual: verde quando Socket.IO está conectado */
.net-indicator {
  transition: color .18s ease, text-shadow .18s ease, opacity .18s ease;
}

.net-indicator.online {
  color: #22c55e !important;
  text-shadow: 0 0 8px rgba(34, 197, 94, .75);
}

.net-indicator.connecting {
  color: #eab308 !important;
  text-shadow: 0 0 8px rgba(234, 179, 8, .55);
}

.net-indicator.offline {
  color: var(--danger, #ef4444) !important;
}

/* ---------- GARANTIA: botão de enviar SEMPRE visível (PWA e APK) ---------- */
.composer #send-btn, .composer #mic-btn {
  display: inline-flex !important;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  min-width: 40px; min-height: 40px;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  position: relative;
  z-index: 2;
}
/* O texto não pode "empurrar" os botões pra fora da tela. */
.composer { flex-wrap: nowrap; }
.composer textarea { flex: 1 1 auto; min-width: 0; }

@media (max-width: 380px) {
  .composer {
    gap: 4px;
    padding-left: 8px;
    padding-right: 8px;
  }
  .composer .icon-btn,
  .composer #send-btn,
  .composer #mic-btn {
    flex-basis: 38px;
    width: 38px;
    min-width: 38px;
    height: 38px;
    min-height: 38px;
  }
  .composer textarea {
    padding-left: 11px;
    padding-right: 11px;
  }
}

/* ============================================================================
   REPAGINAÇÃO PROFISSIONAL (claro refinado + verde refinado)
   Bloco de polimento aditivo — refina o acabamento sem reescrever o layout.
   ========================================================================== */

/* Scrollbars finas e discretas (grande sinal de app profissional). */
* { scrollbar-width: thin; scrollbar-color: rgba(16,32,45,.18) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(16,32,45,.16); border-radius: 8px;
  border: 2px solid transparent; background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(16,32,45,.30); background-clip: padding-box; }

/* Transições suaves nos elementos interativos. */
.btn-primary, .icon-btn, .send-btn, .fab, .chat-item, .user-result, .popup-item,
.auth-tab, .avatar-btn, .call-btn, input, textarea, .select-input {
  transition: background-color .15s ease, color .15s ease, box-shadow .15s ease,
    transform .12s ease, border-color .15s ease, filter .15s ease;
}

/* Botões primários: verde em gradiente sutil, elevação leve, feedback ao tocar.
   (Botões secundários definem a cor de fundo inline, então continuam cinza.) */
.btn-primary { background: var(--accent-grad); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-grad); filter: brightness(1.06); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:active { transform: translateY(0); filter: brightness(.97); }

/* Botões de ação verdes dedicados: ícone branco + sombra esverdeada. */
.fab, .send-btn { background: var(--accent-grad); color: var(--on-accent); box-shadow: var(--shadow-accent); }
.fab:hover { background: var(--accent-grad); filter: brightness(1.06); box-shadow: var(--shadow-lg); }
.send-btn:hover { background: var(--accent-grad); color: var(--on-accent); filter: brightness(1.06); }
.icon-btn:active { transform: scale(.92); }

/* Abas do login em verde gradiente. */
.auth-tab.active { background: var(--accent-grad); color: var(--on-accent); box-shadow: var(--shadow-sm); }

/* Foco claro e elegante nos campos (anel verde suave). */
.auth-form input:focus, .search-bar input:focus, .composer textarea:focus,
.modal-body input:focus, .modal-body input[type=text]:focus,
.modal-body input[type=search]:focus, .select-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(10,161,124,.16);
}

/* Superfícies flutuantes: sombra suave em vez de sombra preta pesada. */
.auth-card { box-shadow: var(--shadow-lg); border-radius: var(--radius-lg); border: 1px solid var(--divider); }
.modal { box-shadow: var(--shadow-lg); border-radius: var(--radius-lg); }
.modal-backdrop { background: rgba(11,18,26,.42); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.popup-menu, .emoji-popup, .mention-suggest, .gcall-incoming, .sos-banner { box-shadow: var(--shadow-lg); }

/* Cabeçalhos e compositor: branco limpo com uma hairline (mais moderno). */
.sidebar { box-shadow: var(--shadow-sm); }
.sidebar-header, .chat-header { background: var(--panel); border-bottom: 1px solid var(--divider); }
.composer { background: var(--panel); border-top: 1px solid var(--divider); }
.search-bar input { border: 1px solid var(--divider); }

/* Lista de conversas: hover suave e ativo com barra de destaque + fundo verde claro. */
.chat-item { border-bottom: 1px solid var(--divider); }
.chat-item:hover { background: var(--panel-2); }
.chat-item.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.avatar { box-shadow: 0 0 0 1px rgba(16,32,45,.05); }

/* Balões de mensagem: cantos mais suaves + sombra sutil (dão profundidade). */
.msg { border-radius: 10px; box-shadow: var(--shadow-sm); }
.msg.in { border-top-left-radius: 4px; }
.msg.out { border-top-right-radius: 4px; }

/* Estado vazio: sem a borda verde grossa (parecia amador). */
.empty-state { border-bottom: none; }

/* Badge de não-lidas com leve elevação. */
.badge { box-shadow: var(--shadow-sm); }

/* Mais "respiro" e alvos de toque maiores (≥44px) — sensação premium.
   O texto respira mais dentro das bolhas; os ícones ficam fáceis de acertar. */
.msg { padding: 8px 12px 9px; }
.icon-btn { width: 42px; height: 42px; }
.chat-item { padding: 13px 14px; }
.composer .icon-btn, #send-btn, #mic-btn { width: 44px; height: 44px; }
.composer textarea { padding: 12px 16px; }
.messages { padding-top: 18px; padding-bottom: 18px; gap: 3px; }

/* Cabeçalho/compositor translúcidos (vidro fosco) — só onde há conteúdo atrás
   pra desfocar; discreto o suficiente pra não pesar. */
.chat-header { background: rgba(255,255,255,.82); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); }
.composer { background: rgba(255,255,255,.86); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); }

/* Ícones Lucide (traço) nos botões de ação — tamanho consistente e centrados. */
.msg-actions button { display: inline-flex; align-items: center; justify-content: center; }
.msg-actions svg { width: 15px; height: 15px; }
.chat-item-menu { display: inline-flex; align-items: center; justify-content: center; }
.call-log-btn svg { display: block; }

/* ---- Micro-interações (CSS puro, sem framework) ---- */
@keyframes sv-modal-in { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes sv-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sv-pop-in { from { opacity: 0; transform: translateY(-5px) scale(.96); } to { opacity: 1; transform: none; } }

/* Superfícies que surgem: entrada suave (aparecem uma vez, sem replay). */
.modal { animation: sv-modal-in .2s cubic-bezier(.2,.8,.2,1); }
.modal-backdrop { animation: sv-fade-in .16s ease; }
.popup-menu, .emoji-popup, .mention-suggest, .gcall-incoming { animation: sv-pop-in .15s cubic-bezier(.2,.8,.2,1); }

/* Feedback visual ao tocar (afunda levemente — casa com o haptic). */
.msg-actions button:active, .call-btn:active, .popup-item:active, .user-result:active,
.emoji-opt:active, .auth-tab:active, .call-log-btn:active, .chat-item-menu:active { transform: scale(.93); }
.send-btn:active, .fab:active { transform: scale(.9); }

/* Reações "pulam" com um leve overshoot ao passar o dedo. */
.emoji-opt { transition: transform .16s cubic-bezier(.2,1.5,.4,1), background-color .12s ease; }
.emoji-opt:hover { transform: scale(1.25); }
.msg-reactions { transition: transform .12s ease; }
.msg-reactions:active { transform: scale(.9); }

/* Itens de menu popup: ícone Lucide + texto alinhados. */
.popup-item { display: flex; align-items: center; gap: 10px; }
.popup-item svg { flex: 0 0 auto; color: var(--text-dim); }

/* Cartões de anexo: localização, contato, evento, Pix. */
.attach-card { background: var(--panel-2); border: 1px solid var(--divider); border-radius: 12px; padding: 10px 12px; margin-bottom: 4px; max-width: 260px; }
.attach-card-head { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.attach-card-head svg { color: var(--accent); flex: 0 0 auto; }
.attach-card-sub { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.attach-card-btn { display: inline-block; margin-top: 8px; background: var(--accent-soft); color: var(--accent-dark);
  font-weight: 600; font-size: 13px; padding: 7px 12px; border-radius: 8px; text-decoration: none; border: none; cursor: pointer; }
.attach-card-btn:hover { filter: brightness(.97); }

/* Acessibilidade: respeita quem pediu menos animação no sistema. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
