/* frontend/css/main.css - Cleaned version */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    height: 100vh;
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Основной контейнер */
.app-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    background: #1e1e2e;
    overflow: hidden;
}

/* Левая панель (чаты) - фиксированная ширина */
.sidebar {
    width: 320px;
    min-width: 260px;
    background: #2a2a3a;
    border-right: 1px solid #3a3a4a;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

/* User Profile Button */
.user-profile-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 72px;
    padding: 0 20px;
    background: #2a2a3a;
    border-bottom: 1px solid #3a3a4a;
    cursor: pointer;
    transition: background 0.2s;
}

.user-profile-btn:hover {
    background: #3a3a4a;
}

.user-avatar {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
    color: white;
}

.user-info-side {
    flex: 1;
}

.user-name-side {
    font-weight: 600;
    color: #fff;
    font-size: 16px;
}

.user-status-side {
    font-size: 12px;
    color: #4caf50;
    margin-top: 2px;
}

/* Section Header */
.section-header {
    padding: 12px 20px;
    background: #2a2a3a;
    font-size: 12px;
    font-weight: 600;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.add-chat-btn,
.sidebar-search-toggle-btn {
    color: white;
    border: none;
    border-radius: 20px;
    padding: 4px 12px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
}

.add-chat-btn {
    background: #667eea;
}

.add-chat-btn:hover {
    background: #5a67d8;
}

.sidebar-search-toggle-btn {
    background: #3a3a4a;
    color: #d7dbe8;
}

.sidebar-search-toggle-btn:hover,
.sidebar-search-toggle-btn.active {
    background: #4a4a62;
    color: #fff;
}

.sidebar-chat-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px 10px;
    background: #2a2a3a;
}

.sidebar-chat-search input {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    background: #1e1e2e;
    border: 1px solid #3a3a4a;
    border-radius: 10px;
    color: #e0e0e0;
    font-size: 13px;
    outline: none;
}

.sidebar-chat-search input:focus {
    border-color: #667eea;
}

.sidebar-chat-search-close {
    width: 32px;
    height: 32px;
    border: 1px solid #3a3a4a;
    border-radius: 8px;
    background: none;
    color: #aaa;
    cursor: pointer;
    flex-shrink: 0;
}

.sidebar-chat-search-close:hover {
    background: #3a3a4a;
    color: #fff;
}

.animation-toggle-btn {
    background: transparent;
    color: #aaa;
    border: 1px solid #4a4a5a;
    border-radius: 20px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s;
}

.animation-toggle-btn:hover {
    color: #fff;
    border-color: #667eea;
}

.animation-lab {
    padding: 12px 16px;
    border-bottom: 1px solid #3a3a4a;
    background: rgba(255, 255, 255, 0.02);
}

.app-version {
    padding: 10px 20px;
    font-size: 12px;
    color: #8f9bb3;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-bottom: 1px solid #3a3a4a;
}

.animation-lab-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.animation-select {
    width: 100%;
    padding: 8px 10px;
    background: #1e1e2e;
    color: #fff;
    border: 1px solid #3a3a4a;
    border-radius: 10px;
}

.animation-lab-btn {
    flex: 1;
    padding: 8px 10px;
    background: #2f3957;
    color: #fff;
    border: 1px solid #4b5b86;
    border-radius: 10px;
    cursor: pointer;
}

.animation-lab-btn:hover {
    background: #3a4870;
}

.animation-lab-hint {
    color: #8f97ad;
    font-size: 11px;
}

.animation-lab-divider {
    height: 1px;
    margin: 12px 0;
    background: rgba(255, 255, 255, 0.08);
}

/* Chats List */
.chats-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.chat-item {
    padding: 12px;
    margin: 4px 0;
    background: #2a2a3a;
    border-radius: 12px;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    gap: 10px;
}

.chat-item-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    font-size: 15px;
    flex-shrink: 0;
    overflow: hidden;
}

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

.chat-item:hover {
    background: #3a3a4a;
    transform: translateX(4px);
}

.chat-item.active {
    background: #667eea;
}

.chat-name {
    font-weight: 500;
    color: #fff;
}

.chat-preview {
    font-size: 12px;
    color: #aaa;
    margin-top: 4px;
}

.unread-badge {
    background: #f44336;
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 600;
}

.unread-badge-live {
    animation: unread-badge-idle 2.4s ease-in-out infinite;
}

.chat-muted-badge {
    background: rgba(255, 193, 7, 0.22);
    color: #ffd65c;
    border: 1px solid rgba(255, 193, 7, 0.32);
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 600;
    margin-right: 8px;
}

.chat-context-menu,
.message-attachment-popover {
    z-index: 2500;
    min-width: 190px;
    background: #161826;
    border: 1px solid #2f3348;
    border-radius: 12px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.35);
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-context-menu {
    position: fixed;
}

.chat-context-menu button,
.message-attachment-popover button {
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    color: #dde3ff;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    cursor: pointer;
}

.chat-context-menu button:hover,
.message-attachment-popover button:hover {
    background: #2b3148;
}

.chat-context-menu button.danger,
.message-attachment-popover button.danger {
    color: #ffb4b4;
}

.chat-context-menu button.danger:hover,
.message-attachment-popover button.danger:hover {
    background: rgba(244, 67, 54, 0.14);
}

.chat-context-menu button.accent,
.message-attachment-popover button.accent {
    color: #9fb1ff;
}

.chat-context-menu button.accent:hover,
.message-attachment-popover button.accent:hover {
    background: rgba(102, 126, 234, 0.14);
}

.message-context-menu button.danger {
    color: #ffb4b4;
}

.message-context-menu button.danger:hover {
    background: rgba(176, 52, 52, 0.25);
}

.chat-item-bump-from {
    transform: translateX(0) translateY(0) scale(1);
}

.chat-item-bump-active {
    animation: chat-item-bump 420ms cubic-bezier(0.2, 0.9, 0.2, 1);
}

.chat-item-wiggle-from {
    transform: translateX(0) rotate(0deg);
}

.chat-item-wiggle-active {
    animation: chat-item-wiggle 520ms cubic-bezier(0.2, 0.85, 0.2, 1);
}

.chat-badge-pop-from {
    transform: scale(0.7);
    opacity: 0.5;
}

.chat-badge-pop-active {
    animation: chat-badge-pop 360ms cubic-bezier(0.18, 0.9, 0.22, 1.15);
}

.chat-badge-bounce-from {
    transform: translateY(0) scale(1);
}

.chat-badge-bounce-active {
    animation: chat-badge-bounce 560ms cubic-bezier(0.2, 0.88, 0.2, 1);
}

@keyframes unread-badge-idle {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(244, 67, 54, 0);
    }

    35% {
        transform: scale(1.08);
        box-shadow: 0 0 0 6px rgba(244, 67, 54, 0.08);
    }

    55% {
        transform: scale(0.98);
    }
}

@keyframes chat-item-bump {
    0% {
        transform: translateX(0) translateY(0) scale(1);
    }

    40% {
        transform: translateX(6px) translateY(-3px) scale(1.02);
    }

    100% {
        transform: translateX(0) translateY(0) scale(1);
    }
}

@keyframes chat-item-wiggle {
    0%, 100% {
        transform: translateX(0) rotate(0deg);
    }

    20% {
        transform: translateX(3px) rotate(1deg);
    }

    45% {
        transform: translateX(-4px) rotate(-1.4deg);
    }

    70% {
        transform: translateX(2px) rotate(0.8deg);
    }
}

@keyframes chat-badge-pop {
    0% {
        transform: scale(0.7);
        opacity: 0.5;
    }

    60% {
        transform: scale(1.2);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes chat-badge-bounce {
    0% {
        transform: translateY(0) scale(1);
    }

    30% {
        transform: translateY(-8px) scale(1.12);
    }

    55% {
        transform: translateY(1px) scale(0.96);
    }

    100% {
        transform: translateY(0) scale(1);
    }
}

/* Центральная область (чат) - занимает все оставшееся место */
.chat-area {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #1e1e2e;
    min-width: 0;
    /* ← не меняй */
    max-width: 100%;
    /* ← не меняй */
}

.chat-attention-jump {
    position: absolute;
    right: 18px;
    bottom: 86px;
    z-index: 6;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid rgba(102, 126, 234, 0.28);
    border-radius: 999px;
    background: rgba(18, 21, 34, 0.92);
    color: #eef2ff;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
    cursor: pointer;
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.chat-attention-jump:hover {
    transform: translateY(-1px);
    background: rgba(28, 33, 52, 0.96);
    border-color: rgba(102, 126, 234, 0.42);
}

.chat-attention-jump-icon {
    font-size: 15px;
    line-height: 1;
}

.chat-attention-jump-count {
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #7f6bff 100%);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

/* Chat header */
.chat-header {
    height: 72px;
    padding: 0 24px;
    background: #2a2a3a;
    border-bottom: 1px solid #3a3a4a;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

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

.chat-header-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    flex-shrink: 0;
    overflow: hidden;
}

.chat-header-name {
    font-weight: 600;
    color: #fff;
    font-size: 18px;
}

.chat-header-status {
    font-size: 12px;
    color: #aaa;
}

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

.chat-info-btn {
    background: none;
    border: none;
    color: #aaa;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
}

.chat-info-btn:hover {
    background: #3a3a4a;
    color: #fff;
}

.chat-members-btn,
.chat-search-btn {
    background: none;
    border: none;
    color: #aaa;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
}

.chat-members-btn:hover,
.chat-search-btn:hover {
    background: #3a3a4a;
    color: #fff;
}

.chat-members-btn.active {
    color: #667eea;
    background: rgba(102, 126, 234, 0.15);
}

.chat-search-btn.active {
    color: #667eea;
    background: rgba(102, 126, 234, 0.15);
}

/* Search panel */
.search-panel {
    position: relative;
    margin: 0 12px 10px;
    padding: 10px;
    background: #252536;
    border: 1px solid #3a3a4a;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: visible;
}

.search-panel-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0;
}

.search-panel-header input {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    background: #1e1e2e;
    border: 1px solid #3a3a4a;
    border-radius: 10px;
    color: #e0e0e0;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.search-panel-header input:focus {
    border-color: #667eea;
}

.search-panel-icon-btn,
.search-panel-close {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    background: none;
    border: 1px solid #3a3a4a;
    color: #aaa;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}

.search-panel-icon-btn {
    font-size: 14px;
}

.search-panel-close {
    font-size: 20px;
}

.search-panel-icon-btn:hover,
.search-panel-close:hover {
    background: #3a3a4a;
    color: #fff;
}

.search-panel-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.search-panel-chip {
    max-width: 100%;
    border: 1px solid #45455b;
    background: #2a2a3a;
    color: #d7dbe8;
    padding: 4px 10px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
}

.search-panel-chip:hover {
    border-color: #667eea;
    color: #fff;
}

.search-scope-label {
    font-size: 11px;
    color: #8f9bb3;
}

.search-panel-popover {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 20;
    background: #202031;
    border: 1px solid #3a3a4a;
    border-radius: 12px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.search-panel-popover-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.search-panel-popover-title {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #8f9bb3;
}

.search-scope-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.search-scope-btn {
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid #45455b;
    background: #2a2a3a;
    color: #cfd4e3;
    font-size: 12px;
    cursor: pointer;
}

.search-scope-btn:hover {
    border-color: #667eea;
    color: #fff;
}

.search-scope-btn.active {
    background: rgba(102, 126, 234, 0.18);
    border-color: #667eea;
    color: #fff;
}

.search-chat-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 150px;
    overflow-y: auto;
    padding-right: 4px;
}

.search-chat-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    background: #252536;
    color: #d7dbe8;
    font-size: 12px;
    cursor: pointer;
}

.search-chat-option:hover {
    background: #2f2f44;
}

.search-chat-option input {
    accent-color: #667eea;
}

.search-chat-option-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-chat-options-empty {
    padding: 6px 0;
    color: #8f9bb3;
    font-size: 12px;
}

.search-panel-filters {
    display: flex;
    gap: 8px;
    padding: 0;
    flex-wrap: wrap;
}

.search-panel-filters input,
.search-panel-filters select {
    flex: 1 1 120px;
    min-width: 0;
    padding: 6px 10px;
    background: #1e1e2e;
    border: 1px solid #3a3a4a;
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 12px;
    outline: none;
}

.search-panel-filters input:focus,
.search-panel-filters select:focus {
    border-color: #667eea;
}

.search-results {
    display: flex;
    flex-direction: column;
    max-height: 220px;
    overflow-y: auto;
    border-top: 1px solid #2f2f44;
}

.search-results:empty {
    display: none;
}

.search-results-empty {
    text-align: center;
    padding: 16px 10px;
    color: #888;
    font-size: 13px;
}

.search-result-count {
    padding: 8px 4px 6px;
    font-size: 12px;
    color: #888;
    border-bottom: 1px solid #2a2a3a;
}

.search-result-item {
    padding: 8px 4px 10px;
    cursor: pointer;
    border-bottom: 1px solid #2a2a3a;
    transition: background 0.15s;
}

.search-result-item:hover {
    background: #2a2a3a;
}

.search-result-item.active {
    background: rgba(102, 126, 234, 0.15);
}

.search-result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 4px;
}

.search-result-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
}

.search-result-chat {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(102, 126, 234, 0.15);
    border: 1px solid rgba(102, 126, 234, 0.28);
    color: #cfd4ff;
    font-size: 11px;
}

.search-result-sender {
    font-size: 12px;
    font-weight: 600;
    color: #667eea;
}

.search-result-date {
    font-size: 11px;
    color: #888;
    white-space: nowrap;
}

.search-result-content {
    font-size: 12px;
    line-height: 1.4;
    color: #ccc;
    white-space: normal;
    overflow: hidden;
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.search-result-content mark {
    background: rgba(102, 126, 234, 0.35);
    color: #fff;
    border-radius: 2px;
    padding: 0 2px;
}

/* Сообщения */
.messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    background: #1e1e2e;
    display: flex;
    flex-direction: column;
}

.messages-top-loader {
    display: flex;
    justify-content: center;
    padding: 10px 0 16px;
    position: sticky;
    top: 0;
    z-index: 1;
    background: rgba(30, 30, 46, 0.95);
}

.load-older-messages-btn {
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    padding: 8px 18px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

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

* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

*::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: content-box;
}

*::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.28);
}

*::-webkit-scrollbar-corner {
    background: transparent;
}

.message {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.message-attention-target .message-bubble {
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.52), 0 10px 26px rgba(102, 126, 234, 0.18);
    animation: messageAttentionPulse 1.2s ease;
}

.message-day-separator {
    display: flex;
    justify-content: center;
    margin: 10px 0 14px;
}

.message-day-separator span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #c9d0f0;
    font-size: 11px;
    letter-spacing: 0.02em;
    text-transform: capitalize;
}

.message-context-active {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.message.search-highlight {
    background: rgba(102, 126, 234, 0.2);
    border-radius: 8px;
    transition: background 0.3s ease;
}

.message-removing {
    pointer-events: none;
}

.message-removing-active {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
    transition: opacity 180ms ease, transform 180ms ease;
}

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

.message.received {
    align-items: flex-start;
}

.message-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: min(70%, 420px);
}

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

.message.received .message-body {
    align-items: flex-start;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    word-wrap: break-word;
    word-break: break-word;
    /* ← принудительный перенос длинных слов */
    max-width: 100%;
    width: fit-content;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message-bubble-media-only {
    padding: 6px;
    gap: 0;
    background: transparent !important;
    max-width: min(360px, 70vw);
}

.message-attachments-stack {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: fit-content;
    max-width: min(360px, 70vw);
}

.message-content {
    white-space: pre-wrap;
}

.message-media {
    display: flex;
    margin-top: 4px;
}

.message-media-only .message-media,
.message-bubble-media-only .message-media,
.message-attachments-stack .message-media,
.message-attachments-stack .message-file-row {
    margin-top: 0;
}

.message-image {
    display: block;
    max-width: min(320px, 100%);
    max-height: 280px;
    border-radius: 14px;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.12);
    cursor: zoom-in;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.message-bubble-media-only .message-image {
    max-width: min(348px, calc(70vw - 12px));
    max-height: 320px;
}

.message-image:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
}

.message-file-row {
    display: flex;
    margin-top: 4px;
}

.message-file-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border-radius: 10px;
    background: rgba(102, 126, 234, 0.14);
    color: #eef2ff;
    text-decoration: none;
}

.message-file-link:hover {
    background: rgba(102, 126, 234, 0.22);
}

.message-mention {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(102, 126, 234, 0.2);
    color: #e5eaff;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s ease, transform 0.18s ease;
}

.message-mention:hover {
    background: rgba(102, 126, 234, 0.3);
    transform: translateY(-1px);
}

.message.sent .message-mention {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

.mention-hover-card {
    position: fixed;
    z-index: 2600;
    width: min(260px, calc(100vw - 16px));
    padding: 10px 12px;
    border-radius: 16px;
    border: 1px solid rgba(102, 126, 234, 0.24);
    background:
        radial-gradient(circle at top left, rgba(102, 126, 234, 0.16), transparent 52%),
        rgba(20, 23, 35, 0.98);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.35);
    pointer-events: none;
}

.mention-hover-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mention-hover-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-weight: 700;
    flex-shrink: 0;
}

.mention-hover-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mention-hover-name {
    color: #fff;
    font-size: 14px;
    font-weight: 700;
}

.mention-hover-username {
    color: #aeb7cf;
    font-size: 12px;
}

.mention-hover-status {
    font-size: 11px;
}

.mention-hover-status.online {
    color: #75d68a;
}

.mention-hover-status.offline {
    color: #a9b3cc;
}

.mention-hover-bio {
    margin-top: 8px;
    color: #d2d8ec;
    font-size: 12px;
    line-height: 1.4;
}

.message-reply-fragment {
    border-left: 3px solid rgba(255, 255, 255, 0.45);
    padding-left: 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    cursor: pointer;
    transition: opacity 0.15s;
}

.message-reply-fragment:hover {
    opacity: 0.8;
}

.message.sent .message-reply-fragment {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 8px 0 8px 10px;
}

.message.received .message-reply-fragment {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    padding: 8px 0 8px 10px;
}

.message-reply-author {
    font-size: 11px;
    font-weight: 600;
    color: #d7ddff;
}

.message-reply-text {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.78);
}

.message.sent .message-bubble {
    background: #667eea;
    color: white;
    border-bottom-right-radius: 4px;
}

.message.received .message-bubble {
    background: #2a2a3a;
    color: #fff;
    border-bottom-left-radius: 4px;
}

.message-sender {
    font-size: 11px;
    color: #aaa;
    margin-bottom: 2px;
    margin-left: 8px;
}

.message-time {
    font-size: 10px;
    color: #666;
    margin-top: 2px;
    margin-left: 12px;
}

.message-edited-label {
    font-size: 10px;
    color: #9da6c8;
    margin-left: 6px;
    text-transform: lowercase;
}

.msg-animate {
    will-change: opacity, transform;
    transform-origin: center center;
}

.msg-enter-spin-drop-from {
    opacity: 0;
    transform: translateY(-36px) rotate(-340deg) scale(0.82);
}

.msg-enter-spin-drop-active {
    opacity: 1;
    transform: translateY(0) rotate(0deg) scale(1);
    transition: opacity 420ms ease, transform 420ms cubic-bezier(0.18, 0.89, 0.32, 1.2);
}

.msg-enter-left-from {
    opacity: 0;
    transform: translateX(-64px);
}

.msg-enter-left-active {
    opacity: 1;
    transform: translateX(0);
    transition: opacity 260ms ease, transform 260ms cubic-bezier(0.22, 1, 0.36, 1);
}

.msg-enter-right-from {
    opacity: 0;
    transform: translateX(64px);
}

.msg-enter-right-active {
    opacity: 1;
    transform: translateX(0);
    transition: opacity 260ms ease, transform 260ms cubic-bezier(0.22, 1, 0.36, 1);
}

.msg-enter-pop-from {
    opacity: 0;
    transform: translateY(10px) scale(0.88);
}

.msg-enter-pop-active {
    opacity: 1;
    transform: translateY(0) scale(1);
    transition: opacity 220ms ease, transform 220ms cubic-bezier(0.2, 0.85, 0.22, 1.1);
}

.msg-enter-fade-from {
    opacity: 0;
}

.msg-enter-fade-active {
    opacity: 1;
    transition: opacity 220ms ease;
}

.msg-bubble-letters .msg-letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(12px) rotate(-8deg) scale(0.72);
    filter: blur(3px);
    animation: letter-chaos-rise 340ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    animation-delay: calc(var(--letter-index) * 22ms);
}

.msg-bubble-explosion {
    perspective: 900px;
    transform-style: preserve-3d;
}

.msg-bubble-explosion .msg-letter-explosion {
    opacity: 0;
    display: inline-block;
    transform:
        translate3d(var(--scatter-x), var(--scatter-y), var(--scatter-z))
        rotate(var(--scatter-rotate))
        scale(0.72);
    filter: blur(3px);
    text-shadow: 0 0 12px rgba(255, 255, 255, 0.16);
    animation: reverse-explosion-in 680ms cubic-bezier(0.18, 0.88, 0.2, 1) forwards;
    animation-delay: var(--scatter-delay);
}

@keyframes letter-chaos-rise {
    0% {
        opacity: 0;
        transform: translateY(12px) rotate(-8deg) scale(0.72);
        filter: blur(3px);
    }

    65% {
        opacity: 1;
        transform: translateY(-2px) rotate(4deg) scale(1.04);
        filter: blur(0);
    }

    100% {
        opacity: 1;
        transform: translateY(0) rotate(0deg) scale(1);
        filter: blur(0);
    }
}

@keyframes reverse-explosion-in {
    0% {
        opacity: 0;
        transform:
            translate3d(var(--scatter-x), var(--scatter-y), var(--scatter-z))
            rotate(var(--scatter-rotate))
            scale(0.72);
        filter: blur(3px);
    }

    70% {
        opacity: 1;
        transform:
            translate3d(calc(var(--scatter-x) * -0.06), calc(var(--scatter-y) * -0.06), 0)
            rotate(calc(var(--scatter-rotate) * -0.05))
            scale(1.06);
        filter: blur(0);
    }

    100% {
        opacity: 1;
        transform: translate3d(0, 0, 0) rotate(0deg) scale(1);
        filter: blur(0);
    }
}

.typing-indicator {
    padding: 8px 16px;
    color: #aaa;
    font-size: 12px;
    font-style: italic;
}

/* Input area */
.input-area {
    position: relative;
    padding: 16px 24px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    background: #2a2a3a;
    border-top: 1px solid #3a3a4a;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
}

.input-row {
    display: flex;
    gap: 12px;
    width: 100%;
    align-items: center;
}

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

.message-attachment-menu {
    position: static;
    flex-shrink: 0;
}

.message-tool-btn {
    width: 40px;
    height: 40px;
    border: 1px solid #3a3a4a;
    border-radius: 12px;
    background: #232335;
    color: #eef2ff;
    cursor: pointer;
    flex-shrink: 0;
}

.message-tool-btn-attachment {
    font-size: 18px;
    line-height: 1;
}

.message-tool-btn.active,
.message-tool-btn:hover:not(:disabled) {
    background: #2f2f44;
    border-color: rgba(102, 126, 234, 0.5);
}

.message-tool-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}

.message-attachment-popover {
    position: absolute;
    left: 0;
    bottom: 100%;
    width: 190px;
}

.message-attachment-option {
    white-space: nowrap;
}

.mention-suggestions {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 8px);
    z-index: 12;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px;
    border-radius: 14px;
    border: 1px solid rgba(102, 126, 234, 0.22);
    background: rgba(17, 20, 31, 0.98);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.35);
}

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

.mention-suggestion-item:hover,
.mention-suggestion-item.active {
    background: rgba(102, 126, 234, 0.16);
}

.mention-suggestion-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.mention-suggestion-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mention-suggestion-name {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
}

.mention-suggestion-meta {
    font-size: 11px;
    color: #9aa3bd;
}

.attachment-preview {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: min(260px, 100%);
    padding: 6px 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.attachment-chip-thumb {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.attachment-chip-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #eef2ff;
    font-size: 12px;
}

.attachment-chip-remove {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
}

.attachment-chip-remove:hover {
    background: rgba(255, 255, 255, 0.16);
}

.reply-preview {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(102, 126, 234, 0.12);
    border: 1px solid rgba(102, 126, 234, 0.26);
}

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

.reply-preview-label {
    font-size: 12px;
    color: #b7c2ff;
    margin-bottom: 4px;
}

.reply-preview-text {
    font-size: 13px;
    color: #eef1ff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-preview-close {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
}

.reply-preview-close:hover {
    background: rgba(255, 255, 255, 0.16);
}

.edit-message-input {
    width: 100%;
    min-height: 120px;
    padding: 12px 14px;
    resize: vertical;
    border-radius: 12px;
    border: 1px solid #3a3a4a;
    background: #1e1e2e;
    color: #fff;
    outline: none;
}

.edit-message-input:focus {
    border-color: #667eea;
}

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

.edit-message-attachments-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    border-radius: 14px;
    border: 1px solid rgba(102, 126, 234, 0.18);
    background: rgba(102, 126, 234, 0.08);
}

.edit-message-attachment-actions {
    display: flex;
    justify-content: flex-start;
}

.attachment-chip-existing {
    border-color: rgba(102, 126, 234, 0.28);
}

.attachment-chip-pending {
    border-color: rgba(122, 230, 145, 0.28);
}

body.image-viewer-open {
    overflow: hidden;
}

.image-viewer-overlay {
    position: fixed;
    inset: 0;
    z-index: 4000;
    opacity: 0;
    transition: opacity 0.16s ease;
}

.image-viewer-overlay.is-visible {
    opacity: 1;
}

.image-viewer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(3, 6, 14, 0.94);
    backdrop-filter: blur(4px);
}

.image-viewer-content {
    position: relative;
    z-index: 1;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.image-viewer-image {
    display: block;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
    width: auto;
    height: auto;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

.image-viewer-close {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}

.image-viewer-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.input-area input {
    flex: 1;
    padding: 12px 16px;
    background: #1e1e2e;
    border: 1px solid #3a3a4a;
    border-radius: 24px;
    outline: none;
    color: #fff;
    font-size: 14px;
}

.input-area input:focus {
    border-color: #667eea;
}

.input-row > button {
    padding: 12px 24px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    font-weight: 600;
}

.input-row > button:hover {
    background: #5a67d8;
}

.input-area.hidden {
    display: none;
}

/* Правая панель (участники) - отдельный блок */
.members-sidebar {
    width: 280px;
    background: #2a2a3a;
    border-left: 1px solid #3a3a4a;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}

.members-sidebar.hidden {
    display: none;
}

.members-header {
    height: 72px;
    padding: 0 16px;
    border-bottom: 1px solid #3a3a4a;
    font-weight: bold;
    color: #fff;
    background: #2a2a3a;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.members-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.online-count {
    font-size: 12px;
    font-weight: normal;
    color: #aaa;
}

.members-collapse-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: #dbe3ff;
    cursor: pointer;
    flex-shrink: 0;
}

.members-collapse-btn:hover {
    background: rgba(102, 126, 234, 0.16);
}

.members-list {
    flex: 1;
    overflow-y: auto;
}

.member-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #3a3a4a;
}

.member-item:hover {
    background: #3a3a4a;
}

.member-avatar {
    width: 36px;
    height: 36px;
    background: #667eea;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    flex-shrink: 0;
    overflow: hidden;
}

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

.member-name {
    font-weight: 500;
    margin-bottom: 2px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.member-full-name {
    font-size: 11px;
    color: #9aa3bd;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.member-status {
    font-size: 11px;
}

.member-status.online {
    color: #4caf50;
}

.member-status.offline {
    color: #aaa;
}

.member-role {
    font-size: 11px;
    color: #ff9800;
    background: rgba(255, 152, 0, 0.2);
    padding: 2px 6px;
    border-radius: 10px;
    flex-shrink: 0;
}

/* Online/Offline indicators */
.online-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #4caf50;
    box-shadow: 0 0 4px #4caf50;
}

.offline-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #666;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    padding: 18px;
    background:
        radial-gradient(circle at top, rgba(102, 126, 234, 0.18), transparent 38%),
        rgba(7, 10, 20, 0.72);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.modal {
    width: min(560px, calc(100vw - 24px));
    max-width: 92vw;
    max-height: min(90vh, 860px);
    overflow: hidden;
    border-radius: 24px;
    border: 1px solid rgba(102, 126, 234, 0.18);
    background:
        linear-gradient(180deg, rgba(42, 45, 66, 0.98), rgba(23, 25, 36, 0.98)),
        #202335;
    box-shadow:
        0 24px 80px rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    animation: modalFadeIn 0.22s ease;
}

.modal-content {
    padding: 18px 18px 16px;
    color: #fff;
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-height: min(90vh, 860px);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.modal-header-spacer {
    flex: 1;
    min-height: 1px;
}

.modal-title,
.modal-content h3 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.02em;
}

.modal-close-btn {
    width: 36px;
    height: 36px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    color: #dbe3ff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s, border-color 0.2s;
}

.modal-close-btn:hover {
    background: rgba(102, 126, 234, 0.16);
    border-color: rgba(102, 126, 234, 0.34);
    transform: translateY(-1px);
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    min-width: 0;
    padding-right: 2px;
}

.modal-content p,
.modal-content small,
.modal-content label {
    color: #aeb7cf;
}

.modal-content label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.modal-content input,
.modal-content textarea,
.modal-content select {
    width: 100%;
    padding: 12px 14px;
    margin: 0;
    background: #171724;
    border: 1px solid #2a2d41;
    border-radius: 14px;
    color: #fff;
    outline: none;
    font-size: 14px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.modal-content textarea {
    min-height: 104px;
    resize: vertical;
}

.modal-content select[multiple] {
    min-height: 140px;
}

.modal-content input::placeholder,
.modal-content textarea::placeholder {
    color: #7f879d;
}

.modal-content input:focus,
.modal-content textarea:focus,
.modal-content select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.16);
}

.modal-content .section-header {
    margin: 2px 0 0;
    padding: 10px 12px;
    border: 1px solid #2a2d41;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    color: #dbe3ff;
    font-size: 11px;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.modal-buttons button {
    min-width: 110px;
    padding: 10px 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.modal-buttons button:hover {
    transform: translateY(-1px);
}

.modal-buttons .primary,
.modal-buttons .primary-btn,
.modal-buttons .btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #7f6bff 100%);
    color: #fff;
    box-shadow: 0 12px 24px rgba(102, 126, 234, 0.28);
}

.modal-buttons .primary:hover,
.modal-buttons .primary-btn:hover,
.modal-buttons .btn-primary:hover {
    background: linear-gradient(135deg, #7587ff 0%, #8d79ff 100%);
}

.modal-buttons button:not([class]),
.modal-buttons .secondary,
.modal-buttons .secondary-btn,
.modal-buttons .btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.08);
}

.modal-buttons button:not([class]):hover,
.modal-buttons .secondary:hover,
.modal-buttons .secondary-btn:hover,
.modal-buttons .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.modal-buttons .danger-btn,
.modal-buttons .btn-danger {
    background: linear-gradient(135deg, #f44336 0%, #e34b71 100%);
    color: white;
    box-shadow: 0 10px 22px rgba(244, 67, 54, 0.22);
}

.modal-buttons .danger-btn:hover,
.modal-buttons .btn-danger:hover {
    background: linear-gradient(135deg, #ff5a50 0%, #ef5f84 100%);
}

@media (max-width: 640px) {
    .modal-overlay {
        padding: 12px;
    }

    .modal {
        width: calc(100vw - 24px);
        max-height: calc(100vh - 24px);
    }

    .modal-content {
        padding: 14px;
    }

    .modal-buttons {
        flex-direction: column-reverse;
    }

    .modal-buttons button {
        width: 100%;
    }
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

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

@keyframes messageAttentionPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.18);
    }

    45% {
        box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.24), 0 12px 28px rgba(102, 126, 234, 0.2);
    }

    100% {
        box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.52), 0 10px 26px rgba(102, 126, 234, 0.18);
    }
}

/* Profile Panel */
.profile-panel {
    text-align: center;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: bold;
    color: white;
    margin: 0 auto 16px;
}

.profile-username {
    font-size: 24px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 8px;
}

.profile-email {
    color: #aaa;
    margin-bottom: 16px;
}

.profile-info {
    text-align: left;
    background: #1e1e2e;
    padding: 16px;
    border-radius: 12px;
    margin: 16px 0;
}

.profile-info-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #3a3a4a;
}

.profile-info-label {
    color: #aaa;
}

.profile-info-value {
    color: #fff;
}

/* Contacts List */
.contacts-list {
    max-height: 200px;
    overflow-y: auto;
    margin: 10px 0;
}

.contact-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    background: #1e1e2e;
    border-radius: 8px;
    margin: 4px 0;
}

.contact-name {
    color: #fff;
}

.add-contact-btn {
    background: #4caf50;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 4px 12px;
    cursor: pointer;
}

/* Group profile modal */
.modal.group-profile-shell {
    width: min(620px, calc(100vw - 24px));
    height: min(86vh, 780px);
}

.modal.group-profile-shell .modal-content {
    height: 100%;
    min-height: 0;
}

.modal.group-profile-shell .modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 0;
}

.user-profile-modal.group-profile-modal {
    width: min(560px, 100%);
    min-height: 0;
    justify-content: flex-start;
}

.group-profile-modal .user-profile-header {
    align-items: flex-start;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 2;
    background: #202335;
    padding: 12px 0;
    margin: -12px 0 0;
}

.group-avatar-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 10px 24px rgba(102, 126, 234, 0.28);
}

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

.group-avatar-placeholder {
    font-size: 32px;
    font-weight: bold;
    color: white;
}

.group-profile-modal .group-profile-summary {
    width: 100%;
}

.group-profile-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.edit-btn {
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 14px;
    padding: 4px 8px;
    border-radius: 8px;
}

.edit-btn:hover {
    background: #3a3a4a;
    color: #fff;
}

.group-description-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.group-description-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.group-description-header .section-title {
    margin: 0;
}

.group-description-card {
    margin: 0;
}

.group-description-edit-btn {
    flex-shrink: 0;
}

.group-description-empty {
    color: #8ea2ff;
    cursor: pointer;
}

.group-description-empty:hover {
    border-color: rgba(102, 126, 234, 0.45);
    background: #1b1d2b;
}

.group-description-muted {
    color: #8f9bb3;
}

.group-profile-modal .group-profile-stats-grid {
    margin-top: 0;
    flex-shrink: 0;
}

.group-profile-members-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.section-title {
    font-weight: 700;
    color: #fff;
}

.group-profile-members {
    max-height: none;
    overflow-y: visible;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 0;
}

.group-profile-members .member-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 0;
    padding: 12px 14px;
    border: 1px solid #2a2d41;
    border-bottom: 1px solid #2a2d41;
    border-radius: 16px;
    background: #171724;
}

.group-profile-members .member-item:hover {
    background: #1d2030;
}

.group-profile-members .member-avatar {
    width: 40px;
    height: 40px;
}

.group-profile-member-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.member-role-badge {
    font-size: 10px;
    padding: 4px 8px;
    border-radius: 999px;
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.member-role-badge.admin {
    background: rgba(255, 152, 0, 0.18);
    color: #ffb347;
}

.member-role-badge.member {
    background: rgba(76, 175, 80, 0.18);
    color: #7edc83;
}

.member-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.member-actions button {
    padding: 4px 8px;
    font-size: 11px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.promote-admin-btn {
    background: #ff9800;
    color: white;
}

.demote-member-btn {
    background: #2196f3;
    color: white;
}

.remove-member-btn {
    background: #f44336;
    color: white;
}

.admin-actions {
    margin-top: 4px;
    text-align: center;
    position: sticky;
    bottom: 0;
    z-index: 2;
    background: #202335;
    padding: 10px 0 4px;
}

.admin-actions .primary-btn,
.admin-actions .group-add-member-btn {
    width: 100%;
    padding: 10px;
}

.group-add-member-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(102, 126, 234, 0.24);
    color: #dbe3ff;
    box-shadow: none;
}

.group-add-member-btn:hover {
    background: rgba(102, 126, 234, 0.12);
    border-color: rgba(102, 126, 234, 0.38);
    color: #fff;
}

.no-members {
    text-align: center;
    color: #aaa;
    padding: 20px;
}

@media (max-width: 640px) {
    .modal.group-profile-shell {
        height: calc(100vh - 24px);
    }

    .group-profile-title-row {
        flex-direction: column;
        align-items: stretch;
    }

    .group-profile-members .member-item {
        flex-wrap: wrap;
    }

    .group-profile-member-side {
        width: 100%;
        align-items: flex-start;
    }

    .member-actions {
        justify-content: flex-start;
    }
}

/* ─── Users List modal (dev) ─────────────────────────────────────── */
.modal.users-list-shell {
    width: min(540px, calc(100vw - 24px));
    height: min(80vh, 700px);
}

.modal.users-list-shell .modal-content {
    height: 100%;
    min-height: 0;
}

.modal.users-list-shell .modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 0;
}

.users-list-modal {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 100%;
    min-height: 0;
}

.users-list-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
}

.users-list-refresh-btn {
    background: rgba(102, 126, 234, 0.12);
    border: 1px solid rgba(102, 126, 234, 0.28);
    color: #dbe3ff;
    border-radius: 10px;
    padding: 6px 14px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.users-list-refresh-btn:hover {
    background: rgba(102, 126, 234, 0.24);
    color: #fff;
}

.users-list-count {
    font-size: 12px;
    color: #8f9bb3;
}

.users-list-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.users-list-loading,
.users-list-error,
.users-list-empty {
    text-align: center;
    color: #8f9bb3;
    padding: 20px;
    font-size: 14px;
}

.users-list-error { color: #f44336; }

.users-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 14px;
    background: #171724;
    border: 1px solid #2a2d41;
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
}

.users-list-item:hover {
    background: #1d2030;
    border-color: rgba(102, 126, 234, 0.3);
}

.users-list-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    font-size: 16px;
    flex-shrink: 0;
    overflow: hidden;
}

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

.users-list-name {
    font-weight: 500;
    color: #fff;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.users-list-fullname {
    font-size: 12px;
    color: #8f9bb3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

.users-list-you {
    color: #8f9bb3;
    font-weight: 400;
}

.users-list-status {
    font-size: 12px;
    margin-top: 2px;
}

.users-list-status.online  { color: #4caf50; }
.users-list-status.offline { color: #666; }

.users-list-id {
    font-size: 11px;
    color: #555;
    flex-shrink: 0;
}

/* Users list button in sidebar */
.users-list-btn {
    background: #3a2a4a;
    color: #c9aaff;
    border: 1px solid rgba(150, 100, 220, 0.3);
    border-radius: 20px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    transition: background 0.2s;
}

.users-list-btn:hover {
    background: #4a3a5a;
    color: #fff;
}
/* ─────────────────────────────────────────────────────────────────── */

/* User profile modal */
.user-profile-modal {
    width: min(460px, 100%);
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 6px 0;
    margin: 0 auto;
    align-self: center;
}

.user-profile-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    border-radius: 20px;
    border: 1px solid rgba(102, 126, 234, 0.22);
    background:
        radial-gradient(circle at top left, rgba(102, 126, 234, 0.22), transparent 52%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
}

.user-avatar-large {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: bold;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 10px 24px rgba(102, 126, 234, 0.28);
    overflow: hidden;
}

.user-profile-summary {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-name-large {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    color: #fff;
}

.user-status-large {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    margin-top: 4px;
}

.user-status-large.online {
    color: #4caf50;
}

.user-status-large.offline {
    color: #aaa;
}

.user-profile-bio {
    background: #171724;
    border: 1px solid #2a2d41;
    border-radius: 16px;
    padding: 12px 14px;
    color: #d3d6e6;
    line-height: 1.5;
}

.user-details-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.user-detail-card {
    background: #171724;
    border: 1px solid #2a2d41;
    border-radius: 14px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.user-detail-card span {
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #8f9bb3;
}

.user-detail-card strong {
    font-size: 13px;
    color: #fff;
    word-break: break-word;
}

.user-details {
    text-align: left;
    background: #171724;
    padding: 12px;
    border-radius: 14px;
    border: 1px solid #2a2d41;
}

.user-details div {
    padding: 6px 0;
    border-bottom: 1px solid #3a3a4a;
}

.user-details div:last-child {
    border-bottom: none;
}

/* Hidden */
.hidden {
    display: none !important;
}

/* Левая панель (чаты) - фиксированная ширина */
.sidebar {
    width: 320px;
    background: #2a2a3a;
    border-right: 1px solid #3a3a4a;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

/* Обертка для чата и правой панели - занимает оставшееся место */
.chat-wrapper {
    display: flex;
    flex: 1;
    min-width: 0;
    background: #1e1e2e;
}

/* Центральная область (чат) - растягивается */
.chat-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #1e1e2e;
}

/* Правая панель (участники) - фиксированная ширина */
.members-sidebar {
    width: 280px;
    background: #2a2a3a;
    border-left: 1px solid #3a3a4a;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}

.members-sidebar.hidden {
    display: none;
}

/* base.css - общие стили */
:root {
    --bg-primary: #1e1e2e;
    --bg-secondary: #2a2a3a;
    --bg-tertiary: #3a3a4a;
    --text-primary: #fff;
    --text-secondary: #aaa;
    --accent: #667eea;
    --accent-hover: #5a67d8;
    --danger: #f44336;
    --success: #4caf50;
    --warning: #ff9800;
    --border: #3a3a4a;
}

.theme-dark {
    --bg-primary: #1e1e2e;
    --bg-secondary: #2a2a3a;
    --bg-tertiary: #3a3a4a;
    --text-primary: #fff;
    --text-secondary: #aaa;
    --border: #3a3a4a;
}

.theme-light {
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f0f0;
    --text-primary: #333;
    --text-secondary: #666;
    --border: #e0e0e0;
}

/* Аватары */
.avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: bold;
    color: white;
    flex-shrink: 0;
}

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

.avatar-md {
    width: 40px;
    height: 40px;
    font-size: 18px;
}

.avatar-lg {
    width: 48px;
    height: 48px;
    font-size: 20px;
}

.avatar-xl {
    width: 80px;
    height: 80px;
    font-size: 32px;
}

.avatar-online {
    position: relative;
}

.avatar-online::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background: #4caf50;
    border-radius: 50%;
    border: 2px solid var(--bg-secondary);
}

/* Loader */
.loader {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: 8px;
    z-index: 2000;
    animation: fadeInOut 3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

@keyframes fadeInOut {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }

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

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

    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
}

/* Кнопки */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

/* ─────────────────────────────────────────
   Mobile navigation: data-mobile-view on body
   values: "list" | "chat" | "members"
   ───────────────────────────────────────── */

/* Back button — скрыт на десктопе */
.chat-back-btn {
    display: none;
}

@media (max-width: 768px) {
    /* На мобиле все три панели занимают 100% экрана и переключаются */
    .app-container {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        /* Учитываем нижнюю панель браузера / нотч */
        bottom: env(safe-area-inset-bottom, 0px);
        height: 100dvh;
        overflow: hidden;
    }

    .sidebar {
        position: absolute;
        inset: 0;
        width: 100%;
        min-width: unset;
        z-index: 10;
        transform: translateX(0);
        transition: transform 0.28s ease;
    }

    .chat-wrapper {
        position: absolute;
        inset: 0;
        width: 100% !important;
        z-index: 20;
        transform: translateX(100%);
        transition: transform 0.28s ease;
        display: flex;
        flex-direction: row;
    }

    .chat-area {
        width: 100% !important;
        flex-shrink: 0;
        height: 100%;
        min-height: 0;
    }

    .messages {
        min-height: 0;
    }

    .members-sidebar {
        position: absolute;
        inset: 0;
        width: 100% !important;
        z-index: 30;
        transform: translateX(100%);
        transition: transform 0.28s ease;
        overflow-y: auto;
    }
    /* Скрыть .hidden не перебить z-index */
    .members-sidebar.hidden {
        display: flex;
    }

    /* ── view = list (default) ── */
    body[data-mobile-view="list"] .sidebar,
    body:not([data-mobile-view]) .sidebar {
        transform: translateX(0);
    }
    body[data-mobile-view="list"] .chat-wrapper,
    body:not([data-mobile-view]) .chat-wrapper {
        transform: translateX(100%);
    }
    body[data-mobile-view="list"] .members-sidebar,
    body:not([data-mobile-view]) .members-sidebar {
        transform: translateX(100%);
    }

    /* ── view = chat ── */
    body[data-mobile-view="chat"] .sidebar {
        transform: translateX(-100%);
    }
    body[data-mobile-view="chat"] .chat-wrapper {
        transform: translateX(0);
    }
    body[data-mobile-view="chat"] .members-sidebar {
        transform: translateX(100%);
    }

    /* ── view = members ── */
    body[data-mobile-view="members"] .sidebar {
        transform: translateX(-100%);
    }
    body[data-mobile-view="members"] .chat-wrapper {
        transform: translateX(0);
    }
    body[data-mobile-view="members"] .members-sidebar {
        transform: translateX(0);
    }

    /* Back button — виден только на мобиле */
    .chat-back-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border: none;
        background: none;
        color: #aaa;
        font-size: 22px;
        cursor: pointer;
        border-radius: 8px;
        flex-shrink: 0;
        margin-right: 4px;
    }
    .chat-back-btn:hover {
        background: #3a3a4a;
        color: #fff;
    }
}


/* Profile Panel */
.profile-panel {
    width: min(560px, 100%);
    min-width: min(340px, 100%);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.profile-header {
    text-align: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.profile-hero-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px;
    border-radius: 24px;
    border: 1px solid rgba(102, 126, 234, 0.22);
    background:
        radial-gradient(circle at top left, rgba(102, 126, 234, 0.24), transparent 54%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
}

.profile-avatar-large {
    width: 96px;
    height: 96px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    overflow: hidden;
    justify-content: center;
    font-size: 36px;
    font-weight: bold;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 12px 28px rgba(102, 126, 234, 0.28);
}

.profile-hero-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.profile-badge-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.profile-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.08);
    color: #dfe4f5;
}

.profile-badge.online {
    color: #75d68a;
}

.profile-badge.offline,
.profile-badge.subtle {
    color: #a9b3cc;
}

.profile-name {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.profile-username {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

.profile-status {
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    background: var(--bg-tertiary);
}

.profile-status.online {
    color: #4caf50;
}

.profile-status.offline {
    color: var(--text-secondary);
}

.profile-bio-card {
    margin-top: 4px;
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(17, 17, 28, 0.56);
    color: #d8dcef;
    line-height: 1.5;
}

.profile-highlights {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.profile-highlight-card {
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid #2a2d41;
    background: #171724;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.profile-highlight-card span {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #8f9bb3;
}

.profile-highlight-card strong {
    font-size: 14px;
    color: #fff;
    word-break: break-word;
}

.profile-section {
    padding: 16px;
    border-radius: 20px;
    border: 1px solid #25283a;
    background: #151523;
}

.profile-section-title {
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #aab4ce;
}

.profile-info {
    padding: 0;
    border-bottom: none;
}

.profile-info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
    border: 1px solid #2a2d41;
    border-radius: 16px;
    background: #1b1b29;
}

.info-item:last-child {
    border-bottom: 1px solid #2a2d41;
}

.info-label {
    width: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.info-label svg {
    flex-shrink: 0;
}

.info-value {
    flex: 1;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    word-break: break-word;
}

.profile-actions {
    display: flex;
    gap: 12px;
    margin-top: 4px;
}

.profile-actions .btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 14px;
    font-size: 14px;
    border-radius: 14px;
}

.profile-actions .btn-primary {
    background: rgba(102, 126, 234, 0.18);
    color: #e2e8ff;
}

.profile-actions .btn-primary:hover {
    background: rgba(102, 126, 234, 0.28);
}

.profile-actions .btn-danger {
    background: rgba(244, 67, 54, 0.16);
    color: #ffdede;
    border: 1px solid rgba(244, 67, 54, 0.24);
}

.profile-actions .btn-danger:hover {
    background: rgba(244, 67, 54, 0.28);
}

.profile-actions .btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #d1d5db;
}

@media (max-width: 640px) {
    .profile-hero-card,
    .user-profile-header {
        flex-direction: column;
        text-align: center;
    }

    .profile-badge-row {
        justify-content: center;
    }

    .profile-highlights,
    .profile-info-grid,
    .user-details-grid {
        grid-template-columns: 1fr;
    }

    .profile-actions {
        flex-direction: column;
    }
}

.edit-profile-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.edit-profile-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    align-items: start;
    min-width: 0;
}

.edit-profile-grid.expanded {
    grid-template-columns: 1fr;
}

.additional-settings-panel {
    background: #141424;
    border: 1px solid #232337;
    border-radius: 20px;
    padding: 18px;
    color: var(--text-primary);
    min-width: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.settings-panel-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.settings-panel-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.settings-panel-hint {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.4;
}

.settings-section-label {
    margin-top: 4px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #dbe3ff;
}

.settings-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
}

.settings-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.settings-group input,
.settings-group select {
    width: 100%;
}

.settings-toggle-btn {
    margin-top: 4px;
    width: fit-content;
    max-width: 100%;
    align-self: flex-start;
    border-radius: 12px;
}

.add-chat-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-mode-toggle {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
    padding: 6px;
    border-radius: 16px;
    background: #141424;
    border: 1px solid #232337;
    align-self: flex-start;
}

.chat-mode-toggle-btn {
    flex: 0 0 auto;
    min-width: 0;
    padding: 9px 14px;
    border: 1px solid transparent;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.chat-mode-toggle-btn:hover {
    transform: translateY(-1px);
}

.chat-mode-toggle-btn.primary-btn {
    background: linear-gradient(135deg, #667eea 0%, #7f6bff 100%);
    color: #fff;
    box-shadow: 0 10px 22px rgba(102, 126, 234, 0.24);
}

.chat-mode-toggle-btn.secondary-btn {
    background: transparent;
    color: #dbe3ff;
    border-color: rgba(255, 255, 255, 0.08);
}

.chat-mode-toggle-btn.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.06);
}

/* Edit Profile Form */
.edit-profile-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group textarea {
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

@media (max-width: 640px) {
    .chat-mode-toggle {
        width: 100%;
    }

    .chat-mode-toggle-btn {
        flex: 1 1 calc(50% - 4px);
        text-align: center;
    }

    .settings-toggle-btn {
        width: 100%;
    }
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--accent);
}

.form-group textarea {
    resize: vertical;
    font-family: inherit;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #d32f2f;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked+.toggle-slider {
    background-color: #667eea;
}

input:checked+.toggle-slider:before {
    transform: translateX(20px);
}

.profile-settings {
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* ── Avatar image (fills any round container) ─────────────────────── */
.profile-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

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

/* ── Avatar upload area (edit-profile form) ────────────────────────── */
.avatar-upload-area {
    position: relative;
    width: 96px;
    height: 96px;
    margin: 0 auto 12px;
    cursor: pointer;
    border-radius: 50%;
}

.avatar-upload-area .profile-avatar-large {
    width: 96px;
    height: 96px;
    margin: 0;
    box-shadow: none;
}

.avatar-upload-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.52);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.03em;
    opacity: 0;
    transition: opacity 0.18s;
    pointer-events: none;
}

.avatar-upload-area:hover .avatar-upload-overlay {
    opacity: 1;
}

/* ── Canvas avatar cropper ─────────────────────────────────────────── */
.crop-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.crop-modal {
    background: #2a2a3a;
    border-radius: 18px;
    padding: 24px 20px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
    max-width: 340px;
    width: 92%;
}

.crop-modal-title {
    font-size: 15px;
    font-weight: 600;
    color: #e0e0f0;
    align-self: flex-start;
}

.crop-canvas {
    border-radius: 50%;
    cursor: grab;
    display: block;
    max-width: 100%;
    touch-action: none;
}

.crop-canvas:active { cursor: grabbing; }

.crop-zoom-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    color: #888;
}

.crop-zoom-row input[type="range"] {
    flex: 1;
    accent-color: #667eea;
}

.crop-actions {
    display: flex;
    gap: 10px;
    width: 100%;
    justify-content: flex-end;
}

/* img fills for all round avatar containers */
.member-avatar img,
.users-list-avatar img,
.user-avatar-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

/* Chat avatar upload overlay */
.group-avatar-editable {
    position: relative;
}

.group-avatar-upload-overlay {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    opacity: 0;
    transition: opacity 0.18s;
    pointer-events: none;
}

.group-avatar-editable:hover .group-avatar-upload-overlay {
    opacity: 1;
}

/* ── Avatar viewer overlay ───────────────────────────────── */
.avatar-viewer-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-viewer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(6px);
}

.avatar-viewer-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    z-index: 1;
    padding: 32px 24px 24px;
}

.avatar-viewer-close {
    position: absolute;
    top: 0;
    right: -8px;
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: white;
    font-size: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.18s;
}

.avatar-viewer-close:hover {
    background: rgba(255, 255, 255, 0.28);
}

.avatar-viewer-circle {
    width: 260px;
    height: 260px;
    border-radius: 50%;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 48px rgba(0, 0, 0, 0.6);
}

.avatar-viewer-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.avatar-viewer-initial {
    font-size: 96px;
    font-weight: bold;
    color: white;
    line-height: 1;
    user-select: none;
}

.avatar-viewer-label {
    color: white;
    font-size: 18px;
    font-weight: 600;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}

.avatar-viewer-edit-btn {
    margin-top: 4px;
    padding: 8px 24px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s;
}

.avatar-viewer-edit-btn:hover {
    background: #5a6fd6;
}

/* ===================== Feedback ===================== */
.feedback-sidebar-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 12px 20px;
    background: none;
    border: none;
    border-top: 1px solid #3a3a4a;
    color: #8f9bb3;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    text-align: left;
    flex-shrink: 0;
}

.feedback-sidebar-btn:hover {
    background: #3a3a4a;
    color: #c8cfe8;
}

.feedback-sidebar-btn svg {
    flex-shrink: 0;
    opacity: 0.7;
}

/* Feedback modal form */
.feedback-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.feedback-desc {
    font-size: 14px;
    color: #9aa0b4;
    line-height: 1.5;
}

.feedback-textarea {
    width: 100%;
    min-height: 130px;
    resize: vertical;
    background: #1e1e2e;
    border: 1px solid #3a3a4a;
    border-radius: 8px;
    color: #e0e6f0;
    font-size: 14px;
    line-height: 1.6;
    padding: 10px 12px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.feedback-textarea:focus {
    outline: none;
    border-color: #667eea;
}

.feedback-char-count {
    font-size: 12px;
    color: #5a6078;
    text-align: right;
    margin-top: -8px;
}

/* Screenshot drop zone */
.feedback-screenshot-area {
    border-radius: 8px;
    overflow: hidden;
}

.feedback-screenshot-drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 18px 12px;
    border: 2px dashed #3a3a4a;
    border-radius: 8px;
    color: #6b7591;
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.feedback-screenshot-drop:hover,
.feedback-screenshot-drop.drag-over {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.06);
    color: #a0aec4;
}

.feedback-screenshot-hint {
    font-size: 11px;
    color: #4a4f6a;
}

.feedback-screenshot-preview {
    position: relative;
    display: inline-block;
    border-radius: 8px;
    overflow: hidden;
    max-height: 200px;
}

.feedback-screenshot-preview img {
    display: block;
    max-width: 100%;
    max-height: 200px;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid #3a3a4a;
}

.feedback-screenshot-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.65);
    border: none;
    color: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.feedback-screenshot-remove:hover {
    background: rgba(220, 50, 50, 0.8);
}
