/* Visual inspirado no WhatsApp Web */
:root {
  --rail: #f0f2f5;
  --panel: #ffffff;
  --head: #ffffff;
  --hover: #f5f6f6;
  --selected: #f0f2f5;
  --input: #f0f2f5;
  --divider: #e9edef;
  --text: #111b21;
  --text-2: #3b4a54;
  --muted: #667781;
  --icon: #54656f;
  --green: #00a884;
  --green-dark: #008069;
  --badge: #25d366;
  --chip-on-bg: #d9fdd3;
  --chip-on-text: #15603e;
  --chip-border: #d1d7db;
  --chat-bg: #efeae2;
  --doodle: rgba(140, 120, 90, .07);
  --in: #ffffff;
  --out: #d9fdd3;
  --quote-bg: rgba(11, 20, 26, .05);
  --system: #ffffff;
  --tick: #8696a0;
  --tick-read: #53bdeb;
  --red: #ea0038;
  --orange: #e8710a;
  --warn-bg: #fff8d6;
  --warn-text: #54656f;
  --menu: #ffffff;
  --shadow: 0 1px .5px rgba(11, 20, 26, .13);
  --shadow-pop: 0 2px 5px rgba(11, 20, 26, .26), 0 2px 10px rgba(11, 20, 26, .16);
  --names: #1f7aec, #e542a3, #fa6533, #6bcbef, #a5b337, #35cd96, #7f66ff, #c75300;
}
@media (prefers-color-scheme: dark) {
  :root {
    --rail: #202c33;
    --panel: #111b21;
    --head: #202c33;
    --hover: #202c33;
    --selected: #2a3942;
    --input: #202c33;
    --divider: #222d34;
    --text: #e9edef;
    --text-2: #d1d7db;
    --muted: #8696a0;
    --icon: #aebac1;
    --chip-on-bg: #0a332c;
    --chip-on-text: #00a884;
    --chip-border: #2a3942;
    --chat-bg: #0b141a;
    --doodle: rgba(255, 255, 255, .035);
    --in: #202c33;
    --out: #005c4b;
    --quote-bg: rgba(0, 0, 0, .2);
    --system: #182229;
    --warn-bg: #2a2f20;
    --warn-text: #d1d7db;
    --menu: #233138;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14.2px/1.45 "Segoe UI", "Helvetica Neue", Helvetica, system-ui, -apple-system, Roboto, sans-serif;
  background: var(--rail); color: var(--text); -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 24px; height: 24px; fill: currentColor; flex-shrink: 0; }
svg.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.app { overflow: hidden; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--red); margin: 0; font-size: 13px; }
kbd { border: 1px solid var(--chip-border); border-radius: 4px; padding: 0 5px; font: 12px/1.6 inherit; background: var(--panel); }

.btn { border: 1px solid var(--chip-border); background: var(--panel); border-radius: 20px; padding: 7px 18px; cursor: pointer; white-space: nowrap; font-weight: 500; color: var(--green-dark); }
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-dark); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.small { padding: 4px 12px; font-size: 13px; }
.btn.link { border: 0; background: none; padding: 4px 0; justify-self: start; }
.icon-btn { border: 0; background: none; cursor: pointer; width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--icon); flex-shrink: 0; text-decoration: none; }
.icon-btn:hover, .icon-btn.on { background: rgba(11, 20, 26, .08); }
@media (prefers-color-scheme: dark) { .icon-btn:hover, .icon-btn.on { background: rgba(255, 255, 255, .08); } }

/* ---------- Login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; background: var(--rail); }
.login-card { background: var(--panel); padding: 32px; border-radius: 16px; width: min(380px, 100%); display: grid; gap: 14px; box-shadow: var(--shadow-pop); }
.login-card h1 { margin: 0 0 6px; font-size: 22px; font-weight: 500; text-align: center; }
.login-logo { width: 64px; height: 64px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; justify-self: center; }
.login-logo svg { width: 34px; height: 34px; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea { border: 1px solid var(--chip-border); border-radius: 8px; padding: 9px 12px; background: var(--panel); color: var(--text); }
input:focus, select:focus { outline: 2px solid var(--green); outline-offset: -1px; border-color: transparent; }

/* ---------- Estrutura ---------- */
.app { display: grid; grid-template-columns: 64px minmax(340px, 30%) minmax(0, 1fr); height: 100vh; height: 100dvh; background: var(--rail); }
/* Sem isso, texto longo numa prévia estica a coluna em vez de cortar com "…" */
.app > * { min-width: 0; }

.rail { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 0; background: var(--rail); border-right: 1px solid var(--divider); }
.rail-btn { position: relative; width: 40px; height: 40px; border-radius: 50%; border: 0; background: none; color: var(--icon); cursor: pointer; display: grid; place-items: center; }
.rail-btn:hover { background: rgba(11, 20, 26, .08); }
.rail-btn.active { background: rgba(11, 20, 26, .1); color: var(--text); }
@media (prefers-color-scheme: dark) { .rail-btn:hover, .rail-btn.active { background: rgba(255, 255, 255, .1); } }
.rail-btn.on { color: var(--green); }
.rail-badge:not(:empty) { position: absolute; top: -2px; right: -4px; background: var(--badge); color: #fff; font-size: 11px; font-weight: 600; min-width: 19px; height: 19px; border-radius: 10px; padding: 0 5px; display: grid; place-items: center; border: 2px solid var(--rail); }
.rail-spacer { flex: 1; }
.rail-me { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 13px; margin-top: 6px; }

.sidebar { background: var(--panel); display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--divider); }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px 20px; }
.side-head h1 { margin: 0; font-size: 22px; font-weight: 600; }
.side-actions { display: flex; gap: 6px; align-items: center; }
.new-chat { width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--green); color: #fff; display: grid; place-items: center; cursor: pointer; }
.new-chat:hover { background: var(--green-dark); }
.search { margin: 4px 14px 8px; display: flex; align-items: center; gap: 10px; background: var(--input); border-radius: 22px; padding: 0 14px; height: 40px; color: var(--muted); }
.search svg { width: 20px; height: 20px; }
.search input { border: 0; background: none; flex: 1; padding: 0; outline: none; height: 100%; }
.chips { display: flex; flex-wrap: wrap; gap: 6px 8px; padding: 2px 14px 10px; }
.chips::-webkit-scrollbar { display: none; }
.chip { border: 1px solid var(--chip-border); background: var(--panel); color: var(--muted); border-radius: 18px; padding: 5px 13px; cursor: pointer; white-space: nowrap; font-size: 14px; }
.chip:hover { background: var(--hover); }
.chip.active { background: var(--chip-on-bg); border-color: var(--chip-on-bg); color: var(--chip-on-text); font-weight: 500; }
.chip span:empty { display: none; }
.chip span { display: inline-block; min-width: 20px; margin-left: 4px; padding: 0 6px; border-radius: 10px; background: var(--green); color: #fff; font-size: 12px; font-weight: 600; line-height: 18px; text-align: center; }
.chip.active span { background: var(--chip-on-text); color: var(--chip-on-bg); }

.conv-list { list-style: none; margin: 0; padding: 0 8px; overflow-y: auto; flex: 1; }

/* Seleção de várias conversas */
.select-bar { margin: 0 12px 8px; background: var(--chip-on-bg); border-radius: 14px; padding: 6px 8px 8px; display: grid; gap: 6px; }
.select-top { display: flex; align-items: center; gap: 8px; }
.select-top strong { flex: 1; color: var(--chip-on-text); font-weight: 600; }
.select-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.act { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--chip-border); background: var(--panel); color: var(--text-2); border-radius: 16px; padding: 4px 11px 4px 8px; cursor: pointer; font-size: 13px; }
.act svg { width: 17px; height: 17px; color: var(--icon); }
.act:hover:not(:disabled) { background: var(--hover); }
.act:disabled { opacity: .45; cursor: default; }
.act[data-acao="close"] { color: var(--green-dark); border-color: var(--green); }
.act[data-acao="close"] svg { color: var(--green); }
.sel-box { width: 49px; height: 49px; flex-shrink: 0; display: grid; place-items: center; }
.sel-box svg { width: 22px; height: 22px; padding: 2px; border: 2px solid var(--muted); border-radius: 6px; color: transparent; box-sizing: content-box; }
.sel-box.on svg { background: var(--green); border-color: var(--green); color: #fff; }
.conv.picked { background: var(--selected); }
.conv { position: relative; display: flex; gap: 14px; padding: 0 10px; height: 72px; cursor: pointer; border-radius: 10px; align-items: center; }
.conv:hover { background: var(--hover); }
.conv.active { background: var(--selected); }
.conv-body { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: center; gap: 2px; border-bottom: 1px solid var(--divider); padding-right: 2px; }
.conv.active .conv-body, .conv:hover .conv-body { border-bottom-color: transparent; }
.conv-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.conv-name { flex: 1; font-size: 16.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.conv.unread .conv-time { color: var(--badge); font-weight: 500; }
.conv-preview { flex: 1; color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; gap: 3px; align-items: center; }
.conv-preview .who { color: var(--text-2); }
.conv-preview .typing { color: var(--green); font-weight: 500; }
.conv-preview svg { width: 16px; height: 11px; }
.conv.unread .conv-preview { color: var(--text); }
.conv-icons { display: flex; align-items: center; gap: 5px; color: var(--muted); flex-shrink: 0; }
.conv-icons svg.pin { width: 17px; height: 17px; }
.badge { background: var(--badge); color: #fff; border-radius: 11px; min-width: 20px; height: 20px; padding: 0 6px; display: grid; place-items: center; font-size: 12px; font-weight: 600; }
.badge.dot { min-width: 12px; width: 12px; height: 12px; padding: 0; }
.wait { font-size: 12px; font-weight: 600; color: var(--muted); }
.wait.warn { color: var(--orange); }
.wait.late { color: var(--red); }
.viewers { display: inline-flex; align-items: center; gap: 2px; font-size: 11.5px; color: var(--green-dark); }
.viewers svg { width: 14px; height: 14px; }
.state { font-size: 11px; border-radius: 8px; padding: 0 6px; background: var(--selected); color: var(--muted); }
.conv-chevron { width: 22px; height: 22px; border: 0; border-radius: 50%; background: none; color: var(--muted); display: none; place-items: center; cursor: pointer; padding: 0; margin-right: -4px; }
.conv-chevron svg { width: 22px; height: 22px; }
.conv:hover .conv-chevron, .conv-chevron.open { display: grid; }
@media (hover: none) { .conv-chevron { display: none !important; } }
.avatar { width: 49px; height: 49px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 500; font-size: 18px; flex-shrink: 0; }
.avatar.unknown { background: #dfe5e7; color: #fff; overflow: hidden; align-items: end; }
.avatar.unknown svg { width: 82%; height: 82%; margin-bottom: -6%; }
@media (prefers-color-scheme: dark) { .avatar.unknown { background: #6a7175; color: #cfd4d6; } }
.chat-title { cursor: pointer; }
.list-empty { padding: 40px 24px; text-align: center; color: var(--muted); }
.list-more { display: block; margin: 8px auto 16px; }

/* ---------- Conversa ---------- */
.chat { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--chat-bg); }
.chat::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; color: var(--doodle);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 20h22a5 5 0 0 1 5 5v12a5 5 0 0 1-5 5H28l-7 6v-6h-3a5 5 0 0 1-5-5V25a5 5 0 0 1 5-5z'/%3E%3Ccircle cx='112' cy='30' r='9'/%3E%3Cpath d='M108 28h0M116 28h0M108 33c2 2 6 2 8 0'/%3E%3Cpath d='M70 70l4 8 9 1-7 6 2 9-8-5-8 5 2-9-7-6 9-1z'/%3E%3Crect x='118' y='92' width='22' height='16' rx='3'/%3E%3Ccircle cx='129' cy='100' r='4'/%3E%3Cpath d='M24 110c6-8 14-8 20 0M30 120a4 4 0 1 0 8 0 4 4 0 1 0-8 0'/%3E%3Cpath d='M86 130l10-10 10 10M96 120v20'/%3E%3Cpath d='M140 150a6 6 0 0 1-12 0c0-5 6-10 6-10s6 5 6 10z'/%3E%3Cpath d='M60 18l6 6M66 18l-6 6'/%3E%3C/svg%3E");
  background-size: 260px; opacity: .06;
}
@media (prefers-color-scheme: dark) { .chat::before { filter: invert(1); opacity: .045; } }

.intro { position: relative; flex: 1; display: grid; place-items: center; text-align: center; background: var(--rail); border-bottom: 6px solid var(--green); }
.intro-box { max-width: 460px; padding: 24px; }
.intro-logo { width: 96px; height: 96px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; margin: 0 auto 20px; }
.intro-logo svg { width: 52px; height: 52px; }
.intro h2 { font-weight: 300; font-size: 30px; margin: 0 0 10px; }
.intro p { color: var(--muted); margin: 6px 0; }
.intro-keys { margin-top: 24px !important; }

.chat-inner { position: relative; display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-head { position: relative; z-index: 2; display: flex; align-items: center; gap: 12px; padding: 0 12px 0 16px; height: 64px; background: var(--head); border-bottom: 1px solid var(--divider); }
.chat-head .avatar { width: 42px; height: 42px; font-size: 16px; }
.chat-title { flex: 1; min-width: 0; display: grid; }
.chat-title strong { font-weight: 500; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-title span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-title .live { color: var(--green-dark); }
.head-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--chip-border); background: var(--panel); color: var(--green-dark); border-radius: 20px; padding: 6px 14px 6px 10px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.head-btn:hover { background: var(--hover); }
.head-btn svg { width: 20px; height: 20px; }
.head-btn.closed { color: var(--muted); }
.back { display: none; }

.messages-wrap { position: relative; flex: 1; min-height: 0; }
.messages { position: absolute; inset: 0; overflow-y: auto; padding: 12px 7% 8px; display: flex; flex-direction: column; }
.day { position: sticky; top: 8px; z-index: 1; align-self: center; background: var(--system); color: var(--muted); font-size: 12.5px; padding: 5px 12px; border-radius: 8px; margin: 10px 0; box-shadow: var(--shadow); text-transform: none; }
.load-older { align-self: center; margin: 6px 0; }

.msg { position: relative; max-width: min(65%, 600px); padding: 6px 7px 8px 9px; border-radius: 7.5px; box-shadow: var(--shadow); margin-top: 2px; word-wrap: break-word; overflow-wrap: anywhere; font-size: 14.2px; }
.msg.in { align-self: flex-start; background: var(--in); }
.msg.out { align-self: flex-end; background: var(--out); }
.msg.tail { margin-top: 10px; }
.msg.tail.in { border-top-left-radius: 0; }
.msg.tail.out { border-top-right-radius: 0; }
.msg.tail.in::before, .msg.tail.out::before { content: ""; position: absolute; top: 0; width: 8px; height: 13px; }
.msg.tail.in::before { left: -8px; background: var(--in); clip-path: polygon(100% 0, 0 0, 100% 100%); }
.msg.tail.out::before { right: -8px; background: var(--out); clip-path: polygon(0 0, 100% 0, 0 100%); }
.msg.flash { animation: flash 1.2s; }
@keyframes flash { 30% { filter: brightness(.85); } }
.sender { font-size: 12.8px; font-weight: 500; margin-bottom: 2px; }
@media (prefers-color-scheme: dark) { .sender, .quote b { filter: brightness(1.7) saturate(.8); } }
.tag { font-size: 12px; color: var(--muted); margin-bottom: 3px; display: flex; align-items: center; gap: 4px; }
.tag svg { width: 14px; height: 14px; }
.msg-body { white-space: pre-wrap; }
.msg-body a { color: #027eb5; }
@media (prefers-color-scheme: dark) { .msg-body a { color: #53bdeb; } }
.msg-body code { font-family: Consolas, monospace; font-size: 13px; }
/* Espaço para a hora "flutuar" no fim do texto, como no WhatsApp */
.msg-body::after { content: ""; display: inline-block; width: var(--meta-w, 64px); }
.meta { position: absolute; right: 7px; bottom: 3px; display: flex; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.msg.media-only .meta { background: rgba(0, 0, 0, .35); color: #fff; padding: 1px 6px; border-radius: 8px; bottom: 7px; right: 10px; }
.msg.media-only { padding: 3px 3px 3px; }
.tick { width: 16px; height: 11px; color: var(--tick); }
.tick.read { color: var(--tick-read); }
.tick.failed { width: 15px; height: 15px; color: var(--red); }
.msg.media-only .tick { color: #fff; }
.msg.media-only .tick.read { color: var(--tick-read); }
.msg img.media { display: block; max-width: 100%; width: 330px; max-height: 360px; object-fit: cover; border-radius: 6px; cursor: pointer; background: var(--quote-bg); }
.msg video.media { display: block; max-width: 100%; width: 330px; max-height: 360px; border-radius: 6px; }
.msg audio { display: block; width: 300px; max-width: 100%; height: 40px; margin: 2px 0; }
.msg .media + .msg-body { margin-top: 5px; }
.doc { display: flex; gap: 10px; align-items: center; background: var(--quote-bg); padding: 10px 12px; border-radius: 6px; text-decoration: none; color: inherit; min-width: 240px; }
.doc svg { width: 32px; height: 32px; color: #e15c4f; }
.doc small { color: var(--muted); }
.unavailable { font-style: italic; color: var(--muted); font-size: 13px; }
.msg-chevron { position: absolute; top: 2px; right: 3px; width: 26px; height: 22px; border: 0; border-radius: 0 6px 0 12px; background: inherit; color: var(--muted); display: none; place-items: center; cursor: pointer; }
.msg-chevron svg { width: 20px; height: 20px; }
.msg:hover .msg-chevron { display: grid; }
.msg.in .msg-chevron { background: linear-gradient(to left, var(--in) 60%, transparent); }
.msg.out .msg-chevron { background: linear-gradient(to left, var(--out) 60%, transparent); }

.quote { display: block; border-left: 4px solid var(--q, #06cf9c); background: var(--quote-bg); border-radius: 6px; padding: 5px 10px; margin-bottom: 5px; font-size: 13px; cursor: pointer; overflow: hidden; }
.quote b { display: block; color: var(--q, #06cf9c); font-weight: 500; font-size: 12.8px; }
.quote span { color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }

.scroll-down { position: absolute; right: 18px; bottom: 14px; width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--panel); color: var(--icon); box-shadow: var(--shadow-pop); cursor: pointer; display: grid; place-items: center; z-index: 3; }
.scroll-down span:not(:empty) { position: absolute; top: -6px; right: -4px; background: var(--badge); color: #fff; border-radius: 10px; min-width: 20px; height: 20px; font-size: 11px; display: grid; place-items: center; padding: 0 5px; }

/* Rodapé de digitação */
.composer-area { position: relative; z-index: 2; padding: 5px 16px 12px; display: grid; gap: 6px; }
.composer { display: flex; align-items: flex-end; gap: 2px; background: var(--panel); border-radius: 26px; padding: 5px 6px; box-shadow: var(--shadow); min-height: 52px; }
.composer .icon-btn { width: 42px; height: 42px; }
.composer textarea { flex: 1; resize: none; min-height: 42px; max-height: 140px; border: 0; background: none; padding: 10px 6px; outline: none; line-height: 1.4; font-size: 15px; }
.composer .action { color: var(--icon); }
.composer .action.send { background: var(--green); color: #fff; }
.composer .action.send:hover { background: var(--green-dark); }
.composer .action.send svg { width: 22px; height: 22px; margin-left: 3px; }
.recording { flex: 1; display: flex; align-items: center; gap: 10px; padding: 0 6px; height: 42px; color: var(--text); font-variant-numeric: tabular-nums; }
.rec-dot { width: 10px; height: 10px; background: var(--red); border-radius: 50%; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.window-closed { display: flex; gap: 12px; align-items: center; background: var(--warn-bg); color: var(--warn-text); padding: 10px 14px; border-radius: 12px; box-shadow: var(--shadow); font-size: 13.5px; }
.window-closed svg { color: var(--orange); }
.window-closed span { flex: 1; }
.reply-bar { display: flex; align-items: center; gap: 8px; background: var(--panel); border-radius: 14px; padding: 8px 8px 8px 10px; box-shadow: var(--shadow); }
.reply-bar .quote { flex: 1; margin: 0; cursor: default; }
.emoji-panel { background: var(--panel); border-radius: 14px; box-shadow: var(--shadow-pop); padding: 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); max-height: 230px; overflow-y: auto; }
.emoji-panel button { border: 0; background: none; font-size: 24px; height: 40px; border-radius: 8px; cursor: pointer; }
.emoji-panel button:hover { background: var(--hover); }

/* Prévia de anexo */
.attach-pane { position: absolute; inset: 64px 0 0; z-index: 5; background: var(--rail); display: flex; flex-direction: column; }
.attach-pane header { display: flex; align-items: center; gap: 12px; padding: 10px 16px; }
.attach-pane header span { flex: 1; text-align: center; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 40px; }
.attach-preview { flex: 1; min-height: 0; display: grid; place-items: center; padding: 16px; }
.attach-preview img, .attach-preview video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; box-shadow: var(--shadow-pop); }
.attach-preview audio { width: min(420px, 100%); }
.file-card { display: grid; justify-items: center; gap: 8px; color: var(--muted); text-align: center; }
.file-card svg { width: 90px; height: 90px; color: #e15c4f; }
.file-card strong { color: var(--text); font-weight: 500; }
.attach-thumbs { display: flex; justify-content: center; gap: 8px; padding: 8px; flex-wrap: wrap; }
.attach-thumbs button { width: 54px; height: 54px; border-radius: 8px; border: 3px solid transparent; background: var(--panel) center/cover; cursor: pointer; display: grid; place-items: center; color: var(--muted); font-size: 11px; overflow: hidden; }
.attach-thumbs button.on { border-color: var(--green); }
.attach-foot { display: flex; align-items: center; gap: 12px; padding: 10px 24px 18px; }
.attach-foot input { flex: 1; border: 0; border-radius: 10px; padding: 12px 14px; background: var(--panel); }
.send-fab { width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--green); color: #fff; display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow-pop); flex-shrink: 0; }
.send-fab:hover { background: var(--green-dark); }
.send-fab:disabled { opacity: .6; }
.send-fab svg { margin-left: 3px; }
.drop-overlay { position: absolute; inset: 64px 0 0; z-index: 6; background: rgba(240, 242, 245, .92); display: grid; place-items: center; font-size: 22px; color: var(--muted); border: 3px dashed var(--green); margin: 10px; border-radius: 12px; pointer-events: none; }
@media (prefers-color-scheme: dark) { .drop-overlay { background: rgba(17, 27, 33, .92); } }

/* Menu flutuante */
.menu { position: fixed; z-index: 50; background: var(--menu); border-radius: 12px; box-shadow: var(--shadow-pop); padding: 8px 0; min-width: 210px; }
.menu button { display: flex; align-items: center; gap: 14px; width: 100%; border: 0; background: none; padding: 9px 20px; text-align: left; cursor: pointer; font-size: 14.5px; color: var(--text-2); }
.menu button:hover { background: var(--hover); }
.menu button svg { width: 20px; height: 20px; color: var(--icon); }
.menu button.danger { color: var(--red); }
.menu hr { border: 0; border-top: 1px solid var(--divider); margin: 6px 0; }

/* Foto em tela cheia */
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(11, 20, 26, .94); display: grid; place-items: center; }
.lightbox img { max-width: 92vw; max-height: 86vh; object-fit: contain; }
.lightbox-bar { position: absolute; top: 10px; right: 14px; display: flex; gap: 6px; }
.lightbox-bar .icon-btn { color: #fff; }
.lightbox-bar .icon-btn:hover { background: rgba(255, 255, 255, .15); }

/* Diálogos */
.dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 32px)); background: var(--panel); color: var(--text); box-shadow: var(--shadow-pop); }
.dialog::backdrop { background: rgba(11, 20, 26, .55); }
.dialog-small { width: min(420px, calc(100vw - 32px)); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 14px 14px 22px; border-bottom: 1px solid var(--divider); }
.dialog-head h2 { margin: 0; font-size: 18px; font-weight: 500; }
.dialog-body { padding: 16px 22px; display: grid; gap: 10px; max-height: 70vh; overflow-y: auto; }
.dialog-body h3 { margin: 12px 0 0; font-size: 15px; font-weight: 500; }
.dialog-body p { margin: 0; }
.dialog-foot { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 12px 22px; border-top: 1px solid var(--divider); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row { display: flex; gap: 8px; align-items: center; }
.tpl-preview-wrap:has(.tpl-preview:not(:empty)) { background: var(--chat-bg); border-radius: 10px; padding: 14px; }
.tpl-preview:not(:empty) { background: var(--out); border-radius: 8px; padding: 8px 10px; white-space: pre-wrap; box-shadow: var(--shadow); max-width: 90%; margin-left: auto; }
.tpl-preview .btns { margin-top: 8px; padding-top: 6px; border-top: 1px solid rgba(0,0,0,.08); color: #027eb5; font-size: 13.5px; text-align: center; }
.checks { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
body:not(.is-admin) .admin-only { display: none !important; }

/* Usuários */
.users { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.user-row { display: flex; align-items: center; gap: 12px; padding: 8px 6px; border-bottom: 1px solid var(--divider); }
.user-row .avatar { width: 38px; height: 38px; font-size: 14px; }
.user-row.off { opacity: .5; }
.user-info { flex: 1; min-width: 0; display: grid; }
.user-info span { font-size: 12.5px; color: var(--muted); }
.tagx { font-size: 11px; border-radius: 8px; padding: 1px 7px; background: var(--chip-on-bg); color: var(--chip-on-text); margin-left: 6px; font-weight: 500; }
.tagx.off { background: var(--selected); color: var(--muted); }
.user-form .check { flex-direction: row; display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; padding-top: 18px; }
.user-form .check input { width: 18px; height: 18px; }

/* Avisos no meio da conversa (como os do WhatsApp) */
.sys { align-self: center; max-width: 85%; text-align: center; background: var(--system); color: var(--muted); font-size: 12.5px; padding: 5px 12px; border-radius: 8px; margin: 6px 0; box-shadow: var(--shadow); }
.sys b { color: var(--text-2); font-weight: 500; }

.toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; width: min(440px, calc(100vw - 32px)); }
.toast { background: #3b4a54; color: #fff; padding: 12px 18px; border-radius: 8px; box-shadow: var(--shadow-pop); font-size: 14px; }
.toast.error { background: var(--red); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: rgba(11, 20, 26, .2); border-radius: 3px; }
@media (prefers-color-scheme: dark) { ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .16); } }

/* ---------- Celular ---------- */
@media (max-width: 800px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
  .app.chat-open .sidebar { display: none; }
  .app:not(.chat-open) .chat { display: none; }
  .back { display: inline-flex; margin-left: -8px; }
  .chat-head { padding: 0 6px 0 10px; gap: 8px; }
  .head-btn span { display: none; }
  .head-btn { padding: 6px 8px; }
  .messages { padding: 10px 12px; }
  .msg { max-width: 85%; }
  .composer-area { padding: 5px 8px 8px; }
  .composer #btn-template { display: none; }
  .grid2 { grid-template-columns: 1fr; }
  .window-closed { flex-wrap: wrap; }
}

/* Reações */
.msg.has-react { margin-bottom: 16px; }
.reacts { position: absolute; bottom: -15px; display: inline-flex; align-items: center; gap: 2px; background: var(--panel); border-radius: 12px; padding: 1px 6px; font-size: 14px; line-height: 20px; box-shadow: var(--shadow); cursor: default; white-space: nowrap; }
.msg.in .reacts { left: 8px; }
.msg.out .reacts { right: 8px; }
.reacts small { font-size: 11.5px; color: var(--muted); margin-left: 2px; }
.menu .react-row { display: flex; align-items: center; gap: 2px; padding: 2px 10px 8px; border-bottom: 1px solid var(--divider); margin-bottom: 6px; }
.menu .react-row button, .menu .react-all button { width: 36px; height: 36px; padding: 0; justify-content: center; font-size: 21px; border-radius: 50%; gap: 0; }
.menu .react-row button.on, .menu .react-all button.on { background: var(--hover); }
.menu .react-all { display: grid; grid-template-columns: repeat(8, 36px); gap: 2px; padding: 4px 10px; max-height: 260px; overflow-y: auto; }

/* Histórico de acessos */
.access { list-style: none; padding: 0; margin: 10px 0 0; max-height: 280px; overflow-y: auto; border: 1px solid var(--divider); border-radius: 8px; }
.access li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 12px; border-bottom: 1px solid var(--divider); font-size: 13.5px; }
.access li:last-child { border-bottom: 0; }
.access li svg { width: 18px; height: 18px; color: var(--green); }
.access li.fail svg { color: var(--red); }
.access li em { color: var(--red); font-style: normal; }
.access small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
