:root {
    --bg-color: #f4f4f9;
    --sidebar-bg: #ffffff;
    --main-bg: #ffffff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --accent-color: #0066B3;
    --accent-hover: #005290;
    --border-color: #e0e0e0;
    --user-msg-bg: #e3f2fd;
    --ai-msg-bg: #f5f5f5;
    --success-color: #28a745;
    --error-color: #dc3545;
    --warning-color: #ffc107;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: white;
    color: #211f1f!important;
    height: 100vh;
    overflow: hidden;
}

a{text-decoration: none;}


.welcome-message span{
color: #3d3d3d;
    display: flex;
    font-size: 21px;
    font-weight: 400;
    justify-content: center;
    margin: 10px auto;
    width: 40%;
}
.welcome-message p{
    color: #101010!important;
    font-family: Gilmer, sans-serif;
    font-size: 45px;
    font-weight: 700;
    line-height: 51px;
    margin: 0 auto 20px;
    padding-top: 10px;
    position: relative;
    text-align: center;
    width: 80%;
}


.model-select-wrapper{box-shadow: 0 0 20px rgba(0, 0, 0, 0.15);}

.app-container {
    display: flex;
    height: 92vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color)!important;
    display: flex;
    flex-direction: column;
    padding: 10px 10px 0 0;
    
    z-index:1000;
}

.sidebar-header {
    margin-bottom: 15px;
}


  .share-buttons { display: flex!important; align-items: center!important; gap: 12px!important; flex-wrap: wrap!important; }
    .share-buttons span { font-weight: 600!important; color: #64748b!important; }
    .share-btn { display: inline-flex!important; align-items: center!important; justify-content: center!important; width: 40px!important; height: 40px!important; border-radius: 10px!important; font-weight: 600!important; font-size: 12px!important; text-decoration: none!important; transition: transform 0.3s, box-shadow 0.3s!important; }
    .share-btn:hover { transform: translateY(-2px)!important; box-shadow: 0 4px 12px rgba(0,0,0,0.15)!important; }
    .share-btn.telegram { background: #229ED9!important; color: #fff!important; }
    .share-btn.vk { background: #0077FF!important; color: #fff!important; }
    .share-btn.facebook { background: #1877F2!important; color: #fff!important; }
     .share-buttons a{padding: 0!important; gap: 0!important; text-decoration: none!important;}
     
.btn-new-chat {
    width: 100%;
    padding: 12px;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    transition: 0.2s;
    color: var(--text-primary);
    font-weight: 500;
}

.btn-new-chat:hover {
    background-color: #f9f9f9;
    border-color: #ccc;
}

.guest-notice {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    text-align: center;
}

.guest-notice p {
    font-weight: 600;
    margin-bottom: 5px;
}

.btn-upgrade {
    display: inline-block;
    background: white;
    color: #667eea;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    font-size: 13px;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: 0.2s;
}

.chat-item:hover {
    background-color: #f0f0f0;
    color: var(--text-primary);
}

.chat-item.active {
    background-color: #eef4fa;
    color: var(--accent-color);
    font-weight: 600;
}

.sidebar-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
}

.user-info {
    margin-bottom: 10px;
    font-size: 14px;
}

.verification-badge {
    display: block;
    font-size: 11px;
    margin-top: 5px;
    padding: 2px 6px;
    border-radius: 3px;
}

.verification-badge.verified {
    background-color: #d4edda;
    color: #155724;
}

.verification-badge.unverified {
    background-color: #fff3cd;
    color: #856404;
}

.btn-logout {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    font-size: 13px;
    width: 100%;
    text-align: left;
    padding: 5px 0;
}

/* Main Chat Area */
.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--main-bg);
    position: relative;
}

.chat-header {
    padding: 5px 30px;
    border-bottom: 0px solid var(--border-color)!important;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
}

.chat-header h2 {
    font-size: 16px;
    font-weight: 600;
}

#model-select {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: #f9f9f9;
    font-size: 13px;
    cursor: pointer;
}

/* Messages */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.welcome-message {
    text-align: center;
    color: var(--text-secondary);
    margin-top: 50px;
}

.message {
    max-width: 80%;
    padding: 15px 20px;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 15px;
    position: relative;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user {
    align-self: flex-end;
    background-color: var(--user-msg-bg);
    color: #004085;
    border-bottom-right-radius: 2px;
}

.message.assistant {
    align-self: flex-start;

    color: var(--text-primary);

}

.model-badge {
    position: absolute;
    bottom: -20px;
    left: 0;
    font-size: 10px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Input Area */
.input-area {
    padding: 20px 30px 35px;
    background: white;
}

.input-wrapper {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    display: flex;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border-radius: 12px;

    background: white;
}

textarea {
    width: 100%;
    padding: 15px 50px 15px 20px;
    border: none;
    border-radius: 12px;
    resize: none;
    font-family: inherit;
    font-size: 15px;
    outline: none;
    max-height: 200px;
}



#send-btn:hover {
    background: var(--accent-hover);
}

.disclaimer {
    text-align: center;
    font-size: 12px;
    color: #999;
    margin-top: 10px;
}

.guest-limit {
    text-align: center;
    font-size: 12px;
    color: var(--warning-color);
    margin-top: 5px;
    font-weight: 600;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 30px;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    position: relative;
}

.close-modal {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 28px;
    cursor: pointer;
    color: #999;
}

.close-modal:hover {
    color: #333;
}

.auth-tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    padding: 10px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
}

.tab-btn.active {
    color: var(--accent-color);
    border-bottom: 2px solid var(--accent-color);
}

.auth-form input {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    margin-top: 10px;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.form-note {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 10px;
    text-align: center;
}

.auth-message {
    margin-top: 15px;
    padding: 10px;
    border-radius: 6px;
    font-size: 13px;
    text-align: center;
}

.auth-message.error {
    background-color: #f8d7da;
    color: #721c24;
}

.auth-message.success {
    background-color: #d4edda;
    color: #155724;
}

/* Alert in index */
.alert {
    background: #ffebee;
    color: #c62828;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 13px;
}


/*Доп функции вывода*/
/* === Markdown-контент: таблицы, код, списки === */
.message-content {
    line-height: 1.6;
    word-wrap: break-word;
}

/* Таблицы */
.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 13px;
    overflow-x: auto;
    display: block;
}

.message-content th,
.message-content td {
    border: 1px solid #ddd;
    padding: 8px 12px;
    text-align: left;
}

.message-content th {
    background-color: #f8f9fa;
    font-weight: 600;
}

.message-content tr:nth-child(even) {
    background-color: #f8f9fa;
}

/* Код и блоки */
.message-content pre {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 10px 0;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
}

.message-content code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Consolas', monospace;
    font-size: 13px;
}

.message-content pre code {
    max-width: 900px;
    background: none;
    padding: 0;
    color: inherit;
}

/* Списки */
.message-content ul,
.message-content ol {
    padding-left: 20px;
    margin: 10px 0;
}

.message-content li {
    margin: 5px 0;
}

/* Цитаты */
.message-content blockquote {
    border-left: 3px solid #0066B3;
    margin: 10px 0;
    padding: 8px 15px;
    background: #f0f7ff;
    color: #333;
}

/* Жирный, курсив, зачеркнутый */
.message-content strong { font-weight: 700; }
.message-content em { font-style: italic; }
.message-content del { text-decoration: line-through; }

/* Ссылки */
.message-content a {
    color: #0066B3;
    text-decoration: none;
}
.message-content a:hover {
    text-decoration: underline;
}

/* === Изображения в ответах === */
.message-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 10px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Индикатор генерации изображения */
.image-generation {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: #f0f7ff;
    border-radius: 8px;
    margin: 10px 0;
}

.image-generation .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #0066B3;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Кнопка генерации изображений */
.btn-image-gen {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    margin-left: 10px;
    transition: transform 0.2s;
}
.btn-image-gen:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}
.btn-image-gen:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* === Адаптивность для мобильных === */
@media (max-width: 768px) {
    .message-content table {
        font-size: 12px;
    }
    .message-content th,
    .message-content td {
        padding: 6px 8px;
    }
}

/* === Переключатель режима изображения === */
.mode-toggle-container {
    max-width: 800px;
    margin: 0 auto 10px;
    display: flex;
    justify-content: flex-end;
}




.mode-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    color: #666;
}

.mode-toggle input {
    display: none;
}

.mode-toggle .slider {
    position: relative;
    width: 44px;
    height: 24px;
    background-color: #e0e0e0;
    border-radius: 24px;
    transition: 0.3s;
    flex-shrink: 0;
}

.mode-toggle .slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.mode-toggle input:checked + .slider {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.mode-toggle input:checked + .slider::before {
    transform: translateX(20px);
}

.mode-toggle .mode-label {
    font-weight: 500;
    transition: color 0.3s;
}

.mode-toggle input:checked + .slider + .mode-label {
    color: #667eea;
    font-weight: 600;
}

/* Подсветка поля ввода в режиме изображения */
.input-wrapper.image-mode-active {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.input-wrapper.image-mode-active textarea {
    background-color: #f8f7ff;
}


/* Плавное появление изображений */
.message-content img {
    opacity: 0;
    transition: opacity 0.5s ease;
}

/* Стиль для заглушки ошибки */
.message-content img[src*="placehold.co"] {
    border: 2px dashed #ff6b6b;
}

/* Плавное появление изображений */
.message-content img.generated-image {
    opacity: 0;
    transition: opacity 0.5s ease;
}

/* Заглушка */
.message-content img[src*="data:image/svg"] {
    border: 3px dashed #ff6b6b !important;
    opacity: 1 !important;
}


/* Плавное появление */
.message-content img.generated-image {
    opacity: 0;
    transition: opacity 0.5s ease;
}

/* Заглушка */
.message-content img[src*="data:image/svg"] {
    border: 3px dashed #ff6b6b !important;
    opacity: 1 !important;
    cursor: not-allowed;
}

/* === Searchable Model Select === */
.model-select-container {
    position: relative;
    width: 100%;
    max-width: 300px;
}

.model-select-wrapper {
    position: relative;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.model-select-wrapper:hover,
.model-select-wrapper.active {
    border-color: #0066B3;
    box-shadow: 0 0 0 3px rgba(0, 102, 179, 0.1);
}

.model-select-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    font-size: 14px;
    color: #333;
}

.model-select-header .arrow {
    font-size: 12px;
    color: #666;
    transition: transform 0.2s;
}

.model-select-wrapper.active .arrow {
    transform: rotate(180deg);
}

.model-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    margin-top: 4px;
    max-height: 400px;
    overflow: hidden;
    display: none;
}

.model-select-wrapper.active .model-select-dropdown {
    display: block;
}

.model-select-search {
    padding: 10px;
    border-bottom: 1px solid #f0f0f0;
}

.model-select-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.model-select-search input:focus {
    border-color: #0066B3;
}

.model-select-list {
    max-height: 320px;
    overflow-y: auto;
    padding: 4px 0;
}

.model-select-group {
    margin: 4px 0;
}

.model-select-group-label {
    padding: 8px 14px 6px;
    font-size: 11px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #f8f9fa;
}

.model-select-option {
    padding: 10px 14px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.model-select-option:hover {
    background: #f0f7ff;
}

.model-select-option.selected {
    background: #e3f2fd;
    color: #0066B3;
    font-weight: 500;
}

.model-select-option .badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    background: #e8f5e9;
    color: #2e7d32;
}

.model-select-option .badge.free {
    background: #fff3e0;
    color: #ef6c00;
}

.model-select-option.hidden {
    display: none;
}

.model-select-loading {
    padding: 20px;
    text-align: center;
    color: #666;
    font-size: 13px;
}

.model-select-error {
    padding: 12px 14px;
    color: #c62828;
    font-size: 13px;
    background: #ffebee;
}

/* Скроллбар для списка */
.model-select-list::-webkit-scrollbar {
    width: 6px;
}
.model-select-list::-webkit-scrollbar-track {
    background: #f1f1f1;
}
.model-select-list::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}
.model-select-list::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* Адаптивность */
@media (max-width: 768px) {
    .model-select-container {
        max-width: 100%;
    }
    .model-select-dropdown {
        position: fixed;
        top: 140px;
        bottom: 0;
        left: 80px;
        right: 0;
        border-radius: 16px 16px 0 0;
        max-height: 60vh;
    }
}


/* === Searchable Model Select === */
.model-select-container { position: relative; width: 100%; max-width: 300px; }
.model-select-wrapper { position: relative; border: 1px solid #e0e0e0; border-radius: 8px; background: white; cursor: pointer; transition: border-color 0.2s, box-shadow 0.2s; }
.model-select-wrapper:hover, .model-select-wrapper.active { border-color: #0066B3; box-shadow: 0 0 0 3px rgba(0, 102, 179, 0.1); }
.model-select-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; font-size: 14px; color: #333; }
.model-select-header .arrow { font-size: 12px; color: #666; transition: transform 0.2s; }
.model-select-wrapper.active .arrow { transform: rotate(180deg); }
.model-select-dropdown { position: absolute; top: 100%; left: 0; right: 0; z-index: 1000; background: white; border: 1px solid #e0e0e0; border-radius: 8px; box-shadow: 0 4px 20px rgba(0,0,0,0.15); margin-top: 4px; max-height: 400px; overflow: hidden; display: none; }
.model-select-wrapper.active .model-select-dropdown { display: block; }
.model-select-search { padding: 10px; border-bottom: 1px solid #f0f0f0; }
.model-select-search input { width: 100%; padding: 8px 12px; border: 1px solid #e0e0e0; border-radius: 6px; font-size: 13px; outline: none; }
.model-select-search input:focus { border-color: #0066B3; }
.model-select-list { max-height: 320px; overflow-y: auto; padding: 4px 0; }
.model-select-group { margin: 4px 0; }
.model-select-group-label { padding: 8px 14px 6px; font-size: 11px; font-weight: 600; color: #666; text-transform: uppercase; letter-spacing: 0.5px; background: #f8f9fa; }
.model-select-option { padding: 10px 14px; font-size: 13px; color: #333; cursor: pointer; transition: background 0.15s; display: flex; justify-content: space-between; align-items: center; }
.model-select-option:hover { background: #f0f7ff; }
.model-select-option.selected { background: #e3f2fd; color: #0066B3; font-weight: 500; }
.model-select-option .badge { font-size: 10px; padding: 2px 6px; border-radius: 4px; background: #e8f5e9; color: #2e7d32; }
.model-select-option .badge.free { background: #fff3e0; color: #ef6c00; }
.model-select-option.hidden { display: none; }
.model-select-loading { padding: 20px; text-align: center; color: #666; font-size: 13px; }
.model-select-error { padding: 12px 14px; color: #c62828; font-size: 13px; background: #ffebee; }
.model-select-list::-webkit-scrollbar { width: 6px; }
.model-select-list::-webkit-scrollbar-track { background: #f1f1f1; }
.model-select-list::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

@media (max-width: 768px) {
    .model-select-container { max-width: 100%; }
    .model-select-dropdown { position: fixed; top: 140px; bottom: 0; left: 70px; right: 0; border-radius: 16px 16px 0 0; max-height: 60vh; }
    .model-select-wrapper{box-shadow: 0 0 0 rgba(0, 0, 0, 0);}
	.chat-badge{display: none!important;}
}


/* Бейдж для бесплатных моделей */
.model-select-option .badge.free {
    background: #e8f5e9;
    color: #2e7d32;
    font-weight: 600;
}

/* Подсветка бесплатных моделей */
.model-select-option[data-id*=":free"] {
    border-left: 3px solid #4caf50;
}

/* Сообщение для гостей о ограничении */
.guest-model-notice {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 10px;
}


/* ============================================================================
   МОБИЛЬНАЯ АДАПТАЦИЯ — ИСПРАВЛЕННАЯ (поле всегда внизу у клавиатуры)
   ============================================================================ */
@media (max-width: 768px) {
    /* Базовые настройки — КРИТИЧНО для работы с клавиатурой */
    html, body {
        height: 87vh;
        height: 87dvh; /* Dynamic viewport — меняется при клавиатуре */
        overflow: hidden;
        width: 100%;
        position: relative; /* ✅ Не fixed, не static */
    }
    
    .welcome-message span{
color: #3d3d3d;
    display: flex;
    font-size: 15px;
    font-weight: 400;
    justify-content: center;
    margin: 10px auto;
    width: 80%;
}
.welcome-message p{
    
    color: #101010!important;
    font-family: Gilmer, sans-serif;
    font-size: 20px!important;
    font-weight: 700;
    line-height: 51px;
    margin: 0 auto 1px;
    padding-top: 1px;
    position: relative;
    text-align: center;
    width: 80%;
}


    
    .app-container {
        flex-direction: column;
        height: 580px;
        overflow: hidden;
        width: 100%;
        max-width: 100vw;
    }
	
	
    /* Сайдбар */
    .sidebar {
        position: fixed;
        left: -280px;
        margin-top: 40px;
        height: 100vh;
        height: 100dvh;
         z-index: 1010;
        width: 280px;
        max-width: 85vw;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
        background: #fff;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .sidebar.active {
        left: 0;
    }

    .sidebar-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 15px;
        border-bottom: 1px solid #e0e0e0;
        flex-shrink: 0;
    }

    .chat-history {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 10px;
    }

    .sidebar-footer {
        padding: 15px;
        border-top: 1px solid #e0e0e0;
        flex-shrink: 0;
    }

    .btn-close-sidebar,
    .btn-menu-mobile {
        display: block !important;
        background: none;
        border: none;
        font-size: 24px;
        cursor: pointer;
        color: #666;
        padding: 5px;
    }

    .btn-menu-mobile {
        margin-right: 10px;
    }

    /* Основная область чата */
    .main-chat {
        flex: 1;
        display: flex;
        flex-direction: column;
        width: 100%;
        min-height: 0; /* ✅ КРИТИЧНО для flex */
        overflow: hidden;
    }

    /* Хедер чата */
    .chat-header {
        padding: 8px 10px;
        border-bottom: 1px solid #e0e0e0;
        display: flex;
        align-items: center;
        gap: 8px;
        flex-wrap: wrap;
        flex-shrink: 0;
        background: #fff;
        min-height: 50px;
    }

    .chat-header h2 {
        font-size: 14px;
        flex: 1;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Выбор модели */
    .model-select-container {
        width: 100%;
        max-width: 160px;
        flex-shrink: 0;
    }

    .model-select-header {
        padding: 6px 10px;
        font-size: 12px;
    }

    .model-select-header span:first-child {
        max-width: 110px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .model-select-dropdown {
        width: 260px;
        max-width: 90vw;
        right: -10px;
    }

    /* Контейнер сообщений — ГИБКИЙ со скроллом */
    .messages-container {
        flex: 1; /* ✅ Занимает всё доступное место */
        overflow-y: auto;
        overflow-x: hidden;
        padding: 1px;
        display: flex;
        flex-direction: column;
        gap: 10px;
        min-height: 0; /* ✅ КРИТИЧНО для скролла внутри flex */
        -webkit-overflow-scrolling: touch;
    }


    .welcome-message {
        padding: 15px;
        text-align: center;
        color: #666;
    }

    .welcome-message h3 {
        font-size: 16px;
        margin-bottom: 8px;
    }

    .welcome-message p {
        font-size: 13px;
    }

    /* ✅ Поле ввода — ВСЕГДА ВНИЗУ у клавиатуры */
    .input-area {
        flex-shrink: 0; /* ✅ НЕ сжимается */
        background: white;

        width: 100%;
        padding: 10px 15px;
        /* ✅ Убраны position и transform которые ломали позиционирование */
    }

    .input-wrapper {
        border-radius: 24px;
        padding: 8px 12px;

        display: flex;
        gap: 8px;
        align-items: flex-end;
    }

    textarea {
        flex: 1;
        min-height: 44px;
        max-height: 120px;
        padding: 12px 45px 12px 16px;
        font-size: 16px; /* ✅ Предотвращает зум на iOS */
        border: none;
        outline: none;
        resize: none;
        line-height: 1.4;
    }



    #send-btn:disabled {
        background: #ccc;
        cursor: not-allowed;
    }

    .disclaimer,
    .limits-info {
        font-size: 11px;
        color: #888;
        text-align: center;
        margin-top: 5px;
        line-height: 1.3;
    }

    /* Уведомления */
    .notification {
        right: 10px;
        left: 10px;
        max-width: none;
        text-align: center;
        bottom: 100px; /* ✅ Выше поля ввода */
        padding: 12px 20px;
        font-size: 13px;
    }

    /* Модальные окна */
    .pricing-modal,
    .modal-content {
        margin: 10% auto;
        width: 95%;
        padding: 20px;
        max-height: 80vh;
        overflow-y: auto;
    }

    .plans-grid-scrollable {
        max-height: 40vh;
        overflow-y: auto;
    }

    .plans-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .plan-card {
        padding: 20px 15px;
    }

    .plan-price {
        font-size: 28px;
    }

    /* Индикатор "Думает" */
    .typing-indicator {
        padding: 8px 12px;
    }

    .typing-dot {
        width: 6px;
        height: 6px;
    }

    /* Ошибки */
    .message.error {
        padding: 10px 12px;
        font-size: 13px;
    }

    .message.error .error-retry {
        padding: 5px 10px;
        font-size: 11px;
    }

    /* Скроллбары */
    .messages-container::-webkit-scrollbar,
    .chat-history::-webkit-scrollbar,
    .model-select-list::-webkit-scrollbar {
        width: 4px;
    }

    .messages-container::-webkit-scrollbar-thumb,
    .chat-history::-webkit-scrollbar-thumb,
    .model-select-list::-webkit-scrollbar-thumb {
        background: #ccc;
        border-radius: 2px;
    }
}

/* ============================================================================
   EXTRA SMALL DEVICES (до 480px)
   ============================================================================ */
@media (max-width: 480px) {
    .sidebar {
        width: 100%;
        max-width: 100vw;
        left: -100%;
    }

    .chat-header h2 {
        font-size: 13px;
    }

    .model-select-container {
        max-width: 180px;
    }

    .model-select-header {
        padding: 5px 8px;
        font-size: 11px;
    }

    .model-select-header span:first-child {
        max-width: 170px;
    }

    .message {
        max-width: 95%;
        padding: 8px 12px;
        font-size: 13px;
    }

    textarea {
        font-size: 16px;
        padding: 10px 40px 10px 12px;
    }



    .welcome-message h3 {
        font-size: 14px;
    }

    .limits-info {
        font-size: 10px;
    }
}

/* ============================================================================
   LANDSCAPE MODE НА МОБИЛЬНЫХ
   ============================================================================ */
@media (max-width: 768px) and (orientation: landscape) {
    .messages-container {
        max-height: calc(100dvh - 130px);
    }

    .modal-content {
        margin: 2% auto;
        max-height: 90vh;
    }
}

/* ============================================================================
   TOUCH-FRIENDLY (сенсорные экраны)
   ============================================================================ */
@media (pointer: coarse) {
    .btn-new-chat,
    .btn-plan,
    .btn-primary,
   

    textarea {
        font-size: 16px; /* Предотвращает зум на iOS */
    }
}


/* ============================================================================
   ИСПРАВЛЕНИЕ МОДАЛЬНОГО ОКНА ТАРИФОВ
   ============================================================================ */

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    overflow-y: auto; /* ✅ Скролл для всего модального окна */
    padding: 20px 0; /* ✅ Отступы сверху и снизу */
}

.modal-content {
    background-color: white;
    margin: 5% auto; /* ✅ Отступ сверху 5% */
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 900px;
    max-height: 85vh; /* ✅ Максимальная высота 85% экрана */
    position: relative;
    overflow-y: auto; /* ✅ Внутренний скролл если контент не влезает */
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Контейнер тарифов с прокруткой */
.plans-grid-scrollable {
    max-height: 50vh; /* ✅ Половина высоты экрана для скролла */
    overflow-y: auto;
    padding: 10px;
    margin: 20px 0;
}

.plans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

/* Адаптивность для мобильных */
@media (max-width: 768px) {
    .modal-content {
        margin: 10% auto;
        width: 95%;
        padding: 20px;
        max-height: 80vh;
    }
    
    .plans-grid-scrollable {
        max-height: 40vh;
    }
    
    .plans-grid {
        grid-template-columns: 1fr;
    }
}

/* Сайдбар для мобильных */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        height: 100vh;
        z-index: 100;
        width: 280px;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }
    .sidebar.active {
        left: 0;
    }
    .btn-menu-mobile, .btn-close-sidebar {
        display: block !important;
        background: none;
        border: none;
        font-size: 24px;
        cursor: pointer;
    }
    .btn-close-sidebar {
        margin-left: auto;
    }
}


/* === Админ-панель === */
.admin-container { display: flex; min-height: 100vh; background: #f4f4f9; }
.admin-sidebar { width: 250px; background: #2c3e50; color: white; padding: 20px 0; position: fixed; height: 100vh; overflow-y: auto; }
.admin-sidebar h3 { padding: 0 20px 20px; margin: 0; border-bottom: 1px solid #34495e; font-size: 18px; }
.admin-nav { list-style: none; padding: 0; margin: 0; }
.admin-nav li a { display: block; padding: 12px 20px; color: #ecf0f1; text-decoration: none; transition: background 0.2s; border-left: 3px solid transparent; }
.admin-nav li a:hover, .admin-nav li a.active { background: #34495e; border-left-color: #3498db; }
.admin-main { flex: 1; margin-left: 250px; padding: 30px; }
.admin-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; padding-bottom: 20px; border-bottom: 1px solid #e0e0e0; }
.admin-header h1 { margin: 0; font-size: 24px; color: #333; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-card { background: white; padding: 20px; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); text-align: center; }
.stat-card .value { font-size: 32px; font-weight: 700; color: #0066B3; margin: 10px 0; }
.stat-card .label { color: #666; font-size: 13px; }
.stat-card.revenue .value { color: #28a745; }
.admin-table { background: white; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.08); margin-bottom: 30px; }
.admin-table-header { padding: 15px 20px; border-bottom: 1px solid #e0e0e0; display: flex; justify-content: space-between; align-items: center; }
.admin-table table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { padding: 12px 20px; text-align: left; border-bottom: 1px solid #f0f0f0; }
.admin-table th { background: #f8f9fa; font-weight: 600; font-size: 13px; color: #666; text-transform: uppercase; }
.status-badge { padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; text-transform: uppercase; }
.status-badge.active { background: #d4edda; color: #155724; }
.status-badge.pending { background: #fff3cd; color: #856404; }
.status-badge.banned { background: #f8d7da; color: #721c24; }
.btn-action { padding: 6px 12px; border: none; border-radius: 4px; cursor: pointer; font-size: 12px; margin-right: 5px; }
.btn-action.edit { background: #3498db; color: white; }
.btn-action.ban { background: #f39c12; color: white; }
.btn-action.delete { background: #e74c3c; color: white; }
.modal { display: none; position: fixed; z-index: 2000; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); }
.modal-content { background: white; margin: 10% auto; padding: 25px; border-radius: 12px; width: 90%; max-width: 500px; position: relative; }
.modal-content .close { position: absolute; right: 20px; top: 15px; font-size: 24px; cursor: pointer; color: #999; }
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 500; font-size: 14px; }
.form-group select, .form-group input { width: 100%; padding: 10px; border: 1px solid #e0e0e0; border-radius: 6px; font-size: 14px; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }
.btn-primary { flex: 1; padding: 12px; background: #0066B3; color: white; border: none; border-radius: 6px; cursor: pointer; font-weight: 600; }
.btn-secondary { padding: 12px 20px; background: #e0e0e0; color: #333; border: none; border-radius: 6px; cursor: pointer; }
.pagination { display: flex; justify-content: center; gap: 5px; margin-top: 20px; }
.pagination a, .pagination span { padding: 8px 12px; border: 1px solid #e0e0e0; border-radius: 4px; text-decoration: none; color: #333; font-size: 13px; }
.pagination a.active { background: #0066B3; color: white; border-color: #0066B3; }
.search-box { display: flex; gap: 10px; margin-bottom: 20px; }
.search-box input { flex: 1; padding: 10px 15px; border: 1px solid #e0e0e0; border-radius: 6px; font-size: 14px; }
.search-box button { padding: 10px 20px; background: #0066B3; color: white; border: none; border-radius: 6px; cursor: pointer; }
.admin-message { padding: 12px 20px; border-radius: 8px; margin-bottom: 20px; font-size: 14px; }
.admin-message.success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.admin-message.error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

@media (max-width: 768px) {
    .admin-sidebar { width: 100%; height: auto; position: relative; }
    .admin-main { margin-left: 0; padding: 20px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .admin-table { overflow-x: auto; }
    .admin-table table { min-width: 800px; }
}


/* === Стили для бокового меню === */
.sidebar-menu {
    margin-bottom: 15px;
    padding: 0 5px;
}

.menu-title {
    font-size: 11px;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 10px;
    margin-bottom: 5px;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 10px;
    margin-bottom: 5px;
    border-radius: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
    cursor: pointer;
}

.menu-item:hover {
    background-color: #f0f0f0;
    color: var(--text-primary);
}

.menu-item.active {
    background-color: #eef4fa;
    color: var(--accent-color);
    font-weight: 600;
}

.menu-icon {
    margin-right: 10px;
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.menu-text {
    flex: 1;
}

/* Адаптивность для мобильного меню */
@media (max-width: 768px) {
    .sidebar-menu {
        padding: 10px;
    }
    
    .menu-item {
        padding: 12px;
        font-size: 15px;
    }
}


/* SEO Analysis Styles */
.seo-container {
    display: flex;
    min-height: 100vh;
    background: #f4f4f9;
}

.seo-main {
    flex: 1;

}

.seo-header {
    background: white;
    padding: 20px 30px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.seo-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.seo-panel {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    max-height: calc(88vh - 200px);
    overflow-y: auto;
}

.seo-panel::-webkit-scrollbar {
    width: 8px;
}

.seo-panel::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.seo-panel::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.seo-panel::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.text-input-area {
    width: 100%;
    min-height: 300px;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    transition: border-color 0.2s;
}

.text-input-area:focus {
    outline: none;
    border-color: #0066B3;
}

.btn-analyze {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 15px;
    transition: transform 0.2s;
}

.btn-analyze:hover {
    transform: translateY(-2px);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

.stat-card .value {
    font-size: 24px;
    font-weight: 700;
    color: #0066B3;
}

.stat-card .label {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

.seo-score {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
    margin-bottom: 20px;
}

.seo-score .number {
    font-size: 48px;
    font-weight: 700;
}

.seo-score .label {
    font-size: 14px;
    opacity: 0.9;
}

.analysis-section {
    margin-bottom: 25px;
}

.analysis-section h3 {
    margin: 0 0 15px;
    font-size: 16px;
    color: #333;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 10px;
}

.keyword-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.keyword-item {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    background: #f8f9fa;
    margin-bottom: 8px;
    border-radius: 6px;
    border-left: 3px solid #0066B3;
}

.keyword-item .word {
    font-weight: 600;
    color: #333;
}

.keyword-item .density {
    color: #667eea;
    font-weight: 600;
}

.recommendation {
    padding: 12px 15px;
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    margin-bottom: 10px;
    border-radius: 4px;
    font-size: 14px;
}

.recommendation.success {
    background: #d4edda;
    border-left-color: #28a745;
}

.recommendation.error {
    background: #f8d7da;
    border-left-color: #dc3545;
}

.btn-fix {
    padding: 8px 16px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    margin-top: 10px;
}

.btn-fix:hover {
    background: #218838;
}

.tab-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: #f8f9fa;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.tab-btn.active {
    background: #0066B3;
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@media (max-width: 1024px) {
    .seo-content {
        grid-template-columns: 1fr;
    }
    .seo-main {
        margin-left: 0;
    }
    .seo-panel {
        max-height: none;
    }
}


.seo-panel {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    max-height: calc(88vh - 150px);
    overflow-y: auto;
}

.seo-panel::-webkit-scrollbar {
    width: 8px;
}

.seo-panel::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.seo-panel::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.seo-panel::-webkit-scrollbar-thumb:hover {
    background: #555;
}


.auth-message {
    padding: 10px 15px;
    border-radius: 6px;
    font-size: 13px;
    margin-top: 10px;
    display: none;
}
.auth-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}
.auth-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}



.chat-badge {
    display: block;
    font-size: 11px;
    margin-top: 5px;
    padding: 2px 6px;
    border-radius: 3px;
	background: #e3f2fd;
}


/* ============================================================================
=== MODERN HEADER STYLES ===
============================================================================ */

/* === Базовая шапка === */
.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: #ffffff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.3s ease;
}

.site-header.scrolled {
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.12);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 14px 0;
    height: 40px;
}

/* === Логотип === */
.logo {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a2e;
    text-decoration: none;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.2s ease;
}

.logo:hover {
    color: #0066B3;
}

.logo::before {
    content: '';
    font-size: 22px;
}

/* === Правая часть: меню + авторизация === */
.header-right {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-left: auto;
	padding-right: 15px;
}

/* === Навигация === */
.nav {
    display: flex;
    align-items: center;
}

.nav-list {
    display: flex;
    list-style: none;
    gap: 4px;
    margin: 0;
    padding: 0;
}

.nav-item {
    position: relative;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    color: black;
    text-decoration: none;
    font-weight: 500;
    font-size: 15px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
    color: #0066B3;
    background: rgba(0, 102, 179, 0.08);
}

.nav-arrow {
    font-size: 10px;
    color: #94a3b8;
    transition: transform 0.2s ease;
}

.nav-item:hover .nav-arrow {
    transform: rotate(180deg);
}

/* === Выпадающее меню (submenu) === */
.submenu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    padding: 8px 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: all 0.25s ease;
    z-index: 1001;
    list-style: none;
    border: 1px solid rgba(0, 0, 0, 0.06);
}


.nav-item:hover > .submenu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.submenu-item {
    padding: 0;
}

.submenu-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    color: #334155;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s ease;
}

.submenu-link:hover {
    background: #f8fafc;
    color: #0066B3;
    padding-left: 22px;
}

.submenu-icon {
    font-size: 16px;
    flex-shrink: 0;
}

/* === Кнопки авторизации === */
.auth-buttons {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.auth-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    transition: all 0.25s ease;
    cursor: pointer;
    border: none;
}

.auth-btn-login {
    background: linear-gradient(135deg, #0066B3 0%, #00a8e8 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(0, 102, 179, 0.25);
}

.auth-btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 102, 179, 0.35);
}

.auth-btn .btn-icon {
    font-size: 16px;
}

.auth-btn .btn-text {
    display: inline;
}

.auth-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    background: #f8fafc;
    border-radius: 10px;
    font-size: 14px;
    color: #334155;
}

.auth-user-info .username {
    font-weight: 600;
}

.auth-user-info .logout-btn {
    color: #64748b;
    text-decoration: none;
    font-size: 13px;
    padding: 4px 10px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.auth-user-info .logout-btn:hover {
    color: #e74c3c;
    background: #fee2e2;
}

/* === Гамбургер-кнопка (мобильная) === */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    background: transparent;
    border: 0px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    padding: 8px;
	margin-right: 15px;
    transition: all 0.3s ease;
    z-index: 1002;
}

.mobile-menu-toggle:hover,
.mobile-menu-toggle.active {
    border-color: #0066B3;
    background: rgba(0, 102, 179, 0.08);
}

.hamburger-line {
    width: 100%;
    height: 2px;
    background: #334155;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}
.mobile-menu-toggle.active .hamburger-line:nth-child(2) {
    opacity: 0;
    transform: translateX(-10px);
}
.mobile-menu-toggle.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* ============================================================================
=== MOBILE ADAPTATION (≤768px) ===
============================================================================ */
@media (max-width: 768px) {
    .header-inner {
        padding: 12px 0;
        gap: 16px;
    }

    .logo {
        font-size: 18px;
    }

    .logo::before {
        font-size: 20px;
    }

    /* Показываем гамбургер */
    .mobile-menu-toggle {
        display: flex;
        order: 2;
    }

    /* Правая часть: скрываем по умолчанию, показываем в меню */
    .header-right {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: #ffffff;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        padding: 24px 20px;
        gap: 0;
        margin-left: 0;
        transform: translateX(100%);
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 999;
        overflow-y: auto;
        box-shadow: -4px 0 25px rgba(0, 0, 0, 0.1);
    }

    .header-right.active {
        transform: translateX(0);
    }

    /* Навигация на мобильных */
    .nav {
        width: 100%;
        margin-bottom: 24px;
    }

    .nav-list {
        flex-direction: column;
        gap: 2px;
    }

    .nav-item {
        border-bottom: 1px solid #689fd5;
    }

    .nav-link {
        padding: 16px 20px;
        font-size: 16px;
        justify-content: space-between;
        border-radius: 0;
    }

    .nav-link:hover,
    .nav-link.active {
        background: rgba(0, 102, 179, 0.1);
    }

    /* Подменю на мобильных (аккордеон) */
    .submenu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        border: none;
        border-radius: 0;
        background: #f8fafc;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.35s ease;
        padding: 0;
        margin: 0;
    }
	
	

    .nav-item.open > .submenu {
        max-height: 500px;
        padding: 4px 0 12px 0;
    }

    .submenu-link {
        padding: 14px 20px 14px 48px;
        font-size: 15px;
    }

    .submenu-link:hover {
        background: rgba(0, 102, 179, 0.08);
        padding-left: 52px;
    }

    /* Авторизация на мобильных */
    .auth-buttons {
        width: 100%;
        margin-top: 16px;
        padding-top: 24px;
        border-top: 1px solid #e2e8f0;
        justify-content: center;
    }

    .auth-btn {
        width: 100%;
        justify-content: center;
        padding: 14px;
        font-size: 15px;
    }

    .auth-btn .btn-text {
        display: inline;
    }

    .auth-user-info {
        width: 100%;
        justify-content: center;
        padding: 12px;
        background: rgba(0, 102, 179, 0.08);
    }



    .auth-user-info::before {
        content: '👤';
        font-size: 18px;
    }

    .auth-user-info .logout-btn {
        padding: 8px 16px;
        font-size: 14px;
    }

    /* Затемнение фона при открытом меню */
    .header-right.active::before {
        content: '';
        position: fixed;
        top: 72px;
        left: 0;
        right: 0;
        bottom: 0;
        background: white;
        z-index: -1;
        animation: fadeIn 0.3s ease;
    }

    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
}

/* ============================================================================
=== EXTRA SMALL (≤480px) ===
============================================================================ */
@media (max-width: 480px) {
    .header-inner {
        padding: 1px 0;
    }

    .logo {
        font-size: 17px;
    }

    .nav-link {
        padding: 14px 16px;
        font-size: 15px;
    }

    .auth-btn {
        padding: 12px;
        font-size: 14px;
    }
}

/* ============================================================================
=== DARK MODE SUPPORT ===
============================================================================ */
@media (prefers-color-scheme: dark) {
    .site-header {
        background: #1a1a2e;
        border-bottom-color: rgba(255, 255, 255, 0.1);
    }

    .logo {
        color: #f0f0f0;
    }

    .logo:hover {
        color: #00a8e8;
    }

    .nav-link {
        color: #cbd5e1;
    }

    .nav-link:hover,
    .nav-link.active {
        color: #00a8e8;
        background: rgba(0, 168, 232, 0.15);
    }

    .submenu {
        background: #1e293b;
        border-color: #334155;
    }

    .submenu-link {
        color: #cbd5e1;
    }

    .submenu-link:hover {
        background: rgba(0, 168, 232, 0.15);
        color: #00a8e8;
    }

    .auth-btn-login {
        background: linear-gradient(135deg, #00a8e8 0%, #0066B3 100%);
    }

    .auth-user-info {
        background: #1e293b;
        color: #f0f0f0;
    }

    .mobile-menu-toggle {
        border-color: #475569;
    }

    .mobile-menu-toggle .hamburger-line {
        background: #f0f0f0;
    }

    @media (max-width: 768px) {
        .header-right {
            background: #1a1a2e;
        }

        .nav-item {
            border-bottom-color: #334155;
        }

        .submenu {
            background: #1e293b;
        }

        .auth-buttons {
            border-top-color: #334155;
        }

        .auth-user-info {
            background: rgba(0, 168, 232, 0.1);
			color: balck;
        }
    }
}

/* ============================================================================
=== ACCESSIBILITY ===
============================================================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

.nav-link:focus-visible,
.submenu-link:focus-visible,
.auth-btn:focus-visible,
.mobile-menu-toggle:focus-visible {
    outline: 2px solid #0066B3;
    outline-offset: 2px;
}