
/* =====================================================================
   ПЕРЕМЕННЫЕ — все цвета, размеры и анимации в одном месте
   ===================================================================== */
/* CSS-переменные приложения */
:root {
    /* === Фон и поверхности === */
    --bg-color:    #050505;                    /* основной фон страницы */
    --card-bg:     rgba(28, 28, 28, 0.7);      /* фон карточки (стеклянный эффект) */
    --input-bg:    rgb(255, 255, 255, 0.06);   /* фон полей ввода */
    --dropdown-bg: rgba(16, 16, 16, 1);        /* фон выпадающих меню */
    --border-color: rgba(255, 255, 255, 0.10); /* тонкие разделительные границы */
    --bg-subtle: rgba(255, 255, 255, 0.05); /* сверхтонкий фон */

    /* === Текст === */
    --text-main:  #ffffffdb;  /* основной текст (почти белый) */
    --text-muted: rgba(255, 255, 255, 0.5);  /* второстепенный текст (приглушённый) */

    /* === Акцент === */
    --accent:       #FF5F2C;  /* основной акцентный цвет (оранжевый) */
    --accent-hover: #E65425;  /* акцент при нажатии / наведении */
    --accent-text:  #111111;  /* цвет текста поверх акцентного фона */

    /* === Статусные цвета === */
    --success:    #30b98c;         /* успешное действие (зелёный) */
    --warning:    #f7ae32;         /* предупреждение (жёлтый) */
    --danger:     #f74141;         /* ошибка / деструктивное действие (красный) */
    --danger-rgb: 242, 79, 79;     /* красный в формате r,g,b для rgba() */

    /* === Форма и тени === */
    --radius:      16px;                        /* скругление углов карточек */
    --radius-sm:    8px;                        /* скругление мелких элементов (инпуты, дропдауны) */
    --radius-xs:    4px;                        /* микро-скругление: чекбоксы, бейджи, ручки слайдера */
    --radius-pill: 999px;                       /* максимальное скругление — таблеточная форма */
    --shadow:      0 8px 32px rgba(0,0,0,0.5); /* тень карточек */

    /* === Акцентные оттенки === */
    --accent-rgb:     255, 95, 44;                      /* RGB-каналы акцента — основа для tint-переменных */
    --accent-tint:    rgba(var(--accent-rgb), 0.08);    /* слабая заливка: фон активного чипа */
    --accent-fill:    rgba(var(--accent-rgb), 0.12);    /* стандартная заливка: активные hover-состояния */
    --accent-overlay: rgba(var(--accent-rgb), 0.18);    /* средняя заливка: подсветка сегментного контрола */
    --accent-glow:    rgba(var(--accent-rgb), 0.24);    /* свечение: тень логотипа-лоадера */
    --accent-ring:    rgba(var(--accent-rgb), 0.25);    /* кольцо фокуса вокруг элементов управления */
    --border-subtle:  rgba(255, 255, 255, 0.05);        /* сверхтонкая граница карточек и элементов списка */

    /* === Типографика === */
    --text-xs:   12px;  /* мелкий: бейджи, метки, подписи */
    --text-base: 14px;  /* основной: большинство элементов интерфейса */
    --text-md:   15px;  /* средний: описание фильма, текст пустого состояния */
    --text-lg:   16px;  /* крупный: заголовок истории */
    --text-xl:   20px;  /* заголовок фильма, рулетка загрузки */
    --text-2xl:  22px;  /* заголовок пустого состояния */

    /* === Насыщенность текста === */
    --fw-regular:       400;  /* обычный: лейблы, чипы, метки */
    --fw-medium:       500;  /* обычный: лейблы, чипы, метки */
    --fw-semibold:     600;  /* полужирный: заголовки, важный текст */
    --fw-bold:         700;  /* жирный: рейтинговые бейджи */

    /* === Межстрочный интервал === */
    --leading-none:   16px;    /* вплотную: иконки, бейджи */
    --leading-tight:  18px;  /* сжатый: кнопки, чипы, вторичный текст */
    --leading-snug:   24px;  /* чуть свободнее: заголовки фильма */
    --leading-normal: 22px;  /* стандартный: тело текста, описания */

    /* === Непрозрачность === */
    --opacity-disabled:     0.3;   /* disabled: неактивные кнопки и поля */
    --opacity-subdued:      0.45;  /* мягко-неактивный: тип-селектор */
    --opacity-skeleton-min: 0.25;  /* скелетон: минимальная яркость */
    --opacity-sep:          0.55;  /* разделитель · между метаданными */
    --opacity-hint:         0.7;   /* подсказки, swipe-hint, счётчик охвата */
    --opacity-pressed:      0.75;  /* нажатие: кнопка «Очистить» */
    --opacity-dim:          0.8;   /* приглушение: исключённый жанр, :active тогл */

    /* === Тени и полупрозрачные поверхности === */
    --shadow-dropdown: rgba(0, 0, 0, 0.8);           /* тёмная тень выпадающего меню */
    --border-glass:    rgba(255, 255, 255, 0.18);    /* граница полупрозрачных панелей */

    /* === Шкала отступов === */
    --space-0:   0px;  /* отсутствие отступа */
    --space-2:   2px;  /* минимальный: малые бейджи */
    --space-4:   4px;  /* миниатюрный: padding бейджей, сегментного контрола */
    --space-6:   6px;  /* очень малый: gap чипов, бейджей */
    --space-8:   8px;  /* малый: padding списков, gap рядов */
    --space-12: 12px;  /* средний: padding кнопок, инпутов, gap секций */
    --space-16: 16px;  /* стандартный: секционные отступы */
    --space-18: 18px;  /* чуть больше стандарта: горизонтальный padding экранов */
    --space-20: 20px;  /* большой: padding карточки, отступы блоков */
    --space-24: 24px;  /* очень большой: крупные секционные отступы */

    /* === Иконки чипов пресетов (inline SVG): размер и stroke без правки HTML === */
    --preset-chip-icon-size: 20px;
    --preset-chip-stroke: 1.5px;
    --preset-chip-padding-left: 40px;

    /* === Анимации — задаются через applyMotionCssVars() из app-config.js === */
}

/* =====================================================================
   БАЗОВЫЕ СТИЛИ — сброс и корневые элементы
   ===================================================================== */

/* сброс отступов и синей вспышки при тапе на мобильных */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

/* цвет под body при bounce-скролле за край экрана */
html {
    background-color: var(--bg-color);
}

/* корневой контейнер: колонка по центру, учитывает нотч и home indicator */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-main);
    display: flex;
    justify-content: center;
    padding-top: calc(env(safe-area-inset-top, 0px) + 16px);
    padding-right: var(--space-16);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
    padding-left: var(--space-16);
    min-height: 100vh;
    position: relative;
    background-color: var(--bg-color);
    overflow-x: hidden;
}

/* Инициализация приложения: показываем UI только после bootstrap,
   чтобы исключить "ступенчатую" отрисовку при перезагрузке страницы. */
body.app-initializing #page-container {
    opacity: 0;
    pointer-events: none;
}

body.app-initializing #page-container * {
    transition: none !important;
    animation: none !important;
}

/* =====================================================================
   ЛЕЙАУТ — основная сетка и структурные контейнеры
   ===================================================================== */

/* вертикальная колонка контента, ограничена по ширине */
.widget-container {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: var(--space-16);
    z-index: 1;
    padding-bottom: 40px;
}

/* Скейлим только контент страницы, исключая fullscreen viewer (#result-card),
   иначе fixed-слои viewer начинают вести себя как внутри transform-контекста. */
#page-container > :not(#result-card) {
    transition:
        opacity var(--motion-fast) ease;
    will-change: opacity;
}

body.page-search-transition-active #page-container > :not(#result-card) {
    opacity: 0;
}

/* логотип Flamo вверху страницы */
.app-logo {
    display: block;
    margin: 0 auto 12px;
    height: 40px;
    width: auto;
}

.app-logo-row {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.debug-open-btn {
    position: absolute;
    top: var(--space-6);
    right: 0;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.08);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.debug-open-btn[hidden] {
    display: none !important;
}

.debug-open-btn img {
    width: 18px;
    height: 18px;
    filter: invert(1) opacity(0.9);
}

.debug-mode-label {
    position: absolute;
    top: 44px;
    text-align: center;
    font-size: var(--text-xs);
    color: var(--success);
}

.debug-mode-label[hidden] {
    display: none !important;
}

.debug-pin-note {
    margin-bottom: var(--space-24);
    color: var(--text-muted);
    font-size: var(--text-base);
}

.debug-pin-input {
    width: 100%;
    text-align: center;
    letter-spacing: 0.2em;
    font-weight: var(--fw-semibold);
}

.debug-pin-input disabled {
    color: var(--text-muted);
    cursor: not-allowed;
    pointer-events: none;
    user-select: none;
}


.debug-pin-error {
    margin-top: var(--space-12);
}

.debug-pin-lock {
    margin-top: var(--space-4);
    color: var(--warning);
    font-size: var(--text-xs);
    text-align: center;
}

.debug-screen-layout {
    max-width: 640px;
}

.debug-screen-grid {
    display: grid;
    grid-template-columns: 1fr;
    font-size: var(--text-base);
}

.debug-screen-section {
    margin-bottom: var(--space-12);
    padding: var(--space-12);
    border-radius: var(--radius);
    box-shadow: inset 0 0 0 1px var(--border-subtle);
    background-color: var(--card-bg);
}

.debug-filter-tabs {
    margin-bottom: var(--space-12);
}

.debug-filter-tab.active {
    color: var(--accent);
    background: var(--accent-fill);
}

.debug-screen-section-title {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: var(--space-8);
}

.debug-kv {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-12);
    padding: var(--space-8) 0;
    border-bottom: 1px solid var(--bg-subtle);
}

.debug-kv:first-child {
    border-top: 1px solid var(--bg-subtle);
}

.debug-kv:last-child {
    border-bottom: none;
    padding-bottom: 0;
}


.debug-kv .k {
    color: var(--text-muted);
    font-size: var(--text-base);
}

.debug-kv .v {
    color: var(--text-main);
    font-weight: var(--fw-semibold);
    font-size: var(--text-base);
    text-align: right;
    word-break: break-word;
}

.dropdown-items.debug-flag-list {
    max-height: none;
    overflow: visible;
    padding: 0;
}

.checkbox-label.debug-flag-item {
    padding: var(--space-8) 0;
}

.checkbox-label.debug-flag-item:last-child {
    padding-bottom: 0;
}

/* A/B в debug.html — тот же визуал шапки, что у фильтров (multi-select-header) */
.debug-page .debug-ab-form-group {
    margin-top: var(--space-12);
    padding-top: var(--space-12);
    border-top: 1px solid var(--border-subtle);
    margin-bottom: 0;
}

.debug-page .debug-ab-select-shell {
    padding: 0;
    padding-right: var(--space-8);
    cursor: pointer;
}

/* :disabled только у <select>; оболочка — div, поэтому дублируем состояние классом .is-disabled */
.debug-page .debug-ab-select-shell.is-disabled {
    cursor: not-allowed;
    pointer-events: none;
    opacity: 0.6;
}

.debug-page .debug-ab-select-native {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text-main);
    font-size: var(--text-base);
    font-family: inherit;
    line-height: inherit;
    padding: var(--space-12) var(--space-4) var(--space-12) var(--space-12);
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.debug-page .debug-ab-select-native:focus {
    outline: none;
}

.debug-page .debug-ab-select-native:disabled {
    cursor: not-allowed;
    color: var(--text-muted);
    user-select: none;
}

.debug-page .debug-ab-select-shell:focus-within {
    box-shadow: inset 0 0 0 1px var(--accent);
}

.debug-page .debug-ab-select-shell.is-disabled:focus-within {
    box-shadow: inset 0 0 0 1px var(--border-subtle);
}

.debug-page .debug-ab-manual-hint {
    margin: var(--space-8) 0 0;
    font-size: var(--text-xs);
    color: var(--text-muted);
    line-height: var(--leading-tight);
}

.debug-snapshot {
    width: 100%;
    min-height: 220px;
    max-height: 46vh;
    overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-subtle) var(--card-bg);
    padding: var(--space-12);
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.28);
    color: var(--text-main);
    font-size: var(--text-xs);
    line-height: var(--leading-tight);
    margin-bottom: var(--space-12);
}

/* =====================================================================
   DEBUG PAGE — отдельная вкладка debug.html
   ===================================================================== */

.debug-page-body {
    min-height: 100vh;
    margin: 0;
    padding: var(--space-16);
    background: var(--bg-color);
    color: var(--text-main);
}

.debug-page {
    width: 100%;
    max-width: 460px;
    margin: 0 auto;
}

.debug-page .header {
    margin-bottom: var(--space-16);
}

.debug-page .title {
    margin: 0 0 var(--space-6);
    font-size: var(--text-xl);
    font-weight: var(--fw-bold);
}

.debug-page .subtitle {
    margin: 0;
    color: var(--text-muted);
    font-size: var(--text-base);
    line-height: var(--leading-tight);
}

.debug-page .blocked {
    margin-top: var(--space-16);
    margin-bottom: var(--space-16);
    padding: var(--space-12);
    border-radius: var(--radius-sm);
    border: 1px solid var(--warning);
    background: rgba(255, 215, 0, 0.04);
    color: var(--warning);
    font-size: var(--text-lg);
    text-align: center;
}

.debug-page .debug-screen-section {
    margin-top: var(--space-12);
}

.debug-page .debug-screen-section.is-hidden {
    display: none !important;
}

.debug-page .debug-screen-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-8);
}

.debug-section-help-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    width: 20px;
    height: 20px;
    padding: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.debug-section-help-btn svg {
    width: 100%;
    height: 100%;
    display: block;
}

.debug-section-help-btn:active {
    transform: scale(0.95);
}

.debug-page .with-help {
    display: inline-flex;
    align-items: center;
    gap: var(--space-6);
}

.debug-help-icon {
    --debug-help-icon-size: 16px;
    --debug-help-icon-color: var(--text-main);
    --debug-help-icon-stroke: 2px;
    border: none;
    background: transparent;
    padding: 0;
    margin: 0;
    width: var(--debug-help-icon-size);
    height: var(--debug-help-icon-size);
    color: var(--debug-help-icon-color);
    cursor: pointer;
    opacity: var(--opacity-disabled);
}

.debug-help-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.debug-help-icon path {
    stroke-width: var(--debug-help-icon-stroke);
}

.debug-help-icon:active {
    transform: scale(0.95);
}

.debug-help-tooltip {
    position: absolute;
    z-index: 2100;
    max-width: min(340px, calc(100vw - 16px));
    padding: var(--space-8);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text-main);
    border: 1px solid var(--border-subtle);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
    font-size: var(--text-base);
    line-height: var(--leading-tight);
}

.debug-tooltip-desc {
    color: var(--text-main);
}

.debug-tooltip-code-wrap {
    margin-top: var(--space-8);
    display: flex;
    align-items: center;
    gap: var(--space-8);
}

.debug-tooltip-code-value {
    position: relative;
    flex: 1;
    min-width: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.9em;
    color: var(--text-main);
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xs);
    padding: var(--space-4);
    padding-right: var(--space-24);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.debug-tooltip-copy {
    position: absolute;
    bottom: var(--space-12);
    right: var(--space-12);
    width: 20px;
    height: 20px;
    background: transparent;
    color: var(--text-main);
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.debug-tooltip-copy svg {
    width: 16px;
    height: 16px;
    display: block;
}

.debug-page .debug-value-bad {
    color: #ff6b6b;
    font-weight: var(--fw-semibold);
}

.debug-page .debug-value-warn {
    color: #f5c16c;
    font-weight: var(--fw-semibold);
}

.debug-health-issues {
    margin-top: var(--space-8);
    font-size: var(--text-base);
    color: var(--text-muted);
    line-height: var(--leading-tight);
}

.debug-health-issues.debug-health-issues-bad {
    color: #ff8a8a;
}

.debug-page .debug-subsection-label {
    margin-top: var(--space-16);
    margin-bottom: var(--space-8);
    font-size: var(--text-base);
    color: var(--text-muted);
}

.debug-help-select-modal {
    z-index: 2500;
}

.debug-help-body p {
    margin: 0 0 var(--space-12);
    color: var(--text-main);
    font-size: var(--text-base);
    line-height: var(--leading-tight);
}

.debug-help-body ul,
.debug-help-body ol {
    margin: 0 0 var(--space-12);
    padding-left: var(--space-20);
    color: var(--text-main);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
}

.debug-help-body li + li {
    margin-top: var(--space-6);
}

.debug-help-body code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.92em;
    color: var(--text-main);
}


/* форма фильтров — поверх карточки результата */
#filter-form {
    position: relative;
    z-index: 10;
}

/* стеклянная карточка с размытием фона */
.card {
    background-color: var(--card-bg);
    border-radius: var(--radius);
    padding: var(--space-16);
    box-shadow: inset 0 0 0 1px var(--border-subtle);
}

/* группа поля фильтра */
.form-group {
    margin-bottom: var(--space-20);
    position: relative;
}

/* строка-заголовок над группой полей */
.group-label {
    display: flex;
    justify-content: space-between;
    font-size: var(--text-base);
    font-weight: var(--fw-regular);
    margin-bottom: var(--space-8);
    color: var(--text-muted);
}

/* заголовок без нижнего отступа (когда прямо над инпутом) */
.group-label-no-margin {
    margin-bottom: 0;
}

/* горизонтальная строка из нескольких полей */
.row {
    display: flex;
    gap: var(--space-12);
}

/* =====================================================================
   ПРЕСЕТЫ — горизонтальный скролл быстрых наборов фильтров
   ===================================================================== */

/* контейнер чипов пресетов со скрытым скроллбаром */
.presets-container {
    display: flex;
    align-items: center;
    gap: var(--space-6);
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: var(--space-12);
    scrollbar-width: none;
}

.presets-container::-webkit-scrollbar {
    display: none;
}

/* чип пресета в неактивном состоянии */
.preset-chip {
    position: relative;
    background-color: var(--bg-subtle);
    padding: var(--space-12) var(--space-16) var(--space-12) var(--preset-chip-padding-left, 40px);
    border-radius: var(--radius-pill);
    font-size: var(--text-base);
    font-weight: var(--fw-regular);
    line-height: var(--leading-none);
    white-space: nowrap;
    cursor: pointer;
    transition: var(--motion-fast);
    color: var(--text-main);
}

/* иконка пресета (Flamo Icons, stroke currentColor) — слева внутри чипса */
.chip-icon {
    position: absolute;
    top: 50%;
    left: 22px;
    transform: translateY(-50%) translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--preset-chip-icon-size, 22px);
    height: var(--preset-chip-icon-size, 22px);
    color: inherit;
    pointer-events: none;
    user-select: none;
    overflow: visible;
}

.preset-chip-svg {
    width: 100%;
    height: 100%;
    flex-shrink: 0;
    display: block;
    overflow: visible;
}

/* Единая толщина линии для всех контуров иконки (каскад сильнее presentation attributes в разметке). */
.preset-chip-svg :is(path, circle, ellipse, line, polyline, polygon, rect) {
    stroke-width: var(--preset-chip-stroke, 1.5px);
}

/* текстовый лейбл — справа от иконки */
.chip-label {
    position: relative;
    z-index: 1;
}

.preset-chip:active {
    transform: scale(0.95);
    background-color: var(--input-bg);
}

/* выбранный пресет — акцентная обводка */
.preset-chip.active {
    background: var(--accent-fill);
    color: var(--accent);
}

/* === Тогл расширенных фильтров === */

/* кнопка «Дополнительные фильтры ▾» */
.advanced-filters-toggle {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 0 0 2px;
    font-size: var(--text-base);
    font-weight: var(--fw-medium);
    cursor: pointer;
    transition: color var(--motion-fast) ease, opacity var(--motion-fast) ease;
}

.advanced-filters-toggle:active {
    opacity: var(--opacity-dim);
    transform: scale(0.98);
}

.advanced-filters-toggle:focus-visible {
    outline: none;
    color: var(--accent);
}

/* состояние когда фильтры раскрыты */
.advanced-filters-toggle.open {
    color: var(--accent);
}

/* шеврон рядом с текстом тогла (SVG из chevron-down) */
.advanced-filters-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: transform var(--motion-fast) ease, color var(--motion-fast) ease;
    transform-origin: center;
}

.advanced-filters-chevron svg {
    display: block;
    flex-shrink: 0;
}

/* шеврон поворачивается вверх при открытии */
.advanced-filters-toggle.open .advanced-filters-chevron {
    transform: rotate(-180deg);
    color: var(--accent);
}

/* контейнер доп. фильтров — скрыт через max-height + blur + opacity */
.advanced-filters-content {
    position: relative;
    z-index: 2;
    max-height: 0;
    overflow: visible;
    opacity: 0;
    filter: blur(8px);
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-8px);
    transition:
        max-height var(--motion-history) var(--motion-curve-collapse),
        opacity var(--motion-medium) ease,
        filter var(--motion-history) ease,
        transform var(--motion-history) var(--motion-curve-collapse),
        visibility 0s linear calc(var(--motion-history) + 60ms);
    will-change: max-height, opacity, transform;
}

/* раскрытое состояние доп. фильтров */
.advanced-filters-content.open {
    max-height: 1200px;
    overflow: visible;
    opacity: 1;
    filter: blur(0px);
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
    transition:
        max-height var(--motion-history) var(--motion-curve-collapse),
        opacity var(--motion-medium) ease,
        filter var(--motion-history) ease,
        transform var(--motion-history) var(--motion-curve-collapse),
        visibility 0s linear 0s;
}

/* =====================================================================
   ПЕРЕКЛЮЧАТЕЛЬ ТИПА КОНТЕНТА — сегментированный контрол (Фильм / Сериал / …)
   ===================================================================== */

/* обёртка сегментированного контрола; --active-index задаётся из JS */
.content-type-control {
    --active-index: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: var(--space-4);
    position: relative;
    overflow: hidden;
    background: var(--input-bg);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-20);
}

/* скользящая подсветка активной кнопки — сдвигается через CSS-переменную */
.content-type-highlight {
    position: absolute;
    top: 4px;
    left: 4px;
    width: calc((100% - 8px) / 2);
    height: calc(100% - 8px);
    border-radius: var(--radius-xs);
    background: var(--accent-fill);
    transform: translateX(calc(var(--active-index) * 100%));
    transition: transform var(--motion-quick) var(--motion-curve-emphasized);
    pointer-events: none;
    z-index: 0;
}

/* кнопка типа контента */
.content-type-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-xs);
    padding: var(--space-8);
    font-size: var(--text-base);
    font-weight: var(--fw-regular);
    line-height: var(--leading-none);
    cursor: pointer;
    transition: background-color var(--motion-fast) ease, color var(--motion-fast) ease;
    position: relative;
    z-index: 1;
    width: 100%;
    min-width: 0;
}

/* активная кнопка типа */
.content-type-btn.active {
    color: var(--accent);
    background: transparent;
    font-weight: var(--fw-medium);
}

.content-type-btn:focus-visible {
    outline: none;
}

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

.content-type-btn:disabled {
    opacity: var(--opacity-disabled);
    cursor: not-allowed;
    pointer-events: none;
}

/* =====================================================================
   ИНПУТЫ И СЛАЙДЕРЫ — числовые поля, двойные слайдеры года и рейтинга
   ===================================================================== */

/* числовые поля ввода и строка поиска внутри дропдауна */
input[type="number"],
.dropdown-search {
    width: 100%;
    background-color: var(--input-bg);
    box-shadow: inset 0 0 0 1px var(--border-color);
    border: none;
    color: var(--text-main);
    padding: var(--space-12);
    border-radius: var(--radius-sm);
    font-size: var(--text-base);
    outline: none;
}

/* акцентная обводка при фокусе */
input[type="number"]:focus,
.dropdown-search:focus {
    box-shadow: inset 0 0 0 1px var(--accent);
}

.label-meta {
    font-size: var(--text-xs);
    font-weight: var(--fw-regular);
    color: var(--text-muted);
}

/* обёртка слайдера — задаёт высоту и локальную переменную размера ручки */
.slider-container {
    position: relative;
    height: 32px;
    --slider-thumb-size: 22px;
}

/* серая дорожка слайдера */
.slider-track {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 8px;
    height: 3px;
    background-color: var(--border-color);
    border-radius: var(--radius-pill);
    z-index: 1;
}

/* белая полоса выбранного диапазона */
.slider-range {
    position: absolute;
    bottom: 8px;
    height: 3px;
    background-color: var(--accent);
    z-index: 2;
}

/* кастомный двойной слайдер года: две ручки на одном треке */
.year-dual-slider {
    position: relative;
    height: 32px;
    --slider-thumb-size: 22px;
}

/* трек года без дополнительных отступов */
.year-dual-slider .slider-track {
    left: 0px;
    right: 0px;
}

/* ручка кастомного слайдера (год / рейтинг) */
.year-thumb {
    position: absolute;
    width: 22px;
    height: 22px;
    background-color: var(--accent);
    box-shadow: 0 0px 8px 0px var(--accent-glow);
    border-radius: 50%;
    bottom: 8px;
    margin-bottom: -9.5px;
    cursor: pointer;
    touch-action: none;
    z-index: 3;
    user-select: none;
    -webkit-user-select: none;
    will-change: left;
}

/* левая ручка: правый край совпадает с позицией значения */
#year-thumb-from,
#rating-thumb-min {
    transform: translateX(-100%);
}

/* правая ручка: левый край совпадает с позицией значения */
#year-thumb-to,
#rating-thumb-max {
    transform: translateX(0);
}

/* трек рейтинга — те же отступы что у года */
#rating-dual-slider .slider-track {
    left: 0px;
    right: 0px;
}

#cert-age-slider-root .slider-track {
    left: 0px;
    right: 0px;
}

#cert-thumb-from {
    transform: translateX(-100%);
}

#cert-thumb-to {
    transform: translateX(0);
}

/* невидимый нативный range поверх кастомного слайдера — только для событий */
.slider-input {
    position: absolute;
    left: calc(var(--slider-thumb-size) / -2);
    bottom: 9px;
    width: calc(100% + var(--slider-thumb-size));
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    pointer-events: none;
    z-index: 3;
}

/* скрываем дефолтный трек нативного range */
.slider-input::-webkit-slider-runnable-track {
    height: 3px;
    background: transparent;
}

.slider-input::-moz-range-track {
    height: 3px;
    background: transparent;
}

/* ручка нативного range (кликабельная зона) */
.slider-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: var(--slider-thumb-size);
    height: var(--slider-thumb-size);
    background-color: var(--accent);
    box-shadow: inset 0 0 0 2px var(--card-bg);
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: none;
    margin-top: -9px;
}

.slider-input::-moz-range-thumb {
    width: var(--slider-thumb-size);
    height: var(--slider-thumb-size);
    background-color: var(--accent);
    box-shadow: inset 0 0 0 2px var(--card-bg);
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: none;
}

#votes-min {
    pointer-events: auto;
    touch-action: pan-x;
    left: 0;
    width: 100%;
}

#votes-min:focus-visible {
    outline: none;
}

#votes-min:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 3px var(--accent-fill), inset 0 0 0 2px var(--card-bg);
}

#votes-min:focus-visible::-moz-range-thumb {
    box-shadow: 0 0 0 3px var(--accent-fill), inset 0 0 0 2px var(--card-bg);
}

#votes-display {
    white-space: nowrap;
}

.votes-single-slider .slider-track {
    left: 0;
    right: 0;
}

#votes-slider-range {
    left: 0;
    right: 0;
    width: auto;
    transform-origin: left center;
    transform: scaleX(0);
}

.votes-single-slider {
    --votes-inset: calc(var(--slider-thumb-size) / 2);
    padding-left: var(--votes-inset);
    padding-right: var(--votes-inset);
}

@media (max-width: 640px) {
    .year-dual-slider {
        height: 36px;
    }
}

/* быстрые пресеты периодов под слайдером года: «80-е», «2010-е» и т.д. */
.year-presets {
    display: flex;
    gap: var(--space-6);
    margin-top: var(--space-8);
    overflow-x: auto;
    scrollbar-width: none;
}

.year-presets::-webkit-scrollbar {
    display: none;
}

/* чип периода в неактивном состоянии */
.year-chip {
    border-radius: var(--radius-pill);
    background: var(--bg-subtle);
    color: var(--text-muted);
    font-size: var(--text-base);
    font-weight: var(--fw-regular);
    padding: var(--space-6) var(--space-4);
    white-space: nowrap;
    cursor: pointer;
    transition: var(--motion-fast);
}

.year-chip:active {
    transform: scale(0.96);
}

/* выбранный пресет периода */
.year-chip.active {
    color: var(--accent);
    background: var(--accent-fill);
}

.year-display {
    color: var(--text-main);
    font-weight: var(--fw-medium);
}

.rating-display {
    color: var(--text-main);
    font-weight: var(--fw-medium);
}

/* =====================================================================
   МУЛЬТИСЕЛЕКТ — выпадающий список с поиском (жанры, актёры, страны)
   ===================================================================== */

/* шапка закрытого дропдауна — выглядит как инпут */
.multi-select-header {
    background-color: var(--input-bg);
    box-shadow: inset 0 0 0 1px var(--border-color);
    padding: var(--space-12);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-12);
    font-size: var(--text-base);
    user-select: none;
    transition: var(--motion-fast);
}

.multi-select-header:active {
    box-shadow: inset 0 0 0 1px var(--accent);
}

.multi-select-header:disabled {
    cursor: not-allowed;
    pointer-events: none;
    user-select: none;
}

/* фокус и открытое состояние — акцентная обводка */
.multi-select-header:focus-visible,
.multi-select-header.open {
    box-shadow: inset 0 0 0 1px var(--accent);
    outline: none;
}

/* текст выбранных значений с обрезкой многоточием */
.multi-select-header-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* иконка действия: стрелка или кнопка сброса */
.multi-select-header-action {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    flex: 0 0 auto;
    border-radius: var(--radius-pill);
    transition: color var(--motion-fast) ease, background-color var(--motion-fast) ease;
    line-height: var(--leading-none);
    font-size: 0;
}

/* SVG-иконка внутри кнопки действия */
.multi-select-header-icon {
    width: 18px;
    height: 18px;
    display: block;
    color: var(--text-muted);
    transition: opacity var(--motion-fast) ease;
}

.multi-select-header-icon.is-hidden {
    display: none;
}

/* кнопка сброса активна (есть выбранные значения) */
.multi-select-header.has-reset .multi-select-header-action {
    color: var(--text-muted);
    cursor: pointer;
}

.multi-select-header.has-reset .multi-select-header-action:active {
    background: var(--accent-fill);
    transform: scale(0.98);
}

/* контейнеры списков: DOM остаётся в форме, показ — в полноэкранной модалке */
.multi-select-dropdown {
    display: none;
}

/* =====================================================================
   МОДАЛКА ВЫБОРА ФИЛЬТРОВ — популярность, жанры, страны
   ===================================================================== */

.select-modal {
    position: fixed;
    inset: 0;
    z-index: 400;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

.select-modal[hidden] {
    display: none !important;
}

.select-modal__backdrop {
    position: absolute;
    inset: 0;
    backdrop-filter: blur(50px) brightness(0.7);
    -webkit-backdrop-filter: blur(50px) brightness(0.7);
}

.select-modal__layout {
    position: relative;
    z-index: 1;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    max-width: 100%;
    padding-left: var(--space-24);
    padding-right: var(--space-24);
    padding-top: calc(var(--space-24) + env(safe-area-inset-top, 0px));
}

.select-modal__title {
    flex-shrink: 0;
    margin: 0 0 var(--space-12);
    font-size: var(--text-xl);
    font-weight: var(--fw-bold);
    color: var(--text-main);
    text-align: left;
}

.select-modal__scroll {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.select-modal__scroll-inner {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 calc(100% - 40px), transparent 100%);
    mask-image: linear-gradient(to bottom, #000 0%, #000 calc(100% - 40px), transparent 100%);
}

.select-modal__body {
    color: var(--text-main);
    padding-bottom: var(--space-24);
}

.select-modal__body .dropdown-items {
    max-height: none;
    overflow-y: visible;
    padding-bottom: var(--space-16);
}

.select-modal__footer {
    flex-shrink: 0;
    display: flex;
    flex-direction: row;
    gap: var(--space-12);
    padding-bottom: var(--space-24);
}

.select-modal__btn {
    flex: 1 1 0;
    width: 100%;
    min-width: 0;
}

.country-selected-panel {
    margin-bottom: var(--space-12);
    box-shadow: inset 0 -1px 0 0 var(--border-color);
}

.country-selected-panel[hidden] {
    display: none !important;
}

/* фоллбэк для браузеров без backdrop-filter (старый Safari) */
@supports not ((backdrop-filter: blur(2px)) or (-webkit-backdrop-filter: blur(2px))) {
    .card {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background-color: rgba(18, 18, 18, 0.94);
    }
}

/* обёртка поля поиска внутри дропдауна */
.dropdown-search-wrapper {
    box-shadow: inset 0 -1px 0 0 var(--border-color);
    padding-bottom: var(--space-12);
    padding-top: var(--space-12);
}

/* поле поиска жанра / актёра */
.dropdown-search {
    font-size: var(--text-base);
}

/* прокручиваемый список элементов */
.dropdown-items {
    max-height: 250px;
    overflow-y: auto;
    padding: var(--space-4) 0;
}

/* состояние загрузки списка */
.dropdown-loading {
    padding: var(--space-12) var(--space-16);
    color: var(--text-muted);
    font-size: var(--text-base);
}

/* строка жанра в нейтральном состоянии */
.genre-item {
    display: flex;
    align-items: center;
    padding: var(--space-12) 0;
    cursor: pointer;
    transition: var(--motion-fast);
    font-size: var(--text-base);
    user-select: none;
    color: var(--text-muted);
}

.genre-item:active {
    transform: scale(0.98);
}

/* квадратный индикатор-чекбокс рядом с названием жанра */
.genre-indicator {
    width: 18px;
    height: 18px;
    border-radius: var(--radius-xs);
    box-shadow: inset 0 0 0 2px var(--text-muted);
    margin-right: var(--space-12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xs);
    font-weight: var(--fw-bold);
    color: transparent;
    transition: var(--motion-fast);
}

/* включённый жанр — зелёный с галочкой */
.genre-item[data-state="include"] {
    color: var(--success);
}

.genre-item[data-state="include"] .genre-indicator {
    background-color: var(--success);
    box-shadow: inset 0 0 0 2px var(--success);
    color: var(--accent-text);
}

.genre-item[data-state="include"] .genre-indicator::after {
    content: '✓';
}

/* исключённый жанр — красный, зачёркнутый */
.genre-item[data-state="exclude"] {
    color: var(--danger);
    text-decoration: line-through;
    opacity: var(--opacity-dim);
}

.genre-item[data-state="exclude"] .genre-indicator {
    background-color: var(--danger);
    box-shadow: inset 0 0 0 2px var(--danger);
    color: var(--accent-text);
}

.genre-item[data-state="exclude"] .genre-indicator::after {
    content: '✕';
}

/* строка с чекбоксом (напр. «Уже виденные») */
.checkbox-label {
    display: flex;
    align-items: center;
    padding: var(--space-12) 0;
    cursor: pointer;
    transition: var(--motion-fast);
    font-size: var(--text-base);
    color: var(--text-main);
}

.checkbox-label:active {
    transform: scale(0.98);
}

/* скрываем нативный чекбокс, показываем кастомный */
.checkbox-label input[type="checkbox"] {
    display: none;
}

/* кастомный квадратный чекбокс */
.checkbox-indicator {
    width: 18px;
    height: 18px;
    border-radius: var(--radius-xs);
    box-shadow: inset 0 0 0 2px var(--text-muted);
    margin-right: var(--space-12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xs);
    font-weight: var(--fw-bold);
    color: transparent;
    transition: var(--motion-fast);
}

/* отмеченный чекбокс — акцентный цвет */
.checkbox-label input[type="checkbox"]:checked + .checkbox-indicator {
    background-color: var(--accent);
    box-shadow: inset 0 0 0 2px var(--accent);
    color: var(--accent-text);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-indicator::after {
    content: '✓';
}

.checkbox-text {
    line-height: var(--leading-none);
}

/* =====================================================================
   СКРОЛЛБАР — кастомный тонкий (только WebKit / Blink)
   ===================================================================== */

::-webkit-scrollbar {
    width: 0;
}

::-webkit-scrollbar-track {
    background: var(--input-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-xs);
}

/* =====================================================================
   КНОПКИ — primary, secondary и общие стили
   ===================================================================== */

/* группа кнопок под формой фильтров */
.btn-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-12);
    margin-top: var(--space-24);
    position: relative;
    z-index: 1;
}

/* базовые стили всех кнопок и ссылок-кнопок */
button,
.btn-link {
    width: 100%;
    padding: var(--space-12);
    border-radius: var(--radius-sm);
    border: none;
    font-family: inherit;
    font-size: var(--text-base);
    font-weight: var(--fw-medium);
    line-height: var(--leading-none);
    cursor: pointer;
    transition: var(--motion-fast);
    text-align: center;
    text-decoration: none;
    display: block;
}

/* недоступная кнопка */
button:disabled {
    opacity: var(--opacity-disabled);
    cursor: not-allowed;
    pointer-events: none;
}

/* акцентная (оранжевая) кнопка — основное действие */
.btn-primary {
    background-color: var(--accent);
    color: var(--accent-text);
}

.btn-primary:active {
    background-color: var(--accent-hover);
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: var(--opacity-disabled);
    cursor: not-allowed;
    pointer-events: none;
}

/* призрачная кнопка — вторичное действие */
.btn-secondary {
    background-color: transparent;
    color: var(--text-main);
    box-shadow: inset 0 0 0 1px var(--border-color);
}

.btn-secondary:active {
    background-color: var(--border-color);
    color: var(--text-main);
    transform: scale(0.98);
}

.btn-secondary:disabled {
    opacity: var(--opacity-disabled);
    cursor: not-allowed;
    pointer-events: none;
}

/* =====================================================================
   ИНДИКАТОР ОХВАТА ПОИСКА — полоска с лейблом под кнопкой «Найти»
   ===================================================================== */

/* вся секция индикатора */
.search-width-meter {
    margin-top: var(--space-16);
}

/* строка над полоской: лейбл слева + число справа */
.search-width-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-8);
    margin-bottom: var(--space-6);
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* слово-лейбл: «Широкий», «Скромный» и т.д. */
.search-width-label {
    font-weight: var(--fw-regular);
}

/* правая часть строки */
.search-width-right {
    display: flex;
    align-items: center;
    gap: var(--space-6);
}

/* примерное число результатов: «~5k» */
.search-width-count {
    font-size: var(--text-xs);
    opacity: var(--opacity-hint);
}

.search-width-value {
    font-weight: var(--fw-medium);
}

/* серая дорожка полоски охвата */
.search-width-track {
    width: 100%;
    height: 6px;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.09);
    overflow: hidden;
}

/* белая заливка — ширина анимируется при смене охвата */
.search-width-fill {
    height: 100%;
    width: 100%;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.3);
    transition: width var(--motion-slow) var(--motion-curve-standard);
}

/* =====================================================================
   УВЕДОМЛЕНИЯ — встроенные сообщения об ошибках с кнопкой действия
   ===================================================================== */

/* базовое уведомление (скрыто по умолчанию) */
.message {
    padding: var(--space-12);
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: var(--text-base);
    display: none;
    margin-bottom: var(--space-16);
    margin-top: var(--space-16);
}

/* уведомление об ошибке */
.message.error {
    background-color: rgba(var(--danger-rgb), 0.1);
    color: var(--danger);
    box-shadow: inset 0 0 0 1px rgba(var(--danger-rgb), 0.3);
}

/* кнопка действия внутри уведомления (напр. «Повторить») */
.message .message-action {
    margin-top: var(--space-12);
    width: auto;
    min-width: 180px;
    display: inline-block;
    padding: var(--space-12) var(--space-16);
    border-radius: var(--radius-sm);
    box-shadow: inset 0 0 0 1px var(--border-glass);
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    font-size: var(--text-base);
    font-weight: var(--fw-medium);
    cursor: pointer;
}

/* =====================================================================
   КАРТОЧКА ФИЛЬМА — результат поиска со свайпом
   ===================================================================== */

/* карточка результата: скрыта до первого поиска */
#result-card {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 120;
    overflow: hidden;
    touch-action: none;
    transition:
        transform var(--motion-medium) var(--motion-curve-standard),
        opacity var(--motion-medium) ease;
    padding: 0;
    box-shadow: none;
    border-radius: 0;
    background: var(--bg-color);
}

#result-card.viewer-closed {
    opacity: 0;
    pointer-events: none;
}

#result-card.viewer-open {
    opacity: 1;
    pointer-events: auto;
}

.viewer-close-btn {
    position: fixed;
    top: max(12px, calc(env(safe-area-inset-top, 0px) + 8px));
    right: max(12px, calc(env(safe-area-inset-right, 0px) + 8px));
    z-index: 200;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 999px;
    color: var(--text-main);
    background: rgba(10, 10, 10, 0.5);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    line-height: 1;
}

.return-to-viewer-btn {
    width: 100%;
    margin-top: var(--space-12);
}

/* кнопка возврата под фильтрами (для выхода из fullscreen-режима) */
.return-to-session-row[hidden] {
    display: none !important;
}

.return-to-session-row {
    display: flex;
    align-items: stretch;
    gap: var(--space-8);
    width: 100%;
    position: relative;
    z-index: 40;
}

.return-to-movie-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
}

.return-to-movie-btn[hidden] {
    display: none !important;
}

.reset-search-session-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    min-width: 40px;
    padding: 0;
}

.reset-search-session-btn__icon {
    display: block;
    flex-shrink: 0;
}

.reset-search-session-btn[hidden] {
    display: none !important;
}

/* =====================================================================
   FULLSCREEN VIEWER — новая shell-обёртка для будущей runtime-интеграции
   ===================================================================== */

.fullscreen-viewer-root {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--motion-medium) var(--motion-curve-standard);
}

.fullscreen-viewer-root[hidden] {
    display: none !important;
}

.fullscreen-viewer-root.is-open {
    opacity: 1;
    pointer-events: auto;
}

.fullscreen-viewer-shell {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: rgba(8, 10, 16, 0.96);
}

.fullscreen-viewer-close {
    position: fixed;
    top: max(12px, calc(env(safe-area-inset-top) + 8px));
    right: max(12px, calc(env(safe-area-inset-right) + 8px));
    width: 44px;
    height: 44px;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-pill);
    background: rgba(0, 0, 0, 0.44);
    color: var(--text-main);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    line-height: 1;
    z-index: 3;
    cursor: pointer;
    transition: var(--motion-fast);
}

.fullscreen-viewer-close:active {
    transform: scale(0.97);
    opacity: var(--opacity-hint);
}

.fullscreen-viewer-overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: none;
    align-items: center;
    justify-content: center;
    padding: calc(env(safe-area-inset-top) + var(--space-24)) var(--space-16) var(--space-24);
    text-align: center;
}

.fullscreen-viewer-overlay.is-visible {
    display: flex;
}

.fullscreen-viewer-layers {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
    pointer-events: auto;
}

/* Лента из трёх слотов: prev / current / next */
.fv-tape {
    display: flex;
    flex-direction: column;
    width: 100%;
    /* начальное положение: показываем средний слот */
    transform: translateY(-100dvh);
    pointer-events: auto;
    /* transition добавляется через JS только в момент commit */
}

.fv-slot {
    width: 100%;
    height: 100dvh;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
    background: var(--bg-color);
    pointer-events: auto;
}

.swipe-preview-card {
    position: relative;
    width: 100%;
    min-height: 100dvh;
    background: var(--bg-color);
    overflow: hidden;
}

.swipe-preview-poster {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.swipe-preview-gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(8, 10, 16, 0.88) 20%, rgba(8, 10, 16, 0.12) 60%, rgba(8, 10, 16, 0) 100%);
}

.swipe-preview-content {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.swipe-preview-title {
    font-size: var(--text-xl);
    font-weight: var(--fw-bold);
    line-height: var(--leading-snug);
    color: var(--text-main);
}

.swipe-preview-submeta {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

/* анимация появления карточки при смене фильма */
#result-card.loading-card-enter {
    animation: cardLoadingEnter var(--motion-slow) var(--motion-curve-emphasized) both;
    will-change: transform, opacity;
}

/* обёртка контента карточки — скрыта до завершения раскрытия.
   Верх без safe-area: постер и фон уходят под статус-бар (edge-to-edge WebView);
   нижний inset оставляем под home indicator при скролле текста. Крестик — .viewer-close-btn. */
#movie-content-wrapper {
    display: none;
    opacity: 0;
    position: relative;
    z-index: 2;
    min-height: 100dvh;
    max-height: 100dvh;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    padding-top: 0;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 0px);
    background: var(--bg-color);
}

/* контент виден после раскрытия */
#movie-content-wrapper.revealed {
    opacity: 1;
}

/* невидимый рендер вне потока — для замера итоговой высоты карточки */
#movie-content-wrapper.measuring {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    visibility: hidden;
    pointer-events: none;
    opacity: 0;
}

/* контейнер постера с градиентной маской снизу — на всю высоту вьюпорта, в т.ч. под статус-бар */
.movie-poster-container {
    position: relative;
    width: 100%;
    min-height: 100dvh;
    overflow: hidden;
    background-color: transparent;
    padding: var(--space-16);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

/* постер — заполняет контейнер, исчезает градиентом снизу */
.movie-poster {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 80%;
    object-fit: cover;
    z-index: 0;
    object-position: center center;
    -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 50%, transparent 90%);
    mask-image: linear-gradient(to bottom, #000 0%, #000 50%, transparent 90%);
    transition:
        filter var(--motion-medium) var(--motion-curve-standard),
        transform var(--motion-medium) var(--motion-curve-standard);
    transform: scale(1);
    filter: none;
}

/* постер размывается и масштабируется при раскрытии описания */
.movie-poster-container.overview-expanded .movie-poster {
    filter: brightness(0.4) blur(3px);
    transform: scale(1.06);
}

/* дочерние элементы контейнера поверх постера */
.movie-poster-container > :not(.movie-poster) {
    position: relative;
    z-index: 2;
}

/* текстовый блок над постером */
.movie-hero-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
}

/* строка метаданных: тип · год · страна */
.movie-topline {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex-wrap: wrap;
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: var(--fw-medium);
}

/* разделитель «·» между элементами строки */
.movie-topline-sep {
    opacity: var(--opacity-sep);
}

/* название фильма */
.movie-title {
    font-size: var(--text-xl);
    font-weight: var(--fw-bold);
    line-height: var(--leading-snug);
    color: var(--text-main);
}

/* подзаголовок: жанры и длительность */
.movie-submeta {
    font-size: var(--text-base);
    color: var(--text-muted);
    line-height: var(--leading-tight);
}

/* блок ссылок «Смотреть» / «Подробнее» */
.external-links {
    margin-top: var(--space-16);
    margin-bottom: var(--space-24);
}

/* кнопка Kinorium */
.btn-kinorium {
    background-color: var(--accent);
    color: var(--accent-text);
}

.btn-kinorium:active {
    background-color: var(--accent-hover);
    transform: scale(0.98);
}

/* строка бейджей: рейтинг, студия */
.movie-badges {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-6);
    margin-bottom: var(--space-8);
}

/* бейдж рейтинга */
.rating-badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-4) var(--space-6);
    border-radius: 7px;
    font-weight: var(--fw-medium);
    font-size: var(--text-xs);
    color: var(--text-main);
    background-color: var(--border-color);
}

/* нейтральный (серый) бейдж */
.rating-badge.neutral {
    background-color: var(--border-color);
    color: var(--text-main);
}

/* бейдж студии с обрезкой длинного названия */
.rating-badge.studio-badge {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: var(--fw-medium);
}

/* строка режиссёр / актёры */
.movie-credits-line {
    font-size: var(--text-base);
    color: var(--text-muted);
    line-height: var(--leading-tight);
    margin-bottom: var(--space-8);
}

/* описание фильма — по умолчанию 3 строки */
.movie-overview {
    font-size: var(--text-md);
    line-height: var(--leading-normal);
    color: var(--text-main);
    margin-bottom: var(--space-6);
    min-height: 68px;
    height: 68px;
    max-height: 68px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    transition: max-height var(--motion-medium) var(--motion-curve-standard);
}

/* полное описание при нажатии «Читать далее» */
.movie-overview.expanded {
    will-change: max-height;
    display: block;
    -webkit-line-clamp: unset;
    line-clamp: unset;
    height: auto;
}

/* кнопка «Читать далее» / «Свернуть» */
.movie-overview-toggle {
    width: auto;
    background: none;
    border: none;
    color: var(--text-main);
    font-size: var(--text-base);
    font-weight: var(--fw-medium);
    padding: 0;
    text-align: left;
    cursor: pointer;
}

.movie-overview-toggle:active {
    opacity: var(--opacity-hint);
    transform: scale(0.98);
}

/* =====================================================================
   ЛОАДЕР — состояния загрузки и пустого результата
   ===================================================================== */

/* оверлей лоадера — появляется с анимацией scale + blur */
#loading-overlay {
    position: absolute;
    inset: 0;
    z-index: 200;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.965);
    filter: blur(10px);
    transition:
        opacity var(--motion-slow) ease,
        transform var(--motion-slow) var(--motion-curve-standard),
        filter var(--motion-slow) ease;
}

/* лоадер виден */
#loading-overlay.visible {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
}

/* экран «ничего не найдено» / «исчерпан» */
#result-empty-state {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 80;
    flex-direction: column;
    min-height: 640px;
    width: 100%;
    padding: var(--space-24) var(--space-18);
    align-items: center;
    justify-content: center;
    text-align: center;
    background: var(--bg-color);
    pointer-events: auto;
}

/* внутренний контейнер ограниченной ширины */
.empty-state-content {
    max-width: 320px;
    width: 100%;
    position: relative;
    z-index: 81;
}

/* блок кнопок (первое объявление — выравнивание) */
.empty-state-actions {
    width: 100%;
    align-items: stretch;
}

/* принудительное центрирование кнопок (inline-flex из JS даёт flex-start) */
.empty-state-actions button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
}

/* заголовок экрана пустого состояния */
.empty-state-title {
    font-size: var(--text-2xl);
    font-weight: var(--fw-bold);
    line-height: var(--leading-none);
    margin-bottom: var(--space-12);
    color: var(--text-main);
}

/* пояснительный текст под заголовком */
.empty-state-text {
    font-size: var(--text-md);
    line-height: var(--leading-normal);
    color: var(--text-muted);
    margin-bottom: var(--space-24);
}

/* блок кнопок действия (второе объявление — flex-колонка) */
.empty-state-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-12);
}

/* =====================================================================
   АНИМАЦИЯ ЛОАДЕРА — логотип Flamo (пламя + зрачок)
   ===================================================================== */

/* SVG-логотип с тенью */
.flame-loader {
    width: 118px;
    margin-bottom: 26px;
    filter: drop-shadow(0 10px 18px var(--accent-glow));
}

.flame-loader svg {
    width: 100%;
    height: auto;
    overflow: visible;
    display: block;
}

/* тело пламени: покачивание + дыхание */
.flame-shape {
    transform-box: fill-box;
    transform-origin: 50% 55%;
    animation:
        flameSway 2.1s ease-in-out infinite,
        flameBreath 1.6s ease-in-out infinite;
}

/* зрачок: поиск взглядом + мигание */
.flame-pupil {
    transform-box: fill-box;
    transform-origin: 50% 60%;
    animation: pupilSearch 2.3s cubic-bezier(0.42, 0, 0.2, 1) infinite;
}

/* боковое покачивание пламени */
@keyframes flameSway {
    0%, 100% { transform: translateX(0) skewX(0deg); }
    25%       { transform: translateX(-4px) skewX(-1.6deg); }
    50%       { transform: translateX(0) skewX(0.5deg); }
    75%       { transform: translateX(4px) skewX(1.8deg); }
}

/* вертикальное дыхание пламени */
@keyframes flameBreath {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(0.95, 1.06); }
}

/* движение зрачка влево-вправо */
@keyframes pupilSearch {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-11px); }
    45%       { transform: translateX(10px); }
    70%       { transform: translateX(-7px); }
}


/* появление карточки из состояния лоадера */
@keyframes cardLoadingEnter {
    0%   { opacity: 0; transform: scale(0.965); }
    100% { opacity: 1; transform: scale(1); }
}

/* прокручиваемые названия фильмов во время загрузки */
.title-roulette {
    color: var(--text-muted);
    font-style: italic;
    font-size: var(--text-xl);
    font-weight: var(--fw-bold);
    text-align: center;
    padding: 0 var(--space-12);
    line-height: var(--leading-snug);
}

/* =====================================================================
   СКЕЛЕТОН — мерцающий плейсхолдер для неполных данных (softTimeout)
   ===================================================================== */

/* пульсация мерцания */
@keyframes skeletonPulse {
    0%, 100% { opacity: var(--opacity-skeleton-min); }
    50%       { opacity: var(--opacity-sep); }
}

@keyframes skeletonPosterPulse {
    0%, 100% { opacity: 0; }
    50%      { opacity: 0.1; }
}

/* серый мерцающий прямоугольник вместо текста */
.skeleton-line {
    display: inline-block;
    background: rgba(255, 255, 255, 0.14);
    border-radius: 5px;
    animation: skeletonPulse 1.4s ease-in-out infinite;
    color: transparent !important;
    pointer-events: none;
    min-height: 1em;
    vertical-align: middle;
}

.movie-poster.skeleton-poster-pulse {
    background: #fff;
    animation: skeletonPosterPulse 1.4s ease-in-out infinite;
}

/* плавное исчезновение скелетона когда данные догрузились */
.skeleton-line.skeleton-fade-out {
    animation: none;
    transition: opacity var(--motion-fast) ease;
    opacity: 0;
}

/* =====================================================================
   ИСТОРИЯ ПРОСМОТРОВ — список ранее просмотренных фильмов
   ===================================================================== */

/* секция истории — появляется с анимацией fadeIn */
#history-section {
    display: none;
    margin-top: var(--space-24);
    animation: fadeIn var(--motion-history);
}

/* анимация исчезновения при нажатии «Очистить» */
#history-section.history-clearing {
    animation: historyClear var(--motion-quick) ease forwards;
    pointer-events: none;
}

/* схлопывание вниз при очистке истории */
@keyframes historyClear {
    from { opacity: 1; transform: scale(1) translateY(0); }
    to   { opacity: 0; transform: scale(0.97) translateY(6px); }
}

/* шапка секции истории: заголовок + кнопка «Очистить» */
.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-12);
    margin-bottom: var(--space-12);
}

/* заголовок «История» */
.history-title {
    font-size: var(--text-lg);
    font-weight: var(--fw-semibold);
    margin-bottom: 0;
    color: var(--text-muted);
    text-align: left;
}

/* кнопка «Очистить» */
.history-clear-btn {
    width: auto;
    padding: var(--space-0);
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: var(--text-base);
    font-weight: var(--fw-medium);
    line-height: var(--leading-none);
    cursor: pointer;
    transition: color var(--motion-fast) ease, opacity var(--motion-fast) ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.history-clear-btn:active {
    opacity: var(--opacity-pressed);
    transform: scale(0.98);
}

.history-clear-btn:focus-visible {
    outline: none;
    color: var(--accent);
}

/* список записей истории */
.history-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-12);
}

/* строка истории: миниатюра + текст */
.history-item {
    display: flex;
    align-items: center;
    gap: var(--space-12);
    background: var(--card-bg);
    padding: var(--space-8);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--motion-fast);
    box-shadow: inset 0 0 0 1px var(--border-subtle);
}

.history-item:active {
    transform: scale(0.98);
}

/* миниатюра постера в истории */
.history-img {
    width: 40px;
    height: 60px;
    border-radius: var(--radius-xs);
    object-fit: cover;
    background: #000;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 1px var(--border-color);
}

/* текстовая часть строки истории */
.history-info {
    flex: 1;
    overflow: hidden;
}

/* название с обрезкой многоточием */
.history-item-title {
    font-size: var(--text-base);
    font-weight: var(--fw-semibold);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: var(--space-8);
}

/* строка метаданных: год + рейтинг */
.history-item-meta {
    font-size: var(--text-base);
    color: var(--text-muted);
    display: flex;
    gap: var(--space-8);
    align-items: center;
}

/* бейдж рейтинга в строке истории */
.history-rating {
    font-weight: var(--fw-medium);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-xs);
    color: var(--accent-text);
    font-size: var(--text-xs);
}

/* общая анимация появления снизу (история, уведомления) */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

