/* ═══ Chat · lista estilo mensajería (2.webp) + conversación con burbuja violeta y panel de compartidos (5.webp) + reacciones y notas de voz (4.png) ═══ */
.chat { --chat-bubble: var(--card); --chat-own: var(--bubble-own); --chat-own-text: var(--bubble-own-text); }
:root[data-theme='dark'] .chat { --chat-bubble: var(--card-2); }
.chat > .col-list { width: 336px; padding: 0; display: flex; flex-direction: column; }
.chat > .col-side { width: 304px; padding: 0; }
.chat.no-side > .col-side { display: none; }
@media (max-width: 1180px) { .chat > .col-side { display: none; } }

/* ── cabecera + "conectados ahora" · CORRECCIÓN DEL CLIENTE: nada de bloques índigo; claro = blanco y tinta, oscuro = vidrio con brasas (todo sale de tokens) ── */
.chat-hero { position: relative; isolation: isolate; flex: none; margin: 10px 10px 4px; padding: 18px 16px 14px; border-radius: 26px; color: var(--text); overflow: hidden;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); animation: rise 460ms var(--ease) both; }
:root[data-theme='dark'] .chat-hero { background: var(--lg-bg); border-color: var(--lg-border); box-shadow: var(--lg-hi), var(--lg-shadow); }
:root[data-theme='dark'] .chat-hero::before { content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(300px 180px at 100% 0%, var(--primary-glow), transparent 70%), radial-gradient(240px 160px at 0% 100%, var(--danger-soft), transparent 72%), var(--lg-sheen); }
.chat-hero h1 { font-size: 24px; } .chat-hero-sub { font-size: 12.5px; color: var(--muted); }
.chat-hero-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--text); background: var(--card-2); border: 1px solid var(--line);
  transition: transform var(--t) var(--spring), background var(--t) var(--ease); }
.chat-hero-btn:hover { background: var(--card-3); transform: translateY(-2px) scale(1.06); } .chat-hero-btn:active { transform: scale(.92); }
.chat-hero-btn:last-child { background: var(--primary); color: var(--on-primary); border-color: transparent; box-shadow: 0 8px 18px var(--primary-glow); } .chat-hero-btn:last-child:hover { background: var(--primary-2); }
.chat-search { margin-top: 14px; }
.chat-online { display: flex; gap: 10px; margin: 14px -16px 0; padding: 4px 16px 2px; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.chat-online::-webkit-scrollbar { display: none; }
.chat-story { width: 62px; flex: none; display: flex; flex-direction: column; align-items: center; gap: 5px; color: var(--text-2); font-size: 11px; font-weight: 600; scroll-snap-align: start; animation: rise 420ms var(--ease) both; }
.chat-story > span:last-child { max-width: 100%; }
.chat-story-ring { width: 60px; height: 60px; border-radius: 50%; padding: 2px; border: 2px solid var(--ok); display: grid; place-items: center; transition: transform var(--t) var(--spring), box-shadow var(--t) var(--ease); }
.chat-story:hover .chat-story-ring { transform: translateY(-3px) scale(1.05); box-shadow: var(--shadow); } .chat-story:active .chat-story-ring { transform: scale(.93); }
.chat-story.add .chat-story-ring { border-style: dashed; border-color: var(--muted); background: var(--card-2); color: var(--text); }
.chat-online-empty { align-self: center; font-size: 12px; color: var(--muted); padding-left: 4px; }

/* ── lista de conversaciones ── */
.chat-list-body { padding: 0 10px 18px; }
.chat-row { padding: 9px 10px; border-radius: 18px; min-height: 58px; }
.chat-row-name { font-weight: 700; font-size: 14px; } .chat-row-prev { color: var(--muted); }
.chat-row.unread .chat-row-name { font-weight: 800; } .chat-row.unread .chat-row-prev { color: var(--text-2); font-weight: 600; }
.chat-row.active .chat-ico { background: var(--primary); color: var(--on-primary); box-shadow: 0 6px 14px var(--primary-glow); }
.chat-clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.chat-ico { width: 40px; height: 40px; border-radius: 14px; flex: none; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); transition: background var(--t) var(--ease), color var(--t) var(--ease), box-shadow var(--t) var(--ease); }
.chat-ico.lock { background: var(--warn-soft); color: var(--warn); }
.chat-ico.xl { width: 76px; height: 76px; border-radius: 26px; } .chat-ico.xl .icon { width: 34px; height: 34px; }
.chat-mini { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); background: var(--card-2); transition: all var(--t) var(--ease); }
.chat-mini .icon { width: 15px; height: 15px; } .chat-mini:hover { background: var(--primary); color: #fff; transform: rotate(90deg); }
.chat-none { padding: 8px 12px; }
.chat-archived-link { display: flex; align-items: center; gap: 8px; margin: 14px 12px 0; font-size: 12px; font-weight: 700; color: var(--muted); transition: color var(--t) var(--ease); }
.chat-archived-link .icon { width: 15px; height: 15px; } .chat-archived-link:hover { color: var(--primary); }
.chat-sk { padding-top: 8px; } .chat-sk-row { display: flex; align-items: center; gap: 12px; padding: 10px; }
.chat-sk-av { width: 40px; height: 40px; border-radius: 50%; flex: none; } .chat-sk-av.sm { width: 32px; height: 32px; }

/* ── conversación ── */
.chat-blank { flex: 1; display: grid; place-items: center; }
.chat-convo { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.chat-head-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; text-align: left; padding: 4px 10px 4px 4px; border-radius: 18px; transition: background var(--t) var(--ease); }
.chat-head-main:hover { background: var(--card-2); } .chat-head .btn.icon { flex: none; } .chat-head .avatar-stack { flex: none; }
/* Anchos intermedios: la conversación queda en ~420–600px y la pila de avatares (redundante con "N en línea" y con el panel derecho) le comía el lugar al nombre del canal. */
@media (max-width: 1040px) { .chat-head .avatar-stack { display: none; } }
@media (min-width: 1180.01px) and (max-width: 1400px) { .chat:not(.no-side) .chat-head .avatar-stack { display: none; } }
.chat-body { position: relative; flex: 1; min-height: 0; display: flex; }
.chat-scroll { flex: 1; min-width: 0; overflow: hidden auto; overscroll-behavior: contain; overflow-anchor: none; /* el ancla al paginar la maneja la vista */ padding: 14px 22px 6px; display: flex; flex-direction: column; }
.chat-scroll > * { flex: none; } .chat-scroll > :first-child { margin-top: auto; }
.chat-intro { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 22px 4px 10px; animation: rise 460ms var(--ease) both; } .chat-intro p { max-width: 460px; }
.chat-intro h2, .chat-intro p { overflow-wrap: anywhere; } /* nombre de canal o tema largo sin espacios: baja de línea en vez de cortarse contra el borde */
.chat-loader { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 14px; font-size: 12px; color: var(--muted); }
.chat-spin { width: 16px; height: 16px; flex: none; border-radius: 50%; border: 2.5px solid var(--card-3); border-top-color: var(--primary); animation: spin .8s linear infinite; }
.chat-day, .chat-new { display: flex; align-items: center; gap: 12px; margin: 18px 0 4px; font-size: 11.5px; font-weight: 700; color: var(--muted); }
.chat-day::before, .chat-day::after, .chat-new::before, .chat-new::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.chat-day span { display: inline-block; padding: 4px 12px; border-radius: var(--r-pill); background: var(--card-2); } .chat-day span::first-letter { text-transform: uppercase; }
.chat-new { color: var(--danger); margin: 12px 0 2px; } .chat-new::before, .chat-new::after { background: var(--danger); opacity: .45; }
.chat-new span { padding: 3px 11px; border-radius: var(--r-pill); background: var(--danger-soft); animation: pop var(--t-slow) var(--spring) both; }

.chat-msg { position: relative; display: flex; gap: 10px; padding: 1.5px 0; border-radius: 16px; transform-origin: 0 100%; }
.chat-msg.own { flex-direction: row-reverse; transform-origin: 100% 100%; } .chat-msg.first { margin-top: 12px; }
.chat-msg.in { animation: chat-in 380ms var(--ease) both; }
.chat-msg.out { opacity: 0; transform: scale(.94); transition: opacity 200ms var(--ease), transform 200ms var(--ease); }
.chat-msg.flash { animation: chat-flash 1.8s var(--ease) both; }
.chat-msg.pending .chat-bubble, .chat-msg.pending .chat-media, .chat-msg.pending .chat-file, .chat-msg.pending .chat-audio { opacity: .62; }
.chat-msg.failed .chat-bubble { box-shadow: 0 0 0 2px var(--danger); }
.chat-msg-av { width: 32px; flex: none; padding-top: 20px; }
.chat-msg-col { position: relative; min-width: 0; max-width: min(76%, 640px); display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.chat-msg.own .chat-msg-col { align-items: flex-end; }
.chat-msg-meta { display: flex; align-items: baseline; gap: 8px; font-size: 11px; color: var(--muted); padding: 0 6px; } .chat-msg-meta b { font-size: 12.5px; color: var(--text); font-weight: 700; }
.chat-bubble { max-width: 100%; padding: 9px 14px; border-radius: 20px; border-top-left-radius: 8px; background: var(--chat-bubble); border: 1px solid var(--line); font-size: 14.5px; line-height: 1.45;
  white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: 0 2px 8px rgba(40, 40, 90, .04); transition: box-shadow var(--t) var(--ease); }
.chat-msg.first .chat-bubble { border-top-left-radius: 20px; }
.chat-msg.own .chat-bubble { background: var(--chat-own); color: var(--chat-own-text); border-color: transparent; border-radius: 20px; border-top-right-radius: 8px; box-shadow: 0 8px 20px var(--primary-glow); }
.chat-msg.own.first .chat-bubble { border-top-right-radius: 20px; }
.chat-bubble a { text-decoration: underline; text-underline-offset: 2px; } .chat-msg.own .chat-bubble a { color: #fff; }
.chat-bubble.jumbo, .chat-msg.own .chat-bubble.jumbo { font-size: 38px; line-height: 1.15; padding: 0 4px; background: none; border-color: transparent; box-shadow: none; }
.chat-edited { font-size: 11px; opacity: .65; }
.chat-mention { padding: 1px 5px; border-radius: 7px; font-weight: 700; color: var(--primary); background: var(--primary-soft); }
.chat-mention.me { color: #a85f00; background: var(--warn-soft); } :root[data-theme='dark'] .chat-mention.me { color: #fbbf24; }
.chat-msg.own .chat-mention { color: #fff; background: rgba(255, 255, 255, .24); }
.chat-quote { max-width: 100%; display: flex; flex-direction: column; gap: 1px; text-align: left; padding: 6px 12px; border-radius: 12px; border-left: 3px solid var(--primary); background: var(--primary-soft);
  font-size: 12.5px; color: var(--text-2); transition: transform var(--t-fast) var(--ease), background var(--t) var(--ease); }
.chat-quote b { color: var(--primary); font-size: 12px; } .chat-quote span { max-width: 320px; } .chat-quote:not(:disabled):hover { transform: translateX(2px); } .chat-quote:disabled { cursor: default; opacity: .7; }
.chat-retry { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--danger); } .chat-retry .icon { width: 14px; height: 14px; }

/* adjuntos */
.chat-media { width: min(340px, 100%); display: grid; gap: 4px; border-radius: 20px; overflow: hidden; grid-template-columns: 1fr 1fr; }
.chat-media.n1 { grid-template-columns: 1fr; } .chat-media.n3 > :first-child { grid-column: span 2; aspect-ratio: 2; }
.chat-media-item { position: relative; display: block; width: 100%; aspect-ratio: 1; overflow: hidden; background: var(--card-3); cursor: zoom-in; }
.chat-media.n1 .chat-media-item { aspect-ratio: 4 / 3; max-height: 420px; }
.chat-media-item img { width: 100%; height: 100%; object-fit: cover; transition: transform var(--t-slow) var(--ease); } .chat-media-item:hover img { transform: scale(1.05); }
.chat-media-ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.chat-play { position: absolute; inset: 0; margin: auto; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgba(10, 10, 30, .5); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); transition: transform var(--t) var(--spring); }
.chat-play .icon { fill: currentColor; width: 18px; height: 18px; margin-left: 2px; } .chat-media-item:hover .chat-play { transform: scale(1.12); }
.chat-dur { position: absolute; right: 8px; bottom: 8px; padding: 2px 7px; border-radius: 8px; font-size: 11px; font-weight: 700; color: #fff; background: rgba(10, 10, 30, .6); }
.chat-file, .chat-link { width: min(300px, 100%); display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 16px; color: var(--text); background: var(--chat-bubble); border: 1px solid var(--line);
  transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease), border-color var(--t) var(--ease); }
.chat-file:hover, .chat-link:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--primary); }
.chat-file b, .chat-file .tiny, .chat-link b, .chat-link .tiny { display: block; } .chat-file b, .chat-link b { font-size: 13px; } .chat-file .tiny, .chat-link .tiny { color: var(--muted); }
.chat-file > .icon { color: var(--muted); width: 18px; height: 18px; }
.chat-file-ico { width: 38px; height: 38px; border-radius: 12px; flex: none; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.chat-audio { width: min(300px, 100%); display: flex; align-items: center; gap: 10px; padding: 7px 14px 7px 7px; border-radius: 24px; background: var(--chat-bubble); border: 1px solid var(--line); color: var(--primary); }
.chat-msg.own .chat-audio { background: var(--chat-own); border-color: transparent; color: var(--chat-own-text); box-shadow: 0 8px 20px var(--primary-glow); }
.chat-audio-btn { width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--primary); color: #fff; transition: transform var(--t) var(--spring); }
.chat-audio-btn:hover { transform: scale(1.08); } .chat-audio-btn:active { transform: scale(.92); } .chat-audio-btn .icon { width: 17px; height: 17px; fill: currentColor; stroke-width: 2.4; }
.chat-msg.own .chat-audio-btn { background: #fff; color: var(--primary); }
.chat-audio-wave { flex: 1; min-width: 0; height: 30px; display: flex; align-items: center; gap: 2px; cursor: pointer; }
.chat-audio-wave i { flex: 1; min-width: 2px; border-radius: 2px; background: currentColor; opacity: .32; transition: opacity var(--t-fast) linear, transform var(--t) var(--ease); }
.chat-audio-wave i.on { opacity: 1; } .chat-audio.playing .chat-audio-wave i.on { transform: scaleY(1.12); }
.chat-audio-time { font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); } .chat-msg.own .chat-audio-time { color: rgba(255, 255, 255, .85); }

/* reacciones y acciones */
.chat-reacts { display: flex; flex-wrap: wrap; gap: 4px; }
.chat-react { height: 27px; padding: 0 9px; border-radius: 14px; display: inline-flex; align-items: center; gap: 5px; font-size: 13px; background: var(--card-2); border: 1.5px solid transparent;
  animation: pop var(--t) var(--spring) both; transition: transform var(--t-fast) var(--spring), background var(--t) var(--ease); }
.chat-react b { font-size: 11.5px; color: var(--text-2); } .chat-react:hover { transform: translateY(-2px) scale(1.06); }
.chat-react.mine { background: var(--primary-soft); border-color: var(--primary); } .chat-react.mine b { color: var(--primary); }
/* Flotantes SOBRE mensajes: fondo opaco (--solid). Con --card (5% de blanco en oscuro) el texto de abajo se leía a través y quedaba encimado con los botones. Sin blur acá: hay una barra por mensaje. */
.chat-actions { position: absolute; top: -34px; z-index: 3; display: flex; gap: 1px; padding: 3px; border-radius: var(--r-pill); background: var(--solid); border: 1px solid var(--line); box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transform: translateY(8px) scale(.94); transition: opacity var(--t-fast) var(--ease), transform var(--t) var(--spring); }
.chat-msg:not(.own) .chat-actions { left: 0; } .chat-msg.own .chat-actions { right: 0; }
.chat-msg.show-actions .chat-actions { opacity: 1; pointer-events: auto; transform: none; }
@media (hover: hover) { .chat-msg:hover .chat-actions, .chat-actions:focus-within { opacity: 1; pointer-events: auto; transform: none; } }
.chat-actions button { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 16px; color: var(--text-2); transition: transform var(--t-fast) var(--spring), background var(--t-fast) var(--ease), color var(--t-fast); }
.chat-actions button .icon { width: 17px; height: 17px; } .chat-actions button:hover { background: var(--card-2); transform: scale(1.15); color: var(--primary); } .chat-actions button.danger:hover { color: var(--danger); background: var(--danger-soft); }

/* flotante "mensajes nuevos" + escribiendo */
.chat-jump { position: absolute; left: 50%; bottom: 10px; z-index: 5; height: 38px; min-width: 38px; padding: 0 12px; border-radius: var(--r-pill); display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 12.5px; font-weight: 700;
  background: var(--solid); background: color-mix(in srgb, var(--solid) 90%, transparent); backdrop-filter: var(--lg-blur); -webkit-backdrop-filter: var(--lg-blur); color: var(--text); border: 1px solid var(--line); box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transform: translate(-50%, 18px) scale(.9); transition: opacity var(--t) var(--ease), transform var(--t) var(--spring), background var(--t) var(--ease); }
.chat-jump.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); } .chat-jump.new { background: var(--primary); color: #fff; border-color: transparent; } .chat-jump .icon { width: 17px; height: 17px; }
.chat-typing { flex: none; height: 22px; padding: 0 28px; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); opacity: 0; transform: translateY(5px); transition: opacity var(--t) var(--ease), transform var(--t) var(--ease); }
.chat-typing.on { opacity: 1; transform: none; }
.chat-dots { display: inline-flex; gap: 3px; } .chat-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); animation: chat-dot 1.1s var(--ease) infinite; }
.chat-dots i:nth-child(2) { animation-delay: .15s; } .chat-dots i:nth-child(3) { animation-delay: .3s; }

/* ── caja de mensaje ── */
.chat-composer { position: relative; flex: none; padding: 0 18px 16px; display: flex; flex-direction: column; gap: 8px; }
.chat-box, .chat-rec { display: flex; align-items: flex-end; gap: 4px; padding: 6px; border-radius: 28px; background: var(--card); border: 1.5px solid var(--line); box-shadow: var(--shadow); transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease); }
.chat-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft), var(--shadow); }
.chat-input { flex: 1; min-width: 0; max-height: 160px; padding: 10px 6px; border: 0; outline: 0; resize: none; background: none; font-size: 14.5px; line-height: 1.45; scrollbar-width: thin; }
.chat-input::placeholder { color: var(--muted); }
.chat-tool { flex: none; background: none; color: var(--muted); } .chat-tool:hover { background: var(--card-2); color: var(--primary); }
.chat-send { flex: none; animation: pop var(--t) var(--spring) both; } .chat-send .icon { width: 18px; height: 18px; }
.chat-rec { align-items: center; gap: 10px; padding-left: 8px; animation: rise var(--t) var(--ease) both; }
.chat-rec-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--danger); animation: chat-blink 1s var(--ease) infinite; }
.chat-rec-time { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 38px; } .chat-rec-wave { color: var(--danger); }
.chat-ctx { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; border-radius: 16px; border-left: 3px solid var(--primary); background: var(--primary-soft); font-size: 12.5px; animation: rise var(--t) var(--ease) both; }
.chat-ctx > .icon { color: var(--primary); } .chat-ctx b, .chat-ctx span { display: block; } .chat-ctx b { color: var(--primary); font-size: 12px; } .chat-ctx span { color: var(--text-2); }
.chat-tray { display: flex; gap: 8px; overflow-x: auto; padding: 8px 2px 2px; scrollbar-width: thin; }
.chat-up { position: relative; width: 72px; height: 72px; flex: none; border-radius: 16px; background: var(--card-2); border: 1px solid var(--line); animation: pop var(--t) var(--spring) both; }
.chat-up img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.chat-up-ico { width: 100%; height: 100%; padding: 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--primary); } .chat-up-ico span { max-width: 100%; color: var(--muted); }
.chat-up-prog { position: absolute; left: 7px; right: 7px; bottom: 7px; height: 5px; border-radius: 3px; background: rgba(10, 10, 30, .35); overflow: hidden; transition: opacity var(--t-slow) var(--ease); }
.chat-up-prog i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--primary-2), #fff); transition: width var(--t) var(--ease); }
.chat-up-prog.inline { position: static; width: 110px; flex: none; background: var(--card-3); } .chat-up-prog.inline i { background: var(--primary); }
.chat-up.done .chat-up-prog { opacity: 0; } .chat-up.error { border-color: var(--danger); box-shadow: 0 0 0 2px var(--danger-soft); } .chat-up.error .chat-up-prog i { background: var(--danger); }
.chat-up-x { position: absolute; top: -7px; right: -7px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--text); color: var(--solid); /* --card es translúcido en oscuro: la X quedaba invisible */ box-shadow: var(--shadow); transition: transform var(--t-fast) var(--spring); }
.chat-up-x .icon { width: 13px; height: 13px; stroke-width: 2.6; } .chat-up-x:hover { transform: scale(1.15); background: var(--danger); color: #fff; }
.chat-mentions { position: absolute; left: 18px; bottom: calc(100% + 2px); z-index: 12; width: min(340px, calc(100% - 36px)); padding: 6px; border-radius: 20px; background: var(--solid); background: color-mix(in srgb, var(--solid) 90%, transparent); backdrop-filter: var(--lg-blur); -webkit-backdrop-filter: var(--lg-blur); border: 1px solid var(--line); box-shadow: var(--shadow-lg); animation: chat-pop 240ms var(--spring) both; transform-origin: 10% 100%; }
.chat-mention-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 13px; text-align: left; font-size: 13.5px; transition: background var(--t-fast) var(--ease); }
.chat-mention-item b { flex: none; max-width: 60%; } .chat-mention-item.sel, .chat-mention-item:hover { background: var(--primary-soft); }
.chat-at { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); } .chat-at .icon { width: 14px; height: 14px; }
.chat-drop { position: absolute; inset: 10px; z-index: 20; border-radius: 26px; border: 2.5px dashed var(--primary); display: grid; place-items: center; color: var(--primary); font-size: 16px; pointer-events: none;
  background: var(--solid); background: color-mix(in srgb, var(--primary) 14%, var(--solid)); /* opaco también en oscuro: el cartel no se encima con los mensajes de abajo */ opacity: 0; transform: scale(.98); transition: opacity var(--t) var(--ease), transform var(--t) var(--spring); }
.chat-drop .icon { width: 40px; height: 40px; } .chat-convo.dragging .chat-drop { opacity: .96; transform: none; }
.chat-sk-convo { display: flex; flex-direction: column; gap: 14px; padding: 10px 0; } .chat-sk-msg { display: flex; align-items: flex-end; gap: 10px; } .chat-sk-msg.own { justify-content: flex-end; }

/* ── panel derecho: miembros + compartidos ── */
.chat-info { padding: 18px 14px 22px; animation: rise 460ms var(--ease) both; }
.chat-info-top { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 8px 8px 6px; } .chat-info-top h3 { margin-top: 6px; overflow-wrap: anywhere; } .chat-info-top p { max-width: 100%; overflow-wrap: anywhere; } .chat-info-top .pill .icon { width: 13px; height: 13px; }
.chat-members .list-row { padding: 7px 10px; } .chat-members .list-row:not([title='']) { cursor: pointer; } .chat-members .list-row[title=''] { cursor: default; }
.chat-shared-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 0 6px; } .chat-shared-grid .chat-media-item { border-radius: 14px; }
.chat-shared .chat-file, .chat-shared .chat-link { width: 100%; } .chat-shared > .col { padding: 0 6px; }
.chat-see { font-size: 11px; font-weight: 800; letter-spacing: 0; text-transform: none; color: var(--primary); }
.modal .chat-info { padding: 0; }

/* ── selector de personas (modales) ── */
.chat-pick { max-height: 300px; overflow: auto; display: flex; flex-direction: column; gap: 2px; scrollbar-width: thin; }
.chat-pick-row { width: 100%; text-align: left; } .chat-pick-row b, .chat-pick-row .tiny { display: block; } .chat-pick-row > .icon { color: var(--muted); width: 16px; height: 16px; }
.chat-pick-row.on { background: var(--primary-soft); }
.chat-check { width: 24px; height: 24px; border-radius: 50%; flex: none; display: grid; place-items: center; border: 2px solid var(--card-3); color: #fff; transition: all var(--t) var(--spring); } .chat-check .icon { width: 14px; height: 14px; stroke-width: 3; }
.chat-pick-row.on .chat-check { background: var(--primary); border-color: var(--primary); transform: scale(1.08); }

/* ── flotantes: emojis y visor ── */
.chat-emoji-pop { position: fixed; z-index: 160; width: 308px; max-width: calc(100vw - 16px); padding: 10px; border-radius: 22px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; background: var(--solid); background: color-mix(in srgb, var(--solid) 90%, transparent); backdrop-filter: var(--lg-blur); -webkit-backdrop-filter: var(--lg-blur); border: 1px solid var(--line); box-shadow: var(--shadow-lg);
  animation: chat-pop 260ms var(--spring) both; transform-origin: 80% 100%; }
.chat-emoji-pop button { aspect-ratio: 1; border-radius: 11px; font-size: 21px; display: grid; place-items: center; transition: transform var(--t-fast) var(--spring), background var(--t-fast) var(--ease); }
.chat-emoji-pop button:hover { background: var(--card-2); transform: scale(1.22); } .chat-emoji-pop button:active { transform: scale(.9); }
.chat-viewer { position: fixed; inset: 0; z-index: 150; display: flex; flex-direction: column; color: #fff; background: rgba(6, 7, 16, .93); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); animation: fade var(--t) var(--ease) both; }
.chat-viewer.out { opacity: 0; transition: opacity 200ms var(--ease); }
.chat-viewer-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: calc(60px + var(--safe-t)) 16px 8px; }
.chat-viewer-stage img, .chat-viewer-stage video { max-width: 100%; max-height: 100%; min-height: 0; object-fit: contain; border-radius: 14px; box-shadow: 0 30px 80px rgba(0, 0, 0, .6); animation: chat-zoom 380ms var(--spring) both; }
.chat-viewer-cap { flex: none; display: flex; align-items: center; justify-content: center; gap: 14px; padding: 10px 16px calc(16px + var(--safe-b)); font-size: 13px; } .chat-viewer-cap .truncate { max-width: 46vw; } .chat-viewer-n { opacity: .7; font-variant-numeric: tabular-nums; }
.chat-viewer-btn { position: absolute; z-index: 2; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .2); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); transition: transform var(--t) var(--spring), background var(--t) var(--ease); }
.chat-viewer-btn:hover { background: rgba(255, 255, 255, .26); transform: scale(1.08); }
.chat-viewer-btn.x { top: calc(12px + var(--safe-t)); right: 14px; } .chat-viewer-btn.prev, .chat-viewer-btn.next { top: 50%; margin-top: -23px; } .chat-viewer-btn.prev { left: 14px; } .chat-viewer-btn.next { right: 14px; }

@keyframes chat-in { from { opacity: 0; transform: translateY(12px) scale(.96); } }
@keyframes chat-pop { from { opacity: 0; transform: translateY(8px) scale(.9); } }
@keyframes chat-zoom { from { opacity: 0; transform: scale(.92); } }
@keyframes chat-flash { 0%, 35% { background: var(--primary-soft); box-shadow: 0 0 0 6px var(--primary-soft); } 100% { background: transparent; box-shadow: 0 0 0 6px transparent; } }
@keyframes chat-dot { 0%, 60%, 100% { transform: none; opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes chat-blink { 50% { opacity: .25; transform: scale(.8); } }
@keyframes chat-slide { from { opacity: 0; transform: translateX(28px); } }

/* ── hoja inferior (táctil): acciones de mensaje y emojis. Vive DENTRO de la conversación, que ya está ajustada al viewport visible → nunca queda detrás del teclado ── */
.chat-sheet-back { position: absolute; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; background: rgba(8, 8, 24, .42); animation: fade var(--t) var(--ease) both; }
.chat-sheet-back.out { opacity: 0; transition: opacity 180ms var(--ease); } .chat-sheet-back.out .chat-sheet { transform: translateY(100%); transition: transform 200ms var(--ease); }
.chat-sheet { position: relative; isolation: isolate; width: min(520px, 100%); max-height: 86%; overflow: hidden auto; overscroll-behavior: contain; border-radius: 28px 28px 0 0; padding: 22px 12px calc(12px + var(--safe-b));
  background: var(--solid); /* opaca a propósito: va sobre mensajes y tiene que leerse perfecto */
  border: 1px solid var(--lg-border); border-bottom: 0; box-shadow: var(--lg-hi), var(--shadow-lg); animation: chat-sheet-in 380ms var(--spring) both; }
.chat-sheet::before { content: ''; position: absolute; top: 8px; left: 50%; width: 40px; height: 5px; margin-left: -20px; border-radius: 3px; background: var(--card-3); }
.chat-sheet-prev { display: flex; flex-direction: column; gap: 1px; margin: 0 4px 12px; padding: 8px 12px; border-radius: 14px; border-left: 3px solid var(--primary); background: var(--card-2); font-size: 13px; color: var(--text-2); }
.chat-sheet-prev b { font-size: 12px; color: var(--text); }
.chat-sheet-reacts { display: flex; justify-content: space-between; gap: 2px; padding: 0 2px 12px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.chat-sheet-reacts button { flex: 1 1 0; min-width: 0; max-width: 48px; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; font-size: 25px; background: var(--card-2); border: 1.5px solid transparent; color: var(--text-2); transition: transform var(--t-fast) var(--spring), background var(--t-fast) var(--ease); }
.chat-sheet-reacts button:active { transform: scale(.86); } .chat-sheet-reacts button.mine { background: var(--primary-soft); border-color: var(--primary); }
.chat-sheet-item { width: 100%; min-height: 54px; display: flex; align-items: center; gap: 14px; padding: 0 14px; border-radius: 16px; text-align: left; font-size: 15.5px; font-weight: 600; color: var(--text); transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.chat-sheet-item .icon { width: 21px; height: 21px; color: var(--text-2); } .chat-sheet-item:active { background: var(--card-2); transform: scale(.985); }
.chat-sheet-item.danger, .chat-sheet-item.danger .icon { color: var(--danger); }
.chat-sheet-title { padding: 0 8px 10px; font-size: 16px; font-weight: 700; }
.chat-sheet-emojis { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.chat-sheet-emojis button { height: 48px; border-radius: 14px; font-size: 26px; display: grid; place-items: center; transition: transform var(--t-fast) var(--spring), background var(--t-fast) var(--ease); } .chat-sheet-emojis button:active { background: var(--card-2); transform: scale(.86); }
@keyframes chat-sheet-in { from { transform: translateY(100%); } }

/* Táctil: no hay hover → la barrita flotante no existe; las acciones salen en la hoja (toque o pulsación larga). Sin selección nativa que compita con la pulsación larga. */
@media (hover: none) {
  .chat-actions { display: none; }
  .chat-msg .chat-bubble, .chat-msg .chat-media, .chat-msg .chat-audio, .chat-msg .chat-file { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
  .chat-msg.held .chat-bubble, .chat-msg.held .chat-media, .chat-msg.held .chat-audio, .chat-msg.held .chat-file { transform: scale(.97); transition: transform 200ms var(--ease); }
}

/* ── móvil: lista → conversación a pantalla completa, caja siempre sobre el teclado ── */
@media (max-width: 860px) {
  .chat > .col-list { width: 100%; padding: 0; }
  .chat-hero { margin: 0; border-radius: 0 0 28px 28px; border-width: 0 0 1px; padding: calc(14px + var(--safe-t)) 16px 14px; animation: none; }
  .chat-hero h1 { font-size: 24px; } .chat-hero-sub { font-size: 13px; }   /* 24px = mismo título que Salas, Contenido, Panel, Equipo y Ajustes */
  .chat-hero-btn { width: 44px; height: 44px; }
  .chat-search { margin-top: 12px; }
  .chat-online { margin-top: 12px; gap: 12px; } .chat-story { width: 64px; font-size: 11.5px; }
  .chat-list-body { padding: 4px 8px calc(104px + var(--safe-b) + var(--dock-h, 0px)); }
  .chat-row { min-height: 66px; padding: 9px 10px; gap: 12px; } .chat-row-name { font-size: 15.5px; } .chat-row-prev { font-size: 13.5px; } .chat-row .tiny { font-size: 12px; }
  .chat-row .avatar:not(.sm) { --s: 48px; } .chat-row .chat-ico { width: 48px; height: 48px; border-radius: 16px; }
  .chat-row .badge { min-width: 22px; height: 22px; border-radius: 11px; font-size: 12px; padding: 0 6px; }
  .chat-mini { width: 40px; height: 40px; margin: -10px -6px -10px 0; background: none; } .chat-mini .icon { width: 19px; height: 19px; }
  .chat-archived-link { min-height: 44px; margin-top: 8px; font-size: 13px; }
  .chat-none { padding: 10px 12px; font-size: 13.5px; }
  .chat .section-title { padding: 16px 12px 6px; }
  /* Respaldo sin JS: con top y bottom fijados y alto auto, la conversación llena EXACTO el marco (debajo del notch en la app instalada). */
  .chat.show-main > .col-main { position: fixed; left: 0; right: 0; top: 0; bottom: 0; height: auto; height: var(--chat-vh, auto); translate: 0 var(--chat-shift, 0px); z-index: 30; animation: chat-slide 340ms var(--ease) both; }   /* translate (no transform): sigue a lo visible con el teclado abierto sin pisar la animación de entrada */
  .chat-head { padding: calc(6px + var(--safe-t)) 6px 6px 4px; gap: 2px; } .chat-head .btn.icon { width: 44px; height: 44px; background: none; } .chat-head-main { gap: 10px; padding: 2px 4px 2px 2px; min-height: 48px; }
  .chat-head h3 { font-size: 16.5px; } .chat-head .chat-ico { width: 38px; height: 38px; border-radius: 13px; } .chat-head .avatar { --s: 38px; }
  .chat-scroll { padding: calc(10px + var(--dock-top-h, 0px)) 12px 14px; -webkit-overflow-scrolling: touch; }   /* aire abajo: el último mensaje no queda pegado a la caja de escribir */   /* en llamada, la pastilla del dock flota arriba: el primer mensaje no queda debajo */
  .chat-intro { padding: 16px 4px 8px; }
  .chat-msg-col { max-width: 82%; } .chat-msg-av { width: 28px; } .chat-msg-av .avatar { --s: 28px; }
  .chat-bubble { font-size: 15.5px; padding: 9px 13px; } .chat-msg-meta { font-size: 11.5px; } .chat-msg-meta b { font-size: 13px; }
  .chat-quote { font-size: 13px; padding: 7px 12px; } .chat-quote span { max-width: 60vw; }
  .chat-media { width: min(300px, 100%); } .chat-file, .chat-link, .chat-audio { width: min(280px, 100%); } .chat-file, .chat-link { min-height: 56px; }
  .chat-audio-btn { width: 44px; height: 44px; } .chat-audio-wave { height: 36px; }
  .chat-react { height: 40px; padding: 0 13px; border-radius: 20px; font-size: 16px; } .chat-react b { font-size: 12.5px; } .chat-reacts { gap: 6px; }
  .chat-retry { min-height: 40px; font-size: 13px; }
  .chat-jump { left: auto; right: 12px; bottom: 10px; height: 44px; min-width: 44px; transform: translateY(18px) scale(.9); } .chat-jump.show { transform: none; }
  .chat-typing { padding: 0 18px; height: 0; transition: height var(--t) var(--ease), opacity var(--t) var(--ease), transform var(--t) var(--ease); } .chat-typing.on { height: 24px; }
  .chat-composer { padding: 6px 8px max(14px, calc(10px + var(--safe-b))); }   /* aire abajo aunque el teléfono no declare barra de gestos (Safari con su barra) */
  html.kb-open .chat-composer { padding-bottom: 8px; }   /* con el teclado abierto no hay barra de inicio que esquivar: la caja se pega al teclado */
  .chat-box:focus-within { box-shadow: 0 0 0 3px var(--primary-soft), var(--shadow); }
  .chat-input { font-size: 16px; padding: 11px 4px; max-height: 132px; } /* 16px: iOS no hace zoom al enfocar */
  .chat-tool, .chat-send, .chat-box .btn.icon, .chat-rec .btn.icon { width: 44px; height: 44px; }
  .chat-box.has-text .chat-tool[aria-label='Emojis'] { display: none; } /* escribiendo: el campo gana ancho (los emojis están en el teclado del teléfono) */
  .chat-ctx { font-size: 13px; } .chat-ctx .btn.icon.sm { width: 40px; height: 40px; }
  .chat-up-x { top: -8px; right: -8px; width: 28px; height: 28px; } .chat-up-x::after { content: ''; position: absolute; inset: -8px; } .chat-tray { padding-top: 10px; }
  .chat-mentions { left: 8px; width: calc(100% - 16px); } .chat-mention-item { min-height: 48px; font-size: 15px; }
  .chat-pick { max-height: 46vh; } .chat-pick-row { min-height: 56px; }
  .chat-viewer-stage { padding: calc(64px + var(--safe-t)) 0 8px; } .chat-viewer-stage img, .chat-viewer-stage video { border-radius: 0; }
  .chat-viewer-btn.x { left: 10px; right: auto; }
  .chat-viewer-btn.prev, .chat-viewer-btn.next { display: none; } /* en el teléfono se pasa deslizando */
  .chat-viewer-cap { justify-content: space-between; } .chat-viewer-cap .truncate { max-width: 40vw; } .chat-viewer-cap .btn { height: 44px; }
  .chat-shared-grid { gap: 4px; padding: 0; } .chat-members .list-row { min-height: 56px; }
}

/* Diagnóstico del teclado (solo con ?diag en la URL): números reales del teléfono, arriba de todo. */
.chat-diag { position: fixed; z-index: 999; left: 8px; right: 8px; top: calc(4px + var(--safe-t)); margin: 0; padding: 8px 10px; border-radius: 12px;
  background: rgba(0, 0, 0, .82); color: #7CFC9B; font: 600 11px/1.35 ui-monospace, Consolas, monospace; white-space: pre; pointer-events: none; }
