/* ==========================================================================
   Генератор: тема оформления (десктоп + мобильные, системные шрифты)
   ========================================================================== */
:root {
    /* Миниатюры галереи: фактический размер задаёт JS (layoutHistoryThumbs), здесь запас и потолок */
    --ai-thumb-min: 132px;
    --ai-thumb-max: 180px;
    --ai-thumb-gap: 12px;

    --ai-font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --ai-text: #0f172a;
    --ai-muted: #64748b;
    --ai-border: rgba(15, 23, 42, 0.1);
    --ai-surface: #ffffff;
    --ai-surface-2: #f8fafc;
    /* Акцент по умолчанию (спиннеры, ссылки) */
    --ai-accent: #4f46e5;
    --ai-accent-dim: rgba(79, 70, 229, 0.12);
    --ai-accent-hover: #4338ca;
    --ai-radius: 14px;
    --ai-radius-sm: 10px;
    --ai-shadow: 0 4px 24px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
    --ai-ring: 0 0 0 3px rgba(79, 70, 229, 0.3);
    --ai-accent-field-border: rgba(79, 70, 229, 0.55);

    /* Единая геометрия кнопок */
    --ai-btn-radius: 10px;
    --ai-btn-min-h: 44px;
    --ai-btn-pad-y: 10px;
    --ai-btn-pad-x: 10px;

    /* Роли: переключатель режима (не путать с «Сгенерировать») */
    --ai-nav-active-from: #334155;
    --ai-nav-active-to: #1e293b;
    --ai-ring-nav: 0 0 0 3px rgba(51, 65, 85, 0.35);

    /* Главное действие в форме — генерация */
    --ai-cta-generate-from: #4f46e5;
    --ai-cta-generate-to: #4338ca;
    --ai-cta-generate-hover-from: #4338ca;
    --ai-cta-generate-hover-to: #3730a3;
    --ai-ring-generate: 0 0 0 3px rgba(79, 70, 229, 0.35);

    /* Вспомогательное действие — загрузка файла */
    --ai-secondary-border: #cbd5e1;
    --ai-secondary-text: #334155;
    --ai-secondary-hover-bg: #f1f5f9;
    --ai-ring-secondary: 0 0 0 3px rgba(100, 116, 139, 0.35);

    /* Коммерция — корзина / оплата */
    --ai-commerce-from: #059669;
    --ai-commerce-to: #047857;
    --ai-commerce-hover-from: #047857;
    --ai-commerce-hover-to: #065f46;
    --ai-ring-commerce: 0 0 0 3px rgba(5, 150, 105, 0.35);

    /* VK — бесплатное скачивание */
    --ai-vk-accent: #f97316;
    --ai-vk-accent-hover: #ea580c;
    --ai-vk-hover-from: #ea580c;
    --ai-vk-hover-to: #c2410c;
    --ai-ring-vk: 0 0 0 3px rgba(249, 115, 22, 0.35);
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.ai-form-mode-heading {
    margin: 0 0 14px;
    font-size: clamp(1.05rem, 2.5vw, 1.35rem);
    font-weight: 650;
    line-height: 1.25;
    color: var(--ai-text);
    width: 100%;
    letter-spacing: -0.02em;
}

.ai-mode-row {
    width: 100%;
    flex: 1 1 100%;
    margin-bottom: 8px;
}

.ai-mode-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
    padding: 5px;
    background: var(--ai-surface-2);
    border-radius: var(--ai-radius-sm);
    border: 1px solid var(--ai-border);
}

/* Режимы: явный контраст — глобальные стили Astra/Woo (.button, цвета шапки) иначе дают белый текст на светлом фоне */
.ai-image-generator-wrapper .ai-mode-btn,
.ai-image-generator-wrapper .ai-mode-buttons .button.ai-mode-btn {
    flex: 1 1 auto;
    min-width: 0;
    min-height: var(--ai-btn-min-h);
    border: none;
    border-radius: var(--ai-btn-radius);
    padding: var(--ai-btn-pad-y) var(--ai-btn-pad-x);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    box-shadow: none;
    text-shadow: none;
    -webkit-appearance: none;
    appearance: none;
}

.ai-image-generator-wrapper .ai-mode-btn:not(.is-active) {
    background: transparent !important;
    background-color: transparent !important;
    color: var(--ai-secondary-text) !important;
    border: 1px solid var(--ai-secondary-border) !important;
}

.ai-image-generator-wrapper .ai-mode-btn:not(.is-active):hover {
    background: var(--ai-secondary-hover-bg) !important;
    color: var(--ai-text) !important;
    border-color: #94a3b8 !important;
}

.ai-image-generator-wrapper .ai-mode-btn.is-active {
    font-weight: 600;
    color: #fff !important;
    background: linear-gradient(135deg, var(--ai-nav-active-from) 0%, var(--ai-nav-active-to) 100%) !important;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
    border: none !important;
}

.ai-image-generator-wrapper .ai-mode-btn:focus-visible {
    outline: none;
    box-shadow: var(--ai-ring-nav);
}

.ai-mode-help {
    font-size: 13px;
    color: var(--ai-muted);
    line-height: 1.5;
    margin: 0;
}

.ai-quality-hint {
    font-size: 12px;
    color: #646970;
    line-height: 1.4;
    margin: 0 0 8px;
}

.ai-field input.ai-quality-range.ai-quality-range--admin-zones {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    accent-color: var(--ai-quality-thumb-color, var(--ai-accent));
}

.ai-field input.ai-quality-range.ai-quality-range--admin-zones::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 999px;
    background: var(--ai-quality-track-gradient, #e4e6e8);
}

.ai-field input.ai-quality-range.ai-quality-range--admin-zones::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    margin-top: -6px;
    border: none;
    border-radius: 50%;
    background: var(--ai-quality-thumb-color, var(--ai-accent));
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    cursor: pointer;
}

.ai-field input.ai-quality-range.ai-quality-range--admin-zones::-moz-range-track {
    height: 4px;
    border-radius: 999px;
    background: var(--ai-quality-track-gradient, #e4e6e8);
    border: none;
}

.ai-field input.ai-quality-range.ai-quality-range--admin-zones::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border: none;
    border-radius: 50%;
    background: var(--ai-quality-thumb-color, var(--ai-accent));
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    cursor: pointer;
}

.ai-prompt-photo-tip {
    font-size: 12px;
    color: #646970;
    line-height: 1.45;
    margin: 8px 0 0;
    padding: 8px 10px;
    background: #f6f7f7;
    border-radius: 4px;
    border-left: 3px solid #2271b1;
}

.ai-edit-upload-inner {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

/* Нативная кнопка «Выберите файл» скрыта — выбор только через «Загрузить изображение». */
.ai-edit-file-input {
    position: absolute;
    left: 0;
    top: 0;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    opacity: 0;
    z-index: 0;
}

.ai-edit-upload-btn {
    position: relative;
    z-index: 1;
}

.ai-upload-thumb-wrap {
    position: relative;
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    line-height: 0;
}

.ai-upload-thumb {
    display: block;
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--ai-accent-field-border, #c3c4c7);
    background: #f6f7f7;
}

.ai-upload-thumb-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #1d2327;
    color: #fff;
    font-size: 14px;
    line-height: 18px;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.ai-upload-thumb-remove:hover {
    background: #c62828;
}

.ai-multi-upload-slots {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    align-items: start;
}

.ai-multi-upload-slot {
    position: relative;
    min-width: 0;
}

.ai-multi-upload-inner {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}

.ai-image-generator-wrapper .ai-multi-upload-btn.button,
.ai-image-generator-wrapper .ai-multi-upload-btn.button-primary {
    width: 100%;
    min-height: var(--ai-btn-min-h);
    padding: var(--ai-btn-pad-y) var(--ai-btn-pad-x);
    border-radius: var(--ai-btn-radius) !important;
    color: var(--ai-secondary-text) !important;
    background: #fff !important;
    background-color: #fff !important;
    border: 1px solid var(--ai-accent-field-border) !important;
    box-shadow: var(--ai-ring);
    text-shadow: none !important;
    font-weight: 600;
    font-size: 14px;
    text-transform: none;
    letter-spacing: normal;
    white-space: nowrap;
}

.ai-image-generator-wrapper .ai-multi-upload-btn.button:not(:disabled):hover,
.ai-image-generator-wrapper .ai-multi-upload-btn.button-primary:not(:disabled):hover {
    color: var(--ai-text) !important;
    background: var(--ai-secondary-hover-bg) !important;
    border-color: var(--ai-accent-field-border) !important;
    box-shadow: var(--ai-ring);
}

.ai-image-generator-wrapper .ai-multi-upload-btn.button:focus-visible,
.ai-image-generator-wrapper .ai-multi-upload-btn.button-primary:focus-visible {
    outline: none;
    border-color: var(--ai-accent-field-border) !important;
    box-shadow: var(--ai-ring);
}

.ai-image-generator-wrapper .ai-multi-upload-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    color: var(--ai-secondary-text) !important;
    background: #f6f7f7 !important;
    background-color: #f6f7f7 !important;
    border-color: var(--ai-accent-field-border) !important;
}

.ai-multi-upload-thumb-wrap {
    align-self: center;
}

@media (max-width: 560px) {
    .ai-multi-upload-slots {
        grid-template-columns: 1fr;
    }
}

.ai-multi-file-input {
    position: absolute;
    left: 0;
    top: 0;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    opacity: 0;
    z-index: 0;
}

.ai-multi-upload-status {
    display: none;
    margin: 6px 0 0;
    font-size: 12px;
    font-weight: 600;
    color: #c62828;
    line-height: 1.35;
}

.ai-multi-upload-status.is-error {
    display: block;
}

.ai-multi-upload-loading,
.ai-image-generator-wrapper.ai-multi-upload-pending .ai-multi-upload-loading {
    display: none;
}

.ai-image-generator-wrapper.ai-multi-upload-pending .ai-multi-upload-loading {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 10px;
    font-size: 13px;
    color: #50575e;
}

.ai-edit-upload-status {
    display: none;
    margin: 8px 0 0;
    font-size: 13px;
    font-weight: 600;
    color: #c62828;
    line-height: 1.4;
}

.ai-edit-upload-status.is-error {
    display: block;
}

.ai-image-generator-wrapper .ai-edit-upload-btn.button,
.ai-image-generator-wrapper .ai-edit-upload-btn.button-primary {
    min-height: var(--ai-btn-min-h);
    padding: var(--ai-btn-pad-y) var(--ai-btn-pad-x);
    border-radius: var(--ai-btn-radius) !important;
    color: var(--ai-secondary-text) !important;
    background: #fff !important;
    background-color: #fff !important;
    border: 1px solid var(--ai-accent-field-border) !important;
    box-shadow: var(--ai-ring);
    text-shadow: none !important;
    font-weight: 600;
    font-size: 14px;
}

.ai-image-generator-wrapper .ai-edit-upload-btn.button:hover,
.ai-image-generator-wrapper .ai-edit-upload-btn.button-primary:hover {
    color: var(--ai-text) !important;
    background: var(--ai-secondary-hover-bg) !important;
    border-color: var(--ai-accent-field-border) !important;
    box-shadow: var(--ai-ring);
}

.ai-image-generator-wrapper .ai-edit-upload-btn.button:focus-visible,
.ai-image-generator-wrapper .ai-edit-upload-btn.button-primary:focus-visible {
    outline: none;
    border-color: var(--ai-accent-field-border) !important;
    box-shadow: var(--ai-ring);
}

.ai-edit-upload-loading {
    display: none;
    align-items: flex-start;
    gap: 12px;
    margin-top: 12px;
    padding: 12px 14px;
    background: linear-gradient(90deg, #f0f6fc 0%, #e8f4fd 50%, #f0f6fc 100%);
    background-size: 200% 100%;
    border: 1px solid #c3d9ed;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.45;
    color: #1d2327;
    animation: ai-upload-banner-shift 2s ease-in-out infinite;
}

.ai-image-generator-wrapper.ai-edit-upload-pending .ai-edit-upload-loading {
    display: flex;
}

@keyframes ai-upload-banner-shift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.ai-edit-upload-spinner {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    margin-top: 2px;
    border: 3px solid #c3d9ed;
    border-top-color: #2271b1;
    border-radius: 50%;
    animation: ai-spin 0.7s linear infinite;
}

.ai-edit-upload-loading-msg {
    flex: 1;
    min-width: 0;
}

.ai-submit-wait-upload-hint {
    display: none;
    flex: 1 1 100%;
    margin: 0;
    padding: 8px 12px;
    font-size: 13px;
    line-height: 1.45;
    color: #135e96;
    background: #f0f6fc;
    border-radius: 4px;
    border-left: 3px solid #2271b1;
    animation: ai-submit-hint-pulse 1.8s ease-in-out infinite;
}

.ai-image-generator-wrapper.ai-edit-upload-pending .ai-submit-wait-upload-hint {
    display: block;
}

@keyframes ai-submit-hint-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.82; }
}

.ai-image-generator-wrapper {
    font-family: var(--ai-font);
    color: var(--ai-text);
    display: flex;
    flex-direction: column;
    gap: clamp(16px, 3vw, 24px);
    border: 1px solid var(--ai-border);
    padding: clamp(16px, 3vw, 28px);
    border-radius: var(--ai-radius);
    background: var(--ai-surface);
    box-sizing: border-box;
    box-shadow: var(--ai-shadow);
    max-width: 1280px;
    margin-left: auto;
    margin-right: auto;
}

.ai-image-generator-form {
    display: flex;
    flex-wrap: wrap;
    gap: clamp(16px, 3vw, 28px);
    align-items: stretch;
}

.ai-image-form-left {
    flex: 1 1 min(100%, 380px);
    min-width: 0;
}

.ai-image-form-right {
    flex: 1 1 min(100%, 380px);
    min-height: 220px;
    max-height: 80vh;
    overflow: hidden;
    border: 1px solid var(--ai-border);
    border-radius: var(--ai-radius-sm);
    padding: clamp(12px, 2vw, 18px);
    background: linear-gradient(180deg, var(--ai-surface-2) 0%, #fff 48%);
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
    justify-content: flex-start;
    text-align: center;
}

.ai-field {
    margin-bottom: 14px;
}

.ai-field > label:first-child {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--ai-text);
    margin-bottom: 6px;
    letter-spacing: 0.01em;
}

.ai-field textarea,
.ai-field input[type="text"]:not(.ai-size-input),
.ai-field select {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--ai-border);
    border-radius: var(--ai-radius-sm);
    padding: 10px 12px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.45;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ai-field textarea {
    min-height: 88px;
    resize: vertical;
}

/* Промпт — акцентная обводка всегда (не только при фокусе) */
.ai-image-generator-wrapper .ai-field-prompt textarea,
.ai-image-generator-wrapper .ai-field-prompt textarea:focus,
.ai-image-generator-wrapper .ai-field-prompt textarea:focus-visible {
    outline: none;
    border-color: var(--ai-accent-field-border);
    box-shadow: var(--ai-ring);
}

.ai-field input:focus-visible,
.ai-field select:focus-visible {
    outline: none;
    border-color: var(--ai-accent-field-border);
    box-shadow: var(--ai-ring);
}

.ai-field:not(.ai-field-prompt) textarea:focus-visible {
    outline: none;
    border-color: var(--ai-accent-field-border);
    box-shadow: var(--ai-ring);
}

.ai-field input[type="range"],
.ai-field input.ai-steps-range,
.ai-field input.ai-quality-range,
.ai-field input.ai-gen-priority-range {
    width: 100%;
    max-width: 100%;
    accent-color: var(--ai-accent);
    touch-action: pan-x;
    min-height: 28px;
    -webkit-tap-highlight-color: transparent;
}

.ai-prompt-label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
}

.ai-prompt-label-main {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
    font-size: 13px;
}

.ai-prompt-label-main label,
.ai-prompt-label-row label {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--ai-text);
    letter-spacing: 0.01em;
    margin-bottom: 0;
}

.ai-prompt-label-main label {
    display: inline;
    flex: 0 1 auto;
}

.ai-gen-prompt-hint-btn {
    width: 1em;
    height: 1em;
    min-width: 1em;
    min-height: 1em;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.22);
    background: #fff;
    color: #111;
    font-weight: 800;
    font-size: 1em;
    line-height: 1;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex: 0 0 auto;
}

.ai-gen-prompt-hint-btn:focus-visible {
    outline: none;
    box-shadow: var(--ai-ring, 0 0 0 2px rgba(27, 94, 32, 0.25));
}

/* Текстовая ссылка — без .button; иначе Astra/Woo дают синий фон и hover */
.ai-image-generator-wrapper button.ai-prompt-clear-btn,
.ai-image-generator-wrapper button.ai-prompt-clear-btn:hover,
.ai-image-generator-wrapper button.ai-prompt-clear-btn:focus,
.ai-image-generator-wrapper button.ai-prompt-clear-btn:focus-visible,
.ai-image-generator-wrapper button.ai-prompt-clear-btn:active {
    flex: 0 0 auto;
    display: inline;
    margin: 0;
    padding: 0 2px;
    min-height: 0;
    height: auto;
    border: 0 !important;
    border-radius: 0;
    background: none !important;
    background-color: transparent !important;
    box-shadow: none !important;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.3;
    letter-spacing: normal;
    text-transform: none;
    color: var(--ai-muted) !important;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
    opacity: 1;
    transition: opacity 0.15s ease;
}

.ai-image-generator-wrapper .ai-prompt-clear-btn:hover,
.ai-image-generator-wrapper .ai-prompt-clear-btn:focus-visible {
    opacity: 0.75;
    outline: none;
}

.ai-prompt-counter {
    margin-top: 6px;
    font-size: 12px;
    color: var(--ai-muted);
}

.ai-prompt-counter.ai-prompt-counter-over {
    color: #dc3232;
    font-weight: 600;
}

.ai-captcha {
    margin: 15px 0;
    padding: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background: #fafafa;
}

.ai-captcha-title {
    font-size: 13px;
    margin-bottom: 8px;
}

.ai-captcha-image-wrapper {
    position: relative;
    height: 60px;
    margin-bottom: 8px;
    background: 
        repeating-linear-gradient(
            45deg,
            #667eea,
            #667eea 10px,
            #764ba2 10px,
            #764ba2 20px
        );
    border-radius: 4px;
    overflow: hidden;
}

.ai-captcha-image {
    position: relative;
    width: 100%;
    height: 100%;
    background: 
        repeating-linear-gradient(
            45deg,
            #667eea,
            #667eea 10px,
            #764ba2 10px,
            #764ba2 20px
        );
}

/* Вырез в фоне - цель для пазла (более заметный) */
.ai-captcha-image::after {
    content: '';
    position: absolute;
    top: 8px;
    left: var(--captcha-target, 50%);
    width: 60px;
    height: 44px;
    background: rgba(255, 255, 255, 0.3);
    border: 3px dashed #fff;
    border-radius: 4px;
    transform: translateX(-50%);
    pointer-events: none;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5) inset;
    animation: ai-captcha-pulse 2s ease-in-out infinite;
}

@keyframes ai-captcha-pulse {
    0%, 100% {
        opacity: 0.8;
        border-color: #fff;
    }
    50% {
        opacity: 1;
        border-color: #ffeb3b;
    }
}

.ai-captcha-piece {
    position: absolute;
    top: 8px;
    left: 0;
    width: 60px;
    height: 44px;
    background: 
        repeating-linear-gradient(
            45deg,
            #667eea,
            #667eea 10px,
            #764ba2 10px,
            #764ba2 20px
        );
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    transition: left 0.1s linear;
    border: 2px solid rgba(255, 255, 255, 0.9);
    z-index: 2;
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.ai-captcha-piece:active {
    cursor: grabbing;
}

.ai-captcha-piece.ai-captcha-piece-dragging {
    transition: none;
}

.ai-captcha-slider input[type="range"] {
    width: 100%;
}

.ai-captcha-message {
    margin-top: 4px;
    font-size: 12px;
    color: #666;
}

.ai-captcha.ai-captcha-success .ai-captcha-message {
    color: #2e7d32;
}

.ai-captcha.ai-captcha-error .ai-captcha-message {
    color: #c62828;
}

.ai-field-row {
    display: flex;
    gap: 10px;
}

.ai-field-row > div {
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
}

.ai-field-row > div input[type="number"],
.ai-field-row > div input[type="text"].ai-size-input {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.ai-size-field label {
    display: inline;
}

.ai-size-error {
    color: #c62828;
    font-size: 12px;
    font-weight: 600;
    margin-left: 0.25em;
}

.ai-field-row .ai-size-invalid {
    border-color: #c62828 !important;
    box-shadow: 0 0 0 1px #c62828;
}

.ai-submit-btn {
    margin-top: 10px;
    padding: 8px 16px;
    min-height: var(--ai-btn-min-h);
    background: linear-gradient(135deg, var(--ai-cta-generate-from) 0%, var(--ai-cta-generate-to) 100%);
    border: none;
    color: #fff;
    border-radius: var(--ai-btn-radius);
    cursor: pointer;
    font-weight: 600;
}

.ai-submit-btn:hover {
    background: linear-gradient(135deg, var(--ai-cta-generate-hover-from) 0%, var(--ai-cta-generate-hover-to) 100%);
}

.ai-gen-pricing-notice,
.ai-gen-pricing-checkout-hint {
    margin: 0 0 14px;
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(79, 70, 229, 0.08);
    border: 1px solid rgba(79, 70, 229, 0.18);
    color: #1e293b;
    font-size: 14px;
    line-height: 1.5;
}

.ai-gen-pricing-checkout-hint {
    margin: 0 0 10px;
    font-size: 13px;
    background: rgba(15, 23, 42, 0.04);
    border-color: rgba(15, 23, 42, 0.1);
}

.ai-submit-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}

.ai-image-generator-wrapper .ai-submit-row button[type="submit"] {
    min-height: 48px;
    padding: 12px 24px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.02em;
    border-radius: var(--ai-btn-radius);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    color: #fff !important;
    background: linear-gradient(135deg, var(--ai-cta-generate-from) 0%, var(--ai-cta-generate-to) 100%) !important;
    border: none !important;
    text-shadow: none !important;
    -webkit-appearance: none;
    appearance: none;
    box-shadow: 0 2px 12px rgba(79, 70, 229, 0.35);
}

.ai-image-generator-wrapper .ai-submit-row button[type="submit"]:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.38);
    color: #fff !important;
    background: linear-gradient(135deg, var(--ai-cta-generate-hover-from) 0%, var(--ai-cta-generate-hover-to) 100%) !important;
}

.ai-image-generator-wrapper .ai-submit-row button[type="submit"]:focus-visible {
    outline: none;
    box-shadow: var(--ai-ring-generate);
}

.ai-cost-preview-label {
    font-size: 13px;
    color: var(--ai-muted);
    line-height: 1.4;
}

.ai-total-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 18px;
    padding: 14px 16px;
    border-top: 1px solid var(--ai-border);
    background: var(--ai-surface-2);
    border-radius: var(--ai-radius-sm);
}

.ai-total-label {
    font-size: 15px;
    font-weight: 650;
    color: var(--ai-text);
}

.ai-image-generator-wrapper .ai-total-row .ai-pay-download-btn,
.ai-image-generator-wrapper button.ai-pay-download-btn {
    min-height: var(--ai-btn-min-h);
    padding: var(--ai-btn-pad-y) var(--ai-btn-pad-x);
    background: linear-gradient(135deg, var(--ai-commerce-from) 0%, var(--ai-commerce-to) 100%) !important;
    border: none !important;
    color: #fff !important;
    border-radius: var(--ai-btn-radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.28);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    text-shadow: none !important;
    -webkit-appearance: none;
    appearance: none;
}

.ai-image-generator-wrapper .ai-pay-download-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(5, 150, 105, 0.38);
    color: #fff !important;
    background: linear-gradient(135deg, var(--ai-commerce-hover-from) 0%, var(--ai-commerce-hover-to) 100%) !important;
}

.ai-image-generator-wrapper .ai-pay-download-btn:focus-visible {
    outline: none;
    box-shadow: var(--ai-ring-commerce);
}

.ai-image-generator-wrapper .ai-pay-download-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    color: #fff !important;
    background: linear-gradient(135deg, var(--ai-commerce-from) 0%, var(--ai-commerce-to) 100%) !important;
}

.ai-total-row-buttons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.ai-image-generator-wrapper .ai-total-row .ai-vk-free-download-btn,
.ai-image-generator-wrapper button.ai-vk-free-download-btn {
    min-height: var(--ai-btn-min-h);
    padding: var(--ai-btn-pad-y) var(--ai-btn-pad-x);
    background: linear-gradient(135deg, var(--ai-vk-accent) 0%, var(--ai-vk-accent-hover) 100%) !important;
    border: none !important;
    color: #fff !important;
    border-radius: var(--ai-btn-radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.28);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    text-shadow: none !important;
    -webkit-appearance: none;
    appearance: none;
}

.ai-image-generator-wrapper .ai-vk-free-download-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(249, 115, 22, 0.38);
    color: #fff !important;
    background: linear-gradient(135deg, var(--ai-vk-hover-from) 0%, var(--ai-vk-hover-to) 100%) !important;
    filter: none;
}

.ai-image-generator-wrapper .ai-vk-free-download-btn:focus-visible {
    outline: none;
    box-shadow: var(--ai-ring-vk);
}

.ai-vk-panel {
    margin-top: 12px;
    padding: 12px 14px;
    background: var(--ai-surface-2);
    border-radius: var(--ai-radius-sm);
    border: 1px solid var(--ai-border);
}

.ai-vk-hint {
    margin: 0 0 6px;
    font-size: 14px;
    color: var(--ai-text);
}

.ai-vk-hint-small,
.ai-vk-legal {
    margin: 0 0 8px;
    font-size: 12px;
    color: var(--ai-muted);
}

.ai-vk-publish-btn {
    min-height: var(--ai-btn-min-h);
    padding: var(--ai-btn-pad-y) var(--ai-btn-pad-x);
    background: var(--ai-vk-accent);
    color: #fff;
    border: none;
    border-radius: var(--ai-btn-radius);
    font-weight: 600;
    cursor: pointer;
}

.ai-vk-publish-btn:hover {
    background: var(--ai-vk-accent-hover);
}

.ai-thumb.ai-vk-selectable .ai-thumb-image-wrap {
    position: relative;
}

.ai-thumb-checkbox {
    display: none;
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 3;
    width: 22px;
    height: 22px;
    accent-color: var(--ai-vk-accent);
    cursor: pointer;
}

.ai-image-generator-wrapper.ai-vk-select-mode .ai-thumb-checkbox {
    display: block;
}

.ai-purchase-checkbox {
    display: none;
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 4;
    width: 22px;
    height: 22px;
    accent-color: var(--ai-commerce-from);
    cursor: pointer;
}

.ai-image-generator-wrapper.ai-purchase-select-mode:not(.ai-vk-select-mode) .ai-purchase-checkbox {
    display: block;
}

.ai-thumb.ai-purchase-selected .ai-thumb-image-wrap::before {
    content: '';
    position: absolute;
    inset: 0;
    border: 3px solid var(--ai-commerce-from);
    border-radius: 8px;
    pointer-events: none;
    z-index: 2;
}

.ai-image-generator-wrapper.ai-vk-select-mode .ai-thumb.ai-purchase-selected .ai-thumb-image-wrap::before {
    display: none;
}

.ai-thumb.ai-vk-selected .ai-thumb-image-wrap::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 3px solid var(--ai-vk-accent);
    border-radius: 8px;
    pointer-events: none;
}

.ai-gen-download-archives-wrap,
.ai-vk-archives-wrap {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--ai-border);
}

.ai-gen-download-archives-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
    font: inherit;
    color: inherit;
}

.ai-image-generator-wrapper .ai-gen-download-archives-toggle,
.ai-image-generator-wrapper .ai-gen-download-archives-toggle:hover,
.ai-image-generator-wrapper .ai-gen-download-archives-toggle:focus,
.ai-image-generator-wrapper .ai-gen-download-archives-toggle:active {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    filter: none !important;
    outline: none;
    color: var(--ai-text, #1a1a1a) !important;
}

.ai-image-generator-wrapper .ai-gen-download-archives-toggle .ai-gen-download-archives-title,
.ai-image-generator-wrapper .ai-gen-download-archives-toggle:hover .ai-gen-download-archives-title,
.ai-image-generator-wrapper .ai-gen-download-archives-toggle:focus .ai-gen-download-archives-title,
.ai-image-generator-wrapper .ai-gen-download-archives-toggle:active .ai-gen-download-archives-title {
    color: var(--ai-text, #1a1a1a) !important;
}

.ai-image-generator-wrapper .ai-gen-download-archives-toggle:hover .ai-gen-download-archives-caret,
.ai-image-generator-wrapper .ai-gen-download-archives-toggle:focus .ai-gen-download-archives-caret,
.ai-image-generator-wrapper .ai-gen-download-archives-toggle:active .ai-gen-download-archives-caret {
    color: var(--ai-muted, #666) !important;
}

.ai-gen-download-archives-title,
.ai-vk-archives-title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.ai-gen-download-archives-caret {
    flex-shrink: 0;
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 7px solid currentColor;
    color: var(--ai-muted, #666);
    transition: transform 0.2s ease;
}

.ai-gen-download-archives-wrap.is-expanded .ai-gen-download-archives-caret {
    transform: rotate(90deg);
}

.ai-gen-download-archives-body {
    margin-top: 10px;
}

.ai-gen-download-archives-body[hidden] {
    display: none !important;
}

.ai-gen-archives-section {
    margin-bottom: 12px;
}

.ai-gen-archives-section:last-child {
    margin-bottom: 0;
}

.ai-gen-archives-section-title {
    margin: 0 0 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ai-text-muted, #666);
}

.ai-gen-archives-list,
.ai-vk-archives-list {
    margin: 0;
    padding-left: 1.2em;
    font-size: 13px;
}

.ai-gen-archives-list a {
    word-break: break-word;
}

.ai-vk-report-list {
    margin: 12px 0;
    padding: 0;
    list-style: none;
}

.ai-vk-report-list li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid var(--ai-border);
    font-size: 13px;
}

.ai-vk-status-ok {
    color: #059669;
    font-weight: 600;
}

.ai-vk-status-error {
    color: #dc2626;
    font-weight: 600;
}

.ai-vk-picker-content {
    max-width: 520px;
}

.ai-vk-picker-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 12px 0 16px;
}

.ai-vk-picker-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    flex: 0 0 auto;
    max-width: 140px;
}

.ai-vk-picker-item input[type="radio"] {
    accent-color: var(--ai-vk-accent);
}

.ai-vk-picker-thumb {
    display: block;
    width: 120px;
    height: 120px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid transparent;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.ai-vk-picker-item:has(input:checked) .ai-vk-picker-thumb {
    border-color: var(--ai-vk-accent);
}

.ai-vk-picker-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ai-vk-picker-label {
    font-size: 12px;
    text-align: center;
    color: var(--ai-muted);
}

.ai-vk-picker-text,
.ai-vk-publish-text {
    width: 100%;
    resize: vertical;
    margin-bottom: 12px;
    font-size: 13px;
    line-height: 1.45;
}

.ai-vk-publish-page h1,
.ai-vk-publish-page h2 {
    margin-top: 0;
}

.ai-vk-publish-step {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.ai-vk-publish-step:last-of-type {
    border-bottom: none;
}

.ai-vk-publish-preview-img {
    border-radius: 8px;
    max-width: 100%;
    height: auto;
    object-fit: cover;
}

.ai-vk-protected-media {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.ai-vk-protected-media img {
    pointer-events: none;
}

.ai-vk-og-parser-image {
    margin: 0 0 1rem;
    max-width: 537px;
}

.ai-vk-og-parser-image .ai-vk-publish-og-img {
    display: block;
    width: 100%;
    max-width: 537px;
    height: auto;
    border-radius: 8px;
}

.ai-vk-verify-progress-bar {
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    margin: 12px 0 8px;
}

.ai-vk-verify-progress-fill {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--ai-vk-accent), var(--ai-vk-accent-hover));
    transition: width 0.1s linear;
}

@media (max-width: 640px) {
    .ai-total-row {
        flex-direction: column;
        align-items: stretch;
    }

    .ai-total-row-buttons {
        flex-direction: column;
        width: 100%;
    }

    .ai-total-row-buttons .ai-pay-download-btn,
    .ai-total-row-buttons .ai-vk-free-download-btn {
        width: 100%;
    }
}

/* Стили для неактивной кнопки генерации */
.ai-image-generator-form button[type="submit"]:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.ai-result-placeholder {
    color: var(--ai-muted);
    font-size: 13px;
    line-height: 1.55;
    text-align: center;
    padding: 14px 12px;
}

.ai-result-placeholder:empty {
    display: none;
}

.ai-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.ai-loader-text {
    text-align: center;
    white-space: pre-line;
    line-height: 1.45;
    max-width: 100%;
}

.ai-gen-queue-priority-promo-link {
    display: inline-block;
    font-weight: 700;
    text-align: center;
    color: var(--ai-accent, #4f46e5);
    text-decoration: underline;
    font-size: 0.95rem;
    line-height: 1.35;
    max-width: 100%;
}

.ai-gen-result-speed-promo-wrap {
    width: 100%;
    text-align: center;
    padding: 10px 8px 4px;
    flex-shrink: 0;
}

.ai-gen-result-speed-promo-wrap[hidden] {
    display: none !important;
}

.ai-gen-result-speed-promo-wrap .ai-gen-auth-view-only-hint {
    margin: 0;
    font-size: 13px;
    color: #dc3232;
    font-weight: 600;
    line-height: 1.45;
}

.ai-gen-queue-priority-promo-body p {
    margin: 0 0 0.75em;
}

.ai-gen-queue-priority-promo-list {
    margin: 0 0 1.25em 1.25em;
    padding: 0;
}

.ai-gen-queue-priority-promo-list li {
    margin-bottom: 0.35em;
}

.ai-gen-auth-actions--split {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.ai-gen-auth-actions--split .ai-gen-auth-btn-primary {
    flex: 1 1 140px;
    max-width: 100%;
}

.ai-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(79, 70, 229, 0.2);
    border-top-color: var(--ai-accent);
    border-radius: 50%;
    animation: ai-spin 1s linear infinite;
}

@keyframes ai-spin {
    to { transform: rotate(360deg); }
}

/* Блок результата: колонка + растягивание по высоте (иначе превью остаётся ~220px и «крошечным») */
.ai-result-image {
    min-width: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    overflow: hidden;
}
.ai-result-image:not(:has(img)) {
    flex: 0 0 auto;
    min-height: 0;
}
.ai-result-image:has(img) {
    flex: 1 1 auto;
    min-height: clamp(280px, 48vh, 78vh);
}

.ai-result-image img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: center;
    display: block;
    border-radius: 4px;
    -webkit-user-drag: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.ai-compare-view {
    position: relative;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    border-radius: 4px;
    touch-action: none;
    user-select: none;
    cursor: ew-resize;
    background: linear-gradient(145deg, #e2e8f0 0%, #f1f5f9 100%);
}

.ai-compare-view--original-only {
    cursor: default;
    touch-action: auto;
}

.ai-compare-layer {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

/* Один и тот же прямоугольник; contain — весь кадр виден, при разных пропорциях возможны поля */
.ai-compare-view .ai-compare-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: contain;
    object-position: center;
    -webkit-user-drag: none;
    user-select: none;
    pointer-events: none;
}

.ai-thumb-image-wrap img,
.ai-gallery-image {
    -webkit-user-drag: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.ai-protect-notice-popup {
    position: fixed;
    inset: 0;
    z-index: 100000;
}

.ai-protect-notice-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
}

.ai-protect-notice-content {
    position: relative;
    width: min(420px, calc(100vw - 32px));
    margin: 10vh auto 0;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 48px rgba(15, 23, 42, 0.28);
    padding: 18px 18px 16px;
    box-sizing: border-box;
}

.ai-protect-notice-header {
    font-size: 20px;
    font-weight: 700;
    color: var(--ai-text);
    margin-bottom: 10px;
}

.ai-protect-notice-text {
    margin: 0;
    font-size: 15px;
    line-height: 1.45;
    color: var(--ai-text);
}

.ai-protect-notice-actions {
    margin-top: 16px;
    text-align: right;
}

.ai-protect-notice-close {
    min-height: 40px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.18);
    background: #fff;
    color: var(--ai-text);
    font-weight: 600;
    cursor: pointer;
}

/* Правая часть сравнения: маска + inner (без clip-path — стабильнее с PNG/JPEG в GPU) */
.ai-compare-before-layer {
    z-index: 1;
}

.ai-compare-after-mask {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    z-index: 2;
    pointer-events: none;
}

.ai-compare-after-inner {
    position: absolute;
    top: 0;
    bottom: 0;
    overflow: hidden;
    pointer-events: none;
}

.ai-compare-divider {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    margin-left: -1px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.55);
    pointer-events: none;
    z-index: 3;
}

.ai-compare-handle {
    position: absolute;
    top: 50%;
    width: 28px;
    height: 28px;
    margin-left: -14px;
    margin-top: -14px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--ai-accent);
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
    pointer-events: none;
    z-index: 3;
}

.ai-status-text {
    margin-top: 6px;
    font-size: 13px;
    color: var(--ai-muted);
    white-space: pre-line;
}

.ai-status-text.ai-status-error {
    color: #dc3232;
    font-weight: 600;
}

.ai-gen-maintenance-stub {
    margin: 0;
    padding: clamp(28px, 5vw, 48px) clamp(20px, 4vw, 32px);
    font-size: clamp(1rem, 2.2vw, 1.15rem);
    line-height: 1.55;
    font-weight: 500;
    text-align: center;
    background: var(--ai-surface-2);
    border: 1px solid var(--ai-border);
    border-radius: var(--ai-radius);
    box-shadow: var(--ai-shadow);
    white-space: pre-line;
}

.ai-image-generator-wrapper--maintenance .ai-gen-maintenance-stub {
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
}

/* Миниатюры: одна ширина ячейки на всю галерею (считает ai-image-generator.js), перенос строк как раньше */
.ai-history-storage-notice {
    margin: 12px 0 0;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.45;
    color: var(--ai-muted);
    background: var(--ai-surface-2);
    border: 1px solid var(--ai-border);
    border-radius: var(--ai-radius-sm);
}

.ai-image-history {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ai-thumb-gap);
    border-top: 1px solid var(--ai-border);
    padding-top: 14px;
    margin-top: 4px;
}

.ai-thumb {
    flex: 0 0 var(--ai-thumb-min);
    width: var(--ai-thumb-min);
    max-width: var(--ai-thumb-max);
    min-width: 0;
    box-sizing: border-box;
    cursor: pointer;
    text-align: center;
    transition: transform 0.15s ease;
}

.ai-thumb:hover {
    transform: translateY(-2px);
}

.ai-thumb-image-wrap {
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: var(--ai-radius-sm);
    border: 1px solid var(--ai-border);
    background: var(--ai-surface-2);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.ai-thumb-image-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ai-thumb-label {
    margin-top: 6px;
    font-size: 11px;
    font-weight: 500;
    color: var(--ai-muted);
}

.ai-log-wrapper {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px dashed #ccc;
}

.ai-log-title {
    font-weight: 600;
    margin-bottom: 5px;
}

.ai-log-output {
    max-height: 250px;
    overflow: auto;
    background: #111;
    color: #e5e5e5;
    padding: 10px;
    border-radius: 4px;
    font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
    font-size: 12px;
    white-space: pre-wrap;
}

.ai-gallery-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.ai-gallery-backdrop {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.88) !important;
    background-image: none !important;
}

.ai-gallery-content {
    position: relative;
    width: min(92vw, 1400px);
    height: 90vh;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 0 48px;
}

.ai-gallery-image-wrap {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.ai-gallery-image-wrap img {
    max-width: 100%;
    max-height: min(72vh, 820px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    display: block;
}

.ai-gallery-caption {
    display: none;
    margin: 12px 0 0;
    padding: 0 12px;
    max-width: 100%;
    text-align: center;
    font-size: 0.95rem;
    line-height: 1.45;
    color: #e8e8e8;
    flex-shrink: 0;
}

.ai-gallery-close,
.ai-gallery-prev,
.ai-gallery-next {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.6) !important;
    background-image: none !important;
    color: #fff !important;
    border: 0 !important;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 18px;
    border-radius: 3px;
    -webkit-appearance: none !important;
    appearance: none !important;
    box-shadow: none !important;
}

.ai-gallery-close:hover,
.ai-gallery-prev:hover,
.ai-gallery-next:hover {
    background-color: rgba(0, 0, 0, 0.82) !important;
}

.ai-gallery-close:focus,
.ai-gallery-prev:focus,
.ai-gallery-next:focus {
    outline: none !important;
}

.ai-gallery-close:focus-visible,
.ai-gallery-prev:focus-visible,
.ai-gallery-next:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.55) !important;
    outline-offset: 2px;
}

.ai-gallery-close {
    top: 10px;
    right: 10px;
}

.ai-gallery-prev {
    left: -40px;
    top: 50%;
    transform: translateY(-50%);
}

.ai-gallery-next {
    right: -40px;
    top: 50%;
    transform: translateY(-50%);
}

/* Адаптивность */
@media (max-width: 768px) {
    .ai-image-generator-wrapper {
        padding: 14px;
        margin-left: 0;
        margin-right: 0;
        border-radius: var(--ai-radius-sm);
    }

    .ai-image-generator-form {
        flex-direction: column;
        gap: 18px;
    }

    .ai-image-form-right {
        max-height: 65vh;
        padding: 12px;
    }

    .ai-field-row {
        flex-direction: column;
    }

    .ai-field-row > div {
        flex: 0 0 auto;
        min-width: 100%;
    }

    .ai-gallery-prev {
        left: 5px;
    }

    .ai-gallery-next {
        right: 5px;
    }
}

/* Кнопка удаления готовых изображений */
.ai-clear-history-wrapper {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--ai-border);
    text-align: center;
}

.ai-clear-history-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--ai-btn-min-h);
    padding: var(--ai-btn-pad-y) var(--ai-btn-pad-x);
    background: linear-gradient(135deg, var(--ai-vk-accent) 0%, var(--ai-vk-hover-from) 100%);
    color: #fff;
    border: none;
    border-radius: var(--ai-btn-radius);
    cursor: pointer;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: inherit;
    box-shadow: 0 2px 10px rgba(249, 115, 22, 0.28);
    transition: filter 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.ai-clear-history-btn:hover {
    filter: brightness(1.05);
    box-shadow: 0 4px 14px rgba(249, 115, 22, 0.36);
}

.ai-clear-history-btn:focus-visible {
    outline: none;
    box-shadow: var(--ai-ring-vk);
}

.ai-clear-history-btn:active {
    transform: scale(0.98);
}

/* Попап подтверждения очистки */
.ai-clear-confirm-popup {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-clear-confirm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
}

.ai-clear-confirm-content {
    position: relative;
    background: #fff;
    border-radius: 8px;
    padding: 25px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 1;
}

.ai-clear-confirm-content h3 {
    margin: 0 0 15px 0;
    font-size: 20px;
    color: #333;
}

.ai-clear-confirm-content p {
    margin: 10px 0;
    font-size: 14px;
    color: #666;
    line-height: 1.5;
}

.ai-clear-history-confirm-popup .ai-clear-warning {
    color: #9a3412 !important;
    font-weight: 600;
    background: rgba(249, 115, 22, 0.1);
    padding: 10px 12px;
    border-radius: var(--ai-radius-sm);
    border-left: 3px solid var(--ai-vk-accent);
}

.ai-clear-confirm-buttons {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.ai-clear-confirm-yes,
.ai-clear-confirm-no,
.ai-image-generator-wrapper .ai-vk-dialog-ok,
.ai-image-generator-wrapper .ai-purchase-select-ok {
    padding: var(--ai-btn-pad-y) var(--ai-btn-pad-x);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: opacity 0.2s;
}

.ai-clear-history-confirm-popup .ai-clear-confirm-yes {
    background: linear-gradient(135deg, var(--ai-vk-accent) 0%, var(--ai-vk-hover-from) 100%);
    color: #fff;
    border-radius: var(--ai-btn-radius);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.3);
}

.ai-clear-history-confirm-popup .ai-clear-confirm-yes:hover {
    filter: brightness(1.05);
}

.ai-clear-history-confirm-popup .ai-clear-confirm-yes:focus-visible {
    outline: none;
    box-shadow: var(--ai-ring-vk);
}

.ai-clear-confirm-no {
    background-color: #f0f0f0;
    color: #333;
}

.ai-clear-confirm-no:hover {
    background-color: #e0e0e0;
}

.ai-image-generator-wrapper .ai-limit-message {
    white-space: pre-line;
}

.ai-limit-popup .ai-clear-confirm-buttons {
    justify-content: space-between;
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
}

.ai-image-generator-wrapper .ai-limit-pay-btn,
.ai-image-generator-wrapper .ai-limit-secondary-btn,
.ai-image-generator-wrapper .ai-limit-tertiary-btn {
    position: relative;
    min-width: 140px;
    min-height: var(--ai-btn-min-h);
    padding: var(--ai-btn-pad-y) var(--ai-btn-pad-x);
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: none;
    color: #fff !important;
    border: none !important;
    border-radius: var(--ai-btn-radius);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    -webkit-appearance: none;
    appearance: none;
}

.ai-image-generator-wrapper .ai-limit-pay-btn {
    background: linear-gradient(135deg, var(--ai-commerce-from) 0%, var(--ai-commerce-to) 100%) !important;
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.28);
}

.ai-image-generator-wrapper .ai-limit-secondary-btn {
    background: linear-gradient(135deg, var(--ai-cta-generate-from) 0%, var(--ai-cta-generate-to) 100%) !important;
    box-shadow: 0 2px 12px rgba(79, 70, 229, 0.35);
}

.ai-image-generator-wrapper .ai-limit-tertiary-btn {
    background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%) !important;
    box-shadow: 0 2px 12px rgba(91, 33, 182, 0.35);
}

.ai-image-generator-wrapper .ai-limit-pay-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(5, 150, 105, 0.38);
    background: linear-gradient(135deg, var(--ai-commerce-hover-from) 0%, var(--ai-commerce-hover-to) 100%) !important;
}

.ai-image-generator-wrapper .ai-limit-secondary-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.38);
    background: linear-gradient(135deg, var(--ai-cta-generate-hover-from) 0%, var(--ai-cta-generate-hover-to) 100%) !important;
}

.ai-image-generator-wrapper .ai-limit-tertiary-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(91, 33, 182, 0.38);
    background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%) !important;
}

.ai-image-generator-wrapper .ai-limit-pay-btn:focus-visible {
    outline: none;
    box-shadow: var(--ai-ring-commerce);
}

.ai-image-generator-wrapper .ai-limit-secondary-btn:focus-visible {
    outline: none;
    box-shadow: var(--ai-ring-generate);
}

@media (max-width: 480px) {
    .ai-clear-confirm-content {
        padding: 20px;
    }

    .ai-limit-popup .ai-clear-confirm-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .ai-clear-confirm-yes,
    .ai-clear-confirm-no,
    .ai-image-generator-wrapper .ai-limit-pay-btn,
    .ai-image-generator-wrapper .ai-limit-secondary-btn,
    .ai-image-generator-wrapper .ai-limit-tertiary-btn {
        width: 100%;
    }
}

/* ==========================================================================
   Виртуальные страницы /generation/: разметка как у Astra + полноширинный hero
   ========================================================================== */

.ai-gen-hero.ai-gen-hero--fullbleed {
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    box-sizing: border-box;
    /* min-height и background-position можно переопределить из настроек плагина (inline) */
    min-height: clamp(160px, 26vw, 300px);
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
}

.ai-generation-landing {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding: 20px 15px;
}

.ai-generation-landing--no-hero {
    /* Резерв для страниц с прозрачной шапкой поверх hero; на /generation/ переопределяется в ai-gen-homepage.css */
    padding-top: clamp(72px, 14vh, 140px);
}

.ai-generation-landing__title {
    margin: 0 0 16px;
    font-size: clamp(1.35rem, 3vw, 2rem);
    line-height: 1.2;
}

.ai-gen-breadcrumbs {
    margin: 0 0 12px;
    font-size: 0.9rem;
    color: var(--ai-muted, #64748b);
}

.ai-gen-seo-text {
    margin-top: 24px;
    font-family: var(--ai-font);
    color: var(--ai-text);
}

/* Типографика длинного SEO-текста (h2–h4 из редактора, без ручных классов) */
.ai-gen-seo-text__inner {
    line-height: 1.65;
}

.ai-gen-seo-text__inner h2 {
    font-size: clamp(1.25rem, 2.4vw, 1.65rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.28;
    margin: 0 0 0.75em;
    padding-bottom: 0.4em;
    border-bottom: 1px solid var(--ai-border);
    color: var(--ai-text);
}

.ai-gen-seo-text__inner h3 {
    font-size: clamp(1.05rem, 1.9vw, 1.22rem);
    font-weight: 650;
    line-height: 1.32;
    margin: 1.65em 0 0.5em;
    padding-left: 0.6rem;
    border-left: 3px solid var(--ai-accent);
    color: var(--ai-text);
}

.ai-gen-seo-text__inner h2 + h3 {
    margin-top: 1em;
}

.ai-gen-seo-text__inner h4 {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.38;
    margin: 1.35em 0 0.45em;
    color: #334155;
}

.ai-gen-seo-text__inner p {
    margin: 0.65em 0;
}

.ai-gen-seo-text__inner ul,
.ai-gen-seo-text__inner ol {
    margin: 0.6em 0 0.85em;
    padding-left: 1.35em;
}

.ai-gen-seo-text__inner li {
    margin: 0.4em 0;
}

.ai-gen-seo-text__inner li > p {
    margin: 0.35em 0;
}

.ai-gen-seo-text__inner a {
    color: var(--ai-accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.ai-gen-seo-text__inner a:hover {
    color: var(--ai-accent-hover);
}

.ai-gen-seo-text__inner > *:first-child {
    margin-top: 0;
}

.ai-gen-seo-text__inner > *:last-child {
    margin-bottom: 0;
}

.ai-gen-examples {
    margin-top: 24px;
}

.ai-gen-examples__grid {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 14px;
}

@media (min-width: 640px) {
    .ai-gen-examples__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px;
    }
}

@media (min-width: 992px) {
    .ai-gen-examples__grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 20px;
    }
}

.ai-gen-examples__figure {
    margin: 0;
}

.ai-gen-examples__payload {
    display: none !important;
}

.ai-gen-examples__open {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 14px;
    overflow: hidden;
    cursor: zoom-in;
    background: #111827;
    line-height: 0;
    aspect-ratio: 4 / 3;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.ai-gen-examples__open:hover,
.ai-gen-examples__open:focus-visible {
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.22);
    outline: none;
    transform: translateY(-2px);
}

.ai-gen-examples__open:focus-visible {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.45);
}

.ai-gen-examples__open img {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    object-fit: contain;
    object-position: center center;
    vertical-align: middle;
    display: block;
    transform: scale(1.2);
    transform-origin: center center;
    transition: transform 0.2s ease;
}

.ai-gen-ready-templates {
    margin-top: 32px;
    padding: 24px 20px 28px;
    background: #f6f7f7;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
}

.ai-gen-ready-templates__title {
    margin: 0 0 16px;
    color: #111827;
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.ai-gen-ready-templates__search-wrap {
    position: relative;
    margin: 0 0 20px;
    max-width: 480px;
}

.ai-gen-ready-templates__search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: #9ca3af;
    pointer-events: none;
}

.ai-gen-ready-templates__search-icon svg {
    display: block;
    width: 100%;
    height: 100%;
}

.ai-gen-ready-templates__search {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px 12px 44px;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    background: #fff;
    color: #111827;
    font: inherit;
    font-size: 0.9375rem;
    line-height: 1.3;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ai-gen-ready-templates__search::placeholder {
    color: #9ca3af;
}

.ai-gen-ready-templates__search:hover {
    border-color: #9ca3af;
}

.ai-gen-ready-templates__search:focus {
    outline: none;
    border-color: var(--ai-accent, #4f46e5);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.ai-gen-ready-templates__filters {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    margin: 0 0 20px;
    padding-bottom: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.ai-gen-ready-templates__filter {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 72px;
    max-width: 88px;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    color: #374151;
    font: inherit;
    cursor: pointer;
    text-align: center;
}

.ai-gen-ready-templates__filter-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    background: #fff;
    color: #374151;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.ai-gen-ready-templates__filter-icon svg {
    width: 24px;
    height: 24px;
}

.ai-gen-ready-templates__filter-label {
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.25;
    color: #4b5563;
}

.ai-gen-ready-templates__filter:hover .ai-gen-ready-templates__filter-icon {
    border-color: #c7d2fe;
    background: #f8fafc;
    color: #111827;
}

.ai-gen-ready-templates__filter.is-active .ai-gen-ready-templates__filter-icon {
    border-color: var(--ai-accent, #4f46e5);
    background: var(--ai-accent, #4f46e5);
    color: #fff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.22);
}

.ai-gen-ready-templates__filter.is-active .ai-gen-ready-templates__filter-label {
    color: #111827;
    font-weight: 600;
}

.ai-gen-ready-templates__filter:focus-visible .ai-gen-ready-templates__filter-icon {
    outline: 2px solid var(--ai-accent, #4f46e5);
    outline-offset: 2px;
}

.ai-gen-ready-templates__empty {
    margin: 0 0 20px;
    padding: 20px;
    border: 1px dashed #d1d5db;
    border-radius: 12px;
    background: #fff;
    text-align: center;
}

.ai-gen-ready-templates__empty-title {
    margin: 0 0 6px;
    color: #111827;
    font-size: 1rem;
    font-weight: 600;
}

.ai-gen-ready-templates__empty-hint {
    margin: 0 0 14px;
    color: #6b7280;
    font-size: 0.875rem;
}

.ai-gen-ready-templates__empty-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    border-radius: 999px;
    background: var(--ai-accent, #4f46e5);
    color: #fff !important;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none !important;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.ai-gen-ready-templates__empty-cta:hover,
.ai-gen-ready-templates__empty-cta:focus-visible {
    background: #4338ca;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
    color: #fff !important;
}

.ai-gen-ready-templates__card.is-filter-hidden {
    display: none;
}

.ai-gen-ready-templates__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

@media (min-width: 640px) {
    .ai-gen-ready-templates__grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 16px;
    }
}

@media (min-width: 992px) {
    .ai-gen-ready-templates {
        padding: 28px 24px 32px;
    }

    .ai-gen-ready-templates__grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 20px;
    }
}

.ai-gen-ready-templates__card {
    position: relative;
    aspect-ratio: 4 / 3;
    border-radius: 14px;
    overflow: hidden;
    background: #111827;
    border: 1px solid #374151;
    isolation: isolate;
}

.ai-gen-ready-templates__link {
    display: block;
    position: relative;
    width: 100%;
    height: 100%;
    color: inherit;
    text-decoration: none;
    outline: none;
}

.ai-gen-ready-templates__media {
    position: absolute;
    inset: 0;
    z-index: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0 42px;
    box-sizing: border-box;
    background: #111827;
    overflow: hidden;
}

.ai-gen-ready-templates__media img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: contain;
    object-position: center center;
    transform: scale(1.2);
    transform-origin: center center;
    transition: transform 0.35s ease;
}

.ai-gen-ready-templates__media--placeholder {
    background: linear-gradient(145deg, #e2e8f0 0%, #f1f5f9 52%, #cbd5e1 100%);
}

.ai-gen-ready-templates__footer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 8px;
    padding: 28px 12px 12px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.88) 0%, rgba(0, 0, 0, 0.45) 55%, transparent 100%);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.ai-gen-ready-templates__label {
    color: #ffffff;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.35;
    letter-spacing: -0.01em;
}

.ai-gen-ready-templates__arrow {
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.88);
    font-size: 1rem;
    line-height: 1;
    transform: translateY(1px);
    transition: transform 0.2s ease, color 0.2s ease;
}

.ai-gen-ready-templates__link:hover .ai-gen-ready-templates__media img,
.ai-gen-ready-templates__link:focus-visible .ai-gen-ready-templates__media img {
    transform: scale(1.236);
}

.ai-gen-ready-templates__link:hover .ai-gen-ready-templates__arrow,
.ai-gen-ready-templates__link:focus-visible .ai-gen-ready-templates__arrow {
    color: #ffffff;
    transform: translate(2px, 1px);
}

.ai-gen-ready-templates__link:focus-visible {
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.65);
    border-radius: 14px;
}

.ai-creative-landing .ai-generation-landing__title {
    margin-bottom: 20px;
}

.ai-gen-creative-grid {
    column-count: 1;
    column-gap: 16px;
    width: 100%;
    margin: 0 0 28px;
}

@media (min-width: 640px) {
    .ai-gen-creative-grid {
        column-count: 2;
        column-gap: 18px;
    }
}

@media (min-width: 1024px) {
    .ai-gen-creative-grid {
        column-count: 3;
        column-gap: 20px;
    }
}

.ai-gen-creative-card {
    position: relative;
    display: inline-block;
    width: 100%;
    margin: 0 0 16px;
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    page-break-inside: avoid;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.ai-gen-creative-card:hover,
.ai-gen-creative-card:focus-within {
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.12);
    transform: translateY(-1px);
}

.ai-gen-creative-card__link {
    display: block;
    line-height: 0;
}

.ai-gen-creative-card__img {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    vertical-align: top;
}

/* Доступность Comfy по кешу и отмена в очереди */
.ai-gen-comfy-health {
    font-size: 0.95rem;
    line-height: 1.4;
    color: #92400e;
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: 8px;
    padding: 10px 14px;
    margin: 0 0 14px;
}

.ai-image-generator-form button.ai-gen-queue-cancel {
    background: #c62828 !important;
    border-color: #b71c1c !important;
    color: #fff !important;
}

/* Аккаунт, баланс, приоритет очереди */
.ai-gen-verify-notice {
    margin: 0 0 12px;
    padding: 12px 14px;
    border-radius: var(--ai-btn-radius);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    text-align: center;
}

.ai-gen-verify-notice--ok {
    color: #047857;
    background: #ecfdf5;
    border: 1px solid #6ee7b7;
}

.ai-gen-verify-notice--error {
    color: #c62828;
    background: #ffebee;
    border: 1px solid #ef9a9a;
}

.ai-gen-auth-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    margin-bottom: 12px;
}

.ai-image-generator-wrapper .ai-gen-auth-email {
    font-size: 14px;
    color: var(--ai-muted);
}

/* Выйти — как неактивная вкладка «Изменение изображения», ширина по тексту */
.ai-image-generator-wrapper .ai-gen-btn-secondary,
.ai-image-generator-wrapper .ai-gen-auth-logout-btn.ai-gen-btn-secondary {
    flex: 0 0 auto;
    width: auto;
    min-height: var(--ai-btn-min-h);
    margin: 0;
    padding: var(--ai-btn-pad-y) var(--ai-btn-pad-x);
    border-radius: var(--ai-btn-radius);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: none;
    text-shadow: none;
    text-transform: none;
    -webkit-appearance: none;
    appearance: none;
    background: transparent !important;
    background-color: transparent !important;
    color: var(--ai-secondary-text) !important;
    border: 1px solid var(--ai-secondary-border) !important;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.ai-image-generator-wrapper .ai-gen-btn-secondary:hover,
.ai-image-generator-wrapper .ai-gen-auth-logout-btn.ai-gen-btn-secondary:hover {
    background: var(--ai-secondary-hover-bg) !important;
    color: var(--ai-text) !important;
    border-color: #94a3b8 !important;
}

.ai-image-generator-wrapper .ai-gen-btn-secondary:focus-visible,
.ai-image-generator-wrapper .ai-gen-auth-logout-btn.ai-gen-btn-secondary:focus-visible {
    outline: none;
    box-shadow: var(--ai-ring-secondary);
}

/* Пополнить баланс — круглая кнопка с «+» */
.ai-image-generator-wrapper .ai-gen-topup-btn,
.ai-gen-balance-toolbar .ai-gen-topup-btn {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    margin: 0;
    border: none !important;
    border-radius: 50%;
    background: var(--ai-accent) !important;
    color: #fff !important;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.32);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    -webkit-appearance: none;
    appearance: none;
    text-shadow: none !important;
}

.ai-image-generator-wrapper .ai-gen-topup-btn:hover:not(:disabled),
.ai-gen-balance-toolbar .ai-gen-topup-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    background: var(--ai-accent-hover) !important;
    color: #fff !important;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

.ai-image-generator-wrapper .ai-gen-topup-btn:focus-visible,
.ai-gen-balance-toolbar .ai-gen-topup-btn:focus-visible {
    outline: none;
    box-shadow: var(--ai-ring);
}

.ai-image-generator-wrapper .ai-gen-topup-btn:disabled,
.ai-gen-balance-toolbar .ai-gen-topup-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.ai-gen-topup-btn__icon {
    position: relative;
    display: block;
    width: 14px;
    height: 14px;
}

.ai-gen-topup-btn__icon::before,
.ai-gen-topup-btn__icon::after {
    content: '';
    position: absolute;
    background: #fff;
    border-radius: 1px;
}

.ai-gen-topup-btn__icon::before {
    left: 50%;
    top: 0;
    width: 2px;
    height: 100%;
    transform: translateX(-50%);
}

.ai-gen-topup-btn__icon::after {
    top: 50%;
    left: 0;
    width: 100%;
    height: 2px;
    transform: translateY(-50%);
}
.ai-gen-balance-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-bottom: 14px;
}
.ai-gen-balance-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    justify-content: flex-end;
}
.ai-gen-priority-block {
    margin: 12px 0 16px;
    padding: 12px 14px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.5);
}
.ai-gen-priority-layout {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 12px;
}
.ai-gen-priority-label-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.ai-gen-priority-left {
    flex: 1 1 auto;
    min-width: 0;
}
.ai-gen-priority-right {
    flex: 0 0 auto;
    margin-left: auto;
    display: flex;
    align-items: center;
}
.ai-gen-priority-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.ai-gen-priority-head .ai-gen-priority-label {
    margin: 0;
}
.ai-gen-priority-info-btn {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.22);
    background: #fff;
    color: #111;
    font-weight: 800;
    font-size: 13px;
    line-height: 1;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex: 0 0 auto;
}
.ai-gen-priority-info-btn:focus-visible {
    outline: none;
    box-shadow: var(--ai-ring, 0 0 0 2px rgba(27, 94, 32, 0.25));
}
.ai-gen-priority-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    position: relative;
    z-index: 1;
}
.ai-gen-priority-range {
    flex: 1 1 160px;
    min-width: 120px;
    position: relative;
    z-index: 2;
    margin: 0;
    padding: 0;
}
.ai-field .ai-gen-priority-input {
    min-height: 40px;
    text-align: center;
    padding-left: 2px;
    padding-right: 2px;
}
.ai-gen-priority-input-desktop {
    display: inline-block;
    width: 30px !important;
    min-width: 30px;
    max-width: 30px !important;
    padding: 0 !important;
    text-indent: 0;
}
.ai-gen-priority-mobile-input-wrap {
    display: none;
    margin-top: 10px;
}
.ai-gen-priority-mobile-input-wrap .ai-gen-priority-input-mobile {
    width: 100%;
}
.ai-gen-priority-position-line {
    margin: 10px 0 0;
    font-size: 0.92rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
}

.ai-gen-priority-pos {
    display: inline-block;
    min-width: 1.2em;
    font-weight: 700;
}

.ai-gen-queue-pos-dots {
    display: inline-flex;
    align-items: flex-end;
    gap: 1px;
    min-width: 1.4em;
    line-height: 1;
    vertical-align: baseline;
}

.ai-gen-queue-pos-dots span {
    display: inline-block;
    font-weight: 700;
    animation: ai-gen-queue-pos-dot 1s ease-in-out infinite;
}

.ai-gen-queue-pos-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.ai-gen-queue-pos-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes ai-gen-queue-pos-dot {
    0%,
    70%,
    100% {
        opacity: 0.2;
        transform: translateY(0);
    }
    35% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

.ai-gen-priority-balance-hint {
    margin: 8px 0 0;
    font-size: 0.88rem;
}

.ai-gen-priority-balance-hint[hidden] {
    display: none !important;
}
.ai-image-generator-wrapper .ai-gen-queue-view-btn {
    margin: 0;
    padding: 6px 12px;
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--ai-accent, #1b5e20) !important;
    background: #fff !important;
    border: 1px solid rgba(0, 0, 0, 0.18) !important;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    text-transform: none;
    box-shadow: none;
    transition: background 0.18s ease, border-color 0.18s ease;
}
.ai-image-generator-wrapper .ai-gen-queue-view-btn:hover {
    color: var(--ai-accent, #1b5e20) !important;
    border-color: var(--ai-accent-field-border, rgba(27, 94, 32, 0.45)) !important;
    background: rgba(27, 94, 32, 0.06) !important;
}
.ai-image-generator-wrapper .ai-gen-queue-view-btn:focus-visible {
    outline: none;
    color: var(--ai-accent, #1b5e20) !important;
    box-shadow: var(--ai-ring, 0 0 0 2px rgba(27, 94, 32, 0.25));
}
.ai-gen-queue-help-body p {
    margin: 6px 0;
}
@media (max-width: 782px) {
    .ai-gen-balance-toolbar {
        justify-content: flex-start;
    }
    .ai-gen-balance-bar {
        justify-content: flex-start;
    }
    .ai-gen-priority-layout {
        display: block;
    }
    .ai-gen-priority-right {
        display: none;
    }
    .ai-gen-priority-input-desktop {
        display: none;
    }
    .ai-gen-priority-mobile-input-wrap {
        display: block;
    }
}

/* Модальные окна входа / регистрации */
.ai-gen-auth-popup .ai-gen-auth-modal {
    max-width: 420px;
    width: min(420px, calc(100vw - 32px));
    padding: 22px 22px 24px;
    box-sizing: border-box;
}

.ai-gen-auth-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    margin-bottom: 18px;
    padding: 0 36px;
}

.ai-gen-auth-header h3 {
    margin: 0;
    text-align: center;
    font-size: 20px;
    font-weight: 700;
    color: var(--ai-text);
    line-height: 1.3;
}

.ai-gen-form-error {
    margin: 0 0 14px;
    padding: 0 4px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: #c62828;
    line-height: 1.35;
    white-space: pre-line;
}

.ai-gen-auth-popup .ai-clear-confirm-content .ai-gen-form-error {
    color: #dc3232 !important;
    font-size: 13px;
    font-weight: 600;
    white-space: pre-line;
}

.ai-gen-form-error:empty {
    display: none;
    margin: 0;
    padding: 0;
}

.ai-gen-auth-panel {
    position: relative;
}

.ai-gen-auth-busy-overlay {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 3;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.72);
    border-radius: var(--ai-radius-sm);
    pointer-events: none;
}

.ai-gen-auth-panel.is-busy .ai-gen-auth-busy-overlay {
    display: flex;
}

.ai-gen-auth-spinner {
    width: 36px;
    height: 36px;
    border-width: 3px;
}

.ai-gen-auth-panel.is-busy {
    pointer-events: none;
}

.ai-gen-auth-panel.is-busy .ai-gen-auth-close {
    pointer-events: auto;
}

.ai-gen-auth-btn-primary .ai-gen-btn-spinner {
    display: none;
    position: absolute;
    left: 50%;
    top: 50%;
    width: 22px;
    height: 22px;
    margin: -11px 0 0 -11px;
    border-width: 3px;
}

.ai-gen-auth-panel.is-busy .ai-gen-auth-btn-primary .ai-gen-btn-spinner {
    display: block;
}

.ai-gen-auth-panel.is-busy .ai-gen-auth-btn-primary .ai-gen-btn-text {
    visibility: hidden;
}

.ai-gen-auth-btn-primary:disabled {
    opacity: 0.85;
    cursor: wait;
    transform: none !important;
}

.ai-gen-auth-close {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: var(--ai-radius-sm);
    background: transparent;
    color: var(--ai-muted);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
}

.ai-gen-auth-close:hover,
.ai-gen-auth-close:focus-visible {
    color: var(--ai-text);
    background: var(--ai-surface-2);
    outline: none;
}

.ai-gen-auth-body,
.ai-gen-auth-popup .ai-gen-auth-step {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.ai-gen-auth-field {
    margin: 0 0 14px;
}

.ai-gen-auth-label-row {
    position: relative;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}

.ai-gen-auth-label-row .ai-gen-auth-label {
    margin-bottom: 0;
}

.ai-gen-auth-hint-trigger {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin: 0;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 50%;
    background: #fff;
    color: var(--ai-muted);
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    font-family: inherit;
    cursor: help;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.ai-gen-auth-hint-trigger:hover,
.ai-gen-auth-hint-trigger:focus-visible {
    color: var(--ai-accent);
    border-color: var(--ai-accent-field-border);
    background: var(--ai-surface-2);
    outline: none;
}

.ai-gen-auth-tooltip {
    position: absolute;
    left: 0;
    top: calc(100% + 6px);
    z-index: 5;
    display: none;
    max-width: min(320px, calc(100vw - 48px));
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.45;
    color: var(--ai-text);
    background: #fff;
    border: 1px solid var(--ai-border);
    border-radius: var(--ai-radius-sm);
    box-shadow: var(--ai-shadow);
}

.ai-gen-auth-label-row.is-tooltip-open .ai-gen-auth-tooltip,
.ai-gen-auth-hint-trigger:hover + .ai-gen-auth-tooltip,
.ai-gen-auth-hint-trigger:focus-visible + .ai-gen-auth-tooltip {
    display: block;
}

.ai-gen-auth-label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--ai-text);
}

.ai-gen-auth-password-wrap {
    position: relative;
    width: 100%;
}

.ai-gen-auth-password-wrap .ai-gen-auth-input {
    padding-right: 44px;
}

.ai-gen-auth-toggle-pw {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: var(--ai-radius-sm);
    background: transparent;
    color: var(--ai-muted);
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
}

.ai-gen-auth-toggle-pw:hover,
.ai-gen-auth-toggle-pw:focus-visible {
    color: var(--ai-text);
    background: var(--ai-surface-2);
    outline: none;
}

.ai-gen-auth-eye {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}

.ai-gen-auth-toggle-pw .ai-gen-auth-eye--on {
    display: none;
}

.ai-gen-auth-toggle-pw.is-visible .ai-gen-auth-eye--off {
    display: none;
}

.ai-gen-auth-toggle-pw.is-visible .ai-gen-auth-eye--on {
    display: flex;
}

.ai-gen-auth-input {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-height: var(--ai-btn-min-h);
    padding: 10px 12px;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.4;
    color: var(--ai-text);
    background: var(--ai-surface);
    border: 1px solid var(--ai-border);
    border-radius: var(--ai-btn-radius);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ai-gen-auth-input:focus {
    outline: none;
    border-color: var(--ai-accent-field-border);
    box-shadow: var(--ai-ring);
}

.ai-gen-auth-field .ai-gen-field-error {
    display: block;
    margin: 6px 0 0;
    font-size: 12px;
    font-weight: 600;
    color: #c62828;
    line-height: 1.35;
    min-height: 0;
}

.ai-gen-auth-field .ai-gen-field-error:empty {
    display: none;
}

.ai-gen-auth-input.ai-size-invalid {
    border-color: #c62828 !important;
    box-shadow: 0 0 0 1px #c62828;
}

.ai-gen-auth-forgot-wrap {
    margin: -4px 0 16px;
    text-align: left;
}

.ai-gen-auth-forgot-link {
    margin: 0;
    padding: 0;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: var(--ai-accent);
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.ai-gen-auth-forgot-link:hover,
.ai-gen-auth-forgot-link:focus-visible {
    color: var(--ai-accent-hover);
    outline: none;
}

.ai-gen-auth-actions {
    display: flex;
    justify-content: flex-start;
    margin-top: 4px;
}

.ai-gen-auth-btn-primary {
    position: relative;
    min-width: 140px;
    min-height: var(--ai-btn-min-h);
    padding: var(--ai-btn-pad-y) var(--ai-btn-pad-x);
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #fff !important;
    background: linear-gradient(135deg, var(--ai-commerce-from) 0%, var(--ai-commerce-to) 100%) !important;
    border: none !important;
    border-radius: var(--ai-btn-radius);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.28);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    -webkit-appearance: none;
    appearance: none;
}

.ai-gen-auth-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(5, 150, 105, 0.38);
    color: #fff !important;
    background: linear-gradient(135deg, var(--ai-commerce-hover-from) 0%, var(--ai-commerce-hover-to) 100%) !important;
}

.ai-gen-auth-btn-primary:focus-visible {
    outline: none;
    box-shadow: var(--ai-ring-commerce);
}

.ai-gen-auth-hint {
    margin: 0 0 12px;
    font-size: 14px;
    color: var(--ai-muted);
    text-align: center;
    line-height: 1.45;
}

.ai-gen-auth-field .ai-gen-topup-limits-hint {
    margin: 4px 0 0;
    font-size: 12px;
    text-align: left;
    font-weight: 500;
}

.ai-gen-auth-popup .ai-gen-auth-error {
    display: none !important;
}

@media (max-width: 480px) {
    .ai-gen-auth-popup .ai-gen-auth-modal {
        padding: 18px 16px 20px;
    }

    .ai-gen-auth-header {
        margin-bottom: 14px;
        padding: 0 32px;
    }

    .ai-gen-auth-header h3 {
        font-size: 18px;
    }

    .ai-gen-auth-btn-primary {
        width: 100%;
    }

    .ai-gen-auth-actions {
        width: 100%;
    }
}

.ai-gen-legal-consent {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0 0 14px;
}

.ai-field.ai-gen-legal-consent > .ai-gen-legal-consent-item,
.ai-gen-legal-consent .ai-gen-legal-consent-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
    font-size: 14px;
    line-height: 1.45;
    font-weight: 400;
    letter-spacing: normal;
    cursor: pointer;
}

.ai-field.ai-gen-legal-consent > .ai-gen-legal-consent-item span,
.ai-field.ai-gen-legal-consent > .ai-gen-legal-consent-item a,
.ai-gen-legal-consent .ai-gen-legal-consent-item span,
.ai-gen-legal-consent .ai-gen-legal-consent-item a {
    font-weight: inherit;
}

.ai-gen-legal-consent-item input[type="checkbox"] {
    margin: 3px 0 0;
    flex-shrink: 0;
}

.ai-gen-legal-consent-item a {
    color: inherit;
    text-decoration: underline;
}

.ai-gen-legal-consent-item a:hover,
.ai-gen-legal-consent-item a:focus-visible {
    text-decoration: none;
}

.ai-gen-legal-consent-error {
    margin: 0;
    font-size: 13px;
}

.ai-gen-legal-consent-error:empty {
    display: none;
}

.ai-gen-legal-consent-error:not(:empty) {
    color: #c62828;
    font-weight: 600;
}

.ai-gen-auth-popup .ai-gen-legal-consent {
    margin-bottom: 12px;
}

