/* ═══════════════════════════════════════════════════════════════════
   УМНЫЙ ПОИСК: люди, категории, карточки фото
   Все классы с префиксом ai- чтобы не пересекаться со style.css
   ═══════════════════════════════════════════════════════════════════ */

#gallery-collections.ai-host {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: auto;
    scrollbar-gutter: stable;
}

#section-gallery.ai-collections > footer.files-statusbar {
    display: none;
}

#section-gallery.ai-collections #gallery-main-actions,
#section-gallery.ai-collections #gallery-trash-actions {
    display: none;
}

.ai-screen {
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 20px 28px 64px;
    display: flex;
    flex-direction: column;
    gap: 34px;
}

/* ── Шапка ─────────────────────────────────────────────────────── */

.ai-hero {
    position: relative;
    overflow: hidden;
    border-radius: 24px;
    padding: 30px 32px 26px;
    background:
        radial-gradient(1200px 300px at 0% 0%, var(--accent-soft-2), transparent 70%),
        radial-gradient(900px 280px at 100% 10%, rgba(56, 189, 248, 0.12), transparent 70%),
        var(--bg-2);
    border: 1px solid var(--border);
    box-shadow: 0 18px 50px var(--shadow);
}

.ai-hero::after {
    content: "";
    position: absolute;
    inset: -40% 40% auto auto;
    width: 420px;
    height: 420px;
    background: radial-gradient(circle, var(--accent-soft), transparent 65%);
    pointer-events: none;
    filter: blur(10px);
}

.ai-kicker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: 700;
    margin-bottom: 10px;
}

.ai-kicker::before {
    content: "";
    width: 22px;
    height: 2px;
    border-radius: 2px;
    background: var(--accent);
}

.ai-hero h1 {
    margin: 0 0 8px;
    font-size: 30px;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.ai-hero p {
    margin: 0;
    color: var(--fg-dim);
    font-size: 14.5px;
    max-width: 720px;
    line-height: 1.55;
}

.ai-hero p b {
    color: var(--fg);
    font-weight: 600;
}

.ai-hero-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.ai-stats {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.ai-stat {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 12px;
    background: var(--bg-3);
    border: 1px solid var(--border);
    font-size: 12.5px;
    color: var(--fg-dim);
    white-space: nowrap;
}

.ai-stat b {
    color: var(--fg);
    font-size: 14px;
}

.ai-search {
    margin-top: 22px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 8px 8px 18px;
    border-radius: 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    transition: border-color 0.18s, box-shadow 0.18s;
}

.ai-search:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.ai-search svg {
    width: 20px;
    height: 20px;
    color: var(--fg-dim);
    flex: none;
}

.ai-search input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--fg);
    font-size: 15.5px;
    padding: 10px 0;
}

.ai-search input::placeholder {
    color: var(--fg-dim);
}

.ai-search button {
    flex: none;
    border: 0;
    border-radius: 12px;
    padding: 11px 20px;
    background: var(--accent);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
}

.ai-search button:hover {
    background: var(--accent-hover);
}

.ai-search button:active {
    transform: scale(0.98);
}

.ai-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.ai-chip {
    border: 1px solid var(--border);
    background: var(--bg-3);
    color: var(--fg-dim);
    border-radius: 999px;
    padding: 7px 13px;
    font-size: 12.5px;
    cursor: pointer;
    transition: all 0.15s;
}

.ai-chip:hover {
    color: var(--fg);
    border-color: var(--accent);
    background: var(--accent-soft);
}

.ai-chip.active {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
}

/* ── Секции ────────────────────────────────────────────────────── */

.ai-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ai-section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
}

.ai-section-head h2 {
    margin: 0;
    font-size: 18px;
    letter-spacing: -0.01em;
}

.ai-section-head .ai-hint {
    font-size: 12.5px;
    color: var(--fg-dim);
}

.ai-loading {
    color: var(--fg-dim);
    font-size: 13.5px;
    padding: 18px 0;
}

/* ── Люди ──────────────────────────────────────────────────────── */

.ai-people-rail {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding: 4px 2px 10px;
    scrollbar-width: thin;
}

.ai-person {
    flex: none;
    width: 104px;
    border: 0;
    background: transparent;
    color: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 0;
}

.ai-avatar {
    position: relative;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background-color: var(--bg-3);
    background-repeat: no-repeat;
    border: 1px solid var(--border);
    box-shadow: 0 6px 18px var(--shadow);
    transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
    overflow: hidden;
}

.ai-person:hover .ai-avatar {
    transform: translateY(-3px);
    border-color: var(--accent);
    box-shadow: 0 10px 26px var(--shadow), 0 0 0 4px var(--accent-soft);
}

.ai-person.active .ai-avatar {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft-2);
}

.ai-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 50%;
}

.ai-avatar .ai-avatar-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    opacity: 0.55;
}

.ai-person-name {
    font-size: 12.5px;
    font-weight: 600;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-person-meta {
    font-size: 11px;
    color: var(--fg-dim);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-person.add .ai-avatar {
    border-style: dashed;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    color: var(--fg-dim);
    background: var(--bg-2);
}

.ai-person {
    position: relative;
}

.ai-person-edit {
    position: absolute;
    top: 0;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-2);
    color: var(--fg-dim);
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transform: translateY(-2px);
    transition: opacity 0.15s, color 0.15s, border-color 0.15s;
}

.ai-person:hover .ai-person-edit,
.ai-person:focus-within .ai-person-edit {
    opacity: 1;
}

.ai-person-edit:hover {
    color: var(--fg);
    border-color: var(--accent);
}

.ai-badge-dup {
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--warning);
    color: #1a1a1c;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg);
}

/* ── Категории ─────────────────────────────────────────────────── */

.ai-category-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-category-group + .ai-category-group {
    margin-top: 6px;
}

.ai-category-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--fg-dim);
    font-weight: 700;
}

.ai-category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
    gap: 10px;
}

.ai-cat {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 13px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--bg-2);
    color: inherit;
    cursor: pointer;
    text-align: left;
    transition: transform 0.15s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.ai-cat:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
    background: var(--bg-3);
    box-shadow: 0 10px 24px var(--shadow);
}

.ai-cat.active {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.ai-cat-icon {
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: var(--bg-3);
}

.ai-cat.active .ai-cat-icon {
    background: var(--accent-soft-2);
}

.ai-cat-body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ai-cat-name {
    font-size: 13.5px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-cat-count {
    font-size: 11.5px;
    color: var(--fg-dim);
}

/* ── Результаты ────────────────────────────────────────────────── */

.ai-results-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.ai-result-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 6px 12px;
    border-radius: 999px;
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    color: var(--fg);
    font-size: 12.5px;
}

.ai-result-chip button {
    border: 0;
    background: transparent;
    color: var(--fg-dim);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 2px;
}

.ai-result-chip button:hover {
    color: var(--danger);
}

.ai-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(228px, 1fr));
    gap: 14px;
}

.ai-card {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    background: var(--bg-3);
    border: 1px solid var(--border);
    cursor: pointer;
    aspect-ratio: 1 / 1;
    transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
}

.ai-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
    box-shadow: 0 16px 34px var(--shadow);
}

.ai-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.ai-card:hover img {
    transform: scale(1.04);
}

.ai-card-overlay {
    position: absolute;
    inset: auto 0 0 0;
    padding: 34px 12px 11px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.82));
    color: #fff;
    display: flex;
    flex-direction: column;
    gap: 6px;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.2s, transform 0.2s;
}

.ai-card:hover .ai-card-overlay {
    opacity: 1;
    transform: none;
}

.ai-card-desc {
    font-size: 12px;
    line-height: 1.42;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.ai-card-tags {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.ai-tag {
    font-size: 10.5px;
    padding: 3px 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    backdrop-filter: blur(4px);
    color: #fff;
    white-space: nowrap;
}

.ai-card-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 5px 9px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    color: #fff;
    font-size: 10.5px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.ai-more {
    align-self: center;
    margin: 8px auto 0;
    border: 1px solid var(--border);
    background: var(--bg-2);
    color: var(--fg);
    border-radius: 12px;
    padding: 11px 22px;
    font-size: 13.5px;
    cursor: pointer;
    transition: all 0.15s;
}

.ai-more:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

/* ── Скелетоны ─────────────────────────────────────────────────── */

.ai-skeleton {
    border-radius: 16px;
    background: linear-gradient(100deg, var(--bg-3) 30%, var(--bg-2) 50%, var(--bg-3) 70%);
    background-size: 220% 100%;
    animation: ai-shimmer 1.3s infinite linear;
    min-height: 140px;
}

@keyframes ai-shimmer {
    from { background-position: 180% 0; }
    to { background-position: -40% 0; }
}

.ai-skeleton-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(228px, 1fr));
    gap: 14px;
}

.ai-skeleton-grid .ai-skeleton {
    aspect-ratio: 1 / 1;
}

/* ── Пустое состояние ──────────────────────────────────────────── */

.ai-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
    padding: 52px 20px;
    border: 1px dashed var(--border);
    border-radius: 20px;
    background: var(--bg-2);
}

.ai-empty-icon {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    background: var(--accent-soft);
}

.ai-empty h3 {
    margin: 0;
    font-size: 16px;
}

.ai-empty p {
    margin: 0;
    color: var(--fg-dim);
    font-size: 13.5px;
    max-width: 460px;
    line-height: 1.5;
}

/* ── Ошибка ────────────────────────────────────────────────────── */

.ai-error {
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--danger);
    background: rgba(224, 82, 82, 0.08);
    color: var(--fg);
    font-size: 13.5px;
}

/* ── Мягкий поиск по сцене ─────────────────────────────────────── */

.ai-search-note {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    margin: 0 0 14px;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-2);
    color: var(--fg-dim);
    font-size: 13px;
    line-height: 1.45;
}

.ai-search-note span:first-child {
    color: var(--fg);
}

/* ── Модальное окно фото ───────────────────────────────────────── */

.ai-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.ai-modal.hidden {
    display: none;
}

.ai-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.62);
    backdrop-filter: blur(10px);
}

.ai-modal-panel {
    position: relative;
    z-index: 1;
    width: min(1180px, 100%);
    max-height: min(86vh, 900px);
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr);
    border-radius: 22px;
    overflow: hidden;
    background: var(--bg-2);
    border: 1px solid var(--border);
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5);
}

.ai-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 3;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 0;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    backdrop-filter: blur(6px);
    transition: background 0.15s;
}

.ai-modal-close:hover {
    background: rgba(0, 0, 0, 0.7);
}

.ai-modal-media {
    position: relative;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 320px;
    overflow: hidden;
}

.ai-modal-media {
    padding: 0;
}

/* Обёртка точно по размеру картинки: проценты рамок лиц совпадают с пикселями. */
.ai-shot {
    position: relative;
    display: inline-flex;
    max-width: 100%;
    max-height: 86vh;
}

.ai-modal-media img {
    display: block;
    max-width: 100%;
    max-height: 86vh;
    width: auto;
    height: auto;
    object-fit: contain;
}

.ai-face-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.ai-face-box {
    position: absolute;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-radius: 10px;
    pointer-events: auto;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.ai-face-box:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft-2);
}

.ai-face-label {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 6px);
    transform: translateX(-50%);
    padding: 4px 9px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.82);
    color: #fff;
    font-size: 11.5px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
}

.ai-face-box:hover .ai-face-label {
    opacity: 1;
}

.ai-modal-info {
    padding: 24px 24px 28px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.ai-modal-info h3 {
    margin: 0;
    font-size: 17px;
    line-height: 1.35;
    letter-spacing: -0.01em;
}

.ai-modal-date {
    font-size: 12px;
    color: var(--fg-dim);
    margin-top: -10px;
}

.ai-desc {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.62;
    color: var(--fg);
    white-space: pre-line;
}

.ai-block-title {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--fg-dim);
    font-weight: 700;
    margin-bottom: 8px;
}

.ai-bars {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.ai-bar {
    display: grid;
    grid-template-columns: 1fr 44px;
    align-items: center;
    gap: 10px;
    font-size: 12.5px;
}

.ai-bar-track {
    position: relative;
    height: 7px;
    border-radius: 999px;
    background: var(--bg-3);
    overflow: hidden;
    margin-top: 4px;
}

.ai-bar-fill {
    position: absolute;
    inset: 0 auto 0 0;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), #38bdf8);
}

.ai-bar-value {
    text-align: right;
    color: var(--fg-dim);
    font-variant-numeric: tabular-nums;
    font-size: 11.5px;
}

.ai-bar-name {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.ai-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ai-pill {
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--bg-3);
    border: 1px solid var(--border);
    color: var(--fg);
}

.ai-pill.text {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11.5px;
}

.ai-person-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 12px;
    background: var(--bg-3);
    border: 1px solid var(--border);
}

.ai-person-row + .ai-person-row {
    margin-top: 6px;
}

.ai-person-row .ai-avatar.sm {
    width: 34px;
    height: 34px;
    box-shadow: none;
}

.ai-person-row-body {
    flex: 1;
    min-width: 0;
}

.ai-person-row-name {
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-person-row-meta {
    font-size: 11px;
    color: var(--fg-dim);
}

.ai-person-row button {
    border: 1px solid var(--border);
    background: var(--bg-2);
    color: var(--fg-dim);
    border-radius: 9px;
    padding: 6px 9px;
    font-size: 11.5px;
    cursor: pointer;
    transition: all 0.15s;
}

.ai-person-row button:hover {
    color: var(--fg);
    border-color: var(--accent);
    background: var(--accent-soft);
}

/* ── Редактор метки ────────────────────────────────────────────── */

.ai-label-panel {
    position: relative;
    z-index: 1;
    width: min(440px, 100%);
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ai-label-panel h3 {
    margin: 0;
    font-size: 17px;
}

.ai-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ai-field label {
    font-size: 12px;
    color: var(--fg-dim);
    font-weight: 600;
}

.ai-field input,
.ai-field select {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border-radius: 11px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--fg);
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.ai-field input:focus,
.ai-field select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.ai-check {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13px;
    color: var(--fg);
    cursor: pointer;
    user-select: none;
}

.ai-check input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.ai-label-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 4px;
}

.ai-btn {
    border-radius: 11px;
    padding: 10px 16px;
    font-size: 13px;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--bg-3);
    color: var(--fg);
    transition: all 0.15s;
}

.ai-btn:hover {
    border-color: var(--accent);
}

.ai-btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.ai-btn.primary:hover {
    background: var(--accent-hover);
}

.ai-btn.danger {
    color: var(--danger);
    border-color: rgba(224, 82, 82, 0.4);
}

.ai-btn.danger:hover {
    background: rgba(224, 82, 82, 0.1);
    border-color: var(--danger);
}

/* ── Адаптив ───────────────────────────────────────────────────── */

@media (max-width: 1100px) {
    .ai-modal-panel {
        grid-template-columns: 1fr;
        max-height: 92vh;
        overflow-y: auto;
    }

    .ai-modal-media {
        max-height: 46vh;
    }

    .ai-modal-media img {
        max-height: 46vh;
    }
}

@media (max-width: 760px) {
    .ai-screen {
        padding: 14px 14px 48px;
        gap: 24px;
    }

    .ai-hero {
        padding: 20px 18px;
        border-radius: 18px;
    }

    .ai-hero h1 {
        font-size: 23px;
    }

    .ai-search {
        flex-wrap: wrap;
        padding: 10px;
        gap: 8px;
    }

    .ai-search input {
        flex-basis: 100%;
        order: -1;
    }

    .ai-search button {
        width: 100%;
    }

    .ai-category-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .ai-grid,
    .ai-skeleton-grid {
        grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
        gap: 9px;
    }

    .ai-card-desc {
        -webkit-line-clamp: 2;
    }

    .ai-modal {
        padding: 0;
    }

    .ai-modal-panel {
        border-radius: 0;
        max-height: 100vh;
        height: 100%;
    }
}

/* ── Тёмная/светлая тема: подсказки ────────────────────────────── */

[data-theme="light"] .ai-hero {
    box-shadow: 0 14px 40px rgba(30, 30, 60, 0.08);
}

[data-theme="light"] .ai-card-overlay {
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
}

[data-theme="light"] .ai-modal-backdrop {
    background: rgba(20, 20, 30, 0.45);
}

[data-theme="light"] .ai-modal-close {
    background: rgba(0, 0, 0, 0.35);
}


/* ── Админка распознавания ─────────────────────────────────────── */

.ai-admin-stack { display: flex; flex-direction: column; gap: 16px; max-width: 1100px; }

.ai-admin-card {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-2);
}

.ai-admin-card h3 { margin: 0 0 10px; font-size: 16px; }

.ai-admin-stats {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    color: var(--fg-dim);
    font-size: 13px;
}

.ai-admin-stats b { color: var(--fg); }

.ai-admin-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.ai-admin-muted { color: var(--fg-dim); font-size: 13px; }

.ai-pair-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 10px;
}

.ai-pair-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-3);
}

.ai-pair-avatars { display: flex; gap: 6px; }

.ai-pair-avatars img {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
    background: var(--bg-2);
}

.ai-pair-names { font-size: 12.5px; font-weight: 600; text-align: center; }

.ai-pair-score { font-size: 12px; color: var(--warning); font-variant-numeric: tabular-nums; }

.ai-worker-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--fg);
}

.ai-worker-dot { width: 9px; height: 9px; border-radius: 50%; }

.ai-worker-progress {
    height: 4px;
    border-radius: 999px;
    background: var(--bg-3);
    overflow: hidden;
    margin: 10px 0 12px;
}

.ai-worker-progress div {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #38bdf8);
    transition: width 0.3s;
}

.ai-worker-form {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 10px;
    align-items: end;
}

.ai-worker-form label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 12px;
    color: var(--fg-dim);
}

.ai-worker-form input[type="text"],
.ai-worker-form input[type="password"],
.ai-worker-form input[type="number"] {
    padding: 9px 10px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--fg);
    font-size: 13px;
    outline: none;
}

.ai-worker-form input:focus { border-color: var(--accent); }

.ai-worker-check {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    color: var(--fg);
    font-size: 13px;
    padding-bottom: 8px;
}

.ai-worker-check input { accent-color: var(--accent); width: 16px; height: 16px; }

.ai-card[draggable="true"] { cursor: grab; }
.ai-card[draggable="true"]:active { cursor: grabbing; }


.ai-manual-merge {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.ai-manual-merge select {
    flex: 1;
    min-width: 220px;
    padding: 9px 10px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--fg);
    font-size: 13px;
}


.ai-card.selected {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
