        /* Логин */
        #login-overlay { position: fixed; top:0; left:0; width:100%; height:100%; background:white; z-index:999; display:flex; justify-content:center; align-items:center; }
        .login-box { width: 300px; display: flex; flex-direction: column; gap: 15px; padding: 20px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); border-radius: 8px; background: white; }
        .login-box h2 { text-align: center; margin: 0; color: #333; }
        .login-box input { padding: 12px; border: 1px solid #ddd; border-radius: 5px; font-size: 16px; }
        .login-box button { padding: 12px; background: #007bff; color: white; border: none; border-radius: 5px; cursor: pointer; font-size: 16px; font-weight: bold; }

        /* Сайдбар */
        .sidebar { width: 320px; background: white; border-right: 1px solid #ddd; display: flex; flex-direction: column; transition: width 0.3s ease, transform 0.3s ease; flex-shrink: 0; }
        .sidebar.hidden { width: 0; transform: translateX(-100%); border: none; }
        
        .sidebar-header { padding: 15px; border-bottom: 1px solid #ddd; background: #f8f9fa; display: flex; justify-content: space-between; align-items: center; }
        .logout-btn { background: none; border: 1px solid #dc3545; color: #dc3545; padding: 5px 10px; border-radius: 4px; cursor: pointer; font-size: 12px; }
        .logout-btn:hover { background: #dc3545; color: white; }
        
        #user-list { overflow-y: auto; flex: 1; }
        .user-item { padding: 15px; border-bottom: 1px solid #eee; cursor: pointer; transition: background 0.2s; position: relative; display: flex; align-items: center; }
        .user-item:hover { background: #f1f1f1; }
        .user-item.active { background: #e6f7ff; border-left: 4px solid #007bff; }
        
        /* Аватар пользователя */
        .user-avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; margin-right: 12px; flex-shrink: 0; border: 1px solid #ddd; background: #fff; }

        .user-name { font-weight: bold; color: #333; display: flex; justify-content: space-between; align-items: center; }
        .unread-badge { background: #dc3545; color: white; border-radius: 12px; padding: 2px 8px; font-size: 12px; font-weight: bold; margin-left: auto; box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
        .user-time { font-size: 0.8em; color: #888; margin-top: 4px; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0;}
        
        .user-tags-dots { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
        .sidebar-tag { font-size: 12px; padding: 3px 8px; border-radius: 10px; color: white; display: inline-block; box-shadow: 0 1px 2px rgba(0,0,0,0.1); white-space: nowrap; }

        /* Чат */
        .chat-area { flex: 1; display: flex; flex-direction: column; background: #efe7dd; position: relative; }
        
        /* Шапка чата */
        .chat-header { background: #f0f2f5; padding: 10px 20px; border-bottom: 1px solid #ddd; display: flex; align-items: center; gap: 15px; height: 60px; box-sizing: border-box; }
        .toggle-sidebar-btn { background: none; border: none; font-size: 24px; cursor: pointer; color: #555; padding: 0; display: flex; align-items: center; justify-content: center; }
        .chat-info { flex: 1; display: flex; flex-direction: column; justify-content: center; }
        .chat-title { font-weight: bold; font-size: 16px; color: #000; }
        .chat-subtitle { font-size: 12px; color: #666; }
        
        .header-tags { display: flex; gap: 8px; align-items: center; }
        .tag-badge { font-size: 14px; padding: 4px 12px; border-radius: 14px; color: white; display: flex; align-items: center; gap: 6px; box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
        .tag-remove { cursor: pointer; font-weight: bold; opacity: 0.7; font-size: 16px; }
        .tag-remove:hover { opacity: 1; }
        .add-tag-btn { background: #e4e6eb; border: none; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; font-weight: bold; color: #555; font-size: 18px; }

        /* Сообщения */
        .messages { flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; background: #e5ddd5; scroll-behavior: smooth; }
        .msg { max-width: 70%; padding: 10px 15px; border-radius: 10px; position: relative; word-wrap: break-word; box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
        .msg.user { align-self: flex-start; background: white; border-bottom-left-radius: 0; }
        .msg.admin { align-self: flex-end; background: #dcf8c6; border-bottom-right-radius: 0; }
        
        .msg-actions { position: absolute; top: 50%; left: -85px; transform: translateY(-50%); display: flex; gap: 5px; opacity: 0; transition: opacity 0.2s ease-in-out; }
        .msg.admin:hover .msg-actions { opacity: 1; }
        .action-btn { cursor: pointer; background: #fff; border-radius: 50%; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 5px rgba(0,0,0,0.2); font-size: 16px; border: 1px solid #ddd; transition: transform 0.1s; }
        .action-btn:hover { transform: scale(1.15); }
        .action-btn.edit-btn { color: #ff9800; border-color: #ffe0b2; }
        .action-btn.edit-btn:hover { background: #ff9800; color: white; }
        .action-btn.delete-btn { color: #dc3545; border-color: #f5c6cb; }
        .action-btn.delete-btn:hover { background: #dc3545; color: white; }

        .msg-image { max-width: 200px; max-height: 200px; object-fit: cover; border-radius: 5px; margin-top: 5px; cursor: zoom-in; border: 1px solid #ddd; }
        .msg-attach { margin-top: 5px; font-size: 0.9em; display: flex; align-items: center; padding: 8px; background: rgba(0,0,0,0.05); border-radius: 4px; color: #333; text-decoration: none; border: 1px solid rgba(0,0,0,0.1); }
        .msg-empty { font-style: italic; color: #999; font-size: 0.8em; }

        /* Ввод */
        .input-area { padding: 15px; background: #f0f2f5; border-top: 1px solid #ddd; display: flex; gap: 10px; align-items: center; }
        .file-upload-wrapper { position: relative; display: flex; align-items: center; }
        .file-upload-label { cursor: pointer; padding: 8px; border-radius: 50%; font-size: 24px; color: #555; }
        .file-upload-label:hover { background: #e4e6eb; color: #007bff; }
        #file-input { display: none; }
        
        .file-status-container { display: none; align-items: center; background: #e9ecef; padding: 5px 10px; border-radius: 15px; font-size: 13px; max-width: 150px; }
        .file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: 5px; }
        .remove-file-btn { cursor: pointer; color: #dc3545; font-weight: bold; margin-left: 5px; }

        input[type="text"] { flex: 1; padding: 12px; border: 1px solid #ddd; border-radius: 20px; outline: none; }
        input[type="text"]:focus { border-color: #007bff; }
        #send-btn { padding: 10px 20px; background: #007bff; color: white; border: none; border-radius: 20px; cursor: pointer; font-weight: bold; }
        #send-btn:hover { background: #0056b3; }
        #send-btn:disabled { background: #ccc; cursor: not-allowed; }

        /* Модалки */
        .modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.9); flex-direction: column; justify-content: center; align-items: center; }
        .modal-content { max-width: 90%; max-height: 85vh; object-fit: contain; }
        .modal-controls { position: absolute; top: 20px; right: 30px; display: flex; gap: 20px; align-items: center; }
        .close-btn { color: #f1f1f1; font-size: 40px; cursor: pointer; line-height: 1; }
        .download-btn { color: white; text-decoration: none; border: 1px solid white; padding: 8px 15px; border-radius: 4px; }

        #tag-modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1001; align-items: center; justify-content: center; }
        .tag-modal-box { background: white; padding: 20px; border-radius: 8px; width: 300px; display: flex; flex-direction: column; gap: 10px; }
        .tag-modal-box h3 { margin: 0 0 10px 0; }
        .tag-colors { display: flex; gap: 10px; margin-bottom: 10px; }
        .color-opt { width: 25px; height: 25px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
        .color-opt.selected { border-color: #333; transform: scale(1.1); }

        /* Кнопка настроек и футер сайдбара */
        .sidebar-footer { padding: 15px; border-top: 1px solid #ddd; background: #f8f9fa; }
        .settings-btn { width: 100%; padding: 10px; background: #e4e6eb; border: none; border-radius: 5px; cursor: pointer; font-weight: bold; color: #555; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 14px; transition: background 0.2s; }
        .settings-btn:hover { background: #d8dadf; color: #333; }

        /* Окно настроек */
        #settings-modal { background-color: rgba(0,0,0,0.5); }
        .settings-content { background: white; padding: 25px; border-radius: 8px; width: 400px; max-width: 90%; position: relative; box-shadow: 0 4px 15px rgba(0,0,0,0.2); }
        .settings-content h2 { margin-top: 0; color: #333; border-bottom: 1px solid #eee; padding-bottom: 10px; margin-bottom: 20px; }
        .settings-close-btn { position: absolute; top: 20px; right: 20px; font-size: 24px; cursor: pointer; background: none; border: none; color: #888; line-height: 1; }
        .settings-close-btn:hover { color: #333; }
        .setting-item { margin-bottom: 15px; }
        .setting-label { font-size: 12px; color: #666; text-transform: uppercase; font-weight: bold; margin-bottom: 5px; display: block; }
        .setting-value { background: #f0f2f5; padding: 12px; border-radius: 5px; font-size: 16px; color: #333; border: 1px solid #ddd; }

        /* Стили для шаблонов */
        .template-item { background: #f8f9fa; border: 1px solid #ddd; padding: 10px; border-radius: 5px; margin-bottom: 10px; }
        .template-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; font-weight: bold; font-size: 14px; }
        .template-actions button { background: none; border: none; cursor: pointer; font-size: 14px; padding: 0 5px; }
        .template-actions button.edit-btn { color: #007bff; }
        .template-actions button.delete-btn { color: #dc3545; }
        .template-content-preview { font-size: 13px; color: #555; white-space: pre-wrap; word-break: break-word; }
        .template-form { display: flex; flex-direction: column; gap: 8px; background: #f0f2f5; padding: 12px; border-radius: 5px; margin-top: 15px; border: 1px solid #ddd;}

        .header { background: white; padding: 15px 30px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); display: flex; justify-content: space-between; align-items: center; }
        .header h1 { margin: 0; font-size: 20px; }
        .back-btn { padding: 8px 15px; background: #e4e6eb; border: none; border-radius: 5px; cursor: pointer; font-weight: bold; color: #333; text-decoration: none; }
        .back-btn:hover { background: #d8dadf; }
        
        .container { max-width: 800px; margin: 30px auto; padding: 0 20px; }
        .settings-card { background: white; border-radius: 8px; padding: 25px; margin-bottom: 25px; box-shadow: 0 2px 6px rgba(0,0,0,0.05); }
        .settings-card h2 { margin-top: 0; border-bottom: 1px solid #eee; padding-bottom: 15px; margin-bottom: 20px; font-size: 18px; }
        
        .setting-group { margin-bottom: 20px; }
        .setting-label { display: block; font-size: 13px; color: #666; font-weight: bold; text-transform: uppercase; margin-bottom: 8px; }
        .input-row { display: flex; gap: 10px; }
        .input-field { flex: 1; padding: 10px; border: 1px solid #ddd; border-radius: 5px; font-size: 15px; outline: none; }
        .input-field:focus { border-color: #007bff; }
        
        .btn-primary { padding: 10px 20px; background: #007bff; color: white; border: none; border-radius: 5px; cursor: pointer; font-weight: bold; }
        .btn-primary:hover { background: #0056b3; }
        .btn-secondary { padding: 10px 20px; background: #6c757d; color: white; border: none; border-radius: 5px; cursor: pointer; font-weight: bold; }
        
        /* Списки */
        .item-list { border: 1px solid #eee; border-radius: 5px; overflow: hidden; margin-bottom: 15px; }
        .item-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 15px; background: #f8f9fa; border-bottom: 1px solid #eee; }
        .item-row:last-child { border-bottom: none; }
        .item-info { display: flex; flex-direction: column; gap: 4px; }
        .item-title { font-weight: bold; font-size: 15px; }
        .item-subtitle { font-size: 13px; color: #666; }
        .action-btns button { background: none; border: none; cursor: pointer; font-size: 16px; padding: 4px; }

        .header { background: white; padding: 15px 30px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); display: flex; justify-content: space-between; align-items: center; }
        .header h1 { margin: 0; font-size: 20px; }
        .back-btn { padding: 8px 15px; background: #e4e6eb; border: none; border-radius: 5px; cursor: pointer; font-weight: bold; color: #333; text-decoration: none; }
        .back-btn:hover { background: #d8dadf; }
        
        .container { max-width: 800px; margin: 30px auto; padding: 0 20px; }
        .settings-card { background: white; border-radius: 8px; padding: 25px; margin-bottom: 25px; box-shadow: 0 2px 6px rgba(0,0,0,0.05); }
        .settings-card h2 { margin-top: 0; border-bottom: 1px solid #eee; padding-bottom: 15px; margin-bottom: 20px; font-size: 18px; }
        
        .setting-group { margin-bottom: 20px; }
        .setting-label { display: block; font-size: 13px; color: #666; font-weight: bold; text-transform: uppercase; margin-bottom: 8px; }
        .input-row { display: flex; gap: 10px; }
        .input-field { flex: 1; padding: 10px; border: 1px solid #ddd; border-radius: 5px; font-size: 15px; outline: none; }
        .input-field:focus { border-color: #007bff; }
        
        .btn-primary { padding: 10px 20px; background: #007bff; color: white; border: none; border-radius: 5px; cursor: pointer; font-weight: bold; }
        .btn-primary:hover { background: #0056b3; }
        .btn-secondary { padding: 10px 20px; background: #6c757d; color: white; border: none; border-radius: 5px; cursor: pointer; font-weight: bold; }
        
        /* Списки */
        .item-list { border: 1px solid #eee; border-radius: 5px; overflow: hidden; margin-bottom: 15px; }
        .item-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 15px; background: #f8f9fa; border-bottom: 1px solid #eee; }
        .item-row:last-child { border-bottom: none; }
        .item-info { display: flex; flex-direction: column; gap: 4px; }
        .item-title { font-weight: bold; font-size: 15px; }
        .item-subtitle { font-size: 13px; color: #666; }
        
        /* Кнопки */
        .user-edit-btn {display:none; padding: 0 6px; cursor: pointer; border: 1px solid #ccc; border-radius: 4px; background: #fff; font-size: 14px; height: 24px; align-items: center; justify-content: center;}


        /* --- МОБИЛЬНАЯ АДАПТАЦИЯ --- */
        @media (max-width: 768px) {
            body {
                flex-direction: column; /* Ставим блоки друг над другом */
            }
            
            /* Предполагаемые классы/id вашей боковой панели. Если у вас они называются иначе (например, #sidebar), замените их */
            .sidebar, #user-list-container {
                width: 100% !important;
                height: 35vh !important; /* Список пользователей занимает 35% высоты */
                border-right: none !important;
                border-bottom: 1px solid #ddd;
            }

            .chat-container, #chat-area {
                width: 100% !important;
                height: 65vh !important; /* Чат занимает остальные 65% */
            }

            /* Делаем шапку чата более компактной */
            .chat-info {
                padding: 10px !important;
            }
            
            /* Уменьшаем шрифты для мобильных */
            .message {
                max-width: 90% !important;
            }
        }