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

/* Плавные переходы для темы */
body,
.sidebar,
.chat-area,
.auth-card,
.btn,
.modal-content,
.chat-item,
.message-content,
input,
textarea {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Исключения для медиа-файлов */
img,
video,
audio,
svg {
    transition: none;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border: #475569;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --shadow: rgba(0, 0, 0, 0.3);
}

/* Светлая тема */
.light-theme {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --shadow: rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    color: var(--text-primary);
    height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
}

/* Разрешить скроллинг на странице авторизации */
#auth-screen {
    overflow-y: auto;
    overflow-x: hidden;
}

/* Запретить скроллинг на главном экране */
#main-screen {
    overflow: hidden;
}

.light-theme body {
    background: linear-gradient(135deg, var(--bg-primary) 0%, #e2e8f0 100%);
}

.screen {
    display: none;
    height: 100vh;
}

.screen.active {
    display: flex;
}

/* Скрыть блок профиля в сайдбаре на странице авторизации */
body.auth-screen-active #sidebar-profile {
    display: none !important;
}

/* Авторизация */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px var(--shadow);
    border: 1px solid var(--border);
}

.logo {
    font-size: 32px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 14px;
}

.auth-section {
    margin-bottom: 24px;
    display: block !important;
    visibility: visible !important;
}

.auth-section h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
    text-align: center;
}

.auth-hint {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 20px;
}

.auth-divider {
    display: flex;
    align-items: center;
    margin: 24px 0;
    text-align: center;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.auth-divider span {
    padding: 0 16px;
    color: var(--text-muted);
    font-size: 13px;
}

.file-upload-area {
    border: 2px dashed var(--primary) !important;
    border-radius: 12px !important;
    padding: 40px 20px !important;
    text-align: center !important;
    cursor: pointer !important;
    transition: all 0.2s !important;
    background: rgba(99, 102, 241, 0.05) !important;
    margin-bottom: 16px !important;
    min-height: 200px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 100% !important;
}

.file-upload-area svg,
.file-upload-area p {
    pointer-events: none;
}

.file-upload-area button {
    pointer-events: all !important;
    cursor: pointer !important;
}

.file-upload-area input {
    pointer-events: all;
}

.file-upload-area:hover {
    border-color: var(--primary) !important;
    background: rgba(99, 102, 241, 0.15) !important;
    border-width: 2px !important;
}

.file-upload-area.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.2);
}

.file-upload-area svg {
    margin-bottom: 12px;
    color: var(--text-muted);
}

.file-upload-area p {
    color: var(--text-secondary);
    font-size: 14px;
}

.file-link {
    color: var(--primary);
    text-decoration: underline;
    cursor: pointer;
}

.file-name {
    margin-top: 12px;
    padding: 8px 12px;
    background: var(--bg-primary);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
    display: none;
    border: 1px solid var(--primary);
}

.file-name.show {
    display: block;
}

.btn-large {
    width: 100%;
    padding: 16px 24px;
    font-size: 16px;
}

.btn-large svg {
    margin-right: 8px;
    vertical-align: middle;
}

.auth-form {
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 100% !important;
}

.auth-form input {
    padding: 14px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 15px;
    transition: all 0.2s;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.btn {
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

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

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

.error-message {
    color: var(--error);
    font-size: 14px;
    margin-top: 8px;
    display: none;
}

.error-message.show {
    display: block;
}

/* Главный экран */
#main-screen {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 360px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

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

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--primary);
    transform: scale(1.05);
}

.user-info {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar, .chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    flex-shrink: 0;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 15px;
}

.user-link {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.user-link code {
    font-family: 'Courier New', monospace;
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-copy {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    transition: color 0.2s;
}

.btn-copy:hover {
    color: var(--primary);
}

.btn-logout {
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: var(--error);
    color: white;
    border-color: var(--error);
}

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

/* Блок профиля внизу сайдбара */
.sidebar-profile {
    padding: 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.sidebar-profile-avatar {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    color: white;
    flex-shrink: 0;
}

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

.sidebar-profile-name {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.sidebar-profile-link {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
}

.sidebar-profile-link code {
    font-family: 'Courier New', monospace;
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    color: var(--text-secondary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-logout-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.sidebar-logout-btn:hover {
    background: var(--bg-tertiary);
    color: var(--error);
}

.chat-item {
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    margin-bottom: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.chat-item.active {
    background: var(--primary);
    color: white;
}

.light-theme .chat-item.active {
    background: var(--primary);
    color: white;
}

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

.chat-item-name {
    font-weight: 500;
    margin-bottom: 4px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.unread-badge {
    background: var(--primary);
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
    line-height: 1.4;
}

.chat-item.active .unread-badge {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

.chat-item-preview {
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.4;
    max-height: 2.8em;
}

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

.user-info-top {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.user-info-top.hidden {
    display: none !important;
}

.chat-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.empty-chat {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 1;
}

.empty-chat.hidden {
    display: none !important;
}

.empty-chat-content {
    text-align: center;
    color: var(--text-muted);
}

.empty-chat-content svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-chat-content h3 {
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.active-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    background: var(--bg-primary);
    min-height: 0;
    position: relative;
    z-index: 2;
}

.active-chat.hidden {
    display: none !important;
}

.chat-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-secondary);
}

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

.btn-back-chats {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    margin-right: 4px;
}

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

/* Скрыть кнопку "назад" на десктопе, показывать только на мобильных */
@media (min-width: 769px) {
    .btn-back-chats {
        display: none;
    }
}

.chat-name-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-other-name {
    font-weight: 600;
    font-size: 16px;
}

.btn-edit-name {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    border-radius: 6px;
    transition: all 0.2s;
    opacity: 0.6;
}

.btn-edit-name:hover {
    background: var(--bg-tertiary);
    color: var(--primary);
    opacity: 1;
}

.chat-status {
    font-size: 12px;
    color: var(--success);
    margin-top: 2px;
    font-weight: 400;
}

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

.chat-menu-wrapper {
    position: relative;
}

.chat-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 24px var(--shadow);
    min-width: 180px;
    z-index: 100;
    overflow: hidden;
}

.chat-menu.active {
    display: block;
}

.chat-menu-item {
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    transition: all 0.2s;
    text-align: left;
}

.chat-menu-item:hover {
    background: var(--bg-tertiary);
    color: var(--error);
}

.chat-menu-item svg {
    flex-shrink: 0;
}

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

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

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.1s ease, visibility 0.1s ease;
}

.message {
    display: flex;
    gap: 8px;
    max-width: 75%;
    width: fit-content;
    margin-bottom: 4px;
    align-items: flex-end;
    animation: fadeIn 0.2s ease-out;
}

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

/* Анимация только для новых сообщений (не при первой загрузке) */
.message[data-new="true"] {
    animation: slideIn 0.3s ease-out;
}

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

/* Сообщения от собеседника - слева */
.message.received {
    align-self: flex-start;
    flex-direction: row;
    margin-left: 0;
    margin-right: auto;
}

/* Сообщения пользователя - справа */
.message.sent {
    align-self: flex-end;
    flex-direction: row-reverse;
    margin-left: auto;
    margin-right: 0;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
    flex-shrink: 0;
    align-self: flex-end;
    margin-bottom: 2px;
    color: white;
}

/* Аватар только для полученных сообщений */
.message.sent .message-avatar {
    display: none;
}

.message-content {
    background: var(--bg-secondary);
    padding: 10px 14px;
    border-radius: 18px;
    border: none;
    position: relative;
    word-wrap: break-word;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    min-width: 50px;
}

/* Сообщения собеседника - серый фон, слева, с "хвостиком" */
.message.received .message-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
    color: var(--text-primary);
}

/* Собственные сообщения - синий фон, справа, с "хвостиком" */
.message.sent .message-content {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-bottom-right-radius: 4px;
}

.light-theme .message.sent .message-content {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border: none;
    color: white;
}

.message-text {
    word-wrap: break-word;
    line-height: 1.5;
    white-space: pre-wrap;
    font-size: 15px;
    color: var(--text-primary);
}

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

.message-media {
    margin-top: 8px;
    border-radius: 12px;
    overflow: hidden;
    max-width: 100%;
}

.message-media img,
.message-media video {
    width: 100%;
    height: auto;
    display: block;
}

.message-audio {
    width: 100%;
    margin-top: 8px;
}

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

.message-file-icon {
    width: 24px;
    height: 24px;
}

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

.message-file-name {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-file-size {
    font-size: 11px;
    color: var(--text-muted);
}

.message-text {
    display: inline-block;
    margin-bottom: 4px;
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 8px;
    opacity: 0.7;
    display: inline-block;
    vertical-align: bottom;
    white-space: nowrap;
}

.message.sent .message-time {
    color: rgba(255, 255, 255, 0.8);
}

.message-content {
    overflow: hidden;
    display: inline-block;
    position: relative;
    max-width: 100%;
}

.chat-input-area {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    gap: 12px;
}

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

#message-input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 24px;
    color: var(--text-primary);
    font-size: 15px;
    transition: all 0.2s;
}

#message-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.btn-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-send:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal.blocked {
    pointer-events: auto;
}

.modal.blocked .modal-content {
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    border: 1px solid var(--border);
    box-shadow: 0 20px 60px var(--shadow);
}

.modal-large {
    max-width: 600px;
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.modal-body input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 15px;
    margin-top: 12px;
}

.modal-body input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Модальное окно для скачивания ключа */
.key-download-warning {
    text-align: center;
    padding: 20px;
    margin-bottom: 24px;
}

.key-download-warning svg {
    color: var(--warning);
    margin-bottom: 16px;
}

.key-download-warning h3 {
    font-size: 18px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.key-download-warning p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 8px;
}

.key-info {
    color: var(--text-muted);
    font-size: 13px;
    font-style: italic;
}

.key-download-area {
    text-align: center;
    padding: 20px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    margin-bottom: 20px;
}

.download-status {
    margin-top: 12px;
    font-size: 14px;
    font-weight: 500;
}

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

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

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

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

/* Адаптивность */
@media (max-width: 768px) {
    #main-screen {
        position: relative;
    }
    
    .sidebar {
        width: 100%;
        max-width: 320px;
        position: fixed;
        left: -100%;
        top: 0;
        z-index: 200;
        height: 100vh;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px var(--shadow);
    }
    
    .sidebar.active {
        left: 0;
    }
    
    .chat-area {
        width: 100%;
    }
    
    .chat-header {
        padding: 12px 16px;
    }
    
    .sidebar-header {
        padding: 16px;
    }
    
    .auth-card {
        padding: 32px 24px;
    }
    
    .messages-container {
        padding: 16px;
    }
    
    .message {
        max-width: 85%;
    }
    
    .chat-input-area {
        padding: 12px 16px;
    }
    
    .modal-content {
        width: 95%;
        margin: 20px;
    }
}

@media (max-width: 480px) {
    .sidebar {
        max-width: 100%;
    }
    
    .auth-card {
        padding: 24px 20px;
    }
    
    .logo {
        font-size: 28px;
    }
    
    .sidebar-header h2 {
        font-size: 18px;
    }
    
    .message {
        max-width: 90%;
    }
    
    .chat-item {
        padding: 10px;
    }
    
    .user-info-top {
        padding: 12px 16px;
        flex-wrap: wrap;
    }
    
    .chat-header-actions {
        gap: 4px;
    }
    
    .modal-content {
        width: 100%;
        max-width: 100%;
        border-radius: 0;
        height: 100vh;
        max-height: 100vh;
        margin: 0;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 16px;
    }
    
    .chat-header-info {
        min-width: 0;
    }
    
    .chat-other-name {
        font-size: 14px;
    }
}

/* Кнопка для открытия сайдбара на мобильных */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 150;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px var(--shadow);
}

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

/* Оверлей для закрытия сайдбара */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 150;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
}

@media (max-width: 768px) {
    .sidebar-overlay.active {
        display: block;
    }
}

/* Стили для btn-copy-small (используется в сайдбаре) */
.btn-copy-small {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-copy-small:hover {
    background: var(--bg-primary);
    color: var(--primary);
}

/* Индикатор записи голоса */
.voice-recording {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--error);
    border-radius: 12px;
    margin: 8px 20px;
}

.voice-recording-indicator {
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.voice-recording-text {
    color: white;
    font-weight: 500;
}

