﻿:root {
    --bg: #0b0f14;
    --surface: #141a22;
    --surface-soft: #10151c;
    --text: #f2f5f9;
    --text-muted: #9fb1c4;
    --border: #1f2933;
    --accent: #5dd0ff;
    --accent-soft: #1b3240;
    --accent-hover: #7ad9ff;
    --accent-rgb: 93, 208, 255;
    --sent: #1e3a5f;
    --received: #141f2b;
    --sidebar: #0f151c;
    --icon: #f7f9fc;
    --icon-muted: #c9d6e4;
}

body[data-theme="light"] {
    --bg: #eef3f8;
    --surface: #ffffff;
    --surface-soft: #f2f6fb;
    --text: #172532;
    --text-muted: #5f7388;
    --border: #d4deea;
    --accent: #3386e6;
    --accent-soft: #cfe6ff;
    --accent-hover: #2a7ad9;
    --accent-rgb: 51, 134, 230;
    --sent: #dbeeff;
    --received: #ffffff;
    --sidebar: #e9f1f8;
    --icon: #1b2a38;
    --icon-muted: #5f7388;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

html {
    height: -webkit-fill-available;
}

body {
    font-family: "Segoe UI", Tahoma, sans-serif;
    background: radial-gradient(circle at 20% 10%, #1a2738 0%, var(--bg) 50%, var(--bg) 100%);
    color: var(--text);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    overflow: hidden;
    position: relative;
}

/* РџСЂРѕСЃС‚РѕР№ СЃС‚Р°С‚РёС‡РЅС‹Р№ С„РѕРЅ РґР»СЏ СЌРєСЂР°РЅР° Р°РІС‚РѕСЂРёР·Р°С†РёРё - РјР°РєСЃРёРјР°Р»СЊРЅР°СЏ РѕРїС‚РёРјРёР·Р°С†РёСЏ */
#auth-screen::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    pointer-events: none;
    z-index: 0;
    background: 
        radial-gradient(circle at 20% 50%, rgba(var(--accent-rgb), 0.06) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(var(--accent-rgb), 0.04) 0%, transparent 40%);
}

@keyframes simpleLine {
    0% {
        opacity: 0;
        transform: translateX(0);
    }
    10% {
        opacity: 0.4;
    }
    90% {
        opacity: 0.4;
    }
    100% {
        opacity: 0;
        transform: translateX(calc(100vw + 800px));
    }
}

/* РЎРєСЂС‹РІР°РµРј СЌС„С„РµРєС‚С‹ РєРѕРіРґР° РЅРµ РЅР° СЌРєСЂР°РЅРµ Р°РІС‚РѕСЂРёР·Р°С†РёРё */
#chat-screen .floating-light-line,
#chat-screen .sparkle-particle,
#chat-screen .auth-effects-svg,
#chat-screen #auth-theme-switch {
    display: none !important;
}

/* РџР»Р°РІР°СЋС‰РёРµ СЃРІРµС‚РѕРІС‹Рµ Р»РёРЅРёРё */
#auth-screen .floating-light-line {
    position: fixed;
    width: 600px;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(var(--accent-rgb), 0.3), transparent);
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    animation: simpleLine 20s linear infinite;
}

#auth-screen .floating-light-line::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(var(--accent-rgb), 0.5), transparent);
    filter: blur(4px);
}

#auth-screen .floating-light-line:nth-child(5) {
    top: 15%;
    left: -200px;
}

#auth-screen .floating-light-line:nth-child(6) {
    top: 50%;
    left: -200px;
}

#auth-screen .floating-light-line:nth-child(7) {
    top: 85%;
    left: -200px;
}

body[data-theme="light"] #auth-screen::before {
    background: 
        radial-gradient(circle at 20% 50%, rgba(var(--accent-rgb), 0.08) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(var(--accent-rgb), 0.05) 0%, transparent 40%);
}

body[data-theme="light"] #auth-screen .floating-light-line {
    background: linear-gradient(90deg, transparent, rgba(var(--accent-rgb), 0.4), transparent);
}

body[data-theme="light"] #auth-screen .floating-light-line::before {
    background: linear-gradient(90deg, transparent, rgba(var(--accent-rgb), 0.6), transparent);
}

body[data-theme="light"] {
    background: radial-gradient(circle at 20% 10%, #e8f0f8 0%, var(--bg) 50%, var(--bg) 100%);
}

.hidden {
    display: none !important;
}

/* File input should remain clickable for programmatic click */
.file-input-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
    left: -9999px;
}

/* Auth container styles */
.auth-container {
    background: rgba(23, 33, 43, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    max-width: 420px;
    width: 100%;
    margin: 0 auto;
    position: relative;
    z-index: 10;
    animation: authFadeIn 0.6s ease-out;
}

.auth-theme-switch-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    color: var(--icon-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.2s ease;
    z-index: 20;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.auth-theme-switch-btn:hover {
    background: rgba(var(--accent-rgb), 0.2);
    color: var(--icon);
    transform: scale(1.1);
}

.auth-theme-switch-btn:active {
    transform: scale(0.95);
}

body[data-theme="light"] .auth-theme-switch-btn {
    background: rgba(0, 0, 0, 0.05);
}

body[data-theme="light"] .auth-theme-switch-btn:hover {
    background: rgba(var(--accent-rgb), 0.15);
}

body[data-theme="light"] .auth-container {
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(255, 255, 255, 0.8) inset;
}

@keyframes authFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.auth-container h1 {
    text-align: center;
    margin-bottom: 28px;
    font-size: 32px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px rgba(var(--accent-rgb), 0.3);
}

body[data-theme="light"] .auth-container h1 {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tabs {
    display: flex;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 4px;
}

.tab-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    background: transparent;
    color: var(--text-muted);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.tab-btn:first-child {
    border-radius: 8px;
}

.tab-btn:last-child {
    border-radius: 8px;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    color: #fff;
    box-shadow: 0 2px 10px rgba(var(--accent-rgb), 0.3);
}

body[data-theme="light"] .tabs {
    background: rgba(0, 0, 0, 0.03);
}

body[data-theme="light"] .tab-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

body[data-theme="light"] .tab-btn.active {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    box-shadow: 0 2px 10px rgba(var(--accent-rgb), 0.3);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.password-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-wrap input {
    width: 100%;
    padding: 12px 44px 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
}

.password-input-wrap input:focus {
    outline: none;
    border-color: var(--accent);
}

.password-toggle-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--icon-muted);
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: background 0.2s ease, color 0.2s ease;
}

.password-toggle-btn:hover {
    background: var(--surface-soft);
    color: var(--icon);
}

.auth-form input,
.profile-form input[type="text"],
.profile-form textarea,
.user-search,
.message-form input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.auth-container .auth-form input,
.auth-container .password-input-wrap input {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.1);
}

.auth-container .auth-form input:focus,
.auth-container .password-input-wrap input:focus {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
}

body[data-theme="light"] .auth-container .auth-form input,
body[data-theme="light"] .auth-container .password-input-wrap input {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.1);
}

body[data-theme="light"] .auth-container .auth-form input:focus,
body[data-theme="light"] .auth-container .password-input-wrap input:focus {
    background: rgba(0, 0, 0, 0.03);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
}

.profile-form textarea {
    resize: vertical;
}

.auth-form input:focus,
.profile-form input[type="text"]:focus,
.profile-form textarea:focus,
.user-search:focus,
.message-form input:focus {
    outline: none;
    border-color: var(--accent);
}

.btn-primary,
.btn-secondary {
    border: none;
    border-radius: 10px;
    padding: 11px 14px;
    cursor: pointer;
    font-size: 14px;
    transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(var(--accent-rgb), 0.3);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(var(--accent-rgb), 0.4);
}

.auth-container .btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    box-shadow: 0 4px 20px rgba(var(--accent-rgb), 0.35);
}

.auth-container .btn-primary:hover {
    background: linear-gradient(135deg, var(--accent-hover) 0%, var(--accent) 100%);
    box-shadow: 0 6px 25px rgba(var(--accent-rgb), 0.45);
}

body[data-theme="light"] .auth-container .btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    box-shadow: 0 4px 15px rgba(var(--accent-rgb), 0.3);
}

body[data-theme="light"] .auth-container .btn-primary:hover {
    background: linear-gradient(135deg, var(--accent-hover) 0%, var(--accent) 100%);
    box-shadow: 0 6px 20px rgba(var(--accent-rgb), 0.4);
}

.btn-secondary {
    background: var(--surface-soft);
    color: var(--text);
}

.error-message {
    min-height: 18px;
    color: #e74c3c;
    font-size: 13px;
}

#chat-screen {
    height: 100vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    border-radius: 0;
    overflow: hidden;
    box-shadow: none;
}

.chat-header {
    height: 56px;
    padding: 10px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header h2 {
    font-size: 17px;
}

.mobile-chat-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-logo {
    width: 74px;
    height: 74px;
    border-radius: 3px;
    object-fit: cover;
}

.mobile-header-btn {
    display: none;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--icon);
    width: 32px;
    height: 32px;
    border-radius: 999px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

#settings-gear-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.user-info .theme-switch-btn {
    display: inline-flex;
}

.mobile-header-actions {
    display: none;
}

#menu-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.chats-compose {
    position: fixed;
    left: 14px;
    bottom: 24px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.chats-compose-toggle {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    padding: 0;
    font-size: 24px;
    line-height: 1;
}

.chats-compose-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: chatComposeActionsSlideIn 0.2s ease;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

#current-username {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 14px;
}

.chat-body {
    flex: 1;
    display: flex;
    min-height: 0;
    background: var(--surface);
}

.sidebar {
    width: 340px;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: width 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.search-wrap {
    position: relative;
    width: calc(100% - 24px);
    margin: 0 auto 10px;
}

.user-search {
    margin: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 999px;
    padding-right: 34px;
}

.clear-search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: var(--surface-soft);
    color: var(--icon-muted);
    cursor: pointer;
    line-height: 1;
    font-size: 14px;
}

.users-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.users-list::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.user-item {
    margin: 0 8px 6px;
    border-radius: 12px;
    padding: 10px 12px;
    display: flex;
    position: relative;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.2s ease, box-shadow 0.2s ease;
}

.user-item:hover {
    background: rgba(var(--accent-rgb), 0.08);
    transform: translateY(-1px);
}

.user-item.active {
    background: var(--accent);
    color: #fff;
}

.user-item.active .contact-time {
    color: rgba(255, 255, 255, 0.85);
}

.clickable-profile {
    cursor: pointer;
}

.user-info .clickable-profile:hover {
    opacity: 0.8;
}

.user-info .clickable-profile:active {
    transform: scale(0.95);
}

.user-main {
    min-width: 0;
    display: flex;
    gap: 10px;
    align-items: center;
    flex: 1;
}

.user-info-wrap {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.last-message-preview {
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.remove-contact {
    opacity: 0;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-size: 18px;
}

.user-item:hover .remove-contact {
    opacity: 0.7;
}

.contact-tools {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: space-between;
    gap: 4px;
    flex-shrink: 0;
    align-self: stretch;
}

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

.contact-time {
    font-size: 11px;
    color: var(--text-muted);
}

.unread-badge {
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
    padding: 0 6px;
    font-weight: 600;
}

.unread-badge.dot {
    min-width: 10px;
    width: 10px;
    height: 10px;
    padding: 0;
    font-size: 0;
    line-height: 10px;
}

.pin-contact {
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 2px;
    opacity: 0.65;
}

.pin-contact.active {
    color: var(--accent);
    opacity: 1;
}

.user-item:hover .pin-contact {
    opacity: 1;
}

.pin-indicator {
    color: var(--accent);
    font-size: 14px;
    line-height: 1;
}

.contact-item {
    -webkit-touch-callout: none;
    user-select: none;
}

.chat-context-menu {
    position: fixed;
    z-index: 1300;
    min-width: 180px;
    max-width: calc(100vw - 16px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
    padding: 6px;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
}

.chat-context-action {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text);
    text-align: left;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

.chat-context-action:hover {
    background: var(--surface-soft);
}

.chat-context-action.danger {
    color: #e55353;
}

/* Message context menu - compact popup style */
.message-context-menu {
    position: fixed;
    bottom: auto;
    left: auto;
    right: auto;
    z-index: 10000;
    background: var(--surface);
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    padding: 12px;
    min-width: 200px;
    max-width: min(320px, calc(100vw - 32px));
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9) translateY(-10px);
    transform-origin: top left;
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.message-context-menu:not(.hidden) {
    opacity: 1 !important;
    transform: scale(1) translateY(0) !important;
    pointer-events: auto !important;
    z-index: 10000 !important;
}

/* Reaction context menu */
.reaction-context-menu {
    position: fixed;
    z-index: 10000;
    background: var(--surface);
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    padding: 12px;
    min-width: 220px;
    max-width: min(320px, calc(100vw - 32px));
    max-height: 400px;
    overflow-y: auto;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9) translateY(-10px);
    transform-origin: top left;
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.reaction-context-menu:not(.hidden) {
    opacity: 1 !important;
    transform: scale(1) translateY(0) !important;
    pointer-events: auto !important;
    z-index: 10000 !important;
}

.reaction-context-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: var(--surface-soft);
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.reaction-context-close:hover {
    background: var(--border);
}

.reaction-context-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
    padding-right: 24px;
}

.reaction-context-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.reaction-user-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 10px;
    background: var(--surface-soft);
    transition: background 0.2s ease;
}

.reaction-user-item:hover {
    background: var(--border);
}

.reaction-user-avatar {
    flex-shrink: 0;
}

.reaction-user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.reaction-user-name {
    font-size: 13px;
    color: var(--text);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reaction-user-emoji {
    font-size: 16px;
    flex-shrink: 0;
}

.message-context-backdrop {
    display: none;
}

.message-context-title {
    display: none;
}

.message-context-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.message-context-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-radius: 10px;
    background: var(--surface-soft);
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s ease;
    pointer-events: auto;
    position: relative;
}

.message-context-btn:hover {
    background: rgba(var(--accent-rgb), 0.1);
}

.message-context-btn.danger {
    color: #e55353;
}

.message-context-btn.danger:hover {
    background: rgba(229, 83, 83, 0.1);
}

.message-context-emoji-panel {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.message-context-emoji-title {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-align: center;
}

.message-context-emojis {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.message-context-emoji-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: var(--surface-soft);
    font-size: 20px;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.message-context-emoji-btn:hover {
    background: rgba(var(--accent-rgb), 0.1);
    transform: scale(1.1);
}

.message-context-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: var(--surface-soft);
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.message-context-close:hover {
    background: var(--border);
}

.chat-panel {
    flex: 1;
    min-width: 0;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--surface-soft) 0%, var(--surface) 100%);
    animation: fadeInPanel 0.28s ease;
}

.chat-panel-header {
    height: 56px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    background: var(--surface);
}

.chat-with-box {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-title-wrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-with-box h3 {
    font-size: 15px;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--accent);
}

.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.typing-dots i {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent);
    animation: blinkDot 1.2s infinite ease-in-out;
}

.typing-dots i:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots i:nth-child(3) {
    animation-delay: 0.4s;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 14px;
    min-height: 0;
}

.messages-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-x: hidden;
    padding-bottom: 32px;
}

.messages-list::after {
    content: '';
    display: block;
    height: 32px;
}

.message {
    max-width: 85%;
    padding: 6px 8px 8px 8px;
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    animation: messageIn 0.2s ease;
    position: relative;
    overflow-wrap: anywhere;
    user-select: none;
    transition: background-color 0.15s ease;
}

.message.selected {
    background: var(--accent-soft) !important;
}

.message.selected::after {
    content: 'вњ“';
    position: absolute;
    top: 4px;
    right: 6px;
    width: 18px;
    height: 18px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    z-index: 100;
    pointer-events: none;
}

.message.has-image {
    max-width: fit-content;
    padding: 0;
    background: transparent;
    box-shadow: none;
}

.message.has-video {
    max-width: fit-content;
    padding: 0;
    background: transparent;
    box-shadow: none;
}

.message.has-image.selected {
    background: transparent !important;
}

.message.has-image.selected .message-content {
    background: var(--accent-soft);
    position: relative;
}

.message.has-image.selected .message-content::after {
    content: 'вњ“';
    position: absolute;
    top: 4px;
    right: 6px;
    width: 18px;
    height: 18px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.message.has-image .message-content {
    padding: 8px 10px 10px 10px;
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.message.has-image .message-attachment.image {
    display: block;
    margin: 0;
    border-radius: 14px 14px 0 0;
}

.message.has-video .video-player {
    margin: 0;
    border-radius: 14px 14px 0 0;
}

.message.sent.has-video {
    border-bottom-right-radius: 6px;
}

.message.sent.has-video .video-player {
    border-bottom-right-radius: 6px;
}

.message.received.has-video {
    border-bottom-left-radius: 6px;
}

.message.received.has-video .video-player {
    border-bottom-left-radius: 6px;
}

.message.has-audio {
    max-width: 95%;
}

.message.sent.composer-flow {
    transform-origin: right bottom;
    animation: messageFromComposer 0.34s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.message-text {
    font-size: 13px;
    line-height: 1.35;
}

.message-attachment,
.attachment-link {
    margin-top: 2px;
}

.message.sent {
    align-self: flex-end;
    background: var(--sent);
    border-bottom-right-radius: 6px;
}

.message.received {
    align-self: flex-start;
    background: var(--received);
    border-bottom-left-radius: 6px;
}

.message-sender-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.message-sender-row-right {
    justify-content: flex-end;
    margin-bottom: 4px;
    margin-top: 6px;
}

/* РђРІР°С‚Р°СЂРєР° СЃРЅР°СЂСѓР¶Рё СЃРѕРѕР±С‰РµРЅРёСЏ (РіСЂСѓРїРїС‹/РєР°РЅР°Р»С‹) */
.message-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 100%;
    margin: 2px 0;
}

.message-wrapper.received {
    justify-content: flex-start;
}

.message-wrapper.sent {
    justify-content: flex-end;
}

.message-wrapper.sent .message {
    order: -1;
}

.message-avatar {
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.message-avatar:hover {
    transform: scale(1.05);
}

.message-sender-name {
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 4px;
}

.message.sent .message-sender-name {
    text-align: right;
}

.message .message-text {
    text-align: left;
    word-break: break-word;
}

.message.sent .message-text {
    text-align: left;
}

.message-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    width: 100%;
}

.message.sent .message-content {
    align-items: flex-end;
}

.message-time-wrap {
    margin-top: auto;
    display: flex;
    align-items: flex-end;
    gap: 5px;
}

.message.sent .message-time {
    flex-direction: row-reverse;
    align-self: flex-end;
}

.message-sender {
    font-size: 12px;
    color: var(--text-muted);
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
    text-align: right;
    display: flex;
    gap: 5px;
    justify-content: flex-end;
    align-items: center;
    white-space: nowrap;
}

.message-status {
    font-size: 11px;
    line-height: 1;
    color: var(--text-muted);
}

.message-status.read {
    color: #33a3ff;
}

/* РџР°РЅРµР»СЊ РІС‹РґРµР»РµРЅРёСЏ СЃРѕРѕР±С‰РµРЅРёР№ */
.selection-toolbar {
    position: absolute;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 8px 12px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--border);
    animation: toolbarSlideIn 0.2s ease;
}

@keyframes toolbarSlideIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.selection-toolbar.hidden {
    display: none;
}

.selection-toolbar-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.selection-count {
    background: var(--accent);
    color: white;
    font-weight: bold;
    font-size: 13px;
    min-width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.selection-label {
    font-size: 13px;
    color: var(--text);
    font-weight: 500;
}

.selection-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: var(--surface-soft);
    color: var(--text);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.selection-action-btn:hover {
    background: var(--border);
}

.selection-action-btn.danger {
    background: #ff4444;
    color: white;
}

.selection-action-btn.danger:hover {
    background: #ff3333;
}

.message-form {
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    background: var(--surface);
    flex-wrap: wrap;
    overflow-x: hidden;
}

.message-form input {
    flex: 1;
}

.attach-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    flex-shrink: 0;
    font-size: 20px;
}

.voice-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    flex-shrink: 0;
    font-size: 20px;
    background: var(--accent);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
    position: relative;
}

.voice-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.voice-btn.recording {
    background: #e8504f;
    color: #fff;
    box-shadow: 0 0 0 3px rgba(232, 80, 79, 0.18);
}

.voice-btn.locked {
    background: #e8504f;
    animation: voiceLockPulse 1.5s infinite ease-in-out;
}

@keyframes voiceLockPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(232, 80, 79, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(232, 80, 79, 0);
    }
}

/* Voice lock indicator */
.voice-lock-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.voice-btn.show-lock .voice-lock-indicator {
    opacity: 1;
}

/* Swipe guide */
.voice-swipe-guide {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 12px 20px;
    border-radius: 20px;
    font-size: 13px;
    z-index: 1000;
    display: none;
    align-items: center;
    gap: 8px;
}

.voice-swipe-guide.show {
    display: flex;
}

.voice-swipe-guide .lock-icon {
    font-size: 16px;
}

.voice-indicator {
    width: 100%;
    padding: 10px 14px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(232, 80, 79, 0.1), rgba(232, 80, 79, 0.05));
    border: 1px solid rgba(232, 80, 79, 0.3);
    color: var(--text);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: recordPulse 2s infinite ease-in-out;
}

@keyframes recordPulse {
    0%, 100% {
        border-color: rgba(232, 80, 79, 0.3);
    }
    50% {
        border-color: rgba(232, 80, 79, 0.6);
    }
}

.voice-indicator-text {
    display: flex;
    align-items: center;
    gap: 8px;
}

.voice-wave-container {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 2px;
    height: 24px;
    overflow: hidden;
}

.voice-wave-rec {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #e8504f;
    animation: recordingBlink 1s infinite ease-in-out;
    flex-shrink: 0;
}

@keyframes recordingBlink {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(0.9);
    }
}

.voice-wave-bars {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 2px;
    height: 100%;
}

.voice-wave-bar-live {
    flex: 1;
    min-width: 3px;
    background: linear-gradient(to top, #e8504f, #ff6b6b);
    border-radius: 2px;
    animation: liveWaveAnimation 0.8s ease-in-out infinite;
    transform-origin: center;
}

.voice-wave-bar-live:nth-child(odd) {
    animation-delay: 0s;
}

.voice-wave-bar-live:nth-child(even) {
    animation-delay: 0.15s;
}

.voice-wave-bar-live:nth-child(3n) {
    animation-delay: 0.3s;
}

.voice-wave-bar-live:nth-child(4n) {
    animation-delay: 0.45s;
}

@keyframes liveWaveAnimation {
    0%, 100% {
        transform: scaleY(0.2);
    }
    50% {
        transform: scaleY(1);
    }
}

.voice-timer {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: #e8504f;
}

.mention-suggest {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    max-height: 160px;
    overflow-y: auto;
}

.mention-item {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    text-align: left;
    cursor: pointer;
}

.mention-item:hover {
    background: var(--surface-soft);
}

.mention-item small {
    margin-left: auto;
    color: var(--text-muted);
}

.reply-preview {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px;
}

.reply-preview-content {
    min-width: 0;
}

.reply-preview-name {
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
}

.reply-preview-text {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 420px;
}

.reply-cancel {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

.message-reply {
    border-left: 3px solid var(--accent);
    padding-left: 8px;
    margin-bottom: 6px;
}

.message-reply-name {
    font-size: 11px;
    color: var(--accent);
    font-weight: 600;
}

.message-reply-text {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 320px;
}

.attachment-link {
    display: inline-block;
    margin-top: 4px;
    color: white;
    max-width: 100%;
}

.message-attachment {
    display: block;
    max-width: min(280px, 100%);
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-soft);
}

.message-attachment.image {
    max-width: 100%;
    max-height: 360px;
    width: auto;
    height: auto;
    object-fit: contain;
    cursor: pointer;
    display: block;
}

.message-attachment.video {
    max-width: min(360px, 100%);
    max-height: 360px;
    width: auto;
    height: auto;
    object-fit: contain;
    cursor: pointer;
}

.message-attachment.audio {
    width: min(280px, 100%);
    height: 48px;
}

/* Custom Audio Player */
.audio-player {
    display: flex;
    align-items: center;
    gap: 12px;
    width: min(420px, 90vw);
    min-width: 260px;
    padding: 10px 14px;
    border-radius: 12px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    transition: all 0.2s ease;
    position: relative;
}

/* Global audio player bar */
.global-audio-player {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 8px 12px;
}

.global-audio-player-body {
    width: 100%;
    max-width: 100%;
}

.global-audio-player-body .audio-progress {
    min-width: 140px;
}

.global-audio-title {
    font-size: 12px;
    color: var(--text-muted);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.audio-player:hover {
    background: rgba(var(--accent-rgb), 0.08);
    border-color: var(--accent);
}

.audio-play-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 6px rgba(var(--accent-rgb), 0.3);
}

.audio-play-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 3px 10px rgba(var(--accent-rgb), 0.4);
}

.audio-play-btn:active {
    transform: scale(0.95);
}

.audio-play-btn.playing {
    background: linear-gradient(135deg, #667eea, #764ba2);
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.5);
    animation: pulsePlaying 1.5s infinite ease-in-out;
}

@keyframes pulsePlaying {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.4);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(102, 126, 234, 0);
    }
}

.audio-time {
    font-size: 12px;
    color: var(--text-muted);
    min-width: 75px;
    text-align: center;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.audio-progress {
    flex: 1;
    height: 40px;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    transition: all 0.2s ease;
    user-select: none;
}

.audio-progress:hover {
    background: rgba(0, 0, 0, 0.15);
}

/* Volume bar visualization - on the back */
.audio-wave {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 0 12px;
    z-index: 0;
    pointer-events: none;
    opacity: 0.6;
}

/* Progress bar fill - visible progress - on top */
.audio-progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    border-radius: 20px;
    width: 0%;
    min-width: 0%;
    transition: width 0.1s linear;
    z-index: 1;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(var(--accent-rgb), 0.5);
}

/* Progress bar track (background) */
.audio-progress::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 20px;
    z-index: 0;
}

.audio-wave-bar {
    width: 3px;
    flex: 1;
    max-width: 3px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 2px;
    animation: volumeWave 1.5s ease-in-out infinite;
    transform-origin: center bottom;
}

.audio-wave-bar:nth-child(odd) {
    animation-delay: 0s;
}

.audio-wave-bar:nth-child(even) {
    animation-delay: 0.2s;
}

.audio-wave-bar:nth-child(3n) {
    animation-delay: 0.4s;
}

.audio-wave-bar:nth-child(4n) {
    animation-delay: 0.6s;
}

.audio-wave-bar:nth-child(5n) {
    animation-delay: 0.8s;
}

@keyframes volumeWave {
    0%, 100% {
        transform: scaleY(0.3);
        opacity: 0.6;
    }
    50% {
        transform: scaleY(1);
        opacity: 1;
    }
}

.audio-progress.playing .audio-wave-bar {
    animation-play-state: running;
}

.audio-progress:not(.playing) .audio-wave-bar {
    animation-play-state: paused;
    transform: scaleY(0.5);
    opacity: 0.8;
}

/* Progress handle for dragging */
.audio-progress-handle {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--accent);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: auto;
    cursor: grab;
    z-index: 3;
}

.audio-progress-handle:active {
    cursor: grabbing;
}

.audio-progress-bar:hover .audio-progress-handle,
.audio-progress-bar.playing .audio-progress-handle {
    opacity: 1;
}

.audio-progress-bar:active .audio-progress-handle {
    transform: translateY(-50%) scale(1.1);
}

.audio-filename {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

/* ==================== VIDEO PLAYER ==================== */
.video-player {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(480px, 95vw);
    min-width: 280px;
    border-radius: 12px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: all 0.2s ease;
}

.video-player:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 20px rgba(var(--accent-rgb), 0.15);
}

.video-thumbnail {
    position: relative;
    width: 100%;
    background: #000;
    cursor: pointer;
    overflow: hidden;
}

.video-thumbnail video {
    width: 100%;
    height: auto;
    max-height: 360px;
    display: block;
    object-fit: contain;
}

.video-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    transition: background 0.2s ease;
}

.video-thumbnail:hover .video-play-overlay {
    background: rgba(0, 0, 0, 0.5);
}

.video-play-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(var(--accent-rgb), 0.9);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: bold;
    box-shadow: 0 4px 20px rgba(var(--accent-rgb), 0.4);
    transition: transform 0.2s ease, background 0.2s ease;
}

.video-thumbnail:hover .video-play-icon {
    transform: scale(1.1);
    background: var(--accent);
}

.video-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 600;
}

.video-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.video-control-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--surface-soft);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.video-control-btn:hover {
    background: var(--accent);
    color: #fff;
    transform: scale(1.08);
}

.video-control-btn.playing {
    background: var(--accent);
    color: #fff;
}

.video-progress-container {
    flex: 1;
    height: 6px;
    background: var(--surface-soft);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.video-progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    border-radius: 3px;
    transition: height 0.1s ease;
}

.video-progress-container:hover .video-progress-bar {
    height: 100%;
}

.video-progress-handle {
    position: absolute;
    top: 50%;
    left: 0%;
    transform: translate(-50%, -50%) scale(0);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s ease;
    pointer-events: none;
}

.video-progress-container:hover .video-progress-handle {
    transform: translate(-50%, -50%) scale(1);
}

.video-time {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    min-width: 40px;
    text-align: center;
}

.video-fullscreen {
    font-size: 13px;
}

.attachment-file {
    display: inline-block;
    margin-top: 2px;
    padding: 5px 7px;
    border-radius: 7px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
}

.attachment-file.pending {
    opacity: 0.8;
}

.reaction-picker {
    position: absolute;
    top: 30px;
    left: 0;
    right: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 4px;
    display: none;
    gap: 2px;
    flex-wrap: wrap;
    width: max-content;
    max-width: min(170px, calc(100vw - 16px));
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
    box-sizing: border-box;
    z-index: 20;
}

.reaction-picker.open {
    display: flex;
}

.message.sent .reaction-picker {
    left: auto;
    right: 0;
}

.reaction-option {
    border: none;
    background: transparent;
    font-size: 16px;
    cursor: pointer;
    border-radius: 8px;
    padding: 4px;
}

.reaction-option:hover {
    background: var(--surface-soft);
}

.message-reactions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    pointer-events: auto;
    position: absolute;
    bottom: -24px;
    left: 8px;
}

.message.sent .message-reactions {
    justify-content: flex-end;
    left: auto;
    right: 8px;
}

.message.received .message-reactions {
    justify-content: flex-start;
}

/* РћС‚СЃС‚СѓРї СЃРЅРёР·Сѓ РґР»СЏ СЃРѕРѕР±С‰РµРЅРёР№ СЃ СЂРµР°РєС†РёСЏРјРё */
.message.has-reactions {
    margin-bottom: 24px;
}

.message-menu {
    position: absolute;
    top: 30px;
    right: 0;
    display: none !important;
    flex-direction: column;
    min-width: 130px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
    overflow: hidden;
    z-index: 15;
    max-width: calc(100vw - 16px);
    box-sizing: border-box;
}

.message.sent .message-menu {
    left: 0;
    right: auto;
}

.message-menu.open {
    display: none !important;
}

.message-menu-item {
    border: none;
    background: transparent;
    color: var(--text);
    text-align: left;
    padding: 9px 10px;
    cursor: pointer;
    font-size: 13px;
}

.message-menu-item:hover {
    background: var(--surface-soft);
}

.message-more-btn {
    display: none;
}

.reaction-chip {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    pointer-events: auto;
}

.reaction-chip.active {
    border-color: var(--accent);
    background: rgba(var(--accent-rgb), 0.14);
    color: var(--accent);
}

.reaction-avatars {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: 4px;
}

.reaction-avatar {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
}

.reaction-more {
    font-size: 10px;
    color: var(--text-muted);
    margin-left: 2px;
}

.btn-send {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    font-size: 16px;
    transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.2s ease, box-shadow 0.2s ease;
}

.btn-send:hover {
    background: var(--accent-hover);
    transform: scale(1.04);
}

.profile-form {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.profile-avatar-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.profile-avatar-wrap input {
    display: none;
}

.avatar-input-label {
    color: var(--accent);
    font-size: 14px;
}

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.settings-logout {
    margin: 0 12px 12px;
}

.setting-item {
    margin: 8px 12px 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--text);
    font-size: 14px;
    background: var(--surface);
}

.avatar {
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: #b9d7f4;
}

.avatar-sm {
    width: 32px;
    height: 32px;
}

.avatar-xs {
    width: 22px;
    height: 22px;
}

.avatar-lg {
    width: 68px;
    height: 68px;
}

.user-profile-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    animation: modalFadeIn 0.24s ease;
}

.user-profile-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    animation: backdropFadeIn 0.24s ease;
}

.user-profile-card {
    position: relative;
    z-index: 1;
    width: min(92vw, 360px);
    margin: 10vh auto 0;
    background: var(--surface);
    border-radius: 14px;
    border: 1px solid var(--border);
    padding: 20px;
    text-align: center;
    animation: modalSlideIn 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.reaction-users-card {
    text-align: left;
}

.reaction-users-card h3 {
    margin-bottom: 12px;
}

.group-modal-card {
    text-align: left;
    max-height: 80vh;
    overflow-y: auto;
}

.channel-modal-card {
    text-align: left;
    max-height: 85vh;
    overflow-y: auto;
}

.user-profile-close {
    position: absolute;
    right: 10px;
    top: 8px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
}

.user-profile-avatar {
    width: 84px;
    height: 84px;
    margin: 6px auto 10px;
}

.user-profile-username {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 3px;
}

.user-profile-bio {
    margin-top: 10px;
    font-size: 14px;
    color: var(--text);
    white-space: pre-wrap;
}

.modal-actions {
    margin-top: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

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

@keyframes messageFromComposer {
    0% {
        opacity: 0;
        transform: translateY(22px) scale(0.86);
        filter: blur(0.6px);
    }
    65% {
        opacity: 1;
        transform: translateY(-2px) scale(1.03);
        filter: blur(0);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

@keyframes fadeInPanel {
    from {
        opacity: 0.92;
    }
    to {
        opacity: 1;
    }
}

@keyframes blinkDot {
    0%, 80%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    40% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes backdropFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes chatComposeActionsSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

::-webkit-scrollbar {
    width: 7px;
}

::-webkit-scrollbar-thumb {
    background: #a9b8c4;
    border-radius: 8px;
}

@media (max-width: 900px) {
    html,
    body {
        width: 100%;
        height: 100dvh;
        min-height: -webkit-fill-available;
        overflow: hidden;
        overscroll-behavior: none;
    }

    body {
        background: var(--bg);
    }

    .container {
        padding: 0;
        height: 100dvh;
        min-height: -webkit-fill-available;
        overflow: hidden;
    }

    #chat-screen {
        height: 100dvh;
        min-height: -webkit-fill-available;
        border-radius: 0;
        box-shadow: none;
        padding-top: 0;
        overflow: hidden;
    }
    
    /* РџР°РЅРµР»СЊ РІС‹РґРµР»РµРЅРёСЏ РЅР° РјРѕР±РёР»СЊРЅС‹С… */
    .selection-toolbar {
        bottom: 60px;
        padding: 6px 10px;
    }
    
    .selection-count {
        min-width: 22px;
        height: 22px;
        font-size: 12px;
    }
    
    .selection-label {
        font-size: 12px;
    }
    
    .selection-action-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .chat-header h2 {
        font-size: 16px;
    }

    .chat-header {
        justify-content: flex-start;
        gap: 10px;
        position: relative;
        padding-top: calc(10px + env(safe-area-inset-top));
        min-height: calc(56px + env(safe-area-inset-top));
    }

    .mobile-header-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-header-actions {
        margin-left: auto;
        display: inline-flex;
        align-items: center;
        gap: 8px;
    }

    .user-info {
        display: none;
    }

    .chat-body {
        flex-direction: column;
        flex: 1;
        min-height: 0;
        padding-bottom: calc(66px + env(safe-area-inset-bottom));
        overflow: hidden;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        min-height: auto;
        height: auto;
        flex: 1;
        min-height: 0;
        transition: height 0.2s ease;
        align-self: flex-start;
    }

    .desktop-nav {
        display: none;
    }

    .chat-panel {
        display: none;
        flex: 1;
        min-height: 0;
    }

    .chat-panel-header {
        display: none;
    }

    .message {
        max-width: 75%;
        padding: 8px 9px 5px;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }

    .message-text,
    .message-attachment.image,
    .message-attachment.video {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
    }

    .message-text {
        font-size: 13px;
    }

    .message.received .reaction-picker,
    .message.received .message-menu {
        left: 0;
        right: auto;
    }

    .message.sent .reaction-picker,
    .message.sent .message-menu {
        right: 0;
        left: auto;
    }

    #chats-panel {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        overflow: hidden;
        padding: 8px;
    }

    #chats-panel .search-wrap {
        width: 100%;
        margin: 0;
    }

    #chats-panel .users-list {
        display: block;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 0;
        width: 100%;
    }

    #chat-screen.mobile-chat-active .chat-panel {
        display: flex;
        flex: 1;
        min-height: 0;
    }

    #chat-screen.mobile-chat-active .chat-panel-header {
        display: flex;
        border-bottom: 1px solid var(--border);
        background: var(--surface);
    }

    #chat-screen.mobile-chat-active.mobile-chats-expanded #chats-panel {
        flex-direction: column;
        align-items: stretch;
        padding: 8px;
    }

    #chat-screen.mobile-chat-active.mobile-chats-expanded #chats-panel h3,
    #chat-screen.mobile-chat-active.mobile-chats-expanded #chats-panel .search-wrap {
        display: block;
    }

    #chat-screen.mobile-chat-active.mobile-chats-expanded #chats-panel .users-list {
        display: block;
        overflow-y: auto;
        overflow-x: hidden;
    }

    #chat-screen.mobile-chat-active.mobile-chats-expanded #chats-panel .user-item {
        margin: 0 0 6px 0;
        padding: 10px 12px;
        min-width: auto;
        justify-content: space-between;
        background: transparent;
    }

    #chat-screen.mobile-chat-active.mobile-chats-expanded #chats-panel .user-item .user-name,
    #chat-screen.mobile-chat-active.mobile-chats-expanded #chats-panel .user-item .remove-contact {
        display: inline-block;
    }

    #chat-screen.mobile-chat-active.mobile-chats-expanded #chats-panel .user-item .contact-tools {
        display: inline-flex;
        position: static;
    }

    #chat-screen.mobile-chat-active.mobile-chats-expanded #chats-panel .user-item .user-main {
        justify-content: flex-start;
        gap: 10px;
    }

    #chat-screen.mobile-chat-active.mobile-chats-expanded #chats-panel .user-item .avatar {
        width: 32px;
        height: 32px;
        border: none;
    }

    .message-reply-text,
    .reply-preview-text {
        max-width: 180px;
    }

    .message-attachment {
        max-width: min(240px, 100%);
        max-height: 220px;
    }
    
    .message-attachment.image {
        max-width: 100% !important;
        max-height: 280px;
    }

    .video-player {
        width: min(100%, 480px);
        min-width: 280px;
    }

    .video-thumbnail video {
        max-height: 280px;
    }

    .video-play-icon {
        width: 52px;
        height: 52px;
        font-size: 22px;
    }

    .video-controls {
        padding: 8px 10px;
        gap: 8px;
    }

    .video-control-btn {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }

    .video-time {
        min-width: 35px;
        font-size: 10px;
    }

    .remove-contact {
        opacity: 0.75;
    }

    .pin-contact {
        opacity: 1;
    }

    .chat-context-menu {
        min-width: 210px;
        border-radius: 14px;
        padding: 8px;
    }

    .chat-context-action {
        padding: 12px 14px;
        font-size: 15px;
    }

    .group-modal-card {
        width: min(96vw, 420px);
        max-height: 84vh;
    }

    .channel-modal-card {
        width: min(96vw, 420px);
        max-height: 88vh;
    }

    .mention-suggest {
        max-height: 130px;
    }

    .message-form {
        position: relative;
        z-index: 2;
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }

    .message {
        padding-bottom: 8px;
    }

    .message-reactions {
        width: 100%;
        position: absolute;
        bottom: -21.5px;
        margin-top: 0;
        height: auto;
        pointer-events: auto;
        left: 2px !important;
        right: auto !important;
    }

    .message.sent .message-reactions {
        left: auto !important;
        right: 8px !important;
    }

    .message.received .message-reactions {
        left: 8px !important;
        right: auto !important;
    }

    /* РћС‚СЃС‚СѓРї РґР»СЏ СЃРѕРѕР±С‰РµРЅРёР№ СЃ СЂРµР°РєС†РёСЏРјРё РЅР° РјРѕР±РёР»СЊРЅС‹С… */
    .message.has-reactions {
        margin-bottom: 24px;
    }
    
    /* Р”РѕРїРѕР»РЅРёС‚РµР»СЊРЅС‹Р№ РѕС‚СЃС‚СѓРї РґР»СЏ РїРѕСЃР»РµРґРЅРµРіРѕ СЃРѕРѕР±С‰РµРЅРёСЏ СЃ СЂРµР°РєС†РёСЏРјРё */
    .messages-list .message:last-child.has-reactions {
        margin-bottom: 32px;
    }

    .chats-compose {
        bottom: calc(76px + env(safe-area-inset-bottom));
        display: flex;
    }

/* РЈРЅРёРІРµСЂСЃР°Р»СЊРЅС‹Р№ РјРµРґРёР°РїР»РµРµСЂ */
.media-attachment-wrapper {
    display: inline-block;
    max-width: min(400px, 100%);
    margin-top: 6px;
}

.media-container {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    background: var(--surface-soft);
    border: 1px solid var(--border);
}

.media-container.media-image {
    max-width: min(400px, 100%);
    max-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-container.media-video {
    max-width: min(400px, 100%);
    max-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-container.media-audio {
    width: min(320px, 100%);
    padding: 0;
    background: transparent;
    border: none;
}

.media-content {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
    cursor: pointer;
}

.media-container.media-audio .media-content {
    height: 38px;
    max-height: none;
}

.media-container.media-video .media-content {
    max-height: 280px;
}

.media-expand-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.2s ease;
}

.media-container:hover .media-expand-btn {
    opacity: 1;
}

.media-expand-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

.media-caption {
    font-size: 12px;
    color: var(--text-muted);
    padding: 6px 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Voice Message Mini Player */
.voice-message-player {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: linear-gradient(135deg, var(--surface-soft) 0%, var(--surface) 100%);
    border: 1px solid var(--border);
    border-radius: 24px;
    min-width: 220px;
    max-width: 320px;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.voice-message-player:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(var(--accent-rgb), 0.15);
}

.voice-message-player.sent {
    background: linear-gradient(135deg, #e8f4fc 0%, #d9f1ff 100%);
    border-color: #b8dcf5;
}

body[data-theme="dark"] .voice-message-player.sent {
    background: linear-gradient(135deg, #1e3a52 0%, #2b5278 100%);
    border-color: #3d6a8a;
}

.voice-play-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 0 2px 6px rgba(var(--accent-rgb), 0.3);
}

.voice-play-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

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

.voice-play-btn.playing {
    background: #e8504f;
    animation: voicePulse 1s infinite ease-in-out;
}

@keyframes voicePulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(232, 80, 79, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(232, 80, 79, 0);
    }
}

.voice-waveform {
    flex: 1;
    height: 32px;
    position: relative;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 4px;
}

.voice-waveform-bar {
    width: 3px;
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    opacity: 0.4;
    transition: opacity 0.15s ease;
}

.voice-message-player.sent .voice-waveform-bar {
    background: #2a8bc7;
}

body[data-theme="dark"] .voice-message-player.sent .voice-waveform-bar {
    background: #5ba4e0;
}

.voice-waveform-bar.active {
    opacity: 1;
}

.voice-waveform-bar.playing {
    animation: waveAnimation 0.6s ease-in-out infinite alternate;
}

@keyframes waveAnimation {
    0% {
        transform: scaleY(0.3);
    }
    100% {
        transform: scaleY(1);
    }
}

.voice-waveform-bar:nth-child(1) { animation-delay: 0s; }
.voice-waveform-bar:nth-child(2) { animation-delay: 0.1s; }
.voice-waveform-bar:nth-child(3) { animation-delay: 0.2s; }
.voice-waveform-bar:nth-child(4) { animation-delay: 0.15s; }
.voice-waveform-bar:nth-child(5) { animation-delay: 0.05s; }
.voice-waveform-bar:nth-child(6) { animation-delay: 0.25s; }
.voice-waveform-bar:nth-child(7) { animation-delay: 0.1s; }
.voice-waveform-bar:nth-child(8) { animation-delay: 0.3s; }
.voice-waveform-bar:nth-child(9) { animation-delay: 0.2s; }
.voice-waveform-bar:nth-child(10) { animation-delay: 0.15s; }
.voice-waveform-bar:nth-child(11) { animation-delay: 0.05s; }
.voice-waveform-bar:nth-child(12) { animation-delay: 0.25s; }

.voice-duration {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    min-width: 40px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.voice-message-player.sent .voice-duration {
    color: #2a8bc7;
}

body[data-theme="dark"] .voice-message-player.sent .voice-duration {
    color: #5ba4e0;
}

/* Progress bar for voice message */
.voice-progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
    transition: width 0.1s linear;
}

.voice-message-player.sent .voice-progress-bar {
    background: #2a8bc7;
}

body[data-theme="dark"] .voice-message-player.sent .voice-progress-bar {
    background: #5ba4e0;
}

/* Voice message in message context */
.message .voice-message-player {
    margin-top: 4px;
    margin-bottom: 2px;
}

/* Hide default audio controls */
.voice-message-player audio {
    display: none;
}

/* ==================== MEDIA VIEWER (PC) ==================== */
#media-viewer-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
}

#media-viewer-modal:not(.hidden) {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

#media-viewer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1;
}

.media-viewer-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.media-viewer-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 28px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.media-viewer-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.media-viewer-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 28px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.media-viewer-nav:hover {
    background: rgba(255, 255, 255, 0.3);
}

.media-viewer-prev {
    left: 16px;
}

.media-viewer-next {
    right: 16px;
}

.media-viewer-content {
    max-width: 90%;
    max-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 3;
}

.media-viewer-content img,
.media-viewer-content video {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    display: block;
}

#media-viewer-caption {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 14px;
    background: rgba(0, 0, 0, 0.6);
    padding: 8px 16px;
    border-radius: 20px;
    max-width: 80%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 4;
}

/* Video controls */
.media-viewer-video-wrapper {
    position: relative;
    max-width: 100%;
    max-height: 75vh;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    z-index: 3;
}

.media-viewer-video-wrapper video {
    display: block;
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
}

.media-viewer-video-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 4;
}

.media-viewer-video-wrapper:hover .media-viewer-video-controls,
.media-viewer-video-wrapper.paused .media-viewer-video-controls {
    opacity: 1;
}

.media-viewer-video-progress {
    position: relative;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    cursor: pointer;
    flex: 1;
}

.media-viewer-video-progress-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: #fff;
    border-radius: 2px;
    width: 0;
}

.media-viewer-video-controls-row {
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 5;
}

.media-viewer-video-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.media-viewer-video-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.08);
}

.media-viewer-video-time {
    font-size: 14px;
    color: #fff;
    font-weight: 600;
    min-width: 100px;
    text-align: center;
}

.media-viewer-video-spacer {
    flex: 1;
}

/* РњРѕРґР°Р»СЊРЅРѕРµ РѕРєРЅРѕ РїСЂРѕСЃРјРѕС‚СЂР° РјРµРґРёР° */
.media-viewer-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

#media-viewer-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
}

#media-viewer-modal:not(.hidden) {
    display: flex;
    align-items: center;
    justify-content: center;
}

#media-viewer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1;
}

.media-viewer-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 28px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-viewer-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.media-viewer-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 28px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-viewer-nav:hover {
    background: rgba(255, 255, 255, 0.3);
}

.media-viewer-prev {
    left: 16px;
}

.media-viewer-next {
    right: 16px;
}

.media-viewer-content {
    max-width: 90%;
    max-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 3;
}

.media-viewer-content img,
.media-viewer-content video {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    display: block;
}

#media-viewer-caption {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 14px;
    background: rgba(0, 0, 0, 0.6);
    padding: 8px 16px;
    border-radius: 20px;
    max-width: 80%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 4;
}

/* РЎРєСЂС‹РІР°РµРј СЃС‚Р°РЅРґР°СЂС‚РЅС‹Рµ РєРѕРЅС‚СЂпїЅпїЅР»С‹ РІРёРґРµРѕ */
.media-viewer-video-wrapper video::-webkit-media-controls {
    display: none !important;
}
.media-viewer-video-wrapper video::-webkit-media-controls-play-button {
    display: none !important;
}
.media-viewer-video-wrapper video::-webkit-media-controls-current-time-display,
.media-viewer-video-wrapper video::-webkit-media-controls-time-remaining-display {
    display: none !important;
}

/* Р’РёРґРµРѕ РІ РјРµРґРёР°-РІСЊСЋРµСЂРµ СЃ РєР°СЃС‚РѕРјРЅС‹РјРё РєРѕРЅС‚СЂРѕР»Р°РјРё */

.media-viewer-video-wrapper {
    position: relative;
    max-width: 100%;
    max-height: 75vh;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    z-index: 3;
}

.media-viewer-video-wrapper video {
    display: block;
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
}

.media-viewer-video-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 4;
}

.media-viewer-video-wrapper:hover .media-viewer-video-controls,
.media-viewer-video-wrapper.paused .media-viewer-video-controls {
    opacity: 1;
}

.media-viewer-video-progress {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.media-viewer-video-progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 3px;
    transition: height 0.1s ease;
}

.media-viewer-video-progress:hover .media-viewer-video-progress-bar {
    height: 100%;
}

.media-viewer-video-controls-row {
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 5;
}

.media-viewer-video-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.media-viewer-video-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.08);
}

.media-viewer-video-time {
    font-size: 14px;
    color: #fff;
    font-weight: 600;
    min-width: 100px;
    text-align: center;
}

.media-viewer-video-spacer {
    flex: 1;
}

.media-viewer-caption {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 14px;
    background: rgba(0, 0, 0, 0.6);
    padding: 8px 16px;
    border-radius: 20px;
    max-width: 80%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 4;
}

}

/* ==================== MEDIA VIEWER (PC > 900px) ==================== */
@media (min-width: 901px) {
    #media-viewer-modal {
        position: fixed;
        inset: 0;
        z-index: 10000;
        display: none;
    }

    #media-viewer-modal:not(.hidden) {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }

    #media-viewer-backdrop {
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, 0.95);
        z-index: 1;
    }

    .media-viewer-container {
        position: relative;
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        z-index: 2;
    }

    .media-viewer-close {
        position: absolute;
        top: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.2);
        color: #fff;
        border: none;
        cursor: pointer;
        font-size: 28px;
        z-index: 10;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.2s ease;
    }

    .media-viewer-close:hover {
        background: rgba(255, 255, 255, 0.3);
    }

    .media-viewer-nav {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.2);
        color: #fff;
        border: none;
        cursor: pointer;
        font-size: 28px;
        z-index: 10;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.2s ease;
    }

    .media-viewer-nav:hover {
        background: rgba(255, 255, 255, 0.3);
    }

    .media-viewer-prev {
        left: 16px;
    }

    .media-viewer-next {
        right: 16px;
    }

    .media-viewer-content {
        max-width: 90%;
        max-height: 80vh;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
        z-index: 3;
    }

    .media-viewer-content img,
    .media-viewer-content video {
        max-width: 100%;
        max-height: 75vh;
        object-fit: contain;
        display: block;
    }

    #media-viewer-caption {
        position: absolute;
        bottom: 24px;
        left: 50%;
        transform: translateX(-50%);
        color: #fff;
        font-size: 14px;
        background: rgba(0, 0, 0, 0.6);
        padding: 8px 16px;
        border-radius: 20px;
        max-width: 80%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        z-index: 4;
    }

    .media-viewer-video-wrapper {
        position: relative;
        max-width: 100%;
        max-height: 75vh;
        background: #000;
        border-radius: 12px;
        overflow: hidden;
        display: flex;
        z-index: 3;
    }

    .media-viewer-video-wrapper video {
        display: block;
        max-width: 100%;
        max-height: 75vh;
        object-fit: contain;
    }

    .media-viewer-video-controls {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
        padding: 16px;
        display: flex;
        flex-direction: column;
        gap: 10px;
        opacity: 0;
        transition: opacity 0.3s ease;
        z-index: 4;
    }

    .media-viewer-video-wrapper:hover .media-viewer-video-controls,
    .media-viewer-video-wrapper.paused .media-viewer-video-controls {
        opacity: 1;
    }

    .media-viewer-video-progress {
        position: relative;
        height: 4px;
        background: rgba(255, 255, 255, 0.3);
        border-radius: 2px;
        cursor: pointer;
        flex: 1;
    }

    .media-viewer-video-progress-bar {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        background: #fff;
        border-radius: 2px;
        width: 0;
    }

    .media-viewer-video-controls-row {
        display: flex;
        align-items: center;
        gap: 12px;
        z-index: 5;
    }

    .media-viewer-video-btn {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        border: none;
        background: rgba(255, 255, 255, 0.2);
        color: #fff;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 20px;
        flex-shrink: 0;
        transition: all 0.2s ease;
    }

    .media-viewer-video-btn:hover {
        background: rgba(255, 255, 255, 0.3);
        transform: scale(1.08);
    }

    .media-viewer-video-time {
        font-size: 14px;
        color: #fff;
        font-weight: 600;
        min-width: 100px;
        text-align: center;
    }

    .media-viewer-video-spacer {
        flex: 1;
    }
}

@media (max-width: 900px) {
    /* Audio message on mobile */
    .message.has-audio {
        max-width: 100%;
    }
    
    .audio-player {
        width: min(280px, 85vw);
        min-width: 200px;
        padding: 8px 10px;
        gap: 8px;
    }
    
    .audio-play-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .audio-progress {
        min-width: 80px;
    }
    
    .audio-time {
        font-size: 10px;
        min-width: 60px;
    }
    
    .audio-wave {
        height: 100%;
        padding: 0 8px;
        gap: 1px;
    }
    
    .audio-wave-bar {
        width: 2px;
        max-width: 2px;
    }

    .global-audio-title {
        display: none;
    }

    .media-viewer-nav {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
    .media-viewer-prev {
        left: 8px;
    }
    .media-viewer-next {
        right: 8px;
    }
    .media-viewer-close {
        top: 8px;
        right: 8px;
        width: 32px;
        height: 32px;
        font-size: 20px;
    }
    .media-viewer-content {
        max-width: 100%;
    }
    .media-viewer-content img,
    .media-viewer-content video {
        max-height: 65vh;
    }
    .media-viewer-video-wrapper {
        max-height: 65vh;
    }
    .media-viewer-video-wrapper video {
        max-height: 65vh;
    }
    .media-viewer-video-controls {
        padding: 12px;
    }
    .media-viewer-video-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
    .media-viewer-video-time {
        font-size: 11px;
        min-width: 70px;
    }
    .media-viewer-caption {
        bottom: 16px;
        font-size: 12px;
        padding: 6px 12px;
        max-width: 90%;
    }

    /* Message context menu on mobile - compact */
    .message-context-menu {
        bottom: auto;
        left: 50% !important;
        right: auto;
        transform: translateX(-50%) scale(1) !important;
        min-width: 160px;
        max-width: calc(100vw - 32px);
        padding: 8px;
        border-radius: 12px;
    }

    .message-context-btn {
        padding: 8px 12px;
        font-size: 13px;
        gap: 6px;
    }

    .message-context-close {
        top: 6px;
        right: 6px;
        width: 24px;
        height: 24px;
        font-size: 18px;
    }

    .message-context-emoji-panel {
        margin-top: 8px;
        padding-top: 8px;
    }

    .message-context-emoji-title {
        font-size: 11px;
        margin-bottom: 6px;
    }

    .message-context-emojis {
        gap: 6px;
    }

    .message-context-emoji-btn {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }
}
