:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #2d2d2d;
    --bg-quaternary: #404040;
    --bg-hover: #3a3a3a;
    --bg-active: #4a4a4a;
    --bg-modal: #1a1a1a;
    --bg-card: #1a1a1a;
    --bg-surface: #1a1a1a;
    --bg-message-in: #252525;
    --bg-message-out: #527c9e;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-muted: #808080;
    --text-placeholder: #666666;
    --accent: #527c9e;
    --accent-hover: #6a9ab5;
    --accent-light: rgba(82, 124, 158, 0.2);
    --danger: #e17055;
    --danger-hover: #d55a40;
    --danger-light: rgba(225, 112, 85, 0.2);
    --success: #00b894;
    --success-hover: #00a884;
    --success-light: rgba(0, 184, 148, 0.2);
    --warning: #fdcb6e;
    --warning-light: rgba(253, 203, 110, 0.2);
    --gold: #fbbf24;
    --gold-hover: #f59e0b;
    --gold-light: rgba(251, 191, 36, 0.2);
    --info: #74b9ff;
    --info-light: rgba(116, 185, 255, 0.2);
    --border-color: #3a3a3a;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.4);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.5);
    --shadow-xl: 0 8px 32px rgba(0,0,0,0.6);
    --transition-fast: 0.1s ease;
    --transition: 0.15s ease;
    --transition-slow: 0.3s ease;
    --sidebar-width: 350px;
    --info-width: 320px;
    --header-height: 60px;
    --message-max-width: 65%;
    --border-radius-sm: 8px;
    --border-radius: 12px;
    --border-radius-lg: 20px;
    --border-radius-xl: 28px;
    --border-radius-full: 50%;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Courier New', monospace;
    --z-fab: 25;
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-sidebar: 500;
    --z-modal: 1000;
    --z-popover: 1100;
    --z-toast: 1200;
    --z-context-menu: 10000;
    --z-media-viewer: 20000;
    --wallpaper-opacity: 0.15;
}

[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-tertiary: #e8e8e8;
    --bg-quaternary: #d4d4d4;
    --bg-hover: #e0e0e0;
    --bg-active: #cccccc;
    --bg-modal: #ffffff;
    --bg-card: #f8f8f8;
    --bg-surface: #ffffff;
    --bg-message-in: #e8e8e8;
    --bg-message-out: #4a90d9;
    --text-primary: #1a1a1a;
    --text-secondary: #555555;
    --text-muted: #888888;
    --text-placeholder: #aaaaaa;
    --accent: #4a90d9;
    --accent-hover: #3570b0;
    --accent-light: rgba(74, 144, 217, 0.1);
    --danger: #e15554;
    --danger-hover: #c94040;
    --success: #00a884;
    --warning: #e6a020;
    --gold: #d4a017;
    --border-color: #dddddd;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
    --shadow-xl: 0 8px 32px rgba(0,0,0,0.2);
    --wallpaper-opacity: 0.5;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; height: 100%; overflow: hidden; }
body { font-family: var(--font-family); background: var(--bg-primary); color: var(--text-primary); height: 100vh; height: 100dvh; overflow: hidden; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; line-height: 1.45; user-select: none; -webkit-user-select: none; max-width: 100vw; overflow-x: hidden; }

h1,h2,h3,h4,h5,h6 { font-weight: 600; line-height: 1.2; color: var(--text-primary); }
h1 { font-size: 32px; } h2 { font-size: 28px; } h3 { font-size: 20px; } h4 { font-size: 16px; }
p { margin-bottom: 8px; color: var(--text-secondary); }
small { font-size: 12px; color: var(--text-muted); }
a { color: var(--accent); text-decoration: none; transition: var(--transition); }
a:hover { text-decoration: underline; color: var(--accent-hover); }
kbd { background: var(--bg-tertiary); padding: 2px 8px; border-radius: 4px; font-size: 13px; font-family: var(--font-mono); border: 1px solid var(--border-color); }
code { background: var(--bg-tertiary); padding: 2px 6px; border-radius: 4px; font-family: var(--font-mono); font-size: 0.9em; }

button { cursor: pointer; border: none; background: none; font-family: inherit; transition: var(--transition); touch-action: manipulation; -webkit-tap-highlight-color: transparent; color: var(--text-primary); position: relative; z-index: 1; }
button:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 20px; background: var(--bg-tertiary); border-radius: var(--border-radius); color: var(--text-primary); font-size: 15px; font-weight: 500; border: 1px solid transparent; transition: all 0.2s ease; white-space: nowrap; cursor: pointer; pointer-events: auto; }
.btn:hover { background: var(--bg-quaternary); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: white; padding: 12px 24px; border-radius: 30px; font-size: 16px; font-weight: 600; box-shadow: var(--shadow-md); border: 1px solid var(--accent); cursor: pointer; pointer-events: auto; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--accent-hover); }
.btn-primary:active { transform: scale(0.97); }
.btn-danger { background: var(--danger-light); color: var(--danger); border: 1px solid transparent; cursor: pointer; }
.btn-danger:hover { background: var(--danger); color: white; border-color: var(--danger); }
.btn-block { width: 100%; display: flex; }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; color: var(--text-secondary); font-size: 14px; font-weight: 500; }
.form-control { width: 100%; padding: 12px 16px; background: var(--bg-tertiary); border: 1.5px solid var(--border-color); border-radius: var(--border-radius); color: var(--text-primary); font-size: 16px; outline: none; transition: border-color 0.2s ease, box-shadow 0.2s ease; font-family: var(--font-family); -webkit-appearance: none; -moz-appearance: none; appearance: none; pointer-events: auto; }
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); outline: none; }
.form-control::placeholder { color: var(--text-placeholder); }
textarea.form-control { resize: vertical; min-height: 80px; line-height: 1.5; }
select.form-control { cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999999' d='M6 9L1 4h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; padding-right: 40px; }
input:focus, textarea:focus, select:focus { outline: none !important; border-color: var(--accent) !important; box-shadow: 0 0 0 3px var(--accent-light) !important; }

.input-icon { display: flex; align-items: center; background: var(--bg-tertiary); border: 1.5px solid var(--border-color); border-radius: var(--border-radius); padding: 0 16px; transition: border-color 0.2s ease, box-shadow 0.2s ease; position: relative; pointer-events: auto; }
.input-icon:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.input-icon i { color: var(--text-muted); margin-right: 12px; font-size: 16px; flex-shrink: 0; }
.input-icon input { flex: 1; padding: 14px 0; background: transparent; border: none; color: var(--text-primary); font-size: 16px; outline: none; font-family: var(--font-family); pointer-events: auto; }
.input-icon input:focus { outline: none; box-shadow: none; }
.input-icon .toggle-password { background: none; border: none; color: var(--text-muted); padding: 14px 12px; cursor: pointer; flex-shrink: 0; font-size: 18px; pointer-events: auto; }
.input-icon .toggle-password:hover { color: var(--text-primary); }
.checkbox-group { display: flex; align-items: center; gap: 10px; cursor: pointer; color: var(--text-secondary); pointer-events: auto; }
.checkbox-group input[type="checkbox"] { width: 20px; height: 20px; margin: 0; cursor: pointer; accent-color: var(--accent); pointer-events: auto; }
.switch { position: relative; display: inline-block; width: 50px; height: 26px; flex-shrink: 0; pointer-events: auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--bg-quaternary); transition: .3s; border-radius: 26px; }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 3px; bottom: 3px; background-color: white; transition: .3s; border-radius: 50%; }
input:checked + .slider { background-color: var(--accent); }
input:checked + .slider:before { transform: translateX(24px); }

input[type="range"] { -webkit-appearance: none; appearance: none; height: 6px; background: var(--bg-tertiary); border-radius: 3px; outline: none; cursor: pointer; pointer-events: auto; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); cursor: pointer; border: 2px solid white; box-shadow: 0 2px 6px rgba(0,0,0,0.3); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes slideInUp { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideOutDown { from { transform: translateY(0); opacity: 1; } to { transform: translateY(100%); opacity: 0; } }
@keyframes slideInDown { from { transform: translateY(-100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideOutUp { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-100%); opacity: 0; } }
@keyframes slideInLeft { from { transform: translateX(-100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOutLeft { from { transform: translateX(0); opacity: 1; } to { transform: translateX(-100%); opacity: 0; } }
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOutRight { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }
@keyframes scaleIn { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes scaleOut { from { transform: scale(1); opacity: 1; } to { transform: scale(0.8); opacity: 0; } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes wave { 0%,100% { transform: scaleY(1); } 50% { transform: scaleY(2); } }
@keyframes messageAppear { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes crownGlow { 0%,100% { filter: drop-shadow(0 0 2px var(--gold)); transform: scale(1); } 25% { filter: drop-shadow(0 0 6px var(--gold)); transform: scale(1.15); } 50% { filter: drop-shadow(0 0 3px var(--gold)); transform: scale(1); } 75% { filter: drop-shadow(0 0 8px var(--gold)); transform: scale(1.1); } }
.crown-animated { display: inline-block; animation: crownGlow 2s ease-in-out infinite; }

.highlight-animation { animation: highlightPulse 2s ease; }
@keyframes highlightPulse { 0% { background: var(--warning); } 100% { background: transparent; } }

.loading-screen { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: var(--bg-primary); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 9999; transition: opacity 0.5s ease; }
.loading-logo { display: flex; flex-direction: column; align-items: center; gap: 16px; margin-bottom: 24px; }
.loading-logo span { font-size: 48px; font-weight: bold; color: var(--accent); letter-spacing: 6px; animation: pulse 1.5s infinite; }
.loading-spinner { width: 40px; height: 40px; border: 3px solid var(--border-color); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
.loading-text { margin-top: 16px; color: var(--text-muted); font-size: 14px; }

.auth-screen { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: var(--bg-primary); display: flex; align-items: center; justify-content: center; z-index: 1000; overflow-y: auto; padding: 20px; }
.auth-container { width: 100%; max-width: 440px; background: var(--bg-secondary); border-radius: var(--border-radius-xl); padding: 32px; box-shadow: var(--shadow-xl); border: 1px solid var(--border-color); animation: scaleIn 0.3s ease; position: relative; }
.auth-logo { text-align: center; margin-bottom: 32px; }
.auth-logo-icon { font-size: 56px; color: var(--accent); margin-bottom: 12px; }
.auth-logo h1 { font-size: 32px; margin-bottom: 6px; color: var(--text-primary); }
.auth-logo h2 { font-size: 24px; margin-bottom: 6px; color: var(--text-primary); }
.auth-logo p { color: var(--text-muted); font-size: 15px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 28px; background: var(--bg-tertiary); padding: 4px; border-radius: var(--border-radius-lg); }
.auth-tab { flex: 1; padding: 12px; border: none; background: transparent; color: var(--text-secondary); font-size: 16px; font-weight: 500; cursor: pointer; border-radius: var(--border-radius); transition: all 0.2s ease; display: flex; align-items: center; justify-content: center; gap: 8px; pointer-events: auto; }
.auth-tab.active { background: var(--accent); color: white; }
.auth-tab:hover:not(.active) { color: var(--text-primary); background: var(--bg-hover); }
.auth-form { display: none; }
.auth-form.active { display: block; animation: fadeIn 0.3s ease; }
.auth-btn { width: 100%; padding: 16px; background: var(--accent); border: none; border-radius: var(--border-radius); color: white; font-size: 16px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 24px; transition: all 0.2s ease; border: 1px solid var(--accent); pointer-events: auto; }
.auth-btn:hover { background: var(--accent-hover); transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--accent-hover); }
.auth-btn:active { transform: scale(0.98); }
.auth-footer { text-align: center; margin-top: 24px; color: var(--text-muted); font-size: 14px; }
.auth-footer a { color: var(--accent); font-weight: 500; cursor: pointer; pointer-events: auto; }
.auth-footer a:hover { text-decoration: underline; }
.auth-version { text-align: center; margin-top: 20px; font-size: 12px; color: var(--text-muted); opacity: 0.5; }
.recaptcha-container { display: flex; justify-content: center; margin-bottom: 20px; overflow: hidden; max-width: 100%; }
.recaptcha-container > * { max-width: 100%; transform: scale(0.9); transform-origin: center top; }

.main-screen { display: flex; height: 100vh; height: 100dvh; width: 100%; position: relative; }
.sidebar { width: var(--sidebar-width); background: var(--bg-secondary); border-right: 1px solid var(--border-color); display: flex; flex-direction: column; position: relative; flex-shrink: 0; z-index: 10; }
.sidebar-header { height: var(--header-height); padding: 0 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border-color); gap: 12px; }
.sidebar-title { font-size: 20px; font-weight: 700; color: var(--text-primary); flex: 1; cursor: pointer; user-select: none; }
.menu-btn, .search-btn { width: 44px; height: 44px; border-radius: var(--border-radius-full); display: flex; align-items: center; justify-content: center; font-size: 20px; color: var(--text-primary); background: var(--bg-tertiary); cursor: pointer; border: 1px solid transparent; transition: all 0.2s ease; flex-shrink: 0; pointer-events: auto; }
.menu-btn:hover, .search-btn:hover { background: var(--bg-quaternary); color: var(--accent); }

.sidebar-menu { position: fixed; top: 0; left: 0; width: 300px; height: 100vh; height: 100dvh; background: var(--bg-secondary); z-index: var(--z-sidebar); display: none; flex-direction: column; box-shadow: var(--shadow-xl); border-right: 1px solid var(--border-color); animation: slideInLeft 0.3s ease; padding-top: 20px; pointer-events: auto; }
.menu-profile { padding: 16px 20px; display: flex; align-items: center; gap: 15px; cursor: pointer; background: transparent; transition: background 0.2s ease; border-radius: var(--border-radius); margin: 0 12px 12px; pointer-events: auto; }
.menu-profile:hover { background: var(--bg-tertiary); }
.menu-avatar { width: 50px; height: 50px; border-radius: var(--border-radius-full); display: flex; align-items: center; justify-content: center; font-size: 20px; color: white; background: var(--accent); overflow: hidden; flex-shrink: 0; }
.menu-avatar img { width: 100%; height: 100%; object-fit: cover; }
.menu-profile-info { flex: 1; min-width: 0; }
.menu-name { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-primary); }
.menu-username { font-size: 14px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-items { flex: 1; overflow-y: auto; padding: 4px 0; }
.menu-item { display: flex; align-items: center; gap: 15px; padding: 12px 20px; color: var(--text-primary); cursor: pointer; background: transparent; width: 100%; transition: background 0.2s ease; font-size: 15px; border: none; text-align: left; pointer-events: auto; }
.menu-item:hover { background: var(--bg-tertiary); }
.menu-item i { width: 24px; color: var(--accent); font-size: 18px; text-align: center; }
.menu-item.danger { color: var(--danger); }
.menu-item.danger i { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-light); }
.menu-divider { height: 1px; background: var(--border-color); margin: 4px 0; }
.menu-version { padding: 16px; text-align: center; font-size: 12px; color: var(--text-muted); opacity: 0.5; }

.close-menu-btn { width: 44px; height: 44px; border-radius: var(--border-radius-full); display: flex; align-items: center; justify-content: center; font-size: 22px; color: var(--text-muted); background: var(--bg-tertiary); cursor: pointer; transition: all 0.2s ease; position: absolute; top: 20px; right: 16px; pointer-events: auto; }
.close-menu-btn:hover { background: var(--bg-quaternary); color: var(--text-primary); }

.sidebar-search { height: var(--header-height); padding: 0 16px; display: none; align-items: center; gap: 10px; border-bottom: 1px solid var(--border-color); animation: slideInDown 0.3s ease; }
.sidebar-search i { color: var(--text-muted); }
.sidebar-search input { flex: 1; background: none; border: none; color: var(--text-primary); font-size: 16px; outline: none; font-family: var(--font-family); pointer-events: auto; }
.sidebar-search input::placeholder { color: var(--text-muted); }
.close-search-btn { padding: 8px; color: var(--text-muted); cursor: pointer; background: transparent; border: none; font-size: 16px; transition: color 0.2s ease; pointer-events: auto; }
.close-search-btn:hover { color: var(--text-primary); }

.chat-list { flex: 1; overflow-y: auto; padding: 8px; }
.chat-folder-list { display: flex; gap: 6px; padding: 8px; overflow-x: auto; scroll-behavior: smooth; scrollbar-width: none; -ms-overflow-style: none; border-bottom: 1px solid var(--border-color); flex-shrink: 0; position: relative; }
.chat-folder-list::-webkit-scrollbar { height: 0; }
.folder-tab { padding: 6px 14px; border-radius: 20px; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; color: var(--text-secondary); background: var(--bg-tertiary); transition: all 0.2s ease; pointer-events: auto; }
.folder-tab:hover { background: var(--bg-quaternary); }
.folder-tab.active { background: var(--accent); color: white; }
.folder-add { background: transparent; border: 1px solid var(--border-color); }
.folder-add:hover { background: var(--bg-tertiary); }
.folder-nav { display: flex; gap: 2px; align-items: center; flex-shrink: 0; margin-left: auto; }
.folder-nav-btn { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 10px; color: var(--text-muted); background: var(--bg-tertiary); cursor: pointer; border: none; transition: all 0.2s ease; pointer-events: auto; }
.folder-nav-btn:hover { background: var(--bg-quaternary); color: var(--text-primary); }

.chat-item { display: flex; align-items: center; padding: 12px; border-radius: var(--border-radius); cursor: pointer; margin-bottom: 4px; animation: fadeIn 0.3s ease; background: transparent; transition: background 0.2s ease; position: relative; overflow: hidden; pointer-events: auto; }
.chat-item:hover { background: var(--bg-tertiary); }
.chat-item.active { background: var(--accent); }
.chat-item.active .chat-item-name, .chat-item.active .chat-item-message, .chat-item.active .chat-item-meta { color: white; }
.chat-item.active .chat-item-message { opacity: 0.8; }
.chat-avatar-wrapper { position: relative; margin-right: 12px; flex-shrink: 0; }
.chat-avatar-sm { width: 50px; height: 50px; border-radius: var(--border-radius-full); display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 500; color: white; background: var(--accent); overflow: hidden; }
.chat-avatar-sm img { width: 100%; height: 100%; object-fit: cover; }
.online-indicator { position: absolute; bottom: 2px; right: 2px; width: 12px; height: 12px; background: var(--success); border: 2px solid var(--bg-secondary); border-radius: var(--border-radius-full); }
.chat-item-info { flex: 1; min-width: 0; }
.chat-item-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; gap: 8px; }
.chat-item-name { font-weight: 600; font-size: 16px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.chat-item-meta { font-size: 12px; color: var(--text-muted); flex-shrink: 0; margin-left: 8px; }
.chat-item-last { display: flex; justify-content: space-between; align-items: center; }
.chat-item-message { font-size: 14px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.draft-icon { color: var(--accent); margin-right: 4px; }
.pinned-icon { color: var(--accent); font-size: 12px; margin-right: 4px; }
.unread-badge { background: var(--accent); color: white; font-size: 12px; font-weight: 600; min-width: 20px; height: 20px; border-radius: 10px; display: flex; align-items: center; justify-content: center; padding: 0 6px; flex-shrink: 0; margin-left: 8px; }

.chat-area { flex: 1; display: flex; flex-direction: column; background: var(--bg-primary); position: relative; overflow: hidden; }
.empty-chat { flex: 1; display: flex; align-items: center; justify-content: center; }
.empty-state { text-align: center; animation: fadeIn 0.5s ease; padding: 40px; }
.empty-state h3 { font-size: 24px; margin-bottom: 8px; color: var(--text-primary); }
.empty-state p { font-size: 16px; margin-bottom: 24px; color: var(--text-secondary); }

.active-chat { display: flex; flex-direction: column; height: 100%; position: relative; background-image: url('/images/fon.png'); background-size: cover; background-position: center; }
.chat-header { height: var(--header-height); padding: 0 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border-color); background: var(--bg-secondary); position: relative; z-index: 2; backdrop-filter: blur(10px); pointer-events: auto; }
.chat-header-left { display: flex; align-items: center; gap: 12px; cursor: pointer; padding: 8px 12px; border-radius: var(--border-radius); background: transparent; transition: background 0.2s ease; flex: 1; min-width: 0; pointer-events: auto; }
.chat-header-left:hover { background: var(--bg-tertiary); }
.back-btn-mobile { display: none; width: 40px; height: 40px; border-radius: var(--border-radius-full); align-items: center; justify-content: center; font-size: 18px; color: var(--text-primary); background: var(--bg-tertiary); margin-right: 8px; cursor: pointer; flex-shrink: 0; border: 1px solid var(--border-color); transition: all 0.2s ease; pointer-events: auto; }
.back-btn-mobile:hover { background: var(--bg-quaternary); }
.chat-avatar { width: 40px; height: 40px; border-radius: var(--border-radius-full); display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 500; color: white; background: var(--accent); overflow: hidden; flex-shrink: 0; }
.chat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-header-info { display: flex; flex-direction: column; min-width: 0; }
.chat-title { font-size: 16px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-subtitle { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.chat-header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.header-btn { width: 40px; height: 40px; border-radius: var(--border-radius-full); display: flex; align-items: center; justify-content: center; font-size: 18px; color: var(--text-primary); background: var(--bg-tertiary); cursor: pointer; border: 1px solid transparent; transition: all 0.2s ease; pointer-events: auto; }
.header-btn:hover { background: var(--bg-quaternary); color: var(--accent); }

.messages-container { flex: 1; overflow-y: auto; padding: 20px; position: relative; z-index: 1; -webkit-overflow-scrolling: touch; }
.messages-list { display: flex; flex-direction: column; gap: 8px; max-width: 800px; margin: 0 auto; }

.pinned-messages-bar { background: var(--bg-secondary); border: 1px solid var(--accent); border-radius: var(--border-radius); padding: 10px 16px; margin-bottom: 12px; display: flex; align-items: center; gap: 12px; cursor: pointer; transition: background 0.2s ease; z-index: 5; }
.pinned-messages-bar:hover { background: var(--bg-tertiary); }
.pinned-messages-bar i { color: var(--accent); font-size: 16px; flex-shrink: 0; }
.pinned-message-item { flex: 1; font-size: 14px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pinned-count { color: var(--accent); font-size: 13px; cursor: pointer; flex-shrink: 0; }
.pinned-close-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 18px; padding: 0 4px; flex-shrink: 0; pointer-events: auto; }
.pinned-close-btn:hover { color: var(--danger); }

.message-date-separator { text-align: center; margin: 20px 0; }
.message-date-separator span { background: rgba(0,0,0,0.4); backdrop-filter: blur(8px); padding: 6px 16px; border-radius: 20px; font-size: 13px; color: white; display: inline-block; }

.message { display: flex; margin-bottom: 8px; animation: messageAppear 0.3s ease; position: relative; max-width: var(--message-max-width); cursor: default; pointer-events: auto; }
.message.incoming { align-self: flex-start; }
.message.outgoing { align-self: flex-end; }
.message-avatar { width: 36px; height: 36px; border-radius: var(--border-radius-full); display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 500; color: white; margin-right: 8px; flex-shrink: 0; overflow: hidden; cursor: pointer; pointer-events: auto; }
.message-avatar img { width: 100%; height: 100%; object-fit: cover; }
.message-content { max-width: 100%; position: relative; pointer-events: auto; }
.message-sender-name { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; display: block; font-weight: 500; }
.message-bubble { background: var(--bg-message-in); padding: 10px 14px; border-radius: 18px; word-wrap: break-word; position: relative; box-shadow: var(--shadow-sm); cursor: pointer; pointer-events: auto; }
.outgoing .message-bubble { background: var(--bg-message-out); color: white; border-bottom-right-radius: 4px; }
.incoming .message-bubble { border-bottom-left-radius: 4px; }
.message-text { line-height: 1.5; word-break: break-word; }
.message-text strong { font-weight: 700; }
.message-text em { font-style: italic; }
.message-text del { text-decoration: line-through; opacity: 0.7; }
.message-text code { background: rgba(0,0,0,0.2); padding: 2px 6px; border-radius: 4px; font-family: var(--font-mono); font-size: 0.9em; }
.message-text a { color: var(--accent); text-decoration: underline; }
.outgoing .message-text a { color: #fff; }
.message-emoji-only { background: transparent !important; box-shadow: none !important; padding: 0 !important; }
.message-emoji-only .message-text { font-size: 48px; line-height: 1.2; }
.message-meta { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 12px; color: var(--text-muted); padding: 0 8px; }
.outgoing .message-meta { justify-content: flex-end; }
.message-time { font-size: 11px; }
.message-status { display: flex; align-items: center; }
.status-pending { color: var(--text-muted); }
.status-sent { color: var(--text-muted); }
.status-read { color: var(--accent); }
.pinned-msg-icon { color: var(--accent); font-size: 12px; margin-left: 4px; }

.message-reply { display: flex; align-items: flex-start; gap: 8px; padding: 8px 12px; background: rgba(0,0,0,0.1); border-radius: 12px; margin-bottom: 8px; border-left: 3px solid var(--accent); cursor: pointer; pointer-events: auto; }
.message-reply i { color: var(--accent); font-size: 14px; }
.reply-name { font-weight: 500; font-size: 13px; display: block; }
.reply-text { font-size: 12px; color: var(--text-secondary); }
.message-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reaction { background: var(--bg-tertiary); padding: 4px 8px; border-radius: 20px; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; transition: all 0.2s ease; pointer-events: auto; }
.reaction:hover { background: var(--accent-light); }

.message-image-wrapper { max-width: 300px; border-radius: 12px; overflow: hidden; cursor: pointer; }
.message-image { width: 100%; height: auto; display: block; transition: transform 0.3s ease; }
.message-image:hover { transform: scale(1.02); }
.message-video { max-width: 300px; border-radius: 12px; overflow: hidden; }
.message-video video { width: 100%; height: auto; display: block; border-radius: 12px; }
.image-grid-1 { max-width: 300px; }
.image-grid-1 .grid-item { border-radius: 12px; overflow: hidden; }
.image-grid-1 img { width: 100%; height: auto; display: block; }
.image-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; max-width: 300px; }
.grid-item { aspect-ratio: 1; border-radius: 8px; overflow: hidden; position: relative; cursor: pointer; pointer-events: auto; }
.grid-item img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s ease; }
.grid-item:hover img { transform: scale(1.05); }
.grid-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: bold; color: white; backdrop-filter: blur(4px); }

.voice-message, .audio-message { display: flex; align-items: center; gap: 12px; padding: 8px 12px; }
.voice-play-btn, .audio-play-btn { width: 40px; height: 40px; border-radius: var(--border-radius-full); background: var(--accent); color: white; font-size: 16px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; cursor: pointer; transition: all 0.2s ease; pointer-events: auto; }
.voice-play-btn:hover, .audio-play-btn:hover { background: var(--accent-hover); transform: scale(1.05); }
.voice-progress-container, .audio-progress-container { flex: 1; height: 4px; background: var(--bg-quaternary); border-radius: 2px; overflow: hidden; }
.voice-progress-bar, .audio-progress-bar { height: 100%; background: var(--accent); width: 0; transition: width 0.1s linear; }
.voice-duration, .audio-duration, .audio-current-time { font-size: 13px; color: var(--text-secondary); min-width: 45px; text-align: right; }

.message-file { display: flex; align-items: center; gap: 12px; padding: 8px 12px; cursor: pointer; pointer-events: auto; }
.file-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--bg-tertiary); display: flex; align-items: center; justify-content: center; font-size: 20px; color: var(--text-secondary); }
.file-info { flex: 1; }
.file-name { font-weight: 500; margin-bottom: 2px; }
.file-size { font-size: 12px; color: var(--text-muted); }
.file-download-btn { width: 36px; height: 36px; border-radius: var(--border-radius-full); background: var(--bg-tertiary); display: flex; align-items: center; justify-content: center; color: var(--text-primary); cursor: pointer; border: none; transition: all 0.2s ease; pointer-events: auto; }
.file-download-btn:hover { background: var(--accent); color: white; }

.poll-container { background: var(--bg-tertiary); padding: 16px; border-radius: 16px; min-width: 250px; }
.poll-question { font-weight: 600; margin-bottom: 16px; font-size: 16px; }
.poll-options { display: flex; flex-direction: column; gap: 12px; }
.poll-option { cursor: pointer; position: relative; pointer-events: auto; }
.poll-option-text { margin-bottom: 4px; font-size: 14px; }
.poll-option-bar { height: 24px; background: var(--accent); border-radius: 12px; transition: width 0.3s ease; min-width: 4px; }
.poll-footer { margin-top: 12px; font-size: 13px; color: var(--text-muted); text-align: center; }

.typing-indicator { display: flex; align-items: center; padding: 8px 20px; background: var(--bg-secondary); border-top: 1px solid var(--border-color); animation: slideInUp 0.3s ease; }
.typing-avatars { display: flex; margin-right: 12px; }
.typing-avatar { width: 24px; height: 24px; border-radius: var(--border-radius-full); display: flex; align-items: center; justify-content: center; font-size: 12px; color: white; margin-right: -8px; border: 2px solid var(--bg-secondary); background: var(--accent); }
.typing-text { font-size: 14px; color: var(--text-muted); }
.typing-dots { display: flex; gap: 4px; margin-left: 8px; }
.typing-dots span { width: 6px; height: 6px; background: var(--text-muted); border-radius: 50%; animation: pulse 1s infinite; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

.chat-input-area { padding: 12px 16px; background: var(--bg-secondary); border-top: 1px solid var(--border-color); position: relative; z-index: 2; pointer-events: auto; }
.reply-panel { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: var(--bg-tertiary); border-radius: var(--border-radius); margin-bottom: 12px; animation: slideInDown 0.3s ease; pointer-events: auto; }
.reply-info { display: flex; align-items: center; gap: 12px; }
.reply-preview { width: 40px; height: 40px; border-radius: 8px; overflow: hidden; background: var(--bg-quaternary); }
.reply-preview img { width: 100%; height: 100%; object-fit: cover; }
.reply-content { display: flex; flex-direction: column; }
.reply-content .reply-name { font-weight: 500; font-size: 14px; color: var(--accent); }
.reply-content .reply-text { font-size: 13px; color: var(--text-secondary); }
.cancel-reply-btn { padding: 8px; color: var(--text-muted); cursor: pointer; font-size: 16px; transition: color 0.2s ease; pointer-events: auto; }
.cancel-reply-btn:hover { color: var(--danger); }

.input-container { display: flex; align-items: center; gap: 6px; position: relative; pointer-events: auto; }
.attach-btn, .emoji-btn, .voice-btn { width: 44px; height: 44px; border-radius: var(--border-radius-full); display: flex; align-items: center; justify-content: center; font-size: 20px; color: var(--text-primary); background: var(--bg-tertiary); cursor: pointer; flex-shrink: 0; border: none; transition: all 0.2s ease; pointer-events: auto; }
.attach-btn:hover, .emoji-btn:hover, .voice-btn:hover { background: var(--bg-quaternary); color: var(--accent); }
.voice-btn.recording { background: var(--danger); color: white; animation: pulse 1s infinite; }

.message-input-wrapper { flex: 1; display: flex; align-items: center; background: var(--bg-tertiary); border-radius: 24px; padding: 0 48px 0 16px; min-height: 44px; border: 1.5px solid var(--border-color); transition: border-color 0.2s ease; position: relative; pointer-events: auto; }
.message-input-wrapper:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.message-input { flex: 1; padding: 12px 0; border: none; background: transparent; color: var(--text-primary); font-size: 16px; outline: none; resize: none; overflow-y: auto; line-height: 1.45; max-height: none; min-height: 44px; word-break: break-word; font-family: var(--font-family); pointer-events: auto; }
.message-input:empty:before { content: attr(placeholder); color: var(--text-placeholder); pointer-events: none; }
.message-input:focus { outline: none; box-shadow: none; }
.send-btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; border-radius: var(--border-radius-full); background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 16px; color: white; cursor: pointer; flex-shrink: 0; border: none; transition: all 0.2s ease; z-index: 2; pointer-events: auto; }
.send-btn:hover { background: var(--accent-hover); transform: translateY(-50%) scale(1.05); }

.attach-menu { position: absolute; bottom: 80px; left: 16px; background: var(--bg-secondary); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 8px; display: none; z-index: var(--z-dropdown); animation: scaleIn 0.2s ease; border: 1px solid var(--border-color); min-width: 200px; pointer-events: auto; }
.attach-option { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--border-radius); cursor: pointer; color: var(--text-primary); background: transparent; border: none; width: 100%; text-align: left; font-size: 15px; transition: background 0.2s ease; pointer-events: auto; }
.attach-option:hover { background: var(--bg-tertiary); }
.attach-option i { width: 24px; text-align: center; }
.attach-divider { height: 1px; background: var(--border-color); margin: 4px 0; }

.emoji-picker { position: absolute; bottom: 80px; left: 80px; width: 350px; max-height: 350px; background: var(--bg-secondary); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 12px; display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; overflow-y: auto; overflow-x: hidden; z-index: var(--z-dropdown); animation: scaleIn 0.2s ease; border: 1px solid var(--border-color); pointer-events: auto; }
.emoji-picker span { display: flex; align-items: center; justify-content: center; cursor: pointer; border-radius: 8px; padding: 4px; font-size: 24px; transition: transform 0.2s ease, background 0.2s ease; pointer-events: auto; }
.emoji-picker span:hover { background: var(--bg-tertiary); transform: scale(1.1); }

.reaction-picker { position: fixed; background: var(--bg-secondary); border-radius: 30px; box-shadow: var(--shadow-lg); padding: 8px 12px; display: flex; gap: 8px; z-index: var(--z-popover); animation: scaleIn 0.2s ease; border: 1px solid var(--border-color); pointer-events: auto; }
.reaction-picker span { font-size: 28px; cursor: pointer; padding: 4px; border-radius: 50%; transition: transform 0.2s ease, background 0.2s ease; pointer-events: auto; }
.reaction-picker span:hover { transform: scale(1.2); background: var(--bg-tertiary); }

.mention-suggestions, .command-suggestions { position: absolute; bottom: 80px; left: 80px; background: var(--bg-secondary); border-radius: 12px; box-shadow: var(--shadow-lg); max-width: 300px; max-height: 200px; overflow-y: auto; z-index: var(--z-dropdown); animation: fadeIn 0.2s ease; border: 1px solid var(--border-color); pointer-events: auto; }
.mention-suggestion { display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; transition: background 0.2s ease; pointer-events: auto; }
.mention-suggestion:hover { background: var(--bg-tertiary); }
.mention-suggestion-avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; color: white; flex-shrink: 0; overflow: hidden; }
.mention-suggestion-avatar img { width: 100%; height: 100%; object-fit: cover; }
.command-suggestion { display: flex; flex-direction: column; padding: 10px 14px; cursor: pointer; transition: background 0.2s ease; pointer-events: auto; }
.command-suggestion:hover { background: var(--bg-tertiary); }
.command-name { font-weight: 500; font-size: 14px; }
.command-description { font-size: 12px; color: var(--text-muted); }

.info-panel { position: absolute; right: 0; top: 0; bottom: 0; width: var(--info-width); background: var(--bg-secondary); border-left: 1px solid var(--border-color); display: none; flex-direction: column; z-index: var(--z-sidebar); animation: slideInRight 0.3s ease; pointer-events: auto; }
.info-header { height: var(--header-height); padding: 0 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border-color); }
.info-header h3 { font-size: 18px; font-weight: 600; }
.close-info-btn { font-size: 20px; color: var(--text-muted); cursor: pointer; transition: color 0.2s ease; pointer-events: auto; }
.close-info-btn:hover { color: var(--text-primary); }
.info-content { flex: 1; overflow-y: auto; padding: 20px; }
.info-avatar { width: 100px; height: 100px; border-radius: var(--border-radius-full); margin: 0 auto 16px; display: flex; align-items: center; justify-content: center; font-size: 40px; color: white; background: var(--accent); overflow: hidden; cursor: pointer; }
.info-avatar img { width: 100%; height: 100%; object-fit: cover; }
.info-name { font-size: 22px; font-weight: 600; text-align: center; margin-bottom: 4px; }
.info-username { font-size: 16px; color: var(--text-muted); text-align: center; margin-bottom: 12px; }
.info-section { margin-bottom: 24px; }
.info-section h4 { font-size: 15px; font-weight: 600; margin-bottom: 12px; color: var(--text-secondary); }
.member-list { display: flex; flex-direction: column; gap: 8px; }
.member-item { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: var(--border-radius); cursor: pointer; transition: background 0.2s ease; pointer-events: auto; }
.member-item:hover { background: var(--bg-tertiary); }
.member-avatar { width: 40px; height: 40px; border-radius: var(--border-radius-full); display: flex; align-items: center; justify-content: center; font-size: 16px; color: white; background: var(--accent); overflow: hidden; flex-shrink: 0; }
.member-avatar img { width: 100%; height: 100%; object-fit: cover; }
.member-info { flex: 1; }
.member-name { font-weight: 500; margin-bottom: 2px; }
.member-role { font-size: 12px; color: var(--text-muted); }
.member-role.owner { color: var(--gold); }
.member-role.admin { color: var(--accent); }

.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.7); display: none; align-items: center; justify-content: center; z-index: var(--z-modal); backdrop-filter: blur(4px); }
.modal-container { width: 90%; max-width: 500px; max-height: 85vh; background: var(--bg-secondary); border-radius: 24px; box-shadow: var(--shadow-xl); display: flex; flex-direction: column; animation: scaleIn 0.3s ease; border: 1px solid var(--border-color); pointer-events: auto; overflow: hidden; }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.modal-header h3 { font-size: 20px; font-weight: 600; }
.modal-close { width: 32px; height: 32px; border-radius: var(--border-radius-full); display: flex; align-items: center; justify-content: center; font-size: 24px; color: var(--text-muted); background: var(--bg-tertiary); cursor: pointer; border: none; transition: all 0.2s ease; pointer-events: auto; }
.modal-close:hover { background: var(--bg-quaternary); color: var(--text-primary); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 12px; pointer-events: auto; flex-shrink: 0; }
.modal-footer button { pointer-events: auto; cursor: pointer; }

.profile-modal { padding: 0 !important; }
.profile-header-bg { height: 120px; border-radius: 0 0 40px 40px; position: relative; margin-bottom: 60px; transition: all 0.3s ease; }
.profile-avatar-container { width: 100px; height: 100px; border-radius: 50%; position: absolute; bottom: -50px; left: 50%; transform: translateX(-50%); border: 4px solid var(--bg-secondary); background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 36px; color: white; overflow: hidden; cursor: pointer; z-index: 2; transition: all 0.3s ease; }
.profile-avatar-container img { width: 100%; height: 100%; object-fit: cover; }

.chat-search-bar { height: var(--header-height); padding: 8px 16px; background: var(--bg-secondary); border-bottom: 1px solid var(--border-color); display: none; align-items: center; gap: 12px; position: absolute; top: 0; left: 0; right: 0; z-index: 40; animation: slideInDown 0.3s ease; pointer-events: auto; }
.chat-search-input { flex: 1; padding: 8px 16px; background: var(--bg-tertiary); border: 1.5px solid var(--border-color); border-radius: 20px; color: var(--text-primary); font-size: 16px; outline: none; font-family: var(--font-family); pointer-events: auto; }
.chat-search-input:focus { border-color: var(--accent); }
.search-navigation { display: flex; align-items: center; gap: 8px; }
.search-nav-btn { width: 32px; height: 32px; border-radius: var(--border-radius-full); display: flex; align-items: center; justify-content: center; color: var(--text-secondary); background: var(--bg-tertiary); cursor: pointer; border: none; transition: all 0.2s ease; pointer-events: auto; }
.search-nav-btn:hover { background: var(--bg-quaternary); color: var(--text-primary); }
.search-nav-count { font-size: 14px; color: var(--text-muted); }
.highlight { background: var(--warning); color: black; padding: 0 2px; border-radius: 2px; }
.search-highlight { box-shadow: 0 0 10px var(--warning); }

.scroll-bottom-btn { position: absolute; bottom: 100px; right: 20px; width: 44px; height: 44px; border-radius: var(--border-radius-full); background: var(--bg-secondary); border: 1px solid var(--border-color); color: var(--text-primary); font-size: 18px; cursor: pointer; box-shadow: var(--shadow-md); display: none; align-items: center; justify-content: center; z-index: 20; transition: all 0.2s ease; pointer-events: auto; }
.scroll-bottom-btn:hover { background: var(--accent); color: white; transform: scale(1.05); }
.scroll-bottom-btn .unread-badge { position: absolute; top: -8px; right: -8px; }

.voice-recorder { position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%); background: var(--bg-secondary); border-radius: 40px; box-shadow: var(--shadow-xl); padding: 16px 24px; z-index: var(--z-popover); display: none; animation: slideInUp 0.3s ease; border: 1px solid var(--border-color); pointer-events: auto; }
.recorder-content { display: flex; align-items: center; gap: 20px; }
.recorder-wave { display: flex; align-items: center; gap: 4px; }
.recorder-wave span { width: 4px; height: 20px; background: var(--accent); border-radius: 2px; animation: wave 0.8s infinite; }
.recorder-wave span:nth-child(2) { animation-delay: 0.1s; }
.recorder-wave span:nth-child(3) { animation-delay: 0.2s; }
.recorder-wave span:nth-child(4) { animation-delay: 0.3s; }
.recorder-wave span:nth-child(5) { animation-delay: 0.4s; }
.recorder-time { font-size: 18px; font-weight: 600; min-width: 60px; text-align: center; }
.recorder-cancel { width: 40px; height: 40px; border-radius: var(--border-radius-full); background: var(--danger); color: white; display: flex; align-items: center; justify-content: center; cursor: pointer; border: none; transition: all 0.2s ease; pointer-events: auto; }
.recorder-cancel:hover { background: var(--danger-hover); }

.media-viewer { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.95); z-index: var(--z-media-viewer); display: none; align-items: center; justify-content: center; animation: fadeIn 0.3s ease; }
.close-media { position: absolute; top: 20px; right: 20px; width: 44px; height: 44px; border-radius: var(--border-radius-full); background: rgba(255,255,255,0.1); color: white; font-size: 24px; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 10; border: none; transition: background 0.2s ease; pointer-events: auto; }
.close-media:hover { background: rgba(255,255,255,0.2); }
.media-container { max-width: 90vw; max-height: 90vh; display: flex; align-items: center; justify-content: center; }
.media-container img, .media-container video { max-width: 100%; max-height: 90vh; border-radius: 12px; box-shadow: var(--shadow-xl); object-fit: contain; }
.media-controls { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; gap: 16px; background: rgba(0,0,0,0.5); padding: 12px 20px; border-radius: 40px; backdrop-filter: blur(10px); }
.media-btn { width: 44px; height: 44px; border-radius: var(--border-radius-full); background: rgba(255,255,255,0.1); color: white; font-size: 20px; display: flex; align-items: center; justify-content: center; cursor: pointer; border: none; transition: background 0.2s ease; pointer-events: auto; }
.media-btn:hover { background: rgba(255,255,255,0.2); }

.context-menu { position: fixed; background: var(--bg-secondary); border-radius: 14px; box-shadow: 0 8px 30px rgba(0,0,0,0.5); padding: 6px; min-width: 200px; z-index: var(--z-context-menu); display: none; animation: scaleIn 0.15s ease; border: 1px solid var(--border-color); backdrop-filter: blur(10px); pointer-events: auto; }
.context-menu-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 8px; cursor: pointer; color: var(--text-primary); background: transparent; border: none; width: 100%; text-align: left; font-size: 15px; transition: background 0.2s ease; pointer-events: auto; }
.context-menu-item:hover { background: var(--bg-tertiary); }
.context-menu-item i { width: 20px; color: var(--accent); }
.context-menu-item.danger { color: var(--danger); }
.context-menu-item.danger i { color: var(--danger); }
.context-menu-separator { height: 1px; background: var(--border-color); margin: 8px 0; }

.toast-container { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: var(--z-toast); display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { padding: 12px 20px; border-radius: var(--border-radius); color: white; font-size: 14px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px; pointer-events: auto; min-width: 200px; max-width: 400px; animation: slideInUp 0.3s ease; cursor: pointer; }
.toast.info { background: var(--info); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); color: black; }

.premium-hero { text-align: center; padding: 30px 20px; background: linear-gradient(135deg, var(--gold-light), rgba(251,191,36,0.05)); border-radius: 20px; margin-bottom: 20px; border: 1px solid var(--gold-light); }
.premium-hero i { font-size: 60px; color: var(--gold); margin-bottom: 16px; }
.premium-hero h2 { font-size: 28px; margin-bottom: 8px; }
.premium-plans { display: flex; gap: 16px; margin-bottom: 24px; }
.plan-card { flex: 1; padding: 20px; background: var(--bg-tertiary); border-radius: 16px; text-align: center; cursor: pointer; border: 2px solid transparent; transition: all 0.2s ease; pointer-events: auto; }
.plan-card:hover { background: var(--bg-quaternary); }
.plan-card.selected { border-color: var(--gold); background: var(--gold-light); }
.plan-name { font-size: 16px; font-weight: 500; margin-bottom: 8px; }
.plan-price { font-size: 28px; font-weight: 700; color: var(--gold); }
.premium-buy-btn { width: 100%; padding: 16px; background: linear-gradient(135deg, var(--gold), #f59e0b); border: none; border-radius: 16px; color: black; font-size: 18px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 12px; transition: all 0.2s ease; pointer-events: auto; }
.premium-buy-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 20px rgba(251,191,36,0.3); }
.premium-features { display: flex; flex-direction: column; gap: 12px; }
.premium-feature { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--bg-tertiary); border-radius: var(--border-radius); }
.premium-feature i.fa-check-circle { font-size: 18px !important; flex-shrink: 0; width: 18px; height: 18px; }
.feature-info h4 { margin-bottom: 4px; font-size: 15px; }
.feature-info p { font-size: 13px; color: var(--text-muted); margin: 0; }

.settings-tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 1px solid var(--border-color); flex-wrap: wrap; }
.settings-tab { padding: 12px 20px; background: transparent; border: none; color: var(--text-secondary); cursor: pointer; font-size: 14px; font-weight: 500; border-bottom: 2px solid transparent; transition: all 0.2s ease; font-family: var(--font-family); pointer-events: auto; }
.settings-tab:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.settings-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.settings-section { margin-bottom: 24px; }
.settings-section h4 { font-size: 15px; font-weight: 600; margin-bottom: 12px; color: var(--text-secondary); }
.settings-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border-color); }
.settings-item:last-child { border-bottom: none; }

.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.stat-card { padding: 20px; background: var(--bg-tertiary); border-radius: 16px; text-align: center; }
.stat-value { font-size: 32px; font-weight: 700; color: var(--accent); margin-bottom: 8px; }
.stat-label { font-size: 14px; color: var(--text-muted); }

.fab-new-chat { position: fixed; bottom: 20px; left: 20px; width: 56px; height: 56px; border-radius: 28px; background: var(--accent); color: white; font-size: 24px; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: var(--shadow-lg); z-index: var(--z-fab); border: none; transition: all 0.3s ease; pointer-events: auto; }
.fab-new-chat:hover { background: var(--accent-hover); transform: scale(1.1); }

.contact-item { display: flex; align-items: center; padding: 12px; border-radius: var(--border-radius); cursor: pointer; background: transparent; border: none; width: 100%; text-align: left; color: var(--text-primary); transition: background 0.2s ease; gap: 12px; pointer-events: auto; }
.contact-item:hover { background: var(--bg-tertiary); }
.contact-avatar { width: 44px; height: 44px; border-radius: var(--border-radius-full); display: flex; align-items: center; justify-content: center; font-weight: 500; color: white; flex-shrink: 0; overflow: hidden; background: var(--accent); }
.contact-avatar img { width: 100%; height: 100%; object-fit: cover; }
.contact-info { flex: 1; }
.contact-name { font-weight: 500; margin-bottom: 2px; }
.contact-status { font-size: 13px; color: var(--text-muted); }
.contact-status.online { color: var(--success); }

.formatting-toolbar { position: fixed; background: var(--bg-secondary); border-radius: var(--border-radius); box-shadow: var(--shadow-lg); padding: 8px; display: none; gap: 4px; z-index: var(--z-dropdown); border: 1px solid var(--border-color); pointer-events: auto; }
.formatting-toolbar button { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 16px; color: var(--text-primary); background: transparent; cursor: pointer; border: none; transition: background 0.2s ease; pointer-events: auto; }
.formatting-toolbar button:hover { background: var(--bg-tertiary); }

.avatar-upload { text-align: center; cursor: pointer; margin-bottom: 20px; pointer-events: auto; }
.avatar-preview { width: 80px; height: 80px; border-radius: var(--border-radius-full); background: var(--accent); margin: 0 auto 12px; display: flex; align-items: center; justify-content: center; font-size: 32px; color: white; overflow: hidden; }
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }

.quick-replies-menu { position: fixed; background: var(--bg-secondary); border-radius: 16px; box-shadow: var(--shadow-lg); max-width: 350px; max-height: 250px; overflow-y: auto; z-index: var(--z-dropdown); display: none; border: 1px solid var(--border-color); pointer-events: auto; }
.quick-reply-item { display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer; transition: background 0.2s ease; pointer-events: auto; }
.quick-reply-item:hover { background: var(--bg-tertiary); }
.quick-reply-shortcut { width: 28px; height: 28px; background: var(--accent); color: white; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px; flex-shrink: 0; }
.quick-reply-text { font-size: 14px; color: var(--text-primary); }

.selected-members { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.selected-member { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-light); padding: 6px 12px; border-radius: 20px; font-size: 13px; color: var(--accent); }
.selected-member button { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 16px; padding: 0 2px; pointer-events: auto; }
.selected-member button:hover { color: var(--danger); }

.select-mode-bar { position: absolute; top: 0; left: 0; right: 0; background: var(--accent); padding: 10px 16px; display: none; align-items: center; justify-content: space-between; z-index: 30; animation: slideInDown 0.3s ease; pointer-events: auto; }
.select-mode-count { color: white; font-weight: 500; }
.select-mode-actions { display: flex; gap: 8px; }
.select-mode-actions button { padding: 6px 14px; background: rgba(255,255,255,0.2); border: none; color: white; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 500; transition: background 0.2s ease; pointer-events: auto; }
.select-mode-actions button:hover { background: rgba(255,255,255,0.3); }

.maintenance-screen { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: var(--bg-primary); display: none; align-items: center; justify-content: center; z-index: 9999; flex-direction: column; text-align: center; padding: 40px; }
.maintenance-screen h2 { margin-bottom: 16px; color: var(--accent); }
.maintenance-screen .maintenance-icon { font-size: 64px; margin-bottom: 24px; color: var(--warning); }
.maintenance-spinner { width: 40px; height: 40px; border: 3px solid var(--border-color); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; margin-top: 32px; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
::selection { background: var(--accent); color: white; }

.search-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.search-bar i { color: var(--text-muted); font-size: 16px; }
.search-bar input { flex: 1; padding: 10px 16px; background: var(--bg-tertiary); border: 1.5px solid var(--border-color); border-radius: 20px; color: var(--text-primary); font-size: 15px; outline: none; font-family: var(--font-family); pointer-events: auto; }
.search-bar input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.search-bar input::placeholder { color: var(--text-placeholder); }

body.modal-open { overflow: hidden; }
body.message-select-mode .message { cursor: pointer; }

.install-app-btn { font-family: var(--font-family); }

.inline-keyboard { margin-top: 4px; }
.inline-keyboard-btn { pointer-events: auto; cursor: pointer; }

.circle-preview-container { width: 200px; height: 200px; border-radius: 50%; overflow: hidden; margin: 0 auto; border: 3px solid var(--accent); box-shadow: 0 0 20px rgba(82,124,158,0.5); }
.circle-preview-container video { width: 100%; height: 100%; object-fit: cover; }

.call-modal { position: fixed; top: 20px; right: 20px; width: 300px; background: var(--bg-secondary); border-radius: 20px; box-shadow: var(--shadow-xl); z-index: var(--z-popover); border: 1px solid var(--border-color); overflow: hidden; }
.call-header { padding: 16px; background: var(--bg-tertiary); text-align: center; }
.call-status { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.call-name { font-size: 16px; font-weight: 600; }
.call-content { padding: 20px; text-align: center; }
.call-avatar { width: 60px; height: 60px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24px; color: white; margin: 0 auto 12px; background: var(--accent); }
.call-timer { font-size: 18px; font-weight: 500; }
.call-actions { display: flex; justify-content: center; gap: 16px; padding: 16px; }
.call-btn { width: 50px; height: 50px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 20px; border: none; cursor: pointer; color: white; }
.call-btn.accept { background: var(--success); }
.call-btn.reject { background: var(--danger); }
.call-btn:hover { transform: scale(1.05); }

@media (max-width: 768px) {
    :root { --sidebar-width: 100%; --info-width: 100%; --message-max-width: 85%; }
    .main-screen { position: relative; overflow: hidden; }
    .sidebar { position: absolute; top: 0; left: 0; bottom: 0; width: 100%; z-index: 10; transition: transform 0.3s ease; transform: translateX(0); }
    .main-screen.chat-open .sidebar { transform: translateX(-100%); }
    .chat-area { position: absolute; top: 0; left: 0; right: 0; bottom: 0; width: 100%; height: 100%; transform: translateX(100%); transition: transform 0.3s ease; z-index: 20; }
    .main-screen.chat-open .chat-area { transform: translateX(0); }
    .main-screen.chat-open .back-btn-mobile { display: flex !important; }
    .chat-open .back-btn-mobile { display: flex !important; }
    .fab-new-chat { position: fixed; bottom: 80px; right: 20px; left: auto; z-index: var(--z-fab); }
    .chat-open .fab-new-chat { display: none !important; }
    .info-panel { width: 100%; z-index: 30; }
    .modal-container { width: 95%; max-height: 85vh; margin: 10px; }
    .modal-body { max-height: calc(85vh - 140px); }
    .emoji-picker { position: fixed; bottom: 0; left: 0; right: 0; width: 100% !important; max-height: 350px; border-radius: 20px 20px 0 0 !important; z-index: var(--z-sticky); }
    body { max-width: 100vw; overflow-x: hidden; }
    .chat-folder-list { overflow-x: auto; }
    .chat-item-name { max-width: 120px; }
    .chat-item-message { max-width: 150px; }
}

@media (max-width: 380px) {
    .chat-item-name { max-width: 80px; }
    .chat-item-message { max-width: 100px; }
    .chat-item-meta { font-size: 10px; }
    .message { max-width: 90%; }
    .emoji-picker { grid-template-columns: repeat(5, 1fr); }
    .auth-container { padding: 20px 16px; }
    .modal-container { width: 98%; margin: 4px; padding: 16px; }
    .modal-header { padding: 16px; }
    .modal-body { padding: 16px; max-height: calc(80vh - 120px); }
    .modal-footer { padding: 12px 16px; }
    .recaptcha-container > * { transform: scale(0.75); }
    .premium-feature { padding: 10px; }
    .premium-feature i.fa-check-circle { font-size: 16px !important; width: 16px; height: 16px; }
    .btn { padding: 8px 14px; font-size: 14px; }
    .btn-primary { padding: 10px 20px; font-size: 14px; }
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .chat-input-area { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
    .sidebar { padding-bottom: env(safe-area-inset-bottom); }
    .fab-new-chat { bottom: max(80px, calc(20px + env(safe-area-inset-bottom))); }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; } }
*:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.webapp-mode .install-app-btn { display: none !important; }