body { font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; background-color: #313338; color: #dbdee1; margin: 0; display: flex; height: 100vh; overflow: hidden; }
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #2b2d31; border-radius: 4px; }
::-webkit-scrollbar-thumb { background: #1a1b1e; border-radius: 4px; }

.auth-container { display: flex; flex: 1; align-items: center; justify-content: center; background: #1e1f22; }
.setup-panel { background: #313338; padding: 32px; border-radius: 5px; width: 440px; box-shadow: 0 2px 10px rgba(0,0,0,0.2); box-sizing: border-box; }
.setup-panel h3 { text-align: center; color: #f2f3f5; margin-top: 0; margin-bottom: 8px; font-size: 24px; }
.setup-panel .subtitle { text-align: center; color: #b5bac1; margin-bottom: 20px; font-size: 15px; }
.input-group { margin-bottom: 15px; }
.input-group label { display: block; color: #b5bac1; font-size: 12px; font-weight: bold; text-transform: uppercase; margin-bottom: 8px; }
.input-group label span { color: #fa777c; }
.setup-panel input, .modal input[type="text"] { width: 100%; padding: 10px; border-radius: 3px; border: none; background: #1e1f22; color: #dbdee1; box-sizing: border-box; outline: none; font-size: 16px; }
.setup-panel button { width: 100%; padding: 12px; margin-top: 10px; border: none; border-radius: 3px; background: #5865F2; color: #fff; font-weight: bold; cursor: pointer; transition: background 0.2s; font-size: 16px; }
.setup-panel button:hover { background: #4752C4; }
.setup-panel button.alt { background: transparent; color: #00a8fc; padding: 0; margin-top: 10px; font-weight: normal; font-size: 14px; text-align: left; }
.setup-panel button.alt:hover { text-decoration: underline; }
.error-msg { color: #fa777c; margin-bottom: 15px; display: none; font-size: 14px; text-align: center; background: rgba(250, 119, 124, 0.1); padding: 8px; border-radius: 4px; }

#appContainer { display: none; flex: 1; width: 100%; }

/* --- Модальные окна и Тосты --- */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); display: none; align-items: center; justify-content: center; z-index: 100; transition: background 0.2s; }
.modal { background: #313338; border-radius: 8px; width: 440px; padding: 24px; box-shadow: 0 8px 16px rgba(0,0,0,0.24); position: relative; display: none; }
.modal h2 { margin-top: 0; margin-bottom: 20px; text-align: center; color: #f2f3f5; }
.modal-close { position: absolute; top: 16px; right: 16px; background: transparent; border: none; color: #80848e; font-size: 20px; cursor: pointer; padding: 4px; transition: color 0.2s; }
.modal-close:hover { color: #dbdee1; }
.modal-buttons { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.btn-primary { padding: 10px 16px; background: #5865F2; color: white; border: none; border-radius: 4px; font-weight: bold; cursor: pointer; transition: background 0.2s; }
.btn-primary:hover { background: #4752C4; }
.btn-secondary { padding: 10px 16px; background: transparent; color: #dbdee1; border: none; font-weight: bold; cursor: pointer; transition: text-decoration 0.2s; }
.btn-secondary:hover { text-decoration: underline; }
.btn-danger { padding: 10px 16px; background: #da373c; color: white; border: none; border-radius: 4px; font-weight: bold; cursor: pointer; transition: background 0.2s; }
.btn-danger:hover { background: #a12828; }

.toast-container { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 1000; pointer-events: none; }
.toast { background: #1e1f22; border-left: 4px solid #23a559; color: #dbdee1; padding: 12px 16px; border-radius: 4px; box-shadow: 0 4px 12px rgba(0,0,0,0.3); font-size: 14px; font-weight: 500; animation: slideIn 0.3s ease-out, fadeOut 0.3s ease-in 2.7s forwards; }
.toast.error { border-left-color: #fa777c; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

/* --- Попап профиля --- */
.user-popout { background: #232428; border-radius: 8px; width: 340px; box-shadow: 0 8px 16px rgba(0,0,0,0.24); position: fixed; display: none; z-index: 101; border: 1px solid #1e1f22; flex-direction: column; }
.popout-banner { height: 60px; background: #23a559; flex-shrink: 0; border-radius: 8px 8px 0 0; }
.popout-avatar-wrapper { width: 80px; height: 80px; border-radius: 50%; background: #1e1f22; border: 6px solid #232428; display: flex; align-items: center; justify-content: center; font-size: 40px; margin-top: -40px; margin-left: 16px; position: relative; user-select: none; }
.popout-status-indicator { width: 16px; height: 16px; background: #23a559; border-radius: 50%; position: absolute; bottom: 0; right: 0; border: 3px solid #232428; }
.popout-body { padding: 16px; background: #111214; margin: 16px; border-radius: 8px; flex: 1; display: flex; flex-direction: column; }
.popout-name-container { margin-bottom: 16px; }
.popout-name { font-size: 20px; font-weight: bold; color: #f2f3f5; word-break: break-all; border-radius: 4px; padding: 2px 4px; margin-left: -4px; min-height: 24px; display: flex; align-items: center; }
.popout-username { font-size: 14px; color: #b5bac1; padding-left: 4px; }
.popout-section { font-size: 12px; font-weight: bold; text-transform: uppercase; color: #f2f3f5; margin-bottom: 8px; border-top: 1px solid #2b2d31; padding-top: 12px; }
.popout-status { font-size: 14px; color: #dbdee1; line-height: 1.4; word-break: break-word; border-radius: 4px; padding: 4px; margin-left: -4px; min-height: 20px; }

.editable { cursor: pointer; transition: background 0.1s; }
.editable:hover { background: #1e1f22; }
.inline-input { background: #1e1f22; border: 1px solid #5865F2; color: #dbdee1; padding: 2px 4px; width: 100%; box-sizing: border-box; border-radius: 4px; outline: none; font-family: inherit; font-size: inherit; font-weight: inherit; }
.avatar-edit-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); border-radius: 50%; display: none; align-items: center; justify-content: center; font-size: 24px; cursor: pointer; color: white; }
.popout-avatar-wrapper.editable:hover .avatar-edit-overlay { display: flex; }
.popout-emoji-picker { display: none; background: #2b2d31; border: 1px solid #1e1f22; border-radius: 8px; margin: 0 16px 16px 16px; padding: 8px; max-height: 150px; overflow-y: auto; flex-wrap: wrap; gap: 4px; justify-content: space-between; }
.emoji-item { font-size: 24px; cursor: pointer; padding: 4px; border-radius: 4px; transition: transform 0.1s; user-select: none; }
.emoji-item:hover { background: #3f4147; transform: scale(1.2); }

/* --- Основной каркас --- */
.servers-bar { width: 72px; background: #1e1f22; display: flex; flex-direction: column; align-items: center; padding-top: 12px; gap: 8px; position: relative; z-index: 10; }
.server-wrapper { position: relative; width: 100%; display: flex; justify-content: center; align-items: center; }
.server-indicator { position: absolute; left: 0; width: 4px; background: #fff; border-radius: 0 4px 4px 0; transition: height 0.2s; height: 0; }
.server-wrapper.active .server-indicator { height: 40px; }
.server-wrapper:hover:not(.active) .server-indicator { height: 20px; }
.server-icon { width: 48px; height: 48px; background: #313338; border-radius: 50%; display: flex; justify-content: center; align-items: center; color: #dbdee1; font-weight: bold; cursor: pointer; transition: all 0.2s ease; font-size: 16px; user-select: none; overflow: hidden; }
.server-wrapper:hover .server-icon, .server-wrapper.active .server-icon { border-radius: 16px; background: #5865F2; color: #fff; }
.server-icon.action-btn { background: #313338; color: #23a559; font-size: 24px; }
.server-wrapper:hover .server-icon.action-btn { background: #23a559; color: #fff; }
.server-separator { width: 32px; height: 2px; background: #35363c; border-radius: 1px; margin: 4px 0; }

.channels-bar { width: 240px; background: #2b2d31; display: flex; flex-direction: column; }
.server-header { height: 48px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #1e1f22; font-weight: bold; color: #f2f3f5; box-sizing: border-box; }
.server-header:hover { background: #35373c; }
.server-header-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.server-header-actions { display: flex; gap: 8px; flex-shrink: 0; }
.header-icon { color: #b5bac1; font-size: 16px; cursor: pointer; transition: color 0.1s; }
.header-icon:hover { color: #dbdee1; }

.channel-list { flex: 1; overflow-y: auto; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; position: relative; }
.channel-item { padding: 6px 8px; border-radius: 4px; cursor: pointer; color: #949ba4; display: flex; justify-content: space-between; align-items: center; font-weight: 500; font-size: 15px; transition: background 0.1s; }
.channel-item-left { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.channel-item-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.channel-settings-btn { display: none; color: #b5bac1; font-size: 14px; padding: 2px 4px; border-radius: 4px; flex-shrink: 0; }
.channel-item:hover .channel-settings-btn { display: block; }
.channel-settings-btn:hover { color: #dbdee1; background: #3f4147; }
.channel-item.dragging { opacity: 0.4; background: #1e1f22; }
.drop-indicator { height: 2px; background-color: #23a559; border-radius: 1px; margin: 0 8px; pointer-events: none; }
.channel-item:hover:not(.dragging) { background: #35373c; color: #dbdee1; }
.channel-item.active:not(.dragging) { background: #404249; color: #f2f3f5; }
.channel-hash { color: #80848e; font-size: 18px; margin-right: 6px; pointer-events: none; }

.user-panel { height: 52px; background: #232428; display: flex; align-items: center; padding: 0 8px; justify-content: space-between; gap: 0; position: relative; }
.user-info { display: flex; align-items: center; cursor: pointer; padding: 4px; border-radius: 4px; flex: 1; min-width: 0; transition: background 0.1s; margin-right: 8px; }
.user-info:hover { background: #3f4147; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: #2b2d31; margin-right: 8px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; position: relative; user-select: none; }
.user-status-dot { width: 10px; height: 10px; background: #23a559; border-radius: 50%; position: absolute; bottom: -2px; right: -2px; border: 2px solid #232428; }
.user-details { display: flex; flex-direction: column; min-width: 0; }
.user-name { color: #f2f3f5; font-size: 13px; font-weight: bold; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-status { color: #b5bac1; font-size: 11px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-controls { display: flex; color: #b5bac1; font-size: 16px; flex-shrink: 0; gap: 0; }
.control-icon { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: 4px; color: #80848e; font-size: 18px; cursor: pointer; transition: background 0.1s; }
.control-icon:hover { background: #3f4147; color: #dbdee1; }

/* --- Чат --- */
.chat-area { flex: 1; background: #313338; display: flex; flex-direction: column; min-width: 0; position: relative; }
.chat-area.drag-over::after { content: 'Отпустите файлы для отправки'; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(88, 101, 242, 0.85); color: white; display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: bold; z-index: 1000; pointer-events: none; border-radius: 8px; }

.chat-header { height: 48px; padding: 0 16px; display: flex; align-items: center; border-bottom: 1px solid #1e1f22; font-weight: bold; color: #f2f3f5; box-sizing: border-box; }
.chat-header .hash { color: #80848e; font-size: 24px; margin-right: 8px; font-weight: normal; }

.messages { flex: 1; overflow-y: auto; padding: 16px 0; display: flex; flex-direction: column; }
.date-separator { display: flex; align-items: center; justify-content: center; margin: 16px 16px 8px 16px; position: relative; }
.date-separator::before { content: ''; position: absolute; left: 0; right: 0; height: 1px; background: #35363c; z-index: 1; }
.date-separator-text { background: #313338; padding: 0 8px; color: #949ba4; font-size: 12px; font-weight: 600; z-index: 2; border-radius: 4px; }

.message { padding: 4px 16px 4px 72px; position: relative; display: flex; flex-direction: column; margin-top: 16px; }
.message.compact { margin-top: 0; padding-top: 2px; padding-bottom: 2px; }
.message:hover { background: #2e3035; }
.message-avatar-wrap { position: absolute; left: 16px; top: 4px; width: 40px; height: 40px; border-radius: 50%; background: #2b2d31; display: flex; align-items: center; justify-content: center; font-size: 24px; cursor: pointer; transition: transform 0.1s; }
.message-avatar-wrap:hover { transform: scale(1.05); }
.compact .message-avatar-wrap { display: none; }
.message-header { display: flex; align-items: baseline; gap: 8px; line-height: 1.2; margin-bottom: 2px; }
.compact .message-header { display: none; }
.message-header .sender { font-weight: 500; color: #f2f3f5; font-size: 16px; cursor: pointer; }
.message-header .sender:hover { text-decoration: underline; }
.message-header .timestamp { font-size: 12px; color: #949ba4; }
.compact-timestamp { position: absolute; left: 8px; top: 4px; font-size: 11px; color: #949ba4; display: none; width: 50px; text-align: right; user-select: none; }
.message.compact:hover .compact-timestamp { display: block; }
.message-text { color: #dbdee1; font-size: 15px; line-height: 1.375rem; word-break: break-word; }
.markdown-code { background: #1e1f22; padding: 2px 4px; border-radius: 3px; font-family: Consolas, monospace; }

.message-text a { color: #00a8fc; text-decoration: none; }
.message-text a:hover { text-decoration: underline; }

/* --- Медиа вложения --- */
.attachment-container { margin-top: 8px; max-width: 400px; }
.attachment-image { max-width: 100%; max-height: 350px; border-radius: 8px; cursor: zoom-in; border: 1px solid #1e1f22; object-fit: contain; background: #2b2d31; }
.attachment-video { max-width: 100%; max-height: 350px; border-radius: 8px; outline: none; background: #000; }
.attachment-audio { width: 100%; height: 40px; outline: none; border-radius: 20px; }
.attachment-file { background: #2b2d31; padding: 12px 16px; border-radius: 8px; border: 1px solid #1e1f22; display: flex; align-items: center; gap: 12px; width: fit-content; max-width: 100%; box-sizing: border-box; }
.attachment-file-icon { font-size: 24px; display: flex; align-items: center; justify-content: center; background: #1e1f22; border-radius: 4px; padding: 10px; }
.attachment-file-details { display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.attachment-file a { color: #00a8fc; text-decoration: none; font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
.attachment-file a:hover { text-decoration: underline; }

/* Модалка для просмотра картинок */
.image-modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); display: none; align-items: center; justify-content: center; z-index: 1000; cursor: zoom-out; opacity: 0; transition: opacity 0.2s ease; }
.image-modal-overlay.show { opacity: 1; display: flex; }
.image-modal-content { max-width: 90vw; max-height: 90vh; border-radius: 4px; box-shadow: 0 8px 24px rgba(0,0,0,0.5); object-fit: contain; cursor: default; }

/* Кнопки действий (Корзина, Редактировать) */
.actions { display: none; position: absolute; right: 16px; top: -16px; background: #313338; border: 1px solid #1e1f22; border-radius: 4px; overflow: hidden; box-shadow: 0 0 4px rgba(0,0,0,0.1); z-index: 10; }
.message:hover .actions { display: flex; }
.actions button { background: transparent; border: none; color: #b5bac1; cursor: pointer; padding: 6px 10px; font-size: 14px; line-height: 1; outline: none; transition: 0.1s; }
.actions button:hover { background: #404249; color: #dbdee1; }

/* --- Ввод сообщений --- */
.input-area { padding: 0 16px 24px 16px; display: flex; flex-direction: column; position: relative; }
.input-wrapper { background: #383a40; border-radius: 8px; display: flex; align-items: center; padding: 0 16px; position: relative; }
.attach-btn { display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: #b5bac1; color: #383a40; font-size: 20px; font-weight: bold; cursor: pointer; margin-right: 12px; flex-shrink: 0; transition: background 0.2s; user-select: none; }
.attach-btn:hover { background: #dbdee1; }
.input-wrapper input[type="text"] { flex: 1; padding: 15px 0; border: none; background: transparent; color: #dbdee1; outline: none; font-size: 15px; }

/* --- Предпросмотр загружаемого файла --- */
.file-preview { display: none; background: #2b2d31; padding: 12px; border-radius: 8px 8px 0 0; margin: 0 16px; border: 1px solid #1e1f22; border-bottom: none; align-items: center; justify-content: space-between; position: relative; }
.file-preview-content { display: flex; align-items: center; gap: 12px; overflow: hidden; }
.file-preview-image { display: none; width: 60px; height: 60px; object-fit: cover; border-radius: 4px; background: #1e1f22; }
.file-preview-info { color: #dbdee1; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-preview-remove { cursor: pointer; color: #fa777c; font-weight: bold; background: rgba(250, 119, 124, 0.1); padding: 6px 10px; border-radius: 4px; transition: 0.2s; font-size: 13px; }
.file-preview-remove:hover { background: rgba(250, 119, 124, 0.2); }

.members-bar { width: 240px; background: #2b2d31; display: flex; flex-direction: column; padding: 16px 8px; box-sizing: border-box; border-left: 1px solid #1e1f22; }
.members-group { color: #949ba4; font-size: 12px; font-weight: 600; text-transform: uppercase; margin-bottom: 8px; padding-left: 8px; }
.member-item { display: flex; align-items: center; padding: 6px 8px; border-radius: 4px; cursor: pointer; opacity: 0.5; transition: background 0.1s; }
.member-item:hover { background: #35373c; color: #dbdee1; opacity: 1; }
.member-avatar { width: 32px; height: 32px; border-radius: 50%; background: #2b2d31; margin-right: 12px; display: flex; justify-content: center; align-items: center; font-size: 20px; position: relative; }
.member-name { color: #949ba4; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.channel-category { color: #949ba4; font-size: 12px; font-weight: 600; text-transform: uppercase; padding: 12px 8px 4px 8px; display: flex; justify-content: space-between; align-items: center; }
.add-channel-btn { cursor: pointer; font-size: 16px; font-weight: normal; }
.add-channel-btn:hover { color: #dbdee1; }

.typing-indicator { height: 20px; font-size: 12px; color: #949ba4; font-weight: 500; margin-bottom: 4px; padding-left: 4px; pointer-events: none; }
.empty-state { display: flex; flex: 1; align-items: center; justify-content: center; color: #949ba4; font-size: 16px; }