        /* Font Awesome optimization - не блокируем рендеринг при загрузке шрифта */
        @font-face {
            font-family: 'Font Awesome 6 Free';
            font-display: swap; /* Показываем текст сразу, шрифт подгрузится позже */
        }
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        html {
            height: 100%;        /* NEW: required for full-viewport vertical layout */
        }
        
        body {
            font-family: var(--font-primary);
            font-size: var(--text-base);
            font-weight: var(--font-weight-regular);
            line-height: 1.6;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
            background: var(--color-bg-main); /* Remove purple gradient, use white */
            margin: 0;
            padding: 0;
            color: var(--color-text-primary);
            overflow: hidden; /* Prevent body scrolling */
            height: 100%;        /* NEW: required for full-viewport vertical layout */
        }

        /* Сохранить моноширинный шрифт для кода */
        code, pre, .code-block {
            font-family: var(--font-mono) !important;
        }
        
        /* Global tooltip */
        .app-tooltip {
            position: fixed;
            z-index: 9999;
            pointer-events: none;
            background: rgba(17, 24, 39, 0.92);
            color: var(--color-bg-main);
            font-size: 12px;
            line-height: 1.4;
            border-radius: 6px;
            box-shadow: 0 10px 28px rgba(15, 23, 42, 0.18);
            opacity: 0;
            visibility: hidden;
            transition: opacity 0.12s ease;
            max-width: 280px;
            text-align: center;
            word-break: break-word;
            white-space: normal;
            padding: 8px 12px;
            top: -9999px;
            left: -9999px;
        }
        
        .app-tooltip.visible {
            opacity: 1;
            visibility: visible;
        }
        
        .app-tooltip::after {
            content: '';
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
            border-width: 6px;
            border-style: solid;
            border-color: rgba(17, 24, 39, 0.92) transparent transparent transparent;
        }
        
        .app-tooltip.is-bottom::after {
            top: auto;
            bottom: 100%;
            border-color: transparent transparent rgba(17, 24, 39, 0.92) transparent;
        }
        
        .app-tooltip:not(.is-bottom)::after {
            top: 100%;
        }
        
        
        .container {
            max-width: none; /* Remove max-width constraint */
            margin: 0; /* Remove margins */
            padding: 0; /* Remove padding */
            height: 100%;        /* NEW */
            display: flex;
            flex-direction: column;
            overflow: hidden; /* Prevent container scrolling */
        }
        
        
        /* Статус сообщений */
        .status {
            padding: 15px;
            border-radius: 8px;
            margin: 0;
            text-align: center;
            font-weight: bold;
            display: none;
            position: absolute;
            top: 20px;
            left: 50%;
            transform: translateX(-50%);
            z-index: 1500;
            max-width: 90%;
            box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        }
        
        .status.info {
            background: rgba(59, 130, 246, 0.1);
            color: var(--color-info);
            border: 1px solid rgba(59, 130, 246, 0.3);
        }
        
        .status.success {
            background: rgba(16, 185, 129, 0.1);
            color: var(--color-success);
            border: 1px solid rgba(16, 185, 129, 0.3);
        }
        
        .status.error {
            background: rgba(239, 68, 68, 0.1);
            color: var(--color-error);
            border: 1px solid rgba(239, 68, 68, 0.3);
        }
        
        /* 📎 File Upload Styles - добавить в существующий <style> блок */

        /* Drag & Drop Overlay */
        .file-drop-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(102, 126, 234, 0.1);
            backdrop-filter: blur(4px);
            z-index: 9999;
            display: none;
            justify-content: center;
            align-items: center;
            flex-direction: column;
            color: var(--color-primary);
            font-size: 24px;
            font-weight: 600;
            pointer-events: none;
        }

        .file-drop-overlay.active {
            display: flex;
        }

        .file-drop-text {
            margin-bottom: 10px;
        }

        .file-drop-icon {
            font-size: 48px;
            margin-bottom: 20px;
        }


        /* Анимация для активного поиска */
        .web-search-btn.searching {
            animation: pulse 1.5s infinite;
        }

        @keyframes pulse {
            0% {
                box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.7);
            }
            70% {
                box-shadow: 0 0 0 10px rgba(102, 126, 234, 0);
            }
            100% {
                box-shadow: 0 0 0 0 rgba(102, 126, 234, 0);
            }
        }

        /* Loading dots animation for Perplexity search */
        .loading-dots span {
            animation: loadingDots 1.4s infinite ease-in-out both;
        }

        .loading-dots span:nth-child(1) {
            animation-delay: -0.32s;
        }

        .loading-dots span:nth-child(2) {
            animation-delay: -0.16s;
        }

        .loading-dots span:nth-child(3) {
            animation-delay: 0s;
        }

        @keyframes loadingDots {
            0%, 80%, 100% {
                transform: scale(0);
                opacity: 0.5;
            }
            40% {
                transform: scale(1);
                opacity: 1;
            }
        }

        /* Error message styling for Perplexity */
        .error-message {
            background: rgba(239, 68, 68, 0.1);
            border: 1px solid rgba(239, 68, 68, 0.3);
            color: var(--color-error);
            padding: 12px;
            border-radius: 8px;
            margin: 8px 0;
        }

        .error-message small {
            color: var(--color-error);
            font-size: 0.85em;
            opacity: 0.8;
        }

        /* Processing Status */
        .file-processing {
            display: none;
            align-items: center;
            background: rgba(245, 158, 11, 0.1);
            border: 1px solid rgba(245, 158, 11, 0.3);
            border-radius: 8px;
            padding: 8px 12px;
            margin-bottom: 10px;
            font-size: 14px;
            color: var(--color-warning);
        }

        .file-processing.active {
            display: flex;
        }

        .processing-spinner {
            width: 16px;
            height: 16px;
            border: 2px solid rgba(245, 158, 11, 0.3);
            border-top: 2px solid var(--color-warning);
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin-right: 8px;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        /* Message with file attachment indicator */
        .message-with-file::before {
            content: "📎";
            font-size: 12px;
            opacity: 0.7;
            margin-right: 4px;
        }

        /* Hidden file input */
        .file-input-hidden {
            display: none;
        }
        
        /* Интерфейс аутентификации */
        .auth-interface {
            display: none; /* Скрыт по умолчанию, показывается только при необходимости */
            background: rgba(255, 255, 255, 0.95);
            border-radius: 16px;
            padding: 40px;
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
            backdrop-filter: blur(10px);
            max-width: 500px;
            margin: 0 auto;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            z-index: 2000;
        }
        
        .auth-tabs {
            display: flex;
            margin-bottom: 30px;
            border-radius: 8px;
            overflow: hidden;
            border: 1px solid var(--color-border-thin);
        }
        
        .auth-tab {
            flex: 1;
            padding: 15px;
            background: var(--color-bg-sidebar);
            text-align: center;
            cursor: pointer;
            transition: all 0.3s ease;
            font-weight: 500;
        }
        
        .auth-tab.active {
            background: var(--color-primary);
            color: var(--color-bg-main);
        }
        
        .auth-form {
            display: none;
        }
        
        .auth-form.active {
            display: block;
        }
        
        .form-group {
            margin-bottom: 20px;
        }
        
        .form-group label {
            display: block;
            margin-bottom: 8px;
            font-weight: 500;
            color: var(--color-text-secondary);
        }
        
        .form-group input {
            width: 100%;
            padding: 12px 16px;
            border: 2px solid var(--color-border-thin);
            border-radius: 8px;
            font-size: 16px;
            transition: border-color 0.3s ease;
        }
        
        .form-group input:focus {
            outline: none;
            border-color: var(--color-primary);
        }
        
        .btn-primary {
            width: 100%;
            padding: 14px;
            background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-image) 100%);
            color: var(--color-bg-main);
            border: none;
            border-radius: 8px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: transform 0.2s ease;
        }
        
        .btn-primary:hover {
            transform: translateY(-2px);
        }
        
        .btn-primary:disabled {
            opacity: 0.6;
            cursor: not-allowed;
            transform: none;
        }
        
        /* OAuth Buttons */
        .oauth-buttons {
            margin-bottom: 20px;
        }
        
        .oauth-btn {
            width: 100%;
            padding: 14px;
            border: 2px solid var(--color-border-thin);
            border-radius: 8px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 12px;
            background: var(--color-bg-main);
            color: var(--color-text-primary);
        }
        
        .oauth-btn:hover {
            background: var(--color-bg-sidebar);
            border-color: var(--color-primary);
            transform: translateY(-2px);
        }
        
        .oauth-btn:active {
            transform: translateY(0);
        }
        
        .oauth-btn svg {
            flex-shrink: 0;
        }
        
        .google-btn {
            /* Google button specific styles if needed */
        }
        
        .yandex-btn {
            margin-top: 12px;
        }
        
        .yandex-btn:hover {
            border-color: var(--color-error);
        }
        
        /* OAuth Separator */
        .oauth-separator {
            display: flex;
            align-items: center;
            text-align: center;
            margin: 24px 0;
            color: var(--color-text-muted);
        }
        
        .oauth-separator::before,
        .oauth-separator::after {
            content: '';
            flex: 1;
            border-bottom: 1px solid var(--color-border-thin);
        }
        
        .oauth-separator span {
            padding: 0 16px;
            font-size: 14px;
            color: var(--color-text-muted);
        }
        
        /* Интерфейс чата */
        .chat-interface {
            display: none;
            flex: 1;
            background: var(--color-bg-main);
            border-radius: 0; /* Remove border radius for fullscreen */
            overflow: hidden;
            box-shadow: none; /* Remove shadow for fullscreen */
            backdrop-filter: none; /* Remove backdrop filter for fullscreen */
            height: 100%;        /* NEW */
            width: 100vw; /* Full viewport width */
            position: absolute;
            top: 0;
            left: 0;
        }
        
        .chat-interface.active {
            display: flex;
            flex-direction: row;
        }
        
        
        
        
        
        
        
        
        
        /* Основная область чата */
        .chat-main {
            flex: 1;
            display: flex;
            flex-direction: column;
            height: 100%;        /* NEW: chat-main must fill full vertical space */
            position: relative;  /* NEW: required for messages-container absolute layout */
            overflow: hidden; /* Prevent main container from scrolling */
            width: calc(100vw - 300px); /* Full width minus sidebar */
        }
        
        .chat-header {
            padding: 6px 10px 6px 20px;
            margin: 1px 8px 1px 8px;
            border-bottom: 1px solid var(--color-border-thin);
            background: var(--color-bg-main);
            display: flex;
            justify-content: space-between; /* Левая часть слева, правая справа */
            align-items: center;
            flex-shrink: 0;
            min-height: 32px;
            border-radius: 6px;
            position: relative;
            height: 44px;
            box-sizing: border-box;
        }

        .chat-header::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            height: 1px;
            background: var(--color-border-thin);
        }

        /* LEFT SIDE: Title + Menu button together */
        .chat-header-left {
            display: flex;
            align-items: center;
            gap: 4px;
            flex-shrink: 1;
            min-width: 0;
            max-width: 600px; /* Ограничиваем максимум */
        }

        /* Chat title */
        .chat-header .chat-title {
            font-size: 14px;
            font-weight: 600;
            color: var(--color-text-primary);
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            flex-shrink: 1;
            min-width: 0;
        }

        /* Chat menu button - сразу после названия */
        .chat-menu-btn {
            background: none;
            border: none;
            color: var(--color-text-secondary);
            cursor: pointer;
            padding: 4px;
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 6px;
            transition: all 0.15s ease;
            flex-shrink: 0; /* Кнопка не сжимается */
        }

        .chat-menu-btn:hover {
            background-color: var(--color-bg-hover);
            color: var(--color-text-primary);
        }

        .chat-menu-btn svg {
            width: 16px;
            height: 16px;
        }

        /* RIGHT SIDE: User menu (Settings) */
        .user-menu {
            display: flex;
            align-items: center;
            gap: 15px;
            margin-left: auto; /* Прижимаем к правому краю */
        }
        
        /* ============================================
           MOBILE HEADER BUTTONS (Hamburger & New Chat)
           ============================================ */
        
        /* Hamburger Menu Button */
        .hamburger-btn {
            display: none; /* Hidden by default (desktop) */
            align-items: center;
            justify-content: center;
            width: 32px;
            height: 32px;
            background: transparent;
            border: none;
            border-radius: 6px;
            color: var(--color-text-secondary);
            cursor: pointer;
            transition: all 0.15s ease;
            flex-shrink: 0;
            padding: 0;
        }
        
        .hamburger-btn:hover {
            background-color: var(--color-bg-hover);
            color: var(--color-text-primary);
        }
        
        .hamburger-btn svg {
            width: 16px;
            height: 16px;
        }
        
        /* New Chat Header Button */
        .new-chat-header-btn {
            display: none; /* Hidden by default (desktop) */
            align-items: center;
            justify-content: center;
            width: 32px;
            height: 32px;
            background: transparent;
            border: none;
            border-radius: 6px;
            color: var(--color-text-secondary);
            cursor: pointer;
            transition: all 0.15s ease;
            flex-shrink: 0;
            padding: 0;
        }
        
        .new-chat-header-btn:hover {
            background-color: var(--color-bg-hover);
            color: var(--color-text-primary);
        }
        
        .new-chat-header-btn svg {
            width: 16px;
            height: 16px;
        }
        
        /* Layout Toggle Button (existing style reference) */
        .layout-toggle-btn {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 32px;
            height: 32px;
            background: transparent;
            border: none;
            border-radius: 6px;
            color: var(--color-text-secondary);
            cursor: pointer;
            transition: all 0.15s ease;
            flex-shrink: 0;
            padding: 0;
        }
        
        .layout-toggle-btn:hover {
            background-color: var(--color-bg-hover);
            color: var(--color-text-primary);
        }
        
        .layout-toggle-btn svg {
            width: 16px;
            height: 16px;
        }
        
        /* User Dropdown Styles */
        .user-dropdown {
            position: relative;
        }
        
        .user-dropdown-trigger {
            display: flex;
            align-items: center;
            gap: 8px;
            background: var(--color-bg-sidebar);
            border: 1px solid var(--color-border-thin);
            border-radius: 8px;
            padding: 8px 12px;
            cursor: pointer;
            font-size: 14px;
            color: var(--color-text-primary);
            transition: all 0.2s ease;
            min-width: 140px;
            justify-content: space-between;
        }
        
        .user-dropdown-trigger:hover {
            background: var(--color-bg-hover);
            border-color: var(--color-primary);
            box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
        }
        
        .user-dropdown-trigger i {
            color: var(--color-text-secondary);
            font-size: 12px;
            transition: transform 0.2s ease;
        }
        
        .user-dropdown.open .user-dropdown-trigger i {
            transform: rotate(180deg);
        }
        
        .user-dropdown-menu {
            position: absolute;
            top: 100%;
            right: 0;
            background: rgba(255, 255, 255, 0.95);
            border: 1px solid var(--color-border-thin);
            border-radius: 12px;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
            min-width: 200px;
            z-index: 1000;
            opacity: 0;
            visibility: hidden;
            transform: translateY(-8px);
            transition: all 0.2s ease;
            backdrop-filter: blur(10px);
            margin-top: 8px;
            border: 1px solid rgba(224, 224, 224, 0.8);
        }
        
        .user-dropdown-menu::before {
            content: '';
            position: absolute;
            top: -6px;
            right: 20px;
            width: 12px;
            height: 12px;
            background: rgba(255, 255, 255, 0.95);
            border-left: 1px solid rgba(224, 224, 224, 0.8);
            border-top: 1px solid rgba(224, 224, 224, 0.8);
            transform: rotate(45deg);
            z-index: -1;
        }
        
        .user-dropdown.open .user-dropdown-menu {
            opacity: 1;
            visibility: visible;
            transform: translateY(0);
        }
        
        .dropdown-item {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 12px 16px;
            cursor: pointer;
            transition: all 0.2s ease;
            color: var(--color-text-primary);
            font-size: 14px;
            position: relative;
            overflow: hidden;
        }
        
        .dropdown-item::before {
            content: '';
            position: absolute;
            left: 0;
            top: 0;
            height: 100%;
            width: 0;
            background: linear-gradient(90deg, rgba(102, 126, 234, 0.1), transparent);
            transition: width 0.2s ease;
        }
        
        .dropdown-item:hover::before {
            width: 100%;
        }
        
        .dropdown-item:hover {
            background: var(--color-bg-hover);
        }
        
        .dropdown-item i {
            width: 16px;
            color: var(--color-text-secondary);
        }
        
        .dropdown-divider {
            height: 1px;
            background: var(--color-border-thin);
            margin: 4px 0;
        }
        
        .logout-item {
            color: var(--color-danger);
        }
        
        .logout-item:hover {
            background: rgba(239, 68, 68, 0.1);
        }
        
        .logout-item i {
            color: var(--color-danger);
        }
        
        
        /* Адаптивность */
        @media (max-width: 768px) {
            /* Выключаем 100vh на мобильных - используем 100dvh с !important */
            .container,
            .chat-interface,
            .chat-main {
                height: 100dvh !important;
                min-height: 100dvh !important;
                max-height: 100dvh !important;
            }
            
            .container {
                padding: 0;
            }
            
            .chat-sidebar {
                display: none;
            }
            
            .chat-interface.active {
                flex-direction: column;
            }
            
            /* Решаем проблему ширины - Chrome считает calc(100vw - 300px) шире экрана */
            .chat-main {
                width: 100% !important;
                /* На mobile оставляем overflow: hidden, скроллится только messages-container */
                overflow: hidden;
            }
            
            /* input-area должна быть fixed на мобиле - только CSS, без JS */
            .input-area {
                position: fixed !important;
                bottom: 0 !important;
                left: 0;
                right: 0;
                width: 100%;
                z-index: 9999;
                margin: 0 !important;
                padding: 0 !important;
                padding-bottom: calc(env(safe-area-inset-bottom, 0) + 6px) !important;
            }
            
            /* Убираем padding-bottom из input-wrapper на мобильных */
            .input-wrapper {
                padding-bottom: 0 !important;
            }
            
            /* messages-container должен быть между header и input-area */
            .messages-container {
                position: absolute;
                top: calc(44px + env(safe-area-inset-top, 0));
                bottom: calc(100px + env(safe-area-inset-bottom, 0)); /* Увеличено с 80px до 100px для предотвращения перекрытия */
                left: 0;
                right: 0;
                overflow-y: auto;
                -webkit-overflow-scrolling: touch;
                padding-bottom: 100px !important; /* Дополнительный padding для кнопок действий */
            }
            
            /* ============================================
               MOBILE HEADER ADAPTATIONS
               ============================================ */
            
            /* Убеждаемся что header всегда вверху и виден */
            .chat-header {
                position: fixed;
                top: env(safe-area-inset-top, 0);
                left: 0;
                right: 0;
                z-index: 10000;
                flex-shrink: 0;
                background: var(--color-bg-main);
                padding: 6px 12px 6px 3px; /* Левый padding: 6px → 3px */
                gap: 8px;
            }
            
            /* Show hamburger menu button on mobile */
            .hamburger-btn {
                display: flex !important;
            }
            
            /* Show New Chat button on mobile - синий стиль как в sidebar */
            .new-chat-header-btn {
                display: flex !important;
                background: var(--color-primary) !important;
                color: var(--color-bg-main) !important;
            }
            
            .new-chat-header-btn:hover {
                background: var(--color-primary-hover) !important;
                color: var(--color-bg-main) !important;
            }
            
            /* Hide chat title on mobile (free up space) */
            .chat-header .chat-title {
                display: none;
            }
            
            /* Hide chat menu button on mobile (dropdown with ...) */
            .chat-menu-btn {
                display: none;
            }
            
            .chat-header-left {
                gap: 8px;
            }
            
            .user-menu {
                gap: 2px; /* Gap: 4px → 2px - layout очень близко к new chat */
            }
            
            
            .model-dropdown-menu {
                min-width: 260px;
                left: -50px;
                right: -50px;
            }
            
            .model-option {
                padding: 10px 14px;
            }
            
            .model-option .model-name {
                font-size: 13px;
            }
            
            .model-option .model-description {
                font-size: 11px;
            }
        }

        @media (max-width: 950px) {
            .input-area {
                position: fixed !important;
                bottom: 0 !important;
                left: 0;
                right: 0;
                width: 100%;
                z-index: 9999;
                margin: 0 !important;
                padding: 0 !important;
                padding-bottom: calc(env(safe-area-inset-bottom, 0) + 6px) !important;
            }
            
            /* Убираем padding-bottom из input-wrapper на мобильных */
            .input-wrapper {
                padding-bottom: 0 !important;
            }

            .messages-container {
                position: absolute;
                top: calc(44px + env(safe-area-inset-top, 0));
                bottom: calc(100px + env(safe-area-inset-bottom, 0)); /* Увеличено с 80px до 100px для предотвращения перекрытия */
                left: 0;
                right: 0;
                padding-bottom: 100px !important; /* Дополнительный padding для кнопок действий */
            }
        }

        .retry-button {
            background: none;
            color: var(--color-error);
            border: 1px solid rgba(239, 68, 68, 0.3);
            padding: 6px 12px;
            border-radius: 6px;
            font-size: 12px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s ease;
            min-width: 120px;
        }

        .retry-button:hover {
            background: rgba(239, 68, 68, 0.1);
        }

        .message-error-text {
            color: var(--color-error);
            font-weight: 500;
        }

        /* 🆕 Стили для индикатора режима продолжения */
        .continuation-indicator {
            display: flex;
            justify-content: space-between;
            align-items: center;
            background: rgba(59, 130, 246, 0.1);
            border: 1px solid var(--color-primary);
            border-radius: 8px;
            padding: 8px 12px;
            margin-bottom: 12px;
            max-width: 1200px;
            margin-left: auto;
            margin-right: auto;
        }
        
        .continuation-info {
            display: flex;
            align-items: center;
            gap: 8px;
            color: var(--color-primary);
            font-size: 13px;
            font-weight: 500;
        }
        
        .continuation-info i {
            font-size: 14px;
        }
        

        

        /* Citations Styles для Perplexity - выглядит как обычный текст */
        .citation-link {
            color: inherit; /* Тот же цвет что и у текста */
            text-decoration: none;
            font-weight: normal; /* Обычная толщина шрифта */
            padding: 0;
            border-radius: 0;
            cursor: pointer; /* Показываем что это кликабельно */
        }

        .citation-link:hover {
            background-color: transparent; /* Убираем фон при наведении */
            text-decoration: none; /* Убираем подчеркивание */
            color: inherit; /* Цвет остается тот же */
        }

        .citations-container {
            margin-top: 15px;
            padding: 15px;
            background: linear-gradient(135deg, var(--color-bg-sidebar) 0%, var(--color-bg-hover) 100%);
            border-radius: 8px;
            border-left: 3px solid var(--color-info);
        }

        .citations-title {
            font-size: 14px;
            font-weight: 600;
            color: var(--color-text-primary);
            margin-bottom: 10px;
        }

        .citations-title::before {
            content: '📚 ';
        }

        .citation-item {
            display: flex;
            align-items: flex-start;
            gap: 8px;
            margin-bottom: 8px;
            padding: 8px;
            background: var(--color-bg-main);
            border-radius: 5px;
        }

        .citation-number {
            min-width: 24px;
            height: 24px;
            background: var(--color-info);
            color: var(--color-bg-main);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 12px;
            font-weight: bold;
        }

        .citation-url {
            flex: 1;
            color: var(--color-text-secondary);
            text-decoration: none;
            font-size: 13px;
            word-break: break-word;
        }

        .citation-url:hover {
            color: var(--color-info);
            text-decoration: underline;
        }

        /* Citations row styles - выглядит как обычный текст */
        .citations-row {
            margin-top: 8px; /* 🆕 Уменьшаем отступ сверху для предотвращения наложения */
            padding: 0; /* Убираем отступы */
            background: transparent; /* Убираем фон */
            border-radius: 0; /* Убираем скругления */
            font-size: inherit; /* Тот же размер что и у текста */
            color: inherit; /* Тот же цвет что и у текста */
        }

        .citation-button {
            color: inherit; /* Тот же цвет что и у текста */
            text-decoration: none;
            font-weight: normal; /* Обычная толщина шрифта */
            margin: 0;
            padding: 0;
            border-radius: 0;
            cursor: pointer; /* Показываем что это кликабельно */
        }

        .citation-button:hover {
            background-color: transparent; /* Убираем фон при наведении */
            text-decoration: none; /* Убираем подчеркивание */
            color: inherit; /* Цвет остается тот же */
        }

        .editing-source {
            border: 3px solid var(--color-success) !important;
            box-shadow: 0 0 15px rgba(16, 185, 129, 0.4);
        }
        
        /* Специальный стиль для выделения только изображения */
        .message-image img.editing-source {
            border: 3px solid var(--color-success) !important;
            box-shadow: 0 0 15px rgba(16, 185, 129, 0.4);
        }

        .edit-button {
            transition: all 0.3s ease;
        }

        .edit-button.editing-active {
            background: var(--color-error) !important;
            color: var(--color-bg-main) !important;
            border-color: var(--color-error) !important;
            box-shadow: 0 0 8px rgba(255, 68, 68, 0.4);
        }

        .edit-button:hover {
            background: var(--color-bg-hover);
            transform: translateY(-1px);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        }
        

/* ============================================ */
/* CONVERSATION MENU (Three Dots) - Flat UI */
/* ============================================ */


/* Three dots button */
.conversation-menu-btn {
  opacity: 0;
  background: none;
  border: none;
  font-size: 18px;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 8px;
  margin-left: 4px;
  transition: opacity 0.15s, color 0.15s, background-color 0.15s;
  flex-shrink: 0;
  line-height: 1;
  border-radius: 4px;
  min-width: 32px;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}


.conversation-menu-btn:hover {
  color: var(--color-text-secondary);
  background-color: var(--color-bg-hover);
}

/* Dropdown Menu - Flat UI */
.conversation-menu {
  position: fixed;
  background: var(--color-bg-main);
            border: 1px solid var(--color-border-main);
  border-radius: 6px;
  padding: 4px 0;
  min-width: 140px;
  z-index: 10000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

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

.conversation-menu-item:hover {
  background-color: var(--color-bg-hover);
}

.conversation-menu-item.delete-item {
            color: var(--color-error);
}

.conversation-menu-item.delete-item:hover {
  background-color: rgba(239, 68, 68, 0.1);
}

.menu-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.menu-text {
  flex: 1;
  font-weight: 500;
}

/* ============================================ */
/* DELETE CONFIRMATION MODAL - Flat UI */
/* ============================================ */

.delete-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  animation: fadeIn 0.2s;
}

.delete-modal {
  background: var(--color-bg-main);
  border-radius: 12px;
  padding: 24px;
  max-width: 420px;
  width: 90%;
  animation: slideIn 0.2s;
}

.delete-modal-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 12px 0;
            color: var(--color-text-heading);
}

.delete-modal-message {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin: 0 0 24px 0;
  line-height: 1.5;
}

.delete-modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.delete-modal-cancel,
.delete-modal-confirm {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s;
}

.delete-modal-cancel {
            background-color: var(--color-bg-sidebar);
  color: var(--color-text-primary);
}

.delete-modal-cancel:hover {
  background-color: var(--color-bg-hover);
}

.delete-modal-confirm {
            background-color: var(--color-error);
  color: var(--color-bg-main);
}

.delete-modal-confirm:hover {
            background-color: var(--color-error);
}

/* ============================================ */
/* UNIFIED NOTIFICATION SYSTEM - Flat UI */
/* ============================================ */

.status-notification {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--color-bg-main);
  padding: 8px 24px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
  z-index: 100000;
  animation: slideDown 0.3s;
  min-width: 200px;
  max-width: 400px;
}

.status-notification.status-success {
            background-color: var(--color-success);
}

.status-notification.status-error {
            background-color: var(--color-error);
}

.status-notification.status-warning {
            background-color: var(--color-warning);
}

.status-notification.status-info {
            background-color: var(--color-info);
}

.success-notification {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
            background-color: var(--color-success);
  color: var(--color-bg-main);
  padding: 8px 24px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
  z-index: 100000;
  animation: slideDown 0.3s;
}

.success-icon {
  width: 20px;
  height: 20px;
            background-color: var(--color-bg-main);
            color: var(--color-success);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 14px;
  flex-shrink: 0;
}

.status-icon {
  width: 20px;
  height: 20px;
            background-color: var(--color-bg-main);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  flex-shrink: 0;
}

.status-notification.status-success .status-icon {
            color: var(--color-success);
}

.status-notification.status-error .status-icon {
            color: var(--color-error);
}

.status-notification.status-warning .status-icon {
            color: var(--color-warning);
}

.status-notification.status-info .status-icon {
            color: var(--color-info);
}

.status-notification.fade-out,
.success-notification.fade-out {
  animation: fadeOut 0.3s forwards;
}

/* ============================================ */
/* ANIMATIONS */
/* ============================================ */

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

@keyframes slideIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translate(-50%, -20px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

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

/* ============================================ */
/* RENAME MODAL (дополнение к delete modal) */
/* ============================================ */

.rename-modal {
  max-width: 480px;
}

.rename-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 14px;
            border: 1px solid var(--color-border-secondary);
  border-radius: 6px;
  margin-bottom: 24px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.rename-input::placeholder {
            color: var(--color-text-muted);
  opacity: 1;
}

.rename-input:focus {
  outline: none;
            border-color: var(--color-info);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.rename-confirm {
            background-color: var(--color-info);
  color: var(--color-bg-main);
}

.rename-confirm:hover {
            background-color: var(--color-info);
}

/* ============================================
   LUCIDE ICONS STYLING
   ============================================ */

i[data-lucide] {
    width: 16px;
    height: 16px;
    display: inline-block;
    vertical-align: middle;
}

/* Для кнопок */
.action-btn i[data-lucide] {
    margin-right: 4px;
}

/* Размеры */
.lucide-sm {
    width: 14px;
    height: 14px;
}

.lucide-md {
    width: 18px;
    height: 18px;
}

.lucide-lg {
    width: 20px;
    height: 20px;
}

/* ============================================
   FIX AUTO-ZOOM ON iOS - Font size 16px
   ============================================ */

input,
textarea,
.message-input {
    font-size: 16px !important;
}

/* ============================================
   LANDSCAPE MODE ON TABLETS/LARGE PHONES
   ============================================ */

/* Планшеты / большие телефоны в landscape c sidebar
   Исключаем iPad 1024px по ширине, чтобы input
   не «уезжал» за пределы экрана на iPad mini. */
@media (orientation: landscape) and (min-width: 800px) and (max-width: 1023px) {
    /* Sidebar открыт: контент начинается после 260px */
    .chat-sidebar:not(.collapsed) + .chat-main .messages-container,
    .chat-sidebar:not(.collapsed) + .chat-main .input-area {
        left: 260px !important; /* ширина sidebar */
        width: calc(100% - 260px) !important;
    }

    /* Sidebar свернут: контент сдвигаем после 60px (узкий sidebar) */
    .chat-sidebar.collapsed + .chat-main .messages-container,
    .chat-sidebar.collapsed + .chat-main .input-area {
        left: 0 !important;
        width: 100% !important;
    }
}

/* Desktop - гарантируем правильное позиционирование input-area */
@media (min-width: 1025px) {
    .input-area {
        left: auto !important;
        width: 100% !important;
        position: relative !important;
    }
}

/* Ширина основной области чата при свернутом sidebar (desktop и большие экраны) */
.chat-sidebar.collapsed + .chat-main {
    width: calc(100vw - 60px);
}
