        /* Базовые переменные (Светлая тема) */
        :root { 
            --primary: #3498db; --success: #27ae60; --warning: #f39c12; --error: #e74c3c; 
            --bg: #f4f6f8; --info-bg: #ebf5fb; --gray: #95a5a6;
            --surface: #ffffff; 
            --text-main: #333333; 
            --text-title: #2c3e50; 
            --border: #eeeeee; 
            /* НОВЫЕ ПЕРЕМЕННЫЕ */
            --text-muted: #555555; /* Цвет лейблов ("Работаете ли вы?") */
            --input-bg: #ffffff;   /* Фон полей ввода */
            --input-border: #dddddd;
            --anon-bg: #fff3cd;    /* Фон желтого предупреждения */
            --anon-border: #ffeeba;
            --anon-text: #856404;
            --sticky-bg: rgba(255, 255, 255, 0.95);
            --btn-sec-bg: #95a5a6;     /* Привычный серый */
            --btn-sec-hover: #7f8c8d;  /* Чуть темнее при наведении */
            --btn-sec-text: #ffffff;   /* Белый текст */
        }
        /* Темная тема */
        :root[data-theme="dark"] {
            --bg: #121212; 
            --surface: #1e1e1e; 
            --text-main: #e0e0e0; 
            --text-title: #ffffff; 
            --border: #333333;
            --info-bg: #1a2a3a; 
            /* НОВЫЕ ПЕРЕМЕННЫЕ ДЛЯ ТЕМНОЙ ТЕМЫ */
            --text-muted: #aaaaaa; /* Светло-серый, чтобы читалось на черном */
            --input-bg: #2a2a2a;   /* Темно-серые поля ввода */
            --input-border: #444444;
            --anon-bg: #332701;    /* Темно-желтый фон */
            --anon-border: #4a3c15;
            --anon-text: #e6c875;
            --sticky-bg: rgba(30, 30, 30, 0.95);
            --btn-sec-bg: #2c2c2c;     /* Глубокий темно-серый, почти в цвет карточек */
            --btn-sec-hover: #3d3d3d;  /* Немного светлеет при наведении */
            --btn-sec-text: #e0e0e0;   /* Светло-серый текст (не чисто белый, чтобы не резало глаза) */
        }
        /* Применяем переменные к базе */
        body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background-color: var(--bg); color: var(--text-main); margin: 0; padding: 15px; line-height: 1.5; transition: background-color 0.3s, color 0.3s; }
        
        .container { max-width: 900px; margin: 0 auto; background: var(--surface); padding: 25px; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.08); transition: background-color 0.3s; }
        
        h1 { font-size: 1.6rem; text-align: center; color: var(--text-title); margin-bottom: 10px; }
        h2 { font-size: 1.3rem; color: var(--text-title); margin-top: 0; text-align: center; margin-bottom: 15px; }
        h3 { color: var(--text-title); border-bottom: 2px solid var(--border); padding-bottom: 5px; margin-top: 30px; }
        
        .instruction { background-color: var(--info-bg); border-left: 5px solid var(--primary); padding: 15px; border-radius: 4px; margin-bottom: 25px; font-size: 0.95rem; color: var(--text-title); line-height: 1.6; transition: all 0.3s; }
        .instruction ul { margin: 5px 0 10px 20px; padding: 0; }
        
        .anon-switch { background: var(--anon-bg); border: 1px solid var(--anon-border); padding: 15px; border-radius: 8px; margin-bottom: 20px; display: flex; align-items: flex-start; gap: 10px; transition: all 0.3s; }
        .anon-switch input { width: 20px; height: 20px; margin-top: 3px; }
        .anon-warning { font-size: 0.85em; color: var(--anon-text); margin-top: 5px; display: none; transition: color 0.3s; }
        
        .step { display: none; opacity: 0; transition: opacity 0.3s ease; }
        .step.active { display: block; opacity: 1; }

        .bratus-premise {font-size: 1.2rem;font-weight: 600;font-style: italic;color: var(--primary);text-align: center;margin: 20px 0 15px 0;padding: 10px;border-bottom: 2px dashed var(--border);transition: color 0.3s, border-color 0.3s;}
        
        .form-group { margin-bottom: 15px; }
        label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 0.9rem; color: var(--text-muted); transition: color 0.3s; }
        input[type="text"], input[type="number"], select, textarea { width: 100%; padding: 12px; border: 1px solid var(--input-border); border-radius: 8px; font-size: 16px; box-sizing: border-box; background: var(--input-bg); color: var(--text-main); appearance: none; transition: all 0.3s; }
        input:disabled, select:disabled { background-color: var(--bg); color: var(--text-muted); border-color: var(--border); opacity: 0.7; }
        .btn-container { display: flex; gap: 15px; margin-top: 25px; transition: all 0.3s ease;}
        /* Класс, который будет добавляться умным кнопкам */
        .btn-container.smart-sticky {position: sticky;bottom: 0;padding: 15px 0;background: var(--sticky-bg); backdrop-filter: blur(5px);border-top: 1px solid var(--border);z-index: 100;transition: background 0.3s, border-top 0.3s;}
        .btn { flex: 1; padding: 16px; border: none; border-radius: 10px; font-size: 17px; font-weight: 600; cursor: pointer; transition: transform 0.1s; color: white; }
        .btn:active { transform: scale(0.98); opacity: 0.9; }
        .btn-next { background-color: var(--primary); }
        .btn-back { background-color: var(--gray); }
        .btn-success { background-color: var(--success); }
        .btn-secondary { background-color: var(--btn-sec-bg); color: var(--btn-sec-text);  margin-top: 10px;width: 100%; padding: 12px; transition: all 0.3s ease; }
        .btn-red { background-color: #dc3545; margin-top: 10px; width: 100%; padding: 12px; }
        .option-card { border: 2px solid var(--border); padding: 12px; margin-bottom: 8px; border-radius: 10px; display: flex; align-items: center; cursor: pointer; transition: all 0.2s; background: var(--input-bg); color: var(--text-main); }
        .option-card input { width: 22px; height: 22px; margin-right: 15px; flex-shrink: 0; }
        .option-card.checked { border-color: var(--primary); background-color: var(--info-bg); }

        .error-msg { color: #fff; background: var(--error); padding: 12px; border-radius: 8px; margin-top: 20px; text-align: center; display: none; font-weight: bold; }
        .highlight-error { border: 2px solid var(--error) !important; background-color: #fff5f5 !important; }

        table { width: 100%; border-collapse: collapse; margin-bottom: 40px; }
        th, td { padding: 12px; text-align: center; border-bottom: 1px solid #eee; vertical-align: middle; }
        th { background: var(--surface); font-size: 0.85rem; color: var(--text-title); position: sticky; top: 0; z-index: 10; box-shadow: 0 2px 5px rgba(0,0,0,0.05); transition: background-color 0.3s, color 0.3s; }
        td:first-child { text-align: left; font-weight: 500; font-size: 0.95rem; width: 45%; }
        
        .res-block { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 20px; margin-bottom: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); transition: background-color 0.3s, border-color 0.3s; }
        .score-badge { display: inline-block; padding: 5px 10px; border-radius: 15px; font-weight: bold; font-size: 0.9em; }
        .bg-green { background: #d4edda; color: #155724; }
        .bg-red { background: #f8d7da; color: #721c24; }
        .bg-blue { background: #d1ecf1; color: #1268f3; }
        canvas { max-height: 300px; margin-top: 15px; }
        .spinner { border: 4px solid #f3f3f3; border-top: 4px solid var(--primary); border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite; margin: 20px auto; }
        @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
        
        /* Анимация успешного завершения (галочка) */
        .success-checkmark { width: 60px; height: 60px; margin: 20px auto; }
        .checkmark-circle {
            stroke-dasharray: 166; stroke-dashoffset: 166;
            stroke-width: 3; stroke-miterlimit: 10; stroke: var(--success); fill: none;
            animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
        }
        .checkmark-check {
            transform-origin: 50% 50%; stroke-dasharray: 48; stroke-dashoffset: 48;
            stroke-width: 4; stroke: var(--success); fill: none;
            animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.4s forwards;
        }
        @keyframes stroke { 100% { stroke-dashoffset: 0; } }

        .dl-section { background: var(--info-bg); border: 2px dashed var(--primary); padding: 20px; text-align: center; border-radius: 10px; margin-bottom: 30px; transition: background-color 0.3s; }
        #result-area { width: 100%; height: 80px; margin-top: 10px; font-size: 12px; padding: 10px; border: 1px solid var(--input-border); background: var(--input-bg); color: var(--text-main); display: none; transition: all 0.3s; }
        /*arrows for the "learn more" button */
        .detail-arrow svg {vertical-align: middle;transition: transform 0.25s ease;transform-origin: center; }
        .detail-arrow {display: inline-block;margin-left: 6px;transition: transform 0.25s ease;}
       /* Поворот стрелки, когда блок открыт */
        .toggle-details[aria-expanded="true"] 
        .detail-arrow {transform: rotate(180deg);}
        .detail-arrow svg {transform: rotate(180deg);}
       /* Лёгкий ховер-эффект — затемнение фона (в духе flat-стиля) */
        .btn-secondary:hover {background-color: var(--btn-sec-hover);}
        /* DEV TOOLS */
        #dev-panel { display: none; background: #333; color: #fff; padding: 15px; border-radius: 8px; margin-top: 15px; }
        #dev-json-input { width: 100%; height: 100px; margin-top: 10px; font-family: monospace; font-size: 12px; color: #333; }
        .dev-btn { background: #555; border: 1px solid #777; color: white; padding: 8px 15px; cursor: pointer; border-radius: 4px; font-size: 0.9em; margin-right: 10px; }
        .dev-btn:hover { background: #666; }
        /* Подсветка отвеченных строк */
        tr.answered td { background-color: var(--info-bg); transition: background-color 0.3s ease; }
        @media (max-width: 600px) { tr.answered { background-color: var(--info-bg); border-radius: 6px; } }

        @media (max-width: 600px) {
            .container { padding: 15px; }
            /* Превращаем строку в гибкий контейнер, который не может быть шире 100% */
            tr { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 10px; border-radius: 8px; width: 100%; box-sizing: border-box; }
            td { padding: 10px 2px; box-sizing: border-box; }
            /* Вопрос занимает все 100% ширины */
            td:first-child { flex: 0 0 100%; font-size: 0.95rem; border-bottom: none; padding-bottom: 10px; color: var(--primary); font-weight: 600; text-align: left; }
            /* Кнопки делят остаток поровну (flex: 1) и не смеют вылезать за края (min-width: 0) */
            td:not(:first-child) { flex: 1 1 0; border: none; text-align: center; min-width: 0; display: flex;flex-direction: column;justify-content: flex-end;align-items: center;}
            thead { display: none; } 
            /* Подписи над кнопками ("Когда как", "Нет") сжимаем аккуратно */
            td:not(:first-child)::before { content: attr(data-label); display: block; font-size: 0.8em; font-weight: 500; color: var(--text-muted); margin-bottom: 8px; line-height: 1.15; word-wrap: break-word; hyphens: auto; }
            /* Чуть уменьшил кнопки для самых узких экранов */
            input[type="radio"] { width: 22px; height: 22px; margin: 0; }
            tr.answered { background-color: var(--info-bg); }
        }
        /* --- СТИЛИ ДЛЯ МОДАЛЬНОГО ОКНА ЗАГРУЗКИ --- */
        #user-import-modal {position: fixed;top: 0; left: 0;width: 100%; height: 100%;background-color: rgba(0,0,0,0.6);display: none; /* Изначально скрыто */align-items: center;justify-content: center;z-index: 1000;}
        .import-modal-content {background: var(--surface); padding: 25px; border-radius: 12px; width: 90%; max-width: 500px; box-shadow: 0 5px 25px rgba(0,0,0,0.5); position: relative; text-align: center; transition: background-color 0.3s;}
        .import-modal-content h3 {margin-top: 0; margin-bottom: 20px; color: var(--text-title); transition: color 0.3s;}
        .import-close-btn {position: absolute;top: 10px;right: 15px;font-size: 28px;line-height: 1;font-weight: bold;color: #aaa;cursor: pointer;transition: color 0.2s;}
        .import-close-btn:hover {color: #333;}
        #user-drop-zone {border: 3px dashed var(--border);border-radius: 10px;padding: 30px;margin-bottom: 15px;background-color: var(--input-bg);transition: background-color 0.2s, border-color 0.2s;}
        #user-drop-zone.drag-over {background-color: var(--info-bg);border-color: var(--primary);}
        #user-paste-area {width: 100%;height: 100px;margin-top: 15px;padding: 10px;font-family: monospace;font-size: 13px;border: 1px solid #ddd;border-radius: 8px;resize: vertical;}
        .load-prior-result {margin-bottom: 20px; padding: 15px; background: var(--info-bg); border-radius: 8px; text-align: center; display: flex; justify-content: center; align-items: center; gap: 15px; transition: background-color 0.3s;} /* Пространство между текстом и кнопкой */
        .load-prior-result span {font-size: 1.0em; color: var(--text-title); transition: color 0.3s;}
        .btn-discreet {background-color: var(--btn-sec-bg); color: var(--btn-sec-text); padding: 8px 16px; font-size: 15px;flex: none; width: auto; transition: all 0.3s ease;}
        .btn-discreet:hover {background-color: var(--btn-sec-hover);}
        .import-or-divider {font-weight: bold;color: var(--text-muted);margin: 15px 0;transition: color 0.3s;}
        #user-import-error {color: var(--error);font-weight: bold;margin-top: 10px;min-height: 20px;}
        /* Тонкий прилипающий прогресс-бар */
        .progress-bar { position: fixed; top: 0; left: 0;width: 100%;height: 5px; background-color: transparent; z-index: 9999; margin: 0;border-radius: 0;}
    .progress-fill { height: 100%; background: var(--primary); width: 0%; transition: width 0.4s ease; }
    /* --- УЛУЧШЕНИЕ UX ТОЛЬКО ДЛЯ ТЕСТОВ И ТОЛЬКО НА ПК --- */
    @media (min-width: 600px) { /* Срабатывает только на десктопах */
            /* Целимся СТРОГО в метки внутри блоков Мильмана и ИПЛ, игнорируя анкету */
            #step-milman label, #step-ipl label {
                cursor: pointer;
                padding: 4px 8px;
                border-radius: 4px;
                transition: background 0.2s;
            }
            /* Серый фон при наведении только для ответов на тесты */
            #step-milman label:hover, #step-ipl label:hover {
                background-color: var(--border); 
            }
            /* Увеличиваем радиокнопки только в тестах */
            #step-milman input[type="radio"], #step-ipl input[type="radio"] {
                transform: scale(1.75);
                margin-right: 30px;
                cursor: pointer;
            }
        }
/* ========================================= */
/* ИИ ЧАТ-БОТ (Стилевое оформление)          */
/* ========================================= */

/* Базовая кнопка (Внешний вид для ПК) */
#ai-chat-btn {
    position: fixed;
    bottom: 25px;
    right: 25px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    cursor: pointer;
    z-index: 10000;
    transition: transform 0.2s, background-color 0.2s, border-radius 0.3s;
    /* Флекс нужен для выравнивания иконки и текста по центру */
    display: flex; 
    align-items: center;
    justify-content: center;
}

#ai-chat-btn:hover {
    transform: scale(1.05);
    background-color: var(--success);
}

.ai-icon {
    font-size: 20px;
    line-height: 1;
}

.ai-text {
    white-space: nowrap; /* Запрещаем тексту переноситься на новую строку */
}

/* ========================================= */
/* АДАПТИВ ДЛЯ МОБИЛЬНЫХ ТЕЛЕФОНОВ           */
/* ========================================= */
@media (max-width: 600px) {
    #ai-chat-btn {
        bottom: 20px;
        right: 20px;
        padding: 0;
        width: 60px; /* Фиксируем ширину */
        height: 60px; /* Фиксируем высоту */
        border-radius: 50%; /* Превращаем в идеальный круг */
    }

    #ai-chat-btn .ai-text {
        display: none; /* Полностью скрываем текст на мобилке */
    }
    
    #ai-chat-btn .ai-icon {
        font-size: 28px; /* Увеличиваем иконку для удобного тапа пальцем */
        margin-left: 0 !important; /* Убиваем отступ, который мы задали в HTML */
    }
    
    /* Немного адаптируем само окно чата под экраны телефонов */
    #ai-chat-window {
        bottom: 90px;
        right: 10px;
        left: 10px;
        width: auto; /* Растягиваем почти на весь экран */
        max-width: none;
    }
}

#ai-chat-window {
    position: fixed;
    bottom: 90px;
    right: 25px;
    width: 380px;
    max-width: 90vw;
    height: 550px;
    max-height: 70vh;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: column;
    z-index: 10000;
    overflow: hidden;
    border: 1px solid var(--border);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Класс для скрытия окна (плавная анимация) */
#ai-chat-window.chat-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
}

.chat-header {
    background: var(--primary);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    font-size: 16px;
}

.chat-header button {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.chat-header button:hover {
    opacity: 1;
}

#ai-chat-messages {
    flex-grow: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg);
}

.chat-msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 15px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap; /* чтобы абзацы от ИИ отображались корректно */
}

.chat-msg.bot {
    background: var(--surface);
    color: var(--text-main);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border);
}

.chat-msg.user {
    background: var(--info-bg);
    color: var(--text-title);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* Спец-сообщение "печатает..." */
.chat-msg.typing {
    color: var(--gray);
    font-style: italic;
    background: transparent;
    border: none;
}

.chat-input-area {
    display: flex;
    padding: 12px;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

#ai-chat-input {
    flex-grow: 1;
    padding: 10px 15px;
    border: 1px solid var(--input-border);
    border-radius: 20px;
    outline: none;
    background: var(--input-bg);
    color: var(--text-main);
    font-family: inherit;
}

#ai-chat-input:focus {
    border-color: var(--primary);
}

.chat-input-area button {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    margin-left: 10px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s;
}

.chat-input-area button:active {
    transform: scale(0.9);
}
/* ========================================= */
/* ИНФО-ОКНО ОБ ИИ                           */
/* ========================================= */
#ai-info-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

#ai-info-icon:hover {
    background: rgba(255, 255, 255, 0.5);
}

#ai-info-popup {
    position: absolute;
    top: 60px; /* Отступ от шапки чата */
    left: 15px;
    right: 15px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
    z-index: 10002;
    font-size: 13px;
    color: var(--text-main);
    line-height: 1.5;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.ai-popup-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
}

.ai-popup-close {
    margin-top: 15px;
    width: 100%;
    padding: 10px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
}

.ai-popup-close:hover {
    background: var(--success);
}