/* Базовые стили для модальных окон */
/* Спека (брейкпоинты, отступы, исключения): docs/ui-kit/GC_MODAL_SYSTEM.md */

/*
 * Единая модель высоты gc-modal:
 * — .modal-dialog: height:auto до предела (высота оверлея), не полный экран при коротком контенте
 * — .modal-content: max-height = потолок viewport (токен ниже), скролл только в .modal-body
 * Переопределение на странице: .modal.gc-modal { --gc-modal-content-max-height: 90dvh; }
 */
.modal.gc-modal {
    z-index: 9050 !important;
    --gc-modal-content-max-height: calc(
        100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - var(--spacing-md)
    );
    /* Шелл оверлея (a11y-dialog: открыто = нет aria-hidden="true") */
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100vh !important;
    height: 100dvh !important;
    overflow: hidden !important;
    /* a11y-dialog управляет aria-hidden (доступность). Визуально управляем классами. */
    /* Без !important здесь: иначе при открытии ломаются transitions у .modal-dialog / ::before (display не анимируется, контекст срывается). */
    display: none;
    pointer-events: none;
}

/* Закрыто по a11y: перебиваем inline style="display:block" от Bootstrap — только в этом состоянии, не трогая кадр открытия. */
.modal.gc-modal[aria-hidden='true'] {
    display: none !important;
}

.modal.gc-modal.gc-modal-is-open {
    display: flex !important;
    pointer-events: auto;
}

@media (min-width: 768px) {
    .modal.gc-modal {
        --gc-modal-content-max-height: calc(100vh - 4rem);
    }
}

/* Открыто: затемнение — ::before (без Bootstrap .modal-backdrop) */
.modal.gc-modal.gc-modal-is-open {
    align-items: flex-end !important; /* мобильные: sheet снизу */
    justify-content: center !important;
}

.modal.gc-modal::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(var(--gc-modal-overlay-blur-radius));
    -webkit-backdrop-filter: blur(var(--gc-modal-overlay-blur-radius));
    z-index: 0;
    pointer-events: auto;
    opacity: 0;
    transition: opacity var(--transition-fast) linear;
}

[data-theme='light'] .modal.gc-modal::before {
    background-color: rgba(0, 0, 0, 0.4);
}

.modal.gc-modal.show::before {
    opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
    .modal.gc-modal::before {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .modal-backdrop.show {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
}

/* Анимация появления модала снизу-вверх на мобильных */
@media (max-width: 767.98px) {
    .modal.gc-modal .modal-dialog {
        transform: translateY(100%);
        transition: transform var(--transition-base) ease-out;
    }
    
    .modal.gc-modal.show .modal-dialog {
        transform: translateY(0);
    }
}

/* Анимация появления модала с fade на десктопе */
@media (min-width: 768px) {
    .modal.gc-modal .modal-dialog {
        opacity: 0;
        transform: scale(0.95);
        transition:
            opacity var(--transition-base) ease-out,
            transform var(--transition-base) ease-out;
    }
    
    .modal.gc-modal.show .modal-dialog {
        opacity: 1;
        transform: scale(1);
    }
}

/* Backdrop (оверлей) - растягивается на весь экран */
.modal-backdrop {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100vh !important;
    height: 100dvh !important;
    z-index: 9040 !important;
}

/* Backdrop: shadcn-style — равномерный полупрозрачный оверлей */
.modal-backdrop.show {
    background-color: rgba(0, 0, 0, 0.5) !important;
    backdrop-filter: blur(var(--gc-modal-overlay-blur-radius));
    -webkit-backdrop-filter: blur(var(--gc-modal-overlay-blur-radius));
    opacity: 1 !important;
}

[data-theme="light"] .modal-backdrop.show {
    background-color: rgba(0, 0, 0, 0.4) !important;
}

/*
 * iOS / viewport-fit=cover: fixed + 100dvh часто не покрывают зону статус-бара/чёлки —
 * сверху просвечивает фон html (на светлой теме белая полоса над затемнением).
 * Сдвигаем вверх и добавляем высоту на safe-area-inset-top.
 */
@media (max-width: 767.98px) {
    .modal-backdrop {
        top: calc(0px - env(safe-area-inset-top, 0px)) !important;
        height: calc(100vh + env(safe-area-inset-top, 0px)) !important;
        height: calc(100dvh + env(safe-area-inset-top, 0px)) !important;
        min-height: calc(100vh + env(safe-area-inset-top, 0px)) !important;
        min-height: calc(100dvh + env(safe-area-inset-top, 0px)) !important;
    }

    .modal.gc-modal {
        top: calc(0px - env(safe-area-inset-top, 0px)) !important;
        height: calc(100vh + env(safe-area-inset-top, 0px)) !important;
        height: calc(100dvh + env(safe-area-inset-top, 0px)) !important;
        min-height: calc(100vh + env(safe-area-inset-top, 0px)) !important;
        min-height: calc(100dvh + env(safe-area-inset-top, 0px)) !important;
    }

    .modal.gc-modal::before {
        top: calc(0px - env(safe-area-inset-top, 0px)) !important;
        height: calc(100dvh + env(safe-area-inset-top, 0px)) !important;
        min-height: calc(100dvh + env(safe-area-inset-top, 0px)) !important;
    }
}

/* Быстрая и плавная анимация модала (не gc-modal — см. блок ниже) */
.modal.fade:not(.gc-modal) {
    transition: opacity var(--transition-fast) linear !important;
}

/*
 * Трансформ dialog только для НЕ gc-modal.
 * Иначе .modal.fade:not(.show) перебивает sheet (translateY(100%)) и при закрытии
 * на мгновение виден scale + translateY(10px) «сверху».
 */
.modal.fade:not(.gc-modal) .modal-dialog {
    transition: transform var(--transition-fast) ease-out !important;
}

.modal.fade:not(.show):not(.gc-modal) .modal-dialog {
    transform: scale(0.98) translateY(10px);
}

.modal.fade.show:not(.gc-modal) .modal-dialog {
    transform: scale(1) translateY(0);
}

/* Быстрая анимация backdrop */
.modal-backdrop {
    transition: opacity var(--transition-fast) linear !important;
}

/* Блокировка скролла: body.modal-open выставляет gc-modal-bridge.js на любой .modal (show.bs.modal / hidden.bs.modal). */
/* Перебиваем Bootstrap: inline overflow на body ломает flex-лейаут (sticky-сайдбары) — держим overflow на html. */
/* Компенсация скроллбара: bridge → --gc-scrollbar-comp для fixed-слоёв; padding на html только без поддержки scrollbar-gutter: stable. */
body.modal-open {
    padding-right: 0 !important;
    overscroll-behavior: none !important;
    overflow: visible !important;
}

html:has(body.modal-open),
html.gc-root-scroll-lock {
    overflow: hidden !important;
    scrollbar-gutter: stable !important;
    overscroll-behavior: none !important;
}

/*
 * Слои position:fixed к viewport — при отсутствии scrollbar-gutter:stable на корне
 * компенсируем исчезновение полосы (--gc-scrollbar-comp в gc-modal-bridge.js).
 * .gc-modal не трогаем: правило width:auto ломало полноэкранный оверлей и давало лишний скролл.
 */
html.gc-root-scroll-lock .gc-desktop-nav,
html.gc-root-scroll-lock .gc-mobile-nav-top,
html.gc-root-scroll-lock .gc-mobile-nav-bottom,
html.gc-root-scroll-lock .gc-floating-search,
html.gc-root-scroll-lock .gc-auth-banner,
html.gc-root-scroll-lock .gc-mobile-nav-pinned-fixed {
    right: var(--gc-scrollbar-comp, 0px);
}

html.gc-root-scroll-lock .modal-backdrop,
html.gc-root-scroll-lock .modal:not(.gc-modal) {
    right: var(--gc-scrollbar-comp, 0px);
    width: auto !important;
}

/* Мобильные: усиленная блокировка (iOS/Android) */
@media (max-width: 767.98px) {
    body.modal-open {
        overflow: hidden !important;
        touch-action: none !important;
        -webkit-overflow-scrolling: touch !important;
        width: 100% !important;
    }

    html.gc-root-scroll-lock .notifications-dropdown {
        right: var(--gc-scrollbar-comp, 0px) !important;
        width: auto !important;
    }
}

/* Резерв под скроллбар + стабильная ширина полосы прокрутки (меньше скачков при lock) */
html {
    overflow-y: auto;
    scrollbar-gutter: stable;
}

/* Dialog: по контенту, не выше оверлея модала */
.gc-modal .modal-dialog {
    margin: 0;
    padding: var(--spacing-md) 0 0 0;
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    overflow: visible;
    position: relative;
    z-index: 1;
    box-sizing: border-box;
}

/*
 * Bootstrap CDN: .modal-dialog-centered задаёт min-height ~100% + align-items:center на самом dialog —
 * в связке с flex-шеллом .modal.gc-modal даёт смещение по вертикали и разное поведение на ширинах.
 * gc-modal центрирует шелл; dialog — только обёртка контента.
 */
.modal.gc-modal .modal-dialog.modal-dialog-centered {
    min-height: unset !important;
    align-items: stretch;
}

/* Перебиваем Bootstrap .modal-dialog-scrollable (height: 100%), сохраняем общую модель */
.gc-modal .modal-dialog.modal-dialog-scrollable {
    height: auto;
    max-height: 100%;
}

/* Content: потолок — токен; скролл внутри .modal-body */
.gc-modal .modal-content {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    margin: auto 0 0 0;
    width: 100%;
    max-width: 100%;
    min-height: 0;
    height: auto;
    max-height: var(--gc-modal-content-max-height);
    background-color: var(--bg-content-main);
    border: none;
    border-top: 1px solid var(--ui-border);
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.gc-modal .modal-header {
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    border-bottom: 1px solid var(--ui-border);
    margin: 0;
    padding: var(--spacing-md);
    border-radius: 0;
    /* Grid: title и btn-close — строка 1; description — строка 2 (только если есть в разметке).
     * Вариант с .gc-modal-header-title-stack — см. блок ниже (крестик не по центру двух строк стека). */
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    column-gap: var(--spacing-sm);
    row-gap: var(--spacing-xs);
    box-shadow: none;
    flex-shrink: 0;
}

.gc-modal .modal-header:has(> .gc-modal-header-title-stack) {
    align-items: start;
}

.gc-modal .modal-header:has(> .gc-modal-header-title-stack) .btn-close {
    align-self: start;
}

.gc-modal .modal-header > .gc-modal-header-title-stack {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    align-self: start;
}

.gc-modal .modal-header > .gc-modal-header-title-stack .modal-title {
    grid-column: unset;
    grid-row: unset;
}

.gc-modal .modal-header > .gc-modal-header-title-stack .modal-description {
    grid-column: unset;
    grid-row: unset;
}

/* Шапка с аватаром заявителя: имя в одной строке с фото (модерация подач и т.п.) */
.gc-modal .modal-header > .gc-modal-header-identity {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    min-width: 0;
}

.gc-modal .modal-header > .gc-modal-header-identity .gc-list-avatar,
.gc-modal .modal-header > .gc-modal-header-identity .gc-list-media-icon.gc-list-avatar-fallback {
    flex-shrink: 0;
}

.gc-modal .modal-header > .gc-modal-header-identity .modal-title {
    grid-column: unset;
    grid-row: unset;
    min-width: 0;
    margin: 0;
}

.gc-modal .modal-title {
    grid-column: 1;
    grid-row: 1;
}

/* Модалки без внешней рамки листа (split, композиции на весь .modal-content) */
.gc-modal--borderless .modal-content {
    border: none;
    border-top: none;
}

/* layout=hero (x-modal.shell): слот hero + штатный .modal-header поверх — GC_MODAL_SYSTEM.md §7.1.1 */
.gc-modal--layout-hero {
    /* Потолок высоты медиа в hero (обложки и т.п.): переопредели на корне модалки при необходимости */
    --gc-modal-hero-cover-max-height: min(52dvh, 25rem);
}

.gc-modal--layout-hero .gc-modal-hero--integrated {
    position: relative;
    flex-shrink: 0;
}

.gc-modal--layout-hero .gc-modal-hero__slot {
    min-width: 0;
}

/* Без внешней рамки «листа»: hero и тело читаются как один блок, клип по скруглению .modal-content */
.gc-modal--layout-hero .modal-content.gc-modal-content--hero {
    border: none;
    border-top: none;
}

.gc-modal--layout-hero .modal-footer {
    border-top: none;
}

.gc-modal--layout-hero .gc-modal-hero--integrated > .modal-header.gc-modal-hero__header {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    z-index: 4;
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
    padding-top: calc(var(--spacing-md) + env(safe-area-inset-top, 0px));
    padding-right: var(--spacing-md);
    padding-bottom: 0;
    padding-left: var(--spacing-md);
    border-bottom: none;
    background: transparent;
    box-shadow: none;
    pointer-events: none;
    /* Сброс grid шапки: в hero только кнопка закрытия (заголовок — .visually-hidden в standard-header) */
    grid-template-columns: unset;
    column-gap: unset;
    row-gap: unset;
}

.gc-modal--layout-hero .gc-modal-hero--integrated > .modal-header.gc-modal-hero__header .btn-close {
    pointer-events: auto;
    width: 32px !important;
    height: 32px !important;
    min-width: 32px;
    border-radius: var(--radius-full) !important;
    background: color-mix(in srgb, white 26%, transparent) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: none !important;
    box-shadow: none;
}

.gc-modal--layout-hero .gc-modal-hero__header .btn-close > i {
    font-size: var(--font-size-md);
    color: color-mix(in srgb, white 92%, transparent);
    filter: none;
}

.gc-modal--layout-hero .gc-modal-hero__header .btn-close:hover {
    background: color-mix(in srgb, white 40%, transparent) !important;
    opacity: 1 !important;
}

.gc-modal--layout-hero .gc-modal-hero__header .btn-close:active {
    background: color-mix(in srgb, white 32%, transparent) !important;
    opacity: 1 !important;
}

.gc-modal--layout-hero .gc-modal-hero__header .btn-close:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .gc-modal--layout-hero .gc-modal-hero__header .btn-close {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}

/* Описание под заголовком — аналог DialogDescription */
.gc-modal .modal-description {
    font-size: var(--font-size-sm);
    color: var(--font-secondary);
    margin: 0;
    line-height: 1.5;
    grid-column: 1 / -1;
    grid-row: 2;
}

/* Кнопка закрытия — всегда в правом верхнем углу grid */
.gc-modal .btn-close {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px !important;
    height: 28px !important;
    min-width: 28px;
    background: transparent !important;
    background-image: none !important;
    border: none !important;
    border-radius: var(--radius-sm) !important;
    opacity: 1 !important;
    padding: 0 !important;
    margin: 0 !important;
    cursor: pointer;
    transition: background var(--transition-fast), opacity var(--transition-fast);
    filter: none !important;
    box-sizing: border-box !important;
    justify-self: end;
}

/* Иконка крестика — рендерится через <i class="ph ph-x"> внутри кнопки */
.gc-modal .btn-close > i {
    font-size: 16px;
    color: var(--font-secondary);
    line-height: 1;
    pointer-events: none;
}

.gc-modal .btn-close:hover {
    background: var(--bg-hover) !important;
    opacity: 1 !important;
}

.gc-modal .btn-close:active {
    opacity: 0.7 !important;
}

.gc-modal .btn-close:focus {
    box-shadow: none;
    opacity: 1 !important;
}

/* Заголовки внутри модалов */
.gc-modal .modal-body h1,
.gc-modal .modal-body h2,
.gc-modal .modal-body h3,
.gc-modal .modal-body h4,
.gc-modal .modal-body h5,
.gc-modal .modal-body h6 {
    font-family: var(--font-family-heading);
}

/* Основной текст внутри модалов */
.gc-modal .modal-body p,
.gc-modal .modal-body span,
.gc-modal .modal-body div {
    font-family: var(--font-family-base);
}

.gc-modal .modal-footer {
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    border-top: 1px solid var(--ui-border);
    margin: 0;
    padding: var(--spacing-md) var(--spacing-md) calc(var(--spacing-md) + env(safe-area-inset-bottom));
    border-radius: 0;
    box-shadow: none;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--spacing-sm);
    position: sticky;
    bottom: 0;
    z-index: 10;
}

/*
 * Bootstrap 5.3 задаёт .modal-footer > * { margin: calc(var(--bs-modal-footer-gap) * .5); }.
 * У нас отступы между кнопками/формами через gap — внешние margin дублируют и съезжают вёрстка.
 */
.gc-modal .modal-footer > * {
    margin: 0;
}

/* На мобильных кнопки растягиваются на всю ширину */
@media (max-width: 767px) {
    .gc-modal .modal-footer {
        justify-content: stretch;
    }
    .gc-modal .modal-footer .gc-btn {
        flex: 1;
    }
}

.gc-modal .modal-footer .gc-btn {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
    margin: 0;
}

/* Fallback для браузеров без поддержки backdrop-filter */
@supports not (backdrop-filter: blur(20px)) {
    .gc-modal .modal-header {
        background: var(--bg-content-main) !important;
    }
    
    .gc-modal .modal-footer {
        background: var(--bg-content-main) !important;
    }
}

.gc-modal .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
    word-wrap: break-word;
    overflow-wrap: break-word;
    padding: var(--spacing-md);
    font-family: var(--font-family-base);
    font-size: var(--font-size-sm);
    line-height: 1.6;
    color: var(--font-primary);
}

/* Короткая подсказка / пустое состояние: Reboot оставляет margin у p — сбрасываем (утилиты цвета/размера текста margin не задают). */
.gc-modal .modal-body .gc-modal-hint {
    margin: 0;
}

/*
 * Тело модалки как зона списка — тот же ритм, что .gc-panel-content--list (styles.css):
 * компактный xs со всех сторон (как .gc-modal-content--list).
 * scrollbar-gutter: auto — без лишнего справа у скролла.
 */
.gc-modal .modal-body.modal-body--list {
    --gc-list-item-hover-bg: transparent;
    display: flex;
    flex-direction: column;
    /* padding/gap — styles.css (--list); ниже только поведение скролла */
    margin: 0;
    flex: 1 1 auto;
    min-height: 0;
    scrollbar-gutter: auto;
    background: transparent;
    border: none;
    border-radius: 0;
    /* Нельзя overflow: visible — сбивает скроллпорт flex-ребёнка: список вылезает на футер.
     * Базовые .modal-body: overflow-y auto + min-height 0 — тело крутится, футер остаётся снизу. */
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Открытый gc-select: выпадашка выходит за скроллпорт (иначе обрежется body) */
.gc-modal .modal-body.modal-body--list:has(.gc-select-dropdown.show),
.gc-modal .modal-body.weapon-modal-body:has(.gc-select-dropdown.show) {
    overflow: visible;
}

/*
 * Зона списка в модалке (.modal-body--list | .gc-modal-content--list):
 * без разделителей между строками (lists.css — border-top у :not(:first-child)).
 * Плитки со скруглением как у строк лоадаута — для ЛЮБЫХ .gc-list-item внутри зоны,
 * не только внутри .gc-grouped-list (иначе «голый» .gc-stack-sm > .gc-list-item без radius).
 */
.gc-modal .modal-body.modal-body--list :is(.gc-list-item, .gc-list-item-add, .gc-list-item-action, .weapon-item),
.gc-modal .gc-modal-content--list :is(.gc-list-item, .gc-list-item-add, .gc-list-item-action, .weapon-item),
.gc-modal .modal-body.modal-body--list .gc-interactive-row,
.gc-modal .gc-modal-content--list .gc-interactive-row {
    --gc-list-divider-color: transparent;
    border-top: none;
    border-radius: var(--radius-md-lg);
}

.gc-modal .modal-body.modal-body--list .weapon-item,
.gc-modal .gc-modal-content--list .weapon-item {
    overflow: visible;
}

/*
 * Список в теле gc-modal — тот же ритм, что .gc-panel-content--list (UI Kit /panel):
 * малый инсет var(--spacing-xs), gap между строками через .gc-stack-sm внутри.
 * Компенсирует padding .modal-body, чтобы hover у gc-interactive-row доходил до внутреннего края модалки без «второй рамки».
 */
.gc-modal .modal-body > .gc-modal-panel-list {
    display: flex;
    flex-direction: column;
    margin: calc(-1 * var(--spacing-md));
    padding: var(--gc-list-zone-padding);
    flex: 1 1 auto;
    min-height: 0;
}

.gc-modal .modal-body > .gc-modal-panel-list > .gc-stack-sm {
    width: 100%;
    min-width: 0;
}

/*
 * Вложенный контент (x-modal.shell content-variant="section|list"):
 * как gc-panel-content / gc-modal-content — один слой отступов, без двойного padding modal-body.
 */
.gc-modal .modal-body.modal-body--nested {
    padding: 0;
    display: flex;
    flex-direction: column;
    /* Иначе наследуется scrollbar-gutter: stable у .modal-body — визуально «лишний» зазор справа */
    scrollbar-gutter: auto;
}

.gc-modal .gc-modal-content:not(.gc-modal-content--list) {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    padding: var(--spacing-mdl);
    flex: 1 1 auto;
    min-height: 0;
}

.gc-modal .gc-modal-content.gc-modal-content--list {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

/*
 * Заголовок группы в зоне --list (модалка): горизонтальный inset — styles.css;
 * сверху sm, снизу 0 — gap у .gc-grouped-list-section.
 */
.gc-modal .gc-modal-content--list .gc-list-group-header,
.gc-modal .modal-body.modal-body--list .gc-list-group-header {
    margin: 0;
    padding: var(--gc-list-row-padding) var(--gc-list-row-padding) 0;
}

/* Список лоадаута внутри content-variant=list — на всю ширину колонки */
.event-squad-modal .gc-modal-content--list .gc-grouped-list {
    width: 100%;
    min-width: 0;
}

/*
 * modal-dialog-scrollable (Bootstrap): раньше отдельная схема высоты.
 * Теперь то же поведение, что у всех gc-modal — класс можно оставить в разметке для совместимости.
 */
.gc-modal .modal-dialog-scrollable .modal-header,
.gc-modal .modal-dialog-scrollable .modal-footer {
    flex-shrink: 0;
}

/* Скрываем дублирование контента на мобильных */
@media (max-width: 767px) {
    .gc-modal .stage-stats {
        display: none;
    }
}

/* Медиа-запросы для десктопа */
@media (min-width: 768px) {
    .modal.gc-modal.gc-modal-is-open {
        align-items: center !important; /* На десктопе центрируем */
    }
    
    .gc-modal .modal-dialog {
        margin: 2rem auto;
        padding: 0;
        width: 90%;
        max-width: 640px; /* Единая комфортная ширина для всех модалов */
        height: auto;
        max-height: calc(100vh - 4rem);
    }
    
    .gc-modal .modal-content {
        border-radius: var(--radius-lg);
        margin: 0;
        height: auto;
        max-height: var(--gc-modal-content-max-height);
        border: 1px solid var(--ui-border);
        padding-bottom: 0;
        overflow: hidden; /* Фиксит border на скруглениях */
    }

    .gc-modal.gc-modal--borderless .modal-content {
        border: none;
    }
    
    .gc-modal .modal-body {
        /* Кастомный скроллбар на десктопе */
        scrollbar-width: thin;
        scrollbar-color: var(--border-secondary) transparent;
    }
    
    /* Webkit scrollbar styling */
    .gc-modal .modal-body::-webkit-scrollbar {
        width: 8px;
    }
    
    .gc-modal .modal-body::-webkit-scrollbar-track {
        background: transparent;
    }
    
    .gc-modal .modal-body::-webkit-scrollbar-thumb {
        background-color: var(--border-secondary);
        border-radius: 4px;
        border: 2px solid var(--bg-content-main);
    }
    
    .gc-modal .modal-body::-webkit-scrollbar-thumb:hover {
        background-color: var(--ui-border);
    }
    
    .gc-modal .modal-footer {
        position: relative;
        bottom: auto;
    }
    
}


/* Полноэкранные модалы на малых экранах (Bootstrap modal-fullscreen-sm-down) */
@media (max-width: 575.98px) {
    .gc-modal .modal-fullscreen-sm-down {
        margin: 0;
        padding: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
    }
    
    .gc-modal .modal-fullscreen-sm-down .modal-content {
        border-radius: 0;
        border: none;
        border-top: 1px solid var(--ui-border);
        height: 100%;
        max-height: 100%;
        margin: 0;
    }
    
    .gc-modal .modal-fullscreen-sm-down .modal-body {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Полноэкранная модалка «сюрприз» после логина (GIF из config/login_surprise.php) */
.modal.gc-modal.login-surprise-modal.gc-modal-is-open,
.modal.gc-modal.login-surprise-modal.show {
    align-items: center !important;
    justify-content: center !important;
}

.gc-modal.login-surprise-modal .modal-dialog {
    padding: 0;
    height: 100%;
    max-height: 100%;
    width: 100%;
    max-width: 100%;
    transform: none !important;
    opacity: 1 !important;
    transition: none !important;
}

.gc-modal.login-surprise-modal .modal-content {
    position: relative;
    margin: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border: none;
    border-radius: 0;
    background-color: var(--bg-content-main);
}

.gc-modal.login-surprise-modal .login-surprise-modal__header {
    position: absolute;
    top: max(var(--spacing-sm), env(safe-area-inset-top, 0px));
    right: max(var(--spacing-sm), env(safe-area-inset-right, 0px));
    z-index: 2;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    width: auto;
    margin: 0;
    padding: var(--spacing-xs);
    border: none;
    min-height: 0;
    background: var(--bg-content-secondary);
    border-radius: var(--radius-md);
    box-shadow: 0 0 0 1px var(--ui-border);
}

.gc-modal.login-surprise-modal .login-surprise-modal__header .btn-close {
    grid-column: auto;
    grid-row: auto;
    justify-self: auto;
}

.gc-modal.login-surprise-modal .login-surprise-modal__header .btn-close > i {
    color: var(--font-primary);
}

.gc-modal.login-surprise-modal .login-surprise-modal__body {
    flex: 1 1 auto;
    position: relative;
    padding: 0;
    min-height: 0;
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Во всю область тела модалки, пропорции сохраняются, края обрезаются (как cover) */
.gc-modal.login-surprise-modal .login-surprise-gif {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: cover;
    object-position: center;
    display: block;
}

/* ===========================================
   Code Block - блок для отображения кода
   =========================================== */

.gc-code-block {
    background: var(--bg-content-main);
    border: 1px solid var(--ui-border);
    border-radius: var(--radius-md);
    padding: var(--spacing-mdl) var(--spacing-md);
    font-family: 'Courier New', Courier, monospace;
    font-size: var(--font-size-sm);
    overflow-x: auto;
    line-height: 1.6;
}

.gc-code-block code {
    color: var(--font-primary);
    background: transparent;
    padding: 0;
    font-size: var(--font-size-sm);
}

/* ===========================================
   Scoring Modal - модал подсчёта результатов
   =========================================== */

/* Контейнер модала с gap между секциями */
.scoring-modal-body {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

/* Заголовки групп */
.scoring-group-header {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--font-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: var(--spacing-sm);
}

/* Первый заголовок без отступа сверху */
.scoring-group-header:first-child {
    margin-top: 0;
}

/* Панель с акцентной левой границей */
.gc-panel--accent-border {
    border-left: 3px solid var(--accent-link);
}

/* Панель с информацией (вложенная) */
.gc-panel--nested-info {
    background: var(--bg-content-secondary);
    margin-top: var(--spacing-sm);
}

/* Панель с предупреждением */
.gc-panel--warning {
    border-left: 3px solid var(--warning-color);
}

/* Фон для warning панели в светлой теме */
[data-theme="light"] .gc-panel--warning {
    background: rgba(var(--warning-color-rgb), 0.1);
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme]) .gc-panel--warning {
        background: rgba(var(--warning-color-rgb), 0.1);
    }
}

/* Заголовок шага */
.scoring-step-title {
    font-size: var(--font-size-md);
    font-weight: 600;
    color: var(--font-primary);
    margin-bottom: var(--spacing-xs);
}

/* Описание шага */
.scoring-step-desc {
    font-size: var(--font-size-sm);
    color: var(--font-secondary);
    margin-bottom: var(--spacing-sm);
}

/* Контейнер для бейджей */
.scoring-badges {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-sm);
}

/* Заголовок примеров */
.scoring-examples-title {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--font-primary);
    margin-top: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
}

/* Текст с увеличенной высотой строки */
.scoring-text-spaced {
    line-height: 1.6;
}

/* Код-блоки в модале скоринга */
.scoring-modal-body .gc-code-block {
    margin-top: var(--spacing-sm);
}

.scoring-modal-body .gc-code-block + .gc-code-block {
    margin-top: var(--spacing-xs);
}

/* Текст после code-block */
.scoring-modal-body .gc-code-block + .gc-text-xs,
.scoring-modal-body .gc-code-block + .gc-text-sm {
    margin-top: var(--spacing-sm);
}