@import url('vars.css');

/* ============================================================================
   AUTH PAGE  (Views/Authorization/Index.cshtml)
   ----------------------------------------------------------------------------
   Структура файла:
     1. Переменные страницы (тёмная тема / светлая тема)
     2. Каркас страницы (body.auth_page, auth_page, фон)
     3. Верхняя панель (auth_topbar)
     4. Карточка входа (auth_card)
     5. Служебные блоки (auth_notice, auth_footer, auth_links)
     6. Демонстрация приложения (demo_panel: описание + видео)
     7. Модальные окна страницы входа (двухфакторный код, смена пароля)
     8. Анимации
     9. Адаптив
   Переключатель темы (.theme-switch) — общий компонент, вынесен в
   wwwroot/css/components/theme-switch.css (подключается в _Layout).
   Правило: классы страницы входа — с префиксами `auth_`, `demo_`
   (человекочитаемое имя, без сокращений), чтобы не конфликтовать с глобальными
   стилями (site.css, basic_elem.css).
   Внутренние части блока — через дефис: .auth_card + .auth_card-title.
   Исключение — .text-field__input у input: это класс из basic_elem.css.
   ========================================================================== */

/* ---------------------------------------------------------------- 1. Переменные */

:root {
    --auth-surface: rgba(255, 255, 255, 0.88);
    --auth-surface-strong: rgba(255, 255, 255, 0.96);
    --auth-surface-muted: rgba(15, 23, 42, 0.04);
    --auth-border: rgba(15, 23, 42, 0.10);
    --auth-border-strong: rgba(15, 23, 42, 0.18);
    --auth-shadow: 0 24px 60px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.06);
    --auth-control-bg: #ffffff;
    --auth-control-border: #d3d9e3;
    --auth-text: var(--fore-color);
    --auth-text-muted: #6b7686;
    --auth-accent: var(--theme-color-1);
    --auth-accent-contrast: #ffffff;
    --auth-danger: var(--color-red);
    --auth-danger-bg: rgba(231, 76, 60, 0.10);
    --auth-radius-lg: 20px;
    --auth-radius-md: 12px;
    --auth-gap: 18px;
    --auth-overlay-bg: rgba(15, 23, 42, 0.45);
    --demo-surface: rgba(255, 255, 255, 0.92);
    --demo-scrim: rgba(15, 23, 42, 0.55);
}

:root[theme='dark'] {
    --auth-surface: rgba(32, 33, 36, 0.82);
    --auth-surface-strong: rgba(32, 33, 36, 0.95);
    --auth-surface-muted: rgba(255, 255, 255, 0.05);
    --auth-border: rgba(255, 255, 255, 0.10);
    --auth-border-strong: rgba(255, 255, 255, 0.20);
    --auth-shadow: 0 24px 60px rgba(0, 0, 0, 0.50), 0 2px 6px rgba(0, 0, 0, 0.35);
    --auth-control-bg: rgba(255, 255, 255, 0.04);
    --auth-control-border: rgba(255, 255, 255, 0.18);
    --auth-text: var(--fore-color);
    --auth-text-muted: #9aa3ae;
    --auth-accent: var(--theme-color-1);
    --auth-accent-contrast: #16130b;
    --auth-danger: var(--color-red);
    --auth-danger-bg: rgba(255, 102, 102, 0.12);
    --auth-overlay-bg: rgba(0, 0, 0, 0.60);
    --demo-surface: rgba(20, 21, 24, 0.90);
    --demo-scrim: rgba(0, 0, 0, 0.70);
}

/* ---------------------------------------------------------------- 2. Каркас */

/* .auth_page — корень страницы (position: absolute; inset: 0), контент гибкий,
   скролл отдаётся .auth_main, когда место кончается (см. адаптив). */
body.auth_page {
    position: fixed;
    overflow: hidden;
}

.auth_page {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    color: var(--auth-text);
    isolation: isolate;
}

/* Декоративный фон: градиенты темы + приглушённая эмблема */
.auth_page::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -2;
    background:
        radial-gradient(1100px 620px at 12% -10%, rgba(184, 134, 11, 0.18), transparent 62%),
        radial-gradient(900px 560px at 108% 112%, rgba(52, 152, 219, 0.16), transparent 60%),
        var(--background-color);
    animation: auth_bg_in 0.9s ease-out both;
}

.auth_page::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image: url('img/sign-gold.svg');
    background-repeat: no-repeat;
    background-position: center;
    background-size: min(46vmin, 460px);
    opacity: 0.07;
}

:root[theme='dark'] .auth_page::before {
    background:
        radial-gradient(1100px 620px at 12% -10%, rgba(255, 171, 0, 0.14), transparent 62%),
        radial-gradient(900px 560px at 108% 112%, rgba(63, 160, 255, 0.12), transparent 60%),
        var(--background-color);
}

:root[theme='dark'] .auth_page::after {
    opacity: 0.10;
}

/* Сетка страницы: шапка / контент / подвал */
.auth_shell {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: var(--auth-gap);
    padding: 0 clamp(16px, 2.4vw, 32px);
}

/* ---------------------------------------------------------------- 3. Шапка */

.auth_topbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 4px;
}

.auth_topbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.auth_topbar-mark {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid var(--auth-border-strong);
    background: var(--auth-surface-strong);
    box-shadow: var(--auth-shadow);
}

.auth_topbar-mark::before {
    content: "";
    width: 26px;
    height: 26px;
    background-image: url('img/sign-gold.svg');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.auth_topbar-titles {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.auth_topbar-name {
    margin: 0;
    font-size: 1.35rem;
    line-height: 1.2;
    letter-spacing: 0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.auth_topbar-meta {
    margin: 0;
    font-size: 1rem;
    color: var(--auth-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.auth_topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

/* Кнопка-иконка в шапке (.theme-switch здесь ниже переопределяет под свой вид) */
.auth_icon_button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--auth-border);
    background: var(--auth-surface);
    color: var(--auth-text);
    font: inherit;
    font-size: 1rem;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

/* :not(.theme-switch) — чтобы не перебивать сам тумблер темы ниже */
.auth_icon_button:not(.theme-switch):hover {
    border-color: var(--auth-border-strong);
    box-shadow: var(--auth-shadow);
    transform: translateY(-1px);
}

.auth_icon_button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--auth-accent) 35%, transparent);
}

.auth_icon_button-icon {
    font-size: 1.05rem;
    line-height: 1;
}

/* --- Переключатель темы на странице входа ------------------------------
   Базовый компонент: css/components/theme-switch.css.
   Здесь только размер под шапку страницы входа. */

.auth_topbar .theme-switch {
    height: 38px;
    padding: 0 14px 0 6px;
    gap: 10px;
    border-color: var(--auth-border);
    background: var(--auth-surface);
    font-size: 1rem;
}

.auth_topbar .theme-switch:hover {
    border-color: var(--auth-border-strong);
    box-shadow: var(--auth-shadow);
}

.auth_topbar .theme-switch-track {
    width: 52px;
    height: 26px;
}

.auth_topbar .theme-switch-thumb {
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    font-size: 11px;
}

.auth_topbar .theme-switch.is-dark .theme-switch-thumb {
    transform: translateX(26px);
}

/* ---------------------------------------------------------------- 4. Контент */

.auth_main {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
    align-items: center;
    justify-content: center;
    gap: clamp(24px, 4vw, 64px);
    padding: 8px 0 16px;
    overflow: auto;
}

/* --- Карточка входа ---------------------------------------------------- */

.auth_card {
    width: 100%;
    max-width: 342px;
    justify-self: center;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 32px clamp(20px, 3vw, 32px) 24px;
    border-radius: var(--auth-radius-lg);
    border: 1px solid var(--auth-border);
    background: var(--auth-surface-strong);
    box-shadow: var(--auth-shadow);
    backdrop-filter: blur(14px);
    animation: auth_card_in 0.55s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

.auth_card-head {
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: center;
}

.auth_card-title {
    margin: 0;
    font-size: 1.8rem;
    line-height: 1.15;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.auth_card-subtitle {
    margin: 0;
    font-size: 1rem;
    color: var(--auth-text-muted);
}

.auth_card-body:empty {
    display: none;
}

/* Форма, которую рендерит TS_Auth.Form (js/Ts/ts_auth.js) */
.auth_card-body .auth_form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0;
    margin: 0;
}

.auth_card-body .auth_form input.text-field__input {
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    height: 44px;
    padding: 0 14px;
    font-size: 1.15rem;
    color: var(--auth-text);
    background: var(--auth-control-bg);
    border: 1px solid var(--auth-control-border);
    border-radius: var(--auth-radius-md);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.auth_card-body .auth_form input.text-field__input::placeholder {
    color: var(--auth-text-muted);
}

.auth_card-body .auth_form input.text-field__input:focus {
    outline: none;
    border-color: var(--auth-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--auth-accent) 25%, transparent);
}

/* Кнопка «Вход» — div.button.enter (без transform, чтобы не «прыгала») */
.auth_card-body .auth_form .button.enter {
    width: 100%;
    margin: 4px 0 0;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--auth-accent-contrast);
    border: 1px solid transparent;
    border-radius: var(--auth-radius-md);
    transition: background 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.auth_card-body .auth_form .button.enter:hover {
    color: var(--auth-accent-contrast);
    border-color: transparent;
    background-color: color-mix(in srgb, var(--auth-accent) 88%, #000);
    box-shadow: 0 10px 24px color-mix(in srgb, var(--auth-accent) 35%, transparent);
    transform: none;
}

.auth_card-body .auth_form .button.enter:active,
.auth_card-body .auth_form .button.enter.button-press {
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.25);
}

/* Подсказка «Enter — вход» */
.auth_card-hint {
    margin: 0;
    text-align: center;
    font-size: 0.92rem;
    color: var(--auth-text-muted);
}

/* Плашка ошибки (ViewBag.Error) */
.auth_notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
    padding: 10px 14px;
    border-radius: var(--auth-radius-md);
    border: 1px solid color-mix(in srgb, var(--auth-danger) 45%, transparent);
    background: var(--auth-danger-bg);
    color: var(--auth-danger);
    font-size: 1.02rem;
    line-height: 1.45;
    display: none;
}

.auth_notice::before {
    content: "!";
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 18px;
    height: 18px;
    margin-top: 1px;
    border-radius: 50%;
    background: var(--auth-danger);
    color: var(--auth-accent-contrast);
    font-size: 0.85rem;
    font-weight: 700;
}

.auth_card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--auth-border);
}

.auth_links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 16px;
}

.auth_links a {
    color: var(--auth-accent);
    font-size: 1rem;
    text-decoration: none;
    border-bottom: 1px dashed color-mix(in srgb, var(--auth-accent) 45%, transparent);
    transition: color 0.2s ease, border-color 0.2s ease;
}

.auth_links a:hover {
    color: var(--auth-text);
    border-bottom-color: var(--auth-text);
}

.auth_card-version {
    color: var(--auth-text-muted);
    font-size: 0.9rem;
    white-space: nowrap;
}

/* Колонка демонстрации (видео) */
.auth_side {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 0;
}

/* ---------------------------------------------------------------- 5. Служебные блоки */
.auth_footer {
    flex: 0 0 auto;
    padding: 6px 4px 10px;
    text-align: center;
    font-size: 0.88rem;
    color: var(--auth-text-muted);
}

/* ---------------------------------------------------------------- 6. Демонстрация */

.demo_panel {
    display: flex;
    align-items: stretch;
    gap: 16px;
    max-width: 100%;
    padding: 16px;
    border-radius: var(--auth-radius-lg);
    border: 1px solid var(--auth-border);
    background: var(--demo-surface);
    box-shadow: var(--auth-shadow);
    backdrop-filter: blur(14px);
    animation: auth_card_in 0.55s cubic-bezier(0.2, 0.8, 0.3, 1) 0.08s both;
}

/* Телефон-рамка */
.demo_phone {
    position: relative;
    flex: 0 0 auto;
    width: 248px;
    border-radius: 28px;
    background: #000;
    border: 1px solid var(--auth-border-strong);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
    overflow: hidden;
}

.demo_phone video {
    display: block;
    width: 100%;
    height: auto;
    opacity: 0;
    transition: opacity 0.35s ease;
}

.demo_phone video.is-loaded {
    opacity: 1;
}

.demo_phone-loader {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--demo-scrim);
    color: #fff;
    font-size: 0.9rem;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.demo_phone-loader.is-hidden {
    opacity: 0;
    visibility: hidden;
}

.demo_phone-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255, 255, 255, 0.28);
    border-top-color: #fff;
    border-radius: 50%;
    animation: demo_spin 0.8s linear infinite;
}

/* Описание рядом с телефоном */
.demo_side {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    max-width: 280px;
}

.demo_side-title {
    margin: 0;
    font-size: 1.05rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--auth-accent);
}

.demo_side-scroll {
    overflow: auto;
    flex: 1 1 auto;
    max-height: 420px;
    padding-right: 6px;
    font-size: 1.02rem;
    line-height: 1.55;
    color: var(--auth-text);
}

.demo_side-scroll .emoji {
    margin-right: 6px;
    animation: none;
}

.demo_side-scroll.is-loading {
    color: var(--auth-text-muted);
}

/* ---------------------------------------------------------------- 7. Модальные окна */

/* Двухфакторный код (Authorization/Auth -> error 2).
   Разметку собирает TS_Auth в ts_auth.js:
     <div name="overlay">
       <h2 class="modal_title">код подтверждения</h2>       <- лежит в оверлее, не в карточке
       <div class="container modal center TwoAuthCode">       <- сама карточка
         <label class="label">🔐 введите код</label>
         <input class="text-field__input">
       </div>
     </div>
   Стили страницы (auth_demo.css) грузятся после site.css: глобальный .modal_title
   здесь не трогаем — он используется в других диалогах, корректируем только
   оверлеи с карточкой страницы входа (:has). */

body.auth_page [name="overlay"]:has(> .TwoAuthCode),
body.auth_page [name="overlay"]:has(> .password_change_form) {
    /* оверлей + колонка: заголовок в потоке, карточка по центру */
    background: var(--auth-overlay-bg);
    backdrop-filter: blur(3px);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 18px;
    padding: 24px;
    box-sizing: border-box;
}

/* Заголовок по центру над карточкой */
body.auth_page [name="overlay"] > .modal_title {
    position: static;
    width: auto;
    margin: 0;
    padding: 0 52px;
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-align: center;
    color: #f5ecd2;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Крестик закрытия — в строке заголовка, справа от карточки */
body.auth_page [name="overlay"] > .button.close {
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--auth-border);
    background: var(--auth-surface);
    box-shadow: var(--auth-shadow);
}

body.auth_page [name="overlay"] > .button.close:hover {
    border-color: var(--auth-border-strong);
    box-shadow: var(--auth-shadow);
}

body.auth_page [name="overlay"] > .button.close:before,
body.auth_page [name="overlay"] > .button.close:after {
    width: 14px;
    background: var(--auth-text);
    opacity: 0.75;
}

/* --- Карточка двухфакторного кода -------------------------------- */

body.auth_page .overlay .container.TwoAuthCode {
    position: relative;
    width: min(290px, 100%);
    max-width: 100%;
    margin: 0;
    padding: 30px 32px 28px;
    /* карточка — flex-элемент колонки оверлея */
    flex: 0 0 auto;
    /* height:auto перебивает инлайновый height, который ставит jQuery position()
       (TS_UIControl.OVERLAY_CONTAINER), иначе карточка «зависает» фиксированной высоты */
    height: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-sizing: border-box;
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius-lg);
    background: var(--auth-surface-strong);
    box-shadow: var(--auth-shadow);
    backdrop-filter: blur(14px);
    color: var(--auth-text);
    opacity: 1;
    /* CSS-анимации не создают stacking context, поэтому акцентная полоса (::before)
       не будет просвечивать сквозь поле ввода */
    overflow: hidden;
    animation: auth_modal_in 0.35s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

/* Акцентная полоса сверху карточки */
body.auth_page .overlay .container.TwoAuthCode::before {
    content: "";
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    height: 3px;
    border-radius: var(--auth-radius-lg) var(--auth-radius-lg) 0 0;
    background: linear-gradient(90deg, transparent 0%, var(--auth-accent) 30%, var(--auth-accent) 70%, transparent 100%);
    opacity: 0.85;
}

body.auth_page .overlay .container.TwoAuthCode .label {
    margin: 0;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--auth-text-muted);
}

/* Поле для кода: крупные цифры, как в приложении-аутентификаторе.
   Поле может быть type=password (скрытый ввод) — селектор покрывает оба варианта. */
body.auth_page .overlay .container.TwoAuthCode input.text-field__input,
body.auth_page .overlay .container.TwoAuthCode input[type="password"].text-field__input {
    display: block;
    width: 100%;
    height: 64px;
    margin: 0;
    padding: 0 16px;
    box-sizing: border-box;
    text-align: center;
    font-family: 'roboto-bold', ui-monospace, 'SFMono-Regular', Menlo, monospace;
    font-size: 3rem;
    color: var(--auth-text);
    background: var(--auth-control-bg);
    border: 1px solid var(--auth-control-border);
    border-radius: var(--auth-radius-md);
    caret-color: var(--auth-accent);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

body.auth_page .overlay .container.TwoAuthCode input.text-field__input::placeholder {
    color: var(--auth-text-muted);
    letter-spacing: 0.08em;
    text-indent: 0;
    font-size: 1.05rem;
}

/* .ui-state-focus не нужен: лишняя синяя рамка jQuery UI поверх нашего фокуса */
body.auth_page .overlay .container.TwoAuthCode input.text-field__input:focus,
body.auth_page .overlay .container.TwoAuthCode input.text-field__input:focus-visible,
body.auth_page .overlay .container.TwoAuthCode input.text-field__input.ui-state-focus {
    border: 1px solid var(--auth-accent);
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--auth-accent) 25%, transparent);
}

/* Подсказка под полем */
body.auth_page .overlay .container.TwoAuthCode::after {
    content: "Проверка начнётся автоматически после ввода четырёх цифр";
    display: block;
    text-align: center;
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--auth-text-muted);
}

body.auth_page .overlay .container.TwoAuthCode .button {
    width: 100%;
    margin: 0;
    background-color: var(--auth-accent);
    color: var(--auth-accent-contrast);
    border-radius: var(--auth-radius-md);
}

body.auth_page .overlay .container.TwoAuthCode .button:hover {
    background-color: color-mix(in srgb, var(--auth-accent) 88%, #000);
    color: var(--auth-accent-contrast);
}

/* Доработка .password_change_form, чтобы диалог смотрелся как карточка входа
   (размеры/цвет фона оставляем из site.css) */
body.auth_page .overlay .container.password_change_form {
    flex: 0 0 auto;
    height: auto;
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius-lg);
    background: var(--auth-surface-strong);
    box-shadow: var(--auth-shadow);
    overflow: hidden;
    animation: auth_modal_in 0.35s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

body.auth_page .overlay .container.password_change_form .button.save {
    margin-top: 4px;
}

/* ---------------------------------------------------------------- 8. Анимации */

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

@keyframes auth_card_in {
    from {
        opacity: 0;
        transform: translateY(22px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes auth_modal_in {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

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

@media (prefers-reduced-motion: reduce) {
    .auth_page::before,
    .auth_card,
    .demo_panel,
    body.auth_page .overlay .container.TwoAuthCode,
    body.auth_page .overlay .container.password_change_form {
        animation: none !important;
        transition: none !important;
    }

    .demo_phone-spinner {
        animation-duration: 2s;
    }
}

/* ---------------------------------------------------------------- 9. Адаптив */

@media (max-width: 1180px) {
    .auth_main {
        grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
        gap: 24px;
    }

    .demo_side {
        max-width: 220px;
    }
}

@media (max-width: 980px) {
    .auth_main {
        grid-template-columns: minmax(0, 1fr);
        align-content: center;
        justify-items: center;
        overflow: auto;
    }

    .auth_side {
        width: 100%;
    }

    .demo_panel {
        order: -1;
        width: 100%;
        max-width: 560px;
    }

    .demo_phone {
        width: 200px;
    }

    .demo_side-scroll {
        max-height: 300px;
    }
}

@media (max-width: 640px) {
    body.auth_page {
        min-width: 0;
    }

    .auth_shell {
        padding: 0 12px;
        gap: 8px;
    }

    .auth_topbar {
        flex-wrap: wrap;
        row-gap: 8px;
    }

    .auth_topbar-meta {
        display: none;
    }

    .auth_topbar-name {
        font-size: 1.15rem;
    }

    .auth_icon_button span:not(.auth_icon_button-icon) {
        display: none;
    }

    .auth_icon_button {
        width: 38px;
        padding: 0;
        justify-content: center;
    }

    /* На узком экране тумблер темы — компактный вариант компонента */
    .auth_topbar .theme-switch {
        width: auto;
        padding: 0 6px;
        gap: 0;
    }

    .auth_topbar .theme-switch-text {
        display: none;
    }

    .auth_main {
        align-content: start;
        padding-top: 4px;
    }

    .auth_card {
        padding: 24px 18px 18px;
    }

    /* На телефоне демо-блок скрываем, как и раньше — экран маленький */
    .auth_side {
        display: none;
    }
}

/* Мобильные: модальные окна страницы входа */
@media (max-width: 480px) {
    body.auth_page [name="overlay"]:has(> .TwoAuthCode),
    body.auth_page [name="overlay"]:has(> .password_change_form) {
        padding: 16px;
    }

    body.auth_page [name="overlay"] > .modal_title {
        font-size: 1rem;
        padding: 0 16px;
    }

    body.auth_page .overlay .container.TwoAuthCode {
        width: 100%;
        padding: 24px 18px 22px;
    }

    body.auth_page .overlay .container.TwoAuthCode input.text-field__input {
        height: 58px;
        font-size: 1.7rem;
        letter-spacing: 0.35em;
        text-indent: 0.35em;
    }
}
