/* wspweb - replica de WhatsApp Web. Diseno propio (tema claro / oscuro). */

:root {
  --fondo-app: #eae6df;
  --fondo-panel: #ffffff;
  --fondo-cab: #f0f2f5;
  --fondo-riel: #f0f2f5;
  --fondo-hover: #f5f6f6;
  --fondo-activo: #e9edef;
  --fondo-input: #f0f2f5;
  --fondo-conv: #efeae2;
  --patron: rgba(0, 0, 0, 0.035);
  --burbuja-in: #ffffff;
  --burbuja-out: #d9fdd3;
  --burbuja-sombra: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  --texto: #111b21;
  --texto-2: #54656f;
  --texto-3: #667781;
  --borde: #e9edef;
  --borde-2: #d1d7db;
  --acento: #00a884;
  --acento-2: #008069;
  --acento-texto: #ffffff;
  --acento-suave: #d9fdd3;
  --azul-tick: #53bdeb;
  --peligro: #ea0038;
  --aviso: #ffd279;
  --sistema-fondo: #ffffff;
  --sistema-texto: #54656f;
  --cita-fondo: rgba(11, 20, 26, 0.05);
  --menu-fondo: #ffffff;
  --sombra: 0 2px 5px rgba(11, 20, 26, 0.26), 0 2px 10px rgba(11, 20, 26, 0.16);
  --badge: #25d366;
  --badge-texto: #ffffff;
  --scroll: rgba(11, 20, 26, 0.2);
  --code: rgba(11, 20, 26, 0.06);
  --enlace: #027eb5;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --fondo-app: #0c1317;
  --fondo-panel: #111b21;
  --fondo-cab: #202c33;
  --fondo-riel: #202c33;
  --fondo-hover: #202c33;
  --fondo-activo: #2a3942;
  --fondo-input: #202c33;
  --fondo-conv: #0b141a;
  --patron: rgba(255, 255, 255, 0.025);
  --burbuja-in: #202c33;
  --burbuja-out: #005c4b;
  --burbuja-sombra: 0 1px 0.5px rgba(0, 0, 0, 0.13);
  --texto: #e9edef;
  --texto-2: #aebac1;
  --texto-3: #8696a0;
  --borde: #222d34;
  --borde-2: #313d45;
  --acento: #00a884;
  --acento-2: #06cf9c;
  --acento-suave: #005c4b;
  --sistema-fondo: #182229;
  --sistema-texto: #8696a0;
  --cita-fondo: rgba(0, 0, 0, 0.18);
  --menu-fondo: #233138;
  --sombra: 0 2px 5px rgba(0, 0, 0, 0.5), 0 2px 10px rgba(0, 0, 0, 0.3);
  --scroll: rgba(255, 255, 255, 0.16);
  --code: rgba(255, 255, 255, 0.08);
  --enlace: #53bdeb;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fondo-app: #0c1317;
    --fondo-panel: #111b21;
    --fondo-cab: #202c33;
    --fondo-riel: #202c33;
    --fondo-hover: #202c33;
    --fondo-activo: #2a3942;
    --fondo-input: #202c33;
    --fondo-conv: #0b141a;
    --patron: rgba(255, 255, 255, 0.025);
    --burbuja-in: #202c33;
    --burbuja-out: #005c4b;
    --burbuja-sombra: 0 1px 0.5px rgba(0, 0, 0, 0.13);
    --texto: #e9edef;
    --texto-2: #aebac1;
    --texto-3: #8696a0;
    --borde: #222d34;
    --borde-2: #313d45;
    --acento-2: #06cf9c;
    --acento-suave: #005c4b;
    --sistema-fondo: #182229;
    --sistema-texto: #8696a0;
    --cita-fondo: rgba(0, 0, 0, 0.18);
    --menu-fondo: #233138;
    --sombra: 0 2px 5px rgba(0, 0, 0, 0.5), 0 2px 10px rgba(0, 0, 0, 0.3);
    --scroll: rgba(255, 255, 255, 0.16);
    --code: rgba(255, 255, 255, 0.08);
    --enlace: #53bdeb;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Segoe UI", "Helvetica Neue", Helvetica, "Noto Sans", Arial, sans-serif;
  font-size: 14.2px;
  color: var(--texto);
  background: var(--fondo-app);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--enlace); }
[hidden] { display: none !important; }
svg.ic { width: 24px; height: 24px; fill: currentColor; flex: none; display: block; }
svg.ic-s { width: 18px; height: 18px; }
svg.ic-xs { width: 15px; height: 15px; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------------------------------------------ login */
.pantalla-login { display: flex; align-items: center; justify-content: center; background: var(--fondo-app); overflow: auto; }
.login-franja { position: fixed; inset: 0 0 auto 0; height: 220px; background: var(--acento-2); }
.login-caja {
  position: relative; width: min(420px, calc(100% - 32px)); background: var(--fondo-panel);
  border-radius: 12px; padding: 36px 32px; box-shadow: var(--sombra);
}
.login-marca { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 18px; color: var(--acento-2); margin-bottom: 18px; }
.login-caja h1 { font-size: 22px; font-weight: 400; margin: 0 0 6px; }
.login-sub { color: var(--texto-3); margin: 0 0 20px; }
.login-caja form { display: flex; flex-direction: column; gap: 14px; }
.login-caja label { display: flex; flex-direction: column; gap: 6px; color: var(--texto-2); font-size: 13px; }
.login-caja input {
  border: 1px solid var(--borde-2); border-radius: 8px; padding: 10px 12px; background: var(--fondo-panel); outline: none;
}
.login-caja input:focus { border-color: var(--acento); }
.login-error { background: #fde8ec; color: #b00030; border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; }

.boton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 22px; border-radius: 24px; font-weight: 500; border: 1px solid var(--borde-2);
  background: var(--fondo-panel); color: var(--acento-2); min-height: 38px;
}
.boton:hover { background: var(--fondo-hover); }
.boton-primario { background: var(--acento); border-color: var(--acento); color: #fff; }
.boton-primario:hover { background: var(--acento-2); }
.boton-peligro { color: var(--peligro); }
.boton:disabled { opacity: .5; cursor: default; }

/* ------------------------------------------------------------------ layout */
.app {
  display: grid; grid-template-columns: 64px minmax(300px, 30%) 1fr; grid-template-rows: minmax(0, 1fr); height: 100vh;
  max-width: 1700px; margin: 0 auto; background: var(--fondo-panel); position: relative;
}
.app > * { min-height: 0; }
.app.con-der { grid-template-columns: 64px minmax(300px, 30%) 1fr minmax(320px, 30%); }
.riel {
  background: var(--fondo-riel); border-right: 1px solid var(--borde); display: flex; flex-direction: column;
  justify-content: space-between; align-items: center; padding: 10px 0;
}
.riel-arriba, .riel-abajo { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.riel-btn {
  width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: var(--texto-2); position: relative;
}
.riel-btn:hover { background: var(--fondo-activo); }
.riel-btn.activo { background: var(--fondo-activo); color: var(--texto); }
.riel-badge {
  position: absolute; top: -2px; right: -4px; background: var(--badge); color: var(--badge-texto);
  font-size: 11px; font-weight: 600; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
}
.riel-punto { position: absolute; top: 4px; right: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--badge); }

.izq { position: relative; border-right: 1px solid var(--borde); display: flex; flex-direction: column; min-width: 0; background: var(--fondo-panel); }
.vista-chats { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.izq-cab { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px 20px; }
.izq-cab h1 { font-size: 22px; font-weight: 600; margin: 0; }
.izq-acciones { display: flex; gap: 6px; }
.icono-btn {
  width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--texto-2); flex: none;
}
.icono-btn:hover { background: var(--fondo-activo); }
.icono-btn.activo { background: var(--fondo-activo); }
.buscador {
  margin: 4px 12px 8px; background: var(--fondo-input); border-radius: 8px; display: flex; align-items: center;
  gap: 12px; padding: 0 12px; color: var(--texto-3); height: 36px;
}
.buscador svg { width: 20px; height: 20px; }
.buscador input { flex: 1; border: 0; background: transparent; outline: none; height: 100%; color: var(--texto); }
.filtros { display: flex; gap: 8px; padding: 4px 16px 8px; flex-wrap: wrap; }
.chip {
  padding: 6px 12px; border-radius: 16px; background: var(--fondo-input); color: var(--texto-2); font-size: 14px;
}
.chip:hover { background: var(--fondo-activo); }
.chip.activo { background: var(--acento-suave); color: var(--acento-2); }
:root[data-theme="dark"] .chip.activo { color: #d9fdd3; }
.aviso-conexion {
  margin: 0 12px 8px; padding: 10px 14px; border-radius: 8px; background: var(--aviso); color: #3b2f00; font-size: 13px;
  display: flex; gap: 10px; align-items: center;
}
.aviso-conexion button { text-decoration: underline; color: inherit; }

/* lista de chats */
.lista-chats { flex: 1; overflow-y: auto; min-height: 0; }
.fila-archivados {
  display: flex; align-items: center; gap: 22px; padding: 12px 28px; color: var(--texto); cursor: pointer; font-weight: 500;
}
.fila-archivados:hover { background: var(--fondo-hover); }
.fila-archivados .cuenta { margin-left: auto; color: var(--acento); font-size: 12px; }
.item-chat { display: flex; align-items: center; gap: 12px; padding: 0 0 0 12px; cursor: pointer; height: 72px; position: relative; }
.item-chat:hover { background: var(--fondo-hover); }
.item-chat.activo { background: var(--fondo-activo); }
.item-chat .cuerpo { flex: 1; min-width: 0; height: 100%; border-bottom: 1px solid var(--borde); display: flex; flex-direction: column; justify-content: center; padding-right: 14px; gap: 2px; }
.item-chat:last-child .cuerpo { border-bottom: 0; }
.item-chat .linea1, .item-chat .linea2 { display: flex; align-items: center; gap: 6px; min-width: 0; }
.item-chat .nombre { flex: 1; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-chat .hora { font-size: 12px; color: var(--texto-3); flex: none; }
.item-chat.no-leido .hora { color: var(--badge); }
.item-chat .previa { flex: 1; color: var(--texto-3); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 3px; min-width: 0; }
.item-chat .previa > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.item-chat .previa svg { flex: none; }
.item-chat .previa.escribiendo { color: var(--badge); }
.item-chat .indicadores { display: flex; align-items: center; gap: 4px; color: var(--texto-3); flex: none; }
.badge {
  background: var(--badge); color: var(--badge-texto); border-radius: 10px; min-width: 20px; height: 20px; padding: 0 6px;
  font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center;
}
.badge.silenciado { background: var(--texto-3); }
.badge.punto { min-width: 12px; width: 12px; height: 12px; padding: 0; }
.item-chat .flecha {
  position: absolute; right: 10px; bottom: 10px; color: var(--texto-3); opacity: 0; transition: opacity .1s;
  background: linear-gradient(90deg, transparent, var(--fondo-hover) 30%); padding-left: 10px;
}
.item-chat:hover .flecha { opacity: 1; }
.lista-titulo { padding: 18px 20px 10px; color: var(--acento-2); font-size: 15px; }
.lista-vacia { padding: 40px 30px; color: var(--texto-3); text-align: center; line-height: 1.5; }
.resultado-msg { padding: 10px 16px 10px 20px; cursor: pointer; border-bottom: 1px solid var(--borde); }
.resultado-msg:hover { background: var(--fondo-hover); }
.resultado-msg .rm-cab { display: flex; justify-content: space-between; color: var(--texto); font-size: 15px; }
.resultado-msg .rm-cab span:last-child { color: var(--texto-3); font-size: 12px; }
.resultado-msg .rm-texto { color: var(--texto-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
mark { background: transparent; color: var(--acento); font-weight: 600; }

/* avatar */
.avatar {
  width: 49px; height: 49px; border-radius: 50%; flex: none; overflow: hidden; position: relative;
  background: #dfe5e7; color: #fff; display: inline-flex; align-items: center; justify-content: center;
}
:root[data-theme="dark"] .avatar { background: #6a7175; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar { background: #6a7175; } }
.avatar svg { width: 62%; height: 62%; fill: #fff; opacity: .95; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar-28 { width: 28px; height: 28px; }
.avatar-40 { width: 40px; height: 40px; }
.avatar-200 { width: 200px; height: 200px; }
.avatar-200 svg { width: 55%; }
.avatar-clic { cursor: pointer; }

/* cajones (paneles que tapan la lista) */
.cajon {
  position: absolute; inset: 0; background: var(--fondo-panel); z-index: 5; display: flex; flex-direction: column;
  transform: translateX(-100%); transition: transform .18s ease-out;
}
.cajon.abierto { transform: none; }
.cajon-cab {
  display: flex; align-items: center; gap: 18px; padding: 0 16px; height: 64px; flex: none; color: var(--texto);
  font-size: 19px; font-weight: 500;
}
.cajon-cuerpo { flex: 1; overflow-y: auto; min-height: 0; }
.cajon-seccion { padding: 14px 24px; }
.cajon-seccion h3 { color: var(--acento-2); font-weight: 400; font-size: 14px; margin: 0 0 14px; }
.separador { height: 8px; background: var(--fondo-app); opacity: .5; }
.opcion {
  display: flex; align-items: center; gap: 20px; padding: 0 24px; height: 60px; cursor: pointer; color: var(--texto);
  width: 100%; text-align: left;
}
.opcion:hover { background: var(--fondo-hover); }
.opcion .ic-opcion {
  width: 49px; height: 49px; border-radius: 50%; background: var(--acento); color: #fff; display: flex; align-items: center;
  justify-content: center; flex: none;
}
.opcion.peligro { color: var(--peligro); }
.opcion .opcion-sub { color: var(--texto-3); font-size: 13px; }
.campo-editable { display: flex; align-items: center; gap: 10px; border-bottom: 2px solid transparent; padding: 4px 0; }
.campo-editable input, .campo-editable textarea {
  flex: 1; border: 0; background: transparent; outline: none; padding: 4px 0; resize: none; font-size: 16px; color: var(--texto);
}
.campo-editable.editando { border-bottom-color: var(--acento); }
.campo-ayuda { color: var(--texto-3); font-size: 13px; margin-top: 10px; line-height: 1.4; }
.perfil-foto { display: flex; justify-content: center; padding: 28px 0; }
.perfil-foto .avatar { cursor: pointer; }
.foto-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,.45); color: #fff; display: none; align-items: center; justify-content: center;
  flex-direction: column; font-size: 12px; text-transform: uppercase; gap: 6px; text-align: center; padding: 30px;
}
.perfil-foto .avatar:hover .foto-overlay { display: flex; }
.chips-sel { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 20px; border-bottom: 1px solid var(--borde); }
.chip-sel { display: inline-flex; align-items: center; gap: 6px; background: var(--fondo-input); border-radius: 16px; padding: 2px 8px 2px 2px; font-size: 13px; }
.chip-sel .avatar { width: 26px; height: 26px; }
.chip-sel button { color: var(--texto-3); }
.boton-flotante {
  position: absolute; right: 50%; transform: translateX(50%); bottom: 26px; width: 54px; height: 54px; border-radius: 50%;
  background: var(--acento); color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: var(--sombra);
}
.boton-flotante:hover { background: var(--acento-2); }

/* ------------------------------------------------------------------ centro */
.centro { position: relative; min-width: 0; display: flex; flex-direction: column; background: var(--fondo-conv); }
.bienvenida {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  background: var(--fondo-cab); color: var(--texto-2); border-bottom: 6px solid var(--acento); padding: 30px;
}
.bienvenida h2 { font-weight: 300; font-size: 32px; color: var(--texto); margin: 26px 0 10px; }
.bienvenida p { line-height: 1.6; margin: 0; }
.bienvenida-pie { position: absolute; bottom: 40px; color: var(--texto-3); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.conv { display: flex; flex-direction: column; height: 100%; min-height: 0; position: relative; }
.conv-cab {
  display: flex; align-items: center; gap: 14px; padding: 0 16px; height: 60px; background: var(--fondo-cab); flex: none;
  border-left: 1px solid var(--borde); z-index: 2;
}
.conv-cab .info { flex: 1; min-width: 0; cursor: pointer; }
.conv-cab .titulo { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-cab .subtitulo { font-size: 13px; color: var(--texto-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-cab .subtitulo.escribiendo { color: var(--acento); }
.conv-cab .acciones { display: flex; gap: 4px; }
.conv-fondo {
  position: absolute; inset: 0; pointer-events: none; opacity: 1;
  background-image: radial-gradient(var(--patron) 1.2px, transparent 1.3px), radial-gradient(var(--patron) 1.2px, transparent 1.3px);
  background-size: 26px 26px; background-position: 0 0, 13px 13px;
}
.mensajes { flex: 1; overflow-y: auto; min-height: 0; position: relative; padding: 10px 0 8px; }
.mensajes-int { position: relative; padding: 0 6%; display: flex; flex-direction: column; }
.ir-abajo {
  position: absolute; right: 22px; bottom: 76px; width: 42px; height: 42px; border-radius: 50%; background: var(--fondo-panel);
  box-shadow: var(--sombra); display: flex; align-items: center; justify-content: center; color: var(--texto-2); z-index: 3;
}
.ir-abajo .badge { position: absolute; top: -8px; right: -4px; }
.cargar-mas { align-self: center; margin: 6px 0 14px; }
.pastilla {
  align-self: center; background: var(--sistema-fondo); color: var(--sistema-texto); border-radius: 7.5px; padding: 5px 12px 6px;
  font-size: 12.5px; box-shadow: var(--burbuja-sombra); margin: 8px 0; text-align: center; max-width: 85%;
}
.pastilla.dia { text-transform: uppercase; position: sticky; top: 4px; z-index: 1; }
.pastilla.no-leidos { background: var(--fondo-panel); color: var(--texto-2); border-radius: 0; width: calc(100% + 12%); max-width: none; margin-left: -6%; text-transform: uppercase; }
.pastilla.llamada { display: flex; gap: 8px; align-items: center; }
.pastilla .ic { width: 16px; height: 16px; }

.fila { display: flex; flex-direction: column; margin-top: 2px; position: relative; }
.fila.nuevo-autor { margin-top: 10px; }
.fila.out { align-items: flex-end; }
.fila.in { align-items: flex-start; }
.fila.resaltada .burbuja { animation: resaltar 1.6s ease-out; }
@keyframes resaltar { 0%, 40% { box-shadow: 0 0 0 3px var(--acento); } 100% { box-shadow: var(--burbuja-sombra); } }
.fila.con-avatar { padding-left: 38px; }
.fila .mini-avatar { position: absolute; left: 0; top: 0; width: 28px; height: 28px; }
.burbuja {
  position: relative; max-width: min(65%, 560px); border-radius: 7.5px; padding: 6px 7px 8px 9px; box-shadow: var(--burbuja-sombra);
  background: var(--burbuja-in); line-height: 19px; word-wrap: break-word; overflow-wrap: anywhere; min-width: 70px;
}
.fila.out .burbuja { background: var(--burbuja-out); }
.fila.nuevo-autor.in .burbuja { border-top-left-radius: 0; }
.fila.nuevo-autor.out .burbuja { border-top-right-radius: 0; }
.fila.nuevo-autor.in .burbuja::before, .fila.nuevo-autor.out .burbuja::before {
  content: ""; position: absolute; top: 0; width: 8px; height: 13px;
}
.fila.nuevo-autor.in .burbuja::before { left: -8px; background: linear-gradient(to bottom left, var(--burbuja-in) 50%, transparent 50%); }
.fila.nuevo-autor.out .burbuja::before { right: -8px; background: linear-gradient(to bottom right, var(--burbuja-out) 50%, transparent 50%); }
.burbuja.solo-media { padding: 3px; }
.burbuja.sticker { background: transparent !important; box-shadow: none; padding: 0; }
.burbuja.sticker::before { display: none; }
.burbuja .autor { font-size: 12.8px; font-weight: 500; margin-bottom: 2px; display: flex; gap: 8px; align-items: baseline; line-height: 18px; }
.burbuja .autor .notify { color: var(--texto-3); font-weight: 400; font-size: 12px; }
.burbuja .reenviado { color: var(--texto-3); font-size: 12.5px; font-style: italic; display: flex; align-items: center; gap: 4px; margin-bottom: 2px; }
.burbuja .texto { white-space: pre-wrap; font-size: 14.2px; }
.burbuja .texto.emoji-grande { font-size: 40px; line-height: 48px; }
.burbuja .texto code { font-family: Consolas, "Courier New", monospace; background: var(--code); border-radius: 3px; padding: 0 3px; font-size: 13px; }
.burbuja .texto pre { margin: 0; font-family: Consolas, monospace; font-size: 13px; white-space: pre-wrap; }
.burbuja .texto blockquote { margin: 0; border-left: 3px solid var(--borde-2); padding-left: 8px; color: var(--texto-2); }
.burbuja .texto .mencion { color: var(--enlace); cursor: pointer; }
.burbuja .meta-espacio { display: inline-block; width: var(--meta-ancho, 68px); height: 1px; }
.burbuja .meta {
  float: right; margin: -10px 0 -5px 8px; position: relative; top: 7px; display: flex; align-items: center; gap: 3px;
  font-size: 11px; color: var(--texto-3); white-space: nowrap; height: 15px;
}
.burbuja.solo-media .meta, .burbuja.sticker .meta {
  position: absolute; right: 7px; bottom: 6px; top: auto; margin: 0; color: #fff; background: rgba(0,0,0,.35); border-radius: 10px;
  padding: 1px 6px; float: none;
}
.burbuja .meta .tick { color: var(--texto-3); }
.burbuja .meta .tick.leido { color: var(--azul-tick); }
.burbuja .meta .tick.error { color: var(--peligro); }
.burbuja.solo-media .meta .tick, .burbuja.sticker .meta .tick { color: #fff; }
.burbuja.solo-media .meta .tick.leido { color: var(--azul-tick); }
.burbuja .menu-btn {
  position: absolute; top: 2px; right: 2px; width: 26px; height: 22px; border-radius: 0 6px 0 12px; display: flex; opacity: 0;
  align-items: center; justify-content: center; color: var(--texto-3); z-index: 2;
  background: radial-gradient(at top right, var(--burbuja-in) 60%, transparent 80%);
}
.fila.out .burbuja .menu-btn { background: radial-gradient(at top right, var(--burbuja-out) 60%, transparent 80%); }
.burbuja.solo-media .menu-btn, .burbuja.sticker .menu-btn { color: #fff; background: radial-gradient(at top right, rgba(0,0,0,.4), transparent 70%); }
.burbuja:hover .menu-btn, .burbuja .menu-btn:focus-visible { opacity: 1; }
.fila-linea { display: flex; align-items: center; gap: 8px; width: 100%; }
.fila.out .fila-linea { flex-direction: row-reverse; }
.fila .reaccionar-rapido {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  background: var(--fondo-cab); color: var(--texto-3); display: flex; align-items: center; justify-content: center; opacity: 0;
}
.fila:hover .reaccionar-rapido { opacity: .9; }
.burbuja .borrado { color: var(--texto-3); font-style: italic; display: flex; align-items: center; gap: 5px; }
.burbuja .aviso-chico { color: var(--texto-3); font-style: italic; }

.cita {
  background: var(--cita-fondo); border-radius: 6px; border-left: 4px solid var(--acento); padding: 6px 10px 6px 8px; margin-bottom: 4px;
  cursor: pointer; display: flex; gap: 8px; overflow: hidden; min-height: 42px;
}
.cita .cita-cuerpo { flex: 1; min-width: 0; }
.cita .cita-autor { font-size: 12.8px; font-weight: 500; color: var(--acento); }
.cita .cita-texto { font-size: 13.2px; color: var(--texto-2); max-height: 60px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; white-space: pre-wrap; }
.cita img { width: 52px; height: 52px; object-fit: cover; border-radius: 4px; margin: -6px -10px -6px 0; }

.media-img { position: relative; border-radius: 6px; overflow: hidden; cursor: pointer; background: #00000014 center/cover no-repeat; max-width: 100%; min-width: 120px; }
.media-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.media-img .reproducir, .media-img .carga {
  position: absolute; inset: 0; margin: auto; width: 54px; height: 54px; border-radius: 50%; background: rgba(11, 20, 26, .55);
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.media-img .duracion { position: absolute; left: 7px; bottom: 6px; color: #fff; font-size: 11px; display: flex; gap: 4px; align-items: center; text-shadow: 0 0 3px #000; }
.media-img.error::after { content: "No se pudo cargar"; position: absolute; inset: auto 0 40% 0; text-align: center; color: #fff; text-shadow: 0 0 3px #000; font-size: 12px; }
.burbuja .caption { padding: 6px 4px 0 4px; }
.sticker-img { width: 160px; height: 160px; object-fit: contain; display: block; cursor: pointer; }

.doc {
  display: flex; align-items: center; gap: 10px; background: var(--cita-fondo); border-radius: 6px; padding: 10px 12px; cursor: pointer;
  min-width: 240px; max-width: 340px;
}
.doc-prev { width: 100%; max-height: 160px; object-fit: cover; object-position: top; border-radius: 6px 6px 0 0; display: block; margin-bottom: -4px; }
.doc .doc-ic {
  width: 30px; height: 38px; border-radius: 3px; background: #6b8fb0; color: #fff; font-size: 9px; font-weight: 700;
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 5px; flex: none; text-transform: uppercase;
}
.doc .doc-ic.pdf { background: #e5252a; }
.doc .doc-ic.xls, .doc .doc-ic.xlsx, .doc .doc-ic.csv { background: #1d6f42; }
.doc .doc-ic.doc, .doc .doc-ic.docx { background: #2b579a; }
.doc .doc-ic.zip, .doc .doc-ic.rar { background: #8a6d3b; }
.doc .doc-info { flex: 1; min-width: 0; }
.doc .doc-nombre { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc .doc-det { font-size: 12px; color: var(--texto-3); }
.doc .doc-bajar { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--borde-2); display: flex; align-items: center; justify-content: center; color: var(--texto-3); }

.audio { display: flex; align-items: center; gap: 10px; min-width: 260px; padding: 4px 2px 0; }
.audio .audio-av { position: relative; }
.audio .audio-av .mic { position: absolute; right: -4px; bottom: -2px; color: var(--azul-tick); }
.audio .play { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; color: var(--texto-2); flex: none; }
.audio .pista { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.audio input[type=range] { width: 100%; accent-color: var(--acento); height: 4px; }
.audio .tiempos { font-size: 11px; color: var(--texto-3); display: flex; justify-content: space-between; }
.audio .velocidad { font-size: 11px; font-weight: 600; background: var(--cita-fondo); border-radius: 10px; padding: 2px 6px; color: var(--texto-2); }

.ubicacion { width: 270px; cursor: pointer; }
.ubicacion .mapa {
  height: 140px; border-radius: 6px; background: linear-gradient(135deg, #cfe8d8, #a6d4e5); display: flex; align-items: center;
  justify-content: center; color: #d33; background-size: cover; background-position: center;
}
.ubicacion .ub-nombre { margin-top: 6px; }
.ubicacion .ub-dir { font-size: 12.5px; color: var(--texto-3); }

.contacto-card { min-width: 240px; }
.contacto-card .cc-fila { display: flex; align-items: center; gap: 12px; padding: 6px 2px 10px; border-bottom: 1px solid var(--borde-2); }
.contacto-card .cc-nombre { font-weight: 500; }
.contacto-card .cc-acc { display: flex; justify-content: center; padding-top: 8px; color: var(--enlace); }

.encuesta { min-width: 280px; }
.encuesta .enc-preg { font-weight: 500; margin-bottom: 4px; }
.encuesta .enc-tipo { font-size: 12px; color: var(--texto-3); margin-bottom: 10px; }
.encuesta .enc-op { margin: 10px 0; }
.encuesta .enc-op-cab { display: flex; justify-content: space-between; gap: 10px; }
.encuesta .enc-barra { height: 6px; border-radius: 3px; background: var(--cita-fondo); margin-top: 5px; overflow: hidden; }
.encuesta .enc-barra div { height: 100%; background: var(--acento); }
.encuesta .enc-votantes { font-size: 11.5px; color: var(--texto-3); margin-top: 2px; }
.encuesta .enc-pie { font-size: 12px; color: var(--texto-3); text-align: center; padding-top: 6px; border-top: 1px solid var(--borde-2); }

.link-prev { display: flex; flex-direction: column; background: var(--cita-fondo); border-radius: 6px; overflow: hidden; margin-bottom: 4px; text-decoration: none; color: inherit; }
.link-prev img { width: 100%; max-height: 160px; object-fit: cover; }
.link-prev .lp-txt { padding: 6px 10px; }
.link-prev .lp-tit { font-size: 13.5px; font-weight: 500; }
.link-prev .lp-desc { font-size: 12.5px; color: var(--texto-3); max-height: 34px; overflow: hidden; }
.link-prev .lp-url { font-size: 12px; color: var(--texto-3); }

.reacciones {
  display: inline-flex; gap: 2px; align-items: center; background: var(--fondo-panel); border-radius: 12px; padding: 2px 6px;
  box-shadow: var(--burbuja-sombra); font-size: 14px; margin: -6px 10px 4px; cursor: pointer; position: relative; z-index: 1;
  border: 1px solid var(--borde);
}
.reacciones .cant { font-size: 12px; color: var(--texto-3); margin-left: 3px; }

/* redactor */
.redactor { background: var(--fondo-cab); flex: none; position: relative; z-index: 2; }
.redactor-barra { display: flex; align-items: flex-end; gap: 6px; padding: 5px 16px; min-height: 62px; }
.redactor-barra > .icono-btn { margin-bottom: 6px; }
.redactor-input {
  flex: 1; background: var(--fondo-panel); border-radius: 8px; padding: 9px 12px; margin: 5px 0 6px; max-height: 140px; overflow-y: auto;
  min-height: 42px; display: flex;
}
:root[data-theme="dark"] .redactor-input { background: #2a3942; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .redactor-input { background: #2a3942; } }
.redactor-input textarea {
  flex: 1; border: 0; outline: none; background: transparent; resize: none; line-height: 22px; font-size: 15px; max-height: 120px;
  padding: 0; height: 22px;
}
.redactor .previa-cita {
  margin: 0 16px; padding: 8px 0 0 0; display: flex; gap: 10px; align-items: center;
}
.redactor .previa-cita .cita { flex: 1; margin: 0; cursor: default; }
.redactor-grabando { display: flex; align-items: center; justify-content: flex-end; gap: 16px; padding: 5px 20px; min-height: 62px; }
.redactor-grabando .punto-rojo { width: 10px; height: 10px; border-radius: 50%; background: var(--peligro); animation: titilar 1s infinite; }
@keyframes titilar { 50% { opacity: .2; } }
.redactor-grabando .tiempo { font-variant-numeric: tabular-nums; color: var(--texto-2); min-width: 44px; }
.boton-enviar { width: 42px; height: 42px; border-radius: 50%; background: var(--acento); color: #fff; display: flex; align-items: center; justify-content: center; margin-bottom: 7px; }
.boton-enviar:hover { background: var(--acento-2); }
.bloqueado-aviso { text-align: center; padding: 20px; color: var(--texto-3); }

.menciones-lista {
  position: absolute; left: 16px; right: 16px; bottom: 100%; max-height: 260px; overflow-y: auto; background: var(--menu-fondo);
  box-shadow: var(--sombra); border-radius: 8px; z-index: 5;
}
.menciones-lista .mencion-item { display: flex; align-items: center; gap: 12px; padding: 8px 14px; cursor: pointer; }
.menciones-lista .mencion-item.sel, .menciones-lista .mencion-item:hover { background: var(--fondo-hover); }

/* paneles emergentes (emojis, adjuntos) */
.popover {
  position: fixed; background: var(--menu-fondo); box-shadow: var(--sombra); border-radius: 12px; z-index: 40; overflow: hidden;
}
.panel-emojis { width: 360px; height: 360px; display: flex; flex-direction: column; }
.panel-emojis .pe-tabs { display: flex; border-bottom: 1px solid var(--borde); }
.panel-emojis .pe-tabs button { flex: 1; padding: 8px 0; font-size: 18px; opacity: .55; border-bottom: 3px solid transparent; }
.panel-emojis .pe-tabs button.activo { opacity: 1; border-bottom-color: var(--acento); }
.panel-emojis .pe-buscar { margin: 8px; padding: 6px 10px; border-radius: 8px; border: 0; background: var(--fondo-input); outline: none; }
.panel-emojis .pe-grilla { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(9, 1fr); padding: 0 6px 8px; align-content: start; }
.panel-emojis .pe-grilla button { font-size: 24px; height: 38px; border-radius: 6px; }
.panel-emojis .pe-grilla button:hover { background: var(--fondo-hover); }
.panel-emojis .pe-titulo { grid-column: 1 / -1; font-size: 12px; color: var(--texto-3); padding: 8px 4px 4px; }
.reacciones-rapidas { display: flex; gap: 2px; padding: 6px 8px; border-radius: 26px; }
.reacciones-rapidas button { font-size: 26px; width: 42px; height: 42px; border-radius: 50%; transition: transform .1s; }
.reacciones-rapidas button:hover { transform: scale(1.18); background: var(--fondo-hover); }
.reacciones-rapidas button.elegida { background: var(--fondo-activo); }

/* menu contextual */
.menu-ctx { position: fixed; z-index: 60; background: var(--menu-fondo); box-shadow: var(--sombra); border-radius: 8px; padding: 8px 0; min-width: 210px; max-height: 80vh; overflow-y: auto; }
.menu-ctx button { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 9px 22px 9px 18px; color: var(--texto); font-size: 14.5px; }
.menu-ctx button:hover { background: var(--fondo-hover); }
.menu-ctx button svg { width: 20px; height: 20px; color: var(--texto-2); }
.menu-ctx button.peligro { color: var(--peligro); }
.menu-ctx hr { border: 0; border-top: 1px solid var(--borde); margin: 6px 0; }

/* panel derecho */
.der { border-left: 1px solid var(--borde); background: var(--fondo-app); display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.der .cajon-cab { background: var(--fondo-panel); }
.der .der-cuerpo { flex: 1; overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.der .bloque { background: var(--fondo-panel); padding: 16px 28px; box-shadow: 0 1px 3px rgba(11,20,26,.08); }
.der .bloque.centrado { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 28px; }
.der .bloque h4 { margin: 0 0 10px; font-weight: 400; color: var(--texto-3); font-size: 14px; display: flex; justify-content: space-between; }
.der .nombre-grande { font-size: 22px; margin-top: 12px; }
.der .sub { color: var(--texto-3); font-size: 15px; }
.der .bloque.opciones { padding: 0; }
.der .bloque.opciones .opcion { padding: 0 28px; height: 54px; }
.der .grilla-media { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.der .grilla-media div { aspect-ratio: 1; border-radius: 6px; background: #0002 center/cover; cursor: pointer; position: relative; }
.participante { display: flex; align-items: center; gap: 14px; padding: 8px 0; cursor: pointer; }
.participante .p-cuerpo { flex: 1; min-width: 0; }
.participante .p-nombre { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.participante .p-sub { color: var(--texto-3); font-size: 13px; }
.participante .p-admin { font-size: 11px; color: var(--acento-2); border: 1px solid var(--acento); border-radius: 4px; padding: 1px 5px; flex: none; }
.pestanas { display: flex; border-bottom: 1px solid var(--borde); background: var(--fondo-panel); }
.pestanas button { flex: 1; padding: 14px 0; color: var(--texto-3); border-bottom: 3px solid transparent; }
.pestanas button.activo { color: var(--acento-2); border-bottom-color: var(--acento); }
.lista-docs .doc { margin: 8px 0; max-width: none; }

/* conexion / QR */
.capa-conexion { position: fixed; inset: 0; background: var(--fondo-app); z-index: 80; display: flex; align-items: center; justify-content: center; overflow: auto; }
.capa-conexion .franja { position: fixed; inset: 0 0 auto 0; height: 200px; background: var(--acento-2); }
.qr-caja {
  position: relative; background: var(--fondo-panel); border-radius: 12px; box-shadow: var(--sombra); padding: 48px 56px; width: min(1000px, calc(100% - 32px));
  display: flex; gap: 48px; align-items: center; flex-wrap: wrap;
}
.qr-caja .qr-texto { flex: 1; min-width: 260px; }
.qr-caja h1 { font-weight: 300; font-size: 28px; margin: 0 0 26px; }
.qr-caja ol { padding-left: 20px; line-height: 2.1; font-size: 17px; color: var(--texto-2); margin: 0 0 20px; }
.qr-caja .qr-img { width: 264px; height: 264px; background: #fff; display: flex; align-items: center; justify-content: center; border-radius: 6px; padding: 8px; }
.qr-caja .qr-img img { width: 100%; height: 100%; image-rendering: pixelated; }
.qr-caja .codigo-par { font-family: Consolas, monospace; font-size: 30px; letter-spacing: 6px; color: var(--acento-2); margin: 14px 0; }
.spinner { width: 40px; height: 40px; border: 4px solid var(--borde-2); border-top-color: var(--acento); border-radius: 50%; animation: girar 1s linear infinite; }
.spinner.chico { width: 22px; height: 22px; border-width: 3px; }
@keyframes girar { to { transform: rotate(360deg); } }

/* modales */
.modal-fondo { position: fixed; inset: 0; background: rgba(11, 20, 26, .55); z-index: 70; display: flex; align-items: center; justify-content: center; padding: 16px; }
:root[data-theme="dark"] .modal-fondo { background: rgba(11, 20, 26, .85); }
.modal { background: var(--fondo-panel); border-radius: 8px; box-shadow: var(--sombra); width: min(500px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; overflow: hidden; }
.modal.ancho { width: min(720px, 100%); }
.modal-cab { display: flex; align-items: center; gap: 16px; padding: 18px 22px 8px; font-size: 19px; }
.modal-cuerpo { padding: 8px 22px 16px; overflow-y: auto; color: var(--texto-2); line-height: 1.5; }
.modal-pie { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 22px 20px; flex-wrap: wrap; }
.modal input[type=text], .modal input[type=number], .modal input[type=tel], .modal input[type=search], .modal textarea, .modal select {
  width: 100%; border: 0; border-bottom: 2px solid var(--acento); background: transparent; padding: 8px 2px; outline: none; color: var(--texto); font-size: 15px;
}
.modal label.check { display: flex; align-items: center; gap: 10px; margin: 10px 0; cursor: pointer; color: var(--texto); }
.modal input[type=checkbox], .modal input[type=radio] { accent-color: var(--acento); width: 18px; height: 18px; }
.modal .lista-sel { max-height: 50vh; overflow-y: auto; margin: 0 -22px; }
.modal .lista-sel .item-sel { display: flex; align-items: center; gap: 14px; padding: 8px 22px; cursor: pointer; color: var(--texto); }
.modal .lista-sel .item-sel:hover { background: var(--fondo-hover); }
.modal .lista-sel .item-sel .is-nombre { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modal .fila-campo { display: flex; gap: 10px; align-items: center; margin: 8px 0; }
.adjuntos-previa { display: flex; flex-direction: column; height: min(600px, calc(100vh - 190px)); margin: 0 -22px -16px; }
.adjuntos-previa .ap-principal { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; background: var(--fondo-cab); padding: 16px; }
.adjuntos-previa .ap-principal img, .adjuntos-previa .ap-principal video { max-width: 100%; max-height: 100%; border-radius: 4px; }
.adjuntos-previa .ap-doc { text-align: center; color: var(--texto-2); }
.adjuntos-previa .ap-doc .doc-ic { width: 70px; height: 90px; margin: 0 auto 14px; font-size: 14px; border-radius: 6px; }
.adjuntos-previa .ap-caption { padding: 10px 22px; }
.adjuntos-previa .ap-miniaturas { display: flex; gap: 8px; padding: 8px 22px 16px; align-items: center; overflow-x: auto; }
.adjuntos-previa .ap-mini {
  width: 52px; height: 52px; border-radius: 6px; border: 2px solid transparent; background: var(--fondo-input) center/cover; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 10px; position: relative; color: var(--texto-2);
}
.adjuntos-previa .ap-mini.activo { border-color: var(--acento); }
.adjuntos-previa .ap-mini .quitar { position: absolute; top: -6px; right: -6px; background: var(--fondo-panel); border-radius: 50%; width: 18px; height: 18px; display: none; align-items: center; justify-content: center; box-shadow: var(--sombra); }
.adjuntos-previa .ap-mini:hover .quitar { display: flex; }
.adjuntos-previa .ap-opciones { display: flex; gap: 18px; padding: 0 22px; color: var(--texto-2); font-size: 13px; flex-wrap: wrap; }

/* toasts */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #323739; color: #fff; padding: 12px 20px; border-radius: 6px; box-shadow: var(--sombra); display: flex; gap: 16px; align-items: center;
  max-width: 90vw; animation: aparecer .15s ease-out;
}
.toast.error { background: #a4001f; }
.toast button { color: #00e2a5; font-weight: 600; }
@keyframes aparecer { from { transform: translateY(10px); opacity: 0; } }

/* visor */
.visor { position: fixed; inset: 0; z-index: 75; background: rgba(233, 237, 239, .97); display: flex; flex-direction: column; }
:root[data-theme="dark"] .visor { background: rgba(11, 20, 26, .97); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .visor { background: rgba(11, 20, 26, .97); } }
.visor-cab { display: flex; align-items: center; gap: 14px; padding: 10px 18px; height: 60px; }
.visor-cab .info { flex: 1; min-width: 0; }
.visor-cab .info div:last-child { font-size: 13px; color: var(--texto-3); }
.visor-cuerpo { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; padding: 10px 70px; position: relative; }
.visor-cuerpo img, .visor-cuerpo video { max-width: 100%; max-height: 100%; box-shadow: var(--sombra); }
.visor-cuerpo .nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; background: var(--fondo-panel); box-shadow: var(--sombra); display: flex; align-items: center; justify-content: center; }
.visor-cuerpo .nav.ant { left: 16px; }
.visor-cuerpo .nav.sig { right: 16px; }
.visor-pie { text-align: center; padding: 12px 20px 22px; color: var(--texto); white-space: pre-wrap; }
.estado-barras { display: flex; gap: 4px; padding: 8px 18px 0; }
.estado-barras div { flex: 1; height: 3px; background: rgba(128,128,128,.35); border-radius: 2px; overflow: hidden; }
.estado-barras div span { display: block; height: 100%; width: 0; background: var(--texto); }
.estado-texto { font-size: 30px; padding: 40px; text-align: center; max-width: 700px; white-space: pre-wrap; border-radius: 12px; }

.soltar { position: fixed; inset: 0; z-index: 65; background: rgba(0, 168, 132, .18); border: 4px dashed var(--acento); display: flex; align-items: center; justify-content: center; font-size: 22px; color: var(--acento-2); pointer-events: none; }
.soltar div { background: var(--fondo-panel); padding: 20px 30px; border-radius: 12px; box-shadow: var(--sombra); }

.buscar-en-chat { display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--fondo-panel); border-bottom: 1px solid var(--borde); }
.buscar-en-chat input { flex: 1; border: 0; background: var(--fondo-input); border-radius: 8px; padding: 8px 12px; outline: none; }

@media (max-width: 900px) {
  .app, .app.con-der { grid-template-columns: 56px 1fr; }
  .app .centro { display: none; }
  .app.en-chat .izq { display: none; }
  .app.en-chat .centro { display: flex; }
  .app.con-der .der { position: fixed; inset: 0; z-index: 30; }
  .app.con-der.en-chat .centro { display: flex; }
  .burbuja { max-width: 85%; }
  .mensajes-int { padding: 0 3%; }
  .boton-volver { display: inline-flex !important; }
}
.boton-volver { display: none !important; }
