:root {
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --bg-message-own: #3b82f6;
    --bg-message-other: #334155;
    --text-white: #f8fafc;
    --text-gray: #94a3b8;
    --accent-blue: #3b82f6;
    --accent-hover: #2563eb;
    --input-bg: #0f172a;
    --border-color: #334155;
    --danger: #ef4444;
    --sidebar-width: 320px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    width: 100%;
    font-family: 'Inter', sans-serif;
    background: var(--bg-dark);
    color: var(--text-white);
    overflow: hidden;
}

/* ── Auth Screen ── */
#auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
}

.auth-card {
    background: var(--bg-card);
    padding: 2.5rem 2rem;
    border-radius: 20px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    text-align: center;
    border: 1px solid var(--border-color);
}

.auth-logo {
    font-size: 3rem;
    margin-bottom: 1rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.auth-card h2 {
    margin-bottom: 1.5rem;
    font-weight: 600;
}

#auth-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#auth-form input {
    width: 100%;
    padding: 14px 16px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-white);
    font-size: 1rem;
    transition: all 0.2s;
}

#auth-form input:focus {
    border-color: var(--accent-blue);
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

#auth-form button {
    padding: 14px;
    background: var(--accent-blue);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 5px;
}

#auth-form button:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

/* ── Chat Layout (Sidebar + Main) ── */
#chat-container {
    display: none;
    /* Покажем через JS после авторизации */
    height: 100dvh;
    width: 100vw;
    display: flex;
    /* Будет перезаписано через JS, но для структуры тут display flex */
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    background: var(--bg-dark);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 10;
}

.sidebar-header {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    height: 65px;
}

.sidebar-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
}

.sidebar-nick {
    font-weight: 500;
    font-size: 15px;
}

.sidebar-search-wrap {
    padding: 15px;
}

.sidebar-search {
    width: 100%;
    padding: 10px 15px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-white);
    outline: none;
    transition: border-color 0.2s;
}

.sidebar-search:focus {
    border-color: var(--accent-blue);
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 10px;
}

.chat-list::-webkit-scrollbar {
    width: 6px;
}

.chat-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 5px;
}

.chat-item:hover {
    background: var(--bg-hover);
}

.chat-item.active {
    background: var(--accent-blue);
}

.chat-item-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    flex-shrink: 0;
    text-transform: uppercase;
}

.chat-item.active .chat-item-avatar {
    background: rgba(255, 255, 255, 0.2);
}

.global-avatar {
    background: linear-gradient(135deg, #6366f1, #3b82f6);
}

.chat-item-info {
    flex: 1;
    overflow: hidden;
}

.chat-item-name {
    display: block;
    font-weight: 500;
    font-size: 15px;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-preview {
    display: block;
    font-size: 13px;
    color: var(--text-gray);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item.active .chat-item-preview {
    color: rgba(255, 255, 255, 0.8);
}

/* Floating Action Button for New Chat */
.new-chat-fab {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: var(--accent-blue);
    color: white;
    border: none;
    border-radius: 24px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
    transition: transform 0.2s, background 0.2s;
}

.new-chat-fab:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

/* ── Main Chat Area ── */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: url('data:image/svg+xml;utf8,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><path d="M10 10h10v10H10z" fill="rgba(255,255,255,0.01)"/></svg>');
    position: relative;
    height: 100%;
}

.chat-header {
    height: 65px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 5;
    gap: 12px;
}

.back-btn {
    display: none;
    /* Показывать только на мобилках */
}

.chat-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    text-transform: uppercase;
}

.header-info {
    flex: 1;
}

.header-info h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

#chat-subtitle {
    font-size: 12px;
    color: var(--text-gray);
}

/* ── Messages ── */
#messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
}

#messages::-webkit-scrollbar {
    width: 6px;
}

#messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.message {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 16px;
    position: relative;
    word-wrap: break-word;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.message.other {
    align-self: flex-start;
    background: var(--bg-message-other);
    border-bottom-left-radius: 4px;
}

.message.own {
    align-self: flex-end;
    background: var(--bg-message-own);
    border-bottom-right-radius: 4px;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 13px;
}

.message.own .message-header {
    justify-content: flex-end;
}

.nick {
    font-weight: 600;
    color: #60a5fa;
}

.message.own .nick {
    display: none;
    /* В своих сообщениях ник не пишем для компактности, как в Telegram */
}

.message-content {
    font-size: 15px;
    line-height: 1.4;
    white-space: pre-wrap;
}

.message-meta {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 5px;
    margin-top: 4px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
}

.message.own .message-meta {
    color: rgba(255, 255, 255, 0.7);
}

.edited-mark {
    font-style: italic;
}

/* Checkmarks (Read status) */
.message-status {
    font-size: 11px;
    font-weight: bold;
    margin-left: 6px;
    user-select: none;
    display: inline-block;
    vertical-align: middle;
}
.message-status.delivered {
    color: rgba(255, 255, 255, 0.4);
}
.message-status.read {
    color: #60a5fa;
}
.message.own .message-status.read {
    color: #ffffff; /* Белые галочки на синем фоне своих сообщений */
}

/* Reply quote inside a message */
.message-reply-quote {
    display: flex;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    margin-bottom: 6px;
    cursor: pointer;
    overflow: hidden;
    max-width: 100%;
    transition: background 0.2s;
}
.message-reply-quote:hover {
    background: rgba(0, 0, 0, 0.25);
}
.reply-quote-indicator {
    width: 3px;
    background: #60a5fa;
    flex-shrink: 0;
}
.message.own .reply-quote-indicator {
    background: #ffffff;
}
.reply-quote-content {
    padding: 6px 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.reply-quote-nick {
    font-size: 12px;
    font-weight: 600;
    color: #60a5fa;
    margin-bottom: 2px;
}
.message.own .reply-quote-nick {
    color: #ffffff;
}
.reply-quote-text {
    font-size: 12px;
    color: var(--text-gray);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.message.own .reply-quote-text {
    color: rgba(255, 255, 255, 0.8);
}

/* Reply Bar (above message input) */
#reply-bar {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    padding: 10px 20px;
    border-top: 1px solid var(--border-color);
    gap: 12px;
    z-index: 4;
    animation: slideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.reply-bar-indicator {
    width: 3px;
    height: 32px;
    background: var(--accent-blue);
    border-radius: 2px;
    flex-shrink: 0;
}
.reply-bar-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.reply-bar-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-blue);
    margin-bottom: 2px;
}
.reply-bar-text {
    font-size: 13px;
    color: var(--text-gray);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Smooth Highlight Flash Animation */
.highlight-flash {
    animation: flashHighlight 1.5s ease-out;
}
@keyframes flashHighlight {
    0% {
        background: var(--bg-hover);
        box-shadow: 0 0 15px var(--accent-blue);
        transform: scale(1.02);
    }
    50% {
        background: var(--bg-hover);
        box-shadow: 0 0 15px var(--accent-blue);
        transform: scale(1.02);
    }
    100% {
        transform: scale(1);
    }
}

/* Message Actions */
.message-actions {
    position: absolute;
    top: -15px;
    right: 0;
    background: var(--bg-card);
    border-radius: 8px;
    padding: 4px;
    display: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    z-index: 2;
}

.message:hover .message-actions {
    display: flex;
    gap: 4px;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 6px;
    border-radius: 4px;
    color: var(--text-gray);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-white);
}

.delete-btn:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* ── Message Input ── */
#message-form {
    display: flex;
    padding: 12px 20px;
    background: var(--bg-dark);
    gap: 12px;
    align-items: flex-end;
}

#message-input {
    flex: 1;
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid transparent;
    border-radius: 24px;
    color: var(--text-white);
    outline: none;
    font-family: inherit;
    font-size: 15px;
    transition: all 0.2s;
    line-height: 1.4;
    max-height: 120px;
    /* Если бы был textarea */
}

#message-input:focus {
    border-color: var(--accent-blue);
    background: var(--bg-dark);
}

.send-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent-blue);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.send-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.send-btn:active {
    transform: scale(0.95);
}

/* ── Modals & Overlays ── */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.search-modal-card {
    background: var(--bg-card);
    width: 100%;
    max-width: 400px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    max-height: 80vh;
}

.search-modal-header {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.search-modal-header h3 {
    font-size: 16px;
}

.search-input-wrap {
    padding: 15px 20px;
}

#user-search-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-white);
    font-size: 14px;
    outline: none;
}

#user-search-input:focus {
    border-color: var(--accent-blue);
}

#search-results {
    padding: 0 10px 15px;
    overflow-y: auto;
    flex: 1;
}

.search-hint {
    text-align: center;
    color: var(--text-gray);
    font-size: 14px;
    padding: 20px 0;
}

.search-user-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.search-user-item:hover {
    background: var(--bg-hover);
}

.search-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-message-other);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    text-transform: uppercase;
}

.search-user-info {
    display: flex;
    flex-direction: column;
}

.search-user-nick {
    font-weight: 500;
    font-size: 15px;
}

.search-user-email {
    font-size: 12px;
    color: var(--text-gray);
}


/* Common Icon Button */
.icon-btn {
    background: none;
    border: none;
    color: var(--text-gray);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-white);
}

/* ── Responsive Mobile ── */
@media (max-width: 768px) {

    .sidebar {
        width: 100%;
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
        transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
        z-index: 20;
    }

    .chat-main {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 10;
    }

    /* States handled by JS classes */
    body.show-chat .sidebar {
        transform: translateX(-100%);
    }

    .back-btn {
        display: flex;
        /* Show back button on mobile */
    }

    /* Modals convert into gorgeous, glassmorphic bottom sheets sliding up from the bottom */
    .overlay {
        align-items: flex-end;
        background: rgba(0, 0, 0, 0.7);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        transition: opacity 0.3s ease;
    }

    .search-modal-card,
    .settings-modal-card,
    .profile-view-card {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 24px 24px 0 0 !important; /* Top roundings only */
        border-left: none !important;
        border-right: none !important;
        border-bottom: none !important;
        margin: 0 !important;
        padding-bottom: env(safe-area-inset-bottom, 24px) !important; /* Home bar safe space */
        transform: translateY(100%);
        animation: slideUpMobile 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
        max-height: 85dvh !important;
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.6) !important;
    }

    /* Elegant swipe handle handle drag indicator on mobile */
    .search-modal-card::before,
    .settings-modal-card::before,
    .profile-view-card::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 2px;
        margin: 8px auto 0 auto;
        flex-shrink: 0;
    }

    @keyframes slideUpMobile {
        to {
            transform: translateY(0);
        }
    }

    /* Tactile micro-feedbacks on mobile taps */
    .icon-btn:active, 
    .send-btn:active, 
    .chat-item:active, 
    .accept-btn:active, 
    .decline-btn:active {
        transform: scale(0.92) !important;
        opacity: 0.8 !important;
    }
}

/* Custom modal (Edit/Delete) */
.modal-content {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 16px;
    width: 90%;
    max-width: 350px;
    text-align: center;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.modal-content h3 {
    margin-bottom: 10px;
}

.modal-content p {
    color: var(--text-gray);
    font-size: 14px;
    margin-bottom: 20px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.modal-buttons button {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    color: white;
}

.modal-cancel {
    background: var(--bg-hover);
}

.modal-cancel:hover {
    background: #475569;
}

.modal-confirm {
    background: var(--accent-blue);
}

.modal-confirm.danger {
    background: var(--danger);
}

#edit-textarea {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    color: white;
    padding: 10px;
    border-radius: 8px;
    min-height: 80px;
    resize: vertical;
    margin-bottom: 15px;
    outline: none;
}

#edit-textarea:focus {
    border-color: var(--accent-blue);
}

/* --- Avatar & Profiles --- */
.avatar-img-container {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: block;
}

.avatar-letter-container {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    text-transform: uppercase;
    color: white;
    font-size: inherit;
}

/* Sidebar profile interactive styles */
.sidebar-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
    user-select: none;
}

.sidebar-profile:hover {
    background-color: var(--bg-hover);
}

.sidebar-profile:active {
    transform: scale(0.98);
}

.gear-icon {
    color: var(--text-gray);
    opacity: 0;
    transition: opacity 0.2s, transform 0.3s;
    margin-left: 2px;
}

.sidebar-profile:hover .gear-icon {
    opacity: 0.7;
}

.sidebar-profile:hover .gear-icon:hover {
    transform: rotate(45deg);
    opacity: 1;
    color: var(--text-white);
}

/* --- Settings Modal --- */
.settings-modal-card {
    background: var(--bg-card);
    width: 90%;
    max-width: 420px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6);
    border: 1px solid var(--border-color);
    animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleUp {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.settings-modal-header {
    padding: 18px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.settings-modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.settings-modal-body {
    padding: 24px;
}

.settings-avatar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 24px;
    gap: 8px;
}

.settings-avatar-wrapper {
    position: relative;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    cursor: pointer;
    overflow: hidden;
    border: 2px solid var(--border-color);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transition: border-color 0.2s, transform 0.2s;
}

.settings-avatar-wrapper:hover {
    border-color: var(--accent-blue);
    transform: scale(1.03);
}

.settings-avatar-preview {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 600;
    background: linear-gradient(135deg, #475569, #1e293b);
}

.settings-avatar-hover {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.settings-avatar-wrapper:hover .settings-avatar-hover {
    opacity: 1;
}

.settings-avatar-hover svg {
    color: white;
}

.settings-avatar-hint {
    font-size: 12px;
    color: var(--text-gray);
}

.settings-fields {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.settings-field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.settings-field-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-gray);
}

.settings-field-group input,
.settings-field-group textarea {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 14px;
    color: white;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.settings-field-group input:focus,
.settings-field-group textarea:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.settings-field-group textarea {
    min-height: 80px;
    resize: none;
}

.settings-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.settings-modal-footer button {
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.settings-cancel-btn {
    background: var(--bg-hover);
    color: var(--text-white);
}

.settings-cancel-btn:hover {
    background: #475569;
}

.settings-save-btn {
    background: var(--accent-blue);
    color: white;
}

.settings-save-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.settings-save-btn:active {
    transform: translateY(0);
}


/* --- Profile View Modal --- */
.profile-view-card {
    background: var(--bg-card);
    width: 90%;
    max-width: 380px;
    border-radius: 24px;
    border: 1px solid var(--border-color);
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.7);
    padding: 30px 24px;
    position: relative;
    text-align: center;
    animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.profile-view-close {
    position: absolute;
    top: 15px;
    right: 15px;
}

.profile-view-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 24px;
}

.profile-view-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    margin-bottom: 16px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: 600;
}

.profile-view-nick {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: white;
}

.profile-view-status {
    font-size: 13px;
    color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.1);
    padding: 4px 12px;
    border-radius: 20px;
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-view-body {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 28px;
    background: rgba(0, 0, 0, 0.15);
    padding: 16px;
    border-radius: 16px;
}

.profile-view-info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.profile-view-info-item .info-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-gray);
    font-weight: 600;
}

.profile-view-info-item .info-value {
    font-size: 14px;
    color: white;
    word-break: break-all;
}

.profile-view-info-item .bio-text {
    line-height: 1.4;
    white-space: pre-wrap;
    color: #cbd5e1;
    font-size: 13.5px;
}

.profile-view-footer {
    display: flex;
    justify-content: center;
}

.profile-message-btn {
    width: 100%;
    padding: 14px;
    background: var(--accent-blue);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.profile-message-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.profile-message-btn:active {
    transform: translateY(0);
}

/* Make global chat user name clickable and look nice */
.message-header .nick {
    cursor: pointer;
    transition: color 0.2s;
}

.message-header .nick:hover {
    color: var(--accent-blue);
    text-decoration: underline;
}

/* --- Message Emoji Reactions --- */

/* Reactions List Container */
.message-reactions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
    user-select: none;
}

/* Individual Reaction pill */
.reaction-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-gray);
    font-family: inherit;
}

.reaction-pill:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.reaction-pill:active {
    transform: translateY(0);
}

/* Reaction pill active state (reacted by current user) */
.reaction-pill.active {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.4);
    color: #60a5fa;
}

.reaction-pill.active:hover {
    background: rgba(59, 130, 246, 0.25);
    border-color: rgba(59, 130, 246, 0.6);
}

/* Reaction Pill Count */
.reaction-count {
    font-weight: 600;
}

/* Reactions picker floating popup */
.reaction-picker-popup {
    display: flex;
    gap: 6px;
    background: rgba(30, 41, 59, 0.85); /* var(--bg-card) with transparency */
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 6px 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    animation: quickPop 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes quickPop {
    from {
        opacity: 0;
        transform: scale(0.85) translateY(5px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.emoji-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.emoji-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.25) translateY(-3px);
}

.emoji-btn:active {
    transform: scale(0.95);
}

/* --- Programmatic Attachments & Typing Indicators --- */

/* Paperclip attach button in message form */
#attach-image-btn {
    color: var(--text-gray);
    flex-shrink: 0;
    transition: color 0.2s, transform 0.2s;
    padding: 10px;
    margin-right: -4px;
}

#attach-image-btn:hover {
    color: var(--text-white);
    transform: scale(1.08) rotate(15deg);
}

#attach-image-btn:active {
    transform: scale(0.95);
}

/* Image container inside chat bubble */
.message-image-container {
    margin-top: 6px;
    border-radius: 12px;
    overflow: hidden;
    cursor: zoom-in;
    position: relative;
    max-width: 280px;
    max-height: 280px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    background: rgba(0, 0, 0, 0.1);
    transition: transform 0.2s cubic-bezier(0.25, 1, 0.5, 1);
}

.message-image-container:hover {
    transform: scale(1.015);
    border-color: rgba(255, 255, 255, 0.2);
}

.message-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    max-height: 280px;
}

/* Fullscreen zoom image preview modal */
.image-preview-close {
    position: absolute;
    top: 25px;
    right: 25px;
    background: rgba(15, 23, 42, 0.6) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: white !important;
    padding: 12px !important;
    z-index: 1010;
}

.image-preview-content {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 16px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: scaleZoom 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    user-select: none;
}

@keyframes scaleZoom {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Typing animated dots inside header */
.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-left: 4px;
}

.typing-dots span {
    width: 4px;
    height: 4px;
    background-color: var(--accent-blue);
    border-radius: 50%;
    display: inline-block;
    animation: dotBounce 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes dotBounce {
    0%, 80%, 100% { 
        transform: scale(0);
        opacity: 0.3;
    } 40% { 
        transform: scale(1.2);
        opacity: 1;
    }
}

/* --- Social Systems: Online, Friends & Blacklist --- */

.chat-item-avatar, .sidebar-avatar, .profile-view-avatar, .avatar-img-container, .avatar-letter-container {
    position: relative;
}

.is-online::after {
    content: '';
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 10px;
    height: 10px;
    background-color: #34d399; /* Green */
    border: 2px solid #0f172a; /* Slate 900 background match */
    border-radius: 50%;
    z-index: 5;
    box-shadow: 0 0 8px #34d399;
    animation: pulseOnline 2s infinite;
}

@keyframes pulseOnline {
    0% {
        box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.7);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(52, 211, 153, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(52, 211, 153, 0);
    }
}

.chat-item-status-pill {
    font-size: 10px;
    color: #38bdf8; /* Light blue accent */
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.15);
    padding: 1px 6px;
    border-radius: 6px;
    max-width: 90px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-left: 6px;
    display: inline-block;
    vertical-align: middle;
}

.settings-blacklist-list, #friend-requests-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.blacklist-item, .friend-request-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    transition: all 0.2s;
}

.blacklist-item:hover, .friend-request-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.blacklist-item span, .friend-request-item span {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-white);
}

.blacklist-item .remove-btn, .friend-request-item .accept-btn, .friend-request-item .decline-btn {
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.blacklist-item .remove-btn {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.blacklist-item .remove-btn:hover {
    background: #ef4444;
    color: white;
}

.friend-request-item .accept-btn {
    background: rgba(52, 211, 153, 0.15);
    color: #34d399;
    margin-right: 6px;
}

.friend-request-item .accept-btn:hover {
    background: #10b981;
    color: white;
}

.friend-request-item .decline-btn {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-gray);
}

.friend-request-item .decline-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-white);
}
