
/* UI roots used for lightweight patching (keep layout identical to old structure) */
#toast-root,
#modal-root,
#mobile-drawer-root,
#sidebar-root,
#incoming-call-root,
#call-overlay-root {
  display: contents;
}
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --brand-dark: #0f172a;
    --brand-light: #1e293b;
    --brand-accent: #22d3ee;
    --brand-purple: #a855f7;
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;
    --slate-950: #020617;
}

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--brand-dark);
    color: white;
    overflow: hidden;
}

/* Better mobile viewport handling (address bar / safe areas) */
body {
    min-height: 100dvh;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-slow {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.3; }
}

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

.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

.animate-pulse-slow {
    animation: pulse-slow 3s ease-in-out infinite;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Auth Screen */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    position: relative;
    overflow: hidden;
}

.auth-bg-blob {
    position: absolute;
    top: -20%;
    left: -10%;
    width: 600px;
    height: 600px;
    background: rgba(34, 211, 238, 0.1);
    border-radius: 50%;
    filter: blur(120px);
    animation: pulse-slow 3s ease-in-out infinite;
}

.auth-card {
    width: 100%;
    max-width: 28rem;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(40px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    position: relative;
    z-index: 10;
    animation: fadeIn 0.3s ease-out;
}

.auth-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
}

.logo-icon {
    width: 3rem;
    height: 3rem;
    border-radius: 0.75rem;
    background: linear-gradient(135deg, var(--brand-accent), var(--brand-purple));
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 1.25rem;
    box-shadow: 0 10px 15px -3px rgba(34, 211, 238, 0.2);
}

.auth-title {
    font-size: 1.5rem;
    font-weight: bold;
    letter-spacing: -0.025em;
}

.auth-tabs {
    display: flex;
    padding: 0.25rem;
    background: rgba(15, 23, 42, 0.5);
    border-radius: 0.75rem;
    margin-bottom: 2rem;
}

.auth-tab {
    flex: 1;
    padding: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.5rem;
    background: transparent;
    border: none;
    color: var(--slate-500);
    cursor: pointer;
    transition: all 0.2s;
}

.auth-tab.active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-input {
    width: 100%;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    color: white;
    font-size: 1rem;
    outline: none;
    transition: all 0.2s;
}

.form-input:focus {
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.1);
}

.form-input::placeholder {
    color: var(--slate-500);
}

.btn-primary {
    width: 100%;
    background: var(--brand-accent);
    color: var(--slate-900);
    font-weight: bold;
    padding: 0.75rem;
    border-radius: 0.75rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(34, 211, 238, 0.3);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--brand-purple);
    color: white;
    padding: 10px 12px;
    border-radius: 12px;    
}

.error-message {
    margin-bottom: 1rem;
    color: #fca5a5;
    font-size: 0.875rem;
    background: rgba(220, 38, 38, 0.2);
    padding: 0.5rem;
    border-radius: 0.5rem;
}

.info-text {
    color: white;
    font-size: 0.875rem;
    text-align: center;
    margin-bottom: 1rem;
}

/* Register step 2: backend message + copyable /reg command */
.reg-instructions {
    margin: 0.75rem 0 1rem;
    padding: 0.85rem 0.85rem 0.75rem;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.9rem;
}

.reg-message {
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.85rem;
    line-height: 1.35;
    white-space: pre-wrap;
    text-align: left;
    margin-bottom: 0.7rem;
}

.reg-command-input {
    background: rgba(2, 6, 23, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.9rem;
    letter-spacing: 0.02em;
}

.reg-command-input:hover {
    background: rgba(2, 6, 23, 0.68);
}

.reg-command-input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.18);
}

.reg-command-hint {
    margin-top: 0.45rem;
    font-size: 0.75rem;
    color: rgba(226, 232, 240, 0.78);
    text-align: center;
}

/* Main App Layout */
.app-container {
    display: flex;
    height: 100dvh;
    width: 100%;
    background: var(--brand-dark);
    overflow: hidden;
    animation: fadeIn 0.3s ease-out;
}

@media (max-width: 768px) {
    /* Mobile layout: full width app, navigation via left drawer */
    .sidebar { display: none !important; }

    .main-content {
        padding-bottom: 0;
    }

    .messenger-container {
        border-radius: 0;
    }

    .chat-list-panel,
    .chat-area {
        border-radius: 0;
        width: 100%;
    }

    .message-content { max-width: 100%; }

    .mobile-menu-btn { display: inline-flex; }

    .chat-list-header,
    .chat-header {
        padding: 0 1rem;
    }

    .messages-container {
        padding: 1rem;
    }

    .message-input-area {
        padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
    }
}

/* Sidebar */
.sidebar {
    width: 4rem;
    background: rgba(30, 41, 59, 0.3);
    backdrop-filter: blur(40px);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 0;
    z-index: 30;
    justify-content: space-between;
}

@media (min-width: 768px) {
    .sidebar {
        width: 5rem;
    }
}

.sidebar-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    width: 100%;
}

.sidebar-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: 100%;
    padding-bottom: 1rem;
}

.sidebar-logo {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    background: linear-gradient(135deg, var(--brand-accent), var(--brand-purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    box-shadow: 0 10px 15px -3px rgba(34, 211, 238, 0.2);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    padding: 0 0.5rem;
}

.nav-button {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--brand-accent);
    color: var(--slate-900);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-button:hover {
    transform: translateY(-2px);
}

.avatar-button {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: var(--slate-700);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
}

.avatar-button:hover {
    background: var(--slate-600);
}

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

.admin-button {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.admin-button:hover {
    background: rgba(239, 68, 68, 0.3);
}

.logout-button {
    color: var(--slate-500);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    transition: color 0.2s;
}

.logout-button:hover {
    color: #f87171;
}

/* Main Content */
.main-content {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.bg-decoration {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.bg-blob {
    position: absolute;
    top: -10%;
    right: -5%;
    width: 500px;
    height: 500px;
    background: rgba(34, 211, 238, 0.05);
    border-radius: 50%;
    filter: blur(100px);
}

/* Messenger Layout */
.messenger-container {
    display: flex;
    height: 100%;
    position: relative;
    z-index: 1;
}

.chat-list-panel {
    width: 100%;
    max-width: 24rem;
    background: rgba(30, 41, 59, 0.3);
    backdrop-filter: blur(40px);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
}

@media (max-width: 768px) {
    .chat-list-panel {
        max-width: 100%;
    }
    
    .chat-list-panel.hidden {
        display: none;
    }
}

.chat-list-header {
    height: 4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-list-title {
    font-size: 1.25rem;
    font-weight: bold;
    letter-spacing: -0.025em;
    text-align: center;
    padding: 5px 5px 15px 5px;
    margin: 15px 0px;
    border-bottom: 1px solid #ffffff;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.icon-button {
    padding: 0.5rem;
    border-radius: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    transition: background 0.2s;
    
    /* ✅ Для мобильных */
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Mobile drawer hamburger button (shown only on small screens) */
.mobile-menu-btn{display:none;}

.icon-button:hover {
    background: var(--bg-secondary);
}

.icon-button:active {
    transform: scale(0.95);
}

@media (max-width: 768px) {
    .chat-header-actions {
        gap: 0.25rem;
    }
    
    .icon-button {
        min-width: 36px;
        min-height: 36px;
        padding: 0.375rem;
    }
    
    /* ✅ Иконки чуть меньше на мобильном */
    .icon-button svg {
        width: 18px;
        height: 18px;
    }
}

.search-box {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.search-input-wrapper {
    position: relative;
}

.search-input {
    width: 100%;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    color: white;
    font-size: 0.875rem;
    outline: none;
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--slate-500);
}

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

.chat-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    transition: background 0.2s;
    border-left: 3px solid transparent;
}

.chat-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.chat-item.active {
    background: rgba(34, 211, 238, 0.1);
    border-left-color: var(--brand-accent);
}

.chat-avatar {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-accent), var(--brand-purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.125rem;
    flex-shrink: 0;
}

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

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

.chat-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.chat-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-time {
    font-size: 0.75rem;
    color: var(--slate-400);
}

.chat-preview {
    font-size: 0.875rem;
    color: var(--slate-400);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-badge {
    min-width: 1.25rem;
    height: 1.25rem;
    border-radius: 0.625rem;
    background: var(--brand-accent);
    color: var(--slate-900);
    font-size: 0.75rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.375rem;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--slate-950);
}

@media (max-width: 768px) {
    .chat-area.hidden {
        display: none;
    }
}

.chat-header {
    height: 4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    background: rgba(30, 41, 59, 0.5);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-header-avatar {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-accent), var(--brand-purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.chat-header-details {
    display: flex;
    flex-direction: column;
}

.chat-header-name {
    font-weight: 600;
}

.chat-header-status {
    font-size: 0.75rem;
    color: var(--slate-400);
}

.chat-header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0; /* important for virtual list spacer accuracy */
}

.vlist-spacer {
    flex: 0 0 auto;
    width: 100%;
    margin: 0;
    padding: 0;
}

.older-loading {
    position: sticky;
    top: 0;
    z-index: 3;
    display: flex;
    gap: .5rem;
    align-items: center;
    justify-content: center;
    padding: .5rem 0;
    font-size: 12px;
    color: var(--slate-400);
    background: rgba(2, 6, 23, .55);
    backdrop-filter: blur(8px);
    border-radius: 10px;
    margin-bottom: .75rem;
}

.message {
    display: flex;
    gap: 0.75rem;
    animation: fadeIn 0.2s ease-out;
    margin-bottom: 1rem;
}

.messages-container .message:last-child {
    margin-bottom: 0;
}

.message:last-child {
    margin-bottom: 0;
}

.message.own {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-accent), var(--brand-purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.message-content {
    max-width: 70%;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

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

.message-sender {
    font-size: 0.75rem;
    color: var(--brand-accent);
    font-weight: 600;
}

.message.own .message-sender {
    color: var(--brand-purple);
}

.message-bubble {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    word-wrap: break-word;
}

.message.own .message-bubble {
    background: linear-gradient(135deg, var(--brand-accent), var(--brand-purple));
    color: white;
}

.message-time {
    font-size: 0.75rem;
    color: var(--slate-500);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.message-status {
    width: 1rem;
    height: 1rem;
}

/* Message Input */
.message-input-area {
    padding: 1rem 1.5rem;
    background: rgba(30, 41, 59, 0.5);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.message-input-wrapper {
    flex-wrap: wrap;
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.message-input-actions {
    display: flex;
    gap: 0.5rem;
}

.message-input {
    flex: 1;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
    padding: 0.35rem 0.5rem;
    color: white;
    font-size: 1rem;
    outline: none;
    resize: none;
    min-height: 2.5rem;
    max-height: 8rem;
}

.send-button {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    background: var(--brand-accent);
    border: none;
    color: var(--slate-900);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.send-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(34, 211, 238, 0.3);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(20px);
    animation: fadeIn 0.3s ease-out;
    padding: 1.5rem;
}

.modal-content {
    width: 100%;
    max-width: 60rem;
    max-height: 90vh;
    background: var(--slate-900);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1.5rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 100px -20px rgba(34, 211, 238, 0.1);
}

.modal-header {
    height: 4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(15, 23, 42, 0.5);
}

.modal-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.modal-icon {
    padding: 0.5rem;
    background: rgba(34, 211, 238, 0.1);
    color: var(--brand-accent);
    border-radius: 0.5rem;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    color: var(--slate-400);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-textarea {
    width: 100%;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    color: white;
    font-size: 1rem;
    outline: none;
    resize: vertical;
    min-height: 6rem;
}

.user-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.user-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.user-item.selected {
    background: rgba(34, 211, 238, 0.1);
    border-color: var(--brand-accent);
}

.user-avatar {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-accent), var(--brand-purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.875rem;
}

.user-info {
    flex: 1;
}

.user-name {
    font-weight: 600;
}

.user-status {
    font-size: 0.75rem;
    color: var(--slate-400);
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--slate-500);
    padding: 2rem;
    text-align: center;
}

.empty-state-icon {
    width: 4rem;
    height: 4rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: var(--slate-400);
}

.empty-state-text {
    font-size: 0.875rem;
}

/* Loading */
.loading-spinner {
    display: inline-block;
    width: 1.5rem;
    height: 1.5rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--brand-accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

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

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

.back-button {
    display: none;
}

@media (max-width: 768px) {
    .back-button {
        display: flex;
    }
}

/* Stickers Grid */
.stickers-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    padding: 1rem 0;
}

.sticker-item {
    aspect-ratio: 1;
    cursor: pointer;
    border-radius: 0.5rem;
    transition: all 0.2s;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}

.sticker-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

/* Admin Dashboard */
.admin-container {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(40px);
    animation: fadeIn 0.3s ease-out;
    padding: 1.5rem;
}

.admin-content {
    width: 100%;
    max-width: 80rem;
    height: 80vh;
    background: var(--slate-900);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1.5rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.admin-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.admin-sidebar {
    width: 16rem;
    background: var(--slate-900);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.admin-tab {
    width: 100%;
    text-align: left;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    font-weight: 500;
    background: transparent;
    border: none;
    color: var(--slate-400);
    cursor: pointer;
    transition: all 0.2s;
}

.admin-tab:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.admin-tab.active {
    background: var(--brand-accent);
    color: var(--slate-900);
    box-shadow: 0 10px 15px -3px rgba(34, 211, 238, 0.2);
}

.admin-main {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    background: rgba(2, 6, 23, 0.5);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: rgba(255, 255, 255, 0.05);
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-label {
    color: var(--slate-400);
    font-size: 0.875rem;
    font-weight: bold;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: white;
}

.activity-chart {
    background: rgba(255, 255, 255, 0.05);
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: 1rem;
}

.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    height: 10rem;
}

.chart-bar {
    flex: 1;
    background: linear-gradient(to top, rgba(34, 211, 238, 0.2), var(--brand-accent));
    border-radius: 0.5rem 0.5rem 0 0;
    transition: opacity 0.2s;
    cursor: pointer;
}

.chart-bar:hover {
    opacity: 0.8;
}

/* File input hidden */
.file-input {
    display: none;
}

/* Chat type icon */
.chat-type-icon {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 4px;
    opacity: 0.6;
    vertical-align: middle;
}

.chat-type-icon svg {
    width: 14px;
    height: 14px;
}

/* Calls (Telemost) */
.call-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ============================================
   АУДИО ЗВОНОК
   ============================================ */

   .call-audio {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Градиентный фон */
.call-audio-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, 
        #667eea 0%, 
        #764ba2 50%, 
        #f093fb 100%
    );
    animation: gradient-shift 10s ease infinite;
    background-size: 200% 200%;
}

@keyframes gradient-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Контент */
.call-audio-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    padding: 2rem;
    max-width: 500px;
    width: 100%;
}

/* Аватар */
.call-audio-avatar {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: 6px solid rgba(255, 255, 255, 0.3);
    animation: pulse-ring 2s ease-in-out infinite;
}

@keyframes pulse-ring {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 25px 70px rgba(0, 0, 0, 0.4);
    }
}

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

.call-avatar-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    color: white;
    font-size: 4rem;
    font-weight: 700;
    text-transform: uppercase;
}

/* Имя и статус */
.call-audio-name {
    font-size: 2rem;
    font-weight: 700;
    color: white;
    text-align: center;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    margin-top: 1rem;
}

.call-audio-status {
    font-size: 1.25rem;
    color: rgba(255, 255, 255, 0.9);
    text-align: center;
}

/* Кнопки управления */
.call-audio-controls {
    display: flex;
    gap: 2rem;
    margin-top: 2rem;
}

.call-control-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    background: rgba(255, 255, 255, 0.2);
    color: white;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

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

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

/* Кнопка завершения */
.call-end-btn {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
}

.call-end-btn:hover {
    background: linear-gradient(135deg, #f87171 0%, #ef4444 100%) !important;
}

/* Muted состояние */
.call-control-btn.muted {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.call-control-btn svg {
    width: 28px;
    height: 28px;
}

.call-video-stage {
    background: #000;
    position: relative;
    width: 100%;
    height: 100%;
}

/* Удаленное видео (собеседник) */
.call-video-remote {
    position: absolute;
    background: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
}

.call-video-remote.fullscreen {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

.call-video-remote.pip {
    top: 20px;
    right: 20px;
    width: 180px;
    height: 240px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    border: 3px solid rgba(255, 255, 255, 0.2);
    z-index: 3;
    cursor: pointer;
    transition: all 0.3s ease;
}

.call-video-remote.pip:hover {
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 0.4);
}

/* Локальное видео (я) */
.call-video-local {
    position: absolute;
    background: #2a2a2a;
}

.call-video-local.fullscreen {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

.call-video-local.pip {
    top: 20px;
    right: 20px;
    width: 180px;
    height: 240px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    border: 3px solid rgba(255, 255, 255, 0.2);
    z-index: 3;
    cursor: pointer;
    transition: all 0.3s ease;
}

.call-video-local.pip:hover {
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 0.4);
}

/*
  Видео элементы
  - В PiP оставляем cover (заполняет маленькое окно без пустых полей).
  - В fullscreen делаем contain, чтобы на больших экранах картинка не "растягивалась/увеличивалась" и сохраняла пропорции.
*/
.call-video-remote video,
.call-video-local video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@media (min-width: 900px) {
    .call-video-remote.fullscreen video,
    .call-video-local.fullscreen video {
        object-fit: contain;
        background: #000;
    }
}

/* Placeholder для видео */
.call-video-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 2rem;
    text-align: center;
    color: #888;
}

.call-placeholder-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 1rem;
}

.call-placeholder-initials {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    color: white;
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.call-placeholder-name {
    font-size: 1.5rem;
    font-weight: 600;
    color: #fff;
}

.call-placeholder-status {
    font-size: 1rem;
    color: #888;
}

/* Панель управления видео */
.call-video-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 5;
    padding: 2rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
}

/* ============================================
   АДАПТАЦИЯ ДЛЯ МОБИЛЬНЫХ
   ============================================ */

@media (max-width: 768px) {
    /* Аудио */
    .call-audio-avatar {
        width: 160px;
        height: 160px;
    }
    
    .call-audio-name {
        font-size: 1.5rem;
    }
    
    .call-audio-status {
        font-size: 1rem;
    }
    
    .call-control-btn {
        width: 56px;
        height: 56px;
    }
    
    .call-control-btn svg {
        width: 24px;
        height: 24px;
    }
    
    .call-audio-controls {
        gap: 1.5rem;
    }
    
    /* Видео */
    .call-video-local.pip,
    .call-video-remote.pip {
        width: 120px;
        height: 160px;
        top: 10px;
        right: 10px;
    }
    
    .call-video-controls {
        padding: 1.5rem 1rem;
        gap: 1rem;
    }
}

/* Landscape на мобильном */
@media (max-width: 768px) and (orientation: landscape) {
    .call-audio-content {
        flex-direction: row;
        max-width: 100%;
    }
    
    .call-audio-avatar {
        width: 120px;
        height: 120px;
    }
    
    .call-audio-name {
        font-size: 1.25rem;
    }
}

/* ============================================
   АНИМАЦИИ
   ============================================ */

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

.call-overlay {
    animation: fadeIn 0.3s ease-out;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

.call-control-btn:focus {
    outline: 3px solid rgba(59, 130, 246, 0.5);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .call-overlay,
    .call-audio-bg,
    .call-audio-avatar,
    .call-control-btn,
    .call-video-local,
    .call-video-remote {
        animation: none;
        transition: none;
    }
}


.call-panel{
  width:min(520px, 100%);
  height:min(420px, 100%);
  background:#0b1220;
  border:1px solid rgba(255,255,255,0.08);
  border-radius:16px;
  overflow:hidden;
  box-shadow:0 16px 40px rgba(0,0,0,0.35);
}
.call-panel-header{
  display:flex; align-items:center; justify-content:space-between;
  padding:10px 12px;
  background:rgba(255,255,255,0.04);
}
.call-panel-title{
  font-weight:800;
  color:#e5e7eb;
}
.call-panel-actions{
  display:flex; gap:8px; align-items:center;
}
.call-btn{
  background:#ef4444;
  color:#fff;
  border:none;
  border-radius:10px;
  padding:8px 12px;
  cursor:pointer;
  font-weight:700;
}
.call-btn:hover{ filter:brightness(1.05); }
.call-iframe{
  width:100%;
  height:calc(100% - 48px);
  border:0;
  background:#000;
}

.call-incoming-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000; /* ✅ КРИТИЧНО: Очень высокий z-index */
    padding: 1rem;
    
    /* ✅ Для iOS Safari */
    -webkit-overflow-scrolling: touch;
}

.call-incoming-card {
    background: var(--bg-primary, #1a1a1a);
    border-radius: 16px;
    padding: 2rem;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease-out;
    
    /* ✅ Для мобильных */
    margin: auto;
}

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

.call-incoming-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary, #ffffff);
    text-align: center;
}

.call-incoming-sub {
    font-size: 1rem;
    color: var(--text-secondary, #a0a0a0);
    margin-bottom: 2rem;
    text-align: center;
}

.call-incoming-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.call-incoming-actions .btn {
    flex: 1;
    padding: 1rem;
    font-size: 1rem;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    
    /* ✅ Для мобильных - увеличить область нажатия */
    min-height: 48px;
    min-width: 100px;
}

.call-incoming-actions .btn-secondary {
    background: var(--red-500, #ef4444);
    color: white;
}

.call-incoming-actions .btn-primary {
    background: var(--green-500, #10b981);
    color: white;
}

.call-incoming-actions .btn:active {
    transform: scale(0.95);
}

/* ✅ Мобильная адаптация */
@media (max-width: 768px) {
    .call-incoming-card {
        max-width: 90%;
        padding: 1.5rem;
    }
    
    .call-incoming-title {
        font-size: 1.25rem;
    }
    
    .call-incoming-actions {
        flex-direction: column;
    }
    
    .call-incoming-actions .btn {
        width: 100%;
        min-height: 56px; /* ✅ Больше для пальца */
    }
}


/* ===== Message actions & reactions (Stage 1) ===== */
.message-time {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.message-time-left {
  display: flex;
  align-items: center;
  gap: 6px;
}
.message-time-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Optimistic upload progress (attachments / recordings) */
.upload-progress {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(148,163,184,.25);
  background: rgba(2,6,23,.25);
}
.upload-progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.upload-progress-text {
  font-size: 12px;
  color: var(--slate-200);
  opacity: .92;
}
.upload-cancel {
  background: rgba(148,163,184,.12);
  border: 1px solid rgba(148,163,184,.25);
  color: var(--slate-100);
  border-radius: 999px;
  width: 24px;
  height: 24px;
  cursor: pointer;
  line-height: 1;
}
.upload-cancel:hover {
  background: rgba(148,163,184,.18);
}
.upload-progress-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(148,163,184,.16);
  overflow: hidden;
}
.upload-progress-bar {
  height: 100%;
  width: 0%;
  background: rgba(96,165,250,.95);
}

.upload-failed {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(248,113,113,.35);
  background: rgba(127,29,29,.18);
}
.upload-failed-text {
  font-size: 12px;
  color: rgba(254,226,226,.95);
  margin-bottom: 6px;
}
.upload-failed-actions {
  display: flex;
  gap: 8px;
}
.message-edited {
  font-size: 10px;
  color: var(--slate-400);
  margin-left: 4px;
}
.msg-action {
  padding: 2px 6px;
  font-size: 14px;
}
.msg-more {
  font-size: 18px;
  line-height: 1;
}

.reactions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.reaction-pill {
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.9);
  border-radius: 999px;
  padding: 4px 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.reaction-pill:hover {
  background: rgba(255,255,255,0.10);
}
.reaction-pill.mine {
  border-color: rgba(59,130,246,0.35);
  background: rgba(59,130,246,0.14);
}
.reaction-count {
  font-weight: 600;
  opacity: 0.9;
}

.reaction-picker {
  position: fixed;
  z-index: 9999;
  background: var(--brand-light);
  border-radius: 12px;
  padding: 10px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.35);
  display: flex;
  gap: 8px;
  border: 1px solid rgba(255,255,255,0.10);
}
.reaction-picker-btn {
  font-size: 22px;
  border: none;
  background: rgba(255,255,255,0.06);
  cursor: pointer;
  padding: 8px;
  border-radius: 10px;
  transition: transform .12s ease, background .12s ease;
}
.reaction-picker-btn:hover {
  background: rgba(255,255,255,0.12);
  transform: scale(1.12);
}

.ctx-menu {
  position: fixed;
  z-index: 10000;
  min-width: 200px;
  background: rgba(17,24,39,0.96);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.45);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ctx-menu-item {
  width: 100%;
  text-align: left;
  padding: 10px 10px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  background: transparent;
  color: rgba(255,255,255,0.92);
  font-size: 14px;
}
.ctx-menu-item:hover {
  background: rgba(255,255,255,0.08);
}
.ctx-menu-item.danger {
  color: #f87171;
}
.ctx-menu-item.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.ctx-menu-item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.edit-preview {
  background: rgba(234,179,8,0.10);
  padding: 12px;
  border-left: 3px solid rgba(234,179,8,0.9);
  margin: 0 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.edit-preview-title {
  font-size: 12px;
  color: rgba(234,179,8,0.9);
  margin-bottom: 4px;
}
.edit-preview-text {
  font-size: 14px;
  color: rgba(255,255,255,0.9);
  max-width: 520px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.forward-modal {
  max-width: 560px;
}
.forward-preview {
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
  border-radius: 12px;
  padding: 12px;
}
.forward-preview-title {
  font-size: 12px;
  color: var(--slate-400);
  margin-bottom: 6px;
}
.forward-preview-text {
  font-size: 14px;
  color: rgba(255,255,255,0.92);
  max-height: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.forward-list {
  margin-top: 12px;
  max-height: 360px;
  overflow: auto;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
}
.forward-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
}
.forward-item:hover {
  background: rgba(255,255,255,0.06);
}
.forward-avatar {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(59,130,246,0.14);
  color: rgba(255,255,255,0.9);
  font-weight: 700;
}
.forward-name {
  font-size: 14px;
  color: rgba(255,255,255,0.92);
}


/* ===== Profile / Avatars / Media gallery ===== */
.profile-avatar-section{
    display:flex;
    gap:12px;
    align-items:center;
    margin-bottom:12px;
}
.profile-avatar-preview,
.chat-profile-avatar{
    width:72px;
    height:72px;
    border-radius:18px;
    overflow:hidden;
    background:rgba(255,255,255,0.06);
    display:flex;
    align-items:center;
    justify-content:center;
}
.avatar-preview-img{
    width:100%;
    height:100%;
    object-fit:cover;
    display:block;
}
.avatar-preview-placeholder{
    width:100%;
    height:100%;
    display:flex;
    align-items:center;
    justify-content:center;
    font-weight:800;
    letter-spacing:0.5px;
    opacity:0.9;
}
.profile-avatar-actions{
    display:flex;
    gap:10px;
    align-items:center;
    flex-wrap:wrap;
}
.section-title{
    margin:10px 0 8px;
    font-size:13px;
    opacity:0.75;
}
.hint-muted{
    font-size:13px;
    opacity:0.72;
    margin:8px 0 12px;
}
.avatar-grid{
    display:grid;
    grid-template-columns:repeat(auto-fill, minmax(56px, 1fr));
    gap:10px;
    margin:10px 0 18px;
}
.avatar-tile{
    border:1px solid rgba(255,255,255,0.12);
    background:transparent;
    padding:0;
    border-radius:14px;
    overflow:hidden;
    cursor:pointer;
}
.avatar-tile:disabled{
    cursor:not-allowed;
    opacity:0.45;
}
.avatar-tile.active{
    outline:2px solid rgba(255,255,255,0.28);
}
.avatar-tile img{
    width:100%;
    height:56px;
    object-fit:cover;
    display:block;
}

.modal-wide{
    max-width:720px;
}

.chat-profile-top{
    display:flex;
    gap:12px;
    align-items:center;
    margin-bottom:10px;
}
.chat-profile-meta{
    display:flex;
    flex-direction:column;
}
.chat-profile-title{
    font-size:18px;
    font-weight:800;
}
.chat-profile-sub{
    font-size:13px;
    opacity:0.75;
    margin-top:2px;
}

.tabs{
    display:flex;
    gap:8px;
    margin:12px 0;
}
.tab{
    padding:8px 12px;
    border-radius:12px;
    border:1px solid rgba(255,255,255,0.12);
    background:transparent;
    cursor:pointer;
    font-weight:600;
}
.tab.active{
    background:rgba(255,255,255,0.08);
}

.row-actions{
    display:flex;
    gap:8px;
    align-items:center;
    flex-wrap:wrap;
    margin-bottom:10px;
}

.chip{
    padding:7px 12px;
    border-radius:999px;
    border:1px solid rgba(255,255,255,0.12);
    background:transparent;
    cursor:pointer;
    font-weight:600;
}
.chip.active{
    background:rgba(255,255,255,0.08);
}

.media-grid{
    display:grid;
    grid-template-columns:repeat(auto-fill, minmax(140px, 1fr));
    gap:10px;
}
.media-item{
    border-radius:16px;
    overflow:hidden;
    border:1px solid rgba(255,255,255,0.12);
    background:rgba(255,255,255,0.04);
}
.media-item img,
.media-item video{
    width:100%;
    height:140px;
    object-fit:cover;
    display:block;
}


/* === Chat enhancements: avatars + menu + record UI === */
.chat-avatar img.avatar-img,
.chat-header-avatar img.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}
.chat-header-name-click { cursor: pointer; }
.chat-header-name-click:hover { text-decoration: underline; }

#record-btn.recording { color: #ef4444; }

/* Recording UX (voice/video notes) */
.message-input-wrapper.recording-active textarea.message-input{
  display:none;
}
.message-input-wrapper.recording-active .send-button{
  display:none;
}
.message-input-wrapper.recording-active .icon-button.record-start{
  color:#ef4444;
}

.record-gesture-area{
  flex:1 1 100%;
  width:100%;
  margin:8px 0 0 0;
  padding:10px;
  border-radius:14px;
  border:1px solid rgba(148,163,184,.22);
  background:rgba(15,23,42,.35);
  display:flex;
  flex-direction:column;
  gap:8px;
}

.voice-note-recording{
  display:flex;
  align-items:center;
  gap:10px;
}
.voice-note-recording .vn-rec{
  width:36px;height:36px;
  border-radius:999px;
  border:1px solid rgba(239,68,68,.35);
  background:rgba(239,68,68,.14);
  color:#fff;
  cursor:default;
}

.video-note-recording{
  display:flex;
  align-items:center;
  gap:10px;
}
.video-note-recording .record-preview-video{
  width:110px;
  height:110px;
  border-radius:14px;
  background:#000;
  object-fit:cover;
}
.video-note-recording .video-note-timer{
  font-size:13px;
  color:#e2e8f0;
  opacity:.95;
  min-width:72px;
}

.record-hints{
  display:flex;
  justify-content:space-between;
  gap:10px;
  font-size:12px;
  color:#94a3b8;
}

.record-draft{
  display:flex;
  flex-direction:column;
  align-items:stretch;
  gap:10px;
  padding:10px;
  margin:8px 0 0 0;
  border-radius:14px;
  border:1px solid rgba(59,130,246,.22);
  background:rgba(59,130,246,.08);
}
.record-draft-top{display:flex;align-items:center;gap:10px;min-width:0;}
.record-draft-preview-wrap{flex:1;min-width:0;display:flex;justify-content:flex-end;}
.record-draft-bottom{display:flex;align-items:center;gap:8px;}
.record-draft-actions{display:flex;gap:8px;justify-content:flex-end;}
.record-draft-left{display:flex;flex-direction:column;gap:2px;min-width:0;}
.record-draft-title{font-weight:600;}
.record-draft-sub{font-size:12px;opacity:.8;}
.record-draft .local-draft-voice{min-width:180px;}
.btn-small { padding: 7px 10px !important; border-radius: 10px !important; font-size: 12px !important; }
.reply-preview-inline { margin: 8px 0 0 0; }
.media-grid .media-item { border: 0; background: transparent; padding: 0; }
.avatar-preview-button { border: 0; background: transparent; padding: 0; cursor: pointer; }


/* Media draft preview (file before send) */
.media-draft {
  display:flex;
  flex-direction:column;
  gap:8px;
  padding:8px;
  border:1px solid rgba(255,255,255,0.10);
  border-radius:12px;
  margin:6px 0;
  background: rgba(255,255,255,0.03);
}
.media-draft-preview { display:flex; justify-content:flex-start; }
.media-draft-img { max-height:160px; border-radius:10px; }
.media-draft-video { max-height:180px; border-radius:10px; }
.media-draft-caption { width:100%; padding:10px 12px; border-radius:10px; border:1px solid rgba(255,255,255,0.10); background: rgba(0,0,0,0.15); color: inherit; }
.media-draft-actions { display:flex; gap:8px; justify-content:flex-end; }
.media-draft-doc { display:flex; gap:10px; align-items:center; }
.media-draft-doc-ico { opacity:0.9; }
.media-draft-doc-name { font-size:14px; }
.media-draft-doc-ext { opacity:0.7; font-size:12px; }

.record-draft-caption{flex:1; min-width:120px; padding:8px 10px; border-radius:10px; border:1px solid rgba(255,255,255,0.10); background: rgba(0,0,0,0.15); color: inherit; margin:0;}

@media (max-width: 768px){
  .record-draft-preview-wrap{justify-content:flex-start;}
  .record-draft-bottom{flex-direction:column;align-items:stretch;}
  .record-draft-actions{justify-content:flex-end;}
}

.avatar-tile-wrap{position:relative; display:inline-block;}
.avatar-tile-del{position:absolute; top:4px; right:4px; width:22px; height:22px; border-radius:11px; border:0; background:rgba(0,0,0,0.55); color:#fff; cursor:pointer; line-height:22px; text-align:center; font-size:14px;}
.avatar-tile-del:hover{background:rgba(0,0,0,0.75);}


/* Calls (Agora) */
.agora-stage{
  display:flex;
  gap:10px;
  padding:10px;
  height:calc(100% - 48px - 34px);
}
.agora-local, .agora-remote{
  flex:1;
  display:flex;
  flex-direction:column;
  gap:6px;
  min-width:0;
}
.agora-tile-title{
  font-size:12px;
  color:#94a3b8;
  padding:0 2px;
}
.agora-player{
  flex:1;
  width:100%;
  min-height:140px;
  background:#000;
  border-radius:12px;
  overflow:hidden;
  position:relative;
}
.agora-remote-grid{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  width:100%;
  height:100%;
}
.agora-remote-grid .agora-player{
  flex:1 1 100%;
  min-height:140px;
}
.agora-audio-placeholder{
  position:absolute; inset:0;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  color:#e5e7eb;
  opacity:0.95;
}
.agora-audio-placeholder svg{
  width:44px; height:44px;
  opacity:0.75;
}
.agora-hint{
  padding:0 12px 12px 12px;
  font-size:12px;
  color:#94a3b8;
}

@media (max-width: 520px){
  .call-panel{ width:100%; height:80vh; }
  .agora-stage{ flex-direction:column; height:calc(100% - 48px - 34px); }
}



/* ============================
   Incoming call avatar sizing
   ============================ */
.call-incoming-avatar{
    width:96px;
    height:96px;
    margin: 0 auto 14px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid rgba(255,255,255,0.15);
    box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}
.call-incoming-avatar img{
    width:100%;
    height:100%;
    object-fit: cover;
    display:block;
}
@media (max-width: 768px){
    .call-incoming-avatar{ width:80px; height:80px; }
}

/* ============================
   Toast notifications
   ============================ */
.toast-container{
    position: fixed;
    top: 72px;
    right: 16px;
    z-index: 12000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: min(360px, calc(100vw - 32px));
}
.toast{
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid rgba(255,255,255,0.10);
    color: #fff;
    border-radius: 14px;
    padding: 12px 14px;
    box-shadow: 0 16px 40px rgba(0,0,0,0.35);
    cursor: pointer;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    animation: toastIn 0.18s ease-out;
}
.toast:hover{ filter: brightness(1.03); }
.toast-info{ border-left: 4px solid rgba(59,130,246,0.9); }
.toast-success{ border-left: 4px solid rgba(16,185,129,0.9); }
.toast-error{ border-left: 4px solid rgba(239,68,68,0.9); }
.toast-text{ font-size: 13px; line-height: 1.35; word-break: break-word; }

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

/* ============================
   Minimized call bar
   ============================ */
.messenger-container.has-mini-call{
    padding-top: 64px;
}

.call-overlay.minimized{
    position: fixed;
    top: 0;
    left: 4rem;
    right: 0;
    bottom: auto;
    height: 64px;
    z-index: 11000;
    background: rgba(2, 6, 23, 0.92);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
}
@media (min-width: 768px){
    .call-overlay.minimized{ left: 5rem; }
}

.call-mini-left{
    display:flex;
    align-items:center;
    gap: 10px;
    min-width: 0;
    cursor: pointer;
}
.call-mini-avatar{
    width: 40px;
    height: 40px;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(255,255,255,0.10);
    flex: 0 0 auto;
    display:flex;
    align-items:center;
    justify-content:center;
}
.call-mini-avatar img{ width:100%; height:100%; object-fit: cover; display:block; }
.call-mini-avatar-ph{ font-weight:700; font-size: 14px; color:#fff; }

.call-mini-meta{ min-width:0; }
.call-mini-name{
    font-weight: 700;
    font-size: 13px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 46vw;
}
.call-mini-status{
    font-size: 12px;
    color: rgba(255,255,255,0.75);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.call-mini-actions{ display:flex; align-items:center; gap: 8px; }
.call-mini-btn{
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: none;
    background: rgba(255,255,255,0.12);
    color:#fff;
    display:flex;
    align-items:center;
    justify-content:center;
    cursor:pointer;
}
.call-mini-btn:hover{ filter: brightness(1.08); }
.call-mini-btn.muted{ background: rgba(239,68,68,0.18); }
.call-mini-btn.end{ background: rgba(239,68,68,0.85); }

/* Small minimize button on expanded overlay */
.call-overlay-minbtn{
    position: absolute;
    top: 10px;
    right: 10px;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(0,0,0,0.25);
    color: #fff;
    cursor: pointer;
    display:flex;
    align-items:center;
    justify-content:center;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.call-overlay-minbtn:hover{ filter: brightness(1.08); }



/* ============================================
   Profile Panel (Sidebar layout)
   ============================================ */
.profile-modal {
    width: min(980px, calc(100vw - 32px));
    height: min(720px, calc(100vh - 32px));
    padding: 0;
    overflow: hidden;
}

.profile-layout{
    display:flex;
    height:100%;
}

.profile-sidebar{
    width: 280px;
    background: rgba(255,255,255,0.06);
    border-right: 1px solid rgba(255,255,255,0.08);
    padding: 16px;
    display:flex;
    flex-direction:column;
    gap: 12px;
}

.profile-sidebar-top{
    text-align:center;
    padding: 10px 8px 8px;
}

.profile-side-avatar{
    width: 88px;
    height: 88px;
    margin: 0 auto 10px;
    border-radius: 22px;
    overflow:hidden;
    background: rgba(255,255,255,0.08);
    display:flex;
    align-items:center;
    justify-content:center;
}

.profile-side-name{
    font-weight: 700;
    font-size: 18px;
    line-height: 1.2;
    margin-top: 2px;
}

.profile-side-login{
    opacity: 0.75;
    margin-top: 4px;
    font-size: 13px;
}

.profile-nav{
    display:flex;
    flex-direction:column;
    gap: 8px;
    padding-top: 6px;
}

.profile-nav-item{
    display:flex;
    align-items:center;
    gap: 10px;
    width:100%;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.04);
    color: inherit;
    cursor: pointer;
}

.profile-nav-item:hover{ background: rgba(255,255,255,0.07); }

.profile-nav-item.active{
    background: rgba(99,102,241,0.18);
    border-color: rgba(99,102,241,0.35);
}

.profile-nav-ic{
    width: 22px;
    height: 22px;
    display:flex;
    align-items:center;
    justify-content:center;
    opacity: .9;
}

.profile-sidebar-bottom{
    margin-top:auto;
    padding-top: 10px;
}

.profile-main{
    flex:1;
    display:flex;
    flex-direction:column;
    min-width: 0;
}

.profile-main-header{
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.profile-main-title{
    font-weight: 700;
    font-size: 18px;
}

.profile-main-body{
    padding: 16px;
    overflow:auto;
}

.profile-section-title{
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 10px;
}

.profile-avatar-row{
    display:flex;
    gap: 14px;
    align-items:center;
}

.profile-avatar-big{
    width: 96px;
    height: 96px;
    border-radius: 24px;
    overflow:hidden;
    background: rgba(255,255,255,0.08);
    display:flex;
    align-items:center;
    justify-content:center;
}

.profile-avatar-actions2{
    flex:1;
    min-width: 0;
}

.sessions-actions{
    display:flex;
    gap: 10px;
    margin: 10px 0 12px;
    flex-wrap: wrap;
}

.sessions-list{
    display:flex;
    flex-direction:column;
    gap: 10px;
}

.session-item{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap: 12px;
    padding: 12px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.04);
}

.session-item.current{
    border-color: rgba(34,197,94,0.35);
    background: rgba(34,197,94,0.08);
}

.session-title{
    font-weight: 700;
}

.session-sub{
    opacity: 0.75;
    font-size: 12px;
    margin-top: 4px;
}

.session-badge{
    margin-left: 8px;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(34,197,94,0.18);
    border: 1px solid rgba(34,197,94,0.32);
}

.settings-block{
    padding: 12px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.04);
}

.settings-block-title{
    font-weight: 700;
    margin-bottom: 10px;
}

.toggle-row{
    display:flex;
    align-items:center;
    gap: 10px;
    user-select:none;
    margin: 8px 0 10px;
}

.form-row{
    display:flex;
    gap: 12px;
    align-items:flex-end;
    flex-wrap: wrap;
}

.btn-danger{
    background: rgba(239,68,68,0.16);
    border: 1px solid rgba(239,68,68,0.35);
    color: #fecaca;
    padding: 10px 12px;
    border-radius: 12px;
}
.btn-danger:hover{ background: rgba(239,68,68,0.22); }

.w100{ width:100%; }

@media (max-width: 720px){
    .profile-modal{ width: calc(100vw - 16px); height: calc(100vh - 16px); }
    .profile-layout{ flex-direction: column; }
    .profile-sidebar{ width:100%; flex-direction: row; align-items:center; padding: 12px; }
    .profile-sidebar-top{ display:flex; align-items:center; gap: 10px; text-align:left; padding:0; }
    .profile-side-avatar{ width: 52px; height: 52px; border-radius: 16px; margin:0; }
    .profile-nav{ flex-direction: row; gap: 8px; overflow:auto; padding:0; }
    .profile-nav-item{ padding: 10px; }
    .profile-sidebar-bottom{ margin-top:0; margin-left:auto; padding-top:0; }
}


/* Contacts/Dialogs tabs */
.list-tabs {
  display: flex;
  gap: 6px;
  margin-left: 12px;
}
.list-tab {
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.85);
  padding: 6px 10px;
  border-radius: 12px;
  font-size: 12px;
  cursor: pointer;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:2px;
  min-width: 70px;
}
.list-tab-ico{display:flex;align-items:center;justify-content:center;opacity:.95;}
.list-tab-ico svg{width:18px;height:18px;}
.list-tab-label{font-size:11px;line-height:1;opacity:.85;white-space:nowrap;}
.list-tab.active {
  background: rgba(124, 58, 237, 0.22);
  border-color: rgba(124, 58, 237, 0.55);
}

@media (max-width: 768px){
  .list-tab{min-width:auto;padding:8px 10px;}
  .list-tab-label{display:none;}
}



/* Contacts grouping subtabs */
.contacts-subtabs{
  display:flex;
  gap:0.4rem;
  padding: 0 1rem 0.7rem;
  overflow:auto;
}
.contacts-subtab{
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.85);
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
}
.contacts-subtab.active{
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(59, 130, 246, 0.55);
}

/* Contact row extras */
.contact-subrow{
  display:flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.15rem;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.65);
}
.contact-status{
  display:flex;
  align-items:center;
  gap: 0.35rem;
  min-width: 0;
}
.presence-dot{
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(148,163,184,0.6);
  flex: 0 0 auto;
}
.presence-dot.online{
  background: rgba(34,197,94,0.9);
  box-shadow: 0 0 0 3px rgba(34,197,94,0.14);
}
.contact-status-text{
  overflow:hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}
.contact-login{
  opacity: 0.85;
  white-space: nowrap;
}
.contact-actions{
  display:flex;
  align-items:center;
  gap: 0.25rem;
  margin-left: 0.5rem;
  flex: 0 0 auto;
}
.icon-button-sm{
  width: 34px;
  height: 34px;
  border-radius: 0.65rem;
}
.icon-button-sm svg{ width:18px; height:18px; }

.contact-item.is-blocked .chat-name{
  opacity: 0.75;
}

/* Contact delete button (icon) */
.contact-delete-btn {
  width: 34px;
  height: 34px;
  display:flex;
  align-items:center;
  justify-content:center;
  border: 1px solid rgba(239,68,68,0.55);
  background: rgba(239,68,68,0.10);
  color: rgba(255,255,255,0.9);
  border-radius: 0.65rem;
  cursor: pointer;
  padding: 0;
}
.contact-delete-btn svg{ width:18px; height:18px; }
.contact-delete-btn:hover {
  background: rgba(239,68,68,0.18);
}

.chat-list-header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}



/* Reply preview above composer input */
.reply-preview{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin:6px 10px 0;
  padding:8px 10px;
  border-left:3px solid var(--brand-accent, #4aa3ff);
  border-radius:10px;
  background: rgba(255,255,255,0.04);
}
.reply-preview .reply-preview-left{min-width:0;}
.reply-preview .reply-preview-title{font-size:12px;opacity:.8;margin-bottom:2px;}
.reply-preview .reply-preview-text{font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%;}
/* Recorder button near send */
.send-button + .icon-button, .message-input-wrapper .icon-button.record-start{
  margin-left:6px;
}
.message-input-wrapper .icon-button.record-start{
  width:38px;height:38px;
  border-radius:10px;
}

/* Forwarded message header */
.msg-forward{
  font-size:12px;
  opacity:.85;
  margin-bottom:6px;
  display:flex;
  gap:6px;
  align-items:center;
}
.msg-forward .tag{
  font-size:11px;
  padding:2px 6px;
  border-radius:999px;
  background: rgba(255,255,255,0.08);
}



/* ============================================
   Recording UX: waveform / preview / gestures
   ============================================ */
.message-input-wrapper.recording-active .message-input {
  display: none;
}
.message-input-wrapper.recording-active .message-input-actions .icon-button:not(#record-btn) {
  opacity: .4;
  pointer-events: none;
}

.record-gesture-area {
  margin: 6px 10px 0;
  padding: 10px;
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  user-select: none;
  touch-action: none; /* allow swipe gestures */
}

.record-waveform-canvas {
  width: 100%;
  height: 44px;
  display: block;
  border-radius: 10px;
  background: rgba(0,0,0,0.25);
}

.record-preview-video {
  width: 100%;
  height: 180px;
  display: block;
  border-radius: 12px;
  background: #000;
  object-fit: cover;
}

.mirror { transform: scaleX(-1); }

.record-hints {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--slate-400);
}

.record-draft-preview {
  width: 100%;
  margin: 10px 0 0;
  border-radius: 12px;
}

/* Forwarded message clickable */
.msg-forward[role="button"] { cursor: pointer; }
.msg-forward[role="button"]:hover { opacity: 0.9; }

/* Highlight when jumping to original message */
.message-highlight {
  outline: 2px solid var(--brand-accent);
  outline-offset: 2px;
  border-radius: 14px;
}

/* Pinned message banner */
.pinned-banner{
  display:flex;
  align-items:center;
  gap:10px;
  padding:8px 12px;
  margin:6px 12px 0 12px;
  border:1px solid var(--slate-700);
  border-radius:12px;
  background:rgba(15,23,42,0.35);
  cursor:pointer;
  user-select:none;
}
.pinned-banner:hover{ background:rgba(15,23,42,0.45); }
.pinned-banner .pinned-icon{ display:inline-flex; opacity:0.9; }
.pinned-banner .pinned-text{ font-size:13px; color:var(--slate-200); }
.pinned-banner .pinned-action{ margin-left:auto; font-size:12px; color:var(--brand-accent); }

/* =============================
   Mobile Left Drawer
   ============================= */
.mobile-drawer{
  position:fixed;
  inset:0;
  z-index:9990;
  display:none;
  background:rgba(2,6,23,.62);
  backdrop-filter:blur(6px);
}
.mobile-drawer.open{display:block;}
.mobile-drawer-panel{
  position:absolute;
  top:0;
  left:0;
  height:100%;
  width:min(340px,86vw);
  background:rgba(15,23,42,.94);
  border-right:1px solid rgba(255,255,255,0.08);
  transform:translateX(-100%);
  transition:transform .22s ease;
  padding:16px 14px calc(16px + env(safe-area-inset-bottom));
  overflow:auto;
}
.mobile-drawer.open .mobile-drawer-panel{transform:translateX(0);}
.drawer-top{display:flex;align-items:center;gap:12px;padding-top:calc(env(safe-area-inset-top));}
.drawer-avatar{width:48px;height:48px;border-radius:16px;overflow:hidden;flex:0 0 auto;border:1px solid rgba(255,255,255,0.12);background:rgba(148,163,184,0.12);display:flex;align-items:center;justify-content:center;}
.drawer-avatar-img{width:100%;height:100%;object-fit:cover;display:block;}
.drawer-avatar-fallback{font-weight:800;color:#fff;}
.drawer-user{flex:1;min-width:0;}
.drawer-name{font-weight:800;color:#fff;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.drawer-login{font-size:12px;color:rgba(226,232,240,0.75);}
.drawer-close{margin-left:auto;}
.drawer-menu{margin-top:14px;display:flex;flex-direction:column;gap:6px;}
.drawer-item{
  display:flex;
  align-items:center;
  gap:12px;
  width:100%;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,0.10);
  background:rgba(255,255,255,0.04);
  color:#e2e8f0;
  cursor:pointer;
  font-weight:700;
}
.drawer-item span{flex:1;text-align:left;}
.drawer-item:hover{background:rgba(255,255,255,0.07);}
.drawer-sep{height:1px;background:rgba(255,255,255,0.10);margin:10px 6px;}
.drawer-footer{margin-top:18px;padding-top:10px;border-top:1px solid rgba(255,255,255,0.08);}
.drawer-logout{
  width:100%;
  display:flex;
  align-items:center;
  gap:12px;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid rgba(239,68,68,0.25);
  background:rgba(239,68,68,0.08);
  color:#fecaca;
  cursor:pointer;
  font-weight:800;
}
.drawer-logout:hover{background:rgba(239,68,68,0.12);}


/* ===== Group profile modal ===== */
.card{
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 16px;
  padding: 14px;
  margin: 10px 0;
}
.card-title{
  font-weight: 700;
  margin-bottom: 10px;
}
.kv{display:flex; flex-direction:column; gap:8px;}
.kv-row{display:flex; justify-content:space-between; gap:12px; font-size: 14px;}
.kv-k{opacity:.7;}
.kv-v{font-weight:600; text-align:right;}

.member-list{display:flex; flex-direction:column; gap:10px;}
.member-row{
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  padding:10px; border-radius:14px;
  background: rgba(0,0,0,0.2);
  border:1px solid rgba(255,255,255,0.05);
}
.member-left{display:flex; align-items:center; gap:10px;}
.member-ava{
  width:36px; height:36px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  background: rgba(96,165,250,0.18);
  font-weight:800;
}
.member-meta{display:flex; flex-direction:column; gap:2px;}
.member-name{font-weight:700;}
.member-sub{display:flex; align-items:center; gap:8px; font-size:12px; opacity:.9;}
.member-actions{display:flex; align-items:center; gap:8px;}
.role-badge{
  padding: 2px 8px; border-radius: 999px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.08);
}
.role-owner{background: rgba(234,179,8,0.15); border-color: rgba(234,179,8,0.25);}
.role-admin{background: rgba(168,85,247,0.15); border-color: rgba(168,85,247,0.25);}
.role-editor{background: rgba(34,211,238,0.12); border-color: rgba(34,211,238,0.22);}
.role-member{background: rgba(148,163,184,0.10); border-color: rgba(148,163,184,0.20);}

.role-select, .select, .input{
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  color: inherit;
  border-radius: 12px;
  padding: 8px 10px;
}
.form-row{display:flex; flex-direction:column; gap:6px; margin-top:10px;}
.label{opacity:.7; font-size:12px;}
.btn-mini{
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.10);
  color: inherit;
}
.btn-mini.danger{
  background: rgba(239,68,68,0.12);
  border-color: rgba(239,68,68,0.25);
}
/* ===== Media grid in profile ===== */
.media-grid{
  display:grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap:10px;
}
.media-thumb{
  width:100%;
  aspect-ratio: 1/1;
  border-radius:14px;
  overflow:hidden;
  border:1px solid rgba(255,255,255,0.06);
  background: rgba(0,0,0,0.2);
}
.media-thumb img{width:100%; height:100%; object-fit:cover; display:block;}
.media-thumb.doc{display:flex; align-items:center; justify-content:center; padding:10px; font-size:12px; opacity:.9;}
@media (max-width: 520px){
  .media-grid{grid-template-columns: repeat(2, minmax(0,1fr));}
  .kv-row{flex-direction:column; align-items:flex-start;}
  .kv-v{text-align:left;}
}


/* Read-only channel banner */
.readonly-banner{
  width:100%;
  padding:12px 14px;
  border-radius:14px;
  background: rgba(148,163,184,0.12);
  color: var(--slate-300);
  font-size: 13px;
  line-height: 1.35;
  text-align: center;
}


.invite-list{display:flex;flex-direction:column;gap:10px;}
.invite-row{display:flex;gap:10px;align-items:center;justify-content:space-between;padding:10px 12px;border-radius:14px;background:rgba(148,163,184,0.06);}
.invite-main{min-width:0;flex:1;}
.invite-url{font-size:13px;color:var(--slate-200);word-break:break-all;}
.invite-sub{font-size:12px;color:var(--slate-400);margin-top:4px;}
.invite-actions{display:flex;gap:8px;}
.btn-mini{padding:6px 10px;border-radius:10px;border:1px solid rgba(148,163,184,0.18);background:transparent;color:var(--slate-200);cursor:pointer;font-size:12px;}
.btn-mini.danger{border-color:rgba(239,68,68,0.35);color:rgba(239,68,68,0.95);}


.vn-wave{ touch-action: none; }

/* ===== New Group: quick user picker ===== */
.ng-selected{margin:10px 0 12px 0; padding:10px 12px; border-radius:14px; background: rgba(148,163,184,0.06); border: 1px solid rgba(148,163,184,0.12);}
.ng-selected-head{display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:8px;}
.ng-selected-title{font-size:13px; color: var(--slate-200);}
.ng-chips{display:flex; flex-wrap:wrap; gap:8px;}
.ng-chip{display:inline-flex; align-items:center; gap:8px; padding:6px 10px; border-radius:999px; border: 1px solid rgba(148,163,184,0.18); background: rgba(148,163,184,0.06); color: var(--slate-200); cursor:pointer; max-width: 100%;}
.ng-chip-name{max-width: 180px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.ng-chip-x{opacity:0.9; font-size:14px; line-height:1;}

.ng-picker{margin-top:10px;}
.ng-tabs{display:flex; gap:8px; margin-bottom:10px;}
.ng-tab{flex:1; padding:10px 12px; border-radius:14px; border:1px solid rgba(148,163,184,0.14); background: rgba(148,163,184,0.06); color: var(--slate-200); cursor:pointer; font-size:13px;}
.ng-tab.active{border-color: rgba(59,130,246,0.45); background: rgba(59,130,246,0.12);}

.ng-list{max-height: 260px; overflow:auto; border-radius:14px; border:1px solid rgba(148,163,184,0.12); background: rgba(148,163,184,0.04);}

.user-list.compact{padding:8px; display:flex; flex-direction:column; gap:8px;}
.user-item.compact{padding:10px 10px; border-radius:14px; display:flex; align-items:center; gap:10px; cursor:pointer; border:1px solid rgba(148,163,184,0.10); background: rgba(148,163,184,0.04);}
.user-item.compact:hover{background: rgba(148,163,184,0.08);}
.user-item.compact.selected{border-color: rgba(34,197,94,0.45); background: rgba(34,197,94,0.10);}
.user-item.compact .user-pick{margin-left:auto; width:22px; height:22px; border-radius:8px; display:flex; align-items:center; justify-content:center; color: var(--slate-200); border:1px solid rgba(148,163,184,0.18); background: rgba(148,163,184,0.06);}
.user-item.compact.selected .user-pick{border-color: rgba(34,197,94,0.45); background: rgba(34,197,94,0.18);} 


.reaction-pill.disabled{cursor:default;opacity:.75;}
