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

/* Тема Aurora: глубокий ночной фон + фиолет/розовый акцент */
:root {
    --accent: #8b5cf6;
    --accent-light: #a855f7;
    --accent-dark: #6d28d9;
    --accent-violet: #ec4899;
    --accent-dim: rgba(139, 92, 246, 0.18);
    
    --dark: #0b0d12;
    --dark-2: #12151c;
    --dark-3: #1a1e28;
    
    --primary-gradient: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
    --accent-gradient: linear-gradient(180deg, var(--accent) 0%, var(--accent-violet) 100%);
    
    --primary-color: var(--accent);
    --primary-hover: var(--accent-light);
    --accent-color: var(--accent);
    
    --bg-primary: var(--dark);
    --bg-secondary: rgba(18, 21, 28, 0.92);
    --bg-tertiary: rgba(26, 30, 40, 0.96);
    --bg-glass: rgba(11, 13, 18, 0.88);
    
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --border-color: rgba(6, 182, 212, 0.22);
    --shadow-sm: 0 0 24px rgba(139, 92, 246, 0.18);
    --shadow-md: 0 0 32px rgba(236, 72, 153, 0.25);
    --shadow-lg: 0 0 48px rgba(139, 92, 246, 0.3);
    --shadow-glow: 0 0 28px rgba(236, 72, 153, 0.45);
    
    --message-user: linear-gradient(135deg, #0891b2 0%, #7c3aed 100%);
    --message-other: rgba(26, 30, 40, 0.92);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    --transition-fast: 0.15s ease;
    --transition-base: 0.28s ease;
    --transition-slow: 0.45s ease;
}

[data-theme="light"] {
    --bg-primary: #f0f4f8;
    --bg-secondary: rgba(255, 255, 255, 0.96);
    --bg-tertiary: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.98);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --border-color: rgba(6, 182, 212, 0.32);
    --message-other: rgba(255, 255, 255, 0.98);
    --shadow-sm: 0 0 20px rgba(6, 182, 212, 0.06);
    --shadow-md: 0 0 28px rgba(139, 92, 246, 0.08);
    --shadow-lg: 0 0 40px rgba(139, 92, 246, 0.1);
}

/* Сканлайны и шум */
.scanlines {
    position: fixed;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.08) 2px,
        rgba(0, 0, 0, 0.08) 4px
    );
    pointer-events: none;
    z-index: 1;
}

.noise {
    position: fixed;
    inset: 0;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 2;
}

.app-loader {
    position: fixed;
    inset: 0;
    z-index: 25000;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(1200px 700px at 15% 15%, rgba(139, 92, 246, 0.25), transparent 60%),
        radial-gradient(1000px 600px at 85% 85%, rgba(236, 72, 153, 0.2), transparent 62%),
        rgba(5, 8, 22, 0.94);
    backdrop-filter: blur(6px);
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.app-loader.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.app-loader-card {
    min-width: 210px;
    padding: 18px 18px 14px;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(17, 24, 39, 0.85);
    box-shadow: 0 15px 45px rgba(15, 23, 42, 0.6);
    text-align: center;
    color: #e5e7eb;
}

.app-loader-logo {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, #8b5cf6, #ec4899);
    box-shadow: 0 0 28px rgba(139, 92, 246, 0.45);
    animation: appLoaderPulse 1.3s ease-in-out infinite;
}

.app-loader-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 10px;
}

.app-loader-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #a78bfa;
    animation: appLoaderDot 1s ease-in-out infinite;
}

.app-loader-dots span:nth-child(2) { animation-delay: 0.12s; }
.app-loader-dots span:nth-child(3) { animation-delay: 0.24s; }

.app-loader-card p {
    font-size: 13px;
    color: #cbd5e1;
}

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

@keyframes appLoaderDot {
    0%, 100% { transform: translateY(0); opacity: 0.5; }
    50% { transform: translateY(-4px); opacity: 1; }
}

body {
    font-family: 'Syne', 'Outfit', system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transition: background var(--transition-base), color var(--transition-base);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

/* Фон-сетка (перспектива) */
.grid-bg {
    position: absolute;
    inset: 0;
    background: 
        linear-gradient(180deg, transparent 0%, var(--dark-2) 40%, var(--dark) 100%),
        linear-gradient(90deg, rgba(6, 182, 212, 0.04) 1px, transparent 1px),
        linear-gradient(rgba(139, 92, 246, 0.03) 1px, transparent 1px);
    background-size: 100% 100%, 60px 60px, 60px 60px;
    transform: perspective(400px) rotateX(55deg) scale(1.2);
    transform-origin: 50% 0%;
    animation: gridMove 20s linear infinite;
}

@keyframes gridMove {
    0% { background-position: 0 0, 0 0, 0 0; }
    100% { background-position: 0 0, 0 -60px, -60px 0; }
}

/* Плавающие орбы (добавляются из JS) */
.floating-orbs {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.4;
    animation: orbFloat 15s ease-in-out infinite;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -40px) scale(1.1); }
    50% { transform: translate(-20px, 20px) scale(0.9); }
    75% { transform: translate(40px, 30px) scale(1.05); }
}

/* Авторизация */
.auth-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

.auth-container {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 40px 44px;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(6, 182, 212, 0.08);
    width: 100%;
    max-width: 440px;
    position: relative;
    z-index: 10;
    animation: slideUp 0.5s ease-out;
}

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

.auth-header {
    text-align: center;
    margin-bottom: 28px;
}

.logo {
    width: 76px;
    height: 76px;
    margin: 0 auto 18px;
    background: var(--primary-gradient);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 38px;
    font-weight: 800;
    color: white;
    font-family: 'Syne', sans-serif;
    box-shadow: 0 0 36px rgba(6, 182, 212, 0.35), 0 0 0 1px rgba(255,255,255,0.08) inset;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    letter-spacing: -0.02em;
}

.logo:hover {
    transform: scale(1.05);
    box-shadow: 0 0 40px var(--accent);
    animation: glitch 0.4s ease;
}

@keyframes glitch {
    0% { transform: scale(1.05) translate(0); }
    20% { transform: scale(1.05) translate(-2px, 2px); }
    40% { transform: scale(1.05) translate(2px, -2px); }
    60% { transform: scale(1.05) translate(-2px, -2px); }
    80% { transform: scale(1.05) translate(2px, 2px); }
    100% { transform: scale(1.05) translate(0); }
}

.auth-header h1 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 0.15em;
    color: var(--text-primary);
    text-shadow: 0 0 24px rgba(6, 182, 212, 0.2);
    margin-bottom: 6px;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 14px;
    font-family: 'JetBrains Mono', monospace;
}

.auth-separator {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0;
    font-size: 12px;
    color: var(--text-muted);
}
.auth-separator::before,
.auth-separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(148, 163, 184, 0.3);
}

.btn-vk {
    width: 100%;
    justify-content: center;
}

/* Переключатели Вход / Регистрация */
.auth-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    background: rgba(15, 23, 42, 0.85);
    border-radius: var(--radius-full);
    padding: 4px;
    border: 1px solid rgba(15, 23, 42, 0.9);
}
.auth-tab {
    flex: 1;
    border-radius: var(--radius-full);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 0;
    cursor: pointer;
    transition: all var(--transition-base);
}
.auth-tab.active {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 0 18px rgba(6, 182, 212, 0.45);
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}
.auth-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--text-muted);
}

.auth-note {
    font-size: 12px;
    color: var(--text-tertiary, #94a3b8);
    line-height: 1.35;
    padding-top: 8px;
}

.desktop-version-gate {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at top, rgba(15, 23, 42, 0.92), rgba(2, 6, 23, 0.98));
}

.desktop-version-card {
    width: min(460px, 100%);
    padding: 26px 22px;
    border-radius: 18px;
    background: linear-gradient(160deg, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 0.86));
    border: 1px solid rgba(34, 211, 238, 0.24);
    box-shadow: 0 20px 55px rgba(2, 6, 23, 0.55);
    text-align: center;
}

.desktop-version-card h2 {
    margin: 0 0 10px;
    color: #f8fafc;
}

.desktop-version-card p {
    margin: 0 0 18px;
    color: #cbd5e1;
}

.desktop-version-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.support-templates {
    display: flex;
    gap: 8px;
    padding: 8px 12px 4px;
    flex-wrap: wrap;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
}

.support-template-btn {
    border: 1px solid rgba(56, 189, 248, 0.35);
    background: rgba(15, 23, 42, 0.7);
    color: #cbd5e1;
    border-radius: 999px;
    font-size: 12px;
    padding: 6px 10px;
    cursor: pointer;
}

.send-btn {
    box-shadow: 0 8px 22px rgba(34, 211, 238, 0.35);
    transition: transform .16s ease, box-shadow .2s ease, filter .2s ease;
}

.send-btn:hover {
    transform: translateY(-1px) scale(1.03);
    box-shadow: 0 12px 26px rgba(56, 189, 248, 0.45);
    filter: saturate(1.08);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

@media (max-width: 900px) {
    .scanlines,
    .noise {
        display: none !important;
    }
    .chat-item,
    .message,
    .sidebar-header,
    .search-container,
    .chat-header {
        backdrop-filter: none !important;
        box-shadow: 0 6px 18px rgba(2, 6, 23, 0.24) !important;
    }
}
.auth-two-cols {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.1fr);
    gap: 10px;
}
.auth-field-button .btn-secondary {
    width: 100%;
}
.auth-inline-btn {
    width: 100%;
    margin-top: 4px;
    margin-bottom: 6px;
}
.auth-main-btn {
    margin-top: 4px;
}

.password-strength-hint {
    font-size: 11px;
    margin-top: 2px;
    color: var(--text-muted);
}
.password-strength-weak {
    color: #f97373;
}
.password-strength-medium {
    color: #facc15;
}
.password-strength-strong {
    color: #4ade80;
}

.link-btn {
    border: none;
    background: transparent;
    color: var(--accent-color);
    font-size: 12px;
    margin-left: 8px;
    cursor: pointer;
    padding: 0;
}
.link-btn:hover {
    text-decoration: underline;
}

.auth-form input {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 12px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 15px;
    color: var(--text-primary);
    transition: all var(--transition-base);
    font-family: 'JetBrains Mono', monospace;
}

.auth-form input::placeholder {
    color: var(--text-muted);
}

.auth-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 16px rgba(6, 182, 212, 0.18);
    background: rgba(0, 0, 0, 0.5);
}

.auth-form .legal-agree {
    margin: 12px 0 16px;
}
.auth-form .legal-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}
.auth-form .legal-check input {
    margin: 2px 0 0;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    accent-color: var(--accent);
}
.auth-form .legal-check a {
    color: var(--accent);
    text-decoration: none;
}
.auth-form .legal-check a:hover { text-decoration: underline; }
.auth-form .form-error {
    color: #ff6b6b;
    font-size: 13px;
    margin: -6px 0 10px 0;
    min-height: 18px;
    text-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: 0 0 28px rgba(6, 182, 212, 0.3);
    position: relative;
    overflow: hidden;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 36px rgba(6, 182, 212, 0.4), 0 0 18px var(--accent);
}

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

.btn-secondary {
    padding: 10px 20px;
    background: var(--accent-dim);
    color: var(--accent);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
}

.btn-secondary:hover {
    background: rgba(6, 182, 212, 0.18);
    box-shadow: 0 0 16px rgba(6, 182, 212, 0.18);
    transform: translateY(-1px);
}

.btn-icon {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 10px;
    border-radius: var(--radius-full);
    transition: all var(--transition-base);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.btn-icon:hover {
    background: rgba(6, 182, 212, 0.14);
    color: var(--accent);
    transform: scale(1.08);
    text-shadow: 0 0 10px var(--accent);
}

.btn-icon svg,
.btn-icon .icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* SVG иконки из спрайта (символы задают stroke, здесь только наследование цвета) */
.icon {
    vertical-align: middle;
    color: currentColor;
}
.icon-sm { width: 14px; height: 14px; }
.icon-inline { margin-right: 6px; vertical-align: -0.2em; }
.tab-icon { display: block; margin: 0 auto; }
.attach-option-icon { display: flex; align-items: center; justify-content: center; margin-bottom: 4px; }
.attach-option-icon .icon { color: var(--accent); }
.drag-overlay-icon { margin-bottom: 16px; color: var(--accent); }
.drag-overlay-icon .icon { width: 48px; height: 48px; }
.placeholder-icon .icon { color: var(--text-muted); opacity: 0.8; }
.user-sparks .icon { color: var(--accent); }
.tab-btn .tab-icon { color: inherit; }
.tab-btn.active .tab-icon { color: white; }
.context-menu-item .icon-inline { margin-right: 8px; }

.auth-switch {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: var(--text-secondary);
}

.auth-switch a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    transition: all var(--transition-base);
    text-shadow: 0 0 20px rgba(6, 182, 212, 0.2);
}

.auth-switch a:hover {
    color: var(--accent);
    text-shadow: 0 0 18px rgba(6, 182, 212, 0.35);
}

.auth-hint {
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}
.auth-hint a {
    color: var(--accent);
    text-decoration: none;
}

/* Новый чат: результат поиска и заявки */
.modal-hint {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
    line-height: 1.4;
}
.new-chat-result {
    margin: 16px 0;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}
.new-chat-result-user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.new-chat-result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}
.new-chat-result-actions .btn-secondary { margin: 0; }
.requests-list { flex: 1; overflow-y: auto; padding: 8px 0; }
.requests-list-inner { padding: 0 8px; }
.request-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
}
.request-card-info { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; overflow: hidden; }
.request-card-info .avatar { flex-shrink: 0; }
.request-card-text { flex: 1; min-width: 0; overflow: hidden; }
.request-card-info .chat-item-name,
.request-card-info .user-status { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.request-card-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.request-card-actions .btn-secondary { margin: 0; padding: 8px 14px; font-size: 13px; }
.request-card-actions .btn-link { font-size: 13px; padding: 6px 10px; }
.request-status-pending { font-size: 13px; color: var(--text-muted); }
.new-chat-no-results { padding: 16px; text-align: center; color: var(--text-secondary); font-size: 14px; line-height: 1.4; }
.new-chat-list-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; }
.new-chat-list-item { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--radius-md); cursor: pointer; transition: background var(--transition-base); }
.new-chat-list-item:hover { background: var(--bg-tertiary); }
.new-chat-list-item .avatar { flex-shrink: 0; }
.new-chat-list-item .user-status { font-size: 12px; color: var(--text-secondary); }

/* Поиск бота / группы */
.search-bot-group-modal .modal-content-search {
    max-width: 520px;
    width: 92%;
}
.search-modal-results {
    max-height: min(52vh, 440px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 4px;
    margin-bottom: 0;
    padding: 8px 4px;
}
.search-section-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 14px 0 8px;
}
.search-section-label:first-child { margin-top: 0; }
.search-quick-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
button.new-chat-list-item.search-pick-chat,
button.new-chat-list-item.search-pick-group,
button.new-chat-list-item.search-pick-user-row {
    width: 100%;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    text-align: left;
    font: inherit;
    color: inherit;
    cursor: pointer;
    padding: 12px 14px;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    box-sizing: border-box;
}
button.new-chat-list-item.search-pick-chat:active,
button.new-chat-list-item.search-pick-group:active,
button.new-chat-list-item.search-pick-user-row:active {
    background: var(--bg-primary);
    border-color: rgba(6, 182, 212, 0.35);
}
.search-pick-text { min-width: 0; flex: 1; }
.search-pick-badge {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    vertical-align: middle;
}
.modal-input.modal-input-search {
    margin-bottom: 12px;
}
@media (max-width: 600px) {
    .search-bot-group-modal.modal {
        align-items: flex-end;
        padding: 0;
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
    .search-bot-group-modal .modal-content-search {
        width: 100%;
        max-width: 100%;
        max-height: min(92vh, 720px);
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        margin: 0;
    }
    .search-bot-group-modal .modal-header {
        padding: 16px 18px;
    }
    .search-bot-group-modal .modal-body {
        padding: 16px 18px 20px;
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0));
    }
    .search-modal-results {
        max-height: min(42vh, 320px);
    }
}

/* Настройки */
.settings-section { margin-bottom: 24px; }
.settings-section h3 { font-size: 14px; color: var(--text-secondary); margin-bottom: 12px; font-weight: 600; }
.settings-row { display: flex; align-items: center; gap: 10px; cursor: pointer; margin-bottom: 8px; }
.settings-row span { font-size: 14px; }
.settings-row-stack {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    cursor: default;
}
.settings-row-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }

.bot-chat-banner {
    margin: 0 12px 10px;
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.45;
    color: var(--text-secondary);
    background: rgba(139, 92, 246, 0.12);
    border: 1px solid rgba(139, 92, 246, 0.28);
    border-radius: var(--radius-md);
}
.chat-item-badge-bot {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 6px;
    border-radius: 6px;
    background: rgba(6, 182, 212, 0.2);
    color: #67e8f9;
    margin-left: 4px;
    vertical-align: middle;
}
.settings-checkbox { width: 18px; height: 18px; accent-color: var(--primary-color); }
.settings-hint { font-size: 12px; color: var(--text-secondary); margin-top: 4px; margin-left: 28px; line-height: 1.3; }

.profile-share-section { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border-color); }
.profile-share-title { font-size: 13px; color: var(--text-secondary); margin-bottom: 10px; font-weight: 600; }
.profile-share-row { display: flex; gap: 8px; margin-bottom: 12px; }
.profile-share-row .modal-input { flex: 1; }
.profile-qr-wrap { margin-top: 12px; display: flex; justify-content: center; }
.profile-qr-card {
    position: relative;
    padding: 14px;
    border-radius: 20px;
    background: radial-gradient(circle at top, rgba(56,189,248,0.35), rgba(15,23,42,0.85));
    box-shadow: 0 18px 45px rgba(15,23,42,0.9);
    border: 1px solid rgba(148,163,184,0.4);
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.profile-qr-inner {
    position: relative;
    padding: 10px;
    border-radius: 16px;
    background: radial-gradient(circle at top, #020617, #020617);
    box-shadow: inset 0 0 0 1px rgba(15,23,42,0.9);
}
.profile-qr-img {
    display: block;
    border-radius: 12px;
}
.profile-qr-caption {
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(226,232,240,0.85);
}
.profile-qr-logo {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 52px;
    height: 52px;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
}
.profile-qr-logo-ring {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: radial-gradient(circle at top, rgba(56,189,248,0.95), rgba(129,140,248,0.7));
    box-shadow: 0 0 24px rgba(56,189,248,0.7);
    opacity: 0.9;
}
.profile-qr-logo-core {
    position: relative;
    z-index: 1;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: radial-gradient(circle at top, #0f172a, #020617);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #e0f2fe;
    text-shadow: 0 0 8px rgba(56,189,248,0.9);
}
.profile-section-title { font-size: 13px; color: var(--text-secondary); margin: 16px 0 8px; font-weight: 600; }
.profile-purchase-list { max-height: 200px; overflow-y: auto; font-size: 13px; }
.profile-purchase-item { padding: 6px 0; border-bottom: 1px solid var(--border-color); display: flex; flex-direction: column; gap: 2px; }
.profile-purchase-item:last-child { border-bottom: 0; }
.profile-purchase-name { font-weight: 500; }
.profile-purchase-meta { font-size: 11px; color: var(--text-muted); }
.profile-purchase-empty { color: var(--text-muted); font-size: 13px; padding: 8px 0; }

.profile-nft { margin-top: 24px; }
.profile-nft-item { display: flex; align-items: center; gap: 12px; }
.profile-nft-item .nft-thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; }

.view-profile-name { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.verified-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 4px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #38bdf8);
    color: #e0f2fe;
    font-size: 11px;
    box-shadow: 0 0 6px rgba(56,189,248,0.7);
}
.view-profile-username { font-size: 14px; color: var(--text-secondary); margin-bottom: 12px; }
.view-profile-bio { font-size: 14px; color: var(--text-secondary); margin-bottom: 16px; white-space: pre-wrap; }
.view-profile-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.view-profile-modal-content #viewProfileBody {
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 14px;
    background: rgba(2, 6, 23, 0.26);
}
.new-chat-result-profile-link { margin-top: 12px; }
.btn-link { background: transparent !important; border: none; color: var(--primary-color); text-decoration: underline; padding: 0; font-size: 13px; }

/* Мессенджер */
.messenger-screen {
    display: flex;
    height: 100vh;
    background: var(--bg-primary);
    position: relative;
}

.messenger-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    background: 
        radial-gradient(ellipse 80% 50% at 80% 20%, rgba(6, 182, 212, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse 60% 40% at 20% 80%, rgba(139, 92, 246, 0.05) 0%, transparent 50%);
    pointer-events: none;
}

/* Боковая панель */
.sidebar {
    width: 380px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(10px);
}

.sidebar-header {
    padding: 20px;
    background:
        radial-gradient(120% 120% at 15% 0%, rgba(139, 92, 246, 0.18), transparent 55%),
        linear-gradient(180deg, rgba(26, 30, 40, 0.96) 0%, rgba(18, 21, 28, 0.96) 100%);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.sidebar-header::after {
    content: '';
    position: absolute;
    inset: auto -20% -60% -20%;
    height: 80%;
    pointer-events: none;
    background: radial-gradient(ellipse at center, rgba(56, 189, 248, 0.18), transparent 65%);
    filter: blur(14px);
}

.header-actions {
    position: relative;
    display: flex;
    align-items: center;
}

.header-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 180px;
    background: rgba(2, 6, 23, 0.92);
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 14px;
    box-shadow: 0 22px 60px rgba(0,0,0,0.55);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 6px;
    z-index: 11000;
}

.header-menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 10px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
}

.header-menu-item:hover {
    background: rgba(139, 92, 246, 0.16);
}

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

.avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: white;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
    position: relative;
}

.avatar::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background: #48bb78;
    border: 2px solid var(--bg-secondary);
    border-radius: var(--radius-full);
}

.avatar:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: var(--shadow-glow);
}

.user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-sparks {
    font-size: 12px;
    color: var(--accent);
    margin-top: 2px;
}
.user-sparks span { font-weight: 600; }

.username {
    font-weight: 600;
    font-size: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.user-status {
    font-size: 13px;
    color: var(--text-secondary);
}

.search-container {
    padding: 16px;
    background: linear-gradient(180deg, rgba(18, 21, 28, 0.92), rgba(11, 13, 18, 0.9));
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
    align-items: center;
    position: relative;
}

.sidebar-tabs {
    display: flex;
    padding: 8px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    gap: 4px;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: transform var(--transition-base), background var(--transition-base), color var(--transition-base), box-shadow var(--transition-base);
    font-family: inherit;
}

.tab-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(139, 92, 246, 0.15);
}

.tab-btn.active {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 0 24px rgba(6, 182, 212, 0.28);
    transform: translateY(-1px);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.search-input {
    flex: 1;
    padding: 12px 18px;
    border: none;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    font-size: 14px;
    color: var(--text-primary);
    transition: all var(--transition-base);
    font-family: inherit;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-input:focus {
    outline: none;
    background: var(--bg-primary);
    box-shadow: 0 0 0 2px var(--accent), 0 0 18px rgba(6, 182, 212, 0.18);
}

.theme-toggle {
    flex-shrink: 0;
}

.chats-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.chats-list-hint {
    font-size: 12px;
    line-height: 1.35;
    color: var(--text-secondary);
    padding: 10px 16px 14px;
    margin: 0 8px 8px;
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

.chat-item {
    padding: 10px 14px;
    margin: 0 8px 4px;
    border-radius: var(--radius-lg);
    cursor: pointer;
    position: relative;
    transition: all var(--transition-base);
    border: 1px solid transparent;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.01), rgba(255, 255, 255, 0));
}

.chat-item-main {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-item:hover {
    background:
        radial-gradient(120% 140% at 0% 0%, rgba(139, 92, 246, 0.18), transparent 60%),
        rgba(15, 23, 42, 0.72);
    border-color: rgba(148, 163, 184, 0.4);
    transform: translateX(3px) translateY(-1px);
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.35);
}

.chat-item.active {
    background:
        radial-gradient(circle at 0 0, rgba(56,189,248,0.28), transparent 52%),
        radial-gradient(circle at 100% 100%, rgba(236,72,153,0.16), transparent 60%),
        rgba(15, 23, 42, 0.92);
    border-color: var(--accent);
    box-shadow: 0 0 24px rgba(56,189,248,0.25);
}

.chat-item-support {
    border-color: rgba(96, 165, 250, 0.7);
}

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

.chat-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.chat-item-name {
    font-weight: 600;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.chat-item-time {
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-left: 8px;
}

.chat-item-preview {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-item-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 1px 6px;
    font-size: 10px;
    margin-right: 4px;
}

.chat-item-badge-fav {
    background: rgba(250, 204, 21, 0.12);
    color: #facc15;
}

.chat-item-badge-muted {
    background: rgba(148, 163, 184, 0.14);
    color: var(--text-secondary);
}

.chat-item-badge-streak {
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.22), rgba(245, 158, 11, 0.3));
    color: #fdba74;
    border: 1px solid rgba(251, 146, 60, 0.4);
    text-shadow: 0 0 8px rgba(251, 146, 60, 0.28);
}

.chat-item-badge-support {
    background: rgba(59, 130, 246, 0.18);
    color: #bfdbfe;
}

.chat-item-badge-verified {
    background: rgba(34, 197, 94, 0.2);
    color: #86efac;
}

.unread-badge {
    position: absolute;
    top: 12px;
    right: 16px;
    background: var(--primary-gradient);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: var(--radius-full);
    min-width: 20px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.message-reply {
    margin-bottom: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-left: 3px solid var(--primary-color);
    border-radius: var(--radius-sm);
}

.reply-line {
    height: 2px;
    width: 20px;
    background: var(--primary-color);
    margin-bottom: 4px;
}

.reply-author {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 2px;
}

.reply-text {
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.avatar.small {
    width: 32px;
    height: 32px;
    font-size: 16px;
}

.avatar.large {
    width: 120px;
    height: 120px;
    font-size: 60px;
    margin: 0 auto 20px;
}

/* Полоса звонка */
.call-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(15, 23, 42, 0.9);
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
}
.call-bar-main {
    display: flex;
    align-items: center;
    gap: 10px;
}
.call-avatar {
    width: 36px;
    height: 36px;
    font-size: 18px;
}
.call-bar-text {
    display: flex;
    flex-direction: column;
}
.call-bar-title {
    font-size: 14px;
    font-weight: 600;
}
.call-bar-status {
    font-size: 12px;
    color: var(--text-secondary);
}
.call-reconnect-banner {
    margin-top: 4px;
    font-size: 12px;
    color: #fbbf24;
}
.call-media-indicators {
    margin-top: 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.call-indicator-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    color: #cbd5e1;
    background: rgba(15, 23, 42, 0.6);
}
.call-indicator-chip.ok {
    border-color: rgba(34, 197, 94, 0.45);
    color: #86efac;
}
.call-indicator-chip.muted {
    border-color: rgba(248, 113, 113, 0.4);
    color: #fecaca;
}
.call-indicator-chip.screen {
    border-color: rgba(56, 189, 248, 0.45);
    color: #7dd3fc;
}
.call-indicator-chip.warn {
    border-color: rgba(251, 191, 36, 0.5);
    color: #fde68a;
}
.call-webrtc-diag {
    margin-top: 4px;
    font-size: 11px;
    color: #94a3b8;
    font-family: "JetBrains Mono", monospace;
    opacity: 0.9;
}
.call-bar-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.call-accept-btn {
    border-color: rgba(74, 222, 128, 0.55);
    color: #86efac;
}
.call-accept-btn:hover {
    background: rgba(74, 222, 128, 0.12);
}

.call-reject-btn {
    border-color: rgba(248, 113, 113, 0.55);
    color: #fecaca;
}
.call-reject-btn:hover {
    background: rgba(248, 113, 113, 0.12);
}
.call-end-btn {
    background: #ef4444;
    border-color: #ef4444;
    color: #fff;
}
.call-end-btn:hover {
    background: #dc2626;
    border-color: #dc2626;
}

/* Меню прикрепления */
.attach-menu {
    position: absolute;
    bottom: 70px;
    left: 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 12px;
    display: grid;
    z-index: 10030;
    box-shadow: var(--shadow-lg);
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    animation: slideUp 0.2s ease-out;
}

.attach-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-height: 72px;
    padding: 16px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 500;
}

.attach-option:hover {
    background: var(--bg-primary);
    transform: scale(1.05);
}

.attach-option span:first-child {
    font-size: 24px;
}

/* Панель форматирования */
.formatting-bar {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px;
    z-index: 10030;
    box-shadow: var(--shadow-lg);
    display: flex;
    gap: 4px;
    box-shadow: var(--shadow-md);
    z-index: 100;
    animation: slideUp 0.3s ease-out;
}

.format-btn {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    font-family: 'Courier New', monospace;
}

.format-btn:hover {
    background: var(--primary-color);
    color: white;
}

.format-btn.active {
    background: var(--primary-gradient);
    color: white;
}

/* Контекстное меню — поверх модалок */
.context-menu {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    min-width: 200px;
    overflow: hidden;
    animation: fadeIn 0.15s ease-out;
}

.context-menu-item {
    width: 100%;
    min-height: 44px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    text-align: left;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 10px;
    box-sizing: border-box;
}

.context-menu-item:hover {
    background: var(--bg-tertiary);
}

.context-menu-item:not(:last-child) {
    border-bottom: 1px solid var(--border-color);
}

/* Результаты поиска */
.search-results {
    max-height: 400px;
    overflow-y: auto;
    margin-top: 16px;
}

.search-result-item {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: all var(--transition-base);
}

.search-result-item:hover {
    background: var(--bg-tertiary);
}

.search-result-text {
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: 4px;
}

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

.search-highlight {
    background: var(--primary-color);
    color: white;
    padding: 2px 4px;
    border-radius: 4px;
}

/* Вкладки в модале поиска (чаты / сообщения) */
.search-modal-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.search-modal-tabs .search-tab {
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
}
.search-modal-tabs .search-tab:hover {
    color: var(--text-primary);
}
.search-modal-tabs .search-tab.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}
.search-tab-panel .modal-input {
    margin-bottom: 12px;
}
.search-no-results {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}
.search-chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
}
.search-chat-item .avatar {
    flex-shrink: 0;
}
.search-result-name {
    font-weight: 500;
    color: var(--text-primary);
}

/* Профиль */
.profile-avatar-large {
    text-align: center;
    margin-bottom: 24px;
}

.avatar-edit {
    position: relative;
    overflow: hidden;
}
.avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}
.avatar-emoji {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}
.profile-avatar-btn {
    margin-top: 8px;
    font-size: 13px;
}

.profile-modal-content,
.view-profile-modal-content {
    max-width: 520px;
    background:
        radial-gradient(120% 120% at 100% 0%, rgba(56, 189, 248, 0.12), transparent 56%),
        radial-gradient(120% 120% at 0% 100%, rgba(139, 92, 246, 0.14), transparent 58%),
        var(--bg-secondary);
}

.profile-modal-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.profile-headline {
    margin-top: -8px;
    text-align: center;
}

.profile-display-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.profile-meta-line {
    margin-top: 3px;
    font-size: 13px;
    color: var(--text-secondary);
}

.profile-form-card {
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.45);
    padding: 14px;
}

.profile-form-card .modal-input {
    margin-bottom: 12px;
}

.profile-form-card .modal-input:last-child {
    margin-bottom: 4px;
}

.profile-context-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.profile-context-text {
    min-width: 0;
}

.profile-context-title {
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Список пользователей для группы */
.users-list {
    max-height: 300px;
    overflow-y: auto;
    margin: 16px 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px;
}

.user-select-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
}

.user-select-item:hover {
    background: var(--bg-tertiary);
}

.user-select-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

/* Улучшения для сообщений с файлами */
.message-file {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-top: 8px;
    cursor: pointer;
    transition: all var(--transition-base);
}

.message-file:hover {
    background: var(--bg-secondary);
}

.message-image {
    max-width: 100%;
    border-radius: var(--radius-md);
    margin-top: 8px;
    cursor: pointer;
    transition: all var(--transition-base);
}

.message-image:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-md);
}

.message-voice {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-top: 8px;
}

.voice-waveform {
    flex: 1;
    height: 40px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 12px;
}

.voice-bar {
    width: 3px;
    background: var(--primary-color);
    border-radius: var(--radius-full);
    transition: height var(--transition-fast);
}

/* Сообщение в процессе правки в поле ввода — при необходимости добавьте класс в JS */
.message-inline-editing {
    opacity: 0.85;
}

/* Индикатор печати */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--message-other);
    border-radius: var(--radius-lg);
    max-width: 60px;
    margin-bottom: 12px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--text-secondary);
    border-radius: var(--radius-full);
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Форматирование текста в сообщениях */
.message-text strong {
    font-weight: 700;
}

.message-text em {
    font-style: italic;
}

.message-text code {
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.message.user .message-text code {
    background: rgba(255, 255, 255, 0.2);
}

/* Закрепленные сообщения */
.message-pinned {
    background: var(--bg-tertiary);
    border-left: 3px solid var(--primary-color);
    padding: 12px;
    margin-bottom: 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
}

.message-pinned:hover {
    background: var(--bg-secondary);
    transform: translateX(4px);
}

.message-pinned-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.message-pinned-icon {
    color: var(--primary-color);
}

.message-pinned-text {
    font-size: 14px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-pinned-time {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Индикатор закрепленного сообщения в чате */
.message-content.pinned::before {
    content: '📌';
    position: absolute;
    top: -8px;
    right: 8px;
    font-size: 12px;
    background: var(--primary-color);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Drag & Drop overlay */
.drag-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px dashed var(--primary-color);
    border-radius: var(--radius-lg);
    animation: pulseBorder 1s ease-in-out infinite;
}

@keyframes pulseBorder {
    0%, 100% {
        border-color: var(--primary-color);
    }
    50% {
        border-color: var(--accent-color);
    }
}

.drag-message {
    text-align: center;
    color: var(--text-primary);
}

/* Предпросмотр ссылок */
.link-preview {
    margin-top: 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-tertiary);
    cursor: pointer;
    transition: all var(--transition-base);
}

.link-preview:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-md);
}

.link-preview-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: var(--bg-secondary);
}

.link-preview-content {
    padding: 12px;
}

.link-preview-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.link-preview-description {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.link-preview-url {
    font-size: 11px;
    color: var(--primary-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Статистика чата */
.chat-info-section {
    margin-bottom: 24px;
}

.chat-info-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 14px;
}

.stat-value {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 14px;
}

/* Звуковые настройки */
.sound-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all var(--transition-base);
}

.sound-toggle:hover {
    background: var(--bg-secondary);
}

/* Переводчик */
.translate-btn {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 12px;
    cursor: pointer;
    margin-top: 8px;
    transition: all var(--transition-base);
}

.translate-btn:hover {
    background: var(--primary-color);
    color: white;
}

.translated-text {
    margin-top: 8px;
    padding: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
    font-style: italic;
    border-left: 2px solid var(--primary-color);
}

.new-chat-btn {
    margin: 16px;
    padding: 14px;
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform var(--transition-base), box-shadow var(--transition-base), filter var(--transition-base), background var(--transition-base);
    box-shadow: var(--shadow-md);
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    filter: saturate(1.08);
}

/* Область чата */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

.chat-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 30%, rgba(6, 182, 212, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(139, 92, 246, 0.05) 0%, transparent 50%);
    pointer-events: none;
}

.chat-placeholder {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.placeholder-content {
    text-align: center;
    color: var(--text-secondary);
    animation: fadeIn 0.6s ease-out;
}

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

.placeholder-icon {
    font-size: 80px;
    margin-bottom: 24px;
    filter: grayscale(0.3);
    animation: floatIcon 3s ease-in-out infinite;
}

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

.placeholder-content h2 {
    margin-bottom: 12px;
    color: var(--text-primary);
    font-size: 24px;
    font-weight: 600;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    z-index: 1;
}

.chat-header {
    background:
        radial-gradient(130% 120% at 80% 0%, rgba(139, 92, 246, 0.13), transparent 60%),
        linear-gradient(180deg, rgba(26, 30, 40, 0.96), rgba(18, 21, 28, 0.92));
    backdrop-filter: blur(10px);
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.chat-header-info h3 {
    font-size: 17px;
    margin-bottom: 4px;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-status {
    font-size: 13px;
    color: var(--text-secondary);
}

.chat-header-actions {
    display: flex;
    gap: 8px;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 75%;
    animation: messageSlide 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

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

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

.message-content {
    background: var(--message-other);
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    word-wrap: break-word;
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    transition: all var(--transition-base);
}

.message-content:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-md);
}

.message.user .message-content {
    background: var(--message-user);
    border: none;
    color: white;
    box-shadow: 0 0 22px rgba(6, 182, 212, 0.2);
}

.message-text {
    font-size: 15px;
    line-height: 1.5;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.message.user .message-text {
    color: white;
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
    text-align: right;
    opacity: 0.7;
}

.message.user .message-time {
    text-align: left;
    color: rgba(255, 255, 255, 0.8);
}

.message-delivery-status {
    margin-left: 6px;
    font-weight: 700;
    letter-spacing: -0.2px;
}

.message-delivery-sent {
    color: rgba(255, 255, 255, 0.7);
}

.message-delivery-delivered {
    color: rgba(255, 255, 255, 0.92);
}

.message-delivery-read {
    color: #7dd3fc;
}

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

.support-rank-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 600;
    border-radius: 4px;
    background: var(--accent, #06b6d4);
    color: white;
    opacity: 0.95;
}

.message-reactions-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
}
.message-reaction-pill {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 8px;
    font-size: 13px;
    border-radius: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    cursor: pointer;
}
.message-reaction-pill.mine {
    background: var(--accent, #06b6d4);
    border-color: var(--accent);
    color: white;
}
.message-reaction-buttons {
    display: inline-flex;
    gap: 2px;
    opacity: 0.7;
}
.message-reaction-buttons:hover {
    opacity: 1;
}
.msg-reaction-btn {
    padding: 2px 6px;
    font-size: 16px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
}
.msg-reaction-btn:hover {
    background: var(--bg-secondary);
}

.quick-replies {
    margin-top: 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.quick-reply-btn {
    border: none;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 11px;
    background: rgba(15,23,42,0.9);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.quick-reply-btn:hover {
    background: rgba(56,189,248,0.2);
    color: var(--text);
}

.message-link {
    color: var(--accent, #06b6d4);
    text-decoration: none;
    word-break: break-all;
}
.message-link:hover {
    text-decoration: underline;
}

.message-input-container {
    background: var(--bg-secondary);
    backdrop-filter: blur(10px);
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.message-input {
    flex: 1;
    padding: 14px 50px 14px 18px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    font-size: 15px;
    color: var(--text-primary);
    resize: none;
    font-family: inherit;
    transition: all var(--transition-base);
}

.message-input::placeholder {
    color: var(--text-muted);
}

.message-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-primary);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.12);
}

.emoji-btn {
    position: absolute;
    right: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-full);
    transition: all var(--transition-base);
}

.emoji-btn:hover {
    background: var(--bg-secondary);
    transform: scale(1.1);
}

.send-btn {
    background: var(--primary-gradient);
    color: white;
    border-radius: var(--radius-full);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: 0 0 24px rgba(6, 182, 212, 0.35);
}

.send-btn:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 0 32px rgba(6, 182, 212, 0.45), 0 0 18px var(--accent);
}

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

.send-btn svg {
    width: 18px;
    height: 18px;
}

/* Эмодзи панель */
.emoji-panel {
    position: absolute;
    bottom: 80px;
    left: 24px;
    right: 24px;
    max-width: 400px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    z-index: 10030;
    box-shadow: var(--shadow-lg);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(20px);
    padding: 16px;
    z-index: 100;
    animation: slideUp 0.3s ease-out;
}

.emoji-categories {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.emoji-category {
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-md);
    padding: 8px 12px;
    cursor: pointer;
    font-size: 20px;
    transition: all var(--transition-base);
}

.emoji-category:hover {
    background: var(--bg-primary);
    transform: scale(1.1);
}

.emoji-category.active {
    background: var(--primary-gradient);
    box-shadow: var(--shadow-sm);
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.emoji-item {
    font-size: 24px;
    padding: 8px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    text-align: center;
}

.emoji-item:hover {
    background: var(--bg-tertiary);
    transform: scale(1.2);
}

/* Модальное окно — поверх scanlines/noise (z 9998–9999), всегда видимы */
body.modal-open {
    overflow: hidden;
    touch-action: none;
}
body.modal-open .app-footer {
    visibility: hidden;
    pointer-events: none;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease-out;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    box-sizing: border-box;
}

#viewProfileModal {
    z-index: 1001;
}

.modal-content {
    background: var(--bg-secondary);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.4s ease-out;
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-input {
    width: 100%;
    padding: 14px 18px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    font-size: 15px;
    color: var(--text-primary);
    margin-bottom: 20px;
    font-family: inherit;
    transition: all var(--transition-base);
}

.modal-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    margin-top: 12px;
}
.modal-label:first-of-type { margin-top: 0; }
.report-target-info {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    padding: 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}
.modal-input::placeholder {
    color: var(--text-muted);
}

.modal-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-primary);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.12);
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Скроллбар */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    border: 2px solid transparent;
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Кнопка «Назад» в чате — только на мобильных */
.chat-back-btn {
    display: none;
    margin-right: 8px;
}
@media (max-width: 768px) {
    .chat-back-btn {
        display: flex;
        min-width: 44px;
        min-height: 44px;
    }
}

/* Адаптивность */
@media (max-width: 768px) {
    .messenger-screen {
        position: relative;
        overflow: hidden;
    }

    .sidebar {
        width: 100%;
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 10;
        height: 100%;
        transition: transform 0.25s ease;
    }

    .messenger-screen.mobile-chat-open .sidebar {
        transform: translateX(-100%);
        pointer-events: none;
    }

    .chat-area {
        width: 100%;
        position: relative;
        z-index: 5;
    }

    .messenger-screen.mobile-chat-open .chat-area {
        position: absolute;
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
        z-index: 20;
    }

    .message {
        max-width: 85%;
    }

    .auth-container {
        padding: 32px 24px;
        margin: 20px;
    }

    .modal {
        padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
        align-items: flex-start;
        padding-top: max(12px, env(safe-area-inset-top));
    }

    .modal-content {
        max-height: calc(100vh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        width: 100%;
        margin: 0;
    }

    .chat-header {
        padding-left: 12px;
        padding-right: 12px;
        min-height: 56px;
    }

    .messages-container {
        -webkit-overflow-scrolling: touch;
    }

    .btn-icon {
        min-width: 44px;
        min-height: 44px;
    }

    .sidebar {
        padding-top: env(safe-area-inset-top);
    }

    .sidebar-footer {
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }

    .chat-header {
        padding-top: max(16px, env(safe-area-inset-top));
    }

    .message-input-container {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    /* Предотвращение зума при фокусе на iOS */
    .search-input,
    .message-input,
    .modal-input,
    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="tel"] {
        font-size: 16px !important;
    }

    .user-profile .avatar { width: 42px; height: 42px; font-size: 18px; }
    .user-info .username { font-size: 15px; }
    .sidebar-tabs { flex-wrap: wrap; gap: 6px; padding: 8px; }
    .sidebar-tabs .tab-btn { min-width: calc(50% - 6px); padding: 10px 8px; font-size: 13px; }
    .sidebar-tabs .tab-btn[data-tab="archived"] { min-width: 100%; }
    .chat-item { padding: 12px 16px; min-height: 56px; }
    .chat-item .avatar { width: 44px; height: 44px; font-size: 20px; }
    .chat-item-name { font-size: 14px; }
    .sidebar-footer { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
    .sidebar-footer .new-chat-btn { margin: 0; width: 100%; min-height: 48px; padding: 14px; }
    .sidebar-footer .new-chat-btn#sendRequestBtn,
    .sidebar-footer .new-chat-btn#newGroupBtn { margin: 0; width: 100%; min-height: 48px; }
    .message-input-container { padding: 12px 16px; gap: 8px; }
    .message-input { padding: 12px 44px 12px 14px; font-size: 16px; }
    .send-btn { min-width: 44px; min-height: 44px; }
    .attach-option { min-height: 44px; padding: 10px 14px; }
    .context-menu-item { min-height: 44px; padding: 14px 18px; }
    .quick-reply-btn { min-height: 36px; padding: 8px 14px; font-size: 12px; }
    .modal-content { max-width: 100%; width: 100%; border-radius: var(--radius-lg); }
    .modal-body { padding: 20px 16px; }
    .modal-actions { flex-wrap: wrap; gap: 10px; }
    .modal-actions .btn-primary,
    .modal-actions .btn-secondary { min-height: 44px; }
    .placeholder-content { padding: 24px 20px; }
    .placeholder-icon { font-size: 56px; }
    .placeholder-content h2 { font-size: 18px; }
    .shop-modal .modal-content { width: 100%; max-width: 100%; }
    .shop-balance { padding: 14px 16px; }
    .shop-tabs { padding: 12px 16px 0; gap: 6px; }
    .shop-catalog { padding: 16px; }
    .shop-cards, .nft-grid { gap: 10px; }
    .profile-share-row { flex-wrap: wrap; }
    .profile-share-row .modal-input { margin-bottom: 8px; }
    .profile-share-row .btn-secondary { width: 100%; min-height: 44px; }
}

/* Дополнительные анимации */
@keyframes shimmer {
    0% { background-position: -1000px 0; }
    100% { background-position: 1000px 0; }
}

.loading {
    animation: shimmer 2s infinite;
    background: linear-gradient(
        to right,
        var(--bg-tertiary) 0%,
        var(--bg-secondary) 50%,
        var(--bg-tertiary) 100%
    );
    background-size: 1000px 100%;
}

/* Улучшенные эффекты */
.glass-effect {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
}

.gradient-text {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.neomorph {
    background: var(--bg-secondary);
    box-shadow: 
        8px 8px 16px rgba(0, 0, 0, 0.3),
        -8px -8px 16px rgba(255, 255, 255, 0.05);
}

/* Дополнительные стили для сообщений */
.message {
    position: relative;
}

.message-content {
    position: relative;
}

.message.user .message-content::after {
    content: '';
    position: absolute;
    right: -8px;
    bottom: 0;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 8px solid;
    border-image: var(--message-user) 1;
}

.message:not(.user) .message-content::after {
    content: '';
    position: absolute;
    left: -8px;
    bottom: 0;
    width: 0;
    height: 0;
    border-right: 8px solid transparent;
    border-bottom: 8px solid var(--message-other);
    border-left: 8px solid var(--message-other);
}

/* Улучшения для модального окна */
.modal-content {
    max-height: 90vh;
    overflow-y: auto;
}

/* Анимация появления элементов */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-item {
    animation: fadeInUp 0.3s ease-out;
    animation-fill-mode: both;
}

.chat-item:nth-child(1) { animation-delay: 0.05s; }
.chat-item:nth-child(2) { animation-delay: 0.1s; }
.chat-item:nth-child(3) { animation-delay: 0.15s; }
.chat-item:nth-child(4) { animation-delay: 0.2s; }
.chat-item:nth-child(5) { animation-delay: 0.25s; }

/* Улучшения для эмодзи панели */
.emoji-panel {
    max-height: 350px;
}

.emoji-grid {
    max-height: 250px;
}

/* Эффект при наведении на кнопки */
.btn-primary:active,
.btn-secondary:active,
.new-chat-btn:active {
    transform: scale(0.98);
}

/* Улучшения для аватаров */
.avatar {
    position: relative;
}

.avatar::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    padding: 2px;
    background: var(--primary-gradient);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.chat-item.active .avatar::before,
.chat-item:hover .avatar::before {
    opacity: 1;
}

/* Улучшения для поиска */
.search-container {
    position: relative;
}

.search-input:focus + .theme-toggle {
    opacity: 0.7;
}

/* Плавная прокрутка */
.messages-container,
.chats-list {
    scroll-behavior: smooth;
}

/* Эффект свечения для активных элементов */
.chat-item.active {
    position: relative;
}

.chat-item.active::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: var(--primary-gradient);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

/* Улучшения для placeholder */
.placeholder-content {
    max-width: 400px;
    padding: 40px;
}

/* ——— Магазин (Sparks) ——— */
.shop-modal .modal-content {
    max-width: 560px;
    width: 95%;
}
.shop-modal-content .modal-header h2 {
    font-size: 18px;
}
.shop-balance {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border-color);
    background: rgba(6, 182, 212, 0.06);
}
.shop-balance-label { color: var(--text-secondary); font-size: 14px; }
.shop-balance-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
    text-shadow: 0 0 18px rgba(6, 182, 212, 0.4);
}
.shop-premium-badge {
    margin-left: auto;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    background: var(--primary-gradient);
    color: white;
    font-size: 12px;
    font-weight: 600;
}
.shop-tabs {
    display: flex;
    gap: 8px;
    padding: 16px 24px 0;
}
.shop-tab { flex: 1; }
.shop-catalog { padding: 20px 24px 24px; }
.shop-section { display: block; }
.shop-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}
.shop-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
}
.shop-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 24px rgba(6, 182, 212, 0.14);
}
.shop-card-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    font-size: 16px;
}
.shop-card-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    line-height: 1.35;
}
.shop-card-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
}
.shop-empty-hint,
.group-users-empty {
    padding: 16px;
    color: var(--text-secondary);
    font-size: 14px;
    text-align: center;
}
.shop-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.shop-buy-btn {
    padding: 8px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--accent);
    background: transparent;
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}
.shop-buy-btn:hover {
    background: var(--accent);
    color: var(--dark);
    box-shadow: 0 0 18px rgba(6, 182, 212, 0.3);
}

/* NFT карточки */
.nft-my { margin-bottom: 20px; }
.nft-my-title { font-size: 14px; color: var(--text-secondary); margin-bottom: 12px; }
.nft-catalog-title { font-size: 14px; color: var(--text-secondary); margin-bottom: 12px; }
.nft-grid, .nft-grid-my {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}
.nft-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 14px;
    text-align: center;
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}
.nft-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(6, 182, 212, 0.2);
}
.nft-icon {
    font-size: 42px;
    line-height: 1;
    margin-bottom: 8px;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.3));
}
.nft-name { font-weight: 600; color: var(--text-primary); font-size: 14px; margin-bottom: 4px; }
.nft-desc { font-size: 11px; color: var(--text-muted); margin-bottom: 8px; line-height: 1.3; max-height: 2.6em; overflow: hidden; }
.nft-history { max-height: 4.5em; font-style: italic; font-size: 10px; }
.nft-rarity { font-size: 11px; font-weight: 600; margin-bottom: 8px; text-transform: uppercase; }
.nft-rarity-common { border-color: rgba(150, 150, 150, 0.5); }
.nft-rarity-common .nft-rarity { color: #9ca3af; }
.nft-rarity-rare { border-color: rgba(6, 182, 212, 0.5); }
.nft-rarity-rare .nft-rarity { color: var(--accent); }
.nft-rarity-epic { border-color: rgba(139, 92, 246, 0.5); box-shadow: 0 0 16px rgba(139, 92, 246, 0.2); }
.nft-rarity-epic .nft-rarity { color: var(--accent-violet); }
.nft-rarity-legendary { border-color: rgba(34, 211, 238, 0.6); box-shadow: 0 0 22px rgba(34, 211, 238, 0.25); }
.nft-rarity-legendary .nft-rarity { color: #ffc800; }
.nft-rarity-legendary .nft-icon { filter: drop-shadow(0 0 12px rgba(255, 200, 0, 0.5)); }
.nft-owned { opacity: 1; }
.nft-card .nft-buy-btn { margin-top: 4px; width: 100%; }
.nft-error { color: var(--text-muted); text-align: center; padding: 20px; }

/* Адаптивные улучшения */
@media (max-width: 1024px) {
    .sidebar {
        width: 320px;
    }
    
    .message {
        max-width: 80%;
    }
}

@media (max-width: 480px) {
    body {
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }

    /* Убираем тяжёлые эффекты на очень маленьких экранах для экономии батареи */
    .scanlines,
    .noise {
        display: none;
    }

    /* Чуть упрощаем стеклянный эффект на телефонах, чтобы не жрал FPS и батарею */
    .auth-container,
    .messenger-screen,
    .modal-content {
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        box-shadow: var(--shadow-sm);
    }

    /* Отключаем фон-анимации на экране входа на телефоне */
    .grid-bg,
    .floating-orbs,
    .orb {
        animation: none !important;
        opacity: 0.35;
    }

    .auth-container {
        padding: 24px 16px;
        margin: 12px;
        max-width: 100%;
    }

    .auth-screen {
        padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    }

    .logo {
        width: 56px;
        height: 56px;
        font-size: 28px;
    }

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

    .auth-form input {
        padding: 14px 16px;
        font-size: 16px;
    }

    .emoji-panel {
        left: 8px;
        right: 8px;
        max-width: none;
        max-height: 40vh;
    }

    .sidebar-header {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .sidebar-tabs .tab-btn {
        padding: 10px 8px;
        font-size: 13px;
    }

    .shop-tabs {
        flex-wrap: wrap;
    }

    .shop-tab {
        min-width: calc(33.33% - 4px);
    }

    .shop-cards,
    .nft-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 10px;
    }

    .modal-content {
        border-radius: var(--radius-lg);
    }

    .modal-header {
        padding: 16px;
    }

    .chat-header-actions .btn-icon {
        min-width: 44px;
        min-height: 44px;
    }

    /* Маленькие экраны: стек кнопок, полная ширина модалок */
    .user-profile { min-width: 0; }
    .user-sparks { font-size: 11px; }
    .search-container { padding: 8px 12px; }
    .chat-item { padding: 12px 14px; margin: 0 6px 6px; }
    .chat-item .avatar { width: 44px; height: 44px; font-size: 20px; }
    .chat-item-name { font-size: 15px; }
    .chat-item-preview { font-size: 13px; }
    .modal-actions { flex-direction: column; }
    .modal-actions .btn-primary,
    .modal-actions .btn-secondary { width: 100%; justify-content: center; }
    .profile-qr-wrap { padding: 12px 0; }
    .profile-qr-card { padding: 16px; }
    .profile-qr-img { max-width: 160px; height: auto; }
    .new-chat-result-profile-link .btn-link { min-height: 44px; padding: 12px; }
    .settings-row { padding: 12px 0; min-height: 44px; align-items: center; }
    .settings-section h3 { font-size: 15px; }
    .message { max-width: 96%; }
    .message-content { padding: 12px 16px; font-size: 16px; line-height: 1.5; }
    .attach-menu { flex-wrap: wrap; padding: 8px; }
    .formatting-bar .format-btn { min-width: 44px; min-height: 44px; }
}

/* Очень узкие экраны */
@media (max-width: 360px) {
    .sidebar-tabs .tab-btn { min-width: 100%; }
    .shop-tab { min-width: 50%; }
    .chat-header-info h3 { font-size: 14px; }
    .modal-header h2 { font-size: 17px; }
}

/* Звонок: компактнее PiP и учёт safe-area на телефонах с вырезом */
@media (max-width: 900px) {
    .webrtc-local-pip {
        width: 128px !important;
        max-width: 36vw !important;
        right: 8px !important;
        bottom: max(72px, calc(env(safe-area-inset-bottom, 0px) + 56px)) !important;
    }
    #callLocalFullscreenPreview {
        width: 140px !important;
        max-width: 36vw !important;
        right: 10px !important;
        bottom: max(88px, calc(env(safe-area-inset-bottom, 0px) + 72px)) !important;
    }
    #callFullscreenModal > div:last-of-type {
        padding-bottom: max(14px, env(safe-area-inset-bottom, 0px)) !important;
        padding-left: max(8px, env(safe-area-inset-left, 0px)) !important;
        padding-right: max(8px, env(safe-area-inset-right, 0px)) !important;
    }
}

/* ========== Режимы оформления: performance (экономный) / premium (красивый) ========== */

html[data-ui-mode="performance"] .scanlines,
html[data-ui-mode="performance"] .noise {
    display: none !important;
}

html[data-ui-mode="performance"] .grid-bg {
    animation: none !important;
    opacity: 0.22;
    transform: none;
}

html[data-ui-mode="performance"] .floating-orbs .orb {
    animation: none !important;
}

html[data-ui-mode="performance"] .auth-container,
html[data-ui-mode="performance"] .sidebar,
html[data-ui-mode="performance"] .chat-area,
html[data-ui-mode="performance"] .modal-content {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

html[data-ui-mode="performance"] .messenger-screen::before {
    opacity: 0.35;
}

html[data-ui-mode="performance"] .premium-aurora {
    display: none !important;
}

html[data-ui-mode="premium"] body {
    font-family: 'Plus Jakarta Sans', 'Syne', system-ui, sans-serif;
}

html[data-ui-mode="premium"] .premium-aurora {
    display: block;
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
    background:
        radial-gradient(ellipse 120% 80% at 10% 0%, rgba(139, 92, 246, 0.35) 0%, transparent 55%),
        radial-gradient(ellipse 100% 60% at 90% 10%, rgba(236, 72, 153, 0.28) 0%, transparent 50%),
        radial-gradient(ellipse 80% 50% at 50% 100%, rgba(6, 182, 212, 0.22) 0%, transparent 45%);
    animation: premiumAuroraShift 18s ease-in-out infinite alternate;
}

@keyframes premiumAuroraShift {
    0% { filter: hue-rotate(0deg) saturate(1); transform: scale(1); }
    100% { filter: hue-rotate(25deg) saturate(1.15); transform: scale(1.03); }
}

html[data-ui-mode="premium"] .messenger-screen {
    background: transparent;
}

html[data-ui-mode="premium"] .messenger-screen > aside,
html[data-ui-mode="premium"] .messenger-screen > .chat-area {
    position: relative;
    z-index: 1;
}

html[data-ui-mode="premium"] .messenger-screen::before {
    opacity: 1;
    background:
        radial-gradient(ellipse 70% 50% at 75% 15%, rgba(6, 182, 212, 0.14) 0%, transparent 55%),
        radial-gradient(ellipse 55% 45% at 15% 85%, rgba(236, 72, 153, 0.12) 0%, transparent 50%);
    animation: premiumGlowPulse 12s ease-in-out infinite alternate;
}

@keyframes premiumGlowPulse {
    0% { opacity: 0.85; }
    100% { opacity: 1; }
}

html[data-ui-mode="premium"] .sidebar {
    background: linear-gradient(165deg, rgba(18, 21, 32, 0.97) 0%, rgba(11, 13, 22, 0.94) 100%);
    border-right: 1px solid transparent;
    border-image: linear-gradient(180deg, rgba(6, 182, 212, 0.45), rgba(139, 92, 246, 0.35), rgba(236, 72, 153, 0.3)) 1;
    box-shadow: 4px 0 48px rgba(0, 0, 0, 0.35), inset -1px 0 0 rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

html[data-ui-mode="premium"] .chat-area {
    background: rgba(8, 10, 18, 0.35);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

html[data-ui-mode="premium"] .chat-header {
    background: linear-gradient(180deg, rgba(15, 18, 28, 0.95) 0%, rgba(11, 13, 20, 0.88) 100%);
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

html[data-ui-mode="premium"] .message.sent .message-content {
    box-shadow:
        0 4px 24px rgba(139, 92, 246, 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.08) inset;
}

html[data-ui-mode="premium"] .message:not(.sent) .message-content {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(148, 163, 184, 0.12);
}

html[data-ui-mode="premium"] .chat-item.active {
    box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.45), 0 8px 28px rgba(139, 92, 246, 0.12);
}

html[data-ui-mode="premium"] .chat-item:hover {
    box-shadow:
        0 0 0 1px rgba(139, 92, 246, 0.28),
        0 10px 30px rgba(139, 92, 246, 0.16);
}

html[data-ui-mode="premium"] .search-input {
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.95), rgba(11, 13, 22, 0.95));
    border: 1px solid rgba(139, 92, 246, 0.22);
}

html[data-ui-mode="premium"] .search-input:focus {
    border-color: rgba(56, 189, 248, 0.65);
    box-shadow:
        0 0 0 2px rgba(56, 189, 248, 0.2),
        0 0 30px rgba(139, 92, 246, 0.24);
}

html[data-ui-mode="premium"] .btn-icon,
html[data-ui-mode="premium"] .btn-secondary {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

html[data-ui-mode="premium"] .scanlines {
    opacity: 0.045;
}

html[data-ui-mode="premium"] .noise {
    opacity: 0.02;
}

html[data-ui-mode="premium"] .auth-container {
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.06) inset,
        0 24px 80px rgba(139, 92, 246, 0.18),
        0 12px 40px rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(139, 92, 246, 0.25);
}

html[data-ui-mode="premium"] .logo {
    box-shadow:
        0 0 48px rgba(236, 72, 153, 0.45),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

html[data-ui-mode="premium"] .btn-primary {
    box-shadow: 0 4px 24px rgba(139, 92, 246, 0.35);
}

html[data-ui-mode="premium"] .modal-content {
    border: 1px solid rgba(139, 92, 246, 0.2);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5), 0 0 60px rgba(139, 92, 246, 0.08);
}

@media (max-width: 480px) {
    html[data-ui-mode="premium"] .scanlines,
    html[data-ui-mode="premium"] .noise {
        display: block !important;
        opacity: 0.03;
    }

    html[data-ui-mode="premium"] .sidebar,
    html[data-ui-mode="premium"] .chat-area,
    html[data-ui-mode="premium"] .modal-content {
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
    }
}

/* Футер приложения (все права защищены) */
.app-footer {
    position: static;
    padding: 10px 16px;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-muted, #94a3b8);
    background: rgba(11, 13, 18, 0.55);
    border-top: 1px solid rgba(6, 182, 212, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    z-index: 1;
}
.app-footer a {
    color: var(--accent, #06b6d4);
    text-decoration: none;
}
.app-footer a:hover { text-decoration: underline; }
.app-footer .sep { opacity: 0.5; }
.app-footer .copy { font-size: 11px; opacity: 0.9; }

/* Мобильные: меньше задержка тапа, плавный скролл */
@media (max-width: 900px) {
    button,
    .chat-item,
    .tab-btn,
    .icon-btn,
    .message-reaction-pill {
        touch-action: manipulation;
    }
    .messages-container,
    .chats-list,
    .sidebar {
        -webkit-overflow-scrolling: touch;
    }
}
