/* ============================================================
   PHANTOM MSG — UX IMPROVEMENTS v2.3
   9 mejoras: search, FAB, swipe, online dot, compact header,
   tab badges, read receipts preview, empty states, long-press
   ============================================================ */

/* ============================================================
   1. SIDEBAR SEARCH BAR
   ============================================================ */
.sidebar-search {
    padding: 10px 16px 6px;
    position: relative;
}
.sidebar-search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1.5px solid var(--border);
    border-radius: 20px;
    transition: var(--transition);
}
.sidebar-search-wrap:focus-within {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100);
}
.sidebar-search-wrap svg {
    flex-shrink: 0;
    color: var(--text-dim);
    width: 16px;
    height: 16px;
}
.sidebar-search-wrap:focus-within svg {
    color: var(--primary-400);
}
.sidebar-search-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-display), var(--font-emoji);
    font-size: 13px;
}
.sidebar-search-input::placeholder {
    color: var(--text-dim);
}
.sidebar-search-clear {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 2px;
    font-size: 16px;
    line-height: 1;
    display: none;
    border-radius: 50%;
    transition: var(--transition);
}
.sidebar-search-clear:hover {
    color: var(--text-primary);
    background: var(--overlay-light);
}
.sidebar-search-clear.show {
    display: block;
}

/* ============================================================
   2. FAB (Floating Action Button)
   ============================================================ */
/* ============================================================
   FAB GOO — Organic blob-morphing floating action button
   Uses SVG filter #goo-filter-fab for viscous merge effect
   ============================================================ */

/* Wrapper: cubre toda el area del sidebar para posicionar */
.fab-goo-wrapper {
    position: absolute;
    bottom: 0;
    right: 0;
    z-index: 9100;
    pointer-events: none;
}

/* Backdrop: oscurece fondo al abrir */
.fab-goo-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 9099;
    pointer-events: none;
    transition: background 0.35s ease;
}
.fab-goo-wrapper.open .fab-goo-backdrop {
    background: rgba(0, 0, 0, 0.4);
    pointer-events: auto;
}

/* Container: posiciona menu y FAB sin filtro SVG agresivo */
/* El filtro goo (stdDeviation=10) causa blur ilegible en texto en mobile */
/* Las animaciones fabGooItemOpen/Close ya dan el efecto visual orgánico */
.fab-goo-container {
    position: absolute;
    bottom: 14px;
    right: 16px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: auto;
}

/* Boton FAB principal */
.sidebar-fab {
    position: relative;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-600), var(--primary-500));
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9102;
    box-shadow: 0 4px 20px var(--primary-glow), 0 2px 8px rgba(0,0,0,0.3);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.3s ease,
                border-radius 0.4s ease;
    flex-shrink: 0;
}
.sidebar-fab:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 8px 28px var(--primary-glow), 0 4px 12px rgba(0,0,0,0.4);
}
.sidebar-fab:active {
    transform: scale(0.92);
}
.sidebar-fab svg {
    width: 22px;
    height: 22px;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* FAB expandido: el boton se agranda y el icono gira */
.fab-goo-wrapper.open .sidebar-fab {
    transform: scale(1.05);
    border-radius: 50%;
    animation: fabGooBreath 2s ease-in-out infinite 0.5s;
}
.fab-goo-wrapper.open .sidebar-fab svg {
    transform: rotate(45deg);
}

@keyframes fabGooBreath {
    0%, 100% { border-radius: 50%; transform: scale(1.05); }
    25% { border-radius: 47% 53% 50% 50%; transform: scale(1.07); }
    50% { border-radius: 50% 46% 54% 50%; transform: scale(1.03); }
    75% { border-radius: 52% 50% 48% 52%; transform: scale(1.06); }
}

/* Menu container */
.fab-menu {
    display: flex;
    flex-direction: column;
    gap: 0px;
    z-index: 9101;
    pointer-events: none;
    margin-bottom: 8px;
    align-items: flex-end;
}
.fab-goo-wrapper.open .fab-menu {
    pointer-events: auto;
}

/* Menu items: estilo base */
.fab-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: var(--primary-600);
    border: none;
    border-radius: 26px;
    color: #fff;
    cursor: pointer;
    font-family: var(--font-display), var(--font-emoji);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.3px;
    white-space: nowrap;
    transition: background 0.2s ease, transform 0.2s ease;
    opacity: 0;
    transform: translateY(40px) scale(0.3);
    pointer-events: none;
}
.fab-item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}
.fab-item-icon svg {
    width: 16px;
    height: 16px;
}
.fab-item-label {
    line-height: 1;
}
.fab-menu-item:hover {
    background: var(--primary-500);
    transform: scale(1.04) translateX(-4px) !important;
}
.fab-menu-item:active {
    transform: scale(0.96) !important;
}

/* Animacion de apertura: blob emerge del FAB */
@keyframes fabGooItemOpen {
    0% {
        opacity: 0;
        transform: translateY(40px) scale(0.2);
        border-radius: 50%;
    }
    35% {
        opacity: 1;
        transform: translateY(-8px) scale(1.12);
        border-radius: 50%;
    }
    55% {
        transform: translateY(4px) scale(0.95);
        border-radius: 30px;
    }
    70% {
        transform: translateY(-2px) scale(1.04);
        border-radius: 28px;
    }
    85% {
        transform: translateY(1px) scale(0.98);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        border-radius: 26px;
    }
}

/* Animacion de cierre: blob se derrite hacia el FAB */
@keyframes fabGooItemClose {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
        border-radius: 26px;
    }
    25% {
        transform: translateY(-6px) scale(1.06);
        border-radius: 30px;
    }
    50% {
        opacity: 0.8;
        transform: translateY(15px) scale(0.7);
        border-radius: 40%;
    }
    100% {
        opacity: 0;
        transform: translateY(50px) scale(0.1);
        border-radius: 50%;
        pointer-events: none;
    }
}

/* Item open: staggered delays crean efecto cascada organica */
.fab-goo-wrapper.open .fab-menu-item {
    pointer-events: auto;
    animation-fill-mode: forwards;
}
.fab-goo-wrapper.open .fab-menu-item:nth-child(3) {
    animation: fabGooItemOpen 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) 0.04s forwards;
}
.fab-goo-wrapper.open .fab-menu-item:nth-child(2) {
    animation: fabGooItemOpen 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) 0.10s forwards;
}
.fab-goo-wrapper.open .fab-menu-item:nth-child(1) {
    animation: fabGooItemOpen 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) 0.16s forwards;
}

/* Item close: staggered en reversa */
.fab-goo-wrapper.closing .fab-menu-item:nth-child(1) {
    animation: fabGooItemClose 0.35s cubic-bezier(0.55, 0.085, 0.68, 0.53) 0.00s forwards;
}
.fab-goo-wrapper.closing .fab-menu-item:nth-child(2) {
    animation: fabGooItemClose 0.35s cubic-bezier(0.55, 0.085, 0.68, 0.53) 0.05s forwards;
}
.fab-goo-wrapper.closing .fab-menu-item:nth-child(3) {
    animation: fabGooItemClose 0.35s cubic-bezier(0.55, 0.085, 0.68, 0.53) 0.10s forwards;
}

/* Animacion de pulso goo cuando el FAB entra al viewport */
@keyframes fabGooReveal {
    0% { transform: scale(0); border-radius: 50%; }
    50% { transform: scale(1.2); border-radius: 45%; }
    70% { transform: scale(0.9); border-radius: 52%; }
    85% { transform: scale(1.05); border-radius: 48%; }
    100% { transform: scale(1); border-radius: 50%; }
}

/* Ripple organico en el FAB al abrir */
.fab-goo-wrapper.open .sidebar-fab::after {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    background: var(--primary-600);
    opacity: 0;
    animation: fabGooRipple 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    z-index: -1;
}
@keyframes fabGooRipple {
    0% { transform: scale(0.8); opacity: 0.5; }
    50% { transform: scale(1.3); opacity: 0.15; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* ============================================================
   3. SWIPE ACTIONS
   ============================================================ */
.chat-item-swipe-wrap {
    position: relative;
    overflow: hidden;
}
.chat-item-swipe-actions-left,
.chat-item-swipe-actions-right {
    position: absolute;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    z-index: 1;
}
.chat-item-swipe-actions-left {
    left: 0;
    padding-left: 8px;
    background: linear-gradient(90deg, var(--primary-500) 0%, var(--primary-500) 80%, transparent 100%);
}
.chat-item-swipe-actions-right {
    right: 0;
    padding-right: 8px;
    background: linear-gradient(270deg, rgba(248,113,113,0.95) 0%, rgba(248,113,113,0.8) 80%, transparent 100%);
}
.swipe-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 12px;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-family: var(--font-display), var(--font-emoji);
    font-size: 10px;
    font-weight: 600;
}
.swipe-action-btn svg {
    width: 18px;
    height: 18px;
}
.chat-item-swipeable {
    position: relative;
    z-index: 2;
    background: var(--bg-card);
    transition: transform 0.2s ease;
}

/* ============================================================
   4. ONLINE INDICATOR DOT
   ============================================================ */
.chat-item-avatar {
    position: relative;
}
.online-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2.5px solid var(--bg-card);
    background: var(--success);
    z-index: 3;
    display: none;
}
.online-dot.show {
    display: block;
    animation: onlineDotPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes onlineDotPop {
    from { transform: scale(0); }
    to { transform: scale(1); }
}
.offline-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2.5px solid var(--bg-card);
    background: var(--text-dim);
    z-index: 3;
    display: none;
}

/* ============================================================
   5. COMPACT HEADER (Identity section)
   ============================================================ */
.identity-logged {
    position: relative;
}
.identity-compact-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}
.identity-action-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--overlay-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
    flex-shrink: 0;
}
.identity-action-icon:hover {
    color: var(--primary-400);
    border-color: var(--primary-500);
    background: var(--primary-100);
}
.identity-action-icon.danger:hover {
    color: var(--danger);
    border-color: var(--danger);
    background: rgba(248,113,113,0.08);
}
.identity-action-icon svg {
    width: 15px;
    height: 15px;
}
.identity-action-icon .icon-tooltip {
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 8px;
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 10px;
    color: var(--text-secondary);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
}
.identity-action-icon:hover .icon-tooltip {
    opacity: 1;
}

/* ============================================================
   6. TAB BADGES
   ============================================================ */
.sidebar-tab {
    position: relative;
}
.tab-badge {
    display: none;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 700;
    font-family: var(--font-display), var(--font-emoji);
    margin-left: 4px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    animation: badgePop 0.3s ease-out;
    vertical-align: middle;
}
.tab-badge.show {
    display: inline-flex;
}
.tab-badge-chats {
    background: var(--primary-500);
    color: var(--bg-body);
}
.tab-badge-contacts {
    background: var(--success);
    color: var(--bg-body);
}
.tab-badge-requests {
    background: var(--accent);
    color: var(--bg-body);
}

/* ============================================================
   7. READ RECEIPTS IN CHAT PREVIEW
   ============================================================ */
.chat-item-checks {
    display: inline-flex;
    align-items: center;
    margin-right: 4px;
    font-size: 12px;
    letter-spacing: -2px;
    line-height: 1;
    vertical-align: middle;
}
.chat-item-checks.sent {
    color: var(--text-dim);
}
.chat-item-checks.delivered {
    color: var(--text-muted);
}
.chat-item-checks.read {
    color: var(--primary-400);
}

/* ============================================================
   8. ENHANCED EMPTY STATES
   ============================================================ */
.sidebar-empty-enhanced {
    padding: 36px 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.sidebar-empty-illustration {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}
.sidebar-empty-illustration.chats-empty {
    background: linear-gradient(135deg, var(--primary-100), var(--primary-100));
    color: var(--primary-400);
}
.sidebar-empty-illustration.contacts-empty {
    background: linear-gradient(135deg, var(--primary-100), var(--primary-100));
    color: var(--success);
}
.sidebar-empty-illustration.requests-empty {
    background: linear-gradient(135deg, var(--accent-100), var(--accent-100));
    color: var(--accent);
}
.sidebar-empty-illustration svg {
    width: 28px;
    height: 28px;
}
.sidebar-empty-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}
.sidebar-empty-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.6;
    max-width: 240px;
}
.sidebar-empty-cta {
    margin-top: 6px;
}
.sidebar-empty-cta .btn {
    font-size: 12px;
    padding: 8px 18px;
}

/* ============================================================
   9. LONG-PRESS / CONTEXT MENU FOR CHAT ITEMS
   ============================================================ */
.chat-ctx-menu {
    position: fixed;
    z-index: 10002;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 0;
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    animation: ctxMenuIn 0.15s ease-out;
}
.chat-ctx-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font-display), var(--font-emoji);
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s ease;
    text-align: left;
}
.chat-ctx-item:hover {
    background: var(--overlay-light);
    color: var(--text-primary);
}
.chat-ctx-item svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: 0.6;
}
.chat-ctx-item:hover svg {
    opacity: 1;
}
.chat-ctx-item.ctx-danger {
    color: var(--danger) !important;
}
.chat-ctx-item.ctx-danger:hover {
    background: rgba(248,113,113,0.08) !important;
}
.chat-ctx-sep {
    height: 1px;
    background: var(--border);
    margin: 4px 12px;
}

/* Section labels in sidebar list */
.sidebar-section-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-dim);
    padding: 10px 20px 4px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* Pinned chat indicator */
.chat-item-pinned {
    color: var(--primary-400);
    font-size: 12px;
    margin-left: 4px;
}

/* Muted chat style */
.chat-item.muted .chat-item-name {
    color: var(--text-muted);
}
.chat-item.muted .chat-item-preview {
    color: var(--text-dim);
}
.chat-item-mute-icon {
    color: var(--text-dim);
    font-size: 12px;
    margin-left: 4px;
}

/* ============================================================
   RESPONSIVE: Mobile adjustments
   ============================================================ */
@media (max-width: 768px) {
    .fab-goo-container {
        bottom: 68px;
        bottom: calc(68px + env(safe-area-inset-bottom, 0px));
        right: 12px;
    }
    .sidebar-fab {
        width: 54px;
        height: 54px;
    }
    .fab-menu-item {
        padding: 10px 16px;
        font-size: 12px;
    }
    .sidebar-search {
        padding: 8px 12px 4px;
    }
    .sidebar-search-wrap {
        padding: 10px 14px;
    }
    .sidebar-search-input {
        font-size: 16px; /* Prevents iOS zoom */
    }
    .chat-ctx-menu {
        min-width: 200px;
    }
}

/* ============================================================
   CHAT MIC/SEND SWAP — WhatsApp style
   ============================================================ */
.chat-mic-btn,
.chat-send-btn {
    transition: opacity 0.15s ease, transform 0.15s ease;
}
.chat-send-btn {
    animation: sendBtnPop 0.2s ease-out;
}
@keyframes sendBtnPop {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* ============================================================
   SETTINGS PANEL
   ============================================================ */
.settings-panel {
    height: 100%;
    display: flex;
    flex-direction: column;
}
.settings-header h2 {
    padding: 0;
    margin: 0;
}
.settings-header {
    display: flex;
    align-items: center;
    gap: 8px;
}
.settings-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: var(--overlay-light);
    color: var(--text-primary);
    border-radius: 10px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}
.settings-back-btn:hover {
    background: var(--overlay-medium);
}
.settings-back-btn:active {
    transform: scale(0.95);
}
.settings-content {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 24px;
}
.st-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    padding: 14px 8px 6px;
}
.st-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 8px;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    color: var(--text-primary);
    font-family: var(--font-display), var(--font-emoji);
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}
.st-row:hover {
    background: var(--overlay-subtle);
}
.st-row:active {
    background: var(--overlay-light);
}
.st-row-danger:hover {
    background: rgba(226,75,74,0.06);
}
.st-row-disabled {
    opacity: 0.4;
    pointer-events: none;
}
.st-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.st-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.st-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.st-hint {
    font-size: 10px;
    color: var(--text-dim);
}
.st-arrow {
    color: var(--text-dim);
    font-size: 18px;
    flex-shrink: 0;
}
.st-sep-line {
    height: 1px;
    background: var(--border);
    margin: 6px 8px;
}
.st-version {
    text-align: center;
    padding: 20px 0 8px;
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: 0.06em;
}

/* Sub-panel */
.st-back {
    display: block;
    background: none;
    border: none;
    color: var(--primary-400);
    font-family: var(--font-display), var(--font-emoji);
    font-size: 13px;
    font-weight: 600;
    padding: 12px 8px;
    cursor: pointer;
    width: 100%;
    text-align: left;
}
.st-back:hover {
    color: var(--primary-300);
}

/* Toggle row */
.st-toggle-row {
    cursor: default;
}
.st-toggle-row .phantom-toggle {
    flex-shrink: 0;
}

/* Input row */
.st-input-row {
    flex-wrap: wrap;
}
.st-input-field {
    width: 140px;
    padding: 6px 10px;
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font-display), var(--font-emoji);
    font-size: 12px;
    flex-shrink: 0;
}
.st-input-field:focus {
    outline: none;
    border-color: var(--primary-400);
}

/* Action buttons */
.st-action-btn {
    width: 100%;
    padding: 10px 16px;
    background: var(--primary-600);
    color: var(--bg-body);
    border: none;
    border-radius: 8px;
    font-family: var(--font-display), var(--font-emoji);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}
.st-action-btn:hover {
    background: var(--primary-500);
}
.st-action-btn:active {
    transform: scale(0.98);
}
.st-action-btn.st-btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.st-action-btn.st-btn-ghost:hover {
    background: var(--overlay-light);
}

/* Status badges */
.st-status-badge {
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    flex-shrink: 0;
}
.st-badge-active {
    background: var(--primary-100);
    color: var(--primary-400);
}
.st-badge-inactive {
    background: var(--overlay-light);
    color: var(--text-dim);
}

/* Stats grid in storage section */
.st-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 8px;
}
.st-stat {
    text-align: center;
    padding: 12px 6px;
    background: var(--overlay-subtle);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.st-stat-num {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}
.st-stat-label {
    font-size: 9px;
    color: var(--text-dim);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* Font size settings applied */
[data-font-size="small"] .msg-content { font-size: 12px !important; }
[data-font-size="large"] .msg-content { font-size: 16px !important; }
.flat-bubbles .msg { border-radius: 4px !important; }
.reduce-motion * { animation-duration: 0s !important; transition-duration: 0s !important; }
.screen-secure {
    -webkit-user-select: none; user-select: none;
    -webkit-touch-callout: none;
}
.screen-secure img, .screen-secure video, .screen-secure canvas {
    pointer-events: none;
    -webkit-user-drag: none;
}

/* ---- SETTINGS DESKTOP LAYOUT ---- */
@media (min-width: 769px) {
    #panel-settings {
        max-width: 560px;
    }
    #panel-settings .settings-panel {
        padding: 0 8px;
    }
    #panel-settings .settings-header {
        margin-bottom: 20px;
        padding-bottom: 16px;
        border-bottom: 1px solid var(--border);
    }
    #panel-settings .settings-main,
    #panel-settings #settingsSubContent {
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        padding: 8px 12px;
    }
    #panel-settings .st-sep-line {
        margin: 4px -12px;
        width: calc(100% + 24px);
    }
    #panel-settings .st-section-label {
        padding: 14px 0 6px;
    }
    #panel-settings .st-row {
        border-radius: var(--radius-sm);
        padding: 12px 10px;
    }
    #panel-settings .st-version {
        margin-top: 8px;
        padding: 16px 0;
    }
    #panel-settings .st-back {
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        margin-bottom: 12px;
        padding: 10px 14px;
        transition: background 0.15s;
    }
    #panel-settings .st-back:hover {
        background: var(--bg-elevated);
    }
    #panel-settings .st-stats-grid {
        margin: 0 -4px;
    }
    #panel-settings .st-action-btn {
        border-radius: var(--radius-sm);
    }
}

@media (max-width: 768px) {
    .st-stats-grid { grid-template-columns: repeat(2, 1fr); }
    .st-input-field { width: 120px; }
    .st-row { padding: 10px 6px; gap: 8px; }
    .st-name { font-size: 12px; }
    .st-hint { font-size: 9px; }
    .st-icon { width: 30px; height: 30px; border-radius: 8px; }
    .st-action-btn { font-size: 12px; padding: 10px; min-height: 40px; }
    .phantom-select-mini { font-size: 11px; padding: 5px 8px; max-width: 140px; }
    .st-status-badge { font-size: 9px; padding: 2px 6px; }
    .settings-panel { padding-bottom: 20px; }
}

/* ============================================================
   INPUT POPUP — WhatsApp-style attachment/options menu
   ============================================================ */
.input-popup {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 8px;
    right: 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px 0;
    box-shadow: var(--shadow-lg);
    display: none;
    z-index: 100;
    animation: popupSlideUp 0.2s ease-out;
}
.input-popup.show {
    display: block;
}
@keyframes popupSlideUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.input-popup-section {
    padding: 0 16px;
}
.input-popup-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    margin-bottom: 10px;
    padding: 0 2px;
}
.input-popup-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 4px;
}
.input-popup-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 4px;
    border-radius: var(--radius-sm);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font-display), var(--font-emoji);
    font-size: 11px;
    font-weight: 500;
    transition: background 0.15s;
}
.input-popup-item:hover {
    background: var(--overlay-light);
}
.input-popup-item:active {
    background: var(--overlay-medium);
    transform: scale(0.96);
}
.input-popup-icon {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.input-popup-sep {
    height: 1px;
    background: var(--border);
    margin: 10px 16px;
}

/* Toggle row */
.input-popup-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 2px;
    gap: 12px;
}
.input-popup-toggle-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}
.toggle-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}
.toggle-hint {
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 1px;
}

/* Stego password row */
.input-popup-stego-pwd {
    padding: 4px 2px 6px 28px;
}

/* ============================================================
   PHANTOM TOGGLE — iOS-style switch
   ============================================================ */
.phantom-toggle {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 22px;
    flex-shrink: 0;
    cursor: pointer;
}
.phantom-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.phantom-toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 22px;
    transition: background 0.25s ease;
}
.phantom-toggle-slider::before {
    content: '';
    position: absolute;
    left: 3px;
    top: 3px;
    width: 16px;
    height: 16px;
    background: var(--text-primary);
    border-radius: 50%;
    transition: transform 0.25s ease;
    opacity: 0.7;
}
.phantom-toggle input:checked + .phantom-toggle-slider {
    background: var(--primary-500);
}
.phantom-toggle input:checked + .phantom-toggle-slider::before {
    transform: translateX(16px);
    opacity: 1;
    background: var(--bg-body);
}

/* ============================================================
   PHANTOM SELECT MINI — Styled dropdown
   ============================================================ */
.phantom-select-mini {
    background: var(--bg-body);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 8px;
    padding: 6px 28px 6px 10px;
    font-size: 12px;
    font-family: var(--font-display), var(--font-emoji);
    font-weight: 500;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 256 256' fill='%238B9BB4'%3E%3Cpath d='M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    transition: border-color 0.15s;
    flex-shrink: 0;
}
.phantom-select-mini:hover {
    border-color: var(--primary-400);
}
.phantom-select-mini:focus {
    outline: none;
    border-color: var(--primary-500);
}

/* ============================================================
   INPUT ACTIVE TAGS — Shows active prefs below input
   ============================================================ */
.input-popup-active {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px 4px;
    flex-wrap: wrap;
}
.input-active-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.input-active-tag.stego {
    background: var(--primary-100);
    color: var(--primary-400);
}
.input-active-tag.timer {
    background: var(--accent-100);
    color: var(--accent);
}

/* Dot indicator on + button when prefs active */
.input-extras-toggle.has-active-prefs {
    position: relative;
}
.input-extras-toggle.has-active-prefs::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 7px;
    height: 7px;
    background: var(--primary-500);
    border-radius: 50%;
    border: 1.5px solid var(--bg-card);
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .input-popup {
        left: 4px;
        right: 4px;
    }
    .input-popup-item {
        padding: 10px 4px;
    }
    .input-popup-icon {
        width: 38px;
        height: 38px;
    }
}

/* ============================================================
   MESSAGE CONTEXT MENU (WhatsApp-style)
   ============================================================ */
.msg-ctx-menu {
    position: fixed;
    z-index: 10002;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 6px 0;
    box-shadow: var(--shadow-lg);
    min-width: 190px;
    max-width: 240px;
    animation: ctxMenuIn 0.15s ease-out;
    overflow: hidden;
}
.msg-ctx-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 11px 16px;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-family: var(--font-display), var(--font-emoji);
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s ease;
    text-align: left;
}
.msg-ctx-item:hover {
    background: var(--overlay-light);
}
.msg-ctx-item:active {
    background: var(--overlay-medium);
}
.msg-ctx-item svg {
    flex-shrink: 0;
    color: var(--text-secondary);
}
.msg-ctx-item:hover svg {
    color: var(--text-secondary);
}
.msg-ctx-item.ctx-warn {
    color: var(--accent) !important;
}
.msg-ctx-item.ctx-warn svg {
    color: var(--accent) !important;
}
.msg-ctx-item.ctx-warn:hover {
    background: var(--accent-100) !important;
}
.msg-ctx-item.ctx-danger {
    color: var(--danger) !important;
}
.msg-ctx-item.ctx-danger svg {
    color: var(--danger) !important;
}
.msg-ctx-item.ctx-danger:hover {
    background: rgba(248,113,113,0.08) !important;
}
.msg-ctx-sep {
    height: 1px;
    background: var(--border);
    margin: 4px 12px;
}

/* Mobile: menu como bottom sheet para touch */
@media (max-width: 768px) {
    .msg-ctx-menu {
        left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important;
        min-width: 100vw; max-width: 100vw;
        border-radius: 16px 16px 0 0;
        border: none;
        border-top: 1px solid var(--border);
        padding: 8px 0 env(safe-area-inset-bottom, 12px);
        animation: msgCtxSlideUp 0.2s ease-out;
    }
    @keyframes msgCtxSlideUp {
        from { transform: translateY(100%); opacity: 0; }
        to { transform: translateY(0); opacity: 1; }
    }
    .msg-ctx-item {
        padding: 15px 20px;
        font-size: 15px;
        min-height: 48px;
    }
}

/* ============================================================
   IDENTITY MINIMAL BAR (Logged out state)
   ============================================================ */
.identity-minimal-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
}
.identity-minimal-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.identity-minimal-name {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: var(--text-primary);
}
.identity-minimal-status {
    font-size: 10px;
    color: var(--text-dim);
}

/* ============================================================
   IDENTITY MODAL (Login / Register lightbox)
   ============================================================ */
.identity-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    backdrop-filter: blur(6px);
    animation: modalFade 0.2s ease-out;
}
.identity-modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    width: 340px;
    max-width: calc(100vw - 32px);
    box-shadow: var(--shadow-lg);
    animation: modalPop 0.25s ease-out;
    position: relative;
}
.identity-modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 20px;
    padding: 4px 8px;
    border-radius: 6px;
    transition: var(--transition);
    line-height: 1;
}
.identity-modal-close:hover {
    color: var(--text-primary);
    background: var(--overlay-light);
}
.identity-modal-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}
.identity-modal-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}
.identity-modal-subtitle {
    font-size: 12px;
    color: var(--text-muted);
}
.identity-modal-box .input {
    font-size: 14px;
    padding: 12px 16px;
}

/* ============================================================
   FORWARD PICKER — Modal para seleccionar chat destino
   ============================================================ */
.fwd-dest-list {
    max-height: 280px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px;
    scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.fwd-dest-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px;
    border-radius: 10px; border: none; background: transparent; cursor: pointer;
    text-align: left; width: 100%; transition: background 0.15s ease;
    font-family: inherit; font-size: 14px; color: var(--text-primary);
}
.fwd-dest-item:hover { background: var(--bg-body); }
.fwd-dest-avatar {
    width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
    background: var(--primary-500); color: #fff; font-weight: 600; font-size: 14px;
    display: flex; align-items: center; justify-content: center;
}
.fwd-dest-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============================================================
   MULTI-SELECT — Seleccion multiple de mensajes
   ============================================================ */
.multi-select-bar {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px; background: var(--bg-elevated, var(--bg-card));
    border-top: 1px solid var(--border);
    position: relative; z-index: 10;
    opacity: 0; max-height: 0; overflow: hidden;
    transition: opacity 0.25s ease, max-height 0.25s ease;
}
.multi-select-bar.msel-visible {
    opacity: 1; max-height: 60px;
}
.msel-close {
    width: 28px; height: 28px; border-radius: 50%; border: none;
    background: transparent; color: var(--text-muted); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; flex-shrink: 0;
}
.msel-close:hover { color: var(--danger); }
.msel-count {
    font-size: 13px; font-weight: 600; color: var(--text-secondary); flex: 1;
}
.msel-actions { display: flex; gap: 8px; }
.msel-btn {
    display: flex; align-items: center; gap: 5px; padding: 6px 12px;
    border-radius: 8px; border: none; cursor: pointer;
    font-size: 12px; font-weight: 500; font-family: inherit;
    transition: all 0.15s ease;
}
.msel-btn-del-me { background: var(--bg-body); color: var(--text-secondary); }
.msel-btn-del-me:hover { background: var(--warning); color: #fff; }
.msel-btn-del-all { background: var(--danger); color: #fff; }
.msel-btn-del-all:hover { opacity: 0.85; }

/* Mensaje seleccionado */
.multi-select-mode .msg { cursor: pointer; }
.msg.msg-selected {
    outline: 2px solid var(--primary-500) !important;
    outline-offset: -2px;
    background: var(--primary-100, var(--primary-100)) !important;
}
.msg-mine.msg-selected {
    background: var(--primary-glow) !important;
}
/* Checkbox visual en cada mensaje durante multi-select */
.multi-select-mode .msg::before {
    content: '';
    position: absolute; left: -8px; top: 50%; transform: translateY(-50%);
    width: 20px; height: 20px; border-radius: 50%;
    border: 2px solid var(--border); background: var(--bg-body);
    z-index: 5; transition: all 0.15s ease;
}
.multi-select-mode .msg-mine::before { left: auto; right: -8px; }
.multi-select-mode .msg.msg-selected::before {
    background: var(--primary-500); border-color: var(--primary-500);
}
/* Checkmark inside */
.multi-select-mode .msg.msg-selected::after {
    content: '';
    position: absolute; left: -4px; top: 50%; transform: translateY(-60%) rotate(45deg);
    width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0;
    z-index: 6;
}
.multi-select-mode .msg-mine.msg-selected::after { left: auto; right: -4px; }

/* ============================================================
   PASSWORD VISIBILITY TOGGLE
   Wrap any <input type="password"> in .pwd-wrap for eye toggle
   ============================================================ */

.pwd-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.pwd-wrap .input {
    padding-right: 42px;
}
.pwd-toggle {
    position: absolute;
    right: 1px;
    top: 1px;
    bottom: 1px;
    width: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    cursor: pointer;
    color: var(--text-dim);
    transition: color 0.2s ease, background 0.2s ease;
    padding: 0;
    z-index: 2;
}
.pwd-toggle:hover {
    color: var(--primary-400);
    background: var(--bg-elevated);
}
.pwd-toggle:active {
    color: var(--primary-500);
}
.pwd-toggle svg {
    width: 18px;
    height: 18px;
    pointer-events: none;
}
.pwd-toggle .pwd-icon-hide {
    display: none;
}
.pwd-wrap.pwd-visible .pwd-toggle .pwd-icon-show {
    display: none;
}
.pwd-wrap.pwd-visible .pwd-toggle .pwd-icon-hide {
    display: block;
}

/* ============================================================
   NETWORK BANNER — Indicador global de conexion
   ============================================================ */

.net-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 99999;
    transform: translateY(-100%);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
}
.net-banner-show {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}
.net-banner-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    font-family: var(--font-display), var(--font-emoji);
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    flex-wrap: wrap;
}
.net-banner-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
.net-banner-text {
    line-height: 1.3;
}
.net-banner-sub {
    width: 100%;
    font-size: 11px;
    font-weight: 400;
    opacity: 0.8;
    margin-top: 2px;
}

/* Offline: rojo con animacion de pulso */
.net-banner-offline {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: #fff;
    box-shadow: 0 2px 12px rgba(220, 38, 38, 0.4);
}
.net-banner-offline .net-banner-icon {
    animation: netPulseIcon 1.5s ease-in-out infinite;
}
@keyframes netPulseIcon {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.9); }
}

/* Online: verde con auto-hide */
.net-banner-online {
    background: linear-gradient(135deg, #16a34a, #15803d);
    color: #fff;
    box-shadow: 0 2px 12px rgba(22, 163, 74, 0.4);
}

/* Light theme */
[data-theme="light"] .net-banner-offline {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 2px 12px rgba(239, 68, 68, 0.3);
}
[data-theme="light"] .net-banner-online {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    box-shadow: 0 2px 12px rgba(34, 197, 94, 0.3);
}

/* ============================================================
   MEDIA VAULT PANEL — Archivos compartidos del chat
   Desliza desde la derecha al hacer clic en avatar
   ============================================================ */

.mv-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0);
    z-index: 9200;
    pointer-events: none;
    transition: background 0.35s ease;
}
.mv-backdrop.mv-show {
    background: rgba(0,0,0,0.3);
    pointer-events: auto;
}

.mv-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(320px, 85%);
    background: var(--bg-surface);
    z-index: 9201;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: -4px 0 24px rgba(0,0,0,0.2);
    overflow: hidden;
}
.mv-panel.mv-show {
    transform: translateX(0);
}

/* Header */
.mv-header {
    padding: 20px 16px 14px;
    text-align: center;
    border-bottom: 1px solid var(--border-light);
    position: relative;
    flex-shrink: 0;
}
.mv-close {
    position: absolute;
    top: 10px;
    left: 10px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 22px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}
.mv-close:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}
.mv-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--bg-elevated);
    margin: 0 auto 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 22px;
    font-weight: 600;
    color: var(--primary-400);
}
.mv-avatar img, .mv-avatar svg {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.mv-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: var(--font-display);
}
.mv-status {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 2px;
}

/* Tabs */
.mv-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}
.mv-tab {
    flex: 1;
    padding: 10px 4px;
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    font-family: var(--font-display);
    color: var(--text-secondary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}
.mv-tab:hover {
    color: var(--text-primary);
}
.mv-tab.active {
    color: var(--primary-400);
    border-bottom-color: var(--primary-500);
}

/* Content area */
.mv-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px;
}

/* Empty state */
.mv-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 16px;
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
    gap: 4px;
}

/* Date group separator */
.mv-date-group {
    font-size: 11px;
    color: var(--text-dim);
    font-weight: 600;
    padding: 8px 4px 4px;
    font-family: var(--font-display);
}

/* Media grid */
.mv-media-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
}
.mv-date-group {
    grid-column: 1 / -1;
}
.mv-media-thumb {
    aspect-ratio: 1;
    background: var(--bg-elevated);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease;
}
.mv-media-thumb:hover {
    transform: scale(1.04);
    opacity: 0.85;
}
.mv-media-thumb:active {
    transform: scale(0.96);
}
.mv-media-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Badges */
.mv-badge {
    position: absolute;
    bottom: 3px;
    right: 3px;
    font-size: 8px;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
    line-height: 1.4;
    letter-spacing: 0.5px;
}
.mv-badge-stego {
    background: rgba(239, 68, 68, 0.85);
    color: #fff;
}
.mv-badge-gif {
    background: rgba(139, 92, 246, 0.85);
    color: #fff;
}
.mv-badge-sticker {
    background: rgba(59, 130, 246, 0.85);
    color: #fff;
}

/* File list */
.mv-file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 8px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}
.mv-file-item:hover {
    background: var(--bg-elevated);
}
.mv-file-icon {
    flex-shrink: 0;
}
.mv-file-info {
    flex: 1;
    min-width: 0;
}
.mv-file-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mv-file-meta {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 2px;
}

/* Link list */
.mv-link-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px;
    border-bottom: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}
.mv-link-item:hover {
    background: var(--bg-elevated);
}
.mv-link-url {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: inherit;
}
.mv-link-favicon {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    flex-shrink: 0;
}
.mv-link-info {
    flex: 1;
    min-width: 0;
}
.mv-link-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--primary-400);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mv-link-domain {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 1px;
}
.mv-goto-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s;
}
.mv-goto-btn:hover {
    background: var(--primary-500);
    border-color: var(--primary-500);
    color: #fff;
}

/* Audio list */
.mv-audio-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 8px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}
.mv-audio-item:hover {
    background: var(--bg-elevated);
}
.mv-audio-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-100);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--primary-500);
}
.mv-audio-info {
    flex: 1;
    min-width: 0;
}
.mv-audio-sender {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}
.mv-audio-meta {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 2px;
}

/* Highlight animation when jumping to message */
@keyframes mvHighlightPulse {
    0% { box-shadow: 0 0 0 0 var(--primary-glow); }
    30% { box-shadow: 0 0 0 6px var(--primary-glow); }
    100% { box-shadow: 0 0 0 0 transparent; }
}
.mv-highlight {
    animation: mvHighlightPulse 2s ease-out;
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Light theme */
[data-theme="light"] .mv-panel,
[data-theme="system"] .mv-panel {
    box-shadow: -4px 0 24px rgba(0,0,0,0.1);
}
[data-theme="light"] .mv-backdrop.mv-show,
[data-theme="system"] .mv-backdrop.mv-show {
    background: rgba(0,0,0,0.15);
}

/* ============================================================
   UPDATE BANNER — Notifica nueva version disponible
   ============================================================ */

.update-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 99999;
    transform: translateY(-100%);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.update-banner.show {
    transform: translateY(0);
}
.update-banner-content {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--primary-600, #0d9488), var(--primary-500, #14b8a6));
    color: #fff;
    font-size: 13px;
    font-family: var(--font-display);
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.update-banner-icon {
    display: flex;
    align-items: center;
    opacity: 0.8;
}
.update-banner-btn {
    margin-left: auto;
    padding: 5px 16px;
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-display);
    cursor: pointer;
    transition: all 0.15s;
}
.update-banner-btn:hover {
    background: rgba(255,255,255,0.35);
}
.update-banner-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.update-banner-close:hover {
    color: #fff;
}

/* ============================================================
   NOTIFICATION SOUND GRID — v1.9.8 + UX v1.9.9
   Selector visual de tonos agrupados por categoria. Reemplaza
   el dropdown plano anterior por cards con icono, preview inline
   y estado activo con checkmark. Usa design tokens del sistema.

   v1.9.9 — mejoras de escritorio:
   - Panel expandido a 900px cuando se abre la seccion notifications
   - Cards con mas respiracion (minmax 130px en desktop)
   - Headers de categoria con linea divisoria y contador de tonos
   ============================================================ */

.sound-grid-wrap {
    padding: var(--space-2) 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
}

/* Header de categoria con titulo, contador y linea divisoria */
.sound-cat-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 0 var(--space-2);
    margin-bottom: calc(-1 * var(--space-2));
}

.sound-cat-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.11em;
    flex-shrink: 0;
}

.sound-cat-count {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.sound-cat-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, var(--border), transparent);
    min-width: 20px;
}

.sound-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: var(--space-2);
}

.sound-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-4) var(--space-2);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    user-select: none;
    outline: none;
    transition: transform var(--transition-fast), border-color var(--transition-fast),
                background var(--transition-fast), box-shadow var(--transition-fast);
}

.sound-card:hover {
    background: var(--bg-elevated);
    border-color: var(--border-focus);
    transform: translateY(-1px);
}

.sound-card:focus-visible {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

.sound-card:active {
    transform: translateY(0);
}

.sound-card.active {
    background: var(--primary-100);
    border-color: var(--primary-500);
    box-shadow: 0 0 0 1px var(--primary-500);
}

.sound-card-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: color var(--transition-fast), transform var(--transition-fast);
}

.sound-card:hover .sound-card-icon {
    color: var(--text-primary);
    transform: scale(1.05);
}

.sound-card.active .sound-card-icon {
    color: var(--primary-400);
}

.sound-card-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    line-height: 1.2;
}

.sound-card.active .sound-card-name {
    color: var(--primary-300);
}

.sound-card-play {
    position: absolute;
    top: var(--space-1);
    left: var(--space-1);
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    color: var(--text-muted);
    opacity: 0;
    padding: 0;
    transition: opacity var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}

.sound-card:hover .sound-card-play,
.sound-card:focus-within .sound-card-play {
    opacity: 1;
}

.sound-card-play:hover {
    background: var(--primary-500);
    color: #fff;
}

.sound-card-play:focus-visible {
    opacity: 1;
    outline: 2px solid var(--primary-500);
    outline-offset: 1px;
}

.sound-card-check {
    position: absolute;
    top: var(--space-1);
    right: var(--space-1);
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-500);
    color: #fff;
    border-radius: var(--radius-full);
    pointer-events: none;
}

/* Mobile: cards mas compactas y play siempre visible (no hay hover) */
@media (max-width: 480px) {
    .sound-grid {
        grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
        gap: var(--space-2);
    }
    .sound-card {
        padding: var(--space-3) var(--space-2);
    }
    .sound-card-icon {
        width: 34px;
        height: 34px;
    }
    .sound-card-play {
        opacity: 1;
        background: var(--bg-surface);
    }
}

/* Desktop (>=769px): panel expandido + cards mas grandes para la grid de tonos.
   Solo aplica cuando #panel-settings tiene .wide-settings (inyectado por
   settingsNav() al entrar a la seccion 'notifications'). En las otras
   secciones de settings el panel mantiene su ancho normal de 560px. */
@media (min-width: 769px) {
    #panel-settings.wide-settings {
        max-width: 900px;
    }

    #panel-settings.wide-settings .sound-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: var(--space-3);
    }

    #panel-settings.wide-settings .sound-card {
        padding: var(--space-6) var(--space-3);
        gap: var(--space-3);
    }

    #panel-settings.wide-settings .sound-card-icon {
        width: 44px;
        height: 44px;
    }

    #panel-settings.wide-settings .sound-card-name {
        font-size: 13px;
    }

    #panel-settings.wide-settings .sound-cat-title {
        font-size: 12px;
    }

    #panel-settings.wide-settings .sound-cat-count {
        font-size: 11px;
    }
}

/* Ultra-wide (>=1200px): un empujon extra para pantallas grandes */
@media (min-width: 1200px) {
    #panel-settings.wide-settings {
        max-width: 1040px;
    }

    #panel-settings.wide-settings .sound-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}

/* Reduced motion: desactiva transiciones y micro-animaciones */
@media (prefers-reduced-motion: reduce) {
    .sound-card,
    .sound-card-icon,
    .sound-card-play {
        transition: none;
    }
    .sound-card:hover {
        transform: none;
    }
    .sound-card:hover .sound-card-icon {
        transform: none;
    }
}
