/* Tema principal: oscuro, negro y morado (estilo cliente de escritorio). */
:root {
  color-scheme: dark;
  --bg: #050407;
  --panel: #110e16;
  --panel-2: #19141f;
  --hover: #201a28;
  --active: #2a2135;
  --border: #261f2e;
  --text: #ece7f3;
  --muted: #9b90aa;
  --accent: #a970ff;
  --accent-strong: #c39bff;
  --accent-btn: #7c3aed;
  --accent-btn-hover: #8b4ff0;
  --accent-soft: #2d1d45;
  --chat-bg: #0a080d;
  --chat-dots: rgba(169, 112, 255, .055);
  --bubble-in: #1d1825;
  --bubble-out: #4b2580;
  --quote-bg: rgba(255, 255, 255, .07);
  --sys-bg: #1d1727;
  --badge: #9d5cff;
  --danger: #ef5b6b;
  --link: #cfa9ff;
  --tick-read: #d4b4ff;
  --name-l: 74%;
  --toast-bg: #2a2036;
  --shadow: 0 1px 1px rgba(0, 0, 0, .45);
  --pop-shadow: 0 10px 32px rgba(0, 0, 0, .65);
  --radius: 10px;
}
/* Alternativa clara (Ajustes → Tema → Claro). */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #e9e5f0; --panel: #ffffff; --panel-2: #f5f2fa; --hover: #f0ebf7; --active: #e8e0f4; --border: #e4ddee;
  --text: #1a1424; --muted: #6f6680; --accent: #7c3aed; --accent-strong: #6d28d9; --accent-btn: #7c3aed; --accent-btn-hover: #6d28d9;
  --accent-soft: #ede3fd; --chat-bg: #efeaf5; --chat-dots: rgba(124, 58, 237, .06); --bubble-in: #ffffff; --bubble-out: #e6d8fd;
  --quote-bg: rgba(0, 0, 0, .05); --sys-bg: #f6efff; --badge: #7c3aed; --link: #6d28d9; --tick-read: #7c3aed;
  --name-l: 38%; --toast-bg: #2a2036; --shadow: 0 1px 1px rgba(20, 10, 30, .10); --pop-shadow: 0 6px 24px rgba(20, 10, 30, .18);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14.5px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Color Emoji", "Segoe UI Emoji", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
a { color: var(--link); }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; margin: 8px 0 0; }

.ic { width: 20px; height: 20px; flex: none; display: inline-block; vertical-align: middle; }
.ic.sm { width: 15px; height: 15px; }
.ic.xs { width: 13px; height: 13px; }
.ic.lg { width: 28px; height: 28px; }

.btn {
  border: 1px solid var(--border); background: var(--panel); border-radius: 8px;
  padding: 8px 14px; font-weight: 500; transition: background .15s, transform .1s;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent-btn); border-color: var(--accent-btn); color: #fff; }
.btn.primary:hover { background: var(--accent-btn-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.wide { width: 100%; padding: 11px; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn {
  border: 0; background: transparent; width: 40px; height: 40px; border-radius: 50%;
  display: inline-grid; place-items: center; color: var(--muted); flex: none; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.send { color: var(--accent); }
.icon-btn.danger { color: var(--danger); }

/* ---------------------------------------------------------------- login */
.login { height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--panel); border-radius: 16px; padding: 32px 28px;
  box-shadow: var(--pop-shadow); text-align: center;
}
.login-card h1 { margin: 12px 0 4px; font-size: 24px; }
.login-card p { margin: 0 0 20px; }
.field { display: block; text-align: left; margin-bottom: 16px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel-2); outline: none;
}
.field input:focus { border-color: var(--accent); }

/* ------------------------------------------------------------- layout */
.app { display: grid; grid-template-columns: 72px minmax(300px, 400px) 1fr; grid-template-rows: minmax(0, 1fr); height: 100%; max-width: 1700px; margin: 0 auto; box-shadow: var(--shadow); overflow: hidden; }
.app > * { min-height: 0; }
@media (min-width: 1440px) { .app { height: calc(100% - 38px); margin-top: 19px; border-radius: 4px; overflow: hidden; } }

.rail { background: var(--panel-2); border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; padding: 12px 0; gap: 6px; overflow-y: auto; }
.rail-accounts { display: flex; flex-direction: column; gap: 6px; width: 100%; align-items: center; }
.rail-acc {
  position: relative; border: 0; background: transparent; width: 64px; padding: 6px 2px; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 4px; transition: background .15s;
}
.rail-acc:hover { background: var(--hover); }
.rail-acc.active { background: var(--active); }
.rail-acc.active::before { content: ""; position: absolute; left: -4px; top: 14px; bottom: 26px; width: 4px; border-radius: 0 4px 4px 0; background: var(--accent); }
.rail-av {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600;
  background: var(--av); font-size: 15px; letter-spacing: .3px;
}
.rail-name { font-size: 11px; color: var(--muted); max-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-acc.active .rail-name { color: var(--text); font-weight: 600; }
.rail-acc .dot { position: absolute; top: 34px; left: 42px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--panel-2); }
.rail-acc .badge { position: absolute; top: 2px; right: 6px; }
.dot.st-ok { background: #25c16f; }
.dot.st-wait { background: #f0b429; }
.dot.st-bad { background: #d14343; }
.dot.st-off { background: #9aa5ab; }
.rail-btn { border: 0; background: transparent; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.rail-btn:hover { background: var(--hover); color: var(--text); }
.rail-spacer { flex: 1; }

.badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--badge); color: #fff; font-size: 11.5px; font-weight: 700; font-style: normal;
}
.badge.muted { background: #5d5469; }
.badge:empty { min-width: 12px; width: 12px; height: 12px; padding: 0; }

/* ------------------------------------------------------------ sidebar */
.sidebar { background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-width: 0; }
.side-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 16px; min-height: 60px; background: var(--panel-2); border-bottom: 1px solid var(--border); }
.side-title { flex: 1; min-width: 0; }
.side-title b { display: block; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-title small { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; }
.side-title small .dot { width: 8px; height: 8px; border-radius: 50%; }
.acc-banner { margin: 8px 10px 0; padding: 10px 12px; border-radius: 8px; background: var(--sys-bg); font-size: 13px; display: flex; gap: 8px; align-items: center; }
.acc-banner .btn { padding: 4px 10px; font-size: 12.5px; margin-left: auto; }
.search { position: relative; margin: 8px 10px 4px; }
.search input {
  width: 100%; border: 0; border-radius: 8px; background: var(--panel-2); padding: 9px 12px 9px 40px; outline: none;
}
.search input:focus { box-shadow: 0 0 0 2px var(--accent-soft); }
.search-ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); display: flex; }
.filters { display: flex; gap: 6px; padding: 6px 10px 8px; overflow-x: auto; scrollbar-width: none; }
.filters button {
  border: 0; border-radius: 16px; padding: 5px 12px; background: var(--panel-2); color: var(--muted); font-size: 13px; white-space: nowrap;
}
.filters button.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.chat-list { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.chat-item { display: flex; align-items: center; gap: 12px; padding: 0 12px 0 14px; cursor: pointer; height: 72px; }
.chat-item:hover { background: var(--hover); }
.chat-item.active { background: var(--active); }
.ci-body { flex: 1; min-width: 0; border-bottom: 1px solid var(--border); height: 100%; display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.chat-item:last-child .ci-body { border-bottom: 0; }
.ci-top, .ci-bottom { display: flex; align-items: center; gap: 6px; }
.ci-name { flex: 1; min-width: 0; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci-time { font-size: 12px; color: var(--muted); flex: none; }
.chat-item.is-unread .ci-time { color: var(--badge); font-weight: 600; }
.ci-prev { flex: 1; min-width: 0; color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item.is-unread .ci-prev { color: var(--text); }
.ci-badges { display: flex; align-items: center; gap: 4px; color: var(--muted); flex: none; }
.list-note { padding: 18px; text-align: center; color: var(--muted); font-size: 13px; }
.new-number { color: var(--accent-strong); }

/* avatares */
.av {
  position: relative; width: 48px; height: 48px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--av, #9aa5ab); color: #fff; font-weight: 600; font-size: 17px; overflow: hidden;
}
.av.sm { width: 34px; height: 34px; font-size: 13px; }
.av.md { width: 40px; height: 40px; font-size: 15px; }
.av .ic { width: 55%; height: 55%; opacity: .9; }
.av-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: var(--av); }

/* --------------------------------------------------------------- pane */
.pane { position: relative; min-width: 0; display: flex; flex-direction: column; background: var(--chat-bg) radial-gradient(var(--chat-dots) 1.2px, transparent 1.3px) 0 0 / 22px 22px; }
.empty { flex: 1; display: grid; place-items: center; text-align: center; background: var(--panel-2); border-bottom: 6px solid var(--accent); }
.empty-inner { max-width: 440px; padding: 24px; }
.empty-ic { color: var(--accent); }
.empty-ic .ic { width: 72px; height: 72px; stroke-width: 1.3; }
.empty h2 { font-weight: 300; font-size: 30px; margin: 14px 0 8px; }

.link-pane { flex: 1; overflow-y: auto; background: var(--panel-2); display: grid; place-items: center; padding: 24px; }
.link-card { background: var(--panel); border-radius: 14px; box-shadow: var(--pop-shadow); padding: 36px; max-width: 900px; width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 36px; align-items: start; }
.link-card h2 { font-weight: 400; font-size: 24px; margin: 0 0 18px; }
.link-card ol { padding-left: 22px; margin: 0 0 20px; line-height: 2; font-size: 15.5px; }
.qr-box { width: 280px; min-height: 280px; display: grid; place-items: center; text-align: center; }
.qr-box img { width: 280px; height: 280px; border-radius: 8px; background: #fff; padding: 6px; image-rendering: pixelated; }
.pair summary { cursor: pointer; color: var(--accent-strong); font-weight: 500; }
.pair form { display: flex; gap: 8px; margin-top: 12px; }
.pair input { flex: 1; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); outline: none; }
.pair-code { margin-top: 14px; font-size: 13.5px; }
.pair-code b { display: block; font: 600 30px/1.3 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: 4px; color: var(--text); margin: 6px 0; }
.link-note { font-size: 12.5px; color: var(--muted); margin-top: 18px; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid var(--border); border-top-color: var(--accent); animation: spin 0.9s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------- chat */
.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 8px 12px; min-height: 60px; background: var(--panel-2); border-bottom: 1px solid var(--border); }
.chat-head .back { display: none; }
.ch-title { flex: 1; min-width: 0; }
.ch-title b { display: block; font-size: 16px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-title small { color: var(--muted); font-size: 12.5px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.messages { flex: 1; overflow-y: auto; padding: 12px 5% 8px; overscroll-behavior: contain; outline: none; }
.msgs-inner { display: flex; flex-direction: column; gap: 2px; max-width: 1100px; margin: 0 auto; }
.loading { text-align: center; color: var(--muted); padding: 30px; }
.older { text-align: center; padding: 8px 0 14px; }
.older button { border: 0; background: var(--panel); border-radius: 16px; padding: 7px 14px; box-shadow: var(--shadow); color: var(--accent-strong); font-size: 13px; }
.day-sep { text-align: center; margin: 12px 0 8px; position: sticky; top: 0; z-index: 2; pointer-events: none; }
.day-sep span, .sys span { display: inline-block; background: var(--panel); color: var(--muted); padding: 5px 12px; border-radius: 8px; font-size: 12.5px; box-shadow: var(--shadow); }
.sys { text-align: center; margin: 6px 0; }
.sys span { background: var(--sys-bg); }

.msg { display: flex; flex-direction: column; align-items: flex-start; max-width: 100%; }
.msg.out { align-items: flex-end; }
.msg.first { margin-top: 8px; }
.bubble {
  position: relative; max-width: min(66%, 560px); min-width: 90px; padding: 6px 8px 7px 9px; border-radius: var(--radius);
  background: var(--bubble-in); box-shadow: var(--shadow); word-wrap: break-word; overflow-wrap: anywhere;
}
.msg.out .bubble { background: var(--bubble-out); }
.msg.first.in .bubble { border-top-left-radius: 2px; }
.msg.first.out .bubble { border-top-right-radius: 2px; }
.msg.flash .bubble { animation: flash 1.4s ease; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: var(--shadow); } }
.sender { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.sender-phone { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 4px; }
.fwd { font-size: 12.5px; color: var(--muted); font-style: italic; display: flex; align-items: center; gap: 4px; margin-bottom: 2px; }
.text { white-space: pre-wrap; font-size: 14.5px; line-height: 1.42; }
.text.big-emoji { font-size: 38px; line-height: 1.2; }
.text.deleted, .muted-text { color: var(--muted); font-style: italic; display: flex; gap: 6px; align-items: center; }
.text code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; background: var(--quote-bg); padding: 1px 4px; border-radius: 4px; }
.text code.block { display: block; padding: 6px 8px; white-space: pre-wrap; }
.mention { color: var(--link); }
.caption { margin-top: 5px; padding: 0 2px; }
.meta { float: right; display: inline-flex; align-items: center; gap: 3px; margin: 6px 0 -5px 12px; font-size: 11px; color: var(--muted); position: relative; top: 2px; white-space: nowrap; }
.meta .edited { font-style: italic; margin-right: 2px; }
.tick { color: var(--muted); }
.tick.read { color: var(--tick-read); }
.tick.err { color: var(--danger); }
.tick .ic { width: 16px; height: 16px; }
.bubble::after { content: ""; display: block; clear: both; }

.msg-menu-btn {
  position: absolute; top: 3px; right: 3px; width: 26px; height: 22px; border: 0; border-radius: 6px; display: grid; place-items: center;
  color: var(--muted); background: linear-gradient(to left, var(--bubble-in) 60%, transparent); opacity: 0; transition: opacity .12s;
}
.msg.out .msg-menu-btn { background: linear-gradient(to left, var(--bubble-out) 60%, transparent); }
.bubble:hover .msg-menu-btn, .msg-menu-btn:focus-visible { opacity: 1; }
.media-only .msg-menu-btn, .sticker-msg .msg-menu-btn { background: rgba(0, 0, 0, .35); color: #fff; z-index: 3; }

.quoted {
  display: flex; flex-direction: column; background: var(--quote-bg); border-left: 4px solid var(--q, var(--accent)); border-radius: 6px;
  padding: 5px 8px; margin-bottom: 5px; cursor: pointer; min-width: 0;
}
.q-name { font-size: 12.5px; font-weight: 600; color: var(--q, var(--accent)); }
.q-body { font-size: 13px; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; white-space: pre-wrap; }

.media { position: relative; border-radius: 7px; overflow: hidden; background-size: cover; background-position: center; background-color: rgba(0,0,0,.08); cursor: pointer; margin: -2px -4px 0 -5px; }
.img-wrap { width: 330px; max-width: 100%; aspect-ratio: 4 / 3; max-height: 420px; }
.img-wrap img { display: block; width: 100%; height: 100%; object-fit: cover; }
.vid-wrap { width: 330px; max-width: 100%; aspect-ratio: 16 / 9; max-height: 420px; background-color: #000; cursor: default; }
.vid-wrap video { display: block; width: 100%; height: 100%; object-fit: contain; background: transparent; }
.media-fail { display: none; position: absolute; inset: auto 8px 8px 8px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; padding: 5px 8px; border-radius: 6px; text-align: center; }
.media.failed .media-fail { display: block; }
.media.failed img { visibility: hidden; }
.media-only .meta { position: absolute; right: 8px; bottom: 8px; margin: 0; top: auto; float: none; color: #fff; background: rgba(0,0,0,.35); padding: 2px 6px; border-radius: 8px; z-index: 2; }
.media-only .meta .tick, .media-only .meta .tick.read { color: #fff; }
.media-only .bubble { padding: 4px; }
.media-only .media { margin: 0; }
.view-once { display: flex; align-items: center; gap: 8px; color: var(--muted); font-style: italic; }
.sticker-msg .bubble { background: transparent !important; box-shadow: none; padding: 0; min-width: 0; }
.sticker { width: 150px; height: 150px; object-fit: contain; display: block; }
.sticker-msg .meta { float: none; display: flex; justify-content: flex-end; margin: 2px 0 0; top: 0; }

.audio { display: flex; align-items: center; gap: 8px; min-width: 260px; padding: 2px 0; }
.audio audio { height: 40px; flex: 1; min-width: 200px; max-width: 320px; }
.audio .ptt-ic { position: relative; }
.audio .ptt-ic .mic { position: absolute; right: -4px; bottom: -2px; color: var(--accent); background: var(--bubble-in); border-radius: 50%; padding: 1px; width: 17px; height: 17px; }
.msg.out .audio .ptt-ic .mic { background: var(--bubble-out); }
.audio .dur { font-size: 12px; color: var(--muted); }

.doc { display: flex; align-items: center; gap: 10px; background: var(--quote-bg); border-radius: 8px; padding: 10px; text-decoration: none; color: inherit; min-width: 240px; }
.doc-ic { position: relative; color: var(--muted); display: grid; place-items: center; width: 38px; }
.doc-ic .ic { width: 34px; height: 34px; stroke-width: 1.4; }
.doc-ic b { position: absolute; bottom: 4px; font-size: 8.5px; font-weight: 700; color: var(--accent-strong); letter-spacing: .3px; }
.doc-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.doc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.doc-sub { font-size: 12px; color: var(--muted); }
.doc-dl { color: var(--muted); border: 1px solid var(--border); border-radius: 50%; width: 34px; height: 34px; display: grid; place-items: center; }
.doc-thumb { height: 140px; border-radius: 8px 8px 0 0; background-size: cover; background-position: top center; margin-bottom: -2px; }
.loc { display: block; text-decoration: none; color: inherit; }
.loc-map { width: 280px; max-width: 100%; height: 150px; border-radius: 7px; background-size: cover; background-position: center; background-color: var(--quote-bg); display: grid; place-items: center; color: var(--danger); }
.loc-text { padding: 6px 2px 0; font-size: 13.5px; }
.contact-card { display: flex; flex-direction: column; gap: 6px; min-width: 220px; }
.contact-row { display: flex; align-items: center; gap: 10px; }
.contact-row .btn { padding: 4px 10px; font-size: 12.5px; margin-left: auto; }
.poll ul { margin: 6px 0 4px; padding-left: 18px; }
.link-prev { background: var(--quote-bg); border-radius: 6px; padding: 6px 8px; margin-bottom: 5px; display: flex; gap: 8px; }
.link-prev .lp-img { width: 56px; height: 56px; flex: none; border-radius: 4px; background-size: cover; background-position: center; }
.link-prev b { display: block; font-size: 13px; }
.link-prev span { font-size: 12.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.reactions { display: flex; gap: 4px; margin: -6px 8px 2px; z-index: 1; position: relative; }
.react { background: var(--panel); border-radius: 12px; padding: 1px 7px; font-size: 14px; box-shadow: var(--shadow); border: 1px solid var(--border); display: inline-flex; align-items: center; gap: 3px; cursor: default; }
.react small { font-size: 11px; color: var(--muted); }
.react.mine { border-color: var(--accent); }

.new-below { position: absolute; right: 22px; bottom: 76px; border: 0; border-radius: 22px; background: var(--panel); box-shadow: var(--pop-shadow); padding: 8px 12px; display: flex; align-items: center; gap: 6px; color: var(--muted); z-index: 5; }
.new-below .badge { margin-left: 2px; }

.reply-bar { display: flex; align-items: stretch; gap: 8px; padding: 8px 12px 0 16px; background: var(--panel-2); }
.reply-bar .quoted { flex: 1; margin: 0; cursor: default; }
.upload-bar { position: relative; height: 26px; background: var(--panel-2); font-size: 12.5px; color: var(--muted); display: flex; align-items: center; padding: 0 16px; overflow: hidden; }
.upload-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--accent-soft); transition: width .2s; }
.upload-text { position: relative; }

.composer { display: flex; align-items: flex-end; gap: 4px; padding: 8px 10px; background: var(--panel-2); min-height: 62px; }
.composer textarea {
  flex: 1; resize: none; border: 0; outline: none; border-radius: 10px; background: var(--panel); padding: 10px 14px;
  max-height: 160px; line-height: 1.4; margin: 1px 4px; overflow-y: hidden;
}
.recorder { align-items: center; gap: 10px; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: pulse 1s ease-in-out infinite; margin-left: 8px; }
@keyframes pulse { 50% { opacity: .3; } }
.rec-time { font-variant-numeric: tabular-nums; font-size: 16px; min-width: 48px; }
.rec-label { flex: 1; }
.drop { position: absolute; inset: 60px 0 0; background: rgba(157, 92, 255, .16); border: 3px dashed var(--accent); display: grid; place-items: center; font-size: 20px; font-weight: 600; color: var(--accent-strong); z-index: 20; pointer-events: none; }

/* ------------------------------------------------------------- popups */
.menu { position: fixed; z-index: 100; background: var(--panel); border-radius: 10px; box-shadow: var(--pop-shadow); padding: 6px 0; min-width: 200px; animation: pop .12s ease-out; }
@keyframes pop { from { opacity: 0; transform: scale(.96); } }
.menu button { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: transparent; padding: 9px 18px; text-align: left; font-size: 14px; }
.menu button:hover { background: var(--hover); }
.menu button.danger { color: var(--danger); }
.menu .emoji-row { display: flex; gap: 2px; padding: 4px 10px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu .emoji-row button { width: 38px; height: 38px; padding: 0; justify-content: center; font-size: 22px; border-radius: 50%; }
.menu .emoji-row button.mine { background: var(--accent-soft); }
.emoji-pop { position: fixed; z-index: 100; background: var(--panel); border-radius: 12px; box-shadow: var(--pop-shadow); padding: 8px; display: grid; grid-template-columns: repeat(8, 38px); gap: 2px; animation: pop .12s ease-out; }
.emoji-pop button { border: 0; background: transparent; font-size: 22px; height: 38px; border-radius: 8px; }
.emoji-pop button:hover { background: var(--hover); }

.overlay { position: fixed; inset: 0; z-index: 90; background: rgba(11, 20, 26, .55); display: grid; place-items: center; padding: 16px; animation: fade .15s ease-out; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--panel); border-radius: 14px; box-shadow: var(--pop-shadow); width: 100%; max-width: 440px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; animation: pop .15s ease-out; }
.modal.wide { max-width: 560px; }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 16px 16px 8px 22px; }
.modal-head h3 { flex: 1; margin: 0; font-size: 18px; font-weight: 600; }
.modal-body { padding: 8px 22px 12px; overflow-y: auto; }
.modal-body p { margin: 0 0 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 22px 18px; }
.check { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.setting { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.setting:last-child { border-bottom: 0; }
.setting > div { flex: 1; }
.setting small { display: block; color: var(--muted); }

.pick-list { max-height: 50vh; overflow-y: auto; margin: 8px -22px 0; }
.pick { display: flex; align-items: center; gap: 12px; padding: 8px 22px; cursor: pointer; }
.pick:hover { background: var(--hover); }
.pick input { width: 18px; height: 18px; accent-color: var(--accent); }
.pick span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.attach-preview { display: grid; place-items: center; background: var(--panel-2); border-radius: 10px; min-height: 160px; max-height: 50vh; overflow: hidden; margin-bottom: 12px; }
.attach-preview img, .attach-preview video { max-width: 100%; max-height: 50vh; display: block; }
.attach-files { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.attach-file { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--panel-2); border-radius: 8px; font-size: 13.5px; }
.attach-file span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-file small { color: var(--muted); }
.modal textarea, .modal input[type="text"] { width: 100%; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); padding: 9px 12px; outline: none; resize: vertical; }

.lightbox { position: fixed; inset: 0; z-index: 95; background: rgba(8, 12, 15, .94); display: flex; flex-direction: column; animation: fade .15s ease-out; }
.lb-head { display: flex; align-items: center; gap: 8px; padding: 10px 16px; color: #e3e9ec; }
.lb-head .icon-btn { color: #e3e9ec; }
.lb-head .icon-btn:hover { background: rgba(255,255,255,.1); }
.lb-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-body { flex: 1; display: grid; place-items: center; min-height: 0; padding: 0 16px; }
.lb-body img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lb-cap { color: #e3e9ec; text-align: center; padding: 12px 16px 20px; white-space: pre-wrap; max-height: 25vh; overflow-y: auto; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--toast-bg); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13.5px; box-shadow: var(--pop-shadow); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 200; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }
.sound-hint { position: fixed; left: 50%; top: 12px; transform: translateX(-50%); z-index: 150; background: var(--panel); box-shadow: var(--pop-shadow); border-radius: 10px; padding: 9px 14px; font-size: 13px; display: flex; gap: 10px; align-items: center; }
.conn-lost { position: fixed; left: 50%; top: 0; transform: translateX(-50%); z-index: 150; background: var(--danger); color: #fff; border-radius: 0 0 10px 10px; padding: 6px 14px; font-size: 12.5px; }

/* -------------------------------------------------------------- móvil */
@media (max-width: 860px) {
  .app { grid-template-columns: 64px 1fr; }
  .pane { display: none; }
  .app.show-chat { grid-template-columns: 1fr; }
  .app.show-chat .rail, .app.show-chat .sidebar { display: none; }
  .app.show-chat .pane { display: flex; }
  .chat-head .back { display: inline-grid; }
  .bubble { max-width: 85%; }
  .messages { padding: 10px 10px 6px; }
  .link-card { grid-template-columns: 1fr; padding: 22px; }
  .qr-box { margin: 0 auto; }
  .rail-acc { width: 58px; }
}
@media (max-width: 420px) {
  .img-wrap, .vid-wrap { width: 250px; }
  .audio { min-width: 0; }
  .audio audio { min-width: 150px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
