:root {
    --bg: #14181c;
    --bg-panel: #1d2328;
    --bg-element: #263038;
    --bg-element-hover: #2e3a45;
    --text: #eef1f4;
    --text-muted: #8a97a5;
    --text-soft: #c7ced6;
    --border: #2e3a45;
    --accent: #00c186;
    --accent-hover: #00d193;
    --accent-text: #062019;
    --ok: #26d07c;
    --want: #4f9cf7;
    --watching: #f7b731;
    --kb: #9b7bff;
    --error: #f5587a;
    --danger: #f5587a;
    --gold: #ffd166;
    --orange: #ff9f43;
    --cyan: #2fd3c7;
    /* Софт-фоны бейджей/пилюлей (тот же оттенок с альфой) */
    --ok-soft: rgba(38, 208, 124, 0.15);
    --error-soft: rgba(245, 88, 122, 0.15);
    --want-soft: rgba(79, 156, 247, 0.15);
    --want-soft-strong: rgba(79, 156, 247, 0.18);
    --watching-soft: rgba(247, 183, 49, 0.15);
    --kb-soft: rgba(155, 123, 255, 0.15);
    --kb-soft-strong: rgba(155, 123, 255, 0.18);
    --gold-soft: rgba(255, 209, 102, 0.15);
    --accent-soft: rgba(0, 193, 134, 0.12);
    --orange-soft: rgba(255, 159, 67, 0.15);
    --cyan-soft: rgba(47, 211, 199, 0.15);
    --surface-2: rgba(255, 255, 255, 0.08);
    --radius: 10px;
    --shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

/* Атрибут hidden должен побеждать display:* (иначе flex-контейнеры
   вроде .tmdb-row перебивают скрытие — кнопка «Показать ещё» не работает). */
[hidden] { display: none !important; }

html { color-scheme: dark; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    line-height: 1.5;
}

a { color: var(--accent); }
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Шапка */
.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(29, 35, 40, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 16px;
    flex-wrap: wrap;
}

.brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    letter-spacing: 0.02em;
}

.nav {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    padding: 4px 2px;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

.nav a:hover { color: var(--text); }
.nav a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* «Добавить» — акцентная кнопка-пилюля в меню */
.nav a.nav-add {
    background: var(--accent);
    color: var(--accent-text);
    border-radius: var(--radius);
    padding: 5px 14px;
    border-bottom: none;
    font-weight: 600;
}

.nav a.nav-add:hover { background: var(--accent-hover); color: var(--accent-text); }

.nav a.nav-add.active {
    color: var(--accent-text);
    border-bottom: none;
    background: var(--accent-hover);
}

main { padding: 24px 0 48px; }

/* Заголовки страниц */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 3px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.page-head h1 { margin: 0; }

/* Группа кнопок действий в шапке страницы */
.page-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Кнопки шапки («Что посмотреть?» и т.п.) — компактнее базовых:
   вертикальные отступы на 3px меньше сверху и снизу (в сумме −6px). */
.page-actions .btn {
    padding: 5px 16px;
    white-space: nowrap;
}

h1 { font-size: 1.5rem; margin: 0 0 16px; }

/* Кнопки */
.btn {
    display: inline-block;
    padding: 8px 16px;
    background: var(--bg-element);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, transform 0.15s;
    text-align: center;
}

.btn:hover { background: var(--bg-element-hover); color: var(--accent); }

.btn-accent {
    background: var(--accent);
    color: var(--accent-text);
    border: none;
}

.btn-accent:hover { background: var(--accent-hover); color: var(--accent-text); }

/* Вторичный discovery-акцент (бирюзовый): «Найти ещё» и подобные */
.btn-cyan {
    background: transparent;
    color: var(--cyan);
    border: 1px solid rgba(47, 211, 199, 0.55);
}

.btn-cyan:hover { background: var(--cyan-soft); color: var(--cyan); }

/* Фокус вторичных действий — бирюзовое кольцо; primary/опасное свои */
.btn:focus-visible { outline-color: var(--cyan); }
.btn-accent:focus-visible { outline-color: var(--accent); }
.btn-danger:focus-visible { outline-color: var(--error); }

button {
    padding: 8px 16px;
    background: var(--accent);
    color: var(--accent-text);
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: opacity 0.15s;
}

button:hover { opacity: 0.88; }

.link-btn {
    background: none;
    color: var(--text-muted);
    padding: 0;
    font-weight: 500;
}

.link-btn:hover { color: var(--accent); opacity: 1; }

.inline { display: inline; }

/* Панель фильтров */
.filters {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 14px;
}

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

.filters input[type="search"],
.filters select {
    padding: 8px 12px;
    background: var(--bg-element);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    min-width: 150px;
    flex: 1 1 140px;
}

.filters select { min-width: 120px; }

/* Поиск — всегда видимая строка в шапке списков */
.filter-search {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.filter-search input[type="search"] {
    flex: 1 1 200px;
    min-width: 160px;
}

/* Сворачиваемые дополнительные фильтры (за кнопкой «Фильтры ▾») */
.filter-extra { display: none; }

.filter-extra.open {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Кнопка «Фильтры ▾» — видима на всех экранах */
.filters-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 8px 14px;
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
}

.filters-toggle:hover { color: var(--accent); border-color: var(--accent); }

.filters-arrow { transition: transform 0.15s; }
.filters-toggle.open .filters-arrow { transform: rotate(180deg); }

.filters-toggle.has-active::after {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
}

/* Липкие фильтры на десктопе: при прокрутке форма сворачивается в компактную
   кнопку-«пилюлю» «Фильтры ▾», прижатую к правому краю экрана (без большой
   прямоугольной области). По клику панель разворачивается у верха экрана.
   Класс filters--collapsed ставит JS, top — CSS-переменная --filters-top. */
@media (min-width: 761px) {
    .filters {
        position: sticky;
        top: var(--filters-top, 56px);
        z-index: 9;
    }
    .filters--collapsed {
        background: none;
        border: none;
        box-shadow: none;
        padding: 0;
        margin-bottom: 14px;
    }
    .filters--collapsed .filter-search input[type="search"],
    .filters--collapsed .filter-search > .btn,
    .filters--collapsed .type-filter-row {
        display: none;
    }
    .filters--collapsed .filters-toggle {
        position: fixed;
        right: 20px;
        top: calc(var(--filters-top, 56px) + 8px);
        min-height: 36px;
        padding: 6px 12px;
        font-size: 0.82rem;
        border-radius: 18px;
        box-shadow: var(--shadow);
        z-index: 9;
    }
}

/* Десктоп: развёрнутые фильтры — строки стопкой (фильтры + «Применить» и
   доп. строка «Просмотрено/Годы» на «Все фильмы»); внутри строки — одна линия. */
@media (min-width: 761px) {
    .filter-extra.open { flex-direction: column; }
    .filter-extra.open .filter-row { flex-wrap: nowrap; }
    .filter-extra.open select,
    .filter-extra.open .popover-toggle {
        flex: 1 1 150px;
        min-width: 0;
    }
    .filter-extra.open .type-toggle {
        flex: 0 1 auto;
        min-width: 0;
    }
    .filter-extra.open .year-filter {
        flex: 0 0 auto;
        width: 180px;
        min-width: 0;
    }
    .filter-extra.open .watched-popover {
        flex: 0 0 auto;
    }
    .filter-extra.open .btn {
        flex: 0 0 auto;
        white-space: nowrap;
    }
}

/* Переключатель «Все / Фильмы / Сериалы» — компактная строка под поиском.
   «Строка с текстом и небольшим чекбоксом», не полноценная кнопка. */
.type-filter-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0 0 8px;
    font-size: 0.85rem;
    line-height: 1.2;
}

.type-filter-opt {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.type-filter-opt input[type="radio"],
.type-filter-opt input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* Чекбокс «Непросмотренные» — прижат к правому краю строки типа */
.type-filter-watched {
    margin-left: auto;
}

.tf-check {
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
    border: 1.5px solid var(--border);
    border-radius: 3px;
    background: var(--bg-element);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.type-filter-opt:hover { color: var(--text); }
.type-filter-opt:hover .tf-check { border-color: var(--accent); }

.type-filter-opt.active { color: var(--text); }
.type-filter-opt.active .tf-check {
    background: var(--accent);
    border-color: var(--accent);
}
.type-filter-opt.active .tf-check::after {
    content: "✓";
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1;
    color: var(--accent-text);
}

/* Фильтры-попапы («Жанр ▾», «Страна ▾»): кнопка + выпадающий список чекбоксов. */
.filter-popover { position: relative; }

.popover-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    min-width: 120px;
    padding: 8px 12px;
    background: var(--bg-panel);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
}

.popover-toggle:hover { color: var(--accent); border-color: var(--accent); }

.popover-toggle.has-active::after {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
}

.popover-panel {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 60;
    min-width: 220px;
    max-height: 260px;
    overflow-y: auto;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 8px;
}

.popover-panel.open { display: block; }

.popover-option {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 4px 6px;
    font-size: 0.85rem;
    color: var(--text);
    cursor: pointer;
    border-radius: var(--radius);
}

.popover-option:hover { background: var(--bg-element); }
.popover-option input { accent-color: var(--accent); width: 14px; height: 14px; }
.popover-empty { font-size: 0.8rem; }

/* Мобильная шторка поиска/фильтров — по умолчанию скрыта (десктоп не нужен) */
.mobile-filter-sheet { display: none; }

/* Переключатель вида */
.view-switch {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 18px;
}

.seg {
    padding: 8px 18px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    background: var(--bg-panel);
    transition: background 0.15s, color 0.15s;
}

.seg + .seg { border-left: 1px solid var(--border); }
.seg:hover { color: var(--text); }

.seg.active {
    background: var(--accent);
    color: var(--accent-text);
}

/* Переключатель «Все / Фильмы / Сериалы» */
.type-toggle {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    padding: 0;
    margin: 0;
    align-self: flex-start;
    background: var(--bg-panel);
}

.type-toggle input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.type-seg {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 8px 14px;
    border-right: 1px solid var(--border);
    color: var(--text-muted);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.type-seg:last-child { border-right: none; }
.type-seg:hover { color: var(--text); }

.type-seg.active {
    background: var(--accent);
    color: var(--accent-text);
}

/* Группа переключателя с подписью (например, «Скачано») в панели фильтров. */
.filter-group {
    display: inline-flex;
    flex-direction: column;
    gap: 2px;
    align-self: flex-start;
}

.filter-group-label {
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding-left: 2px;
}

.filter-group .type-toggle { align-self: stretch; }

/* Двусторонний ползунок «Годы»: два range поверх общего трека. */
.year-filter {
    display: inline-flex;
    flex-direction: column;
    gap: 4px;
    align-self: flex-start;
    min-width: 300px;
}

.year-range {
    position: relative;
    height: 22px;
    margin: 0;
}

.year-range::before {
    content: "";
    position: absolute;
    left: 4px;
    right: 4px;
    top: 50%;
    height: 4px;
    transform: translateY(-50%);
    background: var(--bg-element);
    border-radius: 2px;
}

.year-range-fill {
    position: absolute;
    top: 50%;
    height: 4px;
    transform: translateY(-50%);
    background: var(--accent);
    border-radius: 2px;
    pointer-events: none;
}

.year-range-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 22px;
    margin: 0;
    background: transparent;
    -webkit-appearance: none;
    appearance: none;
    pointer-events: none;
}

.year-range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-panel);
    cursor: pointer;
    pointer-events: auto;
}

.year-range-input::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-panel);
    cursor: pointer;
    pointer-events: auto;
}

.year-range-values {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    font-size: 0.85rem;
    line-height: 1.1;
    color: var(--text-muted);
}

.year-range-value {
    font-weight: 600;
    color: var(--text);
}

/* Иконочная кнопка (квадрат, без текста) */
.btn-icon {
    flex: 0 0 auto;
    min-width: 44px;
    padding-left: 0;
    padding-right: 0;
    font-size: 1rem;
    line-height: 1;
}

/* Очередь: на десктопе карточки, на мобиле строки. */

.badge-link {
    text-decoration: none;
}
.badge-link:hover {
    filter: brightness(1.15);
}

/* Таблица */
.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.table th, .table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.table tr:last-child td { border-bottom: none; }

.table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg-element);
}

.table tr:hover td { background: rgba(38, 48, 56, 0.5); }

.muted { color: var(--text-muted); }
.error { color: var(--error); font-size: 0.85rem; margin: 2px 0 0; }
.help { color: var(--text-muted); font-size: 0.8rem; margin: 2px 0 0; }

/* Сообщения (flash-уведомления) */
.messages { margin-bottom: 16px; }

.message {
    padding: 10px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-panel);
    font-size: 0.9rem;
}

.message-info { border-color: var(--want); color: var(--want); }
.message-success { border-color: var(--ok); color: var(--ok); }
.message-error { border-color: var(--error); color: var(--error); }

/* Поиск на TMDB */
.tmdb-results {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tmdb-row {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 10px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s, transform 0.15s;
}

.tmdb-row:hover { border-color: var(--accent); transform: translateY(-2px); }

.tmdb-poster {
    width: 44px;
    height: 66px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.tmdb-poster-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-element);
    color: var(--text-muted);
    font-size: 0.6rem;
    text-align: center;
}

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

.tmdb-title { font-weight: 600; }
.tmdb-overview {
    font-size: 0.8rem;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tmdb-cancel { margin-top: 8px; width: 100%; text-align: center; }

/* Локальные результаты на странице поиска */
.section-title {
    font-size: 1rem;
    margin: 18px 0 10px;
    color: var(--text-muted);
}

.tmdb-row--local .tmdb-title {
    color: var(--text);
    text-decoration: none;
}

.tmdb-row--local .tmdb-title:hover { color: var(--accent); }

.tmdb-row-action { margin-left: auto; flex-shrink: 0; }

.search-provider-hint {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.filters input[type="number"] { flex: 0 1 90px; }

/* Бейджи */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-muted { background: var(--bg-element); color: var(--text-muted); }
.badge-deleted { background: var(--error-soft); color: var(--error); }
.badge-want { background: var(--want-soft); color: var(--want); }
.badge-watching { background: var(--watching-soft); color: var(--watching); }
.badge-watched { background: var(--ok-soft); color: var(--ok); }

/* Приоритет очереди (числовые коды Priority: 3/2/1) */
.badge-priority-3 { background: var(--orange-soft); color: var(--orange); }
.badge-priority-2 { background: var(--watching-soft); color: var(--watching); }
.badge-priority-1 { background: var(--bg-element); color: var(--text-muted); }
.badge-queued { background: var(--want-soft); color: var(--want); }

/* Модалка выбора приоритета при добавлении в очередь */
.priority-choices {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    margin-bottom: 8px;
}

.priority-choices form { flex: 1; }

.priority-choices .btn {
    width: 100%;
    padding: 5px 12px;
}

/* Список получателей в модалке «Рекомендовать» (множественный выбор) */
.recommend-recipients {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.recommend-recipient {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-element);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 10px;
    cursor: pointer;
    font-size: 0.9rem;
}

.recommend-recipient input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

.watched-check {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* Сетка карточек */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.card {
    position: relative;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.15s, box-shadow 0.15s;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.poster {
    position: relative;
    height: 240px;
    background: var(--bg-element);
}

.poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.poster-ph {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 12px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.poster-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--bg-panel);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
}

.poster-badge--bottom {
    top: auto;
    bottom: 8px;
    left: 8px;
    right: 8px;
    text-align: center;
}

.poster-badge.badge-ok { color: var(--ok); }
.poster-badge.badge-deleted { color: var(--error); }
/* Бейдж «КБ N» на постере: плотная тёмная подложка, чтобы рейтинг читался
   и на светлых постерах (полупрозрачный kb-soft на светлом фоне терялся). */
.poster-badge.badge-kb {
    background: var(--bg-panel);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
    color: var(--kb);
}

/* Оценки «КБ» */
.badge-kb { background: var(--kb-soft); color: var(--kb); }

.rating--kb {
    background: var(--kb-soft-strong);
    color: var(--kb);
}

.rating--sm {
    font-size: 0.7rem;
    padding: 1px 8px;
    font-weight: 700;
}

/* Своя оценка на постере (Letterboxd-стиль) */
.poster-mine {
    position: absolute;
    top: 8px;
    right: 8px;
    min-width: 28px;
    height: 28px;
    padding: 0 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--accent);
    color: var(--accent-text);
    font-weight: 800;
    font-size: 0.85rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
}

.poster-mine--sm {
    min-width: 22px;
    height: 22px;
    font-size: 0.7rem;
    border-radius: 6px;
    top: 4px;
    right: 4px;
}

/* Бейдж рекомендации «От …» */
.badge-recommend {
    background: var(--want-soft-strong);
    color: var(--want);
}

/* Рейтинги в карточке/строке */
.card-ratings,
.mrow-ratings {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    align-items: center;
}

.card-ratings { margin-top: 2px; }

/* Ряд «название + ⋮» */
.card-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

/* Длинное название сжимается и переносится внутри, кнопки справа
   остаются фиксированными и не накладываются на текст. */
.card-title-row a,
.card-title-row .card-title-text {
    flex: 1 1 0;
    min-width: 0;
    overflow-wrap: anywhere;
}

.card-title-text { color: var(--text); }

.mrow-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.mrow-title-row .mrow-title { flex: 1; min-width: 0; }

.info-btn {
    flex-shrink: 0;
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 32px;
    padding: 0 6px;
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 1.15rem;
    line-height: 1;
    border-radius: 8px;
    cursor: pointer;
    opacity: 1;
}

.info-btn:hover { background: var(--bg-element); color: var(--text); }

/* «Просто 3 точки»: без акцентного focus-кольца и без глобальных
   стилей кнопки — только нейтральный серый круг при фокусе. */
.info-btn:focus,
.info-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--border);
}

/* «Просмотрено» на постере карточки (десктоп, по ховеру) */
.poster-watched {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 3;
}

.poster-watched-check {
    appearance: none;
    -webkit-appearance: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(20, 24, 28, 0.75);
    border: 2px solid rgba(255, 255, 255, 0.85);
    cursor: pointer;
    display: none;
}

.card:hover .poster-watched-check { display: block; }

.poster-watched-check:hover,
.poster-watched-check:checked { background: var(--ok); }

/* Кнопка «+ К себе» в стеке действий — на всю ширину карточки */
.card-actions form.add-to-library {
    width: 100%;
    min-width: 0;
    display: flex;
}

/* Модалка «подробнее» */
.info-modal { max-width: 640px; }

.modal--wide > #info-modal-body { overflow-y: auto; }

.info-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.info-modal-head h3 { margin: 0; }

.info-embed { display: flex; flex-direction: column; gap: 6px; }
.info-embed p { margin: 0; }

/* Факт-лист метаданных: метка-слева, значение-справа, тонкие разделители */
.meta-list { display: flex; flex-direction: column; margin: 2px 0 0; }

.meta-row {
    display: flex;
    gap: 10px;
    padding: 3px 0;
    border-bottom: 1px solid var(--border);
}

.meta-row:last-child { border-bottom: none; }

.meta-label {
    flex: 0 0 96px;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding-top: 2px;
}

.meta-value {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.9rem;
    color: var(--text);
    overflow-wrap: anywhere;
}

.info-embed .detail-overview {
    color: var(--text-soft);
    font-size: 0.88rem;
    line-height: 1.5;
}

.info-embed-headinfo .muted { font-style: italic; font-size: 0.82rem; }

.info-embed-head {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.info-embed-poster {
    flex-shrink: 0;
    width: 96px;
    height: 144px;
    object-fit: cover;
    border-radius: 8px;
    background: var(--bg-element);
}

.info-embed-poster-ph {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 8px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.info-embed-title { margin: 0 0 4px; font-size: 1.1rem; }
.info-embed-headinfo p { margin: 0; }
.info-embed-actions { margin-top: 4px; }

/* Шкала под ползунком оценки */
.rate-scale {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.rate-scale span { min-width: 1.2rem; text-align: center; }

.card-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
}

.card-meta { color: var(--text-muted); font-size: 0.8rem; margin: 0; }
.card-genres { color: var(--text-muted); font-size: 0.75rem; margin: 0; }
.card-overview { font-size: 0.8rem; margin: 0; color: var(--text); }

.card-action { margin-top: auto; padding-top: 8px; }
.card-action .btn { width: 100%; }

/* Пагинация */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
}

/* Формы */
.form-card {
    max-width: 360px;
    margin: 0 auto;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.form-card--wide { max-width: 640px; }

.form-card--xl { max-width: 900px; }

.dev-notes-form textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-element);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.5;
    resize: vertical;
    box-sizing: border-box;
}

.dev-notes-form .form-actions { text-align: right; }

.form-card h1 { text-align: center; }

.form-field {
    margin-bottom: 14px;
    min-width: 0;
}

.form-field label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    font-size: 0.9rem;
}

.form-field input[type="text"],
.form-field input[type="password"],
.form-field input[type="email"],
.form-field input[type="number"],
.form-field input[type="search"],
.form-field select,
.form-field textarea {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg-element);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
}

.form-field textarea { resize: vertical; min-height: 140px; }

/* Ползунок оценки: на всю ширину поля (раньше держал нативную половину). */
.form-field input[type="range"] {
    display: block;
    width: 100%;
    margin: 6px 0 2px;
    accent-color: var(--accent);
    cursor: pointer;
}

.form-field ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 18px;
}

.form-field ul li {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.form-field ul input[type="radio"] { width: auto; margin: 0; accent-color: var(--accent); }

.form-field ul label { display: inline; margin: 0; font-weight: 400; }

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.form-actions .btn,
.form-actions button { flex: 1; }

.form-card > .muted { text-align: center; font-size: 0.9rem; }

@media (max-width: 1100px) {
    .cards-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 760px) {
    .cards-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }

    /* «Мои фильмы», «Все фильмы», «Очередь», «Архив» и «Отклонённые»:
       на мобиле только строки, карточки скрыты */
    .page-catalog .cards-grid,
    .page-all .cards-grid,
    .page-watchlist .cards-grid,
    .page-archive .cards-grid,
    .page-rejected .cards-grid { display: none; }

/* «Рекомендации для вас» на мобиле — горизонтальная карусель:
       одновременно видны ~2 карточки, остальные листаются свайпом. */
    .page-catalog .rec-block .cards-grid {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        gap: 12px;
        padding: 0 4px;
        margin-bottom: 8px;
    }

    .page-catalog .rec-block .card {
        flex: 0 0 46%;
        scroll-snap-align: start;
    }
}

@media (max-width: 640px) {
    .header-inner { justify-content: center; }
    .page-head {
        flex-direction: column;
        justify-content: flex-start;
        align-items: flex-start;
        gap: 10px;
    }

    /* Списки фильмов: заголовок и кнопки шапки — в одну строку,
       кнопки компактные (единый вид для Мои/Архив/Отклонённые/Все/Очередь) */
    .page-catalog .page-head,
    .page-archive .page-head,
    .page-rejected .page-head,
    .page-all .page-head,
    .page-watchlist .page-head {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        flex-wrap: nowrap;
    }
    .page-catalog .page-actions,
    .page-archive .page-actions,
    .page-rejected .page-actions,
    .page-all .page-actions,
    .page-watchlist .page-actions { flex: 0 0 auto; }
    .page-catalog .page-actions .btn,
    .page-archive .page-actions .btn,
    .page-rejected .page-actions .btn,
    .page-all .page-actions .btn,
    .page-watchlist .page-actions .btn {
        padding: 3px 10px;
        font-size: 0.8rem;
        white-space: nowrap;
    }

    /* Кнопки шапки на мобиле: текст ровно по центру */
    .page-head .btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        line-height: 1;
    }
}

/* Вкладки (архив: просмотренные / отклонённые) */
.tabs {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 14px;
}

.tab {
    padding: 8px 18px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    background: var(--bg-panel);
    transition: background 0.15s, color 0.15s;
}

.tab + .tab { border-left: 1px solid var(--border); }
.tab:hover { color: var(--text); }

.tab.active {
    background: var(--accent);
    color: var(--accent-text);
}

/* Кнопки-действия */
.btn-danger {
    background: var(--error);
    color: #fff;
    border: none;
}

.btn-danger:hover { opacity: 0.88; background: var(--error); color: #fff; }

.btn-danger-text { color: var(--error) !important; }

.actions-cell {
    white-space: nowrap;
    display: flex;
    gap: 10px;
    align-items: center;
}

.card-actions {
    margin-top: auto;
    padding-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.card-actions .btn,
.card-actions button { width: 100%; }

/* Модальное окно */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    padding: 16px;
    overflow-y: auto;
}

.modal-overlay[hidden] { display: none; }

.modal {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    max-width: 420px;
    width: 100%;
    margin: auto;
    min-width: 0;
}

.modal h3 { margin: 0 0 8px; }
.modal p { margin: 0 0 16px; color: var(--text-muted); }

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.modal-actions .btn,
.modal-actions button { flex: 1 1 auto; }

.modal--wide { max-width: 560px; }

/* Высокая модалка добавления: шапка фиксирована, скроллится содержимое. */
.modal--wide {
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
}

.modal--wide > #add-step-search,
.modal--wide > #add-step-confirm {
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    min-width: 0;
}

.modal--wide #add-search-input {
    width: 100%;
    max-width: 100%;
}

/* Зелёная focus-рамка не должна вылезать за границы блока поиска. */
.modal--wide #add-search-input:focus-visible {
    outline-offset: -4px;
}

/* Модалка «подробнее» (превью): компактная шапка и тело. */
.modal--wide.info-modal { padding: 14px 16px 16px; }

.info-modal-head {
    padding-bottom: 8px;
    margin-bottom: 8px;
}

.info-modal-head h3 { margin: 0; font-size: 1rem; }

/* Общие .modal h3/.modal p дают лишние 8–16px отступов контенту превью
   (объявлены позже embed-правил) — перебиваем с большей специфичностью. */
.modal .info-embed-title { margin: 0 0 2px; }
.modal .info-embed p { margin: 0; }
.modal #info-modal-body { min-height: 0; }

/* Зазор под полосой прокрутки, чтобы текст не касался скроллбара. */
#info-modal-body {
    overflow-x: hidden;
    padding-right: 6px;
    scrollbar-gutter: stable;
}

/* Пока открыто превью: фон не прокручивается и не «выплёскивается» на страницу.
   Вертикальная прокрутка — нативная (pan-y), горизонталь — жест закрытия. */
#info-modal,
.modal-overlay {
    overscroll-behavior: contain;
}

.modal.info-modal {
    touch-action: pan-y;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 14px;
}

.modal-head h3 { margin: 0; }

/* Детальная страница тайтла */
.card-link { display: block; }

.detail {
    position: relative;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.detail-backdrop {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.detail-backdrop img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: blur(10px) brightness(0.35);
    transform: scale(1.1);
}

.detail-main {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 24px;
    padding: 24px;
    flex-wrap: wrap;
}

.detail-poster {
    width: 220px;
    flex-shrink: 0;
    aspect-ratio: 2 / 3;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-element);
    box-shadow: var(--shadow);
}

.detail-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.detail-info {
    flex: 1 1 320px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.detail-info h1 { margin: 0; }

.detail-meta { color: var(--text-muted); margin: 0; }
.detail-overview { margin: 10px 0 0; }
.detail-info p { margin: 0; }

.detail-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.detail-ratings {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.rating {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--gold-soft);
    color: var(--gold);
    font-size: 0.85rem;
    font-weight: 700;
}

.detail-actions {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 0 24px 24px;
}

.detail-actions .btn,
.detail-actions button { flex: 0 1 auto; }

.detail-actions .inline { display: contents; }

.detail-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
}

@media (max-width: 640px) {
    .detail-main { padding: 16px; gap: 16px; }
    .detail-poster { width: 150px; }
    .detail-actions { padding: 0 16px 16px; }
}

/* Бейдж-счётчик в навигации */
.nav-badge {
    display: inline-block;
    margin-left: 4px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-text);
    font-size: 0.7rem;
    font-weight: 700;
    vertical-align: middle;
}

/* Постеры в таблице очереди */
.poster-cell { width: 44px; }

.table-poster {
    width: 44px;
    height: 66px;
    object-fit: cover;
    border-radius: 4px;
    display: block;
}

.table-poster-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-element);
    color: var(--text-muted);
    font-size: 1rem;
}

/* Селект статуса очереди */
.status-select {
    padding: 6px 10px;
    background: var(--bg-element);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
}

.status-select:hover { border-color: var(--accent); }

/* Аватары */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-element);
    color: var(--text-muted);
    font-weight: 700;
    flex-shrink: 0;
}

.avatar-ph {
    color: var(--text);
    background: var(--accent);
    color: var(--accent-text);
}

/* Цветные буквы-аватары (по нику, см. users.templatetags.avatar_color) */
.avatar-ph--0 { background: var(--accent); color: var(--accent-text); }
.avatar-ph--1 { background: var(--want); color: var(--accent-text); }
.avatar-ph--2 { background: var(--watching); color: var(--accent-text); }
.avatar-ph--3 { background: var(--kb); color: #191034; }
.avatar-ph--4 { background: var(--cyan); color: var(--accent-text); }
.avatar-ph--5 { background: var(--orange); color: var(--accent-text); }

.avatar-sm { width: 28px; height: 28px; font-size: 0.8rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.6rem; }
.avatar-nav { width: 20px; height: 20px; font-size: 0.7rem; vertical-align: middle; }

.nav .avatar { margin-right: 2px; }

/* Личный кабинет */
.profile-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-items: start;
}

.profile-card {
    padding: 14px 16px;
    margin: 0;
    max-width: none;
    box-shadow: none;
}

.profile-card h2 { font-size: 1.15rem; }
.profile-card h3 { margin: 0 0 8px; }

/* Сворачиваемый блок «Пригласительные коды» */
.profile-card summary {
    cursor: pointer;
    font-weight: 700;
    font-size: 1.05rem;
    margin: 0;
    padding: 2px 0 6px;
    user-select: none;
    color: var(--text);
}

.profile-card summary:hover { color: var(--accent); }

.profile-card summary::-webkit-details-marker { display: none; }

.profile-card summary::before {
    content: "▸";
    display: inline-block;
    width: 1.1em;
    transition: transform 0.15s ease;
    color: var(--text-muted);
}

.profile-card[open] summary::before { transform: rotate(90deg); }

.profile-card[open] summary { padding-bottom: 10px; }

/* Компактные таблицы внутри кабинета */
.table-compact th,
.table-compact td {
    padding: 6px 8px;
    font-size: 0.85rem;
}

.profile-card-actions { margin-top: 10px; }

/* Пригласительные коды: длинные коды не вылазят за карточку */
#invite-codes { min-width: 0; overflow-x: auto; }
#invite-codes .code { white-space: normal; word-break: break-all; }

/* API-токены в кабинете: длинный токен переносится внутри ячейки */
#api-tokens { min-width: 0; overflow-x: auto; }
#api-tokens .code { white-space: normal; word-break: break-all; }

/* Внутренние прокручиваемые области — кабинет помещается в один экран */
.scroll-box {
    max-height: 240px;
    overflow-y: auto;
    padding-right: 4px;
}

.profile-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.profile-head-info { flex: 1; min-width: 0; }

.profile-edit-toggle { flex-shrink: 0; }

.invite-row-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.profile-versions-card .btn { width: 100%; }

.profile-nick { margin: 0; }

.profile-form-row {
    display: flex;
    gap: 10px;
}

.profile-form-row .form-field { flex: 1; }

.profile-form .form-field { margin-bottom: 8px; }
.profile-form .form-field textarea { min-height: 60px; }
.profile-form input[type="file"] {
    width: 100%;
    padding: 6px 8px;
    background: var(--bg-element);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
}

.form-actions { margin-top: 10px; }

/* Контроль версий */
.changelog-form {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin-bottom: 10px;
}

.changelog-form textarea {
    flex: 1;
    padding: 8px 10px;
    background: var(--bg-element);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    min-height: 44px;
}

.changelog-form button { flex-shrink: 0; }

/* Расход API Кинопоиска (кабинет суперюзера). */
.api-usage-line { margin: 0 0 8px; font-size: 0.95rem; }

.usage-bar {
    height: 10px;
    border-radius: 6px;
    background: var(--surface-2);
    overflow: hidden;
}

.usage-bar-fill {
    height: 100%;
    border-radius: 6px;
    background: var(--accent);
    transition: width 0.3s ease;
}

.usage-bar-fill.usage-bar--full { background: var(--danger); }

.changelog-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.changelog-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.changelog-list li:last-child { border-bottom: none; }

.changelog-ver {
    font-family: monospace;
    font-weight: 700;
    color: var(--accent);
    margin-right: 8px;
}

.changelog-date { font-size: 0.78rem; }

.changelog-notes { margin-top: 2px; font-size: 0.88rem; }

@media (max-width: 640px) {
    .profile-form-row { flex-direction: column; gap: 0; }
}

.code {
    font-family: monospace;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-right: 8px;
}

/* Участники */
.participant {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text);
}

.participant:hover .participant-name { color: var(--accent); }

.participant-name { font-weight: 600; }

/* Дерево приглашений */
.tree, .tree ul {
    list-style: none;
    margin: 0;
    padding-left: 24px;
    position: relative;
}

.tree > li { padding-left: 0; }

.tree li {
    position: relative;
    padding: 4px 0;
}

.tree li::before {
    content: "";
    position: absolute;
    left: -14px;
    top: 0;
    bottom: 0;
    border-left: 1px solid var(--border);
}

.tree li:last-child::before { bottom: auto; height: 14px; }

.tree li::after {
    content: "";
    position: absolute;
    left: -14px;
    top: 14px;
    width: 14px;
    border-top: 1px solid var(--border);
}

.tree > li::before,
.tree > li::after { display: none; }

.tree-node {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.tree-name { font-weight: 600; }

/* Уведомления и комментарии */
.bell { font-size: 1rem; text-decoration: none; }

.comments {
    margin-top: 20px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.comments h2 { margin: 0 0 2px; }

/* Пустая строка «Комментариев пока нет.» — плотно под заголовком */
.comments > .comments-empty { margin: 0 0 2px; }

.comment {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.comment:last-child { border-bottom: none; }

.comment-body { flex: 1; min-width: 0; }

.comment-head {
    display: flex;
    gap: 8px;
    align-items: baseline;
    margin-bottom: 4px;
}

.comment-author { font-weight: 600; }

.comment-text { margin: 0 0 6px; white-space: pre-wrap; }

.comment-form { margin-top: 8px; }
.comment-form .form-field { margin-bottom: 8px; }
.comment-form .form-field textarea { min-height: 60px; }

.notifications {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notification {
    display: flex;
    gap: 12px;
    padding: 14px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.notification-unread { border-left: 3px solid var(--accent); }

.notification-body { flex: 1; min-width: 0; }

.notification-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

/* ===== Мобильная адаптация (этап 9) ===== */

.no-scroll { overflow: hidden; }

/* Мобильные элементы скрыты на десктопе */
.header-mobile,
.burger,
.drawer-overlay,
.drawer,
.tabbar,
.fab,
.rows-mobile { display: none; }

/* Страница человека — только карточки (без мобильного списка) */
.page-person .rows-mobile { display: none; }

@keyframes drawer-in {
    from { transform: translateX(100%); }
}

@keyframes fade-in {
    from { opacity: 0; }
}

@media (max-width: 760px) {
    /* --- Шапка (зеркально): ☰ · аватар · 🔔 слева, «Кинобаза» справа --- */
    .header-inner {
        flex-wrap: nowrap;
        justify-content: space-between;
        padding: 8px 12px;
        gap: 12px;
    }

    .nav { display: none; }

    .header-mobile {
        display: flex;
        align-items: center;
        gap: 4px;
        margin-left: 0;
        order: 0;
    }

    .header-inner .brand { order: 3; }

    /* Порядок в левой группе: меню → профиль → чат → колокольчик */
    .burger { order: 1; }
    .header-profile { order: 2; }
    .header-mobile .chat-mobile { order: 3; }
    .header-mobile .bell { order: 4; }

    .header-mobile > a {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 42px;
        min-height: 42px;
        text-decoration: none;
    }

    .header-mobile .bell { font-size: 1.3rem; }

    .header-mobile .avatar-nav {
        width: 32px;
        height: 32px;
        font-size: 0.95rem;
    }

    .burger {
        display: inline-flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        width: 42px;
        height: 42px;
        background: none;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 0;
        cursor: pointer;
        opacity: 1;
    }

    .burger span {
        width: 20px;
        height: 2px;
        border-radius: 2px;
        background: var(--text);
    }

    /* --- Drawer (выезжающая панель справа) --- */
    .drawer-overlay {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 90;
        background: rgba(0, 0, 0, 0.55);
        animation: fade-in 0.2s ease-out;
    }

    /* display:flex/block выше перебивает скрытие по умолчанию */
    .drawer[hidden],
    .drawer-overlay[hidden] { display: none; }

    .drawer {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        z-index: 95;
        width: min(320px, 85vw);
        background: var(--bg-panel);
        border-left: 1px solid var(--border);
        box-shadow: var(--shadow);
        animation: drawer-in 0.22s ease-out;
    }

    .drawer-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        border-bottom: 1px solid var(--border);
    }

.drawer-title {
        font-size: 1.15rem;
        font-weight: 700;
        color: var(--accent);
        text-decoration: none;
    }

    .drawer-close {
        background: none;
        border: none;
        color: var(--text-muted);
        font-size: 1.25rem;
        line-height: 1;
        padding: 10px;
        cursor: pointer;
    }

    .drawer-nav {
        display: flex;
        flex-direction: column;
        gap: 2px;
        padding: 8px;
        overflow-y: auto;
        flex: 1;
    }

    .drawer-nav a,
    .drawer-nav form {
        display: flex;
        align-items: center;
        gap: 6px;
        min-height: 48px;
        padding: 10px 14px;
        margin: 0;
        border-radius: 8px;
        color: var(--text);
        text-decoration: none;
        font-weight: 500;
    }

    .drawer-nav form button.link-btn {
        min-height: 44px;
        padding: 10px 0;
        text-align: left;
        font-size: 0.95rem;
    }

    .drawer-nav a.active {
        background: var(--accent-soft);
        color: var(--accent);
    }

    /* --- Нижнее таб-меню + FAB --- */
    .tabbar {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 80;
        background: rgba(29, 35, 40, 0.97);
        backdrop-filter: blur(8px);
        border-top: 1px solid var(--border);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .tabbar-item {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 56px;
        padding: 6px 2px;
        background: none;
        border: none;
        color: var(--text-muted);
        font-family: inherit;
        font-size: 0.75rem;
        font-weight: 600;
        text-decoration: none;
        cursor: pointer;
        white-space: nowrap;
    }

    .tabbar-item.active { color: var(--accent); }

    .tabbar-item.tabbar-search {
        flex: 0 0 auto;
        padding: 0 10px;
        font-size: 1.2rem;
        line-height: 1;
    }

    .tabbar-item.tabbar-more {
        flex: 0 0 auto;
        padding: 6px 14px 6px 2px;
    }

    main.container {
        padding-bottom: calc(84px + env(safe-area-inset-bottom));
    }

    .fab {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        right: 16px;
        bottom: calc(72px + env(safe-area-inset-bottom));
        z-index: 85;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: var(--accent);
        color: var(--accent-text);
        font-size: 30px;
        font-weight: 700;
        line-height: 1;
        text-decoration: none;
        box-shadow: var(--shadow);
    }

    .page-add .fab,
    .page-search .fab { display: none; }

    /* Мобильная версия: в основной области остаётся только поле поиска;
       кнопку «Фильтры» и панель фильтров прячем — их заменяет лупа в нижнем меню */
    .filters-toggle { display: none; }

    .filter-extra { display: none !important; }

    .filter-search > .btn { display: none; }

    /* ИИ-поиск ✨ — наоборот, оставляем видимым у строки поиска */
    .filter-search > .btn-ai { display: inline-flex; }

    /* Шторка поиска/фильтров (нижняя панель) */
    .mobile-filter-sheet {
        display: flex;
        flex-direction: column;
        position: fixed;
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
        height: 100vh;
        z-index: 95;
        background: var(--bg-panel);
        border-top: 1px solid var(--border);
        padding: 16px;
        padding-top: calc(16px + env(safe-area-inset-top));
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
        box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.4);
        overflow-y: auto;
        animation: drawer-in 0.22s ease-out;
    }

    .mobile-filter-sheet[hidden] { display: none; }

    .mobile-filter-sheet-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        margin-bottom: 12px;
    }

    .mobile-filter-sheet-title {
        font-size: 1.1rem;
        font-weight: 700;
    }

    .mobile-filter-sheet .filter-row {
        flex-direction: column;
        align-items: stretch;
    }

    .mobile-filter-sheet .filter-row select,
    .mobile-filter-sheet .form-field input[type="search"] {
        width: 100%;
        min-height: 44px;
        font-size: 16px;
        padding: 10px 12px;
        background: var(--bg-element);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        color: var(--text);
        font-family: inherit;
    }

    .mobile-filter-sheet .popover-toggle { width: 100%; }

    .mobile-filter-sheet .type-toggle {
        width: 100%;
        align-self: stretch;
    }

    .mobile-filter-sheet .type-seg { flex: 1; }

    .mobile-filter-sheet .year-filter { width: 100%; }

    .mobile-filter-sheet .modal-actions { margin-top: 12px; }

    /* --- Таблицы → строки-карточки --- */
    .table { display: none; }

    .rows-mobile {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .mrow {
        display: flex;
        gap: 12px;
        background: var(--bg-panel);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 10px;
    }

    .mrow-poster {
        flex-shrink: 0;
        width: 56px;
        height: 84px;
        border-radius: 6px;
        overflow: hidden;
        background: var(--bg-element);
        position: relative;
    }

    .mrow-poster img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }

    .mrow-poster .table-poster {
        width: 100%;
        height: 100%;
        border-radius: 6px;
    }

    .mrow-poster .poster-badge--bottom {
        left: 4px;
        right: 4px;
        bottom: 4px;
        font-size: 0.6rem;
        padding: 1px 6px;
    }

    /* Аватар участника в мобильной строке (слот мини-постера) */
    .mrow-avatar {
        flex-shrink: 0;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        overflow: hidden;
        background: var(--bg-element);
        display: flex;
        align-items: center;
        justify-content: center;
        align-self: flex-start;
    }

    .mrow-avatar img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }

    .mrow-avatar .avatar-ph {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 600;
        color: var(--text-muted);
    }

    .mrow-body {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    .mrow-title {
        font-weight: 600;
        color: var(--text);
        text-decoration: none;
    }

    .mrow-title small {
        display: block;
        font-weight: 400;
        font-size: 0.78rem;
    }

    .mrow-meta { font-size: 0.78rem; margin: 0; }

    .mrow-badges {
        display: flex;
        gap: 6px;
        flex-wrap: wrap;
        margin-top: 2px;
    }

    .mrow-actions {
        display: flex;
        align-items: center;
        gap: 10px;
        flex-wrap: wrap;
        margin-top: auto;
        padding-top: 8px;
    }

    .mrow-actions .btn { flex: 1 1 auto; }

    /* --- Тач-удобство --- */
    .btn,
    button:not(.link-btn):not(.tabbar-item):not(.drawer-close):not(.burger) {
        min-height: 44px;
    }

    .watched-check {
        width: 24px;
        height: 24px;
    }

    /* Кнопки действий — одинакового размера (на всю ширину контейнера) */
    .hide-mobile { display: none !important; }

    .card-actions {
        flex-direction: column;
        gap: 6px;
    }

    .card-actions .btn,
    .card-actions button {
        width: 100%;
        min-height: 44px;
    }

    .mrow-actions > .btn,
    .mrow-actions > button,
    .mrow-actions form.grow {
        flex: 1 1 0;
        min-width: 0;
        min-height: 44px;
        padding-left: 10px;
        padding-right: 10px;
        text-align: center;
        overflow-wrap: break-word;
    }

    .mrow-actions > .btn,
    .mrow-actions > button:not(.btn-icon) {
        white-space: nowrap;
        font-size: 0.85rem;
        padding-left: 6px;
        padding-right: 6px;
    }

    .mrow-actions form.grow .btn,
    .mrow-actions form.grow button {
        width: 100%;
        padding-left: 8px;
        padding-right: 8px;
    }

    .modal-actions .btn,
    .modal-actions button {
        flex: 1 1 0;
        min-height: 44px;
    }

    .pagination .btn { padding: 12px 18px; }

    /* Инпуты 16px — запрет iOS-zoom */
    .filters input[type="search"],
    .filters input[type="number"],
    .filters select,
    .form-field input[type="text"],
    .form-field input[type="password"],
    .form-field input[type="email"],
    .form-field input[type="number"],
    .form-field input[type="search"],
    .form-field select,
    .form-field textarea,
    .status-select {
        font-size: 16px;
    }

    /* Кабинет в одну колонку */
    .profile-grid { grid-template-columns: 1fr; }

    .changelog-form {
        flex-direction: column;
        align-items: stretch;
    }

    /* Очередь на мобиле: компактные иконки + больше места названию */
    .queue-list .mrow-title {
        font-size: 0.92rem;
        overflow-wrap: break-word;
    }

    .queue-list .mrow-actions > button.btn-icon,
    .queue-list .mrow-actions > .btn-icon {
        flex: 0 0 auto;
        width: 44px;
        overflow: visible;
        text-overflow: clip;
    }
}

/* --- Чат --- */
.nav-badge[hidden] { display: none; }

.chat-notice {
    margin-bottom: 14px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    background: var(--bg-panel);
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Список переписок */
.chat-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    transition: background 0.15s ease;
}

.chat-row:hover { background: var(--bg-element); }

.chat-avatar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
}

.avatar-group {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-element);
    font-size: 0.95rem;
}

.chat-row-body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-row-title {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-row-preview {
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-row-meta {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.chat-row-time { font-size: 0.75rem; }

.chat-row-badge { margin-left: 0; }

/* Страница переписки */
.chat-page {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 130px);
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.chat-header-info {
    flex: 1 1 auto;
    min-width: 0;
}

.chat-header-title {
    margin: 0;
    font-size: 1.1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-header-info .muted {
    margin: 2px 0 0;
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-log {
    flex: 1 1 auto;
    padding-bottom: 12px;
}

.chat-older-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
}

/* Пузыри сообщений */
.msg {
    display: flex;
    margin-bottom: 10px;
}

.msg--mine { justify-content: flex-end; }
.msg--other { justify-content: flex-start; }

.msg-bubble {
    max-width: min(75%, 520px);
    padding: 8px 12px;
    border-radius: 14px;
    background: var(--bg-element);
    color: var(--text);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.msg--mine .msg-bubble {
    background: var(--accent);
    color: var(--accent-text);
}

.msg-sender {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 2px;
}

.msg--mine .msg-sender { color: var(--accent-text); }

.msg-text { white-space: pre-wrap; }

.msg-img {
    display: block;
    margin: 6px 0 2px;
    border-radius: 10px;
    overflow: hidden;
}

.msg-img img {
    display: block;
    max-width: 260px;
    max-height: 300px;
    border-radius: 10px;
}

.msg-file {
    display: inline-block;
    margin: 4px 0 2px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-panel);
    text-decoration: none;
    color: var(--text);
    word-break: break-all;
}

.msg-file:hover { border-color: var(--accent); }

.msg--mine .msg-file {
    background: rgba(0, 0, 0, 0.15);
    border-color: transparent;
    color: var(--accent-text);
}

.msg-time {
    margin-top: 4px;
    font-size: 0.7rem;
    opacity: 0.65;
}

/* Композер */
.composer {
    position: sticky;
    bottom: 0;
    z-index: 20;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 0;
    background: var(--bg);
}

.composer textarea {
    flex: 1 1 auto;
    min-height: 44px;
    max-height: 140px;
    resize: none;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-panel);
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.35;
}

.composer textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.chat-attach {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.chat-file-input { display: none; }

.chat-send {
    flex: 0 0 auto;
    height: 44px;
}

.chat-file-hint {
    margin-bottom: 6px;
    font-size: 0.8rem;
}

/* Мобильная адаптация чата */
@media (max-width: 760px) {
    /* На странице переписки нижнее меню и FAB не нужны — композер и так внизу */
    .page-conversation .tabbar,
    .page-conversation .fab { display: none; }

    .chat-page { min-height: calc(100vh - 120px); }

    /* Композер зафиксирован по нижней рамке экрана: при свайпе не «плавает»
       вместе с лентой, поднимается только при открытии клавиатуры. */
    .composer {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 20;
        display: flex;
        align-items: flex-end;
        gap: 6px;
        padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
        background: var(--bg);
        border-top: 1px solid var(--border);
    }

    /* Место под фиксированный композер, чтобы последнее сообщение не пряталось. */
    .chat-log {
        padding-bottom: calc(72px + env(safe-area-inset-bottom));
    }

    .msg-bubble { max-width: 85%; }
}

/* --- Рекомендации --- */
.rec-block { margin-bottom: 22px; }

.rec-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.rec-head h2,
.similar-head h2 {
    margin: 0;
    font-size: 1.1rem;
}

.rec-sub { font-size: 0.85rem; }

.rec-reason {
    font-size: 0.82rem;
    line-height: 1.35;
}

/* Блок «Похожие» на детальной странице */
.similar-block {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.similar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.similar-block .cards-grid {
    margin-bottom: 0;
}

.similar-head > div { min-width: 0; }
.similar-head .similar-sub {
    display: block;
    margin-top: 2px;
    font-size: 0.85rem;
    line-height: 1.3;
}

#similar-message { margin-bottom: 10px; }

.similar-block .card-title-row > span {
    min-width: 0;
    overflow-wrap: anywhere;
}

/* Кнопка «+» на карточке похожего: добавить в свою базу без перехода. */
.similar-add-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 32px;
    padding: 0 8px;
    border: none;
    background: var(--accent);
    color: var(--accent-text);
    font-weight: 800;
    font-size: 1.1rem;
    line-height: 1;
    border-radius: 8px;
    cursor: pointer;
}

.similar-add-btn:hover { background: var(--accent-hover); }

.similar-add-btn:focus-visible { outline-color: var(--accent); }

/* «⊕» — добавить в общую базу (суперпользователь): бирюзовый discovery-акцент. */
.similar-add-btn--global {
    background: var(--cyan);
    color: var(--accent-text);
}

.similar-add-btn--global:hover { background: var(--cyan-soft); color: var(--cyan); }

.similar-more-wrap {
    text-align: center;
    margin-top: 16px;
}

@media (max-width: 600px) {
    .similar-head {
        align-items: flex-start;
        gap: 8px;
    }
}

/* --- Страница «Статистика» --- */
.stats-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

.stats-tabs { display: inline-flex; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    min-width: 0;
}

.stat-num {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--accent);
    overflow-wrap: anywhere;
}

.stat-num--plain { color: var(--text); }

.stat-label {
    margin-top: 3px;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.3;
}

.stats-section {
    margin-bottom: 16px;
}

.stats-section > h3 {
    margin: 0 0 8px;
    font-size: 1rem;
}

.stats-section .scroll-box { max-height: 240px; }

/* Столбчатая диаграмма статистики: колонки от базовой линии, число сверху. */
.stats-chart {
    display: flex;
    align-items: stretch;
    gap: 6px;
    height: 150px;
}

.stat-col {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.stat-col-val {
    display: block;
    height: 16px;
    line-height: 1.1;
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-soft);
    overflow: hidden;
}

.stat-col-track {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: flex-end;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1px;
}

.stat-col-bar {
    width: 100%;
    border-radius: 4px 4px 0 0;
    min-height: 2px;
}

.bar--accent { background: var(--accent); opacity: 0.85; }
.bar--gold { background: var(--gold); opacity: 0.9; }
.bar--cyan { background: var(--cyan); opacity: 0.85; }

.stat-col-label {
    display: block;
    margin-top: 5px;
    text-align: center;
    font-size: 0.66rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stats-table td, .stats-table th {
    padding: 7px 10px;
    font-size: 0.9rem;
}

.stats-table th { white-space: nowrap; }

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-element);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.82rem;
    color: var(--text);
}

.chip b { color: var(--accent); }

.stats-kv {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 14px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 0.9rem;
}

.stats-kv dt { color: var(--text-muted); }
.stats-kv dd { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 760px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .stat-card { padding: 9px 10px; }
    .stat-num { font-size: 1.2rem; }
    .stat-label { font-size: 0.7rem; }

    .stats-chart { height: 105px; }
    .stat-col-val { font-size: 0.6rem; height: 14px; }
    .stat-col-label { font-size: 0.55rem; white-space: nowrap; }
}

/* Сегмент-ссылки в шапке статистики (типа переключателя фильтров) */
.stats-tabs .type-seg { text-decoration: none; }
.stats-tabs { align-self: center; }


/* --- ИИ-поиск (волшебная палочка ✨) --- */
.btn-ai { font-size: 1.1rem; padding: 0.45rem 0.7rem; line-height: 1; flex: 0 0 auto; }
.ai-scopes { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; align-items: center; }
.ai-scope { display: inline-flex; align-items: center; gap: 0.35rem; }
.ai-note { color: var(--muted); margin-bottom: 0.75rem; }
.ai-section + .ai-section { margin-top: 1rem; }
/* Выдача ИИ-поиска — карточки в стиле карточек фильмов (сетка внутри модалки). */
.ai-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
@media (max-width: 480px) {
    .ai-cards { grid-template-columns: 1fr; }
}
.ai-cards .poster { height: 200px; }
.ai-reason { margin: 0.35rem 0 0; font-size: 0.8rem; color: var(--muted); }
.ai-tags { margin: 0.25rem 0 0; }
.ai-tags .badge { margin-right: 0.25rem; }
.ai-clarify { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
#ai-results { margin-top: 0.75rem; }

.ai-added { display: inline-flex; align-items: center; gap: 0.5rem; }

/* Остатки ИИ-поиска в модалке ✨ (строка + бар). */
.ai-usage {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: -0.25rem 0 0.75rem;
    font-size: 0.85rem;
}
.ai-usage-text { color: var(--text-muted); flex: 0 0 auto; }
.ai-usage-text.ai-usage--full { color: var(--danger); font-weight: 600; }
.ai-usage .usage-bar { flex: 1; min-width: 60px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.ai-more-actions { text-align: center; margin-top: 0.6rem; }

/* Кабинет: страница «ИИ-лимиты». */
.badge-danger { background: var(--error-soft); color: var(--error); }
#ai-limits .ai-limit-form {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.ai-limit-input { width: 76px; }
@media (max-width: 760px) {
    .ai-limit-input { width: 100px; }
    .ai-limit-form button { flex: 0 0 auto; }
}

/* --- Раздел «Персоналии» --- */

/* Дропдаун «Меню» в десктоп-шапке (Друзья/Персоналии). */
.nav-drop {
    position: relative;
}

.nav-drop-trigger {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: inherit;
    font-weight: 500;
    padding: 4px 2px;
    cursor: pointer;
}

.nav-drop-trigger:hover { color: var(--text); }
.nav-drop-trigger.active { color: var(--accent); }

.nav-drop-arrow { font-size: 0.7rem; }

.nav-drop-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 180px;
    margin-top: 4px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 30;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-drop-menu a {
    display: block;
    padding: 8px 12px;
    color: var(--text);
    text-decoration: none;
    border-radius: 6px;
    border-bottom: none;
    white-space: nowrap;
    overflow-wrap: anywhere;
}

.nav-drop-menu a:hover { background: var(--bg-element); color: var(--text); }
.nav-drop-menu a.active { color: var(--accent); }

/* Сетка карточек персон (поиск + выбор из кандидатов). */
.people-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
    margin-top: 4px;
}

.person-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    transition: transform 0.15s, box-shadow 0.15s;
}

.person-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.person-photo {
    width: 100%;
    aspect-ratio: 3 / 4;
    background: var(--bg-element);
}

.person-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.person-photo-ph {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 2.5rem;
    font-weight: 700;
}

.person-card-body { padding: 10px 10px 12px; }

.person-card-body .muted { margin: 0; }

.person-card-name {
    margin: 0 0 4px;
    font-size: 0.95rem;
    line-height: 1.3;
    color: var(--text);
    overflow-wrap: anywhere;
}

.person-card-body .card-meta { margin-top: 2px; }

/* Шапка карточки персоны: фото + имена + метаданные. */
.person-head {
    display: flex;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.person-head-photo {
    width: 180px;
    aspect-ratio: 3 / 4;
    background: var(--bg-element);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.person-head-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.person-head-photo-ph {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    color: var(--text-muted);
    height: 100%;
}

.person-head-info { flex: 1 1 auto; min-width: 0; }
.person-head-info h1 { margin: 0 0 6px; }

.person-meta-item { color: var(--text-soft); }

/* Био (факты Кинопоиска). */
.person-facts { margin-bottom: 6px; }

.person-fact {
    margin: 0 0 8px;
    color: var(--text-soft);
    font-size: 0.9rem;
}

.person-more-actions { text-align: center; margin-top: 16px; }

/* Карточки фильмографии: длинное название не ломает ряд с кнопками. */
.person-movie-card .card-title-row > span {
    flex: 1 1 0;
    min-width: 0;
    overflow-wrap: anywhere;
}

@media (max-width: 760px) {
    .people-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }

    .person-head { gap: 14px; }
    .person-head-photo { width: 120px; }
    .person-head-photo-ph { font-size: 2.5rem; }
    .person-photo-ph { font-size: 1.6rem; }
}

/* Лендинг (публичная визитка для анонимных посетителей). */
.landing-hero {
    text-align: center;
    padding: 64px 16px 32px;
}

.landing-title {
    margin: 0 0 12px;
    font-size: 2.4rem;
    color: var(--text);
    letter-spacing: 0.01em;
}

.landing-subtitle {
    max-width: 620px;
    margin: 0 auto 28px;
    color: var(--text-muted);
    font-size: 1.1rem;
}

.landing-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-lg { padding: 12px 26px; font-size: 1rem; }

.landing-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    padding: 24px 0 40px;
}

.landing-feature {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.landing-feature h2 {
    margin: 0 0 8px;
    font-size: 1.05rem;
    color: var(--accent);
}

.landing-feature p {
    margin: 0;
    color: var(--text-soft);
    font-size: 0.92rem;
}

.landing-note {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding-bottom: 48px;
}

@media (max-width: 760px) {
    .landing-hero { padding-top: 40px; }
    .landing-title { font-size: 1.8rem; }
    .landing-features { grid-template-columns: 1fr; gap: 12px; }
}
