
:root {
    --primary-color: #7ea6ff;
    --primary-light: #a5bfff;
    --primary-dark: #3355c4;
    --primary-glow: rgba(125, 177, 255, 0.7);
    --primary-glow-strong: rgba(160, 200, 255, 0.95);
    --accent: #64e0ff;
    --accent-glow: rgba(100, 224, 255, 0.7);

    --background: radial-gradient(circle at top, #111827 0%, #020617 55%, #000000 100%);
    --header-bg: linear-gradient(135deg, #020617 0%, #020617 45%, #111827 100%);
    --outgoing-msg: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
    --button-gradient: linear-gradient(135deg, #4f46e5 0%, #7ea6ff 100%);

    --card-bg: rgba(15, 23, 42, 0.95);
    --card-glass: rgba(15, 23, 42, 0.9);
    --card-glass-hover: rgba(30, 64, 175, 0.9);
    --card-border: rgba(148, 163, 184, 0.6);
    --blur-amount: 18px;

    --text-primary: #e5ecff;
    --text-secondary: #9ca3af;
    --text-on-primary: #ffffff;
    --text-light: rgba(255, 255, 255, 0.98);

    --border: rgba(15, 23, 42, 0.9);
    --incoming-msg: rgba(15, 23, 42, 0.9);
    --online: #4ade80;
    --offline: #6b7280;
    --error: #fb7185;

    --shadow-sm: 0 4px 15px rgba(0, 0, 0, 0.6);
    --shadow-md: 0 14px 45px rgba(0, 0, 0, 0.85);
    --shadow-inner: inset 0 0 10px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 18px rgba(56, 189, 248, 0.5);
    --shadow-glow-strong: 0 0 28px rgba(129, 140, 248, 0.9);
    --reflection: linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0) 60%);

    --fr-im-vv-top: 0px;
    --fr-im-safe-top: env(safe-area-inset-top, 0px);
    --fr-im-chrome-top: max(var(--fr-im-safe-top), var(--fr-im-vv-top));
    --fr-im-header-h: 60px;
    --fr-im-tabs-h: 36px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Segoe UI', 'Segoe UI Variable', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
    position: relative;
    z-index: 0;
    background-color: #020617;
    background-image:
        linear-gradient(to bottom,
            rgba(186, 230, 253, 0.1) 0%,
            rgba(15, 23, 42, 0.45) 45%,
            rgba(2, 6, 23, 0.88) 100%),
        url('Dark%20Gradient%20(10).webp');
    background-position: center center, center center;
    background-size: cover;
    
    background-attachment: scroll;
    background-repeat: no-repeat, no-repeat;
    color: var(--text-primary);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    height: 100%;
    text-rendering: optimizeLegibility;
    overflow: hidden; 
}

body::-webkit-scrollbar {
    display: none;
}

html, body {
    height: 100%;
    height: 100svh;
    height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden; 
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100svh;
    height: 100dvh;
    max-width: 100%;
    margin: 0 auto;
    position: relative;
    overflow: hidden; 
    transform: translate3d(0, 0, 0);
    will-change: auto;
    z-index: 1;
}

@media (max-width: 900px) {
    body.is-touch .chat-container {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        height: auto;
        max-width: 100%;
        z-index: 9999;
    }

    body.is-touch #footer-music-bar,
    body.is-touch .music-player-bar,
    body.is-touch .music-player,
    body.is-touch .music-bar,
    body.is-touch .footer-player {
        display: none !important;
    }

    body.is-touch .message-content {
        -webkit-user-select: none;
        -webkit-touch-callout: none;
        user-select: none;
    }

    body.is-touch .message-footer,
    body.is-touch .message-time {
        -webkit-user-select: none;
        -webkit-touch-callout: none;
        user-select: none;
    }
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: center;
    height: var(--fr-im-header-h);
    position: fixed;
    top: var(--fr-im-chrome-top);
    left: 0;
    right: 0;
    z-index: 10;
    padding: 0 15px;
    background: var(--header-bg);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.85), 0 1px 0 rgba(148, 163, 184, 0.25) inset;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.5);
    overflow: visible;
    transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s ease, background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    color: #ffffff;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom,
        rgba(0, 0, 0, 0.4) 0%,
        rgba(0, 0, 0, 0.2) 100%);
    z-index: 0;
}

.chat-header h1 {
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0;
    flex-grow: 1;
    text-align: center;
    padding: 0 110px 0 10px; 
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    letter-spacing: 0.5px;
    position: relative;
    z-index: 1;
}

.chat-open .chat-header h1 {
    padding: 0 60px 0 10px; 
}

.back-button {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.2rem;
    padding: 6px 12px 6px 10px;
    cursor: pointer;
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    border-radius: 20px;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, opacity 0.2s ease, visibility 0.2s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.back-button:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-50%) scale(1.05);
}

.chat-settings-section {
    margin-bottom: 20px;
}

.chat-settings-section:last-child {
    margin-bottom: 0;
}

.chat-settings-section-title {
    margin: 0 0 10px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.chat-sound-setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    cursor: pointer;
}

.chat-sound-setting-label {
    font-weight: 600;
    font-size: 14px;
}

.chat-sound-setting-toggle {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    accent-color: #4a90e2;
}

.search-toggle {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    font-size: 16px;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), visibility 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), color 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), border-color 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 10;
}

.inbox-toggle {
    position: absolute;
    right: 70px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    font-size: 16px;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), visibility 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), color 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), border-color 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 10;
}

.inbox-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-50%) scale(1.05);
    box-shadow: var(--shadow-glow);
}

.chat-open .inbox-toggle {
    display: none !important;
}

.inbox-toggle .unread-count {
    position: absolute;
    top: -4px;
    right: -4px;
    margin-left: 0;
    min-width: 16px;
    padding: 1px 5px;
    font-size: 10px;
    line-height: 1.2;
    pointer-events: none;
}

.search-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-50%) scale(1.05) rotate(360deg);
    box-shadow: var(--shadow-glow);
}

@media (min-width: 900px) {
    :root {
        --fr-im-header-h: 52px;
    }

    .chat-header {
        height: var(--fr-im-header-h);
        padding: 0 18px;
    }

    .chat-header h1 {
        font-size: 1.15rem;
        padding: 0 110px 0 10px; 
    }

    .messages-scroll-container {
        padding-top: calc(62px + var(--fr-im-chrome-top));
    }
}

@media (max-width: 600px) {
    body.is-touch .search-toggle {
        right: 64px;
    }

    body.is-touch .inbox-toggle {
        right: 114px;
    }
}

.search-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s ease, background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    z-index: 12;
}

.search-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.chat-open .search-overlay {
    bottom: 85px;
}

.search-overlay {
    position: fixed;
    top: calc(120px + var(--fr-im-chrome-top));
    left: 15px;
    right: 15px;
    bottom: 100px;
    background: var(--card-glass);
    backdrop-filter: blur(var(--blur-amount));
    border: 1px solid var(--card-border);
    border-radius: 20px;
    box-shadow: var(--shadow-md);
    opacity: 0;
    visibility: hidden;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), visibility 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), color 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), border-color 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 20;
    overflow: hidden;
}

.search-overlay.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1) translateY(0);
}

.inbox-overlay {
    position: fixed;
    top: calc(70px + var(--fr-im-chrome-top));
    left: 10px;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom, 0px));
    background: rgba(15, 23, 42, 0.94);
    border: 1px solid rgba(148, 163, 184, 0.6);
    border-radius: 20px;
    overflow: hidden;
    z-index: 23;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: transform 0.25s ease, opacity 0.25s ease, visibility 0.25s ease, background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
    box-shadow: var(--shadow-md);
}

.inbox-overlay.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.chat-open .inbox-overlay {
    display: none !important;
}

.inbox-results {
    height: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 0;
}

.inbox-results,
.search-results {
    scrollbar-width: thin;
    scrollbar-color: rgba(180, 200, 255, 0.45) rgba(0, 0, 0, 0.15);
}

.inbox-results::-webkit-scrollbar,
.search-results::-webkit-scrollbar {
    width: 7px;
}

.inbox-results::-webkit-scrollbar-track,
.search-results::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 20px;
}

.inbox-results::-webkit-scrollbar-thumb,
.search-results::-webkit-scrollbar-thumb {
    background: rgba(180, 200, 255, 0.45);
    border-radius: 20px;
    border: 2px solid rgba(0, 0, 0, 0.08);
}

.inbox-results::-webkit-scrollbar-thumb:hover,
.search-results::-webkit-scrollbar-thumb:hover {
    background: rgba(180, 200, 255, 0.65);
}

.inbox-meta {
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding-right: 14px;
    min-width: 44px;
    color: rgba(229, 236, 255, 0.75);
    font-size: 12px;
}

.inbox-time {
    margin-top: 2px;
}

.inbox-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
    transition: background 0.2s ease, transform 0.15s ease;
}

.inbox-close:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: scale(1.05);
}

.inbox-close:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.28);
}

.inbox-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.55);
    z-index: 22;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
}

.inbox-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.chat-open .inbox-backdrop {
    display: none !important;
}

.search-results {
    height: 100%;
    overflow-y: auto;
    padding: 20px;
}

.search-result-item {
    display: flex;
    align-items: center;
    padding: 15px;
    margin-bottom: 10px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 15px;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    position: relative;
    overflow: hidden;
    
}

.search-result-item:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: var(--reflection);
    transition: left 0.6s ease;
}

.search-result-item:hover:before {
    left: 100%;
}

.search-result-item:hover {
    background: var(--card-glass-hover);
    transform: translateY(-3px) scale(1.02);
    box-shadow: var(--shadow-glow), var(--shadow-md);
}

.search-result-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    margin-right: 15px;
    border: 2px solid var(--card-border);
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.search-result-content {
    flex: 1;
    min-width: 0;
}

.search-result-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 3px;
    font-size: 16px;
}

.search-result-preview {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-result-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.search-result-type {
    background: var(--button-gradient);
    color: var(--text-light);
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    box-shadow: var(--shadow-sm);
}

.search-result-time {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
}

.search-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-secondary);
}

.search-loading .loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(125, 177, 255, 0.2);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

.search-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-secondary);
    text-align: center;
}

.search-empty i {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.back-button:active {
    transform: translateY(-50%) scale(0.98);
}

.friends-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow: hidden;
    position: relative;
}

.friends-list-tabs {
    position: fixed;
    top: calc(var(--fr-im-header-h) + var(--fr-im-chrome-top));
    left: 0;
    right: 0;
    z-index: 9;
    display: flex;
    gap: 6px;
    padding: 4px 12px 0;
    height: var(--fr-im-tabs-h);
    box-sizing: border-box;
    background: var(--header-bg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.friends-list-tab {
    flex: 1;
    margin: 0;
    padding: 0 8px;
    min-height: 28px;
    border: none;
    border-radius: 8px 8px 0 0;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.82);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.friends-list-tab.active {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.friends-list-tab:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.65);
    outline-offset: -2px;
}

.chat-open .friends-list-tabs {
    display: none;
}

.friends-empty-hint {
    padding: 24px 16px;
    text-align: center;
    color: rgba(255, 255, 255, 0.75);
    font-size: 14px;
    line-height: 1.45;
}

.friends-list {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-top: calc(var(--fr-im-header-h) + var(--fr-im-tabs-h) + var(--fr-im-chrome-top) + 5px);
    padding-bottom: 30px; 
    scrollbar-width: none; 
    -ms-overflow-style: none; 
    overscroll-behavior: contain;
    scroll-behavior: smooth;
    transform: translateZ(0);
    will-change: transform;
    background: linear-gradient(
        180deg,
        rgba(3, 7, 18, 0.45) 0%,
        rgba(3, 7, 18, 0.25) 40%,
        rgba(3, 7, 18, 0.08) 100%
    );
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.friends-list::after {
    content: '';
    display: block;
    height: 20px;
    flex-shrink: 0;
}

.friend-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    margin: 8px 15px;
    border-radius: 15px;
    background: var(--card-glass);
    border: 1px solid var(--card-border);
    text-decoration: none;
    color: var(--text-primary);
    transition: transform 0.3s ease, background-color 0.3s ease, box-shadow 0.3s ease;
    animation: fadeIn 0.4s ease-out;
    opacity: 1;
    box-shadow: var(--shadow-sm), 0 1px 0 rgba(255, 255, 255, 0.8) inset;
    
    box-sizing: border-box;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.friend-item:hover {
    transform: translateY(-2px) translateZ(0);
    box-shadow: var(--shadow-md), 0 0 15px var(--accent-glow);
    background: var(--card-glass-hover);
}

.unread-badge {
    background: linear-gradient(135deg, #3a7bd5, #00d2ff);
    color: white;
    border-radius: 12px;
    min-width: 20px;
    height: 20px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    right: 15px;
    top: 15px;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    padding: 0 6px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    z-index: 2;
}

.friend-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: var(--reflection);
    opacity: 0.5;
    z-index: 0;
    pointer-events: none;
}

.friend-item:active {
    background-color: rgba(0, 0, 0, 0.05);
    transform: scale(0.98) translateZ(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) inset;
}

.friend-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin-right: 12px;
    object-fit: cover;
    background-color: #e4e6eb;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.6), 0 2px 5px rgba(0, 0, 0, 0.1);
    z-index: 1;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.friend-item:hover .friend-avatar {
    transform: scale(1.05);
    box-shadow: 0 0 0 2px var(--primary-light), 0 3px 8px rgba(0, 0, 0, 0.15);
}

.friend-info {
    flex: 1;
    min-width: 0; 
}

.friend-name {
    font-weight: 500;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.friend-status {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--offline);
    margin-right: 6px;
    flex-shrink: 0;
    display: inline-block;
    transition: background-color 0.3s ease;
}

.friend-item[data-online="true"] .status-indicator {
    background-color: var(--online) !important;
}

.friend-item[data-online="false"] .status-indicator {
    background-color: var(--offline) !important;
}

.status-indicator.online {
    background-color: var(--online) !important;
}

.friend-item .status-indicator.idle,
.friend-item[data-online="true"] .status-indicator.idle {
    background-color: #f59e0b !important;
}

.friend-item.has-unread {
    background: linear-gradient(135deg, rgba(255, 51, 51, 0.1) 0%, rgba(255, 102, 102, 0.05) 100%);
    border-left: 3px solid #ff3333;
    
    box-shadow: var(--shadow-md), 0 0 15px rgba(255, 51, 51, 0.4);
    display: flex !important; 
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 1;
    min-height: 60px; 
    color: var(--text-primary) !important; 
}

@keyframes unreadPulse {
    0%, 100% {
        box-shadow: var(--shadow-md), 0 0 10px rgba(255, 51, 51, 0.3);
    }
    50% {
        box-shadow: var(--shadow-md), 0 0 20px rgba(255, 51, 51, 0.5);
    }
}

.friend-item.has-unread:hover {
    transform: translateY(-2px) translateZ(0);
    box-shadow: var(--shadow-md), 0 0 25px rgba(255, 51, 51, 0.6);
    background: linear-gradient(135deg, rgba(255, 51, 51, 0.15) 0%, rgba(255, 102, 102, 0.08) 100%);
}

.friend-item.has-unread .friend-name,
.friend-item.has-unread .friend-status,
.friend-item.has-unread .status-text {
    color: var(--text-primary) !important;
    opacity: 1 !important;
}

.unread-count {
    background: linear-gradient(135deg, #ff3333, #ff6666);
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: bold;
    margin-left: 8px;
    display: inline-block;
    min-width: 18px;
    text-align: center;
    box-shadow: 0 0 5px rgba(255, 51, 51, 0.5);
    animation: badgePulse 1.5s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.friend-item {
    position: relative;
}

.friend-item::after {
    content: attr(data-last-active);
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 9px;
    padding: 2px 5px;
    border-radius: 3px;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.friend-item:hover::after {
    opacity: 1;
    visibility: visible;
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3) translateY(-50px);
    }
    50% {
        opacity: 1;
    visibility: visible;
        transform: scale(1.05) translateY(-10px);
    }
    70% {
        transform: scale(0.9) translateY(0);
    }
    100% {
        opacity: 1;
    visibility: visible;
        transform: scale(1) translateY(0);
    }
}

@keyframes slideInFromTop {
    0% {
        opacity: 0;
        transform: translateY(-30px);
    }
    100% {
        opacity: 1;
    visibility: visible;
        transform: translateY(0);
    }
}

@keyframes glowPulse {
    0%, 100% {
        box-shadow: var(--shadow-glow);
    }
    50% {
        box-shadow: var(--shadow-glow-strong);
    }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; visibility: visible; transform: translateY(0); }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; visibility: visible; transform: translateX(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; visibility: visible; transform: translateX(0); }
}

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; visibility: visible; }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.chat-view {
    display: none;
    flex-direction: column;
    height: 100%;
    background: radial-gradient(circle at top,
        rgba(3, 7, 18, 0.5) 0%,
        rgba(3, 7, 18, 0.35) 50%,
        rgba(0, 0, 0, 0.18) 100%
    );
    position: relative;
    flex: 1;
    overflow: hidden;
    box-shadow: inset 0 0 150px rgba(255, 255, 255, 0.15); 
}

.chat-messages {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: calc(var(--chat-input-offset, 80px) + env(safe-area-inset-bottom, 0px));
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    
    background-color: transparent;
}

.messages-scroll-container {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: calc(70px + var(--fr-im-chrome-top)) 15px 15px;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
    height: 100%;
    position: relative;
    
    scrollbar-width: none; 
    -ms-overflow-style: none; 
    transform: translateZ(0);
    will-change: transform;
}

.chat-messages::-webkit-scrollbar {
    display: none;
}

body:not(.is-touch) .messages-scroll-container,
body:not(.is-touch) .friends-list {
    scrollbar-width: thin; 
    scrollbar-color: rgba(180, 200, 255, 0.45) rgba(0, 0, 0, 0.18);
}

body:not(.is-touch) .messages-scroll-container::-webkit-scrollbar,
body:not(.is-touch) .friends-list::-webkit-scrollbar {
    display: block;
    width: 8px;
}

body:not(.is-touch) .messages-scroll-container::-webkit-scrollbar-track,
body:not(.is-touch) .friends-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 20px;
    margin: 4px 0;
}

body:not(.is-touch) .messages-scroll-container::-webkit-scrollbar-thumb,
body:not(.is-touch) .friends-list::-webkit-scrollbar-thumb {
    background: rgba(180, 200, 255, 0.45);
    border-radius: 20px;
    border: 2px solid rgba(0, 0, 0, 0.08);
    background-clip: padding-box;
}

body:not(.is-touch) .messages-scroll-container::-webkit-scrollbar-thumb:hover,
body:not(.is-touch) .friends-list::-webkit-scrollbar-thumb:hover {
    background: rgba(180, 200, 255, 0.7);
    background-clip: padding-box;
}

.im-date-divider {
    display: flex;
    align-items: center;
    margin: 18px 0 12px;
    user-select: none;
    pointer-events: none;
}

.im-date-divider::before,
.im-date-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(148, 163, 184, 0.45) 50%, transparent 100%);
}

.im-date-divider span {
    padding: 4px 14px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.load-older-btn {
    display: block;
    margin: 8px auto 12px;
    padding: 8px 20px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(148, 163, 184, 0.4);
    border-radius: 20px;
    color: var(--primary-light);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: transform 0.2s ease, opacity 0.2s ease, visibility 0.2s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.load-older-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.load-older-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.messages-container {
    display: flex;
    flex-direction: column;
    min-height: min-content;
    gap: 6px;
    padding-bottom: 8px;
}

.chat-input-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-glass);
    padding: 15px 20px;
    padding-bottom: calc(15px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid rgba(15, 23, 42, 0.95);
    z-index: 100;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.08), 0 1px 0 rgba(255, 255, 255, 0.8) inset;
    transform: translateZ(0);
    overflow: hidden;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px;
}

.chat-input-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 15px;
    background: var(--reflection);
    opacity: 0.5;
    pointer-events: none;
}

.message {
    max-width: 80%;
    margin-bottom: 6px;
    padding: 9px 14px;
    border-radius: 12px;
    position: relative;
    word-wrap: break-word;
    line-height: 1.35;
    animation: fadeIn 0.3s ease-out forwards;
    opacity: 1;
    transform-origin: center bottom;
    transition: transform 0.3s ease, opacity 0.3s ease, box-shadow 0.3s ease;
    
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25), 0 1px 2px rgba(255, 255, 255, 0.5) inset;
    border: 1px solid rgba(255, 255, 255, 0.7);
}

.message.call-notice {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #e8eefc;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
    margin: 10px auto;
    max-width: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
}

.message.call-notice::before {
    content: '📞';
    font-size: 16px;
    opacity: 0.9;
}

.message.call-notice .message-content {
    color: #e8eefc;
    font-weight: 600;
}

.message.sent {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.98) 0%, rgba(30, 64, 175, 0.9) 100%);
    color: var(--text-primary);
    border-top-right-radius: 2px;
    border-bottom-right-radius: 20px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.9), 0 0 18px var(--primary-glow), 0 1px 2px rgba(255, 255, 255, 0.5) inset;
    animation: slideInRight 0.3s ease-out;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(191, 219, 254, 0.95);
    margin-left: 20%;
}

.message.sent::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0.1) 70%, rgba(255, 255, 255, 0) 100%);
    opacity: 0.7;
    pointer-events: none;
    border-radius: inherit;
}

.message.received {
    align-self: flex-start;
    background: linear-gradient(
        135deg,
        rgba(30, 64, 175, 0.98) 0%,
        rgba(37, 150, 221, 0.96) 45%,
        rgba(88, 80, 236, 0.98) 100%
    );
    color: var(--text-light);
    margin-right: 20%;
    margin-left: 0;
    border-bottom-left-radius: 20px;
    animation: slideInLeft 0.3s ease-out;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.9), 0 0 18px var(--primary-glow);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), visibility 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), color 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), border-color 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(191, 219, 254, 0.95);
    font-weight: 600;
    letter-spacing: 0.2px;
    position: relative;
    padding: 12px 15px;
    overflow: hidden;
}

.message.received::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0.1) 70%, rgba(255, 255, 255, 0) 100%);
    opacity: 0.7;
    pointer-events: none;
    border-radius: inherit;
}

.message-content {
    word-break: break-word;
    white-space: pre-wrap;
    margin: 0;
    padding: 0;
}

.message-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

.message-reactions {
    margin-right: auto;
}

.message-link-previews {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.link-preview-card {
    position: relative;
    display: flex;
    cursor: pointer;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid rgba(148, 163, 184, 0.65);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    max-width: 100%;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.link-preview-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
    background: rgba(255, 255, 255, 0.95);
}

.link-preview-card.link-preview-loading {
    opacity: 0.8;
}

.link-preview-card.link-preview-failed {
    background: rgba(15, 23, 42, 0.9);
    border-style: dashed;
    color: var(--text-secondary);
    font-size: 0.8rem;
    padding: 6px 8px;
}

.link-preview-inner {
    display: flex;
    flex-direction: row;
    width: 100%;
}

.link-preview-thumb {
    flex: 0 0 96px;
    max-width: 96px;
    background: #020617;
    border-right: 1px solid rgba(15, 23, 42, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
}

.link-preview-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.link-preview-body {
    flex: 1;
    padding: 8px 10px;
    min-width: 0;
}

.link-preview-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-preview-description {
    font-size: 0.75rem;
    color: var(--text-secondary);
    max-height: 2.2em;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-preview-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
}

.link-preview-favicon {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

.link-preview-domain {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.link-preview-youtube .link-preview-thumb-youtube {
    position: relative;
    width: 100%;
    padding-top: 56.25%; 
    background: #000;
    overflow: hidden;
}

.link-preview-thumb-youtube img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.link-preview-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #fff 0%, #ddd 40%, #c00 100%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.link-preview-play::before {
    content: '';
    position: absolute;
    left: 52%;
    top: 50%;
    transform: translate(-40%, -50%);
    border-style: solid;
    border-width: 8px 0 8px 14px;
    border-color: transparent transparent transparent #c00;
}

.link-preview-youtube .link-preview-body {
    padding: 6px 8px 8px;
}

.link-preview-youtube .link-preview-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-preview-embed {
    position: relative;
    width: 100%;
    padding-top: 56.25%; 
}

.link-preview-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 12px;
}

.message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.reaction-chip {
    border: none;
    outline: none;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    color: #2c3e50;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.reaction-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    background: rgba(255, 255, 255, 0.9);
}

.reaction-chip-me {
    background: linear-gradient(135deg, #5d8bf4, #7fa8ff);
    color: #ffffff;
    box-shadow: 0 0 8px var(--primary-glow);
}

.message-time {
    font-size: 0.7rem;
    margin-top: 8px;
    color: rgba(148, 163, 184, 0.95);
    align-self: flex-end;
    font-weight: 500;
    letter-spacing: 0.3px;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

.message-meta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.message-status {
    font-size: 0.65rem;
    opacity: 0.85;
    color: rgba(148, 163, 184, 0.95);
}

.message.sent .message-status {
    color: rgba(255, 255, 255, 0.85);
}

.reaction-picker {
    position: absolute;
    bottom: 100%;
    left: 0;
    transform: translateY(-6px);
    background: rgba(0, 0, 0, 0.8);
    border-radius: 999px;
    padding: 4px 8px;
    display: flex;
    gap: 4px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    z-index: 5;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.reaction-picker.reaction-picker-floating {
    position: fixed;
    bottom: auto;
    transform: none;
    z-index: 10050;
    flex-direction: column;
    align-items: stretch;
    border-radius: 12px;
    padding: 6px 8px;
    gap: 6px;
}

.reaction-emoji-row {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
}

.message-action-row {
    display: flex;
    gap: 6px;
    justify-content: center;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.message-action-btn {
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 8px;
    cursor: pointer;
}

.message-action-btn-danger {
    background: rgba(251, 113, 133, 0.35);
}

.message-deleted-text {
    font-style: italic;
    opacity: 0.75;
}

.message-edited-tag {
    font-size: 10px;
    opacity: 0.7;
    margin-right: 4px;
    text-transform: lowercase;
}

.message-edit-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex: 0 0 100%;
    width: 100%;
    box-sizing: border-box;
    padding: 6px 10px;
    margin-bottom: 6px;
    background: rgba(79, 70, 229, 0.35);
    border: 1px solid rgba(129, 140, 248, 0.45);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-primary);
}

.message-edit-banner .message-edit-cancel {
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: inherit;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    cursor: pointer;
}

.message-reply-quote {
    position: relative;
    z-index: 2;
    margin: 0 0 8px 0;
    padding: 6px 10px 6px 11px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.14);
    border-left: 3px solid var(--accent, #64e0ff);
    cursor: pointer;
    max-width: 100%;
    overflow: hidden;
    transition: background 0.15s ease;
}

.message-reply-quote:hover {
    background: rgba(255, 255, 255, 0.24);
}

.message.sent .message-reply-quote {
    background: rgba(0, 0, 0, 0.24);
}

.message.sent .message-reply-quote:hover {
    background: rgba(0, 0, 0, 0.34);
}

.reply-quote-author {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent, #64e0ff);
    margin-bottom: 1px;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-quote-text {
    font-size: 12px;
    line-height: 1.35;
    opacity: 0.92;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-quote-text.reply-quote-deleted {
    font-style: italic;
    opacity: 0.7;
}

.message.message-quote-flash {
    animation: frQuoteFlash 1.2s ease-out;
}

@keyframes frQuoteFlash {
    0%   { box-shadow: 0 0 0 2px var(--accent, #64e0ff), 0 0 22px var(--accent-glow, rgba(100, 224, 255, 0.7)); }
    100% { box-shadow: 0 12px 32px rgba(0, 0, 0, 0.9); }
}

.message-reply-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 100%;
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    margin: 0 0 2px 0;
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid rgba(129, 140, 248, 0.45);
    border-radius: 10px;
    color: var(--text-primary, #fff);
}

.message-reply-banner .reply-banner-accent {
    width: 3px;
    align-self: stretch;
    border-radius: 3px;
    background: var(--accent, #64e0ff);
    flex: 0 0 auto;
}

.message-reply-banner .reply-banner-info {
    flex: 1 1 auto;
    min-width: 0;
}

.message-reply-banner .reply-banner-author {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent, #64e0ff);
}

.message-reply-banner .reply-banner-text {
    font-size: 12px;
    opacity: 0.9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-reply-banner .reply-banner-cancel {
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: inherit;
    font-size: 13px;
    line-height: 1;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    flex: 0 0 auto;
}

.message-reply-banner .reply-banner-cancel:hover {
    background: rgba(255, 255, 255, 0.28);
}

html[data-chat-theme="myspace"] .message .message-reply-quote,
html[data-chat-theme="aim"] .message .message-reply-quote,
html[data-chat-theme="myspace"] .message.sent .message-reply-quote,
html[data-chat-theme="aim"] .message.sent .message-reply-quote {
    background: rgba(0, 0, 51, 0.07) !important;
    border-left-color: #003399 !important;
}

html[data-chat-theme="myspace"] .message .message-reply-quote:hover,
html[data-chat-theme="aim"] .message .message-reply-quote:hover,
html[data-chat-theme="myspace"] .message.sent .message-reply-quote:hover,
html[data-chat-theme="aim"] .message.sent .message-reply-quote:hover {
    background: rgba(0, 0, 51, 0.13) !important;
}

html[data-chat-theme="myspace"] .reply-quote-author,
html[data-chat-theme="aim"] .reply-quote-author {
    color: #003399 !important;
    text-shadow: none !important;
}

html[data-chat-theme="myspace"] .reply-quote-text,
html[data-chat-theme="aim"] .reply-quote-text {
    color: inherit !important;
}

html[data-chat-theme="myspace"] .message-reply-banner,
html[data-chat-theme="aim"] .message-reply-banner {
    background: #ffffff !important;
    border: 1px solid #003399 !important;
    color: #111111 !important;
    border-radius: 4px !important;
}

html[data-chat-theme="myspace"] .message-reply-banner .reply-banner-accent,
html[data-chat-theme="aim"] .message-reply-banner .reply-banner-accent {
    background: #003399 !important;
}

html[data-chat-theme="myspace"] .message-reply-banner .reply-banner-author,
html[data-chat-theme="aim"] .message-reply-banner .reply-banner-author {
    color: #003399 !important;
}

html[data-chat-theme="myspace"] .message-reply-banner .reply-banner-cancel,
html[data-chat-theme="aim"] .message-reply-banner .reply-banner-cancel {
    background: rgba(0, 0, 0, 0.1) !important;
    color: #111111 !important;
}

html[data-chat-theme="facebook"] .message .message-reply-quote,
html[data-chat-theme="facebook"] .message.sent .message-reply-quote {
    background: rgba(59, 89, 152, 0.08) !important;
    border-left-color: #3b5998 !important;
}

html[data-chat-theme="facebook"] .message .message-reply-quote:hover,
html[data-chat-theme="facebook"] .message.sent .message-reply-quote:hover {
    background: rgba(59, 89, 152, 0.15) !important;
}

html[data-chat-theme="facebook"] .reply-quote-author {
    color: #3b5998 !important;
    text-shadow: none !important;
}

html[data-chat-theme="facebook"] .reply-quote-text {
    color: inherit !important;
}

html[data-chat-theme="facebook"] .message-reply-banner {
    background: #ffffff !important;
    border: 1px solid #bdc7d8 !important;
    color: #141823 !important;
    border-radius: 4px !important;
}

html[data-chat-theme="facebook"] .message-reply-banner .reply-banner-accent {
    background: #3b5998 !important;
}

html[data-chat-theme="facebook"] .message-reply-banner .reply-banner-author {
    color: #3b5998 !important;
}

html[data-chat-theme="facebook"] .message-reply-banner .reply-banner-cancel {
    background: rgba(0, 0, 0, 0.08) !important;
    color: #141823 !important;
}

.reaction-option {
    border: none;
    background: transparent;
    color: #ffffff;
    font-size: 18px;
    padding: 2px 4px;
    cursor: pointer;
    line-height: 1;
}

.reaction-option:hover {
    transform: translateY(-1px) scale(1.1);
}

.message.received .message-time {
    color: rgba(148, 163, 184, 0.95);
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.8);
    font-weight: 500;
}

.message.sent .message-time {
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.9);
    font-weight: 500;
}

.typing-dots span {
    display: inline-block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: currentColor;
    margin: 0 1px;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-4px); }
}

.typing-indicator {
    align-self: flex-start;
    background-color: var(--card-bg);
    padding: 8px 12px;
    border-radius: 18px;
    margin-bottom: 0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    font-style: italic;
    color: var(--text-secondary);
    font-size: 0.9rem;
    animation: fadeIn 0.3s ease-out, float 3s ease-in-out infinite;
    transform-origin: left center;
    opacity: 1;
    animation-fill-mode: forwards;
    display: inline-flex;
    align-items: center;
    will-change: transform, opacity;
    backface-visibility: hidden;
    position: fixed;
    left: 15px;
    bottom: calc(var(--chat-input-offset, 80px) + env(safe-area-inset-bottom, 0px) + 10px);
    z-index: 10000;
    max-width: calc(100% - 30px);
    pointer-events: none;
}

.send-button {
    background: var(--button-gradient);
    color: var(--text-light);
    border: 1px solid rgba(255, 255, 255, 0.5);
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    flex-shrink: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1), color 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(255, 255, 255, 0.3) inset;
    position: relative;
    overflow: hidden;
    animation: float 6s ease-in-out infinite;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.send-button:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 5px 15px rgba(93, 139, 244, 0.3), 0 0 20px var(--primary-glow);
}

.send-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: var(--reflection);
    opacity: 0.7;
    pointer-events: none;
}

.send-button:disabled {
    background: rgba(100, 116, 139, 0.4);
    opacity: 0.5;
    cursor: not-allowed;
    animation: none;
    box-shadow: none;
}

.send-button:active {
    transform: scale(0.95);
    box-shadow: 0 2px 5px rgba(93, 139, 244, 0.2), 0 0 5px var(--primary-glow);
}

.send-button:active::after {
    animation: ripple 1s ease-out;
}

body.keyboard-visible .chat-messages {
    padding-bottom: 120px;
}

body.keyboard-visible .chat-input-container {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
}

.message.sent.message-failed {
    cursor: pointer;
}

.message.sent.message-failed .message-content {
    background: rgba(220, 38, 38, 0.18) !important;
    border: 1px dashed rgba(220, 38, 38, 0.65) !important;
    box-shadow: none;
}

.message.sent.message-failed .message-status {
    color: #dc2626 !important;
    font-weight: 700;
}

.chat-header-profile-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    max-width: 100%;
    color: inherit;
    text-decoration: none;
    position: relative;
    z-index: 1;
}

.chat-header-profile-link:hover,
.chat-header-profile-link:focus {
    color: inherit;
    text-decoration: none;
    opacity: 0.92;
}

.chat-header-profile-link .header-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.input-wrapper {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    display: flex;
}

.message-input {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    padding: 10px 15px 10px 76px;
    margin-right: 0;
    font-size: 0.95rem;
    resize: none;
    background-color: rgba(255, 255, 255, 0.9);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1), color 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    max-height: 100px;
    min-height: 42px;
    overflow-y: auto;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1), 0 1px 0 rgba(255, 255, 255, 0.9) inset;
    color: #000000;
    font-weight: bold;
    z-index: 101;
    opacity: 1;
    visibility: visible;
    display: block;
    font-family: inherit;
}

.message-input::placeholder {
    color: #666666;
    font-weight: normal;
    opacity: 1;
    visibility: visible;
}

body.chat-open .search-overlay {
    bottom: 110px !important; 
}
.message-input,
.message-input:focus {
    color: #000000 !important;
}

.message-input:focus {
    border-color: var(--primary-light);
    background-color: rgba(255, 255, 255, 0.85);
    box-shadow: 0 0 0 2px var(--primary-glow), 0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

@keyframes ripple {
    0% {
        transform: scale(0, 0);
        opacity: 0.5;
    }
    100% {
        transform: scale(20, 20);
        opacity: 0;
    }
}

.loading {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 10px;
    height: 100%;
    color: var(--text-secondary);
}

.loading-spinner {
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top: 3px solid var(--primary-color);
    width: 24px;
    height: 24px;
    animation: spin 0.8s cubic-bezier(0.5, 0, 0.5, 1) infinite, pulse 1.5s ease-in-out infinite alternate;
    will-change: auto;
    backface-visibility: hidden;
    transform: translateZ(0);
}

.empty-state {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 15px;
}

.friend-group-header {
    padding: 10px 20px;
    margin: 10px 15px 5px;
    font-weight: 600;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 10px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.friend-group-header.collapsible {
    cursor: pointer;
    user-select: none;
    transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s ease, background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
}

.friend-group-header.collapsible:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
}

.friend-group-header.collapsible:active {
    transform: translateY(0);
}

.friend-group-header .header-text {
    display: flex;
    align-items: center;
    gap: 8px;
}

.friend-group-header .collapse-icon {
    display: inline-block;
    transition: transform 0.3s ease;
    font-size: 12px;
    width: 12px;
}

.offline-friends-container {
    transition: opacity 0.2s ease;
    overflow: hidden;
    max-height: none;
    opacity: 1;
}

.offline-friends-container.collapsed {
    max-height: 0;
    opacity: 0;
    margin-bottom: 0;
}

.offline-friends-container .loading {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}

.chat-header .header-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 8px;
    vertical-align: middle;
}
.chat-header .header-name {
    vertical-align: middle;
    font-weight: 600;
}

@media (max-width: 480px) {
    .chat-header h1 {
        font-size: 1.1rem;
    }
    
    .friend-item {
        padding: 10px 12px;
    }
    
    .friend-avatar {
        width: 44px;
        height: 44px;
    }
    
    .message {
        max-width: 85%;
    }
    
    .message-input {
        font-size: 0.95rem;
    }
}

.search-interface {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 25;
    padding: 10px 15px 8px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    background: var(--card-glass);
    backdrop-filter: blur(var(--blur-amount));
    -webkit-backdrop-filter: blur(var(--blur-amount));
    border-top: 1px solid var(--card-border);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s ease, opacity 0.3s ease;
}
.search-interface.active {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.search-input-container {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 5px 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

#searchInput {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 1rem;
    color: var(--text-primary);
}

#searchClear {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #666;
    font-size: 1.2rem;
    cursor: pointer;
}

.search-filters {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.filter-button {
    flex: 1;
    padding: 6px 10px;
    font-size: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    white-space: nowrap;
}

.filter-button:hover {
    background: rgba(255, 255, 255, 0.14);
}

.filter-button.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #4a7dff;
        --primary-light: #6b9aff;
        --primary-glow: rgba(74, 125, 255, 0.4);
        --background: linear-gradient(135deg, #1a1b2e 0%, #24243e 100%);
        --card-bg: rgba(36, 37, 38, 0.8);
        --card-glass: rgba(36, 37, 38, 0.6);
        --card-border: rgba(255, 255, 255, 0.1);
        --text-primary: #e4e6eb;
        --text-secondary: #b0b3b8;
        --border: rgba(255, 255, 255, 0.1);
        --outgoing-msg: linear-gradient(135deg, #4a7dff 0%, #6b9aff 100%);
        --incoming-msg: rgba(58, 59, 60, 0.8);
        --online: #2ecc71;
        --offline: #6b6e71;
        --shadow-sm: 0 4px 15px rgba(0, 0, 0, 0.2);
        --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.3);
    }

    .message-input {
        background-color: #3a3b3c;
        color: var(--text-primary);
        border-color: var(--border);
    }

    .typing-indicator {
        background-color: var(--card-bg);
        color: var(--text-secondary);
    }
}

@keyframes auroraDrift {
    0% {
        opacity: 0.78;
        transform: translate3d(-1.8%, -0.4%, 0) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translate3d(2.2%, 0.9%, 0) scale(1.07);
    }
}

html[data-chat-theme="frutiger-max"] {
    --primary-color: #8ecbff;
    --primary-light: #e0f4ff;
    --primary-dark: #4f73ff;
    --primary-glow: rgba(100, 210, 255, 0.88);
    --primary-glow-strong: rgba(198, 240, 255, 0.96);
    --accent: #4fffea;
    --accent-glow: rgba(94, 255, 239, 0.78);
    --background:
        radial-gradient(ellipse 90% 60% at 50% -5%, rgba(56, 189, 248, 0.5) 0%, transparent 55%),
        radial-gradient(circle at 100% 15%, rgba(167, 139, 250, 0.45) 0%, transparent 52%),
        radial-gradient(circle at 5% 75%, rgba(14, 165, 233, 0.4) 0%, transparent 50%),
        linear-gradient(200deg, #020617 0%, #0c1224 42%, #0b1120 100%);
    --header-bg:
        linear-gradient(
            128deg,
            rgba(56, 189, 248, 0.45) 0%,
            rgba(59, 130, 246, 0.55) 22%,
            rgba(109, 40, 217, 0.48) 58%,
            rgba(34, 211, 238, 0.4) 100%
        ),
        linear-gradient(180deg, rgba(240, 249, 255, 0.08) 0%, rgba(2, 6, 23, 0.82) 100%);
    --outgoing-msg: linear-gradient(135deg, #1d4ed8 0%, #4338ca 38%, #0ea5e9 100%);
    --button-gradient: linear-gradient(135deg, #6366f1 0%, #3b82f6 42%, #22d3ee 100%, #67e8f9 112%);
    --card-bg: rgba(15, 23, 42, 0.72);
    --card-glass: rgba(26, 45, 90, 0.48);
    --card-glass-hover: rgba(43, 70, 130, 0.62);
    --card-border: rgba(147, 197, 253, 0.55);
    --blur-amount: 26px;
    --text-primary: #f0f9ff;
    --text-secondary: #a9c6e8;
    --text-on-primary: #ffffff;
    --text-light: rgba(255, 255, 255, 0.99);
    --border: rgba(56, 189, 248, 0.35);
    --incoming-msg: rgba(26, 45, 90, 0.65);
    --online: #4ade80;
    --offline: #7c9cbf;
    --error: #fb7185;
    --shadow-sm:
        0 4px 18px rgba(0, 0, 30, 0.55),
        0 0 24px rgba(56, 189, 248, 0.2),
        0 2px rgba(186, 230, 253, 0.2) inset;
    --shadow-md:
        0 18px 48px rgba(0, 0, 38, 0.68),
        0 8px 32px rgba(99, 102, 241, 0.22),
        0 12px 40px rgba(14, 165, 233, 0.12);
    --shadow-inner: inset 0 2px 12px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.38);
    --shadow-glow: 0 0 26px rgba(56, 189, 248, 0.6), 0 0 50px rgba(129, 140, 248, 0.28);
    --shadow-glow-strong: 0 0 40px rgba(56, 189, 248, 0.75), 0 0 80px rgba(167, 139, 250, 0.32);
    --reflection: linear-gradient(180deg, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0.06) 45%, rgba(255, 255, 255, 0) 70%);
}

html[data-chat-theme="frutiger-max"] body {
    background-color: #020617;
    background-image:
        linear-gradient(to bottom,
            rgba(186, 230, 253, 0.16) 0%,
            rgba(15, 23, 42, 0.35) 40%,
            rgba(51, 65, 199, 0.12) 100%),
        radial-gradient(circle at 92% -8%, rgba(167, 139, 250, 0.4), transparent 56%),
        radial-gradient(circle at 12% 88%, rgba(14, 165, 233, 0.32), transparent 48%),
        url('Dark%20Gradient%20(10).webp');
    background-position: center center, center center, center center, center center;
    background-size: cover;
    background-attachment: scroll; 
    background-repeat: no-repeat, no-repeat, no-repeat, no-repeat;
}

html[data-chat-theme="frutiger-max"] body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse at 42% -5%, rgba(186, 230, 253, 0.35), transparent 50%),
        radial-gradient(circle at 112% 40%, rgba(167, 139, 250, 0.32), transparent 46%),
        radial-gradient(circle at -18% 90%, rgba(34, 211, 238, 0.25), transparent 44%);
    animation: auroraDrift 20s ease-in-out infinite alternate;
    filter: saturate(1.25) hue-rotate(7deg);
    opacity: 0.95;
}

html[data-chat-theme="frutiger-max"] .chat-container {
    box-shadow:
        0 0 0 1px rgba(147, 197, 253, 0.28),
        0 0 80px rgba(56, 189, 248, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

html[data-chat-theme="frutiger-max"] .chat-header {
    box-shadow:
        0 12px 40px rgba(0, 0, 38, 0.72),
        0 4px 24px rgba(56, 189, 248, 0.25),
        0 2px rgba(240, 249, 255, 0.35) inset,
        inset 0 -1px rgba(139, 92, 246, 0.2);
    backdrop-filter: blur(18px) saturate(1.45);
    -webkit-backdrop-filter: blur(18px) saturate(1.45);
    border-bottom: 1px solid rgba(186, 230, 253, 0.55);
    text-shadow: 0 1px 2px rgba(0, 0, 20, 0.45), 0 0 28px rgba(56, 189, 248, 0.45);
}

html[data-chat-theme="frutiger-max"] .chat-header::before {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.42) 0%, rgba(255, 255, 255, 0.06) 38%, rgba(2, 6, 23, 0.15) 100%),
        linear-gradient(
            90deg,
            rgba(167, 139, 250, 0.12) 0%,
            rgba(56, 189, 248, 0.08) 50%,
            rgba(147, 197, 253, 0.14) 100%
        );
    pointer-events: none;
}

html[data-chat-theme="frutiger-max"] .chat-header h1 {
    text-shadow:
        0 1px 2px rgba(0, 0, 35, 0.55),
        0 2px 12px rgba(14, 165, 233, 0.5),
        0 0 24px rgba(167, 139, 250, 0.35);
}

html[data-chat-theme="frutiger-max"] .back-button {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(186, 230, 253, 0.55);
    backdrop-filter: blur(12px) saturate(1.2);
    -webkit-backdrop-filter: blur(12px) saturate(1.2);
    box-shadow:
        0 4px 14px rgba(0, 0, 38, 0.35),
        0 0 14px rgba(56, 189, 248, 0.2),
        0 1px 0 rgba(255, 255, 255, 0.45) inset;
}

html[data-chat-theme="frutiger-max"] .search-toggle,
html[data-chat-theme="frutiger-max"] .inbox-toggle {
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(186, 230, 253, 0.5);
    backdrop-filter: blur(14px) saturate(1.25);
    -webkit-backdrop-filter: blur(14px) saturate(1.25);
    box-shadow: 0 2px 10px rgba(0, 0, 38, 0.28), 0 1px 0 rgba(255, 255, 255, 0.38) inset;
}

html[data-chat-theme="frutiger-max"] .friends-list {
    background:
        linear-gradient(
            165deg,
            rgba(56, 189, 248, 0.12) 0%,
            rgba(3, 7, 18, 0.38) 42%,
            rgba(88, 28, 135, 0.1) 100%
        ),
        linear-gradient(
            180deg,
            rgba(3, 7, 18, 0.38) 0%,
            rgba(3, 7, 18, 0.18) 40%,
            rgba(3, 7, 18, 0.04) 100%
        );
    backdrop-filter: blur(6px) saturate(1.2);
    -webkit-backdrop-filter: blur(6px) saturate(1.2);
}

html[data-chat-theme="frutiger-max"] .friend-item {
    box-shadow:
        0 4px 18px rgba(0, 0, 30, 0.55),
        0 0 28px rgba(56, 189, 248, 0.26),
        0 1px rgba(240, 249, 255, 0.55) inset;
    
}

html[data-chat-theme="frutiger-max"] .unread-badge {
    background: linear-gradient(135deg, #22d3ee, #6366f1);
}

html[data-chat-theme="frutiger-max"] .chat-view {
    background:
        radial-gradient(ellipse 85% 45% at 50% -5%, rgba(56, 189, 248, 0.2) 0%, transparent 58%),
        radial-gradient(circle at 106% 30%, rgba(167, 139, 250, 0.16) 0%, transparent 48%),
        radial-gradient(circle at -6% 75%, rgba(14, 165, 233, 0.12) 0%, transparent 45%),
        radial-gradient(circle at 50% 50%,
            rgba(3, 7, 18, 0.42) 0%,
            rgba(3, 7, 18, 0.28) 52%,
            rgba(0, 0, 0, 0.12) 100%
        );
    box-shadow:
        inset 0 0 120px rgba(186, 230, 253, 0.12),
        inset 0 -60px 100px rgba(99, 102, 241, 0.08),
        inset 0 2px rgba(255, 255, 255, 0.05);
}

html[data-chat-theme="frutiger-max"] .chat-input-container {
    background: linear-gradient(
        160deg,
        rgba(56, 189, 248, 0.12) 0%,
        var(--card-glass) 42%,
        rgba(167, 139, 250, 0.1) 100%
    );
    border-top: 1px solid rgba(147, 197, 253, 0.45);
    backdrop-filter: blur(22px) saturate(1.25);
    -webkit-backdrop-filter: blur(22px) saturate(1.25);
    box-shadow:
        0 -12px 40px rgba(0, 0, 38, 0.45),
        0 -4px 24px rgba(56, 189, 248, 0.14),
        0 1px rgba(255, 255, 255, 0.35) inset;
}

html[data-chat-theme="frutiger-max"] .message {
    
    box-shadow:
        0 8px 22px rgba(0, 0, 38, 0.4),
        0 2px rgba(240, 249, 255, 0.45) inset;
    border: 1px solid rgba(186, 230, 253, 0.65);
}

html[data-chat-theme="frutiger-max"] .message.sent {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.25) 0%, transparent 48%),
        var(--outgoing-msg);
    box-shadow:
        0 16px 32px rgba(0, 0, 42, 0.72),
        0 0 32px var(--primary-glow),
        0 1px rgba(255, 255, 255, 0.55) inset;
    text-shadow:
        0 1px 2px rgba(0, 0, 42, 0.75),
        0 0 12px rgba(56, 189, 248, 0.45);
}

html[data-chat-theme="frutiger-max"] .message.received {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.38) 0%, rgba(255, 255, 255, 0.05) 42%, transparent 72%),
        linear-gradient(
            132deg,
            rgba(94, 234, 212, 0.45) 0%,
            rgba(59, 130, 246, 0.75) 36%,
            rgba(139, 92, 246, 0.72) 70%,
            rgba(56, 189, 248, 0.55) 100%
        );
    box-shadow:
        0 16px 32px rgba(0, 0, 42, 0.72),
        0 0 38px rgba(56, 189, 248, 0.35),
        inset 0 1px rgba(255, 255, 255, 0.35);
}

html[data-chat-theme="frutiger-max"] .typing-indicator {
    background: linear-gradient(
        135deg,
        rgba(56, 189, 248, 0.12) 0%,
        var(--card-bg) 40%,
        rgba(167, 139, 250, 0.1) 100%
    );
    box-shadow: 0 4px 18px rgba(0, 0, 38, 0.35), 0 0 20px rgba(56, 189, 248, 0.15);
    border: 1px solid rgba(147, 197, 253, 0.35);
}

html[data-chat-theme="frutiger-max"] .send-button {
    border: 1px solid rgba(240, 249, 255, 0.65);
    box-shadow:
        0 6px 20px rgba(0, 0, 42, 0.4),
        0 0 28px rgba(56, 189, 248, 0.45),
        0 0 42px rgba(167, 139, 250, 0.2),
        0 1px 5px rgba(255, 255, 255, 0.5) inset;
    animation: float 6s ease-in-out infinite, glowPulse 3.2s ease-in-out infinite;
    backdrop-filter: blur(12px) saturate(1.3);
    -webkit-backdrop-filter: blur(12px) saturate(1.3);
}

html[data-chat-theme="frutiger-max"] .send-button:hover {
    box-shadow:
        0 10px 28px rgba(99, 102, 241, 0.4),
        0 0 36px var(--primary-glow),
        0 0 60px rgba(56, 189, 248, 0.35),
        0 1px 5px rgba(255, 255, 255, 0.55) inset;
}

html[data-chat-theme="frutiger-max"] .filter-button.active {
    background: linear-gradient(135deg, #6366f1 0%, #3b82f6 52%, #22d3ee 100%);
    border-color: rgba(186, 230, 253, 0.7);
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.35), 0 1px rgba(255, 255, 255, 0.35) inset;
}

html[data-chat-theme="frutiger-max"] .friend-group-header {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.22) 0%, rgba(167, 139, 250, 0.16) 100%);
    backdrop-filter: blur(14px) saturate(1.2);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
    border: 1px solid rgba(186, 230, 253, 0.45);
    box-shadow: 0 4px 16px rgba(0, 0, 38, 0.28), 0 1px rgba(255, 255, 255, 0.28) inset;
}

html[data-chat-theme="frutiger-max"] .chat-theme-option.active {
    border-color: rgba(125, 211, 252, 0.7);
    background: rgba(56, 189, 248, 0.12);
    box-shadow: inset 0 0 0 1px rgba(125, 211, 252, 0.45), 0 0 24px rgba(56, 189, 248, 0.2);
}

@media (prefers-color-scheme: dark) {
    html[data-chat-theme="frutiger-max"] {
        --primary-color: #7ec8ff;
        --primary-light: #e8f7ff;
        --primary-dark: #3b74ff;
        --primary-glow: rgba(56, 189, 248, 0.55);
        --primary-glow-strong: rgba(198, 240, 255, 0.85);
        --accent-glow: rgba(94, 255, 239, 0.55);
        --background:
            radial-gradient(ellipse 90% 60% at 50% -5%, rgba(56, 189, 248, 0.42) 0%, transparent 55%),
            radial-gradient(circle at 100% 15%, rgba(139, 92, 246, 0.38) 0%, transparent 52%),
            radial-gradient(circle at 5% 75%, rgba(14, 165, 233, 0.32) 0%, transparent 50%),
            linear-gradient(200deg, #01040f 0%, #060b1a 42%, #050a18 100%);
        --header-bg:
            linear-gradient(
                128deg,
                rgba(34, 160, 220, 0.38) 0%,
                rgba(45, 100, 230, 0.48) 22%,
                rgba(99, 50, 200, 0.42) 58%,
                rgba(20, 180, 210, 0.35) 100%
            ),
            linear-gradient(180deg, rgba(230, 248, 255, 0.06) 0%, rgba(2, 6, 18, 0.88) 100%);
        --outgoing-msg: linear-gradient(135deg, #1e40af 0%, #4c1d95 38%, #0284c7 100%);
        --button-gradient: linear-gradient(135deg, #4f46e5 0%, #2563eb 42%, #06b6d4 100%, #5eead4 112%);
        --card-bg: rgba(10, 18, 40, 0.78);
        --card-glass: rgba(20, 35, 72, 0.55);
        --card-glass-hover: rgba(38, 62, 120, 0.62);
        --card-border: rgba(120, 180, 255, 0.42);
        --border: rgba(56, 189, 248, 0.32);
        --incoming-msg: rgba(22, 40, 88, 0.68);
        --text-primary: #e8f4ff;
        --text-secondary: #9fb8dc;
        --online: #34d399;
        --offline: #7c9cbf;
        --shadow-sm:
            0 4px 18px rgba(0, 0, 25, 0.62),
            0 0 22px rgba(56, 189, 248, 0.16),
            0 2px rgba(186, 230, 253, 0.14) inset;
        --shadow-md:
            0 18px 48px rgba(0, 0, 32, 0.75),
            0 8px 32px rgba(99, 102, 241, 0.2),
            0 12px 40px rgba(14, 165, 233, 0.12);
        --shadow-glow: 0 0 26px rgba(56, 189, 248, 0.5), 0 0 52px rgba(129, 140, 248, 0.22);
        --shadow-glow-strong: 0 0 36px rgba(56, 189, 248, 0.65), 0 0 76px rgba(167, 139, 250, 0.28);
    }

    html[data-chat-theme="frutiger-max"] .message-input {
        background-color: rgba(15, 25, 48, 0.92);
        color: var(--text-primary);
        border-color: rgba(120, 180, 255, 0.45);
        font-weight: 600;
        box-shadow: 0 2px 16px rgba(0, 0, 38, 0.45), 0 1px 0 rgba(255, 255, 255, 0.08) inset;
    }

    html[data-chat-theme="frutiger-max"] .message-input::placeholder {
        color: #8aa4c8;
    }

    html[data-chat-theme="frutiger-max"] .message-input,
    html[data-chat-theme="frutiger-max"] .message-input:focus {
        color: var(--text-primary) !important;
    }

    html[data-chat-theme="frutiger-max"] .message-input:focus {
        background-color: rgba(20, 32, 58, 0.95);
        border-color: var(--primary-light);
        box-shadow: 0 0 0 2px var(--primary-glow), 0 1px 0 rgba(255, 255, 255, 0.1) inset;
    }

    html[data-chat-theme="frutiger-max"] .typing-indicator {
        background: linear-gradient(
            135deg,
            rgba(56, 189, 248, 0.12) 0%,
            var(--card-bg) 40%,
            rgba(167, 139, 250, 0.1) 100%
        );
        color: var(--text-secondary);
    }
}

.call-button {
    position: absolute;
    right: 70px; 
    top: 50%;
    transform: translateY(-50%);
    background: rgba(74, 125, 255, 0.25);
    border: 1px solid rgba(126, 166, 255, 0.4);
    color: #7ea6ff;
    font-size: 1.1rem;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s ease, background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(74, 125, 255, 0.3);
}

.call-button:hover {
    background: rgba(74, 125, 255, 0.4);
    color: #a5bfff;
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 4px 12px rgba(74, 125, 255, 0.5);
}

.call-button:active {
    transform: translateY(-50%) scale(0.95);
    background: rgba(74, 125, 255, 0.5);
}

@media (max-width: 600px) {
    .call-button {
        right: 80px; 
    }
}

@media (max-width: 768px) {
    #toggleScreen {
        display: none !important;
    }
}

.call-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.call-modal-content {
    text-align: center;
    padding: 40px 30px;
    max-width: 320px;
    width: 90%;
}

.call-avatar {
    width: 120px;
    height: 120px;
    margin: 0 auto 20px;
    border-radius: 50%;
    overflow: hidden;
    border: 4px solid var(--primary-color);
    box-shadow: 0 0 30px rgba(74, 125, 255, 0.5);
    animation: pulse-ring 2s ease infinite;
}

.call-avatar.large {
    width: 150px;
    height: 150px;
}

.call-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@keyframes pulse-ring {
    0% { box-shadow: 0 0 0 0 rgba(74, 125, 255, 0.7); }
    70% { box-shadow: 0 0 0 20px rgba(74, 125, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(74, 125, 255, 0); }
}

.call-info h2 {
    color: #fff;
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.call-info .call-status {
    color: var(--text-secondary);
    font-size: 1rem;
    animation: blink 1.5s ease infinite;
}

@keyframes blink {
    0%, 50%, 100% { opacity: 1; }
    25%, 75% { opacity: 0.5; }
}

.call-actions {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-top: 40px;
}

.call-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.call-action:active {
    transform: scale(0.95);
}

.call-action i {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #fff;
}

.call-action.decline i {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.call-action.answer i {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    animation: pulse-green 2s ease infinite;
}

@keyframes pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
    70% { box-shadow: 0 0 0 15px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.call-action span {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.call-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, #1a1b2e 0%, #0f172a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.call-overlay-content {
    text-align: center;
    padding: 40px 20px;
    width: 100%;
    max-width: 400px;
}

.call-overlay-content h2 {
    color: #fff;
    font-size: 1.8rem;
    margin: 20px 0 10px;
}

.call-timer {
    color: var(--primary-color);
    font-size: 1.2rem;
    font-weight: 500;
    margin-bottom: 60px;
}

.call-controls {
    display: flex;
    justify-content: center;
    gap: 30px;
    padding: 20px;
}

.call-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease, visibility 0.2s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.call-control:active {
    transform: scale(0.95);
}

.call-control i {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
    transition: background 0.2s ease;
}

.call-control:hover i {
    background: rgba(255, 255, 255, 0.25);
}

.call-control.active i {
    background: var(--primary-color);
}

.call-control.end-call i {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    width: 70px;
    height: 70px;
}

.call-control span {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.video-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000;
    z-index: 1;
}

.video-container video {
    position: absolute;
    object-fit: cover;
}

#remoteVideo {
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

#localVideo {
    width: 120px;
    height: 160px;
    bottom: 140px;
    right: 20px;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

.call-overlay.video-active .call-overlay-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    padding: 20px;
    z-index: 5;
}

.call-overlay.video-active #callAvatarContainer {
    display: none;
}

.call-overlay.video-active #callPartnerName {
    font-size: 1.2rem;
    margin: 0 0 5px;
}

.call-overlay.video-active .call-timer {
    margin-bottom: 20px;
}

.call-overlay.video-active .call-controls {
    padding: 10px;
}

.media-button {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    width: 24px;
    height: 24px;
    min-width: 24px;
    color: #65676b;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.15s ease;
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 102;
}

.media-button:hover {
    opacity: 1;
}

.media-button:active {
    opacity: 0.5;
}

.media-picker-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: none;
}

.media-picker-modal.active {
    display: block;
}

.media-picker-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

.media-picker-sheet {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.98) 0%, rgba(15, 23, 42, 0.99) 100%);
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    animation: slideUp 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
    border-top: 1px solid rgba(148, 163, 184, 0.3);
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.media-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.media-picker-header span {
    font-size: 18px;
    font-weight: 600;
    color: #e2e8f0;
}

.media-picker-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #94a3b8;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, opacity 0.2s ease, visibility 0.2s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.media-picker-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.media-picker-options {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.media-picker-option {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px 10px;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.10) 0%, rgba(79, 70, 229, 0.12) 100%);
    border: 1px solid rgba(125, 177, 255, 0.28);
    border-radius: 16px;
    color: var(--text-primary);
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
    transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.media-picker-option:hover {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.18) 0%, rgba(79, 70, 229, 0.22) 100%);
    border-color: rgba(125, 177, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(37, 99, 235, 0.35), var(--shadow-glow);
}

.media-picker-option:active {
    transform: scale(0.98);
}

.media-picker-option .mpo-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--button-gradient);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.media-picker-option .mpo-icon i {
    font-size: 22px;
    color: #ffffff;
}

.media-picker-option .mpo-gif-badge {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: #ffffff;
    font-family: Tahoma, Verdana, Arial, sans-serif;
}

.media-picker-option .mpo-label {
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    line-height: 1.25;
    color: var(--text-primary);
}

.media-expiry-notice {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 11px;
    color: #64748b;
    margin: 0;
    padding-top: 8px;
}

.media-expiry-notice i {
    font-size: 10px;
}

.voice-recorder-modal {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: none;
}

.voice-recorder-modal.active {
    display: block;
}

.voice-recorder-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

.voice-recorder-sheet {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.98) 0%, rgba(15, 23, 42, 0.99) 100%);
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    border-top: 1px solid rgba(125, 177, 255, 0.3);
    padding: 18px 20px;
    padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.voice-recorder-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.voice-recorder-header span {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.voice-recorder-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #94a3b8;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.voice-recorder-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.voice-recorder-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 14px 0 20px;
}

.voice-visualizer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 56px;
    width: 100%;
    max-width: 260px;
}

.voice-visualizer span {
    flex: 0 0 5px;
    width: 5px;
    height: 8px;
    border-radius: 3px;
    background: linear-gradient(180deg, var(--accent) 0%, var(--primary-color) 100%);
    box-shadow: 0 0 8px var(--accent-glow);
    opacity: 0.55;
    transition: height 0.12s ease, opacity 0.12s ease;
}

.voice-recorder-modal.recording .voice-visualizer span {
    animation: voiceBar 0.9s ease-in-out infinite;
    opacity: 1;
}

.voice-recorder-modal.recording .voice-visualizer span:nth-child(1) { animation-delay: 0s; }
.voice-recorder-modal.recording .voice-visualizer span:nth-child(2) { animation-delay: 0.10s; }
.voice-recorder-modal.recording .voice-visualizer span:nth-child(3) { animation-delay: 0.20s; }
.voice-recorder-modal.recording .voice-visualizer span:nth-child(4) { animation-delay: 0.30s; }
.voice-recorder-modal.recording .voice-visualizer span:nth-child(5) { animation-delay: 0.40s; }
.voice-recorder-modal.recording .voice-visualizer span:nth-child(6) { animation-delay: 0.35s; }
.voice-recorder-modal.recording .voice-visualizer span:nth-child(7) { animation-delay: 0.25s; }
.voice-recorder-modal.recording .voice-visualizer span:nth-child(8) { animation-delay: 0.15s; }
.voice-recorder-modal.recording .voice-visualizer span:nth-child(9) { animation-delay: 0.08s; }
.voice-recorder-modal.recording .voice-visualizer span:nth-child(10) { animation-delay: 0.02s; }

@keyframes voiceBar {
    0%, 100% { height: 8px; }
    50% { height: 44px; }
}

.voice-timer {
    font-size: 26px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    letter-spacing: 1px;
}

.voice-hint {
    font-size: 12px;
    color: var(--text-secondary);
}

.voice-preview-player {
    width: 100%;
    margin: 0 0 14px;
    border-radius: 12px;
}

.voice-recorder-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 22px;
}

.voice-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
    transition: transform 0.15s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

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

.voice-btn-record {
    background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
    box-shadow: 0 4px 16px rgba(225, 29, 72, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.voice-btn-record:hover {
    box-shadow: 0 6px 22px rgba(225, 29, 72, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.voice-btn-stop {
    background: linear-gradient(135deg, #fb7185 0%, #e11d48 100%);
    box-shadow: 0 4px 16px rgba(225, 29, 72, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.25);
    animation: voicePulse 1.4s ease-in-out infinite;
}

@keyframes voicePulse {
    0%, 100% { box-shadow: 0 4px 16px rgba(225, 29, 72, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.25); }
    50% { box-shadow: 0 4px 26px rgba(225, 29, 72, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.25); }
}

.voice-btn-discard {
    width: 48px;
    height: 48px;
    font-size: 17px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.35);
    color: #cbd5e1;
}

.voice-btn-discard:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

.voice-btn-send {
    background: var(--button-gradient);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.voice-btn-send:hover {
    box-shadow: 0 6px 22px rgba(37, 99, 235, 0.7), var(--shadow-glow);
}

.voice-upload-progress {
    margin-top: 16px;
}

.message .voice-note {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 180px;
    max-width: 260px;
}

.message .voice-note audio {
    width: 100%;
    height: 38px;
}

.message .voice-note .voice-note-icon {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--button-gradient);
    color: #fff;
    font-size: 13px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.message-media.message-media-voice {
    margin: 0 0 4px;
    max-width: min(280px, 100%);
    border-radius: 10px;
    overflow: visible;
    background: rgba(0, 0, 0, 0.2);
    padding: 8px 10px;
}

.message-media-voice .message-voice-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 200px;
}

.message-media-voice .message-voice-icon {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--button-gradient);
    color: #fff;
    font-size: 14px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.message-media-voice .message-voice-audio {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    height: 36px;
    max-height: 40px;
}

.message-media-voice .message-voice-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 6px;
    padding-top: 5px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.message-media-voice .media-expiry-badge {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.78);
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-media-voice .media-expiry-badge i {
    font-size: 9px;
}

.message-media-voice .media-download-btn {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    padding: 0;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.15);
}

.message.message-voice-only .message-footer {
    margin-top: 4px;
}

.media-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: none;
}

.media-preview-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-preview-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    animation: fadeIn 0.2s ease;
}

.media-preview-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    z-index: 1;
}

.media-preview-close {
    position: absolute;
    top: max(20px, env(safe-area-inset-top, 20px));
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: transform 0.2s ease, opacity 0.2s ease, visibility 0.2s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.media-preview-close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
}

.media-preview-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px 20px 20px;
    overflow: hidden;
}

.media-preview-container img,
.media-preview-container video {
    max-width: 100%;
    max-height: 100%;
    border-radius: 12px;
    object-fit: contain;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.media-preview-caption {
    padding: 0 20px;
    margin-bottom: 15px;
}

.media-preview-caption input {
    width: 100%;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 24px;
    color: white;
    font-size: 16px;
    outline: none;
    transition: transform 0.2s ease, opacity 0.2s ease, visibility 0.2s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.media-preview-caption input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.media-preview-caption input:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(99, 102, 241, 0.5);
}

.media-preview-actions {
    display: flex;
    gap: 12px;
    padding: 0 20px 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}

.media-preview-cancel {
    flex: 1;
    padding: 14px 24px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 24px;
    color: white;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease, visibility 0.2s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.media-preview-cancel:hover {
    background: rgba(255, 255, 255, 0.2);
}

.media-preview-send {
    flex: 2;
    padding: 14px 24px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border: none;
    border-radius: 24px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.2s ease, opacity 0.2s ease, visibility 0.2s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.media-preview-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.media-preview-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.media-upload-progress {
    padding: 15px 20px;
    text-align: center;
}

.progress-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    border-radius: 3px;
    transition: width 0.2s ease;
}

.progress-text {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
}

.message-media {
    margin: -4px -8px 8px;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    max-width: 280px;
}

.message-media img,
.message-media video {
    width: 100%;
    display: block;
    border-radius: 12px;
    cursor: pointer;
}

.message-inline-image {
    margin-top: 4px;
}

.message-inline-image img {
    max-height: 320px;
    object-fit: contain;
    background: rgba(0, 0, 0, 0.15);
}

.message-media video {
    max-height: 300px;
    object-fit: contain;
    background: #000;
}

.message-media-expired {
    min-height: 88px;
    background: #1e293b;
    border: 1px dashed #475569;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.message-media-expired-inner {
    text-align: center;
    color: #94a3b8;
    padding: 12px;
    font-size: 13px;
}

.message-media-expired-inner i {
    display: block;
    font-size: 22px;
    margin-bottom: 6px;
    opacity: 0.7;
}

.message-media-expired-inner small {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    opacity: 0.85;
}

.message-media-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 30px 10px 8px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
    display: flex;
    align-items: center;
    justify-content: space-between;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.message-media:hover .message-media-overlay {
    opacity: 1;
}

.media-download-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, opacity 0.2s ease, visibility 0.2s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.media-download-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.media-expiry-badge {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    gap: 4px;
}

.media-expiry-badge i {
    font-size: 8px;
}

.video-play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease, visibility 0.2s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.video-play-overlay i {
    color: white;
    font-size: 24px;
    margin-left: 4px;
}

.video-play-overlay:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: translate(-50%, -50%) scale(1.1);
}

.message-media-caption {
    margin-top: 8px;
    font-size: 14px;
    line-height: 1.4;
}

.media-fullscreen-viewer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
}

.media-fullscreen-viewer.active {
    display: flex;
}

.media-fullscreen-viewer img,
.media-fullscreen-viewer video {
    max-width: 95%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
}

.fullscreen-close {
    position: absolute;
    top: max(20px, env(safe-area-inset-top, 20px));
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, opacity 0.2s ease, visibility 0.2s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.fullscreen-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

.fullscreen-download {
    position: absolute;
    bottom: calc(30px + env(safe-area-inset-bottom, 0px));
    right: 20px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border: none;
    border-radius: 24px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s ease, opacity 0.2s ease, visibility 0.2s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.fullscreen-download:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.fullscreen-expiry-notice {
    position: absolute;
    bottom: calc(30px + env(safe-area-inset-bottom, 0px));
    left: 20px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    gap: 5px;
}

.login-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-modal-content {
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.98) 0%, rgba(30, 41, 59, 0.98) 100%);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 24px;
    padding: 40px 30px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5), 0 0 100px rgba(99, 102, 241, 0.1);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header i {
    font-size: 48px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 15px;
    display: block;
}

.login-header h2 {
    color: #f1f5f9;
    font-size: 24px;
    font-weight: 600;
    margin: 0 0 8px 0;
}

.login-header p {
    color: #94a3b8;
    font-size: 14px;
    margin: 0;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.login-field label {
    color: #94a3b8;
    font-size: 13px;
    font-weight: 500;
}

.login-field input {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    padding: 14px 16px;
    color: #f1f5f9;
    font-size: 16px;
    transition: transform 0.2s ease, opacity 0.2s ease, visibility 0.2s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.login-field input:focus {
    outline: none;
    border-color: #6366f1;
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.login-field input::placeholder {
    color: #64748b;
}

.login-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 10px;
    padding: 12px;
    color: #fca5a5;
    font-size: 13px;
    text-align: center;
}

.login-submit {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border: none;
    border-radius: 12px;
    padding: 16px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: transform 0.2s ease, opacity 0.2s ease, visibility 0.2s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    margin-top: 10px;
}

.login-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}

.login-submit:active {
    transform: translateY(0);
}

.login-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.login-footer {
    text-align: center;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid rgba(148, 163, 184, 0.15);
}

.login-footer a {
    color: #818cf8;
    text-decoration: none;
    font-size: 13px;
    transition: color 0.2s ease;
}

.login-footer a:hover {
    color: #a5b4fc;
}

.login-footer span {
    color: #475569;
    margin: 0 10px;
}

.no-messages {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 0.95rem;
    text-align: center;
    font-style: italic;
    opacity: 0.75;
}

.error-message {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 12px 16px;
    padding: 12px 16px;
    background: rgba(251, 113, 133, 0.12);
    border: 1px solid rgba(251, 113, 133, 0.3);
    border-radius: 12px;
    color: #fca5a5;
    font-size: 0.875rem;
    text-align: center;
}

.load-older-btn {
    display: block;
    width: calc(100% - 40px);
    margin: 10px 20px 6px;
    padding: 9px 16px;
    background: rgba(125, 177, 255, 0.1);
    border: 1px solid rgba(125, 177, 255, 0.3);
    border-radius: 20px;
    color: var(--primary-light);
    font-size: 0.8rem;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease;
}

.load-older-btn:hover {
    background: rgba(125, 177, 255, 0.2);
    transform: translateY(-1px);
}

.load-older-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.message.sent .message-status[title="Read"] {
    color: var(--accent);
}

.message.sent .message-status[title="Sent"] {
    color: rgba(255, 255, 255, 0.6);
}

.message.sent .message-status[title="Sending"] {
    color: rgba(255, 255, 255, 0.4);
}

.message.sent .message-status[title="Failed to send"] {
    color: #fca5a5;
    font-weight: 700;
}

.state-hint {
    font-size: 0.875rem;
    opacity: 0.7;
    margin-top: 5px;
}

.friends-loading {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 15px;
}

.friend-skeleton {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 8px;
    border-radius: 15px;
    background: var(--card-glass);
    border: 1px solid var(--card-border);
}

.skeleton {
    background: linear-gradient(90deg,
        rgba(255,255,255,0.06) 25%,
        rgba(255,255,255,0.14) 50%,
        rgba(255,255,255,0.06) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.4s ease-in-out infinite;
    border-radius: 8px;
}

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

.skeleton-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    flex-shrink: 0;
}

.skeleton-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.skeleton-name {
    height: 14px;
    width: 55%;
    border-radius: 6px;
}

.skeleton-status {
    height: 11px;
    width: 35%;
    border-radius: 6px;
}

.messages-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.messages-loading .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(125, 177, 255, 0.2);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.messages-loading .loading-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.message.message-sending {
    opacity: 0.65;
    pointer-events: none;
}

.message.message-sending .message-content::after {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-left: 6px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: rgba(255,255,255,0.9);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
}

#message-notification-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.97);
    color: var(--text-primary);
    padding: 14px 16px;
    z-index: 10001;
    transform: translateY(-100%);
    transition: transform 0.3s ease-in-out;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    border-bottom: 1px solid rgba(125, 177, 255, 0.25);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    cursor: pointer;
}

#message-notification-banner .notification-content {
    flex-grow: 1;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#message-notification-banner .notification-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.2s ease;
}

#message-notification-banner .notification-close:hover {
    color: var(--text-primary);
}

.friend-group-header--unread {
    background: linear-gradient(90deg, #c0392b, #e74c3c) !important;
    color: #ffffff !important;
    font-weight: 700;
    padding: 8px 20px;
    margin: 0 0 4px;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.4);
}

body.chat-open .search-toggle {
    display: none !important;
}

body.chat-open .chat-theme-settings-btn {
    display: none !important;
}

.back-button:focus-visible,
.search-toggle:focus-visible,
.inbox-toggle:focus-visible,
.call-button:focus-visible,
.send-button:focus-visible,
.media-button:focus-visible,
.filter-button:focus-visible,
.call-action:focus-visible,
.call-control:focus-visible,
.inbox-close:focus-visible,
.media-picker-close:focus-visible,
.media-preview-close:focus-visible,
.fullscreen-close:focus-visible,
.chat-theme-settings-btn:focus-visible,
.chat-theme-modal-close:focus-visible,
.chat-theme-option:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.chat-header .header-avatar-wrapper {
    position: relative;
    display: inline-flex;
    margin-right: 8px;
    vertical-align: middle;
    flex-shrink: 0;
}

.chat-header .header-avatar-wrapper .header-avatar {
    margin-right: 0;
}

.chat-header .header-avatar-wrapper .header-online-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--online);
    border: 2px solid #020617;
    display: none;
}

.chat-header .header-avatar-wrapper.is-online .header-online-dot {
    display: block;
}

.chat-theme-settings-btn {
    position: absolute;
    right: 70px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    width: 40px;
    height: 40px;
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    font-size: 16px;
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), visibility 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), color 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), border-color 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 10;
}

body.chat-theme-enabled .chat-theme-settings-btn {
    display: flex;
}

.chat-theme-settings-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-50%) scale(1.05);
    box-shadow: var(--shadow-glow);
}

body.chat-theme-enabled:not(.chat-open) .inbox-toggle {
    right: 120px;
}

body.chat-theme-enabled:not(.chat-open) .chat-header h1 {
    padding: 0 160px 0 10px;
}

@media (min-width: 900px) {
    body.chat-theme-enabled:not(.chat-open) .chat-header h1 {
        padding: 0 160px 0 10px;
    }
}

@media (max-width: 600px) {
    body.chat-theme-enabled.is-touch:not(.chat-open) .chat-theme-settings-btn {
        right: 114px;
    }

    body.chat-theme-enabled.is-touch:not(.chat-open) .inbox-toggle {
        right: 164px;
    }
}

.chat-theme-modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10005;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.chat-theme-modal-backdrop.active {
    display: block;
}

.chat-theme-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10006;
    pointer-events: none;
}

.chat-theme-modal.active {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding-top: var(--fr-im-chrome-top, 0px);
    box-sizing: border-box;
    pointer-events: auto;
}

.chat-theme-modal-sheet {
    position: relative;
    left: 0;
    right: 0;
    width: 100%;
    flex: 0 1 auto;
    min-height: 0;
    max-height: calc(100dvh - var(--fr-im-chrome-top, 0px) - 8px);
    max-height: calc(100svh - var(--fr-im-chrome-top, 0px) - 8px);
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    border-top-left-radius: 22px;
    border-top-right-radius: 22px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-bottom: none;
    box-shadow: 0 -12px 42px rgba(0, 0, 0, 0.45);
    animation: slideUp 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.chat-theme-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--card-border);
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--card-bg);
    padding-top: 2px;
    margin-top: -2px;
}

.chat-theme-modal-header h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-theme-modal-close {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-theme-modal-close:hover {
    background: rgba(255, 255, 255, 0.14);
    color: var(--text-primary);
}

body.is-touch .chat-theme-modal-close {
    min-width: 44px;
    min-height: 44px;
    flex-shrink: 0;
}

body.chat-theme-modal-open {
    overflow: hidden;
}

.chat-theme-modal-hint {
    margin: 0 0 16px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.35;
}

.chat-theme-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-theme-option {
    text-align: left;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.04);
    color: inherit;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.chat-theme-option:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 1px var(--primary-glow);
}

.chat-theme-option.active {
    border-color: var(--primary-color);
    background: rgba(125, 177, 255, 0.12);
    box-shadow: inset 0 0 0 1px rgba(125, 177, 255, 0.35);
}

.chat-theme-option-name {
    display: block;
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.chat-theme-option-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

html[data-chat-theme="myspace"] {
    --primary-color: #003399;
    --primary-light: #1c4ed8;
    --primary-dark: #001a66;
    --primary-glow: rgba(0, 51, 153, 0.35);
    --primary-glow-strong: rgba(30, 107, 219, 0.5);
    --accent: #ff3399;
    --accent-glow: rgba(255, 51, 153, 0.45);
    --background: linear-gradient(185deg, #e8eefc 0%, #d0dbf0 42%, #bccce6 100%);
    --header-bg: linear-gradient(180deg, #4a6eaf 0%, #385f9c 45%, #003399 100%);
    --outgoing-msg: linear-gradient(180deg, #003399 0%, #002f7a 100%);
    --button-gradient: linear-gradient(180deg, #4a6eaf 0%, #003399 55%, #002060 100%);
    --card-bg: rgba(255, 255, 255, 0.92);
    --card-glass: rgba(255, 255, 255, 0.94);
    --card-glass-hover: rgba(255, 236, 246, 0.98);
    --card-border: rgba(0, 51, 153, 0.45);
    --text-primary: #0a0f1a;
    --text-secondary: #4b5563;
    --text-on-primary: #ffffff;
    --text-light: #ffffff;
    --border: rgba(0, 51, 153, 0.35);
    --incoming-msg: #ffffff;
    --online: #00cc00;
    --offline: #808080;
    --error: #cc0000;
    --blur-amount: 0px;
    --shadow-sm: 2px 2px 0 rgba(0, 0, 0, 0.12), inset 1px 1px 0 rgba(255, 255, 255, 0.75);
    --shadow-md: 3px 3px 0 rgba(0, 51, 153, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.85);
    --shadow-inner: inset 2px 2px 3px rgba(0, 0, 0, 0.08);
    --shadow-glow: 0 0 0 1px rgba(0, 51, 153, 0.4);
    --shadow-glow-strong: 2px 2px 0 #003399;
    --reflection: linear-gradient(180deg, rgba(255, 255, 255, 0.65) 0%, rgba(255, 255, 255, 0) 50%);
}

html[data-chat-theme="myspace"],
html[data-chat-theme="myspace"] body {
    font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif;
}

html[data-chat-theme="myspace"] body {
    background:
        linear-gradient(rgba(255, 51, 153, 0.06), rgba(255, 51, 153, 0.06)),
        repeating-linear-gradient(
            -8deg,
            transparent,
            transparent 24px,
            rgba(255, 255, 255, 0.25) 24px,
            rgba(255, 255, 255, 0.25) 25px
        ),
        radial-gradient(circle at 15% -5%, rgba(255, 255, 255, 0.8), transparent 38%),
        linear-gradient(180deg, #f0f4ff 0%, #cdd8ef 52%, #a8bde0 100%);
    background-size: auto, auto, auto, auto;
    background-attachment: scroll; 
    color: var(--text-primary);
}

html[data-chat-theme="myspace"] .chat-theme-option.active {
    border-color: #ff3399;
    box-shadow: inset 0 0 0 2px rgba(255, 51, 153, 0.45), 2px 2px 0 rgba(0, 51, 153, 0.15);
    background: rgba(255, 248, 252, 0.95);
}

html[data-chat-theme="myspace"] .chat-header {
    background: var(--header-bg);
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.35),
        inset 0 -1px 0 rgba(0, 26, 102, 0.6),
        0 2px 4px rgba(0, 0, 40, 0.35);
    border-bottom: 2px solid #001a66;
    text-shadow: none;
}

html[data-chat-theme="myspace"] .chat-header::before {
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.18) 0%, rgba(0, 40, 120, 0.15) 100%);
}

html[data-chat-theme="myspace"] .chat-header h1 {
    color: #ffffff;
    text-shadow: 1px 1px 0 #001a66;
    font-weight: 700;
    letter-spacing: 0;
}

html[data-chat-theme="myspace"] .back-button,
html[data-chat-theme="myspace"] .search-toggle,
html[data-chat-theme="myspace"] .inbox-toggle,
html[data-chat-theme="myspace"] .chat-theme-settings-btn {
    border-radius: 4px !important;
    border: 2px outset #cce0ff !important;
    background: linear-gradient(180deg, #f8faff 0%, #d6e4f7 48%, #b9cde8 52%, #9ebadb 100%) !important;
    color: #003399 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.15), inset 1px 1px 0 rgba(255, 255, 255, 0.9) !important;
}

html[data-chat-theme="myspace"] .back-button:hover,
html[data-chat-theme="myspace"] .search-toggle:hover,
html[data-chat-theme="myspace"] .inbox-toggle:hover,
html[data-chat-theme="myspace"] .chat-theme-settings-btn:hover {
    background: linear-gradient(180deg, #ffffff 0%, #dce9fb 52%, #c8daf2 100%) !important;
    color: #ff3399 !important;
}

html[data-chat-theme="myspace"] .call-button {
    background: linear-gradient(180deg, #d6e9c8 0%, #8fbc6c 52%, #5a9f3f 100%) !important;
    border: 2px outset #cce0ff !important;
    color: #003300 !important;
    border-radius: 4px !important;
    backdrop-filter: none !important;
}

html[data-chat-theme="myspace"] .friend-item {
    background: rgba(255, 255, 255, 0.88) !important;
    border: 2px solid var(--primary-color) !important;
    border-radius: 4px !important;
    box-shadow: var(--shadow-sm) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

html[data-chat-theme="myspace"] .friend-item::before,
html[data-chat-theme="myspace"] .friend-item::after {
    display: none !important;
}

html[data-chat-theme="myspace"] .friend-name {
    color: #003399 !important;
    font-weight: 700;
}

html[data-chat-theme="myspace"] .friend-item .status-text {
    color: #333333 !important;
}

html[data-chat-theme="myspace"] .filter-button {
    border-radius: 4px;
    border: 2px outset #cce0ff;
    background: linear-gradient(180deg, #ffffff 0%, #e2ebf7 100%);
    color: #003399;
}

html[data-chat-theme="myspace"] .filter-button.active {
    background: linear-gradient(180deg, #ff66b2 0%, #ff3399 45%, #cc0066 100%);
    color: #ffffff;
    border: 2px solid #990055;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.35);
}

html[data-chat-theme="myspace"] .chat-input-container {
    background: linear-gradient(180deg, #e2ebf7 0%, #cfd9ec 100%) !important;
    border-top: 2px solid #003399 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.8), 0 -2px 6px rgba(0, 51, 153, 0.2) !important;
}

html[data-chat-theme="myspace"] .chat-input-container::before {
    opacity: 0.25;
}

html[data-chat-theme="myspace"] .message-input,
html[data-chat-theme="myspace"] .message-input:focus {
    border-radius: 4px !important;
    border: 2px inset #9ebadb !important;
    background: #ffffff !important;
    color: #000000 !important;
    font-weight: normal !important;
    box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.12) !important;
}

html[data-chat-theme="myspace"] .message-input:focus {
    border-color: #003399 !important;
    box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.1), 0 0 0 2px rgba(255, 51, 153, 0.45) !important;
}

html[data-chat-theme="myspace"] .send-button {
    border-radius: 4px !important;
    border: 2px outset #cce0ff !important;
    background: var(--button-gradient) !important;
    color: #ffffff !important;
    text-shadow: 1px 1px 0 #001a66;
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.2) !important;
}

html[data-chat-theme="myspace"] .media-button {
    border-radius: 4px !important;
    border: 2px outset #cce0ff !important;
    background: linear-gradient(180deg, #ffffff 0%, #dbe6f4 100%) !important;
    color: #003399 !important;
}

html[data-chat-theme="myspace"] .message {
    border-radius: 4px !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    text-shadow: none !important;
}

html[data-chat-theme="myspace"] .message.sent {
    background: linear-gradient(180deg, #1e4db8 0%, #003399 55%, #002060 100%) !important;
    color: #ffffff !important;
    border: 2px solid #001a66 !important;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.12), inset 1px 1px 0 rgba(255, 255, 255, 0.2) !important;
    border-top-right-radius: 2px !important;
    border-bottom-right-radius: 6px !important;
    font-weight: 600;
}

html[data-chat-theme="myspace"] .message.sent::before {
    opacity: 0.35;
    height: 40%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0) 100%);
}

html[data-chat-theme="myspace"] .message.received {
    background: #ffffff !important;
    color: #111111 !important;
    border: 2px solid #003399 !important;
    box-shadow: 2px 2px 0 rgba(0, 51, 153, 0.12) !important;
    border-bottom-left-radius: 6px !important;
    font-weight: normal;
    letter-spacing: 0;
}

html[data-chat-theme="myspace"] .message.received::after {
    opacity: 0.2;
    height: 35%;
}

html[data-chat-theme="myspace"] .message.sent .message-time,
html[data-chat-theme="myspace"] .message.sent .message-status {
    color: rgba(255, 255, 255, 0.85) !important;
}

html[data-chat-theme="myspace"] .message.received .message-time {
    color: #555555 !important;
}

html[data-chat-theme="myspace"] .message.call-notice {
    background: #ffffcc !important;
    border: 2px solid #cc9900 !important;
    color: #333300 !important;
    border-radius: 4px !important;
    font-family: Tahoma, Verdana, Arial, sans-serif !important;
}

html[data-chat-theme="myspace"] .message.call-notice .message-content {
    color: #333300 !important;
}

html[data-chat-theme="myspace"] .typing-indicator {
    background: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid #003399 !important;
    border-radius: 4px !important;
    color: #003399 !important;
}

html[data-chat-theme="myspace"] .search-overlay {
    background: rgba(255, 255, 255, 0.95) !important;
    border: 2px solid #003399 !important;
    border-radius: 6px !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: 3px 3px 0 rgba(0, 51, 153, 0.2) !important;
}

html[data-chat-theme="myspace"] .inbox-overlay {
    background: rgba(255, 255, 255, 0.96) !important;
    border: 2px solid #003399 !important;
    border-radius: 6px !important;
    backdrop-filter: none !important;
    box-shadow: 3px 3px 0 rgba(0, 51, 153, 0.2) !important;
}

html[data-chat-theme="myspace"] .inbox-meta {
    color: #666666 !important;
}

html[data-chat-theme="myspace"] .search-interface {
    background: linear-gradient(180deg, #e2ebf7 0%, #d0d9ea 100%) !important;
    border-top: 2px solid #003399 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: 0 -3px 8px rgba(0, 51, 153, 0.18) !important;
}

html[data-chat-theme="myspace"] .search-input-container {
    background: #ffffff !important;
    border: 2px inset #9ebadb !important;
    border-radius: 4px !important;
}

html[data-chat-theme="myspace"] #searchInput {
    color: #000000 !important;
}

html[data-chat-theme="myspace"] .inbox-close {
    border-radius: 4px !important;
    border: 2px outset #cce0ff !important;
    background: linear-gradient(180deg, #ffffff 0%, #dbe6f4 100%) !important;
    color: #003399 !important;
}

html[data-chat-theme="myspace"] .chat-header .header-avatar-wrapper .header-online-dot {
    border-color: #ffffff;
    background: var(--online);
}

@media (prefers-color-scheme: dark) {
    html[data-chat-theme="myspace"] .message-input,
    html[data-chat-theme="myspace"] .message-input:focus {
        background: #ffffff !important;
        color: #000000 !important;
        border-color: #003399 !important;
    }
}

html[data-chat-theme="aim"] {
    --primary-color: #000080;
    --primary-light: #0000aa;
    --primary-dark: #000050;
    --primary-glow: rgba(255, 200, 0, 0.35);
    --primary-glow-strong: rgba(0, 0, 0, 0.35);
    --accent: #e8b400;
    --accent-glow: rgba(255, 212, 0, 0.45);
    --background: #ece9d8;
    --header-bg: linear-gradient(180deg, #fefefe 0%, #eae8e6 42%, #c9c7c5 96%, #a8a6a4 100%);
    --outgoing-msg: #c6e4ff;
    --button-gradient: linear-gradient(180deg, #ffffff 0%, #ece9d8 52%, #d4cfca 96%, #c6c3bf 100%);
    --card-bg: #ece9d8;
    --card-glass: #ffffff;
    --card-glass-hover: #f9f9f9;
    --card-border: #404040;
    --text-primary: #000000;
    --text-secondary: #383838;
    --text-on-primary: #ffffff;
    --text-light: #101010;
    --border: #808080;
    --incoming-msg: #ffffff;
    --online: #008000;
    --offline: #606060;
    --error: #cc0000;
    --blur-amount: 0px;
    --shadow-sm: inset 1px 1px 0 #fdfdfd, inset -1px -1px #6d6d6d;
    --shadow-md: inset 1px 1px #ffffff, inset -1px -1px #5a5958;
    --shadow-inner: inset 2px 2px 3px rgba(0, 0, 0, 0.2);
    --shadow-glow: 0 0 0 1px #505050;
    --shadow-glow-strong: inset 1px 1px 0 #ffffff, inset -1px -1px #848484;
    --reflection: none;
}

html[data-chat-theme="aim"],
html[data-chat-theme="aim"] body {
    font-family: Verdana, Tahoma, Arial, Helvetica, sans-serif;
}

html[data-chat-theme="aim"] body {
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
    box-sizing: border-box;
    background-color: #008080;
    background-image:
        linear-gradient(rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.06)),
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.04) 6px, transparent 6px, transparent 28px),
        repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.05) 6px, transparent 6px, transparent 28px),
        radial-gradient(ellipse 140% 60% at 50% -20%, rgba(255, 255, 255, 0.18), transparent 55%),
        linear-gradient(160deg, #007070 0%, #008080 45%, #006060 100%);
    background-size: auto, auto, auto, auto, auto;
    background-attachment: scroll; 
    color: var(--text-primary);
}

html[data-chat-theme="aim"] .chat-container {
    box-sizing: border-box;
    border: 4px groove #dfe3e9;
    box-shadow:
        inset 2px 2px #ffffff,
        inset -2px -2px #3a3938,
        4px 4px 10px rgba(0, 0, 0, 0.45);
    border-radius: 0;
}

html[data-chat-theme="aim"] .chat-theme-option.active {
    border: 2px solid #505050 !important;
    background: linear-gradient(180deg, #000084 0%, #000068 92%, #000058 100%) !important;
    box-shadow:
        inset 1px 1px 0 #404090,
        inset -1px -1px #000038,
        0 0 0 1px #ffff99 !important;
}

html[data-chat-theme="aim"] .chat-theme-option.active .chat-theme-option-name {
    color: #ffff99 !important;
}

html[data-chat-theme="aim"] .chat-theme-option.active .chat-theme-option-desc {
    color: rgba(255, 255, 200, 0.88) !important;
}

html[data-chat-theme="aim"] .chat-header {
    background: var(--header-bg) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: inset 0 1px 0 #fefefe, inset 0 -3px #ffcf33 !important;
    border-bottom: 4px solid #ffcf33;
    border-top: none;
    text-shadow: none;
}

html[data-chat-theme="aim"] .chat-header::before {
    opacity: 0 !important;
    background: transparent !important;
}

html[data-chat-theme="aim"] .chat-header h1 {
    color: #000000 !important;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: none;
    text-shadow: none !important;
}

html[data-chat-theme="aim"] .back-button,
html[data-chat-theme="aim"] .search-toggle,
html[data-chat-theme="aim"] .inbox-toggle,
html[data-chat-theme="aim"] .chat-theme-settings-btn {
    border-radius: 0 !important;
    border-top: 1px solid #ffffff !important;
    border-left: 1px solid #ffffff !important;
    border-right: 1px solid #424242 !important;
    border-bottom: 1px solid #424242 !important;
    background: linear-gradient(180deg, #ffffff 0%, #eae8e4 54%, #d4d2ce 96%, #c6c5c3 100%) !important;
    color: #1a1a1a !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;
}

html[data-chat-theme="aim"] .back-button:hover,
html[data-chat-theme="aim"] .search-toggle:hover,
html[data-chat-theme="aim"] .inbox-toggle:hover,
html[data-chat-theme="aim"] .chat-theme-settings-btn:hover {
    background: linear-gradient(180deg, #fffff8 0%, #ebe9e7 96%, #d8d6d4 100%) !important;
    color: #000000 !important;
}

html[data-chat-theme="aim"] .call-button {
    border-radius: 0 !important;
    border-top: 1px solid #e8ffb8 !important;
    border-left: 1px solid #e8ffb8 !important;
    border-right: 1px solid #287018 !important;
    border-bottom: 1px solid #287018 !important;
    background: linear-gradient(180deg, #e8fad8 0%, #aed68c 96%, #7cb54c 100%) !important;
    color: #1a3810 !important;
    backdrop-filter: none !important;
    box-shadow: none !important;
}

html[data-chat-theme="aim"] .friends-list {
    background: #ece9d8 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

html[data-chat-theme="aim"] .chat-view {
    background: #dfe4d9 !important;
    box-shadow: inset 6px 0 10px rgba(0, 0, 0, 0.08) !important;
}

html[data-chat-theme="aim"] .messages-scroll-container {
    background:
        repeating-linear-gradient(180deg, #fcfbf8 0px, #fcfbf8 31px, #f7f8f9 31px, #f7f8f9 32px),
        #fffef9 !important;
}

html[data-chat-theme="aim"] .friend-item {
    margin-left: 6px !important;
    margin-right: 6px !important;
    border-radius: 0 !important;
    background: #e6ebf3 !important;
    border-top: 1px solid #ffffff !important;
    border-left: 1px solid #fafaf8 !important;
    border-right: 1px solid #848484 !important;
    border-bottom: 1px solid #848484 !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

html[data-chat-theme="aim"] #friendsList .friend-item:hover {
    background: #eaf2fc !important;
}

html[data-chat-theme="aim"] .friend-item::before,
html[data-chat-theme="aim"] .friend-item::after {
    display: none !important;
}

html[data-chat-theme="aim"] .friend-name {
    color: #0000aa !important;
    font-weight: 700;
    text-decoration: underline;
}

html[data-chat-theme="aim"] .friend-item:hover .friend-name {
    color: #cc0000 !important;
}

html[data-chat-theme="aim"] .friend-item .status-text {
    color: #404040 !important;
    font-size: 0.92em;
}

html[data-chat-theme="aim"] .filter-button {
    border-radius: 0;
    border-top: 1px solid #ffffff !important;
    border-left: 1px solid #ffffff !important;
    border-right: 1px solid #5a584d !important;
    border-bottom: 1px solid #5a584d !important;
    background: linear-gradient(180deg, #f8f8f5 0%, #dedcd9 94%, #cccac7 100%) !important;
    color: #000000 !important;
    box-shadow: none !important;
}

html[data-chat-theme="aim"] .filter-button.active {
    background: linear-gradient(180deg, #ffe766 0%, #ffcc00 96%, #e6b600 100%) !important;
    color: #020202 !important;
    border: 2px outset #cfa400 !important;
    text-shadow: none !important;
    font-weight: 700 !important;
}

html[data-chat-theme="aim"] .chat-input-container {
    background: linear-gradient(180deg, #eae8e4 0%, #dbd9d7 94%, #c8c6c5 100%) !important;
    border-top: 2px outset #ebebe8 !important;
    box-shadow: inset 2px 2px rgba(255, 255, 255, 0.45) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

html[data-chat-theme="aim"] .chat-input-container::before {
    display: none !important;
}

html[data-chat-theme="aim"] .message-input,
html[data-chat-theme="aim"] .message-input:focus {
    border-radius: 0 !important;
    border: 2px inset #bdbab6 !important;
    border-top-color: #5b5855 !important;
    border-left-color: #706d6b !important;
    background: #ffffff !important;
    color: #000000 !important;
    font-weight: normal !important;
    box-shadow:
        inset 1px 1px rgba(255, 255, 255, 0.8),
        inset -1px -1px rgba(0, 0, 0, 0.12) !important;
}

html[data-chat-theme="aim"] .message-input:focus {
    outline: 2px groove #cfcfcf !important;
    outline-offset: 1px;
}

html[data-chat-theme="aim"] .send-button {
    border-radius: 0 !important;
    border-top: 2px outset #fdfcfa !important;
    border-left: 2px outset #fdfcfa !important;
    border-right: 2px solid #5a584d !important;
    border-bottom: 2px solid #5a584d !important;
    background: var(--button-gradient) !important;
    color: #101010 !important;
    font-weight: 700;
    text-shadow: none;
    box-shadow: none !important;
}

html[data-chat-theme="aim"] .send-button:active {
    border-style: inset !important;
    border-width: 2px !important;
}

html[data-chat-theme="aim"] .media-button {
    border-radius: 0 !important;
    border-top: 1px solid #ffffff !important;
    border-left: 1px solid #ffffff !important;
    border-right: 1px solid #494946 !important;
    border-bottom: 1px solid #494946 !important;
    background: linear-gradient(180deg, #fdfcfa 0%, #e9e8e7 94%, #d6d5d4 100%) !important;
    color: #282828 !important;
    box-shadow: none !important;
}

html[data-chat-theme="aim"] .message {
    border-radius: 0 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    text-shadow: none !important;
    border-style: solid !important;
}

html[data-chat-theme="aim"] .message.sent {
    background: linear-gradient(180deg, #d7ecff 0%, #bde0ff 100%) !important;
    color: #000000 !important;
    border: 1px solid #4f7eb3 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    font-weight: normal;
}

html[data-chat-theme="aim"] .message.sent::before {
    display: none !important;
}

html[data-chat-theme="aim"] .message.received {
    background: #ffffff !important;
    color: #000000 !important;
    border: 1px ridge #bdbab6 !important;
    border-radius: 0 !important;
    box-shadow: inset 4px 0 0 #c58b2c !important;
    font-weight: normal;
}

html[data-chat-theme="aim"] .message.received::after {
    display: none !important;
}

html[data-chat-theme="aim"] .message.sent .message-time,
html[data-chat-theme="aim"] .message.sent .message-status {
    color: #2a4258 !important;
}

html[data-chat-theme="aim"] .message.received .message-time {
    color: #555555 !important;
}

html[data-chat-theme="aim"] .message.call-notice {
    background: #ffffcc !important;
    border: 1px solid #848484 !important;
    border-radius: 0 !important;
    color: #202000 !important;
}

html[data-chat-theme="aim"] .message.call-notice .message-content {
    color: #202000 !important;
}

html[data-chat-theme="aim"] .typing-indicator {
    background: #eaf7ea !important;
    border: 1px dashed #548754 !important;
    border-radius: 0 !important;
    color: #1a491a !important;
    font-size: 0.9rem;
}

html[data-chat-theme="aim"] .load-older-btn {
    border-radius: 0 !important;
    background: linear-gradient(180deg, #fdfcfa 0%, #eae8e4 100%) !important;
    border: 2px outset #eae8e4 !important;
    color: #101010 !important;
    backdrop-filter: none !important;
    box-shadow: none !important;
}

html[data-chat-theme="aim"] .loading {
    color: #000000 !important;
}

html[data-chat-theme="aim"] .loading-spinner {
    border-color: #c9c9c9;
    border-top-color: #ffcc00;
}

html[data-chat-theme="aim"] .search-overlay {
    background: #ece9d8 !important;
    border: 3px outset #eae8e4 !important;
    border-radius: 0 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: 6px 6px rgba(0, 0, 0, 0.42) !important;
}

html[data-chat-theme="aim"] .inbox-overlay {
    background: #ece9d8 !important;
    border: 3px outset #eae8e4 !important;
    border-radius: 0 !important;
    backdrop-filter: none !important;
    box-shadow: 6px 6px rgba(0, 0, 0, 0.42) !important;
}

html[data-chat-theme="aim"] .inbox-meta {
    color: #3a3938 !important;
}

html[data-chat-theme="aim"] .search-interface {
    background: linear-gradient(180deg, #f0eeec 0%, #dbd9d8 96%, #c8c6c5 100%) !important;
    border-top: 2px ridge #eae8e4 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: inset 2px 2px rgba(255, 255, 255, 0.4) !important;
}

html[data-chat-theme="aim"] .search-input-container {
    background: #ffffff !important;
    border: 2px inset #aeb2b9 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

html[data-chat-theme="aim"] #searchInput {
    color: #000000 !important;
}

html[data-chat-theme="aim"] .inbox-close {
    border-radius: 0 !important;
    border-top: 1px solid #ffffff !important;
    border-left: 1px solid #ffffff !important;
    border-right: 1px solid #494946 !important;
    border-bottom: 1px solid #494946 !important;
    background: linear-gradient(180deg, #ffffff 0%, #eae8e4 100%) !important;
    color: #101010 !important;
}

html[data-chat-theme="aim"] .chat-header .header-avatar-wrapper .header-online-dot {
    border-color: #000000 !important;
    background: var(--online) !important;
}

@media (prefers-color-scheme: dark) {
    html[data-chat-theme="aim"] .message-input,
    html[data-chat-theme="aim"] .message-input:focus {
        background: #ffffff !important;
        color: #000000 !important;
        border-color: inherit !important;
    }
}

html[data-chat-theme="facebook"] {
    --primary-color: #3b5998;
    --primary-light: #627aad;
    --primary-dark: #2f477a;
    --primary-glow: rgba(98, 122, 173, 0.45);
    --primary-glow-strong: rgba(59, 89, 152, 0.55);
    --accent: #6d84b4;
    --accent-glow: rgba(109, 132, 180, 0.45);
    --background: #e9eaed;
    --header-bg: linear-gradient(to bottom, #4f69a9 3%, #3b5998 46%, #314c85 94%);
    --outgoing-msg: linear-gradient(to bottom, #eceff6 0%, #e3e9f7 94%);
    --button-gradient: linear-gradient(to bottom, #6d84bf 10%, #5b73ac 50%, #4c66a4 96%);
    --card-bg: #ffffff;
    --card-glass: #ffffff;
    --card-glass-hover: #f6f9ff;
    --card-border: #bdc7d8;
    --text-primary: #141823;
    --text-secondary: #62708c;
    --text-on-primary: #ffffff;
    --text-light: #ffffff;
    --border: #bdc7d8;
    --incoming-msg: #fafafa;
    --online: #42b72a;
    --offline: #90949c;
    --error: #dd3c10;
    --blur-amount: 0px;
    --shadow-sm: 0 1px 0 rgba(0, 0, 0, 0.04);
    --shadow-md: 0 1px 6px rgba(0, 0, 0, 0.2);
    --shadow-inner: inset 1px 1px rgba(101, 128, 188, 0.16);
    --shadow-glow: 0 0 0 1px #d6deeb;
    --shadow-glow-strong: inset 0 34px rgba(106,126,173,0.14);
    --reflection: none;
}

html[data-chat-theme="facebook"],
html[data-chat-theme="facebook"] body {
    font-family: 'Lucida Grande', Tahoma, Verdana, Arial, Helvetica, sans-serif !important;
}

html[data-chat-theme="facebook"] body {
    padding: 0 !important;
    margin: 0 !important;
    background: var(--background) !important;
    background-image: none !important;
    background-attachment: scroll !important;
    color: var(--text-primary) !important;
}

html[data-chat-theme="facebook"] .chat-container {
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}

html[data-chat-theme="facebook"] .chat-theme-option.active {
    background: linear-gradient(to bottom, #f7faff 2%, #eceff7 94%, #e3e9f7 100%) !important;
    border: 1px solid var(--primary-color) !important;
}

html[data-chat-theme="facebook"] .chat-theme-option.active .chat-theme-option-name {
    color: var(--primary-color) !important;
}

html[data-chat-theme="facebook"] .chat-theme-option.active .chat-theme-option-desc {
    color: #62708c !important;
}

html[data-chat-theme="facebook"] .chat-header {
    background: var(--header-bg) !important;
    border-bottom: 1px solid #133783 !important;
    box-shadow:
        inset 0 1px 0 rgba(154, 176, 220, 0.55),
        inset 0 -1px 0 rgba(19, 55, 120, 0.38),
        0 1px 6px rgba(0, 0, 44, 0.22) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    text-shadow: none !important;
}

html[data-chat-theme="facebook"] .chat-header::before {
    background: transparent !important;
    opacity: 0 !important;
}

html[data-chat-theme="facebook"] .chat-header h1 {
    color: #ffffff !important;
    font-weight: 700 !important;
    letter-spacing: 0 !important;
    text-shadow: 0 -1px 0 rgba(0, 26, 60, 0.45), 0 1px rgba(146, 170, 220, 0.22) !important;
}

html[data-chat-theme="facebook"] .back-button,
html[data-chat-theme="facebook"] .search-toggle,
html[data-chat-theme="facebook"] .inbox-toggle,
html[data-chat-theme="facebook"] .chat-theme-settings-btn {
    border-radius: 3px !important;
    border: 1px solid rgba(16, 32, 80, 0.55) !important;
    background: rgba(255, 255, 255, 0.12) !important;
    color: #ffffff !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: inset 0 1px rgba(182, 200, 240, 0.28) !important;
}

html[data-chat-theme="facebook"] .back-button:hover,
html[data-chat-theme="facebook"] .search-toggle:hover,
html[data-chat-theme="facebook"] .inbox-toggle:hover,
html[data-chat-theme="facebook"] .chat-theme-settings-btn:hover {
    background: rgba(255, 255, 255, 0.26) !important;
    border-color: rgba(255, 255, 255, 0.35) !important;
    color: #ffffff !important;
}

html[data-chat-theme="facebook"] .call-button {
    border-radius: 3px !important;
    background: rgba(74, 196, 90, 0.95) !important;
    border: 1px solid #358e3c !important;
    color: #ffffff !important;
    backdrop-filter: none !important;
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.35), 0 1px rgba(10, 50, 20, 0.18) !important;
}

html[data-chat-theme="facebook"] .friends-view {
    background: var(--background) !important;
}

html[data-chat-theme="facebook"] .friends-list {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    padding-left: 10px;
    padding-right: 10px;
}

html[data-chat-theme="facebook"] .chat-view {
    background: var(--background) !important;
    box-shadow: none !important;
}

html[data-chat-theme="facebook"] .messages-scroll-container {
    background-color: transparent !important;
}

html[data-chat-theme="facebook"] .friend-group-header {
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding: 7px 10px !important;
    font-size: 11px !important;
    letter-spacing: 0.045em !important;
    font-weight: 700 !important;
    text-transform: none !important;
    color: #62708c !important;
    background: linear-gradient(to bottom, #fdfdfe 0%, #ebeff5 92%, #d8dee8 98%) !important;
    border: 1px solid #bdc7d8 !important;
    border-radius: 3px !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: none !important;
}

html[data-chat-theme="facebook"] .friend-group-header.collapsible:hover {
    background: linear-gradient(to bottom, #fefefe 0%, #f0f3f9 94%, #e2e9f5 98%) !important;
    transform: none !important;
    box-shadow: none !important;
}

html[data-chat-theme="facebook"] .friend-group-header--unread {
    background: linear-gradient(to bottom, #fefced 5%, #fff9d7 96%, #fff3c8 99%) !important;
    border: 1px solid #e2c822 !important;
    box-shadow: 0 0 0 1px rgba(226, 200, 34, 0.18) inset !important;
    color: #7b6512 !important;
}

html[data-chat-theme="facebook"] .friend-item {
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding: 12px 12px !important;
    border-radius: 4px !important;
    border: 1px solid var(--border) !important;
    background: #ffffff !important;
    box-shadow: 0 0 1px rgba(0, 0, 0, 0.05) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

html[data-chat-theme="facebook"] .friend-item::before,
html[data-chat-theme="facebook"] .friend-item::after {
    display: none !important;
}

html[data-chat-theme="facebook"] .friend-item:hover {
    background: #edf2fb !important;
    border-color: #9aafce !important;
}

html[data-chat-theme="facebook"] .friend-name {
    color: #3b5998 !important;
    font-weight: 600 !important;
    text-decoration: none !important;
}

html[data-chat-theme="facebook"] .friend-item:hover .friend-name {
    text-decoration: underline !important;
    color: #2f487c !important;
}

html[data-chat-theme="facebook"] .friend-item .status-text {
    color: #90949c !important;
    font-weight: normal !important;
}

html[data-chat-theme="facebook"] .filter-button {
    border-radius: 3px !important;
    border: 1px solid #cdd3e6 !important;
    background: linear-gradient(to bottom, #f8f9fd 12%, #ebedf6 94%) !important;
    color: #4b6082 !important;
    font-weight: 600 !important;
    padding: 6px 10px !important;
}

html[data-chat-theme="facebook"] .filter-button.active {
    background: linear-gradient(to bottom, #6d84bf 14%, #5b73ac 52%, #4c68a9 94%) !important;
    border: 1px solid var(--primary-dark) !important;
    color: #ffffff !important;
    box-shadow:
        inset 0 13px rgba(255, 255, 255, 0.12),
        0 1px 1px rgba(19, 35, 80, 0.18) !important;
    text-shadow: 0 -1px rgba(0, 0, 0, 0.18) !important;
}

html[data-chat-theme="facebook"] .chat-input-container {
    background: linear-gradient(to bottom, #f6f8fc 0%, #eaeef8 94%, #e2e6f0 100%) !important;
    border-top: 1px solid #d0d9e9 !important;
    box-shadow: inset 0 1px 0 #ffffff !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

html[data-chat-theme="facebook"] .chat-input-container::before {
    display: none !important;
}

html[data-chat-theme="facebook"] .message-input,
html[data-chat-theme="facebook"] .message-input:focus {
    border-radius: 0 !important;
    border: 1px solid #bdc7d8 !important;
    background: #ffffff !important;
    color: #141823 !important;
    font-weight: normal !important;
    box-shadow: inset 0 5px rgba(237, 242, 250, 0.55) !important;
}

html[data-chat-theme="facebook"] .message-input:focus {
    border-color: #627aad !important;
    outline: none !important;
    box-shadow: 0 0 2px rgba(98, 122, 173, 0.45), inset 0 5px rgba(237, 242, 250, 0.85) !important;
}

html[data-chat-theme="facebook"] .send-button {
    border-radius: 4px !important;
    border: 1px solid var(--primary-dark) !important;
    background: var(--button-gradient) !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    text-shadow: 0 -1px rgba(0, 0, 0, 0.22) !important;
    box-shadow:
        inset 0 17px rgba(148, 170, 220, 0.18),
        0 1px 3px rgba(12, 30, 80, 0.18) !important;
}

html[data-chat-theme="facebook"] .send-button:disabled {
    opacity: 0.52 !important;
    filter: grayscale(0.1);
}

html[data-chat-theme="facebook"] .media-button {
    border-radius: 4px !important;
    border: 1px solid var(--border) !important;
    background: linear-gradient(to bottom, #ffffff 0%, #eef2fb 94%, #e7ecf6 98%) !important;
    color: #4f6185 !important;
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.78) !important;
}

html[data-chat-theme="facebook"] .message {
    border-radius: 3px !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    text-shadow: none !important;
}

html[data-chat-theme="facebook"] .message.sent {
    background: linear-gradient(to bottom, #f1f5fd 12%, #e6ecf8 94%, #dee6f7 98%) !important;
    border: 1px solid var(--border) !important;
    color: var(--text-primary) !important;
    box-shadow:
        inset 8px 0 0 rgba(221, 230, 244, 0.55),
        0 2px rgba(148, 160, 195, 0.08),
        inset 0 1px 0 #ffffff !important;
    margin-left: 18% !important;
}

html[data-chat-theme="facebook"] .message.sent::before {
    display: none !important;
}

html[data-chat-theme="facebook"] .message.received {
    background: #ffffff !important;
    border: 1px solid #e3e8f5 !important;
    color: var(--text-primary) !important;
    box-shadow: 0 1px 5px rgba(100, 120, 160, 0.08), inset -6px 0 0 rgba(189, 199, 216, 0.45) !important;
    margin-right: 14% !important;
}

html[data-chat-theme="facebook"] .message.received::after {
    display: none !important;
}

html[data-chat-theme="facebook"] .message.sent .message-time,
html[data-chat-theme="facebook"] .message.sent .message-status {
    color: var(--text-secondary) !important;
}

html[data-chat-theme="facebook"] .message.received .message-time {
    color: #90949c !important;
}

html[data-chat-theme="facebook"] .message.call-notice {
    background: #fffef3 !important;
    border: 1px solid #dcbf5c !important;
    border-radius: 3px !important;
    color: #59430b !important;
}

html[data-chat-theme="facebook"] .message.call-notice .message-content {
    color: #59430b !important;
}

html[data-chat-theme="facebook"] .typing-indicator {
    background: linear-gradient(to bottom, #fffef9 0%, #fff9d8 94%, #ffeec2 96%) !important;
    border: 1px solid #e9de9a !important;
    border-radius: 3px !important;
    color: #695f2c !important;
}

html[data-chat-theme="facebook"] .load-older-btn {
    border-radius: 4px !important;
    border: 1px solid var(--border) !important;
    background: linear-gradient(to bottom, #fdfefe 14%, #e9edf6 94%) !important;
    color: var(--primary-color) !important;
    font-weight: 600 !important;
    backdrop-filter: none !important;
}

html[data-chat-theme="facebook"] .loading {
    color: #62708c !important;
}

html[data-chat-theme="facebook"] .loading-spinner {
    border-color: #e2e8f7;
    border-top-color: #3b5998;
}

html[data-chat-theme="facebook"] .search-overlay {
    background: #ffffff !important;
    border: 1px solid var(--border) !important;
    border-radius: 4px !important;
    backdrop-filter: none !important;
    box-shadow:
        inset 0 0 40px rgba(239, 244, 252, 0.55),
        0 2px 14px rgba(41, 60, 100, 0.16) !important;
}

html[data-chat-theme="facebook"] .inbox-overlay {
    background: #ffffff !important;
    border: 1px solid var(--border) !important;
    border-radius: 4px !important;
    backdrop-filter: none !important;
    box-shadow:
        inset 0 0 40px rgba(239, 244, 252, 0.55),
        0 2px 14px rgba(41, 60, 100, 0.16) !important;
}

html[data-chat-theme="facebook"] .inbox-meta {
    color: #90949c !important;
}

html[data-chat-theme="facebook"] .search-interface {
    background: linear-gradient(to bottom, #f4f8ff 14%, #e6ecf9 94%, #dae3f5 96%) !important;
    border-top: 1px solid #d0dae8 !important;
    backdrop-filter: none !important;
    box-shadow: inset 0 1px 0 #fefeff !important;
}

html[data-chat-theme="facebook"] .search-input-container {
    background: #ffffff !important;
    border: 1px solid var(--border) !important;
    border-radius: 3px !important;
}

html[data-chat-theme="facebook"] #searchInput {
    color: #141823 !important;
}

html[data-chat-theme="facebook"] .inbox-close {
    border-radius: 3px !important;
    border: 1px solid #cccfd8 !important;
    background: linear-gradient(to bottom, #fdfefd 22%, #e8eaf3 94%) !important;
    color: #4f6188 !important;
}

html[data-chat-theme="facebook"] .chat-header .header-avatar-wrapper .header-online-dot {
    border-color: #ffffff !important;
}

@media (prefers-color-scheme: dark) {
    html[data-chat-theme="facebook"] .message-input,
    html[data-chat-theme="facebook"] .message-input:focus {
        background: #ffffff !important;
        color: #141823 !important;
        border-color: #bdc7d8 !important;
    }
}

@supports (-moz-appearance: none) {
    .chat-header,
    .friends-list,
    .chat-input-container,
    .search-overlay,
    .search-interface,
    .search-backdrop,
    .media-picker-backdrop,
    .friend-group-header,
    .load-older-btn,
    .search-toggle,
    .inbox-toggle,
    .send-button {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }

    
    .unread-count,
    .send-button {
        animation: none !important;
    }

    
    html[data-chat-theme="frutiger-max"] body::before {
        animation: none !important;
        filter: none;
        opacity: 0.85;
    }

    
    html[data-chat-theme="frutiger-max"] {
        --card-glass: rgba(20, 35, 75, 0.82);
    }
    html[data-chat-theme="frutiger-max"] .friends-list {
        background:
            linear-gradient(
                165deg,
                rgba(56, 189, 248, 0.14) 0%,
                rgba(3, 7, 18, 0.68) 42%,
                rgba(88, 28, 135, 0.2) 100%
            ),
            linear-gradient(
                180deg,
                rgba(3, 7, 18, 0.62) 0%,
                rgba(3, 7, 18, 0.45) 40%,
                rgba(3, 7, 18, 0.32) 100%
            );
    }

        html[data-chat-theme="frutiger-max"] .message,
    html[data-chat-theme="frutiger-max"] .message.sent,
    html[data-chat-theme="frutiger-max"] .message.received {
        box-shadow: 0 2px 6px rgba(0, 0, 38, 0.4) !important;
        text-shadow: none !important;
    }
    html[data-chat-theme="frutiger-max"] .friend-item {
        box-shadow: var(--shadow-sm) !important;
    }

        html[data-chat-theme="myspace"] body {
        background:
            linear-gradient(rgba(255, 51, 153, 0.06), rgba(255, 51, 153, 0.06)),
            radial-gradient(circle at 15% -5%, rgba(255, 255, 255, 0.8), transparent 38%),
            linear-gradient(180deg, #f0f4ff 0%, #cdd8ef 52%, #a8bde0 100%) !important;
    }
}

/* Keep sorting beside the list tabs, without taking another row of messages. */
.friends-list-tabs.has-friend-sort {
    padding-right: calc(clamp(112px, 40vw, 160px) + 18px);
}
.friend-sort-control {
    position: fixed;
    top: calc(var(--fr-im-header-h) + var(--fr-im-chrome-top) + 7px);
    right: 12px;
    z-index: 10;
    width: clamp(112px, 40vw, 160px);
    height: 27px;
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-light);
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
}
.friend-sort-control[hidden], .chat-open .friend-sort-control { display: none; }
.friend-sort-label { flex: 0 0 auto; font-size: 11px; font-weight: 600; }
.friend-sort-select {
    min-width: 0;
    width: 100%;
    height: 27px;
    padding: 2px 2px 2px 5px;
    border: 1px solid var(--card-border);
    border-radius: 4px;
    background: var(--card-bg);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 11px;
    line-height: 1.2;
    cursor: pointer;
    text-overflow: ellipsis;
}
.friend-sort-select option { background: #111827; color: #f0f4ff; }
html[data-chat-theme="myspace"] .friend-sort-select option,
html[data-chat-theme="aim"] .friend-sort-select option,
html[data-chat-theme="facebook"] .friend-sort-select option { background: #fff; color: #111; }
html[data-chat-theme="myspace"] .friend-sort-select { border: 1px solid #003399; border-radius: 2px; }
html[data-chat-theme="aim"] .friend-sort-select { border: 2px inset #c6c3bf; border-radius: 0; }
html[data-chat-theme="facebook"] .friend-sort-select { border: 1px solid #bdc7d8; border-radius: 2px; }
html[data-chat-theme="frutiger-max"] .friend-sort-select { border-radius: 8px; }
.friend-sort-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.friend-sort-more {
    display: block;
    width: calc(100% - 24px);
    margin: 8px 12px;
    padding: 7px;
    border: 1px solid var(--card-border);
    border-radius: 4px;
    background: var(--card-bg);
    color: var(--text-primary);
    font: inherit;
    cursor: pointer;
}
@media (max-width: 280px) {
    .friends-list-tabs.has-friend-sort { padding-right: 100px; }
    .friend-sort-control { width: 88px; }
    .friend-sort-label { display: none; }
}
.friends-list-tabs.has-friend-sort .friends-list-tab {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
@media (max-width: 280px) {
    .friends-list-tabs.has-friend-sort .friends-list-tab { padding: 0 3px; font-size: 11px; }
}
html[data-chat-theme="aim"] .friends-list-tabs.has-friend-sort .friends-list-tab { color: #222; }
html[data-chat-theme="aim"] .friends-list-tabs.has-friend-sort .friends-list-tab.active { color: #000080; background: #fff; }
@media (max-width: 360px) {
    .friends-list-tabs.has-friend-sort .friends-list-tab { padding: 0 4px; font-size: 12px; letter-spacing: 0; }
}
@media (max-width: 280px) {
    .friends-list-tabs.has-friend-sort .friends-list-tab { padding: 0 3px; font-size: 11px; }
}
