/* Equipo Nova — estilo Telegram iOS (vidrio translúcido) */
:root {
  --accent: #0a84ff;
  --accent-press: #0060df;
  --bg: #ffffff;
  --bg-grouped: #f2f2f7;
  --cell: #ffffff;
  --text: #000000;
  --text-2: #8e8e93;
  --sep: rgba(60, 60, 67, .18);
  --glass: rgba(255, 255, 255, .62);
  --glass-strong: rgba(255, 255, 255, .78);
  --glass-border: rgba(255, 255, 255, .7);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, .10), 0 1px 2px rgba(0, 0, 0, .06);
  --field: rgba(118, 118, 128, .12);
  --bubble-in: #ffffff;
  --bubble-out: #e3fbcf;
  --bubble-out-meta: #3fa34d;
  --bubble-in-meta: #8e8e93;
  --link-out: #2a8a3a;
  --danger: #ff3b30;
  --online: #34c759;
  --wall-1: #c5dbb2;
  --wall-2: #9fc79e;
  --wall-3: #e4e6b3;
  --wall-4: #a3cbc6;
  --wall-pattern: rgba(40, 80, 40, .07);
  --system-pill: rgba(60, 90, 60, .32);
  --radius: 18px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --app-h: 100dvh;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #3e9bff;
    --accent-press: #2b7fe0;
    --bg: #000000;
    --bg-grouped: #000000;
    --cell: #1c1c1e;
    --text: #ffffff;
    --text-2: #8d8d93;
    --sep: rgba(84, 84, 88, .55);
    --glass: rgba(28, 28, 30, .58);
    --glass-strong: rgba(28, 28, 30, .78);
    --glass-border: rgba(255, 255, 255, .10);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, .45), 0 1px 2px rgba(0, 0, 0, .3);
    --field: rgba(118, 118, 128, .24);
    --bubble-in: #262628;
    --bubble-out: #2f5f8a;
    --bubble-out-meta: #9cc7ef;
    --bubble-in-meta: #8d8d93;
    --link-out: #cfe6ff;
    --wall-1: #18222d;
    --wall-2: #1d2b3a;
    --wall-3: #142029;
    --wall-4: #213244;
    --wall-pattern: rgba(255, 255, 255, .035);
    --system-pill: rgba(255, 255, 255, .14);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --accent: #3e9bff; --accent-press: #2b7fe0; --bg: #000000; --bg-grouped: #000000; --cell: #1c1c1e;
  --text: #ffffff; --text-2: #8d8d93; --sep: rgba(84, 84, 88, .55);
  --glass: rgba(28, 28, 30, .58); --glass-strong: rgba(28, 28, 30, .78); --glass-border: rgba(255, 255, 255, .10);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, .45), 0 1px 2px rgba(0, 0, 0, .3);
  --field: rgba(118, 118, 128, .24); --bubble-in: #262628; --bubble-out: #2f5f8a; --bubble-out-meta: #9cc7ef;
  --bubble-in-meta: #8d8d93; --link-out: #cfe6ff; --wall-1: #18222d; --wall-2: #1d2b3a; --wall-3: #142029;
  --wall-4: #213244; --wall-pattern: rgba(255, 255, 255, .035); --system-pill: rgba(255, 255, 255, .14);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--bg-grouped);
  color: var(--text);
  font: 17px/1.3 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
svg { display: block; }
[hidden] { display: none !important; }

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  border: .5px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

/* ---------- Arranque ---------- */
#app { height: var(--app-h); position: relative; }
.splash { position: absolute; inset: 0; display: grid; place-items: center; }
.splash img { border-radius: 18px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.94); opacity: .7; } }

/* ---------- Login ---------- */
.auth {
  height: 100%; overflow-y: auto; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(var(--safe-t) + 24px) 16px calc(var(--safe-b) + 24px);
  background:
    radial-gradient(120% 80% at 10% 0%, rgba(10, 132, 255, .22), transparent 60%),
    radial-gradient(100% 70% at 100% 100%, rgba(52, 199, 89, .18), transparent 60%),
    var(--bg-grouped);
}
.auth-card { width: 100%; max-width: 380px; text-align: center; }
.auth-logo { width: 96px; height: 96px; border-radius: 24px; margin: 0 auto 18px; box-shadow: 0 12px 40px rgba(10, 132, 255, .35); }
.auth h1 { font-size: 28px; font-weight: 700; margin: 0 0 6px; letter-spacing: -.02em; }
.auth p.sub { color: var(--text-2); margin: 0 0 28px; font-size: 15px; }
.auth form { display: flex; flex-direction: column; gap: 12px; }
.auth .fields { border-radius: 14px; overflow: hidden; text-align: left; }
.auth .fields input {
  display: block; width: 100%; border: 0; outline: 0; padding: 15px 16px; background: transparent;
}
.auth .fields input + input { border-top: .5px solid var(--sep); }
.auth .error { color: var(--danger); font-size: 14px; min-height: 18px; margin: 0; }
.btn-primary {
  background: var(--accent); color: #fff; font-weight: 600; border-radius: 14px; padding: 15px; width: 100%;
  transition: transform .12s, background .12s;
}
.btn-primary:active { transform: scale(.98); background: var(--accent-press); }
.btn-primary:disabled { opacity: .5; }
.auth .hint { color: var(--text-2); font-size: 13px; margin-top: 20px; }

/* ---------- Estructura principal ---------- */
.shell { height: 100%; display: flex; overflow: hidden; background: var(--bg); }
.pane-list { position: relative; width: 100%; height: 100%; flex: none; background: var(--bg); overflow: hidden; }
.pane-chat {
  position: absolute; inset: 0; z-index: 5; transform: translateX(100%);
  transition: transform .34s cubic-bezier(.32, .72, 0, 1), box-shadow .34s;
}
.shell.chat-open .pane-chat { transform: none; box-shadow: -8px 0 24px rgba(0, 0, 0, .08); }
.shell.chat-open .pane-list { transform: translateX(-28%); transition: transform .34s cubic-bezier(.32, .72, 0, 1); }
.shell:not(.chat-open) .pane-list { transform: none; transition: transform .34s cubic-bezier(.32, .72, 0, 1); }

@media (min-width: 900px) {
  .pane-list { width: 380px; border-right: .5px solid var(--sep); transform: none !important; }
  .pane-chat { position: relative; flex: 1; transform: none !important; box-shadow: none; inset: auto; height: 100%; }
  .chat-empty { display: grid !important; }
  .chat-back { display: none !important; }
}

.view { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding-top: calc(var(--safe-t) + 52px); padding-bottom: calc(var(--safe-b) + 96px); }

/* Barra superior translúcida */
.navbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 4;
  padding: calc(var(--safe-t) + 6px) calc(12px + var(--safe-r)) 6px calc(12px + var(--safe-l));
  display: flex; align-items: center; justify-content: space-between; min-height: calc(var(--safe-t) + 52px);
  transition: background .2s, border-color .2s;
  border-bottom: .5px solid transparent;
}
.navbar.scrolled {
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%);
  border-bottom-color: var(--sep);
}
.navbar .title { position: absolute; left: 50%; transform: translateX(-50%); font-weight: 600; font-size: 17px; opacity: 0; transition: opacity .2s; pointer-events: none; }
.navbar.scrolled .title { opacity: 1; }
.nav-btn {
  height: 38px; min-width: 38px; padding: 0 12px; border-radius: 19px; display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  color: var(--text); font-size: 16px;
}
.nav-btn.glass:active { transform: scale(.94); }
.nav-btn svg { width: 22px; height: 22px; }

.large-title { font-size: 34px; font-weight: 700; letter-spacing: -.025em; margin: 4px 16px 8px; }

.searchbar { margin: 0 16px 8px; position: relative; }
.searchbar input {
  width: 100%; border: 0; outline: 0; background: var(--field); border-radius: 12px; padding: 9px 12px 9px 34px; font-size: 17px;
}
.searchbar svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-2); }

/* Banners de instalación / notificaciones */
.banner {
  margin: 8px 16px; padding: 12px 14px; border-radius: 16px; display: flex; gap: 12px; align-items: center;
  background: var(--field); font-size: 14px; line-height: 1.35;
}
.banner .ico { font-size: 24px; flex: none; }
.banner .txt { flex: 1; }
.banner .txt b { display: block; font-size: 15px; margin-bottom: 2px; }
.banner button.act { background: var(--accent); color: #fff; font-weight: 600; font-size: 14px; padding: 7px 14px; border-radius: 16px; flex: none; }
.banner button.x { color: var(--text-2); font-size: 20px; padding: 0 4px; flex: none; }

/* Lista de chats */
.list { margin: 0; padding: 0; list-style: none; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 0 0 0 calc(14px + var(--safe-l)); cursor: pointer; position: relative;
  min-height: 76px; user-select: none;
}
.row:active, .row.active { background: var(--field); }
@media (min-width: 900px) { .row.active { background: var(--accent); color: #fff; } .row.active .sub, .row.active .time { color: rgba(255,255,255,.85) !important; } .row.active .badge { background: #fff; color: var(--accent); } }
.row .body { flex: 1; min-width: 0; align-self: stretch; display: flex; flex-direction: column; justify-content: center; padding: 8px calc(14px + var(--safe-r)) 8px 0; border-bottom: .5px solid var(--sep); }
.row:last-child .body { border-bottom: 0; }
.row .top { display: flex; align-items: baseline; gap: 8px; }
.row .name { font-weight: 600; font-size: 17px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .time { font-size: 14px; color: var(--text-2); flex: none; display: flex; align-items: center; gap: 3px; }
.row .time svg { width: 16px; height: 12px; color: var(--accent); }
.row .bottom { display: flex; align-items: flex-start; gap: 8px; margin-top: 2px; }
.row .sub { flex: 1; min-width: 0; color: var(--text-2); font-size: 15px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.row .sub .who { color: var(--text); }
.row.compact { min-height: 58px; }
.row.compact .body { padding-top: 6px; padding-bottom: 6px; }
.badge { background: var(--accent); color: #fff; font-size: 14px; font-weight: 600; min-width: 22px; height: 22px; border-radius: 11px; padding: 0 7px; display: grid; place-items: center; flex: none; margin-top: 2px; }

.avatar {
  flex: none; width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 20px;
  position: relative; letter-spacing: .02em;
}
.avatar.sm { width: 40px; height: 40px; font-size: 15px; }
.avatar.xs { width: 32px; height: 32px; font-size: 13px; }
.avatar.lg { width: 96px; height: 96px; font-size: 36px; }
.avatar .dot { position: absolute; right: 1px; bottom: 1px; width: 14px; height: 14px; border-radius: 50%; background: var(--online); border: 2.5px solid var(--bg); }
.avatar.sm .dot { width: 11px; height: 11px; border-width: 2px; right: 0; bottom: 0; }
.avatar svg { width: 55%; height: 55%; }

.empty-state { text-align: center; color: var(--text-2); padding: 48px 32px; font-size: 15px; }

/* Barra de pestañas flotante */
.tabbar {
  position: absolute; z-index: 6; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-b) + 10px);
  display: flex; gap: 2px; padding: 4px; border-radius: 30px;
}
.tabbar button {
  display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 10.5px; font-weight: 500; color: var(--text);
  width: 84px; padding: 6px 0 5px; border-radius: 26px; transition: background .2s, color .2s; position: relative;
}
.tabbar button svg { width: 26px; height: 26px; }
.tabbar button.on { color: var(--accent); background: var(--field); }
.tabbar .tbadge { position: absolute; top: 2px; left: 50%; margin-left: 6px; background: var(--danger); color: #fff; font-size: 12px; font-weight: 600; min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px; display: grid; place-items: center; }

/* ---------- Chat ---------- */
.chat { position: absolute; inset: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--wall-1); }
.wallpaper {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(60% 50% at 15% 20%, var(--wall-3), transparent 70%),
    radial-gradient(50% 45% at 85% 30%, var(--wall-4), transparent 70%),
    radial-gradient(60% 55% at 30% 85%, var(--wall-2), transparent 70%),
    radial-gradient(55% 50% at 90% 90%, var(--wall-3), transparent 70%),
    var(--wall-1);
}
.wallpaper::after {
  content: ""; position: absolute; inset: 0; opacity: 1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cg fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 30l14-6-4 14-4-4z'/%3E%3Ccircle cx='110' cy='24' r='7'/%3E%3Cpath d='M70 70c6-8 14-8 20 0'/%3E%3Cpath d='M128 96l8 8m0-8l-8 8'/%3E%3Crect x='22' y='100' width='16' height='12' rx='3'/%3E%3Cpath d='M80 128l6 10 6-10z'/%3E%3Cpath d='M140 150c4-4 10-4 14 0'/%3E%3Ccircle cx='60' cy='150' r='3'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 160px 160px;
  -webkit-mask-image: linear-gradient(#000, #000); mask-image: linear-gradient(#000, #000);
  filter: opacity(var(--pat, 1));
  mix-blend-mode: normal;
}
:root .wallpaper::after { opacity: .07; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .wallpaper::after { opacity: .05; filter: invert(1); } }
:root[data-theme="dark"] .wallpaper::after { opacity: .05; filter: invert(1); }

.chat-empty { display: none; position: absolute; inset: 0; place-items: center; z-index: 1; }
.chat-empty span { background: var(--system-pill); color: #fff; font-size: 14px; padding: 6px 14px; border-radius: 14px; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }

.chat-header {
  position: absolute; top: 0; left: 0; right: 0; z-index: 4;
  padding: calc(var(--safe-t) + 6px) calc(10px + var(--safe-r)) 8px calc(10px + var(--safe-l));
  display: flex; align-items: center; gap: 8px;
}
.chat-header .center {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 4px 16px; border-radius: 22px; margin: 0 auto; max-width: 70%; cursor: pointer;
}
.chat-header .center .t { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.chat-header .center .s { font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.chat-header .center .s.online { color: var(--accent); }
.chat-header .avatar { cursor: pointer; }
.chat-back { height: 44px; min-width: 44px; padding: 0 10px 0 6px; border-radius: 22px; display: flex; align-items: center; gap: 2px; font-size: 16px; }
.chat-back svg { width: 24px; height: 24px; }
.chat-back .cnt { background: var(--field); border-radius: 10px; padding: 0 7px; font-size: 14px; font-weight: 600; min-width: 20px; height: 20px; display: grid; place-items: center; }

.chat-scroll {
  position: relative; z-index: 1; flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch;
  padding: calc(var(--safe-t) + 66px) calc(8px + var(--safe-r)) 8px calc(8px + var(--safe-l));
  display: flex; flex-direction: column;
}
.chat-scroll .spacer { flex: 1; }
.load-more { align-self: center; margin: 8px 0; font-size: 13px; color: #fff; background: var(--system-pill); padding: 5px 12px; border-radius: 12px; }

.day-sep { align-self: center; position: sticky; top: calc(var(--safe-t) + 62px); z-index: 2; margin: 10px 0 6px; }
.day-sep span, .sys-msg span {
  display: inline-block; background: var(--system-pill); color: #fff; font-size: 13.5px; font-weight: 500; padding: 4px 11px; border-radius: 14px;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.sys-msg { align-self: center; margin: 6px 24px; text-align: center; max-width: 85%; }

.msg { display: flex; align-items: flex-end; gap: 6px; margin-top: 2px; max-width: 100%; }
.msg.out { justify-content: flex-end; }
.msg.run-start { margin-top: 8px; }
.msg .av-slot { width: 34px; flex: none; }
.msg .av-slot .avatar { width: 34px; height: 34px; font-size: 13px; }

.bubble {
  position: relative; max-width: min(78%, 520px); padding: 6px 10px 7px 11px; border-radius: var(--radius);
  background: var(--bubble-in); font-size: 16.5px; line-height: 1.34; word-wrap: break-word; overflow-wrap: anywhere;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .08);
  animation: pop .22s cubic-bezier(.2, .9, .3, 1.2) both;
}
.msg.no-anim .bubble { animation: none; }
@keyframes pop { from { transform: scale(.92) translateY(6px); opacity: 0; } }
.msg.out .bubble { background: var(--bubble-out); }
.msg.in:not(.run-start) .bubble { border-top-left-radius: 6px; }
.msg.out:not(.run-start) .bubble { border-top-right-radius: 6px; }
.msg.in:not(.run-end) .bubble { border-bottom-left-radius: 6px; }
.msg.out:not(.run-end) .bubble { border-bottom-right-radius: 6px; }
.msg.in.run-end .bubble:not(.media) { border-bottom-left-radius: 0; }
.msg.out.run-end .bubble:not(.media) { border-bottom-right-radius: 0; }
/* Colita del último globo de cada tanda */
.msg.run-end .bubble::after {
  content: ""; position: absolute; bottom: 0; width: 11px; height: 17px; background: inherit;
}
.msg.out.run-end .bubble::after {
  right: -10px;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='17'%3E%3Cpath d='M0 0C0 9 4 14.5 11 17H0z'/%3E%3C/svg%3E") no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='17'%3E%3Cpath d='M0 0C0 9 4 14.5 11 17H0z'/%3E%3C/svg%3E") no-repeat;
}
.msg.in.run-end .bubble::after {
  left: -10px;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='17'%3E%3Cpath d='M11 0C11 9 7 14.5 0 17H11z'/%3E%3C/svg%3E") no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='17'%3E%3Cpath d='M11 0C11 9 7 14.5 0 17H11z'/%3E%3C/svg%3E") no-repeat;
}

.bubble .sender { font-size: 14px; font-weight: 600; margin-bottom: 1px; }
.bubble .text { white-space: pre-wrap; }
.bubble .text a { color: var(--accent); word-break: break-all; }
.msg.out .bubble .text a { color: var(--link-out); }
.bubble .meta {
  float: right; margin: 6px 0 -4px 10px; font-size: 12px; color: var(--bubble-in-meta); display: inline-flex; align-items: center; gap: 3px;
  position: relative; top: 3px; white-space: nowrap; user-select: none;
}
.msg.out .bubble .meta { color: var(--bubble-out-meta); }
.bubble .meta svg { width: 17px; height: 11px; }
.bubble .meta .clock { width: 12px; height: 12px; }
.bubble.hl { animation: hl 1.6s ease; }
@keyframes hl { 0%, 40% { box-shadow: 0 0 0 3px var(--accent); } }

/* Fotos */
.bubble.media { padding: 3px; overflow: hidden; }
.bubble.media.run-end-fix::after { display: none; }
.msg.run-end .bubble.media::after { display: none; }
.bubble.media img { display: block; width: 100%; height: auto; border-radius: calc(var(--radius) - 3px); background: rgba(127, 127, 127, .15); cursor: zoom-in; object-fit: cover; }
.bubble.media .meta.on-img {
  position: absolute; right: 9px; bottom: 9px; float: none; margin: 0; top: auto; color: #fff; background: rgba(0, 0, 0, .42);
  padding: 2px 7px; border-radius: 10px; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.bubble.media .caption { padding: 5px 8px 3px; }
.bubble.media .sender { padding: 3px 8px 2px; }

/* Archivos */
.file-card { display: flex; align-items: center; gap: 11px; min-width: 210px; padding: 3px 0 1px; text-decoration: none; color: inherit; cursor: pointer; }
.file-ico {
  flex: none; width: 48px; height: 48px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center;
  font-size: 11px; font-weight: 800; letter-spacing: .03em; position: relative;
}
.file-ico.pdf { background: #e5483f; }
.file-ico.doc { background: #2f6fe0; }
.file-ico.xls { background: #1f9d55; }
.file-ico.zip { background: #8e8e93; }
.msg.out .file-ico { box-shadow: 0 0 0 2px rgba(255,255,255,.2); }
.file-info { min-width: 0; flex: 1; }
.file-name { font-weight: 600; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.file-size { font-size: 13px; color: var(--bubble-in-meta); margin-top: 2px; }
.msg.out .file-size { color: var(--bubble-out-meta); }

/* Subida en progreso */
.progress-ring { position: absolute; inset: -3px; }
.progress-ring circle { fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; transform: rotate(-90deg); transform-origin: center; transition: stroke-dashoffset .2s; }
.msg.pending .bubble { opacity: .9; }
.msg.failed .bubble { box-shadow: 0 0 0 1.5px var(--danger); }
.retry { color: var(--danger); font-size: 13px; margin: 2px 6px; align-self: center; font-weight: 600; }

/* Botón bajar */
.to-bottom {
  position: absolute; z-index: 3; right: calc(14px + var(--safe-r)); bottom: 84px; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; transition: opacity .2s, transform .2s;
}
.to-bottom.hide { opacity: 0; transform: scale(.7); pointer-events: none; }
.to-bottom svg { width: 24px; height: 24px; color: var(--text-2); }
.to-bottom .badge { position: absolute; top: -8px; left: 50%; transform: translateX(-50%); margin: 0; }

/* Barra de escritura */
.composer-wrap { position: relative; z-index: 3; padding: 6px calc(8px + var(--safe-r)) calc(var(--safe-b) + 8px) calc(8px + var(--safe-l)); }
html.kb .composer-wrap { padding-bottom: 8px; }
.tray { display: flex; gap: 8px; overflow-x: auto; padding: 8px; margin-bottom: 6px; border-radius: 20px; }
.tray .item { position: relative; flex: none; width: 76px; height: 76px; border-radius: 12px; overflow: hidden; background: var(--field); display: grid; place-items: center; text-align: center; font-size: 11px; padding: 4px; }
.tray .item img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tray .item .ext { font-weight: 800; font-size: 13px; color: var(--accent); }
.tray .item .nm { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-all; color: var(--text-2); }
.tray .item .rm { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font-size: 15px; line-height: 22px; z-index: 1; }
.composer { display: flex; align-items: flex-end; gap: 8px; }
.composer .round {
  flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--text-2);
  transition: transform .12s;
}
.composer .round:active { transform: scale(.9); }
.composer .round svg { width: 26px; height: 26px; }
.composer .field { flex: 1; min-width: 0; border-radius: 22px; display: flex; align-items: flex-end; padding: 0 6px 0 16px; min-height: 44px; }
.composer textarea {
  flex: 1; resize: none; border: 0; outline: 0; background: transparent; padding: 11px 0; max-height: 160px; font-size: 17px; line-height: 22px; height: 44px;
}
.composer textarea::placeholder { color: var(--text-2); }
.composer .send { background: var(--accent); color: #fff; transform: scale(0); width: 0; margin-left: -8px; transition: transform .2s cubic-bezier(.2,.9,.3,1.3), width .2s, margin .2s; }
.composer.can-send .send { transform: scale(1); width: 44px; margin-left: 0; }
.composer .send svg { width: 22px; height: 22px; }
.drop-hint { position: absolute; inset: 12px; z-index: 9; border: 2.5px dashed var(--accent); border-radius: 24px; display: grid; place-items: center; font-weight: 600; color: var(--accent); background: var(--glass-strong); }

/* ---------- Ajustes / listas agrupadas ---------- */
.grouped { background: var(--bg-grouped); }
.section-h { font-size: 13px; color: var(--text-2); text-transform: uppercase; letter-spacing: .02em; margin: 24px calc(32px + var(--safe-l)) 7px; }
.section-f { font-size: 13px; color: var(--text-2); margin: 7px calc(32px + var(--safe-l)) 0; line-height: 1.4; }
.group { background: var(--cell); border-radius: 22px; margin: 0 calc(16px + var(--safe-r)) 0 calc(16px + var(--safe-l)); overflow: hidden; }
.cell { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 0 0 16px; width: 100%; text-align: left; position: relative; }
.cell:active { background: var(--field); }
.cell .ci { flex: none; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff; }
.cell .ci svg { width: 19px; height: 19px; }
.cell .cb { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; align-self: stretch; padding-right: 16px; border-bottom: .5px solid var(--sep); }
.cell:last-child .cb { border-bottom: 0; }
.cell .cl { flex: 1; min-width: 0; padding: 12px 0; }
.cell .cl small { display: block; color: var(--text-2); font-size: 14px; margin-top: 1px; }
.cell .cv { color: var(--text-2); font-size: 16px; }
.cell .chev { width: 8px; color: var(--text-2); opacity: .6; }
.cell.danger { color: var(--danger); }
.cell input.cinput { flex: 1; border: 0; outline: 0; background: transparent; padding: 14px 16px 14px 0; min-width: 0; }
.profile { text-align: center; padding: 8px 16px 4px; }
.profile .avatar { margin: 0 auto 12px; }
.profile h2 { margin: 0; font-size: 24px; font-weight: 600; }
.profile p { margin: 4px 0 0; color: var(--text-2); font-size: 15px; }

.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--field); border-radius: 16px; transition: background .2s; }
.switch span::before { content: ""; position: absolute; left: 2px; top: 2px; width: 27px; height: 27px; background: #fff; border-radius: 50%; box-shadow: 0 2px 6px rgba(0,0,0,.2); transition: transform .25s cubic-bezier(.3,1.4,.6,1); }
.switch input:checked + span { background: var(--online); }
.switch input:checked + span::before { transform: translateX(20px); }

/* ---------- Hojas modales ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .35); animation: fade .25s both; }
.sheet {
  position: fixed; z-index: 51; left: 0; right: 0; bottom: 0; max-height: calc(var(--app-h) - var(--safe-t) - 12px);
  background: var(--bg-grouped); border-radius: 26px 26px 0 0; display: flex; flex-direction: column; overflow: hidden;
  animation: up .38s cubic-bezier(.32, .72, 0, 1) both; padding-bottom: var(--safe-b);
}
@media (min-width: 700px) {
  .sheet { left: 50%; bottom: auto; top: 50%; width: 460px; max-height: 80vh; border-radius: 26px; transform: translate(-50%, -50%); animation: fade .2s both; }
}
.sheet.closing { animation: down .25s ease both; }
.sheet-backdrop.closing { animation: fade .25s reverse both; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes down { to { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 8px; gap: 8px; }
.sheet-head h3 { margin: 0; font-size: 17px; font-weight: 600; flex: 1; text-align: center; }
.sheet-head .nav-btn { min-width: 70px; }
.sheet-head .nav-btn.primary { color: var(--accent); font-weight: 600; }
.sheet-head .nav-btn:disabled { opacity: .4; }
.sheet-body { overflow-y: auto; padding-bottom: 20px; }
.check { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--text-2); flex: none; display: grid; place-items: center; margin-right: 4px; }
.check.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.check svg { width: 14px; height: 14px; }
.pw-box { margin: 12px 16px; padding: 16px; background: var(--cell); border-radius: 18px; text-align: center; }
.pw-box code { display: block; font: 600 26px/1.3 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .08em; margin: 8px 0 12px; user-select: all; }

/* Visor de fotos */
.viewer { position: fixed; inset: 0; z-index: 60; background: #000; display: flex; flex-direction: column; animation: fade .2s both; touch-action: pinch-zoom; }
.viewer .vbar { position: absolute; left: 0; right: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: calc(var(--safe-t) + 8px) 12px 8px; color: #fff; background: linear-gradient(rgba(0,0,0,.5), transparent); }
.viewer .vbar.bottom { bottom: 0; top: auto; padding: 8px 12px calc(var(--safe-b) + 10px); background: linear-gradient(transparent, rgba(0,0,0,.5)); }
.viewer .vbar .nav-btn { color: #fff; background: rgba(255,255,255,.16); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.viewer .vinfo { text-align: center; font-size: 14px; }
.viewer .vinfo small { display: block; opacity: .7; font-size: 12px; }
.viewer img { flex: 1; min-height: 0; width: 100%; object-fit: contain; }
.viewer .vcap { color: #fff; text-align: center; font-size: 15px; padding: 0 20px; white-space: pre-wrap; }

/* Aviso flotante */
.toast {
  position: fixed; z-index: 70; left: 50%; top: calc(var(--safe-t) + 12px); transform: translateX(-50%);
  padding: 10px 18px; border-radius: 20px; font-size: 15px; font-weight: 500; animation: tdrop .35s cubic-bezier(.3,1.3,.6,1) both;
  max-width: calc(100% - 32px); text-align: center;
}
@keyframes tdrop { from { transform: translate(-50%, -30px); opacity: 0; } }

/* Instrucciones de instalación */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.steps li { counter-increment: s; display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-bottom: .5px solid var(--sep); font-size: 15px; line-height: 1.4; }
.steps li:last-child { border-bottom: 0; }
.steps li::before { content: counter(s); flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; font-size: 14px; display: grid; place-items: center; }
.steps svg.inline { display: inline-block; width: 18px; height: 18px; vertical-align: -3px; color: var(--accent); }

.search-hit .sub mark { background: rgba(255, 204, 0, .45); color: inherit; border-radius: 3px; }
