
/* CALCULATOR DISPLAY FIX */
#calc-display {
    font-size: clamp(3rem, 18vw, 5.5rem) !important;
    font-weight: 200 !important;
    text-align: right !important;
    margin-bottom: 30px !important;
    color: #fff !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    padding: 0 12px !important;
    min-height: 80px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    word-break: break-all !important;
    user-select: none !important;
}

/* Toast animations */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

:root {
    --primary-red: #b7000b;
    --sky-blue: #00a8e8;
    --whatsapp-bg: #e5ddd5;
    --msg-sent: #e1ffc7;
    --msg-received: #ffffff;
    --text-dark: #303030;
    --text-muted: #868686;
    --tick-blue: #4fc3f7;
    --tick-grey: #a0a0a0;
}

.tick-pending {
    color: #94a3b8;
}

.tick-pending i {
    font-size: 11px;
}

.ticks {
    font-size: 11px;
    color: #a0a0a0;
    margin-left: 4px;
}

.tick-sent {
    color: #a0a0a0;
}

.tick-delivered {
    color: #a0a0a0;
}

.tick-seen {
    color: #4fc3f7;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

input,
button,
textarea {
    outline: none !important;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    overscroll-behavior: none;
}

body {
    background-color: #f0f2f5;
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    animation: pageFadeIn 0.18s ease;
    -webkit-user-select: none;
    user-select: none;
}

input,
textarea {
    -webkit-user-select: text;
    user-select: text;
}

@keyframes pageFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes appLoaderSpin {
    to {
        transform: rotate(360deg);
    }
}

#app,
#chat-app {
    width: 100%;
    max-width: 500px;
    height: 100dvh;
    background: var(--whatsapp-bg);
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

/* --- Calculator & Selection --- */
#calculator-view {
    height: 100%;
    background: var(--sky-blue);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 0 16px 40px 16px;
    transition: opacity 0.4s ease;
}

.calc-display {
    font-size: clamp(4rem, 20vw, 6rem);
    font-weight: 200;
    text-align: right;
    margin-bottom: 30px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    padding: 0 12px;
}

.calc-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.calc-btn {
    aspect-ratio: 1;
    border-radius: 50%;
    border: none;
    font-size: clamp(1.5rem, 6vw, 2.2rem);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    user-select: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.calc-btn:active {
    transform: scale(0.9);
    filter: brightness(1.1);
}

.btn-num {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.btn-func {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.btn-op {
    background: white;
    color: var(--sky-blue);
    font-weight: 600;
}

.btn-zero {
    grid-column: span 2;
    aspect-ratio: auto;
    border-radius: 50px;
    padding-left: 30px;
    justify-content: flex-start;
}

#identity-view {
    position: absolute;
    inset: 0;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 50;
}

.selection-card h2 {
    color: var(--primary-red);
    margin-bottom: 30px;
}

.user-options {
    display: flex;
    gap: 30px;
    justify-content: center;
}

.user-card {
    cursor: pointer;
    text-align: center;
    transition: transform 0.2s;
}

.user-card:active {
    transform: scale(0.95);
}

.avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--primary-red);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: bold;
    margin-bottom: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    border: 3px solid white;
}

.s-avatar {
    border-color: #ff4d4d;
}

/* --- Chat Header --- */
.chat-header {
    background: var(--primary-red);
    color: white;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 68px;
    z-index: 100;
    /* Higher z-index to stay on top */
    position: relative;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.back-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.4rem;
    padding: 8px;
    cursor: pointer;
}

.avatar-small {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.2rem;
    color: white;
    border: 1.5px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
    text-transform: uppercase;
    position: relative;
    /* Removed overflow: hidden so status dot is not clipped */
}

.avatar-small img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 50%;
}

.online-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    /* Slightly larger */
    height: 14px;
    background-color: #00e676;
    /* Bright vibrant green */
    border-radius: 50%;
    border: 2px solid white;
    display: none;
    box-shadow: 0 0 10px rgba(0, 230, 118, 0.5);
    /* Glow */
}

.online-dot.active {
    display: block;
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(0, 230, 118, 0.7);
    }

    70% {
        transform: scale(1.1);
        box-shadow: 0 0 0 8px rgba(0, 230, 118, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(0, 230, 118, 0);
    }
}

.user-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.2;
}

.menu-container {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 50px;
    right: 0;
    background: #ffffff;
    box-shadow: 0 6px 20px rgba(0,0,0,0.18);
    border-radius: 10px;
    display: none;
    z-index: 999;
    min-width: 170px;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.06);
}

.dropdown-menu.active {
    display: block;
    animation: dropdownFadeIn 0.14s ease;
}

@keyframes dropdownFadeIn {
    from { opacity:0; transform:translateY(-6px); }
    to   { opacity:1; transform:translateY(0); }
}

.dropdown-menu button {
    width: 100%;
    padding: 10px 16px;
    text-align: left;
    background: none;
    border: none;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    color: #444;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    transition: background 0.15s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

.dropdown-menu button:last-child {
    border-bottom: none;
}

.dropdown-menu button * {
    pointer-events: none;
}

.dropdown-menu button i {
    color: #b7000b;
    font-size: 0.9rem;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
    opacity: 0.7;
}

.dropdown-menu button:hover {
    background: #fdf0f0;
}

.dropdown-menu button:active {
    background: #f5e0e0;
}

/* Buttons that have a small subtitle hint line below them */
.dropdown-menu .dropdown-btn-with-sub {
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    padding: 8px 16px;
}

.dropdown-menu .dropdown-btn-main {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.82rem;
    color: #444;
    font-weight: 500;
}

.dropdown-menu .dropdown-btn-sub {
    font-size: 10px;
    color: #aaa;
    padding-left: 26px;
    line-height: 1.2;
    font-weight: 400;
}


.user-text h3 {
    font-size: 1.05rem;
    /* Slightly larger */
    font-weight: 600;
    margin: 0;
    line-height: 1.1;
}

.user-text p {
    font-size: 0.8rem;
    /* Better visibility */
    font-weight: 400;
    margin: 2px 0 0 0;
    /* Tiny gap above status */
    color: rgba(255, 255, 255, 0.85);
    /* Slightly softer white for contrast */
}

.status-container {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 20px;
}

.activity-text {
    font-size: 0.8rem;
    font-weight: 500;
    color: #4ade80;
    /* Typing/Green */
    margin: 0;
    font-style: italic;
}

.activity-text.recording {
    color: #ff4d4d;
    /* Recording/Red */
}

.refresh-inline-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, transform 0.2s;
}

.refresh-inline-btn:active {
    transform: scale(0.9);
    color: white;
}


.header-right .icon-btn {
    background: none;
    border: none;
    color: white;
    padding: 8px;
    font-size: 1.2rem;
    cursor: pointer;
}

/* --- Messages Area --- */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background-image: url('chat-bg.png');
    background-color: var(--whatsapp-bg);
}

.message-bubble {
    max-width: 85%;
    padding: 6px 10px;
    border-radius: 10px;
    font-size: 0.9rem;
    /* Reduced from 0.95rem */
    position: relative;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
    line-height: 1.35;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.msg-me {
    align-self: flex-end;
    background: #dcf8c6;
    color: #303030;
    border-top-right-radius: 2px;
}

.msg-them {
    align-self: flex-start;
    background: #ffffff;
    color: #303030;
    border-top-left-radius: 2px;
}

.bubble-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 4px;
}

.msg-time {
    font-size: 0.65rem;
    color: #888;
}

.ticks {
    font-size: 0.8rem;
    color: #999;
}

.ticks.seen {
    color: #4fc3f7;
}

/* Media in bubble */
.chat-img {
    max-width: 100%;
    border-radius: 8px;
    display: block;
    margin-bottom: 4px;
}

.chat-vid {
    max-width: 100%;
    border-radius: 8px;
}

.chat-audio {
    width: 210px;
    height: 36px;
}

/* --- Input Area --- */
.input-area {
    padding: 10px 12px;
    background: transparent;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    position: relative;
    z-index: 10;
}

.input-wrapper {
    background: white;
    flex: 1;
    border-radius: 25px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    min-height: 48px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.recording-bar {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: white;
    z-index: 5;
}

.rec-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rec-left i.pulse {
    color: #df0000;
    font-size: 1.1rem;
    animation: blink 1s infinite alternate;
}

#recording-timer {
    font-weight: 600;
    color: #333;
    font-size: 0.95rem;
    min-width: 35px;
}

.rec-center {
    flex: 1;
    text-align: center;
}

.slide-cancel {
    color: #888;
    font-size: 0.85rem;
}

.dismiss-voice-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 1.2rem;
    padding: 8px;
    cursor: pointer;
    transition: color 0.2s;
}

.dismiss-voice-btn:active {
    color: #df0000;
    transform: scale(0.9);
}

.attach-btn {
    background: none;
    border: none;
    outline: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    transform: rotate(45deg);
    cursor: pointer;
    margin-right: 12px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none !important;
    /* Remove any shadow */
    transition: transform 0.2s;
}

.attach-btn:active {
    transform: rotate(45deg) scale(0.9);
}

#msg-input {
    flex: 1;
    border: none !important;
    background: none !important;
    padding: 10px 0;
    font-size: 1.1rem;
    outline: none !important;
    box-shadow: none !important;
    color: var(--text-dark);
}

.action-buttons {
    flex-shrink: 0;
}

.voice-btn,
.send-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary-red);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.cancel-rec-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: white;
    color: #888;
    border: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    cursor: pointer;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Attach Menu */
.attach-menu {
    position: absolute;
    bottom: 75px;
    left: 20px;
    background: white;
    border-radius: 16px;
    padding: 8px;
    display: none;
    flex-direction: column;
    min-width: 140px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    z-index: 1000;
}

.attach-menu.active {
    display: flex;
}

.attach-menu button {
    background: none;
    border: none;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    font-size: 0.95rem;
    cursor: pointer;
    color: #333;
    border-radius: 10px;
    transition: background 0.2s;
}

.attach-menu button:hover {
    background: #f0f0f0;
}

.attach-menu button i {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.attach-menu .fa-image {
    background: #bf59cf;
}

.attach-menu .fa-film {
    background: #ff4081;
}

/* Recording Overlay */
#recording-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.recording-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.pulse {
    font-size: 3rem;
    color: var(--primary-red);
    animation: pulseAnim 1s infinite alternate;
}

@keyframes pulseAnim {
    from {
        transform: scale(1);
        opacity: 1;
    }

    to {
        transform: scale(1.2);
        opacity: 0.6;
    }
}

.rec-btn-group {
    display: flex;
    gap: 20px;
}

.rec-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.cancel-rec {
    background: #888;
}

.send-rec {
    background: var(--primary-red);
}

/* --- Custom Views & Modals --- */
.view-container {
    position: absolute;
    inset: 0;
    background: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 1000;
}

.custom-input {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid #eee;
    border-radius: 12px;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
    background: white;
    margin-bottom: 20px;
    text-align: center;
}

.custom-input:focus {
    border-color: var(--primary-red);
}

.modal-buttons {
    display: flex;
    gap: 12px;
    width: 100%;
}

.modal-btn {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    border: none;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-btn.primary {
    background: var(--primary-red);
    color: white;
}

.modal-btn.secondary {
    background: #f0f0f0;
    color: #666;
}

.modal-btn:active {
    transform: scale(0.96);
}

/* Modal Overlay */
.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal-overlay.active {
    display: flex;
}

.custom-modal {
    background: white;
    width: 100%;
    max-width: 320px;
    border-radius: 20px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: none;
}

.custom-modal.active {
    display: block;
}

.custom-modal h3 {
    margin-bottom: 10px;
    color: #333;
}

.custom-modal p {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 20px;
}

/* Profile Password Modal styling */
.profile-pass-modal {
    max-width: 360px !important;
    padding: 26px 22px !important;
    border-radius: 24px !important;
    background: #ffffff;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3) !important;
    animation: passModalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes passModalPop {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header-themed {
    text-align: center;
    margin-bottom: 20px;
}

.modal-header-themed .modal-icon {
    font-size: 24px;
    color: #ffffff;
    background: linear-gradient(145deg, #8b0000, #660000);
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    box-shadow: 0 6px 16px rgba(139, 0, 0, 0.25);
}

.modal-header-themed h3 {
    font-size: 19px;
    font-weight: 700;
    color: #111111;
    margin-bottom: 4px;
    letter-spacing: -0.2px;
}

.modal-header-themed p {
    font-size: 13px;
    color: #666666;
    margin-bottom: 0;
    line-height: 1.4;
}

.pass-input-group {
    display: flex;
    align-items: center;
    background: #f8f5f0;
    border: 1.5px solid #e2dad0;
    border-radius: 14px;
    padding: 12px 14px;
    gap: 12px;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.pass-input-group:focus-within {
    border-color: #8b0000;
    box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.14);
    background: #ffffff;
}

.pass-input-group .input-left-icon {
    color: #8b0000;
    font-size: 15px;
    flex-shrink: 0;
}

.pass-input-group input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 500;
    color: #111111;
    outline: none !important;
}

.pass-input-group input::placeholder {
    color: #999999;
    font-weight: 400;
}

.pass-input-group .input-eye-icon {
    color: #888888;
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    flex-shrink: 0;
    transition: color 0.2s, transform 0.1s;
}

.pass-input-group .input-eye-icon:active {
    transform: scale(0.9);
}

.pass-input-group .input-eye-icon:hover {
    color: #8b0000;
}

/* Dark mode overrides for profile password modal */
.dark-mode .profile-pass-modal {
    background: #1f2c34 !important;
    border: 1px solid #2a3942;
}

.dark-mode .modal-header-themed h3 {
    color: #e9edef;
}

.dark-mode .modal-header-themed p {
    color: #8696a0;
}

.dark-mode .modal-header-themed .modal-icon {
    color: #ff4d4d;
}

.dark-mode .pass-input-group {
    background: #111b21;
    border-color: #2a3942;
}

.dark-mode .pass-input-group:focus-within {
    border-color: #ff4d4d;
    box-shadow: 0 0 0 3px rgba(255, 77, 77, 0.2);
}

.dark-mode .pass-input-group input {
    color: #e9edef;
}

/* Transition classes */
.fade-in {
    animation: fadeIn 0.3s ease;
}

/* ============================================================
   TELEGRAM MEDIA — attach icon, upload progress ring, lazy
   video/document bubbles, retry state
   ============================================================ */
.attach-menu .fa-file-alt {
    background: #34b7f1;
}

/* Circular progress ring, driven purely by the --p (0-100) custom prop —
   no extra JS animation loop needed, just update the CSS var per frame. */
.upload-ring,
.lazy-progress-ring {
    --p: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    background: conic-gradient(var(--primary-red) calc(var(--p) * 1%), rgba(0, 0, 0, 0.15) 0);
    transition: background 0.15s linear;
    flex-shrink: 0;
}

.upload-ring {
    background: conic-gradient(#25d366 calc(var(--p) * 1%), rgba(0, 0, 0, 0.12) 0);
}

.media-loader {
    position: relative;
}

.loader-text-wrap {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.loader-cancel {
    background: none;
    border: none;
    color: #c0392b;
    font-size: 15px;
    cursor: pointer;
    padding: 4px 6px;
    display: none;
    align-items: center;
    justify-content: center;
}

/* Lazy video bubble (not yet downloaded) */
.media-lazy {
    position: relative;
    width: 220px;
    height: 150px;
    border-radius: 8px;
    background: #1c2b33;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    overflow: hidden;
}

.lazy-thumb {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.15);
    font-size: 42px;
}

.lazy-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1;
}

.lazy-status-text {
    color: rgba(255, 255, 255, 0.85);
    font-size: 11px;
    z-index: 1;
}

/* Document bubble */
.doc-bubble {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 10px;
    padding: 10px 12px;
    min-width: 210px;
    max-width: 260px;
    cursor: pointer;
}

.doc-icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--primary-red);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
}

.doc-icon-ready {
    background: #4a4a4a;
}

.doc-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.doc-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dark, #222);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.doc-status {
    font-size: 0.72rem;
    color: #888;
}

/* --- Media Loader --- */
.media-loader {
    align-self: flex-end;
    background: #dcf8c6;
    padding: 8px 12px;
    border-radius: 12px 2px 12px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
    margin-bottom: 10px;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--primary-red);
    border-radius: 50%;
    animation: rotate 0.8s linear infinite;
}

@keyframes rotate {
    to {
        transform: rotate(360deg);
    }
}

.loader-text {
    font-size: 0.85rem;
    color: #666;
}

/* Mobile Responsive Adjustments */
/* Fullscreen Image Viewer */
.image-viewer {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    padding: 20px;
    cursor: pointer;
}

.image-viewer.active {
    display: flex;
}

.image-viewer img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 4px;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

.close-viewer {
    position: absolute;
    top: 20px;
    right: 20px;
    color: #fff;
    font-size: 2.5rem;
    line-height: 1;
}

/* Activity Indicator (WhatsApp style) */
.activity-indicator {
    position: absolute;
    bottom: 80px;
    left: 16px;
    background: rgba(255, 255, 255, 0.9);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-style: italic;
    color: #075e54;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    display: none;
    z-index: 50;
    animation: slideUp 0.3s ease-out;
}

.activity-indicator.active {
    display: flex;
    align-items: center;
    gap: 8px;
}

.activity-indicator::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #075e54;
    border-radius: 50%;
    animation: blink 0.8s infinite alternate;
}

@media (max-width: 500px) {

    #app,
    #chat-app {
        max-width: 100%;
        box-shadow: none;
    }
}

/* Profile Modal Styles */
.profile-img-container {
    width: 240px;
    height: 240px;
    margin: 0 auto 20px;
    border-radius: 50%;
    overflow: hidden;
    background: #f0f0f0;
    border: 4px solid var(--primary-red);
}

.profile-img-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-small img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* Call button in header */
.icon-btn {
    background: transparent;
    border: none;
    color: #e2e8f0;
    font-size: 18px;
    padding: 10px;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.2s, transform 0.1s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.icon-btn:active {
    transform: scale(0.92);
}

.icon-btn * {
    pointer-events: none;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Call avatar large */
.call-avatar-large {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    font-weight: 700;
    color: white;
    border: 3px solid rgba(255, 255, 255, 0.3);
}

/* Reply bar */
#reply-bar {
    border-left: 3px solid #667eea;
    border-radius: 4px;
    margin: 4px 8px;
}

/* Reply preview in bubble */
.reply-preview {
    background: rgba(0, 0, 0, 0.2);
    border-left: 3px solid #667eea;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    color: #aaa;
    margin-bottom: 4px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== TICK STYLES ===== */
.ticks {
    margin-left: 4px;
    font-size: 13px;
}

.tick-sent {
    color: #94a3b8;
}

.tick-delivered {
    color: #94a3b8;
}

.tick-seen {
    color: #4fc3f7;
}

/* ===== ONLINE STATUS ===== */
#target-status {
    font-size: 12px;
    transition: color 0.3s;
}

#target-activity {
    font-size: 12px;
    display: none;
    color: #25d366;
}

/* ===== VOICE PLAYER ===== */
.voice-player {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 180px;
    max-width: 240px;
    padding: 4px 0;
}

.vp-play-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #b7000b;
    border: none;
    color: white;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.msg-them .vp-play-btn {
    background: #128c7e;
}

.vp-bar {
    flex: 1;
    height: 4px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
    overflow: hidden;
}

.vp-progress {
    height: 100%;
    width: 0%;
    background: #b7000b;
    border-radius: 2px;
    transition: width 0.1s linear;
}

.msg-them .vp-progress {
    background: #128c7e;
}

.vp-dur {
    font-size: 11px;
    color: #666;
    flex-shrink: 0;
    min-width: 30px;
}

/* ===== REPLY BAR & PREVIEW ===== */
#reply-bar {
    border-left: 3px solid #b7000b;
    border-radius: 0 6px 6px 0;
}

.reply-preview {
    background: rgba(0, 0, 0, 0.08);
    border-left: 3px solid #b7000b;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    color: #666;
    margin-bottom: 4px;
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== CALL ICON BUTTONS IN HEADER ===== */
.icon-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 18px;
    padding: 8px;
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:active {
    background: rgba(255, 255, 255, 0.2);
}

/* ===== HEADER RIGHT SPACING ===== */
.header-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Toast animations */
@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

/* Pending message indicator */
.pending-badge {
    font-size: 10px;
    color: #f39c12;
    margin-left: 4px;
}

/* ============================================================
   WHATSAPP STYLE VOICE PLAYER — Complete CSS
   ============================================================ */

/* CSS Variables for wave colors */
:root {
    --wave-active: #25d366;
    --wave-inactive: #8696a0;
    --vp-bg-me: #005c4b;
    --vp-bg-them: #1f2c34;
    --vp-play-bg-me: #25d366;
    --vp-play-bg-them: #8696a0;
}

/* Main voice bubble wrapper */
.voice-msg-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    min-width: 200px;
    max-width: 260px;
    width: 100%;
    box-sizing: border-box;
}

/* Play/Pause button — WhatsApp circle style */
.vp-play {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 50%;
    border: none;
    background: var(--vp-play-bg-them);
    color: white;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    padding-left: 2px;
    flex-shrink: 0;
    transition: transform 0.1s;
}

.vp-play:active {
    transform: scale(0.93);
}

/* My messages — green play button */
.msg-me .vp-play {
    background: var(--vp-play-bg-me);
}

/* Middle section — waves + time */
.vp-middle {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

/* Waveform container */
.vp-waveform {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 22px;
    width: 100%;
    overflow: hidden;
}

/* Individual wave bar */
.wv-bar {
    flex: 1;
    min-width: 2px;
    max-width: 3px;
    border-radius: 2px;
    background: var(--wave-inactive);
    opacity: 0.5;
    transition: background 0.1s, opacity 0.1s;
}

/* Duration time text */
.vp-time {
    font-size: 11px;
    color: #8696a0;
    font-weight: 400;
    line-height: 1;
    min-width: 28px;
}

/* My messages time color */
.msg-me .vp-time {
    color: #aedbb4;
}

/* My messages wave colors */
.msg-me .wv-bar {
    background: rgba(255, 255, 255, 0.35);
}

/* Remove any old wave styles */
.vp-waveform-old {
    display: none !important;
}

/* Voice message bubble — tight like WhatsApp */
.message-bubble:has(.voice-msg-wrap) {
    padding: 4px 4px 4px 6px !important;
}

/* Fallback for older browsers */
.msg-me .voice-msg-wrap,
.msg-them .voice-msg-wrap {
    margin: -2px -4px;
}


#offline-banner {
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
    }

    to {
        transform: translateY(0);
    }
}

/* Voice Bubble Styles */
.voice-bubble {
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 18px;
    padding: 8px 12px;
    min-width: 200px;
    max-width: 260px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.voice-mine {
    background: #dcf8c6;
    align-self: flex-end;
    border-top-right-radius: 2px;
}

.voice-them {
    background: #ffffff;
    align-self: flex-start;
    border-top-left-radius: 2px;
}

.vb-play-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #075e54;
    color: white;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.vb-play-btn:active {
    background: #054c3d;
}

.vb-waveform {
    flex: 1;
    height: 28px;
    display: flex;
    align-items: center;
    gap: 2px;
    overflow: hidden;
}

.wave-bar {
    width: 3px;
    min-height: 4px;
    border-radius: 2px;
    transition: height 0.05s ease;
}

.vb-duration {
    font-size: 11px;
    color: #555;
    flex-shrink: 0;
    min-width: 32px;
    text-align: right;
}

/* Reaction styles */
.msg-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.reaction-badge {
    font-size: 16px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    padding: 2px 6px;
}

/* Reply bar */
.reply-preview {
    font-size: 11px;
    color: #555;
    border-left: 3px solid #b7000b;
    padding-left: 6px;
    margin-bottom: 4px;
}

/* Blink animation for recording */
@keyframes blink {
    from {
        opacity: 1;
    }

    to {
        opacity: 0.3;
    }
}

/* ============================================ */
/* PAIRS SELECTION SCREEN STYLES */
/* ============================================ */

body.pairs-body {
    margin: 0;
    padding: 0;
    background: #c9c4b9;
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
}

#pairs-app {
    width: 100%;
    max-width: 500px;
    height: 100vh;
    background: #d4cfc4;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

/* Header */
.pairs-header {
    background: linear-gradient(135deg, #0088b0 0%, #006680 100%);
    padding: 35px 20px 30px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    position: relative;
}

.pairs-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #00a8e8, #006680, #00a8e8);
}

.pairs-header h1 {
    color: white;
    font-size: 26px;
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.pairs-header h1 i {
    font-size: 22px;
}

.pairs-subtitle {
    color: rgba(255, 255, 255, 0.95);
    font-size: 14px;
    font-weight: 400;
    letter-spacing: 0.5px;
}

/* Search Container */
.search-container {
    padding: 20px;
    background: #e8e3d8;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.08);
    border-bottom: 1px solid #d0cbbf;
}

.search-box {
    display: flex;
    align-items: center;
    background: white;
    border-radius: 28px;
    padding: 14px 20px;
    gap: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.search-box:focus-within {
    border-color: #0088b0;
    box-shadow: 0 4px 12px rgba(0, 136, 176, 0.2);
}

.search-icon {
    color: #0088b0;
    font-size: 16px;
}

.search-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 15px;
    outline: none;
    color: #303030;
    font-weight: 500;
}

.search-input::placeholder {
    color: #9a9a9a;
}

/* Pairs List */
.pairs-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px 0;
    background: #d4cfc4;
    min-height: 300px;
    max-height: calc(100vh - 200px);
}

.pair-card {
    display: flex;
    align-items: center;
    padding: 18px 20px;
    background: white;
    margin: 8px 16px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e0dbd0;
    position: relative;
    overflow: hidden;
}

.pair-card:active {
    transform: scale(0.98);
    background: #f5f0e5;
}

.pair-icon {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, #0088b0 0%, #00a8e8 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 16px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 136, 176, 0.3);
}

.pair-icon i {
    color: white;
    font-size: 22px;
}

.pair-info {
    flex: 1;
}

.pair-name {
    font-size: 17px;
    font-weight: 600;
    color: #303030;
    margin-bottom: 6px;
    letter-spacing: 0.3px;
}

.pair-users {
    font-size: 13px;
    color: #6b6b6b;
    font-weight: 500;
}

.pair-arrow {
    color: #0088b0;
    font-size: 14px;
    opacity: 0.6;
    transition: all 0.3s ease;
}

.pair-card:hover .pair-arrow {
    opacity: 1;
    transform: translateX(3px);
}

/* No Results */
.no-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    color: #6b6b6b;
}

.no-results i {
    font-size: 56px;
    margin-bottom: 20px;
    opacity: 0.4;
    color: #0088b0;
}

.no-results p {
    font-size: 15px;
    font-weight: 500;
}

/* Show More Button */
.show-more-container {
    display: flex;
    justify-content: flex-start;
    padding: 15px 20px;
    background: #d4cfc4;
}

.show-more-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #0088b0 0%, #00a8e8 100%);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 136, 176, 0.25);
    letter-spacing: 0.2px;
}

.show-more-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 136, 176, 0.35);
}

.show-more-btn:active {
    transform: translateY(0);
}

.show-more-btn i {
    font-size: 12px;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    padding: 0;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: #f5f0e5;
    border-radius: 24px 24px 0 0;
    width: 100%;
    max-width: 500px;
    margin-bottom: 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    animation: sheetSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes sheetSlideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
    border-bottom: 1px solid #d0cbbf;
    background: linear-gradient(135deg, #e8e3d8 0%, #f5f0e5 100%);
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 600;
    color: #303030;
    letter-spacing: 0.3px;
}

.modal-close {
    background: rgba(0, 0, 0, 0.05);
    border: none;
    color: #6b6b6b;
    font-size: 18px;
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #303030;
}

.modal-body {
    padding: 24px;
}

.modal-subtitle {
    font-size: 14px;
    color: #6b6b6b;
    margin-bottom: 18px;
    font-weight: 500;
}

/* Password Input */
.password-input-container {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    background: white;
    border-radius: 14px;
    padding: 18px 22px;
    gap: 14px;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 2px solid transparent;
}

.password-input-container:focus-within {
    border-color: #0088b0;
    box-shadow: 0 4px 16px rgba(0, 136, 176, 0.25);
}

.password-lock-icon {
    color: #0088b0;
    font-size: 20px;
    flex-shrink: 0;
}

.password-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    font-size: 16px;
    outline: none;
    color: #303030;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.password-input::placeholder {
    color: #9a9a9a;
}

.toggle-password {
    background: none;
    border: none;
    color: #6b6b6b;
    cursor: pointer;
    padding: 10px;
    flex-shrink: 0;
    transition: all 0.2s;
    border-radius: 6px;
}

.toggle-password:hover {
    color: #0088b0;
    background: rgba(0, 136, 176, 0.1);
}

.error-message {
    color: #c0392b;
    font-size: 13px;
    margin-top: 14px;
    text-align: center;
    font-weight: 500;
    padding: 10px;
    background: rgba(192, 57, 43, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(192, 57, 43, 0.2);
}

/* Modal Footer */
.modal-footer {
    display: flex;
    gap: 14px;
    padding: 20px 24px;
    background: #e8e3d8;
    border-top: 1px solid #d0cbbf;
}

.btn-primary,
.btn-secondary {
    flex: 1;
    padding: 16px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.3px;
}

.btn-primary {
    background: linear-gradient(135deg, #0088b0 0%, #00a8e8 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 136, 176, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 136, 176, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: #c0bcb0;
    color: #303030;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn-secondary:hover {
    background: #b0aca0;
    transform: translateY(-2px);
}

.btn-secondary:active {
    transform: translateY(0);
}

/* User Selection */
.user-selection {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.user-option {
    display: flex;
    align-items: center;
    padding: 18px;
    background: white;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    gap: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 2px solid transparent;
}

.user-option:hover {
    background: #f5f0e5;
    transform: translateY(-3px);
    border-color: #0088b0;
    box-shadow: 0 6px 16px rgba(0, 136, 176, 0.2);
}

.user-avatar {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, #0088b0 0%, #00a8e8 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 136, 176, 0.3);
}

.user-avatar i {
    color: white;
    font-size: 22px;
}

.user-name {
    font-size: 17px;
    font-weight: 600;
    color: #303030;
    letter-spacing: 0.3px;
}

/* ============================================================
   USER SELECTION PAGE STYLES (user-selection.html) — Matching pairs.html theme
   ============================================================ */
.user-selection-body {
    background-color: #d4cfc4;
    color: #303030;
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

#user-selection-app {
    width: 100%;
    max-width: 480px;
    min-height: 100vh;
    background: #f5f0e5;
    display: flex;
    flex-direction: column;
    padding: 24px 20px;
    box-sizing: border-box;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.user-selection-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid #d0cbbf;
}

.user-selection-header h1 {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    color: #303030;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.3px;
}

.user-selection-header h1 i {
    color: #0088b0;
    font-size: 24px;
}

.back-btn {
    background: #e8e3d8;
    border: 1px solid #d0cbbf;
    color: #0088b0;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.back-btn:hover {
    background: #0088b0;
    color: white;
    transform: scale(1.06);
    box-shadow: 0 4px 12px rgba(0, 136, 176, 0.3);
}

.pair-info-card {
    background: linear-gradient(135deg, #0088b0 0%, #00a8e8 100%);
    border-radius: 18px;
    padding: 22px 20px;
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 28px;
    box-shadow: 0 8px 24px rgba(0, 136, 176, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.pair-info-icon {
    width: 54px;
    height: 54px;
    background: rgba(255, 255, 255, 0.22);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #ffffff;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.pair-info-text h3 {
    margin: 0 0 4px 0;
    font-size: 24px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.5px;
}

.pair-info-text p {
    margin: 0;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.92);
    font-weight: 500;
}

.user-options-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.user-option-card {
    background: #ffffff;
    border-radius: 18px;
    padding: 20px 22px;
    display: flex;
    align-items: center;
    gap: 18px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}

.user-option-card:hover {
    background: #ffffff;
    border-color: #0088b0;
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0, 136, 176, 0.22);
}

.user-avatar-large {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #0088b0 0%, #00a8e8 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #ffffff;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(0, 136, 176, 0.35);
    border: 3px solid #ffffff;
}

.user-option-card:nth-child(2) .user-avatar-large {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    box-shadow: 0 4px 14px rgba(118, 75, 162, 0.35);
}

.user-info {
    flex: 1;
}

.user-info h3 {
    margin: 0 0 4px 0;
    font-size: 19px;
    font-weight: 700;
    color: #303030;
    letter-spacing: 0.3px;
}

.user-info p {
    margin: 0;
    font-size: 13px;
    color: #6b6b6b;
    font-weight: 500;
}

.user-highlight {
    color: #0088b0;
    font-weight: 600;
}

.user-arrow {
    width: 36px;
    height: 36px;
    background: #f0ebe0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0088b0;
    font-size: 14px;
    transition: all 0.3s ease;
}

.user-option-card:hover .user-arrow {
    background: #0088b0;
    color: #ffffff;
    transform: translateX(4px);
    box-shadow: 0 4px 10px rgba(0, 136, 176, 0.3);
}

/* ===== DARK MODE ===== */
.dark-mode {
    --whatsapp-bg: #0b141a;
    --msg-sent: #005c4b;
    --msg-received: #202c33;
    --text-dark: #e9edef;
    --text-muted: #8696a0;
    --primary-red: #6b0000;
}

.dark-mode body,
.dark-mode #app,
.dark-mode #chat-app,
.dark-mode #pairs-app,
.dark-mode #user-selection-app {
    background-color: var(--whatsapp-bg);
    color: var(--text-dark);
}

.dark-mode .msg-me {
    background: var(--msg-sent);
    color: #e9edef;
}

.dark-mode .msg-them {
    background: var(--msg-received);
    color: #e9edef;
}

.dark-mode .input-wrapper,
.dark-mode .password-input-container,
.dark-mode .search-box {
    background: #202c33;
}

.dark-mode #msg-input,
.dark-mode .password-input,
.dark-mode .search-input {
    color: #e9edef;
}

.dark-mode .pair-card,
.dark-mode .user-card,
.dark-mode .user-option-card,
.dark-mode .custom-modal,
.dark-mode .modal-content {
    background: #1f2c34;
    color: #e9edef;
}

.dark-mode .pair-name,
.dark-mode .user-info .name,
.dark-mode .custom-modal h3 {
    color: #e9edef;
}

/* ═══════════════════════════════════════════════════════════════════
   CHAT LOCK SCREEN — White/Red Theme Matching Selection Page
   Only shown to the user who SET a password (checked via hasProfilePassword(me))
   A1 sets password → A1 sees lock. S1 sees nothing.
═══════════════════════════════════════════════════════════════════ */

#chat-lock-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: linear-gradient(180deg, #efe7dd 0%, #d4c8bc 100%);
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    overflow: hidden;
}

/* Pattern overlay */
#chat-lock-overlay::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%238b0000' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 0;
    opacity: 1;
}

#chat-lock-overlay[style*="display:none"],
#chat-lock-overlay[style*="display: none"] {
    display: none !important;
}

#chat-lock-overlay.unlocking {
    animation: lockFadeOut 0.28s ease forwards;
    pointer-events: none;
}

/* ── Container ── */
.lock-screen-container {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: rgba(239, 231, 221, 0.95);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

/* ── Header ── */
.lock-header {
    background: linear-gradient(145deg, #8b0000, #660000);
    padding: 20px 20px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 4px 24px rgba(139, 0, 0, 0.25);
}

.lock-back-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: white;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.lock-back-btn:active {
    transform: scale(0.90);
    background: rgba(255, 255, 255, 0.20);
}

.lock-header h1 {
    flex: 1;
    font-size: 18px;
    font-weight: 700;
    color: white;
    margin: 0;
    letter-spacing: -0.3px;
}

/* ── Content ── */
.lock-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    gap: 24px;
}

.lock-icon-container {
    margin-bottom: 8px;
}

.lock-icon-circle {
    width: 100px;
    height: 100px;
    background: linear-gradient(145deg, #8b0000, #660000);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(139, 0, 0, 0.35);
    border: 3px solid rgba(255, 255, 255, 0.2);
}

.lock-icon-circle i {
    font-size: 42px;
    color: white;
}

.lock-title {
    font-size: 24px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0;
    text-align: center;
    letter-spacing: -0.3px;
}

.lock-subtitle {
    font-size: 14px;
    color: #5a5a5a;
    margin: 0;
    text-align: center;
    font-weight: 500;
}

/* ── Input ── */
.lock-input-container {
    width: 100%;
    max-width: 320px;
}

.lock-input-box {
    display: flex;
    align-items: center;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 0 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    height: 48px;
}

.lock-input-box:focus-within {
    border-color: #8b0000;
    box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.08);
}

.lock-input-icon {
    color: #8b0000;
    font-size: 16px;
    margin-right: 12px;
    flex-shrink: 0;
}

.lock-input-box input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 14px 0;
    font-size: 15px;
    font-weight: 500;
    color: #1a1a1a;
    outline: none;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.lock-input-box input::placeholder {
    color: #9a9a9a;
    font-weight: 400;
}

.lock-toggle-icon {
    color: #8a8a8a;
    font-size: 16px;
    margin-left: 4px;
    margin-right: 6px;
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.2s;
    padding: 4px;
}

.lock-toggle-icon:hover {
    color: #8b0000;
}

/* ── Voice Message Bubble — WhatsApp Style ── */
.voice-message {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 210px;
    max-width: 250px;
    padding: 8px 10px;
}

/* Received = white bubble, sent = your existing green sent-bubble bg
   (voice-message itself stays transparent so it inherits parent bubble) */
.message.sent .voice-message {
    background: transparent;
    flex-direction: row;
    /* avatar first, then play, then waveform */
}

.message.received .voice-message {
    background: transparent;
    flex-direction: row-reverse;
    /* play+waveform first, avatar last, visually */
}

/* Because flex-direction: row-reverse reverses child ORDER visually but not
   DOM order, we keep DOM order the same for both (play, waveform, avatar)
   and only flip received. Sent needs avatar actually first in DOM+visual,
   so sent uses a different structure — see Part 2 render function which
   outputs different DOM order per isSent rather than relying on CSS flip.
   (This avoids relying on row-reverse quirks with the scrub dot.) */
.message.sent .voice-message {
    flex-direction: row;
}

.message.received .voice-message {
    flex-direction: row;
}

.voice-play-btn {
    width: 22px;
    height: 22px;
    border-radius: 0;
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b6b6b;
    font-size: 15px;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
}

.voice-play-btn.loading {
    color: #999;
}

.voice-play-btn .spinner {
    width: 15px;
    height: 15px;
    border: 2px solid rgba(0, 0, 0, 0.15);
    border-top-color: #6b6b6b;
    border-radius: 50%;
    animation: voiceSpin 0.7s linear infinite;
}

@keyframes voiceSpin {
    to {
        transform: rotate(360deg);
    }
}

.voice-waveform-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.voice-waveform {
    display: flex;
    align-items: center;
    gap: 1.5px;
    height: 20px;
    cursor: pointer;
    position: relative;
}

.voice-bar {
    flex: 1;
    min-width: 1.5px;
    max-width: 2px;
    background: #c8c8c8;
    border-radius: 1px;
    transition: background 0.1s linear;
}

.voice-bar.played {
    background: #8a8a8a;
}

.message.sent .voice-bar {
    background: rgba(0, 0, 0, 0.18);
}

.message.sent .voice-bar.played {
    background: rgba(0, 0, 0, 0.45);
}

/* Meta row: duration on the left, timestamp (+ ticks if sent) on the right —
   exactly like the reference image's bottom row of each bubble */
.voice-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 10.5px;
    color: #8a8a8a;
}

.message.sent .voice-meta-row {
    color: rgba(0, 0, 0, 0.45);
}

.voice-duration {
    font-variant-numeric: tabular-nums;
}

.voice-timestamp {
    display: flex;
    align-items: center;
    gap: 3px;
    font-variant-numeric: tabular-nums;
}

.voice-tick {
    display: flex;
    align-items: center;
}

.voice-tick i {
    font-size: 11px;
}

.voice-tick.sending i {
    color: #999;
}

.voice-tick.sent i {
    color: #8a8a8a;
}

.voice-tick.delivered i {
    color: #8a8a8a;
}

/* grey double-check, matches text semantics */
.voice-tick.read {
    color: #4fc3f7;
}

.voice-retry-btn {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background: rgba(183, 0, 11, 0.12);
    color: #b7000b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    margin-left: 4px;
    flex-shrink: 0;
    font-size: 10px;
}

.voice-retry-btn:active {
    transform: scale(0.9);
    background: rgba(183, 0, 11, 0.22);
}

.voice-retry-btn i {
    font-size: 10px;
}

.voice-speed-btn {
    background: rgba(0, 0, 0, 0.06);
    border: none;
    border-radius: 8px;
    padding: 0 5px;
    font-size: 9px;
    font-weight: 600;
    color: inherit;
    cursor: pointer;
    display: none;
    margin-left: 4px;
}

/* Avatar with mic badge — appears LEFT for sent, RIGHT for received,
   controlled by DOM order in Part 2, not by CSS */
.voice-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
}

.voice-avatar img,
.voice-avatar .voice-avatar-fallback {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    background: #b0b0b0;
}

.voice-avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
}

.voice-mic-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #1fa9f3;
    border: 2px solid #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 6.5px;
}

.message.sent .voice-mic-badge {
    border-color: #dcf8c6;
}

.wa-recording-bar {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: recBarSlideUp 0.2s ease;
}

.wa-recording-backdrop {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 90px;
    background: #d9d9d9;
    z-index: 599;
    pointer-events: none;
    display: none;
}

.wa-recording-backdrop.active {
    display: block;
}

@keyframes recBarSlideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.wa-rec-trash {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(139, 0, 0, 0.25);
    border: none;
    color: #ff4d4d;
    font-size: 19px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.wa-rec-trash:active {
    transform: scale(0.92);
}

.wa-rec-pill {
    flex: 1;
    height: 52px;
    background: #1c2733;
    border-radius: 26px;
    display: flex;
    align-items: center;
    padding: 0 8px 0 18px;
    gap: 10px;
    min-width: 0;
}

.wa-rec-timer {
    color: #ffffff !important;
    font-size: 14px;
    font-weight: 500;
    flex-shrink: 0;
    min-width: 34px;
}

.wa-rec-waveform {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 2px;
    height: 24px;
    overflow: hidden;
}

.wa-rec-waveform .wa-bar {
    width: 3px;
    min-height: 3px;
    border-radius: 2px;
    background: #8696a0;
    flex-shrink: 0;
    transition: height 0.08s ease;
}

.wa-rec-pause-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: #e9edef;
    font-size: 13px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.wa-rec-send {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #b7000b;
    border: none;
    color: white;
    font-size: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(183, 0, 11, 0.4);
}

.wa-rec-send:active,
.wa-rec-trash:active,
.wa-rec-pause-btn:active {
    transform: scale(0.9);
}

/* ── Button ── */
.lock-button-container {
    width: 100%;
    max-width: 320px;
}

.lock-unlock-btn {
    width: 100%;
    padding: 14px 20px;
    border-radius: 12px;
    border: none;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(145deg, #8b0000, #660000);
    color: white;
}

.lock-unlock-btn:hover {
    background: linear-gradient(145deg, #a00000, #800000);
    transform: translateY(-1px);
}

.lock-unlock-btn:active {
    transform: scale(0.98);
}

.lock-unlock-btn i {
    font-size: 14px;
}

.lock-error-msg {
    color: #8b0000;
    font-size: 13px;
    text-align: center;
    margin: 8px 0 0;
    font-weight: 500;
    min-height: 20px;
}

.lock-forgot-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 12px auto 0;
    padding: 6px 10px;
    border: 0;
    background: transparent;
    color: #8b0000;
    font-size: 13px;
    cursor: pointer;
}

.lock-forgot-panel {
    width: 100%;
    margin-top: 12px;
}

.lock-forgot-help {
    margin: 0 0 10px;
    color: #666;
    font-size: 12px;
    text-align: center;
}

.lock-forgot-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.lock-cancel-btn {
    border: 0;
    background: transparent;
    color: #666;
    cursor: pointer;
    font-size: 13px;
}

/* Skeleton loading for chat */
.chat-skeleton {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
}

.skeleton-bubble {
    height: 36px;
    border-radius: 12px;
    width: 55%;
    background: linear-gradient(90deg, #e8e8e8 25%, #f2f2f2 50%, #e8e8e8 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.4s ease-in-out infinite;
}

.skeleton-received {
    align-self: flex-start;
}

.skeleton-sent {
    align-self: flex-end;
    width: 40%;
}

@keyframes skeletonShimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ===== VOICE TICK — SENDING PULSE ===== */
@keyframes tickPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.35;
    }
}

.voice-tick.sending i {
    animation: tickPulse 1.4s ease-in-out infinite;
}

/* ===== SEGMENT TRAY (inside recording-bar) ===== */
.rec-segments-tray {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    flex: 1;
    padding: 0 6px;
    min-width: 0;
}

.rec-segment-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(0, 136, 176, 0.15);
    border: 1px solid rgba(0, 136, 176, 0.35);
    border-radius: 20px;
    padding: 3px 9px 3px 7px;
    font-size: 11px;
    color: #0088b0;
    font-weight: 600;
    white-space: nowrap;
}

.rec-segment-pill i {
    font-size: 10px;
}

/* Status text under segment tray */
.rec-status-text {
    font-size: 11px;
    color: #8696a0;
    padding: 0 8px 4px;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Dark-mode */
.dark-mode .rec-segment-pill {
    background: rgba(0, 136, 176, 0.25);
    border-color: rgba(0, 136, 176, 0.5);
    color: #4fc3f7;
}

/* ===== SEGMENT COUNT BADGE on mic button ===== */
.seg-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #0088b0;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    line-height: 1;
}

/* ===== MIC BUTTON — ACTIVELY RECORDING STATE ===== */
.voice-btn.recording-active {
    background: #e53935 !important;
    color: #fff !important;
    animation: micPulse 1s ease-in-out infinite;
}

@keyframes micPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(229, 57, 53, 0.5);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(229, 57, 53, 0);
    }
}

/* ============================================================
   BUG #4 FIX — WHATSAPP-STYLE POLISH FOR TEXT + VOICE BUBBLES
   These rules come LAST so they win on specificity/cascade order
   without needing !important everywhere. Only visual polish —
   no functional class names changed.
   ============================================================ */

/* ── Text bubbles: rounder, WhatsApp-like corners + softer shadow ── */
.message-bubble {
    max-width: 78%;
    padding: 7px 9px 8px 10px;
    border-radius: 12px;
    box-shadow: 0 1px 1.5px rgba(0, 0, 0, 0.13);
    font-size: 0.94rem;
    line-height: 1.4;
}

.msg-me {
    border-radius: 12px;
    border-top-right-radius: 3px;
}

.msg-them {
    border-radius: 12px;
    border-top-left-radius: 3px;
}

.bubble-content p {
    white-space: pre-wrap;
    word-break: break-word;
}

/* ── Voice bubble: bigger, smoother, more breathing room ── */
.voice-message {
    min-width: 275px;
    max-width: 325px;
    padding: 11px 14px;
    gap: 12px;
    border-radius: 16px;
}

.message-bubble:has(.voice-message) {
    padding: 6px 6px !important;
    background: transparent;
    box-shadow: none;
    max-width: 325px;
}

/* Give the voice bubble its own background/shadow now that the outer
   .message-bubble wrapper is transparent, so it reads as ONE smooth pill
   instead of a box-inside-a-box. */
.msg-me .voice-message,
.message.sent .voice-message {
    background: #dcf8c6;
    box-shadow: 0 1px 1.5px rgba(0, 0, 0, 0.12);
    border-top-right-radius: 3px;
}

.msg-them .voice-message,
.message.received .voice-message {
    background: #ffffff;
    box-shadow: 0 1px 1.5px rgba(0, 0, 0, 0.12);
    border-top-left-radius: 3px;
}

.dark-mode .msg-me .voice-message,
.dark-mode .message.sent .voice-message {
    background: #005c4b;
}

.dark-mode .msg-them .voice-message,
.dark-mode .message.received .voice-message {
    background: #202c33;
}

/* Sleek, compact play button — smaller than avatar */
.voice-play-btn {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.06);
    color: #b7000b;
    font-size: 15px;
    flex-shrink: 0;
    transition: background 0.15s ease, transform 0.1s ease;
}

.voice-play-btn:active {
    transform: scale(0.93);
}

.message.sent .voice-play-btn {
    background: rgba(0, 0, 0, 0.08);
    color: #075e54;
}

/* Taller, smoother waveform bars with nicer spacing */
.voice-waveform {
    height: 30px;
    gap: 3px;
}

.voice-bar {
    max-width: 3px;
    border-radius: 2px;
    transition: background 0.15s ease, height 0.15s ease;
}

/* ── BUG #3: play-button-as-retry visual state (WhatsApp style) ── */
.voice-play-btn-failed {
    background: rgba(183, 0, 11, 0.14) !important;
    color: #b7000b !important;
}

.voice-play-btn-failed:active {
    transform: scale(0.9);
    background: rgba(183, 0, 11, 0.24) !important;
}

/* Prominent, large avatar — larger than play button (WhatsApp style) */
.voice-avatar {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.voice-avatar .voice-mic-badge {
    width: 19px;
    height: 19px;
    font-size: 8.5px;
    bottom: -2px;
    right: -2px;
    border: 2px solid #ffffff;
}

.voice-avatar .voice-avatar-fallback {
    font-size: 18px;
    font-weight: 700;
}

/* ============================================================
   WhatsApp-style send progress — small ring pinned to media bubble
   ============================================================ */
.bubble-content {
    position: relative;
}

.send-progress-overlay {
    position: absolute;
    left: 6px;
    bottom: 6px;
    z-index: 3;
}

/* For video bubbles: show loader in the TOP RIGHT side */
.bubble-content:has(video) .send-progress-overlay,
.video-send-overlay {
    top: 8px !important;
    right: 8px !important;
    bottom: auto !important;
    left: auto !important;
}

.send-ring {
    width: 28px;
    height: 28px;
    font-size: 11px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.55);
}

/* ============================================================
   CHANGE APP ICON MODAL — full-viewport picker with image tiles
   ============================================================ */
.change-icon-modal-full {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    display: none;
    flex-direction: column;
    background: #f4f5f7;
    z-index: 10000;
    overflow: hidden;
    padding: 0 !important;
}

.change-icon-modal-full.active {
    display: flex !important;
}

.change-icon-header {
    padding: 20px 20px 12px;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    flex-shrink: 0;
    background: #b7000b;
}

.change-icon-header h3 {
    font-size: 17px;
    font-weight: 700;
    color: #ffffff;
    margin: 0 0 3px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.change-icon-header p {
    font-size: 12px;
    color: rgba(255,255,255,0.75);
    margin: 0;
}

.icon-choice-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    padding: 16px;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
    background: #f4f5f7;
}

.icon-choice-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 14px 10px 12px;
    border-radius: 16px;
    border: 2.5px solid transparent;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    cursor: pointer;
    color: #333;
    transition: border-color 0.18s, background 0.18s, transform 0.12s, box-shadow 0.18s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.icon-choice-btn * {
    pointer-events: none;
}

.icon-choice-btn:active {
    transform: scale(0.96);
}

.icon-choice-btn.selected {
    border-color: #b7000b;
    background: #fff5f5;
    box-shadow: 0 0 0 2px rgba(183,0,11,0.2);
}

.icon-img-wrap {
    width: 76px;
    height: 76px;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
    flex-shrink: 0;
}

.icon-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    -webkit-user-drag: none;
    -webkit-touch-callout: none;
    user-select: none;
    pointer-events: none;
}

.icon-choice-btn span {
    font-size: 11.5px;
    font-weight: 600;
    text-align: center;
    color: #333;
    line-height: 1.3;
}

.change-icon-actions {
    display: flex;
    gap: 10px;
    padding: 14px 16px 24px;
    border-top: 1px solid rgba(0,0,0,0.08);
    flex-shrink: 0;
    background: #ffffff;
}

.change-icon-actions .modal-btn {
    flex: 1;
    padding: 13px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: opacity 0.15s;
}

.change-icon-actions .modal-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.change-icon-actions .modal-btn.secondary {
    background: #f0f0f0;
    color: #555;
}

.change-icon-actions .modal-btn.primary {
    background: #b7000b;
    color: #fff;
}

/* ===================== Calculator password popup ===================== */
.calc-pin-hint { font-size: 12px; color: #888; margin: 12px 0 0; line-height: 1.4; }
.dark-mode .calc-pin-hint { color: #aaa; }
.modal-btn:disabled { opacity: .45; cursor: not-allowed; }
