@charset "utf-8";
@font-face {
    font-family: 'Inter';
    src: url('/fonts/Inter-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Inter';
    src: url('/fonts/Inter-Medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Inter';
    src: url('/fonts/Inter-SemiBold.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Inter';
    src: url('/fonts/Inter-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/*
   Важно для iOS Safari/Yandex Browser:
   делаем высоту через цепочку html->body->.chat (как в эталоне psyai),
   чтобы flex-раскладка корректно рассчитывала доступную высоту.
*/
html,
body {
    height: 100%;
}

:root {
    --primary: #7B6AAF;
    --primary-light: #9B8FCF;
    --primary-bg: #F0EBF8;
    --accent: #5BBAA8;
    --accent-light: #E8F5F1;
    --gray-50: #FAFAFA;
    --gray-100: #F5F5F5;
    --gray-200: #EEEEEE;
    --gray-300: #E0E0E0;
    --gray-400: #BDBDBD;
    --gray-500: #9E9E9E;
    --gray-600: #757575;
    --gray-700: #616161;
    --gray-800: #424242;
    --gray-900: #212121;
    --white: #FFFFFF;
    --danger: #E53935;
    --danger-light: #FFEBEE;
    /* Янтарь для «мягкого» режима блока безопасности (verdict=supportive) — не тревога, но не «всё ок». */
    --warning: #C77700;
    --warning-light: #FFF3E0;
    /* Синий для блока «научная проверка» академика (confirm/refine/correct). */
    --info: #2563EB;
    --info-light: #EAF1FE;
    --font-heading: Roboto, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
    /* Брендовый шрифт вордмарка «Vera» — как на лендингах (fonts.css: --font-heading=Merriweather).
       На страницах чата fonts.css не подключён, поэтому @font-face дублируется ниже. */
    --font-brand: 'Merriweather', Georgia, 'Times New Roman', serif;
}

/* Брендовый шрифт «Vera» для страниц чата (fonts.css сюда не подключается) */
@font-face {
    font-family: 'Merriweather';
    src: url('/fonts/Merriweather-VariableFont_opsz,wdth,wght.ttf') format('truetype');
    font-weight: 300 900;
    font-style: normal;
    font-display: swap;
}

h1, h2, h3 {
    font-family: var(--font-heading);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-100);
    overflow: hidden;
    /* safe-area обрабатываем на header/footer, чтобы не ломать расчёт высоты */
    padding: 0;
}

/* Утилита как в эталоне psyai (Bootstrap-совместимая): display:none */
.d-none {
    display: none !important;
}

/* Chat Layout */
.chat {
    display: flex;
    /*
       Высота = видимая область вьюпорта, чтобы футер с полем ввода не уходил
       под экранную клавиатуру на мобиле.
       - 100vh  — фолбэк для старых движков без dvh;
       - 100dvh — современные браузеры (динамический вьюпорт: тулбары);
       - var(--app-height) — значение из JS (setupViewportHeight) по
         window.visualViewport.height: единственное, что на iOS Safari/старых
         WebView реально вычитает высоту клавиатуры. На Chrome/Android основную
         работу делает interactive-widget=resizes-content в viewport-meta.
    */
    height: 100vh;
    height: 100dvh;
    height: var(--app-height, 100dvh);
    /* было min-height:100dvh — не давало .chat ужаться под клавиатуру */
    min-height: 0;
}

/* Sidebar */
.chat-aside {
    width: 280px;
    background: #fff;
    -webkit-appearance: none;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.aside-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--gray-200);
}

.aside-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-brand);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
    text-decoration: none;
}

.aside-logo img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.aside-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    /* Минимальная высота для скролла */
    min-height: 0;
}

/* Кастомный скроллбар для списка чатов */
.aside-body::-webkit-scrollbar {
    width: 6px;
}

.aside-body::-webkit-scrollbar-track {
    background: transparent;
}

.aside-body::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

.aside-body::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* Firefox */
.aside-body {
    scrollbar-width: thin;
    scrollbar-color: var(--gray-300) transparent;
}

.aside-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 0.75rem;
}

/* Строка «Чаты» + компактная кнопка «Создать чат» справа */
.aside-chats-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.aside-chats-header .aside-title {
    margin-bottom: 0;
}

/* =========================
   Role Selector Buttons
   ========================= */
.role-selector {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.role-btn {
    width: 100%;
    padding: 0.875rem 1.25rem;
    border: 2px solid #d4d4d4;
    border-radius: 24px;
    background: var(--white);
    color: var(--gray-700);
    font-size: 0.9375rem;
    font-weight: 500;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: center;
    text-decoration: none;
    display: block;
}

.role-btn:hover {
    border-color: transparent;
    background: linear-gradient(135deg, #9F7AEA 0%, #805AD5 50%, #6B46C1 100%);
    color: var(--white);
    box-shadow: 0 4px 15px rgba(128, 90, 213, 0.35);
}

.role-btn.active {
    border-color: transparent;
    background: linear-gradient(135deg, #9F7AEA 0%, #805AD5 50%, #6B46C1 100%);
    color: var(--white);
    box-shadow: 0 4px 15px rgba(128, 90, 213, 0.35);
}

.role-btn:active {
    transform: scale(0.98);
}

.btn-add-dialog {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-add-dialog:hover {
    background: var(--primary-light);
}

.btn-add-dialog svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

/* Dialog List */
.dialog-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.dialog-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.2rem 0.75rem;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.dialog-item:hover {
    background: var(--gray-100);
}

.dialog-item.active {
    background: var(--gray-100);
}

.dialog-name {
    font-size: 0.875rem;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.dialog-name-input {
    font-size: 0.875rem;
    color: var(--gray-800);
    border: 1px solid var(--primary);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    outline: none;
    flex: 1;
    display: none;
}

.dialog-item.editing .dialog-name {
    display: none;
}

.dialog-item.editing .dialog-name-input {
    display: block;
}

.dialog-menu-btn {
    background: transparent;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    border-radius: 4px;
    color: var(--gray-500);
    transition: all 0.2s;
    position: relative;
}

.dialog-menu-btn:hover {
    background: var(--gray-200);
    color: var(--gray-700);
}

.dialog-menu-btn svg {
    width: 18px;
    height: 18px;
}

/* Dropdown Menu */
.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: #fff;
    -webkit-appearance: none;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    min-width: 150px;
    z-index: 100;
    display: none;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    color: var(--gray-700);
    cursor: pointer;
    transition: background 0.2s;
}

.dropdown-item:first-child {
    border-radius: 8px 8px 0 0;
}

.dropdown-item:last-child {
    border-radius: 0 0 8px 8px;
}

.dropdown-item:hover {
    background: var(--gray-50);
}

.dropdown-item.danger {
    color: var(--danger);
}

.dropdown-item.danger:hover {
    background: var(--danger-light);
}

.dropdown-item svg {
    width: 16px;
    height: 16px;
}

/* Main Chat Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0.5rem;
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    /*
       Ключевой фикс для iOS Safari/Yandex:
       шапка должна быть частью flex-потока, иначе она перекрывает первое сообщение.
       Скролл идёт внутри .chat-body-scroll, поэтому шапка и так остаётся сверху.
    */
    position: relative;
    z-index: 20;
}

@media (max-width: 768px) {
    /* учитываем «чёлку»/safe-area на iPhone */
    .chat-header {
        padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
        padding-bottom: 0.75rem;
        /* Убираем backdrop-filter на мобиле: он создаёт containing-block для
           position:fixed, из-за чего полноэкранное меню профиля «залипало» бы
           внутри шапки. Фон шапки и так 98% непрозрачный — визуально незаметно. */
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    flex-shrink: 0;
}

.btn-profile {
    background: transparent;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--gray-600);
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-profile:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.btn-profile svg {
    width: 24px;
    height: 24px;
}

.profile-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: #fff;
    -webkit-appearance: none;
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    min-width: 240px;
    z-index: 100;
    display: none;
    overflow: hidden;
}

.profile-menu.show {
    display: block;
    animation: menuSlideIn 0.2s ease;
}

@keyframes menuSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.profile-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    font-size: 0.9375rem;
    color: var(--gray-700);
    cursor: pointer;
    transition: background 0.2s;
}

.profile-menu-item:hover {
    background: var(--gray-100);
}

.profile-menu-item-danger {
    color: var(--danger);
}

.profile-menu-item-danger:hover {
    background: var(--danger-light);
}

.profile-menu-item svg {
    width: 18px;
    height: 18px;
}

/* Эмодзи-иконка пункта меню (🆘 «Мне плохо») — та же колонка, что и svg-иконки */
.profile-menu-item-emoji {
    flex: 0 0 auto;
    width: 18px;
    text-align: center;
    font-size: 15px;
    line-height: 1;
}

/* Пункты-ссылки на ИИ-помощников — белые кнопки с фиолетовым контуром, названия в одну строку.
   Селектор .profile-menu-item.profile-menu-item-nav (0,2,0) перебивает
   и базовый пункт, и мобильные правила .profile-menu-item. */
.profile-menu-item.profile-menu-item-nav {
    margin: 7.2px 12px;
    padding: 0.95rem 1.15rem;
    border-radius: 12px;
    border: 2px solid #805AD5;
    background: var(--white);
    color: #6B46C1;
    box-shadow: 0 2px 8px rgba(128, 90, 213, 0.12);
    text-decoration: none;
    white-space: nowrap;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.profile-menu-item.profile-menu-item-nav:hover {
    background: rgba(128, 90, 213, 0.08);
    color: #6B46C1;
    border-color: #6B46C1;
    box-shadow: 0 6px 16px rgba(128, 90, 213, 0.18);
    transform: translateY(-1px);
}

/* Иконка внутри кнопки — фиолетовая (svg stroke=currentColor) */
.profile-menu-item.profile-menu-item-nav svg {
    color: #6B46C1;
}

/* Чуть больше воздуха перед группой ИИ-помощников (отделяем кнопки от «аккаунт»-пунктов) */
.profile-menu-item.profile-menu-item-nav.profile-menu-group-start {
    margin-top: 16px;
}

/* На десктопе ИИ-помощники уже в левом сайдбаре — в меню профиля дубли не показываем.
   На мобиле (≤768px) сайдбар скрыт, поэтому пункты остаются. */
@media (min-width: 769px) {
    .profile-menu-item.profile-menu-item-nav {
        display: none;
    }
}

/* Гость (не авторизован) не видит пункт «Выйти» */
.profile-menu--guest .profile-menu-item-danger {
    display: none;
}

/* Шапка меню (лого + крестик) — только для полноэкранного мобильного вида */
.profile-menu-mobile-header {
    display: none;
}

/* ===== Единый стандарт: на мобиле меню профиля разворачивается на весь экран,
   как бургер-меню лендинга. Десктоп выше остаётся выпадающим дропдауном. ===== */
@media (max-width: 768px) {
    .profile-menu {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        min-width: 0;
        border: none;
        border-radius: 0;
        box-shadow: none;
        background: var(--white);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        z-index: 900;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        /* Видимость через opacity/visibility (как у бургера), а не display —
           ради плавного появления. */
        display: flex;
        flex-direction: column;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: none;
        transition: opacity 0.25s ease, visibility 0.25s ease;
        animation: none;
    }

    .profile-menu.show {
        display: flex;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        animation: none;
    }

    /* Шапка полноэкранного меню: бренд слева, крестик справа */
    .profile-menu-mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        padding: calc(0.9rem + env(safe-area-inset-top, 0px)) 1.25rem 0.9rem;
        border-bottom: 1px solid var(--gray-200);
    }

    .profile-menu-mobile-brand {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        font-family: var(--font-brand);
        font-weight: 700;
        font-size: 1.25rem;
        color: var(--gray-900);
    }

    .profile-menu-mobile-logo {
        width: 28px;
        height: 28px;
        object-fit: contain;
    }

    .profile-menu-close {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        padding: 0;
        background: transparent;
        border: none;
        border-radius: 50%;
        color: var(--gray-700);
        cursor: pointer;
        transition: background 0.2s;
    }

    .profile-menu-close:hover,
    .profile-menu-close:active {
        background: var(--gray-100);
    }

    .profile-menu-close svg {
        width: 26px;
        height: 26px;
    }

    /* Пункты — крупные, во всю ширину, с разделителями */
    .profile-menu-item {
        padding: 1.15rem 1.5rem;
        font-size: 1.15rem;
        gap: 1rem;
        border-bottom: 1px solid var(--gray-100);
    }

    .profile-menu-item svg {
        width: 22px;
        height: 22px;
    }

    .profile-menu-item-emoji {
        width: 22px;
        font-size: 19px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .profile-menu,
    .profile-menu.show {
        transition: none;
        animation: none;
    }
}

.btn-mobile-menu {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: transparent;
    border: none;
    color: var(--primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
}

.btn-mobile-menu svg {
    width: 20px;
    height: 20px;
}

.chat-title {
    font-size: 1rem;
    font-weight: 500;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.chat-title-brand {
    display: none;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
    color: var(--primary);
}

.chat-title-logo {
    width: 18px;
    height: 18px;
    object-fit: contain;
}

.chat-title-sep {
    color: var(--gray-400);
    margin-left: 0.125rem;
}

.chat-title-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-close-chat {
    background: transparent;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--gray-500);
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-close-chat:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn-close-chat svg {
    width: 24px;
    height: 24px;
}

/* Chat Body */
/*
   Делаем структуру как в эталоне psyai:
   - .chat-body = контейнер (overflow:hidden; position:relative)
   - Кнопка scroll-bottom внутри .chat-body
   - Скролл привязан к #chatBody (дочерний элемент)
*/
.chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: transparent;
    overflow: hidden;
    position: relative;
    min-height: 0;
}

/* scroll container (аналог .srollable-y из psyai) */
.chat-body-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    /* без искусственного top-padding: шапка в потоке и не перекрывает сообщения */
    padding: 1rem 1.5rem 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    background: transparent;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

.chat-messages {
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}


/* Message */
.message {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.message-ai {
    align-items: flex-start;
}

.message-user {
    align-items: flex-end;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--primary);
    font-weight: 500;
}

.message-header svg {
    width: 16px;
    height: 16px;
}

.message-logo {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.message-content {
    background: #fff;
    -webkit-appearance: none;
    padding: 1rem 1.25rem;
    border-radius: 16px;
    max-width: 85%;
    line-height: 1.6;
    color: var(--gray-800);
    font-size: 1.1rem;
}

.message-ai .message-content {
    border-top-left-radius: 4px;
}

.message-user .message-content {
    background: var(--gray-100);
    border-top-right-radius: 4px;
}

/* ── Типографика ответа (markdown-разметка): читабельность ── */
.message-content p {
    margin: 0 0 0.7em;
}
.message-content p:last-child,
.message-content > :last-child {
    margin-bottom: 0;
}
.message-content strong {
    font-weight: 700;
    color: var(--gray-900, #1a1a2e);
}
.message-content em {
    font-style: italic;
}
.message-content .msg-h {
    font-weight: 700;
    color: var(--gray-900, #1a1a2e);
    line-height: 1.35;
    margin: 0.5em 0 0.35em;
}
.message-content .msg-h:first-child {
    margin-top: 0;
}
.message-content .msg-h1 { font-size: 1.25em; }
.message-content .msg-h2 { font-size: 1.18em; }
.message-content .msg-h3 { font-size: 1.08em; }
.message-content .msg-h4 { font-size: 1em; letter-spacing: 0.01em; }
.message-content .msg-list {
    margin: 0.35em 0 0.7em;
    padding-left: 1.4em;
}
.message-content .msg-list li {
    margin: 0.2em 0;
    line-height: 1.55;
}

/* Быстрый старт: чипы частых тем под приветствием */
.quick-start {
    width: 100%;
    margin-top: 0.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

/* Пустой чат: контейнер растягивается, блок старта центрируется по вертикали —
   свободное место делится поровну сверху и снизу (класс ставит renderMessages) */
.chat-messages.chat-messages-start {
    flex: 1;
    justify-content: center;
}

/* Приветствие-пузырь от Vera в пустом чате — обычный message-ai, лишние отступы гасим */
.qs-greeting {
    margin: 0;
}

/* Одна приглушённая строка доверия под чипами */
.quick-start-trustline {
    font-size: 0.8rem;
    line-height: 1.45;
    color: var(--gray-500);
}

.quick-start-hint {
    font-size: 0.85rem;
    color: var(--primary);
    opacity: 0.85;
}

.quick-start-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.quick-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 36px;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    border: 1px solid var(--primary-light);
    background: rgba(255, 255, 255, 0.95);
    color: var(--gray-800);
    font-family: inherit;
    font-size: 0.82rem;
    line-height: 1.2;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.quick-chip:hover {
    background: var(--primary-bg);
    border-color: var(--primary);
}

.quick-chip:active {
    transform: scale(0.98);
}

.quick-chip-emoji {
    font-size: 0.95rem;
    line-height: 1;
}

/* Мобайл: чипы по 2 в ряд, удобный tap-target */
@media (max-width: 480px) {
    .quick-chip {
        flex: 1 1 calc(50% - 0.5rem);
        justify-content: center;
        font-size: 0.78rem;
        padding: 0.35rem 0.5rem;
    }
}

/* Ссылка-сравнение «Чем Vera лучше…» ПОД чипами — тихая текстовая, не конкурирует
   с целевым действием (раньше была самой заметной кнопкой первого экрана) */
.compare-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    align-self: flex-start;
    max-width: 100%;
    min-height: 36px;
    padding: 0.35rem 0.15rem;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--primary);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.3;
    text-align: left;
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 0.15s ease, transform 0.05s ease;
}

.compare-badge:hover {
    opacity: 1;
    text-decoration: underline;
}

.compare-badge:active {
    transform: scale(0.99);
}

.compare-badge:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(123, 106, 175, 0.25);
}

.compare-badge-arrow {
    font-weight: 700;
    flex-shrink: 0;
}

@media (max-width: 480px) {
    .compare-badge {
        font-size: 0.85rem;
    }
}

/* Модалка сравнения */
.compare-modal {
    max-width: 640px;
    padding: 2rem 1.75rem 1.6rem;
}

.compare-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--gray-800);
    margin: 0 0 0.4rem;
    padding-right: 2rem;
}

.compare-subtitle {
    font-size: 0.92rem;
    color: var(--gray-600);
    line-height: 1.5;
    margin: 0 0 1.25rem;
}

.compare-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.compare-table {
    min-width: 440px;
    border: 1px solid var(--primary-light);
    border-radius: 14px;
    overflow: hidden;
}

.compare-head,
.compare-row {
    display: grid;
    grid-template-columns: 1.05fr 1fr 1fr;
}

.compare-head {
    background: var(--primary-bg);
}

.compare-head .compare-cell {
    padding: 0.7rem 0.6rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--gray-800);
    text-align: center;
    justify-content: center;
}

.compare-head-vera {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
}

.compare-row {
    border-top: 1px solid var(--gray-200);
}

.compare-cell {
    display: flex;
    gap: 0.35rem;
    align-items: flex-start;
    padding: 0.7rem 0.6rem;
    font-size: 0.82rem;
    line-height: 1.42;
    color: var(--gray-700);
}

.compare-cell-feature {
    flex-direction: column;
    gap: 0.3rem;
    align-items: flex-start;
    justify-content: center;
    font-weight: 700;
    color: var(--gray-800);
}

.compare-cell-vera {
    background: var(--accent-light);
    color: var(--gray-800);
}

.compare-mark {
    font-weight: 800;
    line-height: 1.42;
    flex-shrink: 0;
}

.compare-mark-yes {
    color: var(--accent);
}

.compare-mark-no {
    color: var(--gray-400);
}

.compare-detail-toggle {
    background: none;
    border: none;
    /* Вертикальный паддинг + компенсирующий отрицательный margin: тач-таргет ~32px,
       но строка таблицы по высоте не разъезжается. */
    padding: 0.45rem 0;
    margin: -0.4rem 0;
    color: var(--primary);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}

.compare-detail-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(123, 106, 175, 0.25);
    border-radius: 4px;
}

.compare-detail {
    padding: 0.8rem 0.85rem;
    background: var(--primary-bg);
    border-top: 1px solid var(--gray-200);
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--gray-700);
}

.compare-cta {
    margin-top: 1.25rem;
    text-align: center;
}

.compare-cta-btn {
    appearance: none;
    border: none;
    border-radius: 12px;
    padding: 0.85rem 1.6rem;
    min-height: 44px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.compare-cta-btn:hover {
    box-shadow: 0 8px 20px rgba(123, 106, 175, 0.3);
}

.compare-cta-btn:active {
    transform: translateY(1px);
}

.compare-cta-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(123, 106, 175, 0.25);
}

@media (max-width: 480px) {
    .compare-modal {
        padding: 1.6rem 1.1rem 1.3rem;
    }
    .compare-title {
        font-size: 1.2rem;
    }
    .compare-cell {
        font-size: 0.8rem;
        padding: 0.6rem 0.5rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .compare-badge,
    .compare-cta-btn {
        transition: none;
    }
}

.message-footer {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--gray-500);
}

.message-cost {
    color: var(--gray-500);
}

.btn-message-action {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    /* Фон виден уже в покое — почти как при наведении (hover лишь чуть темнее). */
    background: var(--gray-100);
    border: none;
    color: var(--gray-500);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-message-action:hover {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-message-action.danger:hover {
    background: var(--danger-light);
    color: var(--danger);
}

.btn-message-action svg {
    width: 14px;
    height: 14px;
}

/* Scroll to Bottom Button */
/* поддерживаем оба класса: старый .btn-scroll-bottom и эталонный .scroll-bottom */
.btn-scroll-bottom,
.scroll-bottom {
    position: absolute;
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    background: #fff;
    -webkit-appearance: none;
    border: 1px solid var(--gray-300);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 15;
}

/* скрываем кнопку через d-none (как в эталоне psyai) */
.btn-scroll-bottom.d-none,
.scroll-bottom.d-none {
    display: none !important;
}

.btn-scroll-bottom:hover,
.scroll-bottom:hover {
    background: var(--gray-50);
    border-color: var(--primary);
}

.btn-scroll-bottom svg,
.scroll-bottom svg {
    width: 20px;
    height: 20px;
    color: var(--gray-600);
}

/* Chat Footer */
.chat-footer {
    padding: 1rem 1.5rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
    background: var(--white);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    position: relative;
    z-index: 10;
}

.chat-footer-inner {
    max-width: 800px;
    margin: 0 auto;
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    background: var(--gray-50);
    border: 1px solid var(--gray-300);
    border-radius: 16px;
    padding: 0.75rem 1rem;
    transition: border-color 0.2s;
    position: relative;
    min-height: 52px;
}

.chat-input-wrapper:focus-within {
    border-color: var(--primary);
}

.chat-input-icon {
    color: var(--accent);
    flex-shrink: 0;
}

.chat-input-icon svg {
    width: 20px;
    height: 20px;
}

.chat-input {
    flex: 1;
    border: none;
    background: transparent;
    /* без inherit textarea берёт UA-monospace — плейсхолдер выглядел «печатным»/сломанным */
    font-family: inherit;
    font-size: 0.9375rem;
    color: var(--gray-800);
    resize: none;
    outline: none;
    max-height: 150px;
    line-height: 1.5;
    min-height: 24px;
    -webkit-appearance: none;
    appearance: none;
}

.chat-input::placeholder {
    color: var(--gray-500);
}

.chat-input-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.btn-voice {
    background: transparent;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--gray-500);
    border-radius: 8px;
    transition: all 0.2s;
}

.btn-voice:hover {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-voice svg {
    width: 20px;
    height: 20px;
}

.btn-send {
    background: var(--primary);
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--white);
    border-radius: 8px;
    transition: all 0.2s;
}

.btn-send:hover {
    background: var(--primary-light);
}

.btn-send:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
}

.btn-send svg {
    width: 20px;
    height: 20px;
}

.chat-disclaimer {
    text-align: center;
    font-size: 0.625rem;
    /* safety-текст остаётся читаемым (итог ревью); де-акцент даёт краткая формулировка */
    color: var(--gray-500);
    margin-top: 0.75rem;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: flex-start;
    justify-content: center;
    padding: 20px 20px;
    overflow-y: auto;
}

/* Centered small modals (confirm/delete) */
.modal-overlay.modal-overlay-center {
    align-items: center;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: white;
    border-radius: 24px;
    padding: 3rem;
    max-width: 1000px;
    width: 100%;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s ease;
    margin: auto;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    /* Firefox: тонкий скролл вместо широкого нативного */
    scrollbar-width: thin;
    scrollbar-color: var(--gray-300) transparent;
}

/* Тонкий стилизованный скролл модалок — вместо широкого нативного, который
   «резал» скруглённый угол (border-radius: 24px) и смотрелся грубо. Согласован
   с .aside-body; отступ трека держит бегунок в стороне от скруглённых углов. */
.modal::-webkit-scrollbar {
    width: 8px;
}

.modal::-webkit-scrollbar-track {
    background: transparent;
    margin: 20px 0;
}

.modal::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 4px;
}

.modal::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

.modal.modal-confirm {
    max-width: 560px;
    padding: 2.5rem 2.75rem;
}

.modal > h3,
.modal > .bonus-banner,
.modal > .modal-tabs,
.modal > .tab-content {
    max-width: 650px;
    margin-left: auto;
    margin-right: auto;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: var(--primary-bg);
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-600);
    transition: color 0.3s, background 0.3s;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--gray-800);
    background: var(--primary-light);
}

/* Агентская модалка (супервизор/академик): крестик ЗАКРЕПЛЁН, скроллится только контент.
   Сама .agent-modal не прокручивается (overflow:hidden) → .modal-close (absolute) не уезжает;
   внутренняя .agent-modal-scroll получает бывший паддинг .modal и прокручивается. */
.modal.agent-modal {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
    /* На весь экран, без тёмных полос по бокам. position:fixed + inset:0 надёжно перекрывает
       фон-оверлей во весь вьюпорт независимо от его flex-раскладки (overlay показывается
       инлайновым style.display=flex, поэтому width:100% на flex-элементе был ненадёжен). */
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: auto;
    max-width: none;
    min-height: 0;
    max-height: none;
    margin: 0;
    border-radius: 0;
}

/* Оверлей окна рекомендаций — без внутреннего паддинга и без собственного скролла
   (скроллится .agent-modal-scroll внутри модалки). */
#agentModal.modal-overlay {
    padding: 0;
    overflow: hidden;
}

/* Крестик поверх скролла — непрозрачный фон (var(--primary-bg) из базового .modal-close),
   чтобы контент не «просвечивал» под ним при прокрутке. */
.modal.agent-modal .modal-close {
    z-index: 2;
}

/* Контент читаемой ширины по центру — модалка белая на весь экран, но текст не растягивается
   на широких мониторах. На узких (< ~720px) блоки занимают всю ширину. */
.agent-modal-scroll > .agent-modal-title,
.agent-modal-scroll > .agent-modal-desc-wrap,
.agent-modal-scroll > .agent-modal-body,
.agent-modal-scroll > .agent-modal-safety-wrap {
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
}

.agent-modal-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 3rem;
    scrollbar-width: thin;
    scrollbar-color: var(--gray-300) transparent;
}

.agent-modal-scroll::-webkit-scrollbar {
    width: 8px;
}

.agent-modal-scroll::-webkit-scrollbar-track {
    background: transparent;
    margin: 20px 0;
}

.agent-modal-scroll::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 4px;
}

.agent-modal-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

@media (max-width: 480px) {
    .agent-modal-scroll {
        padding: 2rem 1.5rem;
        padding-bottom: calc(2rem + env(safe-area-inset-bottom));
    }
}

.modal h3 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    color: var(--gray-800);
    font-family: 'Inter', sans-serif;
    font-weight: 700;
}

/* Confirm/Delete modal buttons (Да/Нет) */
.modal-title {
    text-align: center;
}

/* ===== Окно «Профиль»: десктоп — центрированная карточка; моб — на весь экран =====
   Единый стандарт полноэкранных окон на мобиле (как «Моя анкета»). */
.profile-modal {
    max-width: 520px;
    width: 92%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.profile-modal #profileBody {
    flex: 1;
    min-height: 0;
    overflow: auto;
}

@media (max-width: 768px) {
    /* убираем внешние отступы overlay, чтобы карточка легла на весь экран */
    #profileModal.modal-overlay {
        padding: 0;
        overflow: hidden;
    }

    .profile-modal {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        max-width: none;
        height: auto;
        max-height: none;
        border-radius: 0;
        margin: 0;
        box-sizing: border-box;
        background: var(--white);
        overflow: hidden;
        padding: calc(1.5rem + env(safe-area-inset-top, 0px)) 1.25rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
    }
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    margin-top: 1.25rem;
}

.btn-modal {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 0.9rem 1.25rem;
    min-width: 140px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.btn-modal:active {
    transform: translateY(1px);
}

.btn-modal:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(123, 106, 175, 0.25);
}

.btn-modal-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-modal-danger:hover {
    background: #d93431;
    box-shadow: 0 10px 25px rgba(229, 57, 53, 0.25);
}

.btn-modal-cancel {
    background: #fff;
    -webkit-appearance: none;
    color: var(--gray-700);
    border-color: var(--gray-300);
}

.btn-modal-cancel:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

/* Основная (primary) кнопка модалок — фиолетовый градиент, канонический для сайта.
   Стандарт: используйте .btn-modal.btn-modal-primary для главного действия в окне. */
.btn-modal-primary {
    background: linear-gradient(135deg, #9F7AEA 0%, #805AD5 50%, #6B46C1 100%);
    color: var(--white);
    box-shadow: 0 4px 15px rgba(128, 90, 213, 0.25);
}

.btn-modal-primary:hover {
    box-shadow: 0 8px 22px rgba(128, 90, 213, 0.38);
    transform: translateY(-1px);
}

@media (max-width: 480px) {
    .modal-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-modal {
        width: 100%;
        min-width: 0;
    }
}

.bonus-banner {
    background: linear-gradient(135deg, #FFF7ED 0%, #FEF3E8 100%);
    border: 2px solid #FFE4CC;
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.bonus-banner p {
    margin: 0;
    color: var(--gray-800);
    font-size: 0.95rem;
    line-height: 1.5;
}

.bonus-amount {
    font-weight: 700;
    color: var(--gray-900);
}

.modal-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--gray-200);
}

.tab-button {
    flex: 1;
    background: none;
    border: none;
    padding: 1rem;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.3s;
    border-bottom: 3px solid transparent;
    position: relative;
    bottom: -2px;
}

.tab-button.active {
    color: var(--gray-900);
    border-bottom-color: #5B52E8;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.info-text {
    color: var(--gray-600);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.security-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: #5B52E8;
    text-decoration: none;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.security-link:hover {
    text-decoration: underline;
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
}

.form-group label {
    font-weight: 600;
    color: var(--gray-800);
    font-size: 0.95rem;
}

.phone-input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.phone-prefix {
    padding: 0.9rem 1rem;
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    background: var(--gray-100);
    color: var(--gray-800);
    font-weight: 600;
    min-width: 60px;
    text-align: center;
}

.phone-input-wrapper input {
    flex: 1;
}

.form-group input,
.form-group textarea {
    padding: 0.9rem 1.2rem;
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    transition: border-color 0.3s;
    background: var(--gray-50);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #5B52E8;
}

.form-group textarea {
    min-height: 120px;
    resize: vertical;
}

.password-requirements {
    margin-top: 0.75rem;
    padding: 0;
}

.password-requirements li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--gray-600);
    margin-bottom: 0.4rem;
    list-style: none;
}

.password-requirements li::before {
    content: '\2713';   /* ✓ escape — не зависит от кодировки */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--gray-200);
    color: var(--gray-600);
    font-size: 0.7rem;
    font-weight: bold;
}

.toggle-password {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-600);
    padding: 0.5rem;
}

.register-button {
    background: #5B52E8;
    color: white;
    padding: 1rem 2rem;
    border: none;
    border-radius: 50px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Inter', sans-serif;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.register-button:hover {
    background: #4942C7;
    transform: translateY(-2px);
}

.login-link {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--gray-600);
    font-size: 0.95rem;
}

.login-link a {
    color: #5B52E8;
    text-decoration: none;
    font-weight: 600;
}

.login-link a:hover {
    text-decoration: underline;
}

.terms-text {
    text-align: center;
    font-size: 0.85rem;
    color: var(--gray-600);
    margin-top: 1.5rem;
    line-height: 1.5;
}

.terms-text a {
    color: #5B52E8;
    text-decoration: none;
}

.terms-text a:hover {
    text-decoration: underline;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--gray-800);
    color: var(--white);
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-size: 0.875rem;
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Mobile Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
}

.sidebar-overlay.show {
    display: block;
}

/* Responsive */
@media (max-width: 768px) {
    .chat-aside {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 300;
        transform: translateX(-100%);
        transition: transform 0.3s;
    }

    /* На мобиле лого + «Vera |» в тайтле скрыты (место под усечение названия) */
    .chat-title-brand {
        display: none;
    }

    .chat-aside.open {
        transform: translateX(0);
    }

    .btn-mobile-menu {
        display: flex;
    }

    /* Левая группа занимает всё свободное место и усекает длинный тайтл «…»,
       чтобы иконка профиля оставалась прижатой к правому краю */
    .chat-header-left {
        flex: 1;
        min-width: 0;
    }

    .chat-title {
        font-size: 0.875rem;
    }

    .chat-body-scroll {
        padding: 1rem 1rem 2rem 1rem;
    }

    .message-content {
        max-width: 95%;
    }

    .btn-scroll-bottom {
        bottom: 1rem;
    }

    .chat-footer {
        padding: 0.75rem 1rem;
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    }
    
    .chat-input-wrapper {
        min-height: 48px;
    }
    
    .chat-input {
        font-size: 16px; /* iOS не будет зумить при фокусе */
        -webkit-text-size-adjust: 100%;
    }

    .chat-disclaimer {
        display: none;
    }

    .modal {
        padding: 2.5rem 2rem;
    }
}

@media (max-width: 480px) {
    .modal-overlay {
        padding: 0;
        align-items: stretch;
    }

    /* Confirm/Delete modal should stay centered (not full-screen) */
    .modal-overlay.modal-overlay-center {
        padding: 20px;
        align-items: center;
    }

    .modal {
        max-width: 100%;
        width: 100%;
        border-radius: 0;
        padding: 2rem 1.5rem;
        max-height: 100vh;
        max-height: 100dvh;
        padding-bottom: calc(2rem + env(safe-area-inset-bottom));
        margin: 0;
    }

    .modal.modal-confirm {
        width: 100%;
        max-width: 560px;
        border-radius: 24px;
        padding: 2.25rem 1.75rem;
        max-height: calc(100vh - 40px);
        margin: auto;
    }

    .modal-close {
        top: 1rem;
        right: 1rem;
    }
}

/* Круглый спиннер для генерации текста */
.typing-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-left: 4px;
    border: 2px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spinTyping 0.8s linear infinite;
    vertical-align: middle;
}

/* Спиннер + подпись "Уже скоро" (используется в non-streaming regenerate loader) */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 6px;
    vertical-align: middle;
}

.typing-label {
    font-size: 0.8125rem;
    color: var(--gray-500);
    user-select: none;
    white-space: nowrap;
}

@keyframes spinTyping {
    to {
        transform: rotate(360deg);
    }
}

/* Кнопка "Стоп" */
.btn-stop {
    background: var(--gray-600);
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--white);
    border-radius: 8px;
    transition: all 0.2s;
    animation: stopPulse 1.5s ease-in-out infinite;
}

.btn-stop:hover {
    background: var(--gray-700);
}

.btn-stop svg {
    width: 20px;
    height: 20px;
}

@keyframes stopPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(117, 117, 117, 0.4);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(117, 117, 117, 0);
    }
}

.char-limit-alert {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: #E53935;
    color: white;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 500;
    z-index: 100;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.char-limit-alert span {
    display: flex;
    align-items: center;
    gap: 8px;
}

#currentCharCount {
    font-weight: 700;
}

/*
   Важно: раньше здесь был iOS-хак с фиксированным footer и большим padding-bottom,
   который создавал лишнее «серое поле» и большой зазор над полем ввода.
   Оставляем только фикс против автозума (уже есть в @media max-width:768px).
*/

/* Android Chrome фиксы */
@media screen and (max-width: 768px) {
    /* Для всех мобильных устройств */
    .chat-input-wrapper {
        -webkit-tap-highlight-color: transparent;
    }
    
    .chat-input {
        /* Убираем outline на Android */
        -webkit-tap-highlight-color: transparent;
        /* Размер шрифта для предотвращения автозума */
        font-size: max(16px, 0.9375rem);
    }
    
    /* Фикс для Android Chrome при появлении клавиатуры */
    .chat-footer {
        background: #fff;
    -webkit-appearance: none;
    }
}

/* =========================
   Lazy Loading Indicators
   ========================= */

/* Индикатор загрузки старых сообщений */
.lazy-load-indicator {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem;
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.lazy-load-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Индикатор что все сообщения загружены */
.all-messages-loaded {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    color: var(--gray-400);
    font-size: 0.8125rem;
    font-style: italic;
    margin-bottom: 1rem;
}

.all-messages-loaded span {
    padding: 0.5rem 1.25rem;
    background: var(--gray-100);
    border-radius: 20px;
}

/* Мобильная адаптация индикаторов */
@media (max-width: 768px) {
    .lazy-load-indicator,
    .all-messages-loaded {
        padding: 0.75rem;
        font-size: 0.8125rem;
    }
    
    .lazy-load-spinner {
        width: 18px;
        height: 18px;
    }
}

/* =========================
   Coming Soon Modal
   ========================= */
.modal.modal-coming-soon {
    max-width: 600px;
    padding: 2.5rem;
    text-align: center;
}

.coming-soon-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}

.coming-soon-icon {
    font-size: 3.5rem;
    margin-bottom: 0.5rem;
    animation: rocketBounce 2s ease-in-out infinite;
}

@keyframes rocketBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.modal-coming-soon h3 {
    font-size: 2rem;
    color: var(--gray-900);
    margin-bottom: 0;
}

.coming-soon-subtitle {
    color: var(--gray-600);
    font-size: 1rem;
    margin: 0;
}

.coming-soon-features {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    margin-top: 0.5rem;
}

.coming-soon-feature {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    border-radius: 16px;
    text-align: left;
    transition: all 0.3s ease;
}

.coming-soon-feature.highlighted {
    background: linear-gradient(135deg, #F0EBF8 0%, #E8E3F5 100%);
    border-color: var(--primary-light);
    box-shadow: 0 4px 15px rgba(123, 106, 175, 0.15);
}

.coming-soon-feature .feature-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.coming-soon-feature .feature-content {
    flex: 1;
}

.coming-soon-feature .feature-content h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0 0 0.5rem 0;
}

.coming-soon-feature .feature-content p {
    font-size: 0.9375rem;
    color: var(--gray-600);
    line-height: 1.5;
    margin: 0;
}

.btn-coming-soon-ok {
    background: linear-gradient(135deg, #9F7AEA 0%, #805AD5 50%, #6B46C1 100%);
    color: white;
    padding: 1rem 3rem;
    border: none;
    border-radius: 50px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Inter', sans-serif;
    margin-top: 1rem;
    box-shadow: 0 4px 15px rgba(128, 90, 213, 0.35);
}

.btn-coming-soon-ok:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(128, 90, 213, 0.45);
}

.btn-coming-soon-ok:active {
    transform: translateY(0);
}

/* Мобильная адаптация Coming Soon Modal */
@media (max-width: 480px) {
    .modal.modal-coming-soon {
        padding: 2rem 1.5rem;
        border-radius: 24px;
    }
    
    .coming-soon-icon {
        font-size: 2.5rem;
    }
    
    .modal-coming-soon h3 {
        font-size: 1.5rem;
    }
    
    .coming-soon-feature {
        padding: 1rem;
        gap: 0.75rem;
    }
    
    .coming-soon-feature .feature-icon {
        font-size: 1.5rem;
    }
    
    .coming-soon-feature .feature-content h4 {
        font-size: 1rem;
    }
    
    .coming-soon-feature .feature-content p {
        font-size: 0.875rem;
    }
    
    .btn-coming-soon-ok {
        padding: 0.875rem 2rem;
        font-size: 1rem;
        width: 100%;
    }
}

/* =========================
   Audio Recording Interface
   ========================= */
.chat-audio-recorder {
    display: none;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: var(--gray-50);
    border: 2px solid var(--primary);
    border-radius: 16px;
    margin-bottom: 0.75rem;
}

.btn-audio-cancel {
    background: var(--gray-200);
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--gray-700);
    border-radius: 50%;
    transition: all 0.2s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-audio-cancel:hover {
    background: var(--gray-600);
    color: var(--white);
}

.btn-audio-cancel svg {
    width: 20px;
    height: 20px;
}

.audio-wave-container {
    flex: 1;
    background: transparent;
    border-radius: 8px;
    overflow: hidden;
    min-height: 40px;
}

.audio-wave {
    width: 100%;
    height: 40px;
}

.audio-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.audio-indicator {
    width: 8px;
    height: 8px;
    background: #be1111;
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

.audio-time {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    min-width: 45px;
}

/* Контейнер с кнопками отмены и отправки */
.audio-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Кнопка отправки аудио (галочка) */
.btn-audio-send {
    background: var(--accent);
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--white);
    border-radius: 50%;
    transition: all 0.2s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: sendPulse 1.5s ease-in-out infinite;
}

.btn-audio-send:hover {
    background: #4AA897;
}

.btn-audio-send svg {
    width: 20px;
    height: 20px;
}

@keyframes sendPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(91, 186, 168, 0.4);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(91, 186, 168, 0);
    }
}

/* Кнопка отправки при активной записи */
.btn-send.recording-active {
    background: var(--accent);
    animation: recordingPulse 1.5s ease-in-out infinite;
}

.btn-send.recording-active:hover {
    background: #4AA897;
}

@keyframes recordingPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(91, 186, 168, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(91, 186, 168, 0);
    }
}

/* Кнопка микрофона при активной записи (скрыта) */
.btn-voice.recording-hidden {
    display: none;
}

/* Мобильная адаптация аудио-записи */
@media (max-width: 768px) {
    .chat-audio-recorder {
        padding: 0.75rem;
        gap: 0.5rem;
    }
    
    .audio-wave-container {
        min-height: 35px;
    }
    
    .audio-wave {
        height: 35px;
    }
    
    .btn-audio-cancel {
        padding: 0.4rem;
    }
    
    .btn-audio-cancel svg {
        width: 18px;
        height: 18px;
    }
}

/* =========================
   Loop Interrupted Alert Modal
   ========================= */
.modal-loop-alert {
    max-width: 500px;
    padding: 2.5rem;
    text-align: center;
}

.loop-alert-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.loop-alert-icon {
    font-size: 3.5rem;
    animation: warningPulse 2s ease-in-out infinite;
}

@keyframes warningPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

.loop-alert-message {
    color: var(--gray-700);
    font-size: 1rem;
    line-height: 1.7;
    margin: 0;
    max-width: 400px;
}

.btn-loop-alert-ok {
    background: linear-gradient(135deg, #9F7AEA 0%, #805AD5 50%, #6B46C1 100%);
    color: white;
    padding: 1rem 3rem;
    border: none;
    border-radius: 50px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Inter', sans-serif;
    box-shadow: 0 4px 15px rgba(128, 90, 213, 0.35);
}

.btn-loop-alert-ok:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(128, 90, 213, 0.45);
}

.btn-loop-alert-ok:active {
    transform: translateY(0);
}

/* Мобильная адаптация Loop Alert Modal */
@media (max-width: 480px) {
    .modal.modal-loop-alert {
        padding: 2rem 1.5rem;
        border-radius: 24px;
    }
    
    .loop-alert-icon {
        font-size: 2.5rem;
    }
    
    .loop-alert-message {
        font-size: 0.9375rem;
    }
    
    .btn-loop-alert-ok {
        padding: 0.875rem 2rem;
        font-size: 1rem;
        width: 100%;
    }
}

/* =========================
   Microphone Permission Modal
   ========================= */
.modal.modal-microphone {
    max-width: 480px;
    padding: 2.5rem;
    text-align: center;
}

.microphone-modal-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}

.microphone-modal-icon {
    font-size: 3.5rem;
    margin-bottom: 0.5rem;
    animation: micPulse 2s ease-in-out infinite;
}

@keyframes micPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.85;
    }
}

.modal-microphone h3 {
    font-size: 1.5rem;
    color: var(--gray-900);
    margin: 0;
}

.microphone-modal-text {
    color: var(--gray-700);
    font-size: 1rem;
    line-height: 1.6;
    margin: 0;
    max-width: 380px;
}

.microphone-modal-hint {
    color: var(--gray-500);
    font-size: 0.875rem;
    line-height: 1.5;
    margin: 0;
    padding: 0.75rem 1rem;
    background: var(--gray-50);
    border-radius: 12px;
    max-width: 380px;
}

.microphone-modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
    margin-top: 0.5rem;
}

.btn-microphone-help {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    background: var(--gray-100);
    border: 2px solid var(--gray-300);
    border-radius: 50px;
    color: var(--gray-700);
    font-size: 0.9375rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-microphone-help:hover {
    background: var(--gray-200);
    border-color: var(--gray-400);
    color: var(--gray-800);
}

.btn-microphone-help svg {
    width: 18px;
    height: 18px;
}

.btn-microphone-retry {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, #9F7AEA 0%, #805AD5 50%, #6B46C1 100%);
    border: none;
    border-radius: 50px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(128, 90, 213, 0.35);
}

.btn-microphone-retry:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(128, 90, 213, 0.45);
}

.btn-microphone-retry:active {
    transform: translateY(0);
}

.btn-microphone-retry svg {
    width: 18px;
    height: 18px;
}

/* Мобильная адаптация Microphone Permission Modal */
@media (max-width: 480px) {
    .modal.modal-microphone {
        padding: 2rem 1.5rem;
        border-radius: 24px;
    }
    
    .microphone-modal-icon {
        font-size: 2.5rem;
    }
    
    .modal-microphone h3 {
        font-size: 1.25rem;
    }
    
    .microphone-modal-text {
        font-size: 0.9375rem;
    }
    
    .microphone-modal-hint {
        font-size: 0.8125rem;
    }
    
    .btn-microphone-help,
    .btn-microphone-retry {
        width: 100%;
    }
}

/* =========================
   Transcription Status
   ========================= */
.transcription-status {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    background: linear-gradient(135deg, #F0EBF8 0%, #E8E3F5 100%);
    border: 2px solid var(--primary-light);
    border-radius: 12px;
    margin-top: 0.75rem;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.transcription-status span {
    color: var(--gray-700);
    font-size: 0.9375rem;
    font-weight: 500;
}

.transcription-loader {
    width: 20px;
    height: 20px;
    border: 3px solid var(--primary-bg);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: transcriptionSpin 0.8s linear infinite;
}

@keyframes transcriptionSpin {
    to {
        transform: rotate(360deg);
    }
}

/* Мобильная адаптация статуса транскрибации */
@media (max-width: 768px) {
    .transcription-status {
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }
    
    .transcription-status span {
        font-size: 0.875rem;
    }
    
    .transcription-loader {
        width: 18px;
        height: 18px;
        border-width: 2.5px;
    }
}

/* =========================
   Recording Warning Banner
   ========================= */
.recording-warning-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: none;
    justify-content: center;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #FF9800 0%, #F57C00 100%);
    box-shadow: 0 4px 15px rgba(255, 152, 0, 0.35);
    animation: slideDownBanner 0.3s ease;
}

.recording-warning-banner.show {
    display: flex;
}

@keyframes slideDownBanner {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.recording-warning-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    max-width: 800px;
    color: white;
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.4;
    text-align: center;
}

.recording-warning-content svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    stroke: white;
    animation: warningIconPulse 1.5s ease-in-out infinite;
}

@keyframes warningIconPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.1);
    }
}

/* Мобильная адаптация баннера предупреждения */
@media (max-width: 768px) {
    .recording-warning-banner {
        padding: 0.625rem 0.75rem;
    }
    
    .recording-warning-content {
        font-size: 0.8125rem;
        gap: 0.5rem;
    }
    
    .recording-warning-content svg {
        width: 18px;
        height: 18px;
    }
}

@media (max-width: 480px) {
    .recording-warning-content {
        font-size: 0.75rem;
        text-align: left;
    }
    
    .recording-warning-content svg {
        width: 16px;
        height: 16px;
    }
}

/* =========================
   Connection Lost Banner
   ========================= */
.connection-lost-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    display: none;
    justify-content: center;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #E53935 0%, #C62828 100%);
    box-shadow: 0 4px 15px rgba(229, 57, 53, 0.35);
    animation: slideDownBanner 0.3s ease;
}

.connection-lost-banner.show {
    display: flex;
}

.connection-lost-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    max-width: 800px;
    color: white;
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.4;
    text-align: center;
}

.connection-lost-content svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    stroke: white;
    animation: wifiPulse 2s ease-in-out infinite;
}

@keyframes wifiPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Мобильная адаптация баннера потери соединения */
@media (max-width: 768px) {
    .connection-lost-banner {
        padding: 0.625rem 0.75rem;
    }
    
    .connection-lost-content {
        font-size: 0.8125rem;
        gap: 0.5rem;
    }
    
    .connection-lost-content svg {
        width: 18px;
        height: 18px;
    }
}

@media (max-width: 480px) {
    .connection-lost-content {
        font-size: 0.75rem;
        text-align: left;
    }
    
    .connection-lost-content svg {
        width: 16px;
        height: 16px;
    }
}

/* =========================
   Message Failed & Retry Button
   ========================= */

/* Сообщение с ошибкой */
.message-ai.message-failed .message-content {
    background: linear-gradient(135deg, #FFF5F5 0%, #FFF0F0 100%);
    border: 1px solid #FFCDD2;
}

/* Кнопка "Повторить" */
.btn-retry {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 6px;
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 0.5rem;
}

.btn-retry:hover {
    background: var(--primary-light);
    transform: translateY(-1px);
}

.btn-retry:active {
    transform: translateY(0);
}

.btn-retry:disabled {
    background: var(--gray-400);
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
}

.btn-retry:disabled:hover {
    background: var(--gray-400);
    transform: none;
}

.btn-retry svg {
    width: 12px;
    height: 12px;
}

/* Мобильная адаптация кнопки "Повторить" */
@media (max-width: 768px) {
    .btn-retry {
        padding: 0.3rem 0.625rem;
        font-size: 0.6875rem;
    }

    .btn-retry svg {
        width: 11px;
        height: 11px;
    }
}

/* =========================================================
   Подбор психолога: карточка "готовый запрос" + CTA-кнопка
   Рендерятся из токенов [[REQUEST]]…[[/REQUEST]] и [[MATCH]]
   (formatMessage в chat-common.js).
   ========================================================= */
.request-card {
    margin: 0.75rem 0;
    border: 1px solid var(--primary-light);
    background: var(--primary-bg);
    border-radius: 14px;
    overflow: hidden;
}

.request-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    background: rgba(123, 106, 175, 0.12);
}

.request-card-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary);
}

.request-card-copy {
    flex: 0 0 auto;
    border: 1px solid var(--primary-light);
    background: var(--white);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.3rem 0.625rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.request-card-copy:hover {
    background: var(--primary);
    color: var(--white);
}

.request-card-body {
    padding: 0.875rem;
    color: var(--gray-800);
    line-height: 1.6;
    white-space: normal;
}

/* CTA: интеллектуальный подбор психолога */
/* Ссылки на смежных ассистентов внутри ответа (ИИ-Нутрициолог/ИИ-Коуч/ИИ-Психолог/Подбор психолога). */
.message-content .assistant-link {
    color: var(--primary);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-thickness: 1px;
}
.message-content .assistant-link:hover {
    color: var(--primary-light);
    text-decoration: none;
}

.message-cta-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 0.5rem 0;
    padding: 0.75rem 1.25rem;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
    color: var(--white);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
    text-decoration: none;
    border-radius: 12px;
    box-shadow: 0 4px 14px rgba(123, 106, 175, 0.32);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.message-cta-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(123, 106, 175, 0.42);
    color: var(--white);
}

@media (prefers-reduced-motion: reduce) {
    .message-cta-button,
    .request-card-copy {
        transition: none;
    }
    .message-cta-button:hover {
        transform: none;
    }
}

@media (max-width: 768px) {
    .message-cta-button {
        display: flex;
        width: 100%;
        padding: 0.75rem 1rem;
        font-size: 0.9375rem;
    }
    .request-card-head {
        flex-wrap: wrap;
    }
}

/* =========================
   Рекомендации агентов: кнопки в футере (супервизор + академик) + плашка + модалка
   Академик — акцент --accent (бирюзовый); супервизор — акцент --primary (фиолетовый).
   ========================= */

/* Группа «Рекомендации:» с лейблом — держит две кнопки в одном ряду футера. */
.message-recos {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.message-recos-label {
    font-size: 0.75rem;
    color: var(--gray-500);
    user-select: none;
}

/* Кнопка «🔬 ИИ-академик ↗» — как .btn-message-action, в акцентном цвете.
   Тинт-фон виден уже в покое (почти как hover). */
.btn-message-action.btn-academic {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 600;
}

.btn-message-action.btn-academic:hover {
    background: var(--accent-light);
    color: var(--accent);
}

/* Кнопка «ИИ-супервизор ↗» — зеркально академику, акцент --primary.
   Тинт-фон виден уже в покое (почти как hover). */
.btn-message-action.btn-supervisor {
    background: var(--primary-bg);
    color: var(--primary);
    font-weight: 600;
}

.btn-message-action.btn-supervisor:hover {
    background: var(--primary-bg);
    color: var(--primary);
}

/* Общие иконка/стрелка для кнопок-рекомендаций. */
.btn-agent-icon,
.btn-academic-icon {
    font-size: 0.875rem;
    line-height: 1;
}

.btn-agent-arrow,
.btn-academic-arrow {
    font-size: 0.8125rem;
    opacity: 0.85;
}

/* Коучмарк-подсказка после первого ответа: указывает вверх на кнопку «ИИ-супервизор».
   Компактный «пузырь» в цвете супервизора с треугольником-указателем сверху. */
.supervisor-hint {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 100%;
    box-sizing: border-box;
    margin: 0.375rem 0 0.75rem;
    padding: 0.625rem 0.875rem;
    background: var(--primary-bg);
    border: 1.5px solid var(--primary);
    border-radius: 12px;
    animation: supervisorHintIn 0.4s ease both;
}

/* Треугольник-указатель вверх — примерно под строкой «Рекомендации: ИИ-супервизор». */
.supervisor-hint::before {
    content: '';
    position: absolute;
    top: -7px;
    left: 26px;
    width: 12px;
    height: 12px;
    background: var(--primary-bg);
    border-left: 1.5px solid var(--primary);
    border-top: 1.5px solid var(--primary);
    transform: rotate(45deg);
}

.supervisor-hint-arrow {
    flex-shrink: 0;
    font-size: 1.15rem;
    line-height: 1;
}

.supervisor-hint-text {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary);
    line-height: 1.35;
}

@keyframes supervisorHintIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .supervisor-hint { animation: none; }
}

/* Плашка-обратный-отсчёт — на всю ширину, заметная, но не тревожная.
   Иконку держим у ВЕРХА (align-items:flex-start) — под многострочным содержимым
   (заголовок + список пользы + CTA) она не «уплывает» в вертикальный центр. */
.academic-teaser {
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    width: 100%;
    box-sizing: border-box;
    margin: 1rem 0 0.5rem;
    padding: 0.875rem 1rem;
    background: var(--accent-light);
    border: 1.5px solid var(--accent);
    border-radius: 14px;
}

.academic-teaser-icon {
    flex-shrink: 0;
    font-size: 1.5rem;
    line-height: 1;
}

.academic-teaser-body {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.academic-teaser-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--gray-800);
    line-height: 1.35;
}

/* Инфо-карточка про ИИ-супервизора/команду — раскрывающийся список (нативный <details>)
   в цвете супервизора (--primary). Свёрнута по умолчанию: виден только заголовок + «Подробнее ▾». */
.team-teaser-details {
    width: 100%;
    box-sizing: border-box;
    margin: 1rem 0 0.5rem;
    background: var(--primary-bg);
    border: 1.5px solid var(--primary);
    border-radius: 14px;
    overflow: hidden;
}

/* Шапка-переключатель: иконка + заголовок слева, «Подробнее ▾» справа. */
.team-teaser-summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.875rem 1rem;
}

.team-teaser-summary::-webkit-details-marker {
    display: none;
}

.team-teaser-summary-icon {
    flex-shrink: 0;
    font-size: 1.5rem;
    line-height: 1;
}

/* Заголовок + подзаголовок — колонкой, чтобы подзаголовок всегда был виден в свёрнутой шапке. */
.team-teaser-summary-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.team-teaser-summary-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--gray-800);
    line-height: 1.35;
}

.team-teaser-summary-sub {
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--gray-700);
    line-height: 1.3;
}

.team-teaser-summary-more {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
}

.team-teaser-summary-more::after {
    content: '\25BE';   /* ▾ escape — не зависит от кодировки, не ломается без charset */
    font-size: 0.7rem;
    transition: transform 0.2s ease;
}

.team-teaser-details[open] .team-teaser-summary-more::after {
    transform: rotate(180deg);
}

/* Тело раскрытия: абзацы + список экспертов, разделённые аккуратными отступами. */
.team-teaser-details-body {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    padding: 0 1rem 0.875rem;
}

.team-teaser-lead {
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--gray-800);
}

.team-teaser-subhead {
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.4;
    color: var(--gray-800);
}

.team-teaser-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.team-teaser-list li {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.9375rem;
    line-height: 1.45;
    color: var(--gray-800);
}

.team-teaser-check {
    flex-shrink: 0;
    line-height: 1.45;
}

/* Список преимуществ внутри тизера академика — небольшой воздух до заголовка. */
.academic-teaser-list {
    margin: 0.125rem 0;
}

/* Кнопка «Продолжить» под вопросом анонима, упершегося в лимит: после регистрации отправляет тот же
   вопрос заново (вводить не нужно). Выравниваем к правому краю — под правым пузырём пользователя.
   Главная кнопка = фиолетовый градиент (стандарт проекта, см. .btn-modal-primary). */
.continue-gate {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.375rem;
    margin: 0.25rem 0 0.75rem;
}
.continue-gate-btn {
    padding: 0.625rem 1.5rem;
    background: linear-gradient(135deg, #9F7AEA, #805AD5, #6B46C1);
    color: var(--white, #fff);
    border: none;
    border-radius: 12px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(107, 70, 193, 0.25);
    transition: transform 0.15s, box-shadow 0.2s;
}
.continue-gate-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(107, 70, 193, 0.32);
}
.continue-gate-hint {
    max-width: 34ch;
    font-size: 0.8125rem;
    line-height: 1.35;
    color: var(--gray-500, #6b7280);
    text-align: right;
}

/* Модалка агента (супервизор/академик) теперь на весь экран — см. правила `.modal.agent-modal`
   выше (position:fixed; inset:0). Прежний компактный `max-width:640px` убран, чтобы окно было
   edge-to-edge без тёмных полос по бокам. Паддинг живёт на `.agent-modal-scroll`.
   Легаси-класс `.academic-modal` (не используется — модалка рендерится как `.agent-modal`). */
.modal.academic-modal {
    max-width: 640px;
    padding: 2rem 2.25rem 2.25rem;
}

/* Нейтральный заголовок (не привязан к цвету агента) — подходит и супервизору, и академику. */
.agent-modal-title,
.academic-modal-title {
    color: var(--gray-800) !important;
    font-size: 1.5rem !important;
    margin-bottom: 1rem !important;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.agent-modal-icon {
    line-height: 1;
}

/* Пояснение под заголовком — простым языком, для не-специалиста. Мягкий инфо-блок. */
.agent-modal-desc {
    margin: -0.25rem 0 1.25rem !important;
    padding: 0.75rem 0.9375rem;
    background: var(--gray-100);
    border-radius: 10px;
    font-size: 0.875rem;
    line-height: 1.55;
    color: var(--gray-700);
}

.agent-modal-body,
.academic-modal-body {
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--gray-800);
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* Обёртка пояснения под заголовком (раскрывающийся блок «Кто такой ИИ-супервизор ▾» или абзац). */
.agent-modal-desc-wrap {
    margin: -0.25rem 0 1.25rem;
}

/* Раскрывающийся блок-пояснение (свёрнут по умолчанию) — не занимает место, пока не нужен. */
.agent-modal-disclose {
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    background: var(--gray-100);
    overflow: hidden;
}

.agent-modal-disclose-summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
}

.agent-modal-disclose-summary::-webkit-details-marker {
    display: none;
}

.agent-modal-disclose-summary::after {
    content: '\25BE';   /* ▾ escape — не зависит от кодировки, не ломается без charset */
    font-size: 0.75rem;
    color: var(--gray-500);
    transition: transform 0.2s ease;
}

.agent-modal-disclose[open] .agent-modal-disclose-summary::after {
    transform: rotate(180deg);
}

/* Текст пояснения внутри раскрытия — фон даёт внешний <details>, поэтому здесь прозрачный. */
.agent-modal-disclose .agent-modal-desc {
    margin: 0 !important;
    padding: 0 0.875rem 0.875rem;
    background: transparent;
    border-radius: 0;
    font-size: 0.875rem;
    line-height: 1.55;
    color: var(--gray-700);
}

/* Рекомендация супервизора: фраза-рамка (лид) + пункты «• …». */
.superv-lead {
    margin: 0 0 0.875rem;
    font-size: 0.9375rem;
    line-height: 1.55;
    color: var(--gray-800);
}

.superv-para {
    margin: 0.75rem 0 0;
    font-size: 0.9375rem;
    line-height: 1.55;
    color: var(--gray-800);
}

.superv-points {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.superv-points li {
    position: relative;
    padding-left: 1.125rem;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--gray-800);
}

.superv-points li::before {
    content: '\2022';   /* • escape — не зависит от кодировки */
    position: absolute;
    left: 0;
    top: -0.02em;
    color: var(--accent);
    font-weight: 700;
}

/* Блок «проверка безопасности» под рекомендацией. Цвет — по verdict супервизора. */
.agent-modal-safety-wrap {
    margin-top: 1.25rem;
}

.superv-safety {
    padding: 1rem 1.125rem 1.125rem;
    border: 1.5px solid var(--accent);
    border-radius: 14px;
    background: var(--accent-light);
}

/* supportive — «на стабилизацию»: янтарь, НЕ зелёная «пройдено». */
.superv-safety--supportive {
    border-color: var(--warning);
    background: var(--warning-light);
}

/* crisis — «безопасность важнее всего»: красный, НЕ галочки «всё ок». */
.superv-safety--crisis {
    border-color: var(--danger);
    background: var(--danger-light);
}

.superv-safety-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.superv-safety-icon {
    flex-shrink: 0;
    font-size: 1.125rem;
    line-height: 1;
}

.superv-safety-title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--gray-800);
}

.superv-safety--supportive .superv-safety-title {
    color: var(--warning);
}

.superv-safety--crisis .superv-safety-title {
    color: var(--danger);
}

.superv-safety-sub {
    margin-bottom: 0.625rem;
    font-size: 0.875rem;
    line-height: 1.45;
    color: var(--gray-700);
}

.superv-safety-points {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.superv-safety-points li {
    position: relative;
    padding-left: 1.5rem;
    font-size: 0.875rem;
    line-height: 1.45;
    color: var(--gray-800);
}

/* passed — зелёные галочки «проверено». */
.superv-safety-points li::before {
    content: '\2713';   /* ✓ escape — не зависит от кодировки */
    position: absolute;
    left: 0;
    top: -0.02em;
    font-weight: 700;
    color: var(--accent);
}

/* Для supportive/crisis маркер — нейтральная точка, а НЕ галочка «пройдено». */
.superv-safety--supportive .superv-safety-points li::before {
    content: '\2022';   /* • escape — не зависит от кодировки */
    color: var(--warning);
}

.superv-safety--crisis .superv-safety-points li::before {
    content: '\2022';   /* • escape — не зависит от кодировки */
    color: var(--danger);
}

/* Блок «научная проверка» академика под заметкой. Синий для confirm/refine/correct; красный для safety. */
.acad-check {
    padding: 1rem 1.125rem 1.125rem;
    border: 1.5px solid var(--info);
    border-radius: 14px;
    background: var(--info-light);
}

/* safety — «приоритет безопасности» (вето/red flags): красный, НЕ «пройдено», без галочек. */
.acad-check--safety {
    border-color: var(--danger);
    background: var(--danger-light);
}

.acad-check-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.acad-check-icon {
    flex-shrink: 0;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.12em;   /* сдвигаем «галочки» ✓✓ ближе — читается как «сверено» */
    color: var(--info);
}

.acad-check--safety .acad-check-icon {
    letter-spacing: normal;
    color: var(--danger);
}

.acad-check-title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--gray-800);
}

.acad-check--safety .acad-check-title {
    color: var(--danger);
}

.acad-check-sub {
    margin-bottom: 0.625rem;
    font-size: 0.875rem;
    line-height: 1.45;
    color: var(--gray-700);
}

.acad-check-points {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.acad-check-points li {
    position: relative;
    padding-left: 1.5rem;
    font-size: 0.875rem;
    line-height: 1.45;
    color: var(--gray-800);
}

/* confirm/refine/correct — синие галочки «сверено». */
.acad-check-points li::before {
    content: '\2713';   /* ✓ escape — не зависит от кодировки */
    position: absolute;
    left: 0;
    top: -0.02em;
    font-weight: 700;
    color: var(--info);
}

/* safety — нейтральная точка (красная), а НЕ галочка «пройдено». */
.acad-check--safety .acad-check-points li::before {
    content: '\2022';   /* • escape — не зависит от кодировки */
    color: var(--danger);
}

/* Разбор академика (промпт v4): public_note из секций «### эмодзи Заголовок» рендерится
   карточками-блоками (сверка · взгляд науки · команда · усиление · куда движемся) вместо
   сплошного текста. Легаси-заметки и safety-режим без маркеров идут прежним плоским рендером. */
.acad-note-block {
    margin: 0 0 0.75rem;
    padding: 0.875rem 1rem 1rem;
    border: 1px solid var(--gray-200);
    border-left: 3px solid var(--info);
    border-radius: 12px;
    background: var(--gray-50);
}

.acad-note-block:last-child {
    margin-bottom: 0;
}

.acad-note-block-title {
    margin-bottom: 0.5rem;
    font-size: 0.9375rem;
    font-weight: 700;
    line-height: 1.35;
    color: var(--gray-800);
}

.acad-note-para {
    margin: 0 0 0.5rem;
    font-size: 0.9375rem;
    line-height: 1.55;
    color: var(--gray-800);
}

.acad-note-para:last-child {
    margin-bottom: 0;
}

.acad-note-points {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.acad-note-points li {
    position: relative;
    padding-left: 1.25rem;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--gray-800);
}

.acad-note-points li::before {
    content: '\2022';   /* • escape — не зависит от кодировки */
    position: absolute;
    left: 0.25rem;
    top: -0.02em;
    font-weight: 700;
    color: var(--info);
}

@media (prefers-reduced-motion: reduce) {
    .agent-modal-disclose-summary::after {
        transition: none;
    }
    .team-teaser-summary-more::after {
        transition: none;
    }
}

@media (max-width: 767px) {
    .academic-teaser {
        gap: 0.625rem;
        padding: 0.75rem 0.875rem;
        border-radius: 12px;
    }
    .academic-teaser-icon {
        font-size: 1.25rem;
    }
    .academic-teaser-title {
        font-size: 0.875rem;
    }
    .team-teaser-lead,
    .team-teaser-subhead,
    .team-teaser-list li {
        font-size: 0.875rem;
    }
    /* На узком экране «Подробнее ▾» не помещается рядом с многострочным заголовком —
       переносим его на отдельную строку под подзаголовком, выравнивая под текстом. */
    .team-teaser-summary {
        flex-wrap: wrap;
        align-items: flex-start;
        gap: 0.5rem;
        padding: 0.75rem 0.875rem;
    }
    .team-teaser-summary-icon {
        font-size: 1.25rem;
        width: 1.5rem;
        text-align: center;
    }
    .team-teaser-summary-title {
        font-size: 0.875rem;
    }
    .team-teaser-summary-more {
        flex-basis: 100%;
        box-sizing: border-box;
        padding-left: 2rem;   /* иконка 1.5rem + gap 0.5rem → под текстом */
        margin-top: 0.125rem;
    }
    .team-teaser-details-body {
        padding: 0 0.875rem 0.75rem;
    }
    .modal.agent-modal,
    .modal.academic-modal {
        padding: 1.75rem 1.25rem 2rem;
    }
    .agent-modal-title,
    .academic-modal-title {
        font-size: 1.25rem !important;
    }
    .superv-safety,
    .acad-check {
        padding: 0.875rem 0.9375rem 1rem;
        border-radius: 12px;
    }
    .superv-safety-title,
    .acad-check-title {
        font-size: 0.9375rem;
    }
    .acad-note-block {
        padding: 0.75rem 0.875rem 0.875rem;
        border-radius: 10px;
    }
    .acad-note-block-title,
    .acad-note-para,
    .acad-note-points li {
        font-size: 0.875rem;
    }
    /* На узких экранах группа рекомендаций переносится под «Копировать». */
    .message-recos {
        gap: 0.375rem;
    }
}

/* ============================================================
   УЛУЧШЕНИЯ КОНВЕРСИИ/БЕЗОПАСНОСТИ (2026-07-08, add-only):
   бейдж «3 ИИ», кнопка «Мне плохо», кризис-карточка, карточка
   «Что Vera поняла», клинические шкалы, «Мой прогресс».
   Все классы уникальны; значения — из токенов :root.
   ============================================================ */

/* --- Бейдж доверия «Проверяют 3 ИИ» в шапке --- */
.chat-trust-badge {
    display: inline-flex; align-items: center; gap: 5px; margin-left: 10px;
    padding: 4px 10px; border: 1px solid var(--accent); border-radius: 999px;
    background: var(--accent-light); color: #2f7a68; font-size: 0.78rem;
    font-weight: 600; cursor: pointer; white-space: nowrap; line-height: 1.1;
    transition: background .15s ease;
}
.chat-trust-badge:hover { background: #d9efe8; }
.chat-trust-badge-dot { display: inline-flex; align-items: center; }
.chat-trust-badge-dot svg { width: 12px; height: 12px; }
.chat-trust-badge:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Кризис-карточка с телефонами (под crisis-плашкой, в модалке, в результате шкалы) --- */
.crisis-help-card {
    margin-top: 12px; padding: 14px 16px; border: 1px solid #f2c2c2;
    border-left: 4px solid var(--danger); border-radius: 12px; background: #fff6f6;
}
.crisis-help-lead { font-size: 0.92rem; color: var(--gray-800); line-height: 1.5; margin-bottom: 12px; }
.crisis-help-phones { display: flex; flex-direction: column; gap: 8px; }
/* Номер СВЕРХУ, подпись под ним (колонка, не два столбца) */
.crisis-phone {
    display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px;
    border: 1px solid var(--gray-200); border-radius: 10px; background: var(--white);
    text-decoration: none; color: var(--gray-900); transition: border-color .15s ease, box-shadow .15s ease;
}
.crisis-phone:hover { border-color: var(--danger); box-shadow: 0 2px 8px rgba(229,57,53,.12); }
.crisis-phone-num { font-weight: 700; font-size: 1.02rem; color: var(--danger); white-space: nowrap; }
.crisis-phone-meta { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.crisis-phone-meta b { font-size: 0.9rem; color: var(--gray-800); }
.crisis-phone-note { font-size: 0.8rem; color: var(--gray-600); }
.crisis-phone-call {
    margin-top: 6px; font-size: 0.78rem; font-weight: 600; color: var(--white); background: var(--danger);
    padding: 5px 12px; border-radius: 999px; white-space: nowrap;
}
.crisis-help-foot { margin-top: 12px; font-size: 0.8rem; color: var(--gray-600); line-height: 1.45; }

/* --- Универсальная модалка улучшений (кризис/доверие/шкалы/прогресс) --- */
.improve-modal {
    max-width: 560px; width: 100%; background: var(--white); border-radius: 16px;
    padding: 26px 24px 22px; max-height: 88vh; overflow-y: auto; position: relative;
}
.improve-modal-title { margin: 0 0 10px; font-size: 1.25rem; }
.improve-modal-lead { margin: 0 0 16px; color: var(--gray-700); font-size: 0.95rem; line-height: 1.5; }
.improve-modal-foot { margin: 16px 0 0; font-size: 0.82rem; color: var(--gray-600); line-height: 1.45; }
/* Мобила ≤768px: окно на весь экран — единый стандарт модалок (эталон — «Профиль») */
@media (max-width: 768px) {
    .modal-overlay.improve-overlay { padding: 0; overflow: hidden; }
    .improve-modal {
        position: fixed; top: 0; right: 0; bottom: 0; left: 0;
        width: 100%; max-width: none; height: auto; max-height: none;
        border-radius: 0; margin: 0; box-sizing: border-box; overflow-y: auto;
        padding: calc(1.5rem + env(safe-area-inset-top, 0px)) 16px calc(1.5rem + env(safe-area-inset-bottom, 0px));
    }
    .crisis-phone-call { display: none; }
}

/* --- Пояснение «3 ИИ» (trust-flow) --- */
.trust-flow { display: flex; flex-direction: column; gap: 6px; }
.trust-step {
    display: flex; align-items: center; gap: 12px; padding: 12px 14px;
    border: 1px solid var(--gray-200); border-radius: 12px; background: var(--gray-50);
}
.trust-step-ic { font-size: 1.4rem; }
.trust-step b { display: block; font-size: 0.95rem; color: var(--gray-900); }
.trust-step span { display: block; font-size: 0.85rem; color: var(--gray-600); line-height: 1.4; }
.trust-arrow { text-align: center; color: var(--primary); font-size: 1.1rem; }

/* --- Карточка «Что Vera поняла о вас» --- */
.what-understood {
    margin: 12px 0; padding: 14px 16px; border: 1px solid var(--primary-light);
    border-radius: 14px; background: var(--primary-bg);
}
.wu-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.wu-ic { font-size: 1.15rem; }
.wu-title { font-weight: 700; font-size: 0.98rem; color: var(--gray-900); }
.wu-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.wu-list li { display: flex; gap: 8px; align-items: baseline; }
.wu-key { flex: 0 0 auto; min-width: 92px; font-size: 0.82rem; font-weight: 600; color: var(--primary); }
.wu-val { font-size: 0.9rem; color: var(--gray-800); line-height: 1.4; }
.wu-foot { margin-top: 12px; font-size: 0.82rem; color: var(--gray-600); line-height: 1.45; }

/* Вторичная кнопка «Позже/Закрыть» в модалках шкал (инлайн-оффер шкал из лога чата удалён). */
.scale-offer-later {
    background: transparent; color: var(--gray-600); border: 1px solid var(--gray-300);
    border-radius: 10px; padding: 9px 16px; font-size: 0.9rem; cursor: pointer;
}

/* --- Опросник шкалы --- */
.scale-form { display: flex; flex-direction: column; gap: 16px; margin-bottom: 18px; }
.scale-q-text { font-size: 0.92rem; color: var(--gray-900); margin-bottom: 8px; line-height: 1.4; }
.scale-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.scale-opt {
    padding: 9px 10px; border: 1px solid var(--gray-300); border-radius: 10px;
    background: var(--white); color: var(--gray-800); font-size: 0.85rem; cursor: pointer;
    text-align: center; transition: all .12s ease;
}
.scale-opt:hover { border-color: var(--primary-light); }
.scale-opt.selected { background: var(--primary); color: var(--white); border-color: var(--primary); }
.scale-submit-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.scale-submit {
    background: var(--primary); color: var(--white); border: none; border-radius: 10px;
    padding: 10px 20px; font-size: 0.92rem; font-weight: 600; cursor: pointer;
}
.scale-submit:disabled { opacity: .5; cursor: default; }
.scale-submit-hint { font-size: 0.82rem; color: var(--gray-500); }

/* --- Результат шкалы --- */
.scale-result { text-align: center; padding: 8px 0 4px; }
.scale-result-score { font-size: 2.4rem; font-weight: 800; color: var(--gray-900); line-height: 1; }
.scale-result-score span { font-size: 1rem; font-weight: 500; color: var(--gray-500); margin-left: 6px; }
.scale-result-bar { height: 10px; border-radius: 999px; background: var(--gray-200); overflow: hidden; margin: 14px 0 10px; }
.scale-result-bar i { display: block; height: 100%; border-radius: 999px; }
.scale-result-sev { font-size: 1rem; font-weight: 700; color: var(--gray-800); }
.scale-result-advice { font-size: 0.9rem; color: var(--gray-600); line-height: 1.5; margin-top: 8px; }
.scale-result-actions { justify-content: center; margin-top: 18px; }
/* Цвета уровней (меньше — лучше): зелёный→жёлтый→оранжевый→красный */
.scale-sev-minimal i, .scale-sev-minimal { background: #4caf50; }
.scale-sev-mild i, .scale-sev-mild { background: #8bc34a; }
.scale-sev-moderate i, .scale-sev-moderate { background: #ffb300; }
.scale-sev-moderately_severe i, .scale-sev-moderately_severe { background: #fb8c00; }
.scale-sev-severe i, .scale-sev-severe { background: var(--danger); }

/* --- «Мой прогресс» --- */
.scales-progress-body { display: flex; flex-direction: column; gap: 20px; }
.scales-progress-loading { color: var(--gray-500); font-size: 0.9rem; }
.scales-progress-title { font-weight: 700; font-size: 1rem; color: var(--gray-900); margin-bottom: 10px; }
.scales-progress-empty { font-size: 0.88rem; color: var(--gray-600); }
.scales-rows { display: flex; flex-direction: column; gap: 6px; }
.scales-row { display: flex; align-items: center; gap: 10px; }
.scales-row-date { flex: 0 0 auto; width: 78px; font-size: 0.8rem; color: var(--gray-500); }
.scales-row-bar { flex: 1; height: 10px; border-radius: 999px; background: var(--gray-200); overflow: hidden; }
.scales-row-bar i { display: block; height: 100%; }
.scales-row-score { flex: 0 0 auto; width: 28px; text-align: right; font-weight: 700; font-size: 0.88rem; color: var(--gray-800); }
.scales-delta { margin-top: 8px; font-size: 0.85rem; font-weight: 600; color: var(--gray-700); }
.scales-delta.good { color: #2e7d54; }
.scales-delta.bad { color: var(--danger); }
.scale-inline-link {
    margin-top: 10px; background: transparent; border: none; color: var(--primary);
    font-size: 0.85rem; font-weight: 600; cursor: pointer; padding: 0; text-decoration: underline;
}

/* --- Адаптив ≤600px --- */
@media (max-width: 600px) {
    .chat-trust-badge-text { display: none; }
    .chat-trust-badge { margin-left: 6px; padding: 5px 8px; }
    .scale-opts { grid-template-columns: 1fr; }
    .wu-key { min-width: 78px; }
}
