/* ==========================================================================
   Стили главной страницы (home) — макет НовГУ + встроенный RAG-чат.
   Базовые стили чата адаптированы из MVP-стилей public/css/app.css,
   чтобы сохранить единую визуальную логику, но под светлый фон страницы.
   ========================================================================== */

:root {
    --blue: #0a3cb8;
    --navy: #0a2d69;
    --ink: #111;
    --gray: #f6f7f9;
    --accent: #465ac8;
    /* Современная палитра чата: градиенты бренда + стекло (glassmorphism) */
    --grad-brand: linear-gradient(135deg, var(--navy) 0%, var(--blue) 55%, var(--accent) 100%);
    --glass-bg: rgba(255, 255, 255, .78);
    --glass-border: rgba(255, 255, 255, .65);
    --focus-ring: rgba(10, 60, 184, .16);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, .07);
    --shadow-lg: 0 24px 64px rgba(10, 45, 105, .16);
    --shadow-glow: 0 10px 30px rgba(10, 60, 184, .35);
    --radius-lg: 24px;
    --radius-pill: 999px;
    /* Скругление «экранов»: хедер-карточка и верх футера */
    --radius-screen: 44px;
    /* Сколько футера видно из-под сгиба на первом экране */
    --footer-peek: 64px;
    /* Палитра футера: тёмное «стекло» и приглушённый текст поверх градиента */
    --footer-glass: rgba(255, 255, 255, .08);
    --footer-glass-border: rgba(255, 255, 255, .18);
    --footer-text-muted: rgba(255, 255, 255, .72);
    --footer-line: rgba(255, 255, 255, .14);
    --accent-warm: #eea200;
    /* Порядок отрисовки полосы прокрутки страницы: должна быть над хедером (10) и футером (6) */
    --scroll-page-z: 60;
    --transition: .25s ease;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

html, body { height: 100%; }

body {
    margin: 0;
    /* Сам документ не прокручивается: скроллится только .page-scroll (PerfectScrollbar) */
    overflow: hidden;
    font-family: 'Nunito Variable', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--ink);
    /* Полотно страницы: из-за скруглений хедера/футера видно по краям */
    background: var(--gray);
    -webkit-font-smoothing: antialiased;
}

/* ===== прокрутка страницы (PerfectScrollbar вместо штатной полосы браузера) ===== */
.page-scroll {
    height: 100%;
    /* Полоса PS позиционируется абсолютно относительно короба прокрутки */
    position: relative;
    /* Нативный скролл сохраняем (нужен для тача и клавиатуры), но прячем его полосу */
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.page-scroll::-webkit-scrollbar { display: none; }
/* .ps по умолчанию ставит overflow:hidden — возвращаем прокручиваемость, specificity выше за счёт двух классов */
.page-scroll.ps { overflow-y: auto !important; }

/* Полосу PS поднимаем над хедером (z-index:5) и футером (z-index:6), иначе она под ними.
   Вид (цвет, ширина, прижатие к краю) — дефолтный PerfectScrollbar, как в блоке ответа ИИ */
.page-scroll > .ps__rail-y {
    z-index: var(--scroll-page-z);
}

a { text-decoration: none; transition: color var(--transition), background var(--transition), opacity var(--transition); }

/* Элементы форм берут шрифт браузера, а не наследуют от body — переопределяются на общий стек */
button, input, select, textarea { font-family: inherit; }
/* Каретка (курсор ввода) в полях — светлый фирменный синий */
input, textarea { caret-color: var(--accent); }
/* Толщина каретки CSS-свойством не задаётся: слой ui-caret.js рисует её поверх поля, нативная скрывается */
.ui-caret {
    position: absolute; z-index: 2; width: 2px; border-radius: 1px;
    background: var(--accent); pointer-events: none; visibility: hidden;
    animation: caretBlink 1.06s step-end infinite;
}
.ui-caret--on { visibility: visible; }
.has-ui-caret { caret-color: transparent; }
/* Зеркало поля: по нему меряется ширина набранного текста до каретки */
.ui-caret-mirror {
    position: absolute; top: 0; left: -9999px; white-space: pre;
    visibility: hidden; pointer-events: none;
}
@keyframes caretBlink { 50% { opacity: 0; } }
/* Каретка на тёмном стекле футера — светлая */
.footer .ui-caret { background: #fff; }

.container { max-width: 1220px; margin: 0 auto; padding: 0 15px; }

/* Плейсхолдеры изображений/иконок */
.img-ph { display: inline-block; background: #eef1f6; border: 1px dashed #b6c1d6; }
.icon-ph { display: inline-block; border-radius: 50%; background: currentColor; }

/* ===== появление блоков главной при загрузке ===== */
/* Шапка въезжает сверху, соц-рейл — справа; чат анимируется своим fadeIn. Подвал не анимируется: transform в keyframes растягивает прокручиваемую высоту вниз, из-за чего при загрузке снизу проступает фон */
@keyframes headerIn {
    from { opacity: 0; transform: translateY(-14px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes railIn {
    /* базовое центрирование translateY(-50%) сохраняется в keyframes */
    from { opacity: 0; transform: translate(20px, -50%); }
    to   { opacity: 1; transform: translate(0, -50%); }
}
@keyframes footerIn {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.site-header { animation: headerIn .6s ease-in both; }
.social-rail { animation: railIn   .6s ease-in .0s both; }
.footer      { animation: footerIn .6s ease-in .0s both; }

@media (prefers-reduced-motion: reduce) {
    .site-header, .social-rail { animation: none; }
}

/* ===== верхняя панель: бренд-градиент и пилюли-ссылки с выпадающими меню ===== */
.topbar {
    position: relative; z-index: 3; color: #fff; font-size: 13.5px;
    background: linear-gradient(100deg, var(--navy) 0%, var(--blue) 62%, #1a55cf 100%);
    border-top-left-radius: inherit; border-top-right-radius: inherit;
}
.topbar__inner { display: flex; align-items: center; gap: 20px; min-height: 48px; max-width: fit-content }
.topbar__menu {
    position: relative; display: flex; align-items: center; gap: 4px;
    margin-left: auto; flex-wrap: wrap; padding: 5px 0;
}
.topbar__link {
    display: inline-block; padding: 7px 13px; border-radius: var(--radius-pill);
    color: #fff; line-height: 1.25; white-space: nowrap; opacity: .88;
    transition: background var(--transition), color var(--transition), opacity var(--transition);
}
.topbar__link:hover { background: rgba(255, 255, 255, .14); opacity: 1; }

/* Активный раздел: мы на этой странице — инвертированная пилюля (правило идёт после :hover) */
.topbar__link.is-current { background: #fff; color: var(--navy); opacity: 1; }

/* Стрелка у пунктов с выпадающим меню: разворачивается вместе с открытием */
.has-sub::after {
    content: ""; display: inline-block; margin-left: 7px; vertical-align: middle;
    border: 4px solid transparent; border-bottom: 0; border-top-color: currentColor;
    transition: transform var(--transition);
}
.topbar__item { position: relative; }
.topbar__item.is-open > .has-sub::after,
.topbar__item:focus-within > .has-sub::after { transform: rotate(180deg); }

/* Выпадающая панель — светлое «стекло» поверх контента.
   Число колонок (--cols) подбирает JS: 1 — если список влезает по высоте экрана,
   дальше по одной добавляется, пока панель не станет ниже вьюпорта.
   --col-w и --col-gap — источник истины и для JS (он читает их вычисленными). */
.topbar__submenu {
    --shift: -50%;
    --nudge: 0px;
    --cols: 1;
    --col-w: 258px;
    --col-gap: 12px;
    position: absolute; top: calc(100% + 10px); left: 50%; z-index: 30;
    width: calc(var(--cols) * var(--col-w) + (var(--cols) - 1) * var(--col-gap) + 20px);
    max-width: calc(100vw - 32px);
    display: grid; align-items: start;
    grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
    row-gap: 2px; column-gap: var(--col-gap); padding: 8px;
    background: rgba(255, 255, 255, .94);
    backdrop-filter: blur(16px) saturate(1.5); -webkit-backdrop-filter: blur(16px) saturate(1.5);
    border: 1px solid var(--glass-border); border-radius: 18px;
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(10, 45, 105, .06);
    opacity: 0; visibility: hidden; pointer-events: none;
    transform: translate(calc(var(--shift) + var(--nudge, 0px)), -8px);
    transition: opacity .18s ease, transform .26s cubic-bezier(.22, 1, .36, 1), visibility .26s;
}
/* Открытое состояние: класс ставит JS (hover/тач), :focus-within — работа с клавиатуры */
.topbar__item.is-open > .topbar__submenu,
.topbar__item:focus-within > .topbar__submenu {
    opacity: 1; visibility: visible; pointer-events: auto;
    transform: translate(calc(var(--shift) + var(--nudge, 0px)), 0);
}
/* Хвостик-указатель на пункт меню */
.topbar__submenu::before {
    content: ''; position: absolute; top: -6px; left: 50%;
    width: 12px; height: 12px; transform: translateX(-50%) rotate(45deg);
    background: rgba(255, 255, 255, .94);
    border-left: 1px solid rgba(10, 45, 105, .08); border-top: 1px solid rgba(10, 45, 105, .08);
    border-radius: 3px 0 0 0;
}
/* Мостик между пунктом и панелью: иначе курсор срывается и меню закрывается */
.topbar__submenu::after { content: ''; position: absolute; top: -11px; left: 0; right: 0; height: 11px; }
/* --nudge подставляет JS, когда панель не влезает в экран по горизонтали */
/* Правые пункты прижимаем панель правым краем к пункту — иначе она за экраном */
.topbar__item:nth-last-child(-n+4) > .topbar__submenu { --shift: 0; left: auto; right: 0; }
.topbar__item:nth-last-child(-n+4) > .topbar__submenu::before { left: auto; right: 22px; transform: rotate(45deg); }

.topbar__submenu a {
    display: block; padding: 9px 12px; border-radius: 12px;
    color: var(--navy); font-size: 13.5px; line-height: 1.3; opacity: 1;
    transition: background var(--transition), color var(--transition), transform var(--transition);
}
.topbar__submenu a:hover { background: rgba(10, 60, 184, .08); color: var(--blue); transform: translateX(3px); }
.topbar__submenu a:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }

.site-header {
    flex: none;
    background: #fff;
    box-shadow: var(--shadow-sm);
    position: relative;
    /* Выпадные панели должны перекрывать и контент, и соцрейл (z-index:9) */
    z-index: 10;
    margin: 0 0 -44px;
    border-bottom-left-radius: 44px;
    border-bottom-right-radius: 44px;
    /* ⚠️ overflow:hidden здесь ставить нельзя: он обрежет выпадающие панели */
}
.header__main { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 24px; padding: 24px 15px 14px; }
.header__tools { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; }

/* Поиск — светлая пилюля; кольцо фокуса только в шапке, чтобы не влиять на футер */
.search { position: relative; width: 280px; max-width: 100%; }
.search input {
    width: 100%; padding: 11px 44px 11px 16px; background: #eef1f7; border: 1px solid transparent;
    border-radius: var(--radius-pill); font-size: 14px; color: #2b3242; outline: none;
    transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.search input:focus { background: #fff; border-color: rgba(10, 60, 184, .35); }
.search input::placeholder { color: #98a1b2; }
.site-header .search input:focus { box-shadow: 0 0 0 4px var(--focus-ring); }
.search__btn {
    position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
    width: 15px; height: 15px; border: 2px solid #a8b1c2; border-radius: 50%; background: transparent; cursor: pointer;
    transition: border-color var(--transition);
}
.search__btn:hover { border-color: var(--blue); }
.search__btn::after {
    content: ""; position: absolute; right: -5px; bottom: -2px; width: 8px; height: 2px;
    background: #a8b1c2; border-radius: 2px; transform: rotate(45deg);
    transition: background var(--transition);
}
.search__btn:hover::after { background: var(--blue); }

.site-header .corp {
    display: inline-flex; align-items: center; gap: 10px; padding: 5px 15px 5px 5px; opacity: 1;
    border-radius: var(--radius-pill); font-size: 14.5px; font-weight: 600; color: var(--navy);
    transition: color var(--transition), background var(--transition);
}
.site-header .corp:hover { color: var(--blue); background: var(--focus-ring); }
.corp .icon-ph {
    width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%; background: rgba(10, 60, 184, .1); color: var(--blue); font-size: 13px;
    transition: background var(--transition), color var(--transition);
}
.corp:hover .icon-ph { background: var(--grad-brand); color: #fff; }

.header__logo { justify-self: center; display: inline-flex; align-items: center; opacity: 1; }
.header__logo img { width: clamp(190px, 20vw, 275px); height: auto; }

/* ===== панель авторизации в шапке (гость / пользователь) ===== */
.auth-box { justify-self: end; display: flex; flex-direction: column; align-items: flex-end; gap: 7px; text-align: right; }
/* Гость: единая группа-сегменты «Войти | Регистрация» в одной градиентной пилюле */
.auth-box--guest {
    flex-direction: row; align-items: stretch; gap: 0;
    border-radius: var(--radius-pill); background: var(--grad-brand); box-shadow: var(--shadow-glow);
    overflow: hidden;
}
.auth-btn,
.auth-register {
    display: inline-flex; align-items: center; gap: 8px; padding: 8px 22px;
    border: 0; background: transparent; font-family: inherit; cursor: pointer;
    color: #fff; font-weight: 700; font-size: 14px; letter-spacing: .02em; white-space: nowrap;
    transition: background var(--transition);
}
.auth-btn:hover,
.auth-register:hover { color: #fff; background: rgba(255, 255, 255, .14); }
.auth-register { border-left: 1px solid rgba(255, 255, 255, .28); }

/* Правый блок шапки: отдельная кнопка админки + панель логина (не влияют на размеры друг друга) */
.header__right { justify-self: end; display: flex; align-items: center; gap: 24px; }
.auth-hello { font-size: 14px; color: var(--navy); }
.auth-name { font-weight: 700; color: var(--blue); }
/* Ссылка на админку — отдельная акцентная пилюля вне общего списка ссылок */
.auth-admin-group { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
.auth-admin {
    position: relative; height: 1.75rem;
    display: inline-flex; align-items: center; justify-content: center; padding: 0 14px 0 1.75rem;
    border-radius: var(--radius-pill); background: var(--grad-brand);
    color: #fff; font-size: 13px; font-weight: 600; line-height: 1; box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), filter var(--transition);
}
/* Иконка — кружок высотой с пилюлю, прижат к левому краю */
.auth-admin > i {
    position: absolute; left: 0; top: 0; bottom: 0;
    display: inline-flex; align-items: center; justify-content: center;
    width: 1.75rem; border-radius: 50%;
}
.auth-admin:hover { color: #fff; filter: brightness(1.06); box-shadow: var(--shadow-glow); }
.auth-links { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 7px; font-size: 13.5px; }
.auth-links a { font-weight: 600; color: var(--blue); }
.auth-links a:hover { color: var(--navy); text-decoration: underline; text-underline-offset: 3px; }
.auth-sep { color: #a8b1c2; }

/* ===== модалка входа (гость): открывается кнопкой «Войти» ===== */
.login-modal {
    position: fixed; inset: 0; z-index: 100; display: flex; overflow-y: auto; padding: 20px;
    opacity: 0; visibility: hidden;
    transition: opacity var(--transition), visibility var(--transition);
}
.login-modal.is-open { opacity: 1; visibility: visible; }
.login-modal__backdrop {
    position: fixed; inset: 0; background: rgba(10, 45, 105, .45);
    backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.login-modal__dialog {
    position: relative; margin: auto; width: 100%; max-width: 380px; padding: 30px 28px 26px;
    background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    transform: translateY(14px) scale(.98);
    transition: transform .3s cubic-bezier(.22, 1, .36, 1);
}
.login-modal.is-open .login-modal__dialog { transform: none; }
.login-modal__close {
    position: absolute; top: 14px; right: 14px; width: 34px; height: 34px;
    display: inline-flex; align-items: center; justify-content: center; border: 0; cursor: pointer;
    border-radius: 50%; background: #eef1f7; color: var(--navy); font-size: 15px;
    transition: background var(--transition), color var(--transition);
}
.login-modal__close:hover { background: var(--grad-brand); color: #fff; }
.login-modal__title { margin: 0 0 18px; text-align: center; font-size: 22px; font-weight: 800; color: var(--navy); }
.login-modal__error { margin-bottom: 16px; padding: 10px 14px; border-radius: 12px; background: rgba(220, 53, 69, .1); color: #b02537; font-size: 13.5px; text-align: center; }

.login-form { display: grid; }
.login-form__label { margin-top: 12px; font-size: 13px; font-weight: 600; color: var(--navy); }
.login-form__input {
    margin-top: 6px; padding: 11px 14px; border: 1px solid #d7deea; border-radius: 12px;
    font-family: inherit; font-size: 14px; color: #2b3242; outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.login-form__input:focus { border-color: rgba(10, 60, 184, .35); box-shadow: 0 0 0 4px var(--focus-ring); }
.login-form__input.is-invalid { border-color: #dc3545; }
.login-form__remember { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 13.5px; color: #5a6375; }
.login-form__submit {
    margin-top: 20px; padding: 12px; border: 0; border-radius: var(--radius-pill); cursor: pointer;
    background: var(--grad-brand); box-shadow: var(--shadow-glow); font-family: inherit;
    color: #fff; font-weight: 700; font-size: 15px;
    transition: transform var(--transition), filter var(--transition);
}
.login-form__submit:hover { color: #fff; transform: translateY(-2px); filter: brightness(1.06); }
.login-form__forgot { margin-top: 14px; text-align: center; font-size: 13px; font-weight: 600; color: var(--blue); }
.login-form__forgot:hover { color: var(--navy); text-decoration: underline; text-underline-offset: 3px; }

/* ===== боковая панель соцсетей (фиксирована по центру правой стороны экрана) ===== */
.social-rail {
    position: fixed;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 7px;
    z-index: 9;
}

.soc {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #ffffff;

    transition: transform 0.3s ease-out, background-color 0.3s ease-out;
}

.soc:hover {
    transform: translateY(-2px);
}

.soc * {
    transition: fill 0.3s ease-out;
}

.max-outer {
    fill: #ffffff
}

#max_widget:hover .max-outer, #max_widget:hover .max-frame, #rutube_widget:hover path {
    fill: #100943;
}

#vk_widget:hover path{
    fill: #0077FF;
}

#t_widget:hover path{
    fill: #0088cc;
}

#zen_widget:hover path{
    fill: #000000;
}

.widget {
    background: none !important;
}

.widget:hover path {
    fill: #eea200;
}

    /* ===== первый экран (хедер + контент; футер торчит на --footer-peek) ===== */
.first-screen {
    display: flex;
    flex-direction: column;
    flex: none;
    min-height: calc(100vh);
}

/* ===== контент ===== */
.content {
    flex: 1 0 auto;
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, #fbfcfe 0%, var(--gray) 100%);
}
/* Декоративные градиентные пятна бренда на фоне */
.content::before,
.content::after {
    content: ''; position: absolute; border-radius: 50%; filter: blur(90px); pointer-events: none;
}
.content::before { width: 480px; height: 480px; top: -160px; left: -140px; background: rgba(10, 60, 184, .10); }
.content::after { width: 520px; height: 520px; bottom: -220px; right: -160px; background: rgba(70, 90, 200, .12); }
.content__inner { width: 100%; }

/* ===== RAG-чат (адаптировано из app.css под светлый фон) ===== */
.chat-container {
    position: relative;
    z-index: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.link-to-chat { animation: fadeIn .6s ease-in; margin-bottom: 1.25rem; }
.link-to-chat .chat-link-btn {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .6rem 1.5rem; border-radius: var(--radius-pill);
    background: var(--grad-brand); color: #fff; font-weight: 600; font-size: .95rem;
    letter-spacing: .01em; box-shadow: var(--shadow-glow);
    transition: transform var(--transition), box-shadow var(--transition), filter var(--transition);
}
.link-to-chat .chat-link-btn:hover {
    color: #fff; transform: translateY(-2px); filter: brightness(1.1);
    box-shadow: 0 14px 36px rgba(10, 60, 184, .45);
}

.chat-title {
    font-size: clamp(1.9rem, 4vw, 2.75rem);
    font-weight: 800;
    letter-spacing: -.02em;
    margin: 0 0 .75rem;
    text-align: center;
    padding-inline: .15em;
    background: linear-gradient(120deg, var(--navy) 20%, var(--blue) 60%, var(--accent) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--navy); /* запас для браузеров без background-clip: text */
    animation: fadeIn .6s ease-in;
}

/* Подзаголовок-пояснение под приветствием */
.chat-subtitle {
    margin: 0 0 1.75rem; text-align: center; max-width: 560px;
    font-size: clamp(.9rem, 2vw, 1.05rem); line-height: 1.5; color: #5a6375;
    animation: fadeIn .6s ease-in;
}

.chat-greeting {
    overflow: hidden;
    transition: opacity .3s ease, transform .3s ease, max-height .35s ease, margin .35s ease;
}

.chat-title.chat-greeting {
    max-height: 8rem;
}

.chat-subtitle.chat-greeting {
    max-height: 6rem;
}

.chat-container.has-response .chat-greeting {
    opacity: 0;
    transform: translateY(-10px);
    max-height: 0;
    margin-top: 0;
    margin-bottom: 0;
    pointer-events: none;
}

.chat-box {
    position: relative;
    width: 100%;
    max-width: 860px;
    background: var(--glass-bg);
    backdrop-filter: blur(18px) saturate(1.6);
    -webkit-backdrop-filter: blur(18px) saturate(1.6);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 1.1rem 1.35rem;
    animation: fadeIn .6s ease-in;
    transition: box-shadow var(--transition), border-color var(--transition);
}

#chat-input { transition: color .2s ease, opacity .2s ease, background .2s ease; }
#chat-input:disabled,
#chat-input[disabled] { cursor: wait; opacity: .55; color: #6b7280; }
#chat-input:disabled::placeholder,
#chat-input[disabled]::placeholder { color: #6b7280; opacity: .75; }

.chat-input-row {
    display: flex; align-items: center; gap: .75rem;
    padding-bottom: .85rem; border-bottom: 1px solid rgba(10, 45, 105, .08);
}
.chat-input-row input {
    flex: 1; border: none; outline: none; font-size: 1.05rem; color: #1b1b18; background: transparent;
}
.chat-input-row input::placeholder { color: #9aa1b2; }

.icon-btn {
    border: none; background: transparent; color: #8a93a6; font-size: 1.25rem;
    padding: .35rem; border-radius: 50%; cursor: pointer;
    transition: color var(--transition), background var(--transition), transform var(--transition);
}
.icon-btn:hover { color: var(--accent); background: var(--focus-ring); transform: rotate(-8deg); }

.chat-bottom-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: .9rem; }

/* Вкладки режимов — стеклянная пилюля с горизонтальным скроллом на узких экранах */
.mode-tabs {
    position: relative;
    display: flex; align-items: center; gap: .2rem;
    background: rgba(10, 45, 105, .06); border: 1px solid rgba(255, 255, 255, .7);
    border-radius: var(--radius-pill); padding: .3rem;
    overflow-x: auto; scrollbar-width: none;
}
.mode-tabs::-webkit-scrollbar { display: none; }

.mode-tabs--pill {
    --tp: .3rem; --tg: .2rem; --i: 0;
    padding: var(--tp); gap: var(--tg);
}
.mode-tabs--pill .mode-tab {
    flex: 1 1 0; min-width: 8rem; justify-content: center;
    padding-left: 2.1rem;
}
.mode-tabs--pill .mode-tab > i {
    position: absolute; left: 0; top: 0; bottom: 0;
    display: inline-flex; align-items: center; justify-content: center;
    width: 2.1rem; border-radius: 50%;
}
.mode-tabs--pill:has(.mode-tab:nth-of-type(2).active) { --i: 1; }
.mode-tabs--pill:has(.mode-tab:nth-of-type(3).active) { --i: 2; }
.mode-pill {
    display: none;
    position: absolute; top: var(--tp); bottom: var(--tp); left: var(--tp);
    width: calc((100% - 2 * var(--tp) - 2 * var(--tg)) / 3);
    transform: translateX(calc(var(--i) * (100% + var(--tg))));
    border-radius: var(--radius-pill);
    background: var(--grad-brand);
    box-shadow: 0 4px 12px rgba(10, 60, 184, .3);
    transition: transform .38s cubic-bezier(.22, 1, .36, 1);
    pointer-events: none;
}
.mode-tabs--pill:has(.mode-pill) .mode-pill { display: block; }
.mode-tabs--pill:has(.mode-pill) .mode-tab.active { background: transparent; box-shadow: none; }

.mode-tab {
    position: relative; z-index: 1;
    border: none; background: transparent; padding: .45rem 1rem;
    border-radius: var(--radius-pill);
    font-size: .85rem; font-weight: 600; color: #5a6375; line-height: 1.2;
    display: inline-flex; align-items: center; gap: .4rem;
    cursor: pointer; white-space: nowrap; flex: none;
    transition: color var(--transition);
}
.mode-tab:hover { color: var(--blue); }
.mode-tab.active { color: #fff; background: var(--grad-brand); box-shadow: 0 4px 12px rgba(10, 60, 184, .3); }

.send-btn {
    width: 48px; height: 48px; flex-shrink: 0; border-radius: 50%; border: none;
    background: var(--grad-brand); color: #fff; font-size: 1.2rem;
    display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
    box-shadow: var(--shadow-glow);
    transition: box-shadow var(--transition), filter var(--transition);
}
.send-btn:hover { filter: brightness(1.1); box-shadow: 0 14px 34px rgba(10, 60, 184, .45); }

/* Блок ответа ИИ (скрыт по умолчанию) — та же стеклянная карта, что и chat-box */
.ai-response {
    width: 100%; max-width: 860px; margin-top: 1.5rem;
    background: var(--glass-bg);
    backdrop-filter: blur(18px) saturate(1.6);
    -webkit-backdrop-filter: blur(18px) saturate(1.6);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    padding: .75rem .5rem; text-align: left; display: none; animation: fadeIn .5s ease-in;
}
.ai-response.visible { display: block; }

.response-scroll { padding: .75rem 1rem; max-height: 56vh; overflow: hidden; position: relative; }

.ai-response-header {
    display: inline-flex; align-items: center; gap: .45rem;
    font-weight: 600; font-size: .82rem; letter-spacing: .04em; text-transform: uppercase;
    color: var(--blue);
    background: linear-gradient(135deg, rgba(10, 60, 184, .08), rgba(70, 90, 200, .12));
    border: 1px solid rgba(10, 60, 184, .12);
    padding: .35rem .9rem; border-radius: var(--radius-pill);
    margin: 0 0 .9rem .25rem;
}
.ai-response-content { color: #2c3345; line-height: 1.65; font-size: .98rem; animation: fadeIn .4s ease-in; }

.ai-loader { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .75rem; }

.ai-status-text {
    font-weight: 600; font-size: 1.5rem;
    display: flex; align-items: center; justify-content: center;
    animation: statusFadeIn .4s ease-out both;
}
.ai-status-value {
    background: linear-gradient(90deg, var(--blue) 0%, var(--blue) 40%, #3f63d6 50%, var(--blue) 60%, var(--blue) 100%);
    background-size: 200% 100%;
    -webkit-background-clip: text; background-clip: text; color: transparent;
    animation: shimmer 2.5s linear infinite;
}
@keyframes shimmer {
    from { background-position: 200% center; }
    to { background-position: -200% center; }
}
@keyframes statusFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes statusEnter {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes statusExit {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-20px); }
}
.status-enter { animation: statusEnter .3s ease-out both, shimmer 2.5s linear infinite; }
.status-exit { animation: statusExit .3s ease-in both; }

/* Markdown внутри ответа ИИ */
.ai-response-content h1,
.ai-response-content h2,
.ai-response-content h3 { margin: 1em 0 .5em; font-weight: 700; line-height: 1.3; color: var(--navy); }
.ai-response-content h1:first-child,
.ai-response-content h2:first-child,
.ai-response-content h3:first-child { margin-top: 0; }
.ai-response-content p { margin: 0 0 .8em; }
.ai-response-content p:last-child { margin-bottom: 0; }
.ai-response-content a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.ai-response-content ul,
.ai-response-content ol { margin: .6em 0; padding-left: 1.6em; }
.ai-response-content li { margin-bottom: .35em; }
.ai-response-content code:not(pre code) {
    background: rgba(128, 128, 128, .15); padding: .15em .4em; border-radius: 5px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace; font-size: .88em; color: #d63384;
}
.ai-response-content pre {
    background: #1e1e2e; color: #e6e6e6; border-radius: 10px; padding: 1rem 1.1rem;
    margin: .8em 0; overflow-x: auto; font-size: .88rem; line-height: 1.5;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}
.ai-response-content pre code { background: transparent; padding: 0; color: inherit; }
.ai-response-content blockquote {
    margin: .8em 0; padding: .5em 1em; border-left: 4px solid var(--blue);
    background: rgba(10, 60, 184, .06); border-radius: 0 10px 10px 0; font-style: italic;
}
/* Таблицы Markdown (например, расписание): фирменная шапка-градиент, скругление, зебра */
.ai-response-content table {
    width: 100%; margin: 1em 0; border-collapse: separate; border-spacing: 0;
    border: 1px solid rgba(10, 60, 184, .12); border-radius: 12px; overflow: hidden;
    font-size: .92rem; line-height: 1.45;
}
.ai-response-content thead {
    background: linear-gradient(100deg, #2f4f93, #4a63ad);
}
.ai-response-content thead th {
    background: transparent;
    color: #fff; font-weight: 600; text-align: left; white-space: nowrap;
    padding: .6rem .8rem;
}
.ai-response-content tbody td {
    padding: .55rem .8rem; vertical-align: top; color: #2c3345;
    border-top: 1px solid rgba(10, 60, 184, .08);
}
.ai-response-content tbody tr:nth-child(even) { background: rgba(10, 60, 184, .04); }
.ai-response-content table th:first-child,
.ai-response-content table td:first-child { padding-left: 1rem; }
.ai-response-content table th:last-child,
.ai-response-content table td:last-child { padding-right: 1rem; }
/* На узких экранах таблица прокручивается горизонтально, не ломая вёрстку */
@media (max-width: 560px) {
    .ai-response-content table { display: block; overflow-x: auto; white-space: nowrap; }
}

/*
 * Плавное появление новых чанков ответа ИИ. Класс .chunk-enter навешивает
 * ai-response.js только на вновь добавленные блоки; дорастающий блок
 * анимации не подвергается, иначе она обрывалась бы на каждой дельте.
 */
@keyframes chunkIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.ai-response-content > .chunk-enter { animation: chunkIn .45s cubic-bezier(.22, .61, .36, 1) both; }

@media (prefers-reduced-motion: reduce) {
    .ai-response-content > .chunk-enter { animation: none; }
}

/* ===== подвал (скруглённый верх + «ручка»-индикатор в видимой полоске) ===== */
.footer {
    margin-top: -3.5vh;
    flex: none; color: #fff; padding: 84px 0 24px; font-size: 14px;
    position: relative; z-index: 6;
    border-radius: var(--radius-screen) var(--radius-screen) 0 0;
    box-shadow: 0 -24px 64px rgba(10, 45, 105, .22), 0 3px 0 0 #071d47;
    /* Глубокий градиент бренда с мягкими световыми пятнами — рифма с первым экраном */
    background:
        radial-gradient(900px 380px at 88% -12%, rgba(70, 90, 200, .32), transparent 62%),
        radial-gradient(760px 420px at 2% 108%, rgba(10, 60, 184, .36), transparent 60%),
        linear-gradient(180deg, #0d3374 0%, var(--navy) 36%, #071d47 100%);
}
/* Индикатор «тут есть ещё»: пилюля-ручка, слегка пульсирует вниз */
.footer::before {
    content: ''; position: absolute; top:1.5vh; left: 50%;
    transform: translateX(-50%);
    width: 72px; height: 6px; border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, .35);
}

.footer::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: min(720px, 76%);
    height: 1px;
    pointer-events: none;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45) 50%, transparent);
}

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

.footer__grid {
    display: grid;
    grid-template-columns: minmax(250px, 300px) 1fr 1fr 1fr 1.5fr;
    gap: 30px 44px;
    align-items: start;
}

.f-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.f-logo a {
    transition: opacity var(--transition);
}

.f-logo a:hover {
    opacity: .85;
}

.f-copy {
    margin: 18px 0 22px;
    font-size: 13px;
    letter-spacing: .02em;
    color: var(--footer-text-muted);
}

/* Поиск в футере — «стеклянная» пилюля на тёмном градиенте */
.footer .search {
    width: 100%;
    max-width: 360px;
}

.footer .search input {
    padding: 11px 46px 11px 18px;
    background: var(--footer-glass);
    border: 1px solid var(--footer-glass-border);
    border-radius: var(--radius-pill);
    color: #fff;
    transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.footer .search input::placeholder {
    color: rgba(255, 255, 255, .55);
}

.footer .search input:focus {
    background: rgba(255, 255, 255, .13);
    border-color: rgba(255, 255, 255, .5);
}

.footer .search .search__btn {
    border-color: rgba(255, 255, 255, .75);
}

.footer .search .search__btn::after {
    background: rgba(255, 255, 255, .75);
}

.footer .search .search__btn:hover {
    border-color: #fff;
}

.f-col ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 14px;
}

.f-col a {
    position: relative;
    display: inline-block;
    color: rgba(255, 255, 255, .82);
    transition: color var(--transition), transform var(--transition);
}

.f-col a:hover {
    color: var(--accent-warm);
}

.f-contact p {
    margin: 0 0 14px;
    font-size: 13px;
    line-height: 1.55;
    color: var(--footer-text-muted);
}

.f-soc {
    display: flex;
    gap: 10px;
    margin-top: 28px;
}

.f-soc .soc {
    background: #fff;
    color: var(--navy);
}

.f-soc .soc:hover {
    background: var(--accent);
}

.footer__bottom {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    margin-top: 42px;
    padding-top: 24px;
    border-top: 1px solid var(--footer-line);
    font-size: 12px;
}

.footer__bottom a {
    display: inline-block;
    padding: .38rem .85rem;
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    color: var(--footer-text-muted);
    transition: color var(--transition), background var(--transition), border-color var(--transition);
}

.footer__bottom a:hover {
    background: rgba(255, 255, 255, .14); opacity: 1;
}

a {
    color: #fff;
    line-height: 1.35;
    opacity: .9;
}

a:hover {
    color: var(--accent-warm);
    opacity: 1;
}

/* ===== адаптивность ===== */
@media (max-width: 960px) {
    .header__main { grid-template-columns: 1fr; justify-items: start; }
    .header__logo { justify-self: start; }
    .auth-box { justify-self: start; align-items: flex-start; text-align: left; }
    .header__right { justify-self: start; align-items: center; }
    .auth-box--guest { align-items: stretch; }
    .auth-links { justify-content: flex-start; }
    .footer__grid { grid-template-columns: repeat(2, 1fr); row-gap: 38px; }
    .footer__grid > :first-child { grid-column: 1 / -1; }
    .social-rail { display: none; }
    /* Декоративные пятна не должны растягивать страницу по ширине */
    .content::before { width: 300px; height: 300px; }
    .content::after { width: 320px; height: 320px; }
}

@media (max-width: 768px) {
    .topbar__menu { gap: 2px 4px; padding-bottom: 10px; }
    .topbar__item { position: static; }
    .topbar__menu .topbar__item .topbar__submenu {
        --shift: 0; top: calc(100% + 2px); left: 0; right: 0;
        /* на мобильных панель тянется на всю ширину и всегда в одну колонку */
        width: auto; min-width: 0; max-width: none;
        grid-template-columns: 1fr;
        max-height: calc(100vh - 150px);
        overflow-y: auto;
    }
    .topbar__submenu::before,
    .topbar__submenu::after { display: none; }
    .topbar__link { padding: 6px 11px; font-size: 13px; }
    .header__main { padding: 18px 15px 10px; gap: 18px; }
    .search { width: 100%; }
}

@media (max-width: 576px) {
    :root { --footer-peek: 48px; --radius-screen: 28px; }
    .site-header { margin: 10px 10px 0; border-radius: 22px; }
    .auth-box { width: 100%; }
    .auth-box--guest .auth-btn,
    .auth-box--guest .auth-register { flex: 1; justify-content: center; }
    .footer { padding-top: 68px; }
    .footer::before { top: 20px; width: 56px; }
    .footer__grid { grid-template-columns: 1fr; row-gap: 28px; }
    .footer .search { max-width: none; }
    .footer__bottom { margin-top: 34px; padding-top: 20px; }
    .chat-container { padding: 2rem 0; }
    .chat-subtitle { margin-bottom: 1.25rem; padding: 0 1rem; }
    .chat-box { padding: .85rem 1rem; border-radius: 20px; }
    .ai-response { border-radius: 20px; }
    .chat-bottom-row { flex-direction: column; align-items: stretch; gap: .75rem; }
    .mode-tabs { justify-content: flex-start; }
    .mode-tab { padding: .4rem .75rem; font-size: .8rem; }
    .mode-tab i { display: none; }
    .mode-tabs--pill .mode-tab { min-width: 0; padding-left: .75rem; }
    .mode-tabs--pill .mode-tab > i { display: none; }
    /* Кнопка отправки — во всю ширину, как основной CTA на мобильных */
    .send-btn { width: 100%; border-radius: var(--radius-pill); height: 44px; }
}
