* {
    box-sizing: border-box;
}

:root {
    --ai-blue: #0802f5;
    --ai-blue-hover: #415bfe;
    --ai-red: #d90101;
    --ai-green: #03911f;
    --ai-yellow: #ffcd05;
}

body {
    color: #111827;
}

.ai-rws-section {
    margin-top: 7px;
    margin-bottom: 60px;
    border: 0px solid blue;
    scroll-margin-top: 20px;
    scroll-behavior: smooth;
}

/* Prefer dynamic viewport units where supported */
@supports (height: 100dvh) {
    .ai-rws-section {
        min-height: calc(100dvh - 110px);
    }
}

/* Desktop tuning */
@media (min-width: 768px) {
    .ai-rws-section {
        min-height: calc(100svh - 95px);
    }

    @supports (height: 100dvh) {
        .ai-rws-section {
            min-height: calc(100dvh - 95px);
        }
    }
}

/* Mobile: your rows="8" already works well, so keep it gentle */
@media (max-width: 520px) {
    .ai-rws-section {
        min-height: calc(100svh - 75px);
        margin-bottom: 28px;
    }

    @supports (height: 100dvh) {
        .ai-rws-section {
            min-height: calc(100dvh - 75px);
        }
    }
}

.ai-header {
    text-align: center;
    padding: 10px 0 18px;
}

.ai-header h1 {
    margin: 0;
    font-size: clamp(2rem, 8vw, 3.3rem);
    line-height: 1.2 !important;
    letter-spacing: -0.04em;
}

.ai-header p {
    margin: 12px auto 0;
    max-width: 560px;
    color: #4b5563;
    font-size: 1rem;
}

.ai-logo {
    width: 44px;
    height: 44px;
    margin: 0 auto 10px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: #111827;
    color: #fff;
    font-weight: 800;
}

.ai-card {
    background: #fff;
    border-radius: 22px;
    padding: 16px;
    box-shadow: 0 16px 45px rgba(15, 23, 42, 0.08);
    margin-bottom: 60px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
}

textarea {
    width: 100%;
    min-height: 138px;
    resize: vertical;
    border: 1px solid #d1d5db;
    border-radius: 16px;
    padding: 14px;
    font: inherit;
    font-size: 1rem;
    outline: none;
}

.ai-card textarea,
#aiPrompt {
    font-size: 18px !important;
    line-height: 1.5 !important;
    font-family: 'Montserrat', Arial, sans-serif !important;
    min-height: 120px;
    height: clamp(120px, 18vh, 150px);
}

textarea:focus,
select:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.14);
}

.ai-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 12px;
    align-items: stretch;
}

#aiGenerateButton {
    grid-column: 1 / -1;
}

select,
button,
.ai-result-buttons a,
.ai-image-reference-button {
    min-height: 50px;
    border-radius: 15px;
    border: 0;
    font: inherit;
    font-size: 18px !important;
    line-height: 1.2 !important;
    font-weight: 800;
}

select {
    width: 100%;
    padding: 0 12px;
    background: #f8fafc;
    border: 1px solid #d1d5db;
    color: #111827;
}

button,
.ai-result-buttons a,
.ai-image-reference-button {
    cursor: pointer;
    text-decoration: none;
    display: grid;
    place-items: center;
    padding: 0 16px;
}

button:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    -webkit-filter: none !important;
}

#aiInputImage {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
}

.ai-image-reference-button {
    background: var(--ai-yellow) !important;
    color: #000000 !important;
    margin: 0;
    text-align: center;
}

.ai-image-reference-button:hover {
    -webkit-filter: brightness(110%) !important;
    cursor: pointer;
    color: #000000 !important;
}

.ai-note {
    margin: 10px 0 0;
    color: #6b7280;
    font-size: 1.5rem;
    text-align: center;
}

.ai-progress {
    margin-top: 18px;
    padding: 20px 14px;
    text-align: center;
    border-radius: 18px;
    background: #f8fafc;
}

.ai-loader {
    width: 42px;
    height: 42px;
    border: 4px solid #e5e7eb;
    border-top-color: var(--ai-blue) !important;
    border-radius: 50%;
    margin: 0 auto 10px;
    animation: aiSpin 1s linear infinite;
}

@keyframes aiSpin {
    to {
        transform: rotate(360deg);
    }
}

.ai-progress p {
    margin: 0 0 12px;
    font-weight: 700;
}

.ai-bar {
    height: 10px;
    border-radius: 999px;
    background: #e5e7eb;
    overflow: hidden;
}

#aiProgressBarFill {
    width: 0%;
    height: 100%;
    background: var(--ai-blue) !important;
    transition: width 0.4s ease;
}

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

.ai-image-preview-wrap {
    margin-top: 14px;
    border: 1px solid #d9d9d9;
    border-radius: 12px;
    padding: 12px;
    background: #fafafa;
}

.ai-image-preview-wrap img {
    display: block;
    max-width: 100%;
    max-height: 280px;
    height: auto;
    border-radius: 10px;
    margin: 0 auto 12px;
}

.ai-reference-actions {
    display: grid;
    grid-template-columns: 1fr 1.6fr;
    gap: 10px;
    align-items: stretch;
    margin-top: 12px;
}

#aiStrength {
    min-height: 50px;
    border-radius: 15px;
    border: 1px solid #d1d5db;
    font: inherit;
    font-size: 18px !important;
    line-height: 1.2 !important;
    font-weight: 800;
    padding: 0 12px;
    background: #f8fafc;
    color: #111827;
}

#aiRemoveImageButton {
    border: 0;
    border-radius: 10px;
    padding: 10px 14px;
    cursor: pointer;
}

.ai-result {
    margin-top: 18px;
    text-align: center;
}

.ai-result img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 18px;
    background: #e5e7eb;
}

.ai-result-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 12px;
}

.ai-simple-content {
    margin: 16px 0 0;
    padding: 18px;
    border-radius: 20px;
    background: #fff;
    color: #374151;
}

.ai-simple-content h2 {
    margin: 22px 0 6px;
    font-size: 1.2rem;
    color: #111827;
}

.ai-simple-content h2:first-child {
    margin-top: 0;
}

.ai-simple-content p {
    margin: 0 0 10px;
}

.ai-links {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 18px !important;
}

.ai-links a {
    color: #111827;
    font-weight: 700;
}

.ai-steps {
    display: grid;
    gap: 12px;
    margin: 16px 0 18px;
}

.ai-step {
    display: grid;
    grid-template-columns: 44px 1fr;
    gap: 12px;
    align-items: start;
    padding: 14px;
    border-radius: 16px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
}

.ai-step-number {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--ai-blue);
    color: #ffffff;
    font-weight: 900;
    line-height: 1;
}

.ai-step h3 {
    margin: 0 0 4px;
    color: #111827;
    font-weight: 900;
    line-height: 1.55;
}

.ai-step h3 em {
    display: inline-block;
    margin-left: 6px;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--ai-yellow);
    color: #000000;
    font-style: normal;
    font-weight: 900;
    vertical-align: middle;
}

.ai-step p {
    margin: 0;
    color: #374151;
    line-height: 1.45;
}

.ai-privacy-note {
    margin-top: 14px !important;
    padding: 12px 14px;
    border-radius: 14px;
    background: #eef2ff;
    color: #1f2937;
    font-weight: 700;
}

/* Reusable colour classes for AI generator buttons */
.ai-card .btn-blue,
.ai-result-buttons .btn-blue {
    background-color: var(--ai-blue) !important;
    border-color: var(--ai-blue) !important;
    color: #ffffff !important;
}

.ai-card .btn-blue:hover,
.ai-result-buttons .btn-blue:hover {
    background-color: var(--ai-blue-hover) !important;
    border-color: var(--ai-blue-hover) !important;
    cursor: pointer;
    color: #ffffff !important;
}

.ai-card .btn-red,
.ai-result-buttons .btn-red {
    background-color: var(--ai-red) !important;
    border-color: var(--ai-red) !important;
    color: #ffffff !important;
}

.ai-card .btn-red:hover,
.ai-result-buttons .btn-red:hover {
    -webkit-filter: brightness(130%) !important;
    cursor: pointer;
    color: #ffffff !important;
}

.ai-card .btn-green,
.ai-result-buttons .btn-green {
    background-color: var(--ai-green) !important;
    border-color: var(--ai-green) !important;
    color: #ffffff !important;
}

.ai-card .btn-green:hover,
.ai-result-buttons .btn-green:hover {
    -webkit-filter: brightness(120%) !important;
    cursor: pointer;
    color: #ffffff !important;
}

.ai-card .btn-yellow,
.ai-result-buttons .btn-yellow {
    background-color: var(--ai-yellow) !important;
    border-color: var(--ai-yellow) !important;
    color: #000000 !important;
}

.ai-card .btn-yellow:hover,
.ai-result-buttons .btn-yellow:hover {
    -webkit-filter: brightness(110%) !important;
    cursor: pointer;
    color: #000000 !important;
}

.ai-card button:disabled,
.ai-result-buttons button:disabled,
.ai-card .btn-red:disabled,
.ai-card .btn-green:disabled,
.ai-card .btn-blue:disabled,
.ai-card .btn-yellow:disabled {
    opacity: 0.55 !important;
    cursor: not-allowed !important;
    -webkit-filter: none !important;
}

@media (max-width: 520px) {
    .ai-page {
        padding: 12px 10px 34px;
    }

    .ai-card {
        padding: 14px;
        border-radius: 20px;
    }

    .ai-controls {
        grid-template-columns: 1fr 1fr;
    }

    .ai-image-reference-button {
        width: 100%;
    }

    .ai-result-buttons {
        grid-template-columns: 1fr;
    }

    .ai-reference-actions {
        grid-template-columns: 1fr;
    }

    .ai-card textarea,
    #aiPrompt {
        font-size: 17px !important;
        min-height: 200px;
    }

    .ai-step {
        grid-template-columns: 38px 1fr;
        gap: 10px;
        padding: 12px;
    }

    .ai-step-number {
        width: 38px;
        height: 38px;
    }
}

/* Desktop: make the generator card fill most of the first viewport */
@media (min-width: 768px) {
    .ai-card textarea,
    #aiPrompt {
        min-height: clamp(260px, 38vh, 420px);
    }

    .ai-card {
        margin-bottom: 32px;
    }
}

/* Taller desktop screens can take a slightly larger prompt box */
@media (min-width: 1024px) and (min-height: 800px) {
    .ai-card textarea,
    #aiPrompt {
        min-height: clamp(320px, 47vh, 500px);
    }
}

/* Shorter laptops: avoid making the form too tall */
@media (min-width: 768px) and (max-height: 720px) {
    .ai-card textarea,
    #aiPrompt {
        min-height: clamp(230px, 32vh, 340px);
    }
}



.modal-dialog {
    position: relative !important; 
    
}

#aiResetPromptButton {
    grid-column: 1 / -1;
}

.ai-reset-prompt-button {
    min-height: 42px;
    width: 54px;
    justify-self: center;
    border-radius: 999px;
    border: 1px solid #d1d5db;
    background: #f8fafc;
    color: #111827;
    font-size: 18px !important;
    font-weight: 800;
    display: grid;
    place-items: center;
    padding: 0;
    cursor: pointer;
}

.ai-reset-prompt-button:hover {
    background: #eef2ff;
    border-color: #0802f5;
    color: #0802f5;
    cursor: pointer;
}

.ai-reset-prompt-button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.ai-image-reference-button.ai-disabled {
    opacity: 0.55;
    cursor: not-allowed !important;
    pointer-events: none;
}


.ai-link-to-page-wrap {
    display: flex;
    justify-content: center;
    margin-top: 14px;
}

.ai-link-to-page-button {
    min-height: 44px;
    border-radius: 999px;
    border: 1px solid #d1d5db;
    background: #f8fafc;
    color: #111827;
    font-size: 15px !important;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 18px;
    cursor: pointer;
}

.ai-link-to-page-button:hover {
    background: #eef2ff;
    border-color: var(--ai-blue);
    color: var(--ai-blue);
}

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

.ai-link-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: grid;
    place-items: center;
    padding: 18px;
}

.ai-link-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, 0.58);
}

.ai-link-modal-box {
    position: relative;
    width: min(420px, 100%);
    background: #ffffff;
    border-radius: 18px;
    padding: 18px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
    z-index: 1;
    text-align: center;
}

.ai-link-modal-box h2 {
    margin: 0 36px 12px;
    font-size: 1.8rem;
    line-height: 1.25;
}

.ai-link-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 34px;
    min-height: 34px;
    height: 34px;
    border-radius: 999px;
    padding: 0;
    background: #f3f4f6;
    color: #111827;
    border: 1px solid #d1d5db;
    display: grid;
    place-items: center;
    cursor: pointer;
}

.ai-link-modal-close:hover {
    background: #fee2e2;
    color: #991b1b;
}

#aiLinkHtmlCode {
    width: 100%;
    min-height: 92px;
    resize: none;
    font-family: Consolas, Monaco, monospace !important;
    font-size: 13px !important;
    line-height: 1.45 !important;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    padding: 10px;
    background: #f8fafc;
    color: #111827;
}

.ai-copy-link-code-button {
    margin: 12px auto 0;
    width: 46px;
    min-width: 46px;
    min-height: 46px;
    height: 46px;
    border-radius: 999px;
    padding: 0;
    background: var(--ai-blue);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    cursor: pointer;
    white-space: nowrap;
}

.ai-copy-link-code-button:hover {
    background: var(--ai-blue-hover);
}

.ai-copy-link-code-button.ai-copy-success {
    width: auto;
    min-width: 110px;
    padding: 0 16px;
    background: var(--ai-green);
}

.ai-copy-link-code-button .ai-copied-icon,
.ai-copy-link-code-button .ai-copy-status {
    display: none;
}

.ai-copy-link-code-button.ai-copy-success .ai-copy-icon {
    display: none;
}

.ai-copy-link-code-button.ai-copy-success .ai-copied-icon,
.ai-copy-link-code-button.ai-copy-success .ai-copy-status {
    display: inline-flex;
    align-items: center;
}

.ai-copy-status {
    font-size: 14px;
    font-weight: 800;
    line-height: 1;
}



html[dir="rtl"] .ai-link-modal-close {
    right: auto;
    left: 10px;
}


/* Private gallery additions */
.ai-secondary-actions-wrap {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.ai-private-gallery-top-button,
.ai-save-gallery-button,
.ai-view-gallery-button {
    min-height: 50px;
    border-radius: 15px;
    border: 0;
    font: inherit;
    font-size: 18px !important;
    line-height: 1.2 !important;
    font-weight: 800;
    text-decoration: none !important;
    display: grid;
    place-items: center;
    padding: 0 16px;
    cursor: pointer;
}

.ai-private-gallery-top-button {
    background: var(--ai-yellow) !important;
    color: #000 !important;
    gap: 8px;
    grid-auto-flow: column;
}

.ai-save-gallery-button {
    color: #000 !important;
}

.ai-gallery-page .ai-card {
    margin-bottom: 24px;
}

.ai-gallery-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.ai-gallery-toolbar-left,
.ai-gallery-toolbar-right {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.ai-gallery-note {
    background: #fff8d7;
    border: 1px solid #f4d35e;
    border-radius: 15px;
    color: #3d3300;
    padding: 12px 14px;
    font-weight: 700;
    margin: 0 0 14px;
}

.ai-gallery-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 0 0 16px;
}

.ai-gallery-breadcrumb button {
    min-height: 38px;
    font-size: 14px !important;
    border-radius: 999px;
    padding: 0 12px;
    background: #eef2ff;
    color: #1e1b4b;
}

.ai-private-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    gap: 14px;
}

.ai-gallery-card {
    position: relative;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    overflow: hidden;
    min-height: 155px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.07);
}

.ai-gallery-card[draggable="true"] {
    cursor: grab;
}

.ai-gallery-card.ai-drop-target {
    outline: 4px solid var(--ai-yellow);
    outline-offset: 2px;
}

.ai-gallery-image-card img {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    object-fit: cover;
    background: #e5e7eb;
}

.ai-gallery-folder-card {
    display: grid;
    place-items: center;
    padding: 16px;
    text-align: center;
}

.ai-gallery-folder-icon {
    font-size: 58px;
    color: #f6b800;
    line-height: 1;
    margin-bottom: 8px;
}

.ai-gallery-folder-name,
.ai-gallery-image-name {
    font-weight: 800;
    color: #111827;
    word-break: break-word;
    padding: 0 8px 8px;
}

.ai-gallery-overlay-actions {
    position: absolute;
    inset: 8px 8px auto auto;
    display: flex;
    gap: 6px;
    z-index: 2;
}

.ai-gallery-icon-button {
    width: 38px;
    height: 38px;
    min-height: 38px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    padding: 0;
    background: rgba(17, 24, 39, 0.95);
    color: #fff !important;
    text-decoration: none !important;
    font-size: 15px !important;
}

.ai-gallery-delete-button {
    background: rgba(217, 1, 1, 0.95) !important;
}

.ai-gallery-empty {
    text-align: center;
    color: #4b5563;
    padding: 30px 12px;
    font-weight: 700;
}

.ai-gallery-root-drop {
    border: 2px dashed #cbd5e1;
    border-radius: 16px;
    padding: 10px 12px;
    font-weight: 800;
    color: #334155;
    background: #f8fafc;
    margin-bottom: 14px;
}

.ai-gallery-root-drop.ai-drop-target {
    border-color: var(--ai-yellow);
    background: #fffbeb;
}

@media (max-width: 520px) {
    .ai-secondary-actions-wrap,
    .ai-result-buttons {
        grid-template-columns: 1fr !important;
    }

    .ai-private-gallery-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .ai-gallery-toolbar,
    .ai-gallery-toolbar-left,
    .ai-gallery-toolbar-right {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }
}


/* Private gallery v2 adjustments */
.ai-controls #aiPrivateGalleryTopButton {
    width: 100%;
    text-align: center;
    justify-content: center;
    align-items: center;
    gap: 0 !important;
}

.ai-controls #aiPrivateGalleryTopButton i {
    display: none !important;
}

.ai-private-gallery-top-button.btn-yellow {
    background: var(--ai-yellow) !important;
    color: #000 !important;
}

.ai-private-gallery-top-button.btn-yellow:hover {
    -webkit-filter: brightness(110%) !important;
    filter: brightness(110%) !important;
    color: #000 !important;
}

.ai-result-image-link {
    display: block;
    text-decoration: none !important;
    cursor: zoom-in;
}

.ai-result-image-link img {
    display: block;
}

.ai-result-buttons {
    grid-template-columns: 1fr 1fr;
}

.ai-result-buttons .ai-save-gallery-button {
    width: 100%;
}

.ai-gallery-breadcrumb {
    gap: 6px;
}

.ai-gallery-breadcrumb-separator {
    display: inline-flex;
    align-items: center;
    color: #64748b;
    font-weight: 900;
    padding: 0 2px;
}

.ai-gallery-breadcrumb button.ai-drop-target {
    outline: 3px solid var(--ai-yellow);
    outline-offset: 2px;
    background: #fffbeb;
}

@media (max-width: 520px) {
    .ai-controls {
        grid-template-columns: 1fr 1fr;
    }

    .ai-controls #aiPrivateGalleryTopButton span {
        text-align: center;
    }

    .ai-result-buttons {
        grid-template-columns: 1fr !important;
    }
}


/* Private gallery v3 refinements */
.ai-link-to-page-wrap.ai-secondary-actions-wrap {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    grid-template-columns: none !important;
    width: 100% !important;
    margin-top: 14px !important;
}

.ai-link-to-page-wrap.ai-secondary-actions-wrap #aiLinkToPageButton {
    margin-left: auto !important;
    margin-right: auto !important;
}

.ai-gallery-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.ai-gallery-breadcrumb-separator {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-weight: 900;
    padding: 0 2px;
    line-height: 1;
}

.ai-gallery-card {
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.ai-gallery-touch-ghost {
    position: fixed;
    z-index: 999999;
    width: 112px;
    height: 112px;
    pointer-events: none;
    opacity: 0.82;
    transform: translate(-50%, -50%);
    border-radius: 16px;
    box-shadow: 0 18px 38px rgba(15, 23, 42, 0.28);
    overflow: hidden;
    background: #ffffff;
}

.ai-gallery-touch-ghost img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ai-gallery-touch-ghost .ai-gallery-folder-icon {
    height: 100%;
    display: grid;
    place-items: center;
    font-size: 54px;
    color: #f8b400;
}

.ai-gallery-touch-dragging {
    opacity: 0.45;
}


/* Batch generation additions */
.ai-controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

#aiGenerateButton,
#aiResetPromptButton {
    grid-column: 1 / -1;
}

.ai-batch-summary {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 14px;
    background: #eef2ff;
    color: #1f2937;
    font-weight: 800;
    text-align: center;
}

.ai-batch-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.ai-batch-card {
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    background: #f8fafc;
    padding: 12px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.05);
}

.ai-batch-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    font-weight: 800;
}

.ai-batch-card-status {
    font-size: 14px;
    color: #475569;
}

.ai-batch-card-preview {
    border-radius: 14px;
    overflow: hidden;
    background: #e5e7eb;
    min-height: 160px;
    display: grid;
    place-items: center;
}

.ai-batch-card-preview img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 14px;
}

.ai-batch-card-placeholder {
    padding: 18px;
    text-align: center;
    color: #475569;
    font-weight: 700;
}

.ai-batch-card-meta {
    margin: 10px 0 8px;
    color: #475569;
    font-size: 14px;
    min-height: 20px;
}

.ai-batch-card-bar {
    height: 10px;
    border-radius: 999px;
    background: #e5e7eb;
    overflow: hidden;
}

.ai-batch-card-bar-fill {
    width: 0%;
    height: 100%;
    background: var(--ai-blue) !important;
    transition: width 0.4s ease;
}

.ai-batch-card.ai-batch-success .ai-batch-card-bar-fill {
    width: 100% !important;
}

.ai-batch-card.ai-batch-failed .ai-batch-card-bar-fill {
    width: 100% !important;
    background: var(--ai-red) !important;
}

.ai-batch-card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 12px;
}

.ai-batch-card-actions a,
.ai-batch-card-actions button {
    width: 100%;
}

.ai-batch-card-cost {
    display: inline-block;
    margin-top: 6px;
    font-weight: 800;
    color: #111827;
}

@media (max-width: 520px) {
    .ai-controls {
        grid-template-columns: 1fr !important;
    }

    .ai-batch-grid,
    .ai-batch-card-actions {
        grid-template-columns: 1fr !important;
    }
}


/* Batch UI v2 tidy-up */
.ai-batch-card-header {
    display: none !important;
}

.ai-batch-card-meta:empty {
    display: none;
}

.ai-batch-card-actions a,
.ai-batch-card-actions button,
.ai-batch-card-actions .btn-blue,
.ai-batch-card-actions .btn-yellow {
    border-radius: 999px !important;
    min-height: 46px;
    padding: 12px 18px !important;
    font-weight: 800;
    text-align: center;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}


/* Batch UI v4 */
.ai-batch-card-placeholder:empty {
    display: none;
}

.ai-batch-image-link {
    display: block;
    width: 100%;
}

.ai-batch-image-link img {
    cursor: zoom-in;
}

.ai-batch-card-bar[hidden] {
    display: none !important;
}


/* v5 layout refinements */
@media (min-width: 521px) {
    .ai-controls {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 58px !important;
    }

    #aiAspectRatio {
        grid-column: 1 / 2 !important;
    }

    #aiBatchSize {
        grid-column: 2 / 4 !important;
    }

    #aiGenerateButton {
        grid-column: 1 / -1 !important;
    }

    .ai-controls #aiPrivateGalleryTopButton {
        grid-column: 1 / 3 !important;
        width: auto !important;
        min-width: 220px;
        max-width: 280px;
        justify-self: end;
    }

    #aiResetPromptButton {
        grid-column: 3 / 4 !important;
        width: 58px !important;
        min-width: 58px !important;
        justify-self: end;
    }

    .ai-batch-grid {
        grid-template-columns: repeat(var(--ai-batch-count, 2), minmax(0, 1fr)) !important;
    }

    .ai-batch-card-preview {
        min-height: 118px;
    }
}

@media (max-width: 520px) {
    .ai-rws-section {
        margin-top: 0 !important;
    }

    .ai-rws-section > h1 {
        margin-top: 0 !important;
    }

    .ai-controls {
        grid-template-columns: 1fr !important;
    }

    #aiAspectRatio,
    #aiBatchSize,
    #aiGenerateButton,
    .ai-controls #aiPrivateGalleryTopButton,
    #aiResetPromptButton {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        max-width: none !important;
    }

    .ai-controls #aiPrivateGalleryTopButton {
        justify-self: stretch !important;
    }
}


/* v6 refinements */
@media (min-width: 521px) {
    .ai-controls {
        grid-template-columns: minmax(0, 1fr) minmax(220px, 280px) 58px minmax(0, 1fr) !important;
        justify-content: center !important;
    }

    #aiAspectRatio {
        grid-column: 1 / 3 !important;
    }

    #aiBatchSize {
        grid-column: 3 / 5 !important;
    }

    #aiGenerateButton {
        grid-column: 1 / -1 !important;
    }

    .ai-controls #aiPrivateGalleryTopButton {
        grid-column: 2 / 3 !important;
        width: 100% !important;
        min-width: 220px;
        max-width: 280px;
        justify-self: end !important;
    }

    #aiResetPromptButton {
        grid-column: 3 / 4 !important;
        width: 58px !important;
        min-width: 58px !important;
        justify-self: start !important;
    }

    .ai-batch-grid {
        grid-template-columns: repeat(var(--ai-batch-columns, 2), minmax(0, 1fr)) !important;
    }

    .ai-batch-card-actions {
        grid-template-columns: 1fr !important;
    }

    .ai-batch-grid[data-batch-size="1"] .ai-batch-card-actions {
        grid-template-columns: 1fr 1fr !important;
    }
}

@media (max-width: 520px) {
    .ai-batch-card-actions {
        grid-template-columns: 1fr !important;
    }
}


/* v7 final layout override: equal dropdowns on desktop */
@media (min-width: 521px) {
    .ai-controls {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
        align-items: stretch !important;
    }

    #aiAspectRatio {
        grid-column: 1 / 2 !important;
        width: 100% !important;
    }

    #aiBatchSize {
        grid-column: 2 / 3 !important;
        width: 100% !important;
    }

    #aiGenerateButton {
        grid-column: 1 / -1 !important;
        width: 100% !important;
    }

    .ai-controls #aiPrivateGalleryTopButton {
        grid-column: 1 / 2 !important;
        width: min(280px, 100%) !important;
        min-width: 220px !important;
        max-width: 280px !important;
        justify-self: end !important;
    }

    #aiResetPromptButton {
        grid-column: 2 / 3 !important;
        width: 58px !important;
        min-width: 58px !important;
        justify-self: start !important;
    }
}

@media (max-width: 520px) {
    .ai-controls {
        grid-template-columns: 1fr !important;
    }

    #aiAspectRatio,
    #aiBatchSize,
    #aiGenerateButton,
    .ai-controls #aiPrivateGalleryTopButton,
    #aiResetPromptButton {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        max-width: none !important;
    }
}


/* v8: treat Private Gallery + Reset as one centered desktop control */
.ai-private-reset-pair {
    display: grid;
    gap: 10px;
    align-items: stretch;
}

@media (min-width: 521px) {
    .ai-controls {
        grid-template-columns: 1fr 1fr !important;
    }

    #aiAspectRatio {
        grid-column: 1 / 2 !important;
        width: 100% !important;
    }

    #aiBatchSize {
        grid-column: 2 / 3 !important;
        width: 100% !important;
    }

    #aiGenerateButton {
        grid-column: 1 / -1 !important;
        width: 100% !important;
    }

    .ai-private-reset-pair {
        grid-column: 1 / -1 !important;
        grid-template-columns: minmax(220px, 280px) 58px;
        justify-content: center;
        width: 100%;
    }

    .ai-private-reset-pair #aiPrivateGalleryTopButton {
        grid-column: 1 / 2 !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        justify-self: stretch !important;
    }

    .ai-private-reset-pair #aiResetPromptButton {
        grid-column: 2 / 3 !important;
        width: 58px !important;
        min-width: 58px !important;
        justify-self: stretch !important;
    }
}

@media (max-width: 520px) {
    .ai-private-reset-pair {
        grid-column: 1 / -1 !important;
        grid-template-columns: 1fr !important;
        width: 100%;
    }

    .ai-private-reset-pair #aiPrivateGalleryTopButton,
    .ai-private-reset-pair #aiResetPromptButton {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        max-width: none !important;
    }
}


/* v13: centre Private Gallery + reset as one combined control */
.ai-control-secondary-pair {
    grid-column: 1 / -1 !important;
    display: inline-flex !important;
    align-items: stretch !important;
    justify-content: center !important;
    gap: 10px !important;
    justify-self: center !important;
    width: auto !important;
    max-width: 100% !important;
}

.ai-control-secondary-pair #aiPrivateGalleryTopButton {
    width: 240px !important;
    min-width: 0 !important;
    max-width: 240px !important;
    justify-self: auto !important;
}

.ai-control-secondary-pair #aiResetPromptButton {
    width: 58px !important;
    min-width: 58px !important;
    max-width: 58px !important;
    justify-self: auto !important;
}

@media (min-width: 521px) {
    .ai-controls {
        grid-template-columns: 1fr 1fr !important;
    }

    #aiAspectRatio {
        grid-column: 1 / 2 !important;
        width: 100% !important;
    }

    #aiBatchSize {
        grid-column: 2 / 3 !important;
        width: 100% !important;
    }

    #aiGenerateButton {
        grid-column: 1 / -1 !important;
        width: 100% !important;
    }
}

@media (max-width: 520px) {
    .ai-control-secondary-pair {
        display: grid !important;
        grid-template-columns: 1fr !important;
        width: 100% !important;
    }

    .ai-control-secondary-pair #aiPrivateGalleryTopButton,
    .ai-control-secondary-pair #aiResetPromptButton {
        width: 100% !important;
        max-width: none !important;
    }
}

/* v13 active-generation toast */
.ai-toast {
    position: fixed;
    left: 50%;
    bottom: 22px;
    transform: translateX(-50%);
    z-index: 999999;
    width: min(520px, calc(100vw - 28px));
    padding: 14px 18px;
    border-radius: 16px;
    background: #111827;
    color: #ffffff;
    font-weight: 800;
    text-align: center;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.ai-toast[hidden] {
    display: none !important;
}


/* v18 recovery: single image must use full-width result area */
.ai-batch-grid[data-batch-size="1"] {
    grid-template-columns: 1fr !important;
}

.ai-batch-grid[data-batch-size="1"] .ai-batch-card {
    grid-column: 1 / -1 !important;
}

/* Keep multi-image batches at two columns on desktop, one column on mobile */
@media (min-width: 521px) {
    .ai-batch-grid:not([data-batch-size="1"]) {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 520px) {
    .ai-batch-grid {
        grid-template-columns: 1fr !important;
    }
}


/* v25: one generated image should occupy the full result width */
.ai-batch-grid[data-batch-size="1"] {
    grid-template-columns: 1fr !important;
}

.ai-batch-grid[data-batch-size="1"] .ai-batch-card {
    grid-column: 1 / -1 !important;
}

/* Keep multi-image batches two columns on desktop, one column on mobile */
@media (min-width: 521px) {
    .ai-batch-grid:not([data-batch-size="1"]) {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 520px) {
    .ai-batch-grid {
        grid-template-columns: 1fr !important;
    }
}

/* v25: stack Download and Save buttons consistently to avoid tablet overflow */
.ai-result-buttons,
.ai-batch-card-actions {
    grid-template-columns: 1fr !important;
}


/* v26: robust single-image and action-button layout */
.ai-batch-grid[data-batch-size="1"] {
    grid-template-columns: 1fr !important;
}

.ai-batch-grid[data-batch-size="1"] .ai-batch-card {
    grid-column: 1 / -1 !important;
    width: 100% !important;
}

.ai-batch-grid[data-batch-size="1"] .ai-batch-card-actions,
.ai-batch-card-actions,
.ai-result-buttons {
    grid-template-columns: 1fr !important;
}

.ai-result-buttons {
    display: grid !important;
    width: 100% !important;
}

.ai-result-buttons a,
.ai-result-buttons button,
.ai-batch-card-actions a,
.ai-batch-card-actions button {
    width: 100% !important;
}

@media (min-width: 521px) {
    .ai-batch-grid[data-batch-size="1"] {
        grid-template-columns: 1fr !important;
    }

    .ai-batch-grid[data-batch-size="1"] .ai-batch-card-actions {
        grid-template-columns: 1fr !important;
    }
}


/* v27 final override: one generated image must always occupy one full-width column */
#aiBatchGrid.ai-batch-grid[data-batch-size="1"],
#aiBatchGrid.ai-batch-grid[style*="--ai-batch-columns: 1"] {
    grid-template-columns: minmax(0, 1fr) !important;
}

#aiBatchGrid.ai-batch-grid[data-batch-size="1"] > .ai-batch-card,
#aiBatchGrid.ai-batch-grid[style*="--ai-batch-columns: 1"] > .ai-batch-card {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    max-width: 100% !important;
}

@supports selector(.ai-batch-grid:has(> .ai-batch-card:only-child)) {
    #aiBatchGrid.ai-batch-grid:has(> .ai-batch-card:only-child) {
        grid-template-columns: minmax(0, 1fr) !important;
    }
}


/* v30 generated image share overlay */
.ai-batch-card-preview {
    position: relative;
}

.ai-image-share-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 5;
    width: 44px;
    height: 44px;
    min-height: 44px !important;
    border-radius: 999px !important;
    border: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    background: rgba(255, 255, 255, 0.94) !important;
    color: #111827 !important;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.22);
    cursor: pointer;
}

.ai-image-share-overlay:hover,
.ai-image-share-overlay:focus {
    background: #ffffff !important;
    color: var(--ai-blue) !important;
    outline: none;
    transform: translateY(-1px);
}

.ai-image-share-overlay[hidden] {
    display: none !important;
}

.ai-image-share-overlay:disabled {
    opacity: 0.65;
    cursor: wait;
}


/* v41: per-image regenerate icon overlay */
.ai-image-regenerate-overlay {
    position: absolute;
    right: 10px;
    bottom: 10px;
    z-index: 5;
    width: 44px;
    height: 44px;
    min-height: 44px !important;
    border-radius: 999px !important;
    border: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    background: rgba(255, 255, 255, 0.94) !important;
    color: #111827 !important;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.22);
    cursor: pointer;
}

.ai-image-regenerate-overlay:hover,
.ai-image-regenerate-overlay:focus {
    background: #ffffff !important;
    color: var(--ai-blue) !important;
    outline: none;
    transform: translateY(-1px);
}

.ai-image-regenerate-overlay[hidden] {
    display: none !important;
}

.ai-image-regenerate-overlay:disabled {
    opacity: 0.65;
    cursor: wait;
}



/* v30 keep single-image generation full width and button rows stacked */
#aiBatchGrid.ai-batch-grid[data-batch-size="1"],
#aiBatchGrid.ai-batch-grid[style*="--ai-batch-columns: 1"] {
    grid-template-columns: minmax(0, 1fr) !important;
}

#aiBatchGrid.ai-batch-grid[data-batch-size="1"] > .ai-batch-card,
#aiBatchGrid.ai-batch-grid[style*="--ai-batch-columns: 1"] > .ai-batch-card {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    max-width: 100% !important;
}

.ai-result-buttons,
.ai-batch-card-actions,
#aiBatchGrid.ai-batch-grid[data-batch-size="1"] .ai-batch-card-actions {
    grid-template-columns: 1fr !important;
}

/* v30 encourage ad visibility below generated image containers */
.mv-ad-box,
[data-mv-ad-box],
[data-mv-unit],
.adthrive-ad,
.ai-ad-container,
.ai-ad-slot {
    margin-bottom: 32px !important;
}

/* v35: keep aspect ratio and batch size side by side on mobile */
@media (max-width: 520px) {
    .ai-controls {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
        gap: 10px !important;
    }

    .ai-controls #aiAspectRatio {
        grid-column: 1 / 2 !important;
        width: 100% !important;
        min-width: 0 !important;
    }

    .ai-controls #aiBatchSize {
        grid-column: 2 / 3 !important;
        width: 100% !important;
        min-width: 0 !important;
    }

    .ai-controls #aiAspectRatio,
    .ai-controls #aiBatchSize {
        font-size: 16px !important;
        padding-left: 8px !important;
        padding-right: 8px !important;
    }

    .ai-controls #aiGenerateButton,
    .ai-controls .ai-responsible-use-note-wrap,
    .ai-controls .ai-private-reset-pair {
        grid-column: 1 / -1 !important;
        width: 100% !important;
    }

    .ai-controls .ai-control-secondary-pair {
        grid-column: 1 / -1 !important;
        display: grid !important;
        grid-template-columns: 1fr !important;
        width: 100% !important;
    }

    .ai-controls #aiPrivateGalleryTopButton,
    .ai-controls #aiResetPromptButton {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        max-width: none !important;
    }
}


/* v42: below 1350px keep generated-image batches in a single column on desktop/tablet */
@media (min-width: 521px) and (max-width: 1349.98px) {
    #aiBatchGrid.ai-batch-grid:not([data-batch-size="1"]) {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    #aiBatchGrid.ai-batch-grid:not([data-batch-size="1"]) > .ai-batch-card {
        grid-column: auto !important;
        width: 100% !important;
        max-width: 100% !important;
    }
}

@media (min-width: 1350px) {
    #aiBatchGrid.ai-batch-grid:not([data-batch-size="1"]) {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}


/* v48: prevent browser scroll anchoring without reserving full image space before generation */
html,
body,
#aiBatchGrid,
.ai-batch-grid,
.ai-batch-card,
.ai-batch-card-preview,
.ai-batch-card-actions {
    overflow-anchor: none !important;
}

/* Keep pending image containers compact so the advert below remains visible while images generate. */
#aiBatchGrid.ai-batch-grid .ai-batch-card:not(.ai-batch-success):not(.ai-batch-failed) .ai-batch-card-preview {
    min-height: 0 !important;
    height: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    overflow: hidden !important;
}

#aiBatchGrid.ai-batch-grid .ai-batch-card:not(.ai-batch-success):not(.ai-batch-failed) .ai-batch-card-placeholder {
    display: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Once an image exists, let it take its natural rendered height rather than reserving space up front. */
#aiBatchGrid.ai-batch-grid .ai-batch-card.ai-batch-success .ai-batch-card-preview {
    min-height: 0 !important;
    height: auto !important;
    aspect-ratio: auto !important;
}

#aiBatchGrid.ai-batch-grid .ai-batch-card.ai-batch-success .ai-batch-card-preview img {
    width: 100% !important;
    height: auto !important;
    object-fit: contain !important;
}

/* v3.90 model selector for Cloudflare default and RunPod HD option */
.ai-controls #aiModel,
.ai-controls .ai-model-help {
    grid-column: 1 / -1;
}

.ai-model-help {
    margin-top: -2px;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 14px;
    background: #f8fafc;
    color: #374151;
    font-size: 14px;
    line-height: 1.45;
    text-align: center;
}

@media (max-width: 520px) {
    .ai-controls #aiModel,
    .ai-controls .ai-model-help {
        grid-column: 1 / -1 !important;
        width: 100% !important;
    }
}

/* v41: spin the regenerate overlay icon while that image is regenerating */
.ai-regenerate-image-button i {
    margin-right: 0;
}

.ai-batch-card[data-regen-running="1"] .ai-regenerate-image-button i {
    animation: ai-regenerate-spin 1s linear infinite;
}

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


/* v43: toast error messages with centred close button */
.ai-temp-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translate(-50%, 18px);
    z-index: 999999;
    width: min(560px, calc(100vw - 28px));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 14px 14px 18px;
    border-radius: 16px;
    background: #111827;
    color: #ffffff;
    font-weight: 800;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.ai-temp-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
    pointer-events: auto;
}

.ai-temp-toast-message {
    flex: 1;
    min-width: 0;
    line-height: 1.35;
}

.ai-temp-toast-close {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
    font-size: 26px;
    line-height: 1;
    font-weight: 900;
    cursor: pointer;
}

.ai-temp-toast-close:hover,
.ai-temp-toast-close:focus {
    background: rgba(255, 255, 255, 0.24);
    outline: 2px solid rgba(255, 255, 255, 0.55);
    outline-offset: 2px;
}


/* v4.07: Inline Cloudflare Turnstile verification block.
   It stays collapsed under the Generate button during silent verification.
   If Cloudflare needs user interaction, it expands in-place under Generate. */
.ai-turnstile-wrap {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 100%;
    max-height: 0;
    min-height: 0;
    margin: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-4px);
    transition: max-height 0.22s ease, margin 0.22s ease, opacity 0.22s ease, transform 0.22s ease;
    pointer-events: none;
}

.ai-turnstile-wrap[hidden] {
    display: none !important;
}

.ai-turnstile-wrap.is-interactive {
    max-height: 110px;
    margin: 2px 0 4px;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.ai-turnstile-wrap.is-verified-pending {
    opacity: 0.92;
}

.ai-turnstile-wrap.is-hidden,
.ai-turnstile-wrap.is-verified {
    max-height: 0;
    min-height: 0;
    margin: 0;
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
}

#aiTurnstileWidget {
    min-width: 300px;
    min-height: 65px;
}

@media (max-width: 520px) {
    .ai-controls .ai-turnstile-wrap {
        grid-column: 1 / -1 !important;
        width: 100% !important;
    }

    #aiTurnstileWidget {
        min-width: 280px;
        transform: scale(0.95);
        transform-origin: top center;
    }
}


/* AI niche hub and landing pages */
.ai-niche-hub-section {
    padding: 24px;
}

.ai-niche-hub-intro {
    max-width: 840px;
    margin: 0 0 18px;
    text-align: left;
}

.ai-niche-search-wrap {
    margin: 0 0 16px;
    max-width: 520px;
}

.ai-niche-search-label {
    display: block;
    font-weight: 800;
    margin: 0 0 6px;
}

.ai-niche-search-input-wrap {
    display: block;
    position: relative;
    width: 100%;
}

.ai-niche-search-icon {
    color: #94a3b8;
    font-size: 0.95rem;
    left: 15px;
    line-height: 1;
    pointer-events: none;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}

.ai-niche-search-input {
    border: 1px solid #e3e8ef;
    border-radius: 16px;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.035);
    font: inherit;
    min-height: 46px;
    padding: 11px 15px 11px 42px;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
    width: 100%;
}

.ai-niche-search-input:focus {
    border-color: #9fb1d0;
    box-shadow: 0 0 0 3px rgba(147, 197, 253, 0.25);
    outline: 0;
}

.ai-niche-card-grid,
.ai-niche-example-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-top: 18px;
}

.ai-niche-card,
.ai-niche-example-card {
    --ai-niche-card-radius: 18px;
    border: 1px solid #e5e7eb;
    border-radius: var(--ai-niche-card-radius);
    background: #ffffff;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.ai-niche-card-live {
    display: flex;
    flex-direction: column;
}

.ai-niche-card-image-button {
    border: 0;
    background: transparent;
    border-radius: var(--ai-niche-card-radius);
    cursor: pointer;
    display: block;
    margin: 10px 10px 0;
    overflow: hidden;
    padding: 0;
    text-decoration: none;
    width: calc(100% - 20px);
}

.ai-niche-card-image-button:focus-visible {
    outline: 3px solid #2563eb;
    outline-offset: 3px;
}

.ai-niche-card-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    padding: 12px 14px 14px;
}

.ai-niche-card img,
.ai-niche-example-card img {
    border-radius: var(--ai-niche-card-radius);
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 3 / 2;
    object-fit: cover;
}

.ai-niche-card h3,
.ai-niche-example-card h3 {
    font-size: 1.15rem;
    line-height: 1.24;
    margin: 0 0 7px;
}

.ai-niche-card p,
.ai-niche-example-card p {
    margin: 0 0 10px;
    font-size: 0.98rem;
    line-height: 1.4;
}

.ai-niche-card p {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ai-niche-card-cta {
    align-self: flex-start;
    color: #0802f5;
    display: inline-flex;
    font-size: 0.9rem;
    font-weight: 800;
    line-height: 1.2;
    margin-top: auto;
    text-decoration: none;
}


.ai-niche-hub-hint {
    color: #475569;
    font-size: 0.94rem;
    margin: -8px 0 18px;
}

.ai-niche-pagination {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 22px;
}

.ai-niche-pagination[hidden] { display: none !important; }

.ai-niche-page-button {
    align-items: center;
    background: #fff;
    border: 1px solid #dbe3ee;
    border-radius: 10px;
    color: #1e293b;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 700;
    justify-content: center;
    min-height: 40px;
    min-width: 40px;
    padding: 8px 12px;
}

.ai-niche-page-button:hover,
.ai-niche-page-button:focus-visible {
    border-color: #93c5fd;
    outline: 0;
}

.ai-niche-page-button.is-active {
    background: #0802f5;
    border-color: #0802f5;
    color: #fff;
}

.ai-niche-page-button:disabled {
    cursor: default;
    opacity: 0.46;
}

.ai-niche-pagination-ellipsis {
    color: #64748b;
    padding: 0 2px;
}

.ai-niche-example-image-button {
    background: transparent;
    border: 0;
    cursor: zoom-in;
    display: block;
    padding: 0;
    width: 100%;
}

.ai-niche-example-image-button:focus-visible {
    border-radius: var(--ai-niche-card-radius);
    outline: 3px solid #2563eb;
    outline-offset: 3px;
}

.ai-niche-example-card-body {
    padding: 14px;
}

.ai-niche-example-prompt {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.ai-niche-example-prompt-actions {
    align-items: center;
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

.ai-niche-prompt-copy {
    background: #f8fafc;
    border: 1px solid #dbe3ee;
    border-radius: 9px;
    color: #334155;
    cursor: pointer;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    padding: 7px 10px;
}

.ai-niche-prompt-copy:hover,
.ai-niche-prompt-copy:focus-visible {
    background: #eff6ff;
    border-color: #93c5fd;
    outline: 0;
}

.ai-niche-create-button.btn-green {
    border-radius: 10px !important;
}

.ai-niche-empty-message {
    border: 1px dashed #cbd5e1;
    border-radius: 14px;
    color: #475569;
    grid-column: 1 / -1;
    padding: 14px;
}

.ai-niche-hero,
.ai-niche-gallery-section,
.ai-niche-prompt-section,
.ai-niche-faq-section {
    text-align: left;
}

.ai-niche-prompt-section .btn-green,
.ai-niche-hero .btn-green {
    display: inline-block;
    margin-top: 10px;
    text-decoration: none;
}

@media (min-width: 900px) and (max-width: 1000px) {
    .ai-niche-card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 899px) and (min-width: 500px) {
    .ai-niche-card-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 14px;
    }
}

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

@media (max-width: 640px) {
    .ai-niche-hub-section {
        padding: 18px 14px;
    }
    .ai-niche-card-grid,
    .ai-niche-example-grid {
        gap: 12px;
    }
    .ai-niche-card-image-button {
        margin: 8px 8px 0;
        width: calc(100% - 16px);
    }
    .ai-niche-card-body {
        padding: 9px 9px 11px;
    }
    .ai-niche-card h3,
    .ai-niche-example-card h3 {
        font-size: 0.98rem;
        line-height: 1.22;
        margin-bottom: 5px;
    }
    .ai-niche-card p,
    .ai-niche-example-card p {
        font-size: 0.84rem;
        line-height: 1.32;
        margin-bottom: 8px;
    }
    .ai-niche-card-body,
    .ai-niche-example-card-body {
        display: flex !important;
        flex-direction: column !important;
        visibility: visible !important;
        opacity: 1 !important;
        color: #1f2937 !important;
    }
    .ai-niche-card-cta {
        font-size: 0.74rem;
        line-height: 1.15;
    }
}

@media (max-width: 499px) {
    .ai-niche-card-grid,
    .ai-niche-example-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* v70: invisible Turnstile container. The security token still works, but no box should appear under the Generate button. */
.ai-turnstile-wrap,
.ai-turnstile-wrap.is-interactive,
.ai-turnstile-wrap.is-verified-pending,
.ai-turnstile-wrap.is-hidden,
.ai-turnstile-wrap.is-verified {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
}


/* v71: Invisible Turnstile must not be display:none while executing. */
.ai-turnstile-wrap.is-invisible-mode,
.ai-turnstile-wrap.is-hidden.is-invisible-mode {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    max-width: 1px !important;
    max-height: 1px !important;
    overflow: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
}


/* v81: top-centred toast option for model notices so they are not hidden behind mobile ads. */
.ai-temp-toast.ai-temp-toast-top {
    top: max(18px, calc(env(safe-area-inset-top, 0px) + 12px));
    bottom: auto;
    transform: translate(-50%, -18px);
}

.ai-temp-toast.ai-temp-toast-top.is-visible {
    transform: translate(-50%, 0);
}


/* v86: keep the previous image visible while a card is queued/re-generating. */
#aiBatchGrid.ai-batch-grid .ai-batch-card.ai-batch-success[data-regen-queued="1"] .ai-batch-card-preview,
#aiBatchGrid.ai-batch-grid .ai-batch-card.ai-batch-success[data-regen-running="1"] .ai-batch-card-preview {
    min-height: 0 !important;
    height: auto !important;
    aspect-ratio: auto !important;
    background: #e5e7eb !important;
    overflow: hidden !important;
    border-radius: 14px !important;
}

#aiBatchGrid.ai-batch-grid .ai-batch-card.ai-batch-success[data-regen-queued="1"] .ai-batch-card-preview img,
#aiBatchGrid.ai-batch-grid .ai-batch-card.ai-batch-success[data-regen-running="1"] .ai-batch-card-preview img {
    width: 100% !important;
    height: auto !important;
    object-fit: contain !important;
}

.ai-batch-card.ai-batch-success[data-regen-running="1"] .ai-batch-card-bar-fill {
    width: var(--ai-card-progress, 0%) !important;
    background: var(--ai-blue) !important;
}



/* v4.28 image reference panel */
.ai-image-reference-toggle,
.ai-reference-panel,
.ai-image-reference-teaser {
    grid-column: 1 / -1;
}

.ai-image-reference-teaser a {
    display: inline-block;
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #bfdbfe;
    border-radius: 14px;
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 700;
    text-decoration: none;
    text-align: center;
}

.ai-reference-panel {
    border: 1px solid #dbeafe;
    background: #f8fbff;
    border-radius: 18px;
    padding: 14px;
}

.ai-reference-panel-title {
    font-weight: 800;
    margin-bottom: 6px;
    font-size: 18px;
}

.ai-reference-limit-text,
.ai-reference-panel-note,
.ai-reference-drop-zone-subtext,
.ai-reference-empty-state {
    color: #374151;
    font-size: 14px;
    line-height: 1.45;
}

.ai-reference-panel-note {
    margin-bottom: 10px;
}

.ai-reference-drop-zone {
    border: 2px dashed #93c5fd;
    background: #ffffff;
    border-radius: 16px;
    padding: 14px;
    text-align: center;
}

.ai-reference-choose-button {
    min-width: 220px;
    margin: 0 auto 10px auto;
}

.ai-reference-drop-zone-text {
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 6px;
}

.ai-reference-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.ai-reference-preview-card {
    position: relative;
    border: 1px solid #d1d5db;
    border-radius: 14px;
    background: #fff;
    overflow: hidden;
}

.ai-reference-preview-card img {
    display: block;
    width: 100%;
    height: 120px;
    object-fit: cover;
}

.ai-reference-preview-meta {
    padding: 8px;
    font-size: 12px;
    color: #4b5563;
    line-height: 1.35;
}

.ai-reference-remove-button {
    position: absolute;
    top: 6px;
    right: 6px;
    min-height: 34px;
    min-width: 34px;
    border-radius: 999px;
    border: none;
    background: rgba(17, 24, 39, 0.78);
    color: #fff;
    font-size: 16px !important;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
}

.ai-reference-clear-button {
    margin-top: 12px;
    width: 100%;
    min-height: 46px;
    border-radius: 14px;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #1f2937;
    font-weight: 800;
}

@media (max-width: 520px) {
    .ai-card textarea,
    #aiPrompt {
        min-height: 110px;
        height: 110px;
    }

    .ai-reference-choose-button {
        min-width: 0;
        width: 100%;
    }

    .ai-reference-preview-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* v4.29 cleaner Image to Image controls */
.ai-controls #aiModel {
    grid-column: 1 / 2 !important;
}

.ai-controls .ai-image-reference-toggle,
.ai-controls .ai-image-reference-teaser {
    grid-column: 2 / 3 !important;
    width: 100% !important;
}

.ai-controls .ai-image-reference-toggle,
.ai-controls .ai-image-reference-teaser-button {
    min-height: 50px !important;
    width: 100% !important;
    border-radius: 15px !important;
    background: #0802f5 !important;
    color: #fff !important;
    display: grid !important;
    place-items: center !important;
    text-align: center !important;
    text-decoration: none !important;
    font-weight: 800 !important;
    font-size: 18px !important;
    line-height: 1.2 !important;
    padding: 0 16px !important;
    border: 0 !important;
}

.ai-reference-panel {
    grid-column: 1 / -1 !important;
    border: 1px solid #dbeafe !important;
    background: #f8fbff !important;
    border-radius: 18px !important;
    padding: 14px !important;
}

.ai-reference-panel-title {
    margin: 0 0 12px 0 !important;
    color: #111827 !important;
    font-weight: 800 !important;
    font-size: 18px !important;
    line-height: 1.35 !important;
    text-align: center !important;
}

.ai-reference-slot-grid {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 12px !important;
    align-items: stretch !important;
    width: 100% !important;
}

.ai-reference-slot-grid[data-ref-limit="1"] {
    grid-template-columns: minmax(160px, 25%) !important;
    justify-content: center !important;
}

.ai-reference-slot {
    min-height: 132px !important;
    width: 100% !important;
    border: 2px dashed #93c5fd !important;
    background: #fff !important;
    color: #1f2937 !important;
    border-radius: 18px !important;
    display: grid !important;
    place-items: center !important;
    gap: 8px !important;
    padding: 12px !important;
    cursor: pointer !important;
    position: relative !important;
    overflow: hidden !important;
    font-weight: 800 !important;
}

.ai-reference-slot:hover,
.ai-reference-slot:focus {
    border-color: #0802f5 !important;
    box-shadow: 0 0 0 4px rgba(8, 2, 245, 0.12) !important;
    outline: none !important;
}

.ai-reference-slot-icon {
    width: 54px !important;
    height: 54px !important;
    border-radius: 999px !important;
    background: rgba(8, 2, 245, 0.10) !important;
    color: #0802f5 !important;
    display: grid !important;
    place-items: center !important;
    font-size: 28px !important;
}

.ai-reference-slot-label {
    font-size: 15px !important;
    line-height: 1.25 !important;
    text-align: center !important;
}

.ai-reference-slot.has-image {
    border-style: solid !important;
    padding: 0 !important;
}

.ai-reference-slot.has-image img {
    width: 100% !important;
    height: 100% !important;
    min-height: 132px !important;
    object-fit: cover !important;
    display: block !important;
}

.ai-reference-slot-remove {
    position: absolute !important;
    top: 8px !important;
    right: 8px !important;
    width: 34px !important;
    height: 34px !important;
    border-radius: 999px !important;
    background: rgba(17, 24, 39, 0.78) !important;
    color: #fff !important;
    display: grid !important;
    place-items: center !important;
    font-size: 20px !important;
    line-height: 1 !important;
    z-index: 3 !important;
}

.ai-reference-strength-wrap {
    margin-top: 16px !important;
    padding: 14px !important;
    border: 1px solid #dbeafe !important;
    border-radius: 18px !important;
    background: #fff !important;
}

.ai-reference-strength-title-row {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
    margin-bottom: 10px !important;
    font-weight: 800 !important;
    color: #111827 !important;
}

.ai-reference-strength-title-row output {
    min-width: 46px !important;
    min-height: 30px !important;
    border-radius: 999px !important;
    background: #0802f5 !important;
    color: #fff !important;
    display: grid !important;
    place-items: center !important;
    font-size: 14px !important;
    font-weight: 800 !important;
}

.ai-reference-strength-slider {
    width: 100% !important;
    height: 14px !important;
    border-radius: 999px !important;
    accent-color: #0802f5 !important;
    cursor: pointer !important;
}

.ai-reference-strength-slider::-webkit-slider-runnable-track {
    height: 12px !important;
    border-radius: 999px !important;
    background: linear-gradient(90deg, #bfdbfe, #0802f5) !important;
}

.ai-reference-strength-slider::-webkit-slider-thumb {
    -webkit-appearance: none !important;
    width: 28px !important;
    height: 28px !important;
    margin-top: -8px !important;
    border-radius: 999px !important;
    background: #0802f5 !important;
    border: 4px solid #fff !important;
    box-shadow: 0 4px 14px rgba(8, 2, 245, 0.35) !important;
}

.ai-reference-strength-slider::-moz-range-track {
    height: 12px !important;
    border-radius: 999px !important;
    background: linear-gradient(90deg, #bfdbfe, #0802f5) !important;
}

.ai-reference-strength-slider::-moz-range-thumb {
    width: 22px !important;
    height: 22px !important;
    border-radius: 999px !important;
    background: #0802f5 !important;
    border: 4px solid #fff !important;
    box-shadow: 0 4px 14px rgba(8, 2, 245, 0.35) !important;
}

.ai-reference-strength-labels {
    display: flex !important;
    justify-content: space-between !important;
    gap: 14px !important;
    margin-top: 9px !important;
    color: #374151 !important;
    font-size: 13px !important;
    line-height: 1.35 !important;
    font-weight: 700 !important;
}

@media (max-width: 700px) {
    .ai-controls #aiModel,
    .ai-controls .ai-image-reference-toggle,
    .ai-controls .ai-image-reference-teaser {
        grid-column: 1 / -1 !important;
        width: 100% !important;
    }

    .ai-reference-slot-grid,
    .ai-reference-slot-grid[data-ref-limit="1"] {
        grid-template-columns: 1fr !important;
        justify-content: stretch !important;
    }

    .ai-reference-slot {
        min-height: 120px !important;
    }

    .ai-reference-strength-labels {
        display: grid !important;
        grid-template-columns: 1fr !important;
        text-align: center !important;
    }
}


/* Image to Image active state: centred toggle, no text-to-image model dropdown */
.ai-controls.ai-reference-mode-active #aiModel,
.ai-controls.ai-reference-mode-active .ai-model-help {
    display: none !important;
}

.ai-controls.ai-reference-mode-active .ai-image-reference-toggle {
    grid-column: 1 / -1 !important;
    justify-self: center !important;
    width: min(100%, 360px) !important;
    max-width: 360px !important;
}

.ai-controls .ai-image-reference-toggle:disabled,
.ai-controls .ai-image-reference-toggle.ai-disabled {
    opacity: 0.55 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
    -webkit-filter: none !important;
}

.ai-controls.ai-reference-mode-active .ai-reference-panel {
    grid-column: 1 / -1 !important;
}

@media (max-width: 700px) {
    .ai-controls.ai-reference-mode-active .ai-image-reference-toggle {
        width: 100% !important;
        max-width: none !important;
    }
}


/* v4.36: visible Turnstile fallback placed above Generate.
   The checked server-side pass lasts for 24 hours, so this box is only shown
   when the visitor does not yet have a trusted security cookie. */
.ai-controls .ai-turnstile-wrap {
    grid-column: 1 / -1 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    opacity: 1 !important;
    transform: none !important;
    pointer-events: auto !important;
    visibility: visible !important;
}

.ai-controls .ai-turnstile-wrap[hidden],
.ai-controls .ai-turnstile-wrap.is-hidden,
.ai-controls .ai-turnstile-wrap.is-verified,
.ai-controls .ai-turnstile-wrap.is-token-ready,
.ai-controls .ai-turnstile-wrap.is-verified-pending {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.ai-controls .ai-turnstile-wrap.is-interactive {
    display: flex !important;
    width: 100% !important;
    min-height: 74px !important;
    margin: 6px 0 4px !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    visibility: visible !important;
}

.ai-controls #aiTurnstileWidget {
    min-width: 300px !important;
    min-height: 65px !important;
}

@media (max-width: 520px) {
    .ai-controls #aiTurnstileWidget {
        min-width: 280px !important;
        transform: scale(0.95) !important;
        transform-origin: top center !important;
    }
}


/* v4.37: robust visible Turnstile behaviour.
   If a verification challenge is needed, the box must be visible above Generate.
   If a token is already ready or the 24h trusted cookie exists, the area fully collapses. */
.ai-controls .ai-turnstile-wrap[hidden],
.ai-controls .ai-turnstile-wrap.is-hidden,
.ai-controls .ai-turnstile-wrap.is-token-ready,
.ai-controls .ai-turnstile-wrap.is-verified,
.ai-controls .ai-turnstile-wrap.is-verified-pending {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.ai-controls .ai-turnstile-wrap.is-interactive:not([hidden]) {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    justify-content: center !important;
    align-items: center !important;
    grid-column: 1 / -1 !important;
    width: 100% !important;
    min-height: 74px !important;
    max-height: none !important;
    margin: 6px 0 4px !important;
    padding: 0 !important;
    overflow: visible !important;
    opacity: 1 !important;
    transform: none !important;
    pointer-events: auto !important;
    visibility: visible !important;
}

.ai-turnstile-status {
    display: block;
    max-width: 360px;
    margin: 0 auto;
    font-size: 13px;
    line-height: 1.35;
    text-align: center;
    color: #374151;
}

.ai-turnstile-status[hidden] {
    display: none !important;
}


.ai-prompt-builder-entry{margin:0 0 0px;display:flex;gap:12px;align-items:center;flex-wrap:wrap;padding:12px 14px;background:#fafbfc;border:1px solid #e6ebf0;border-radius:14px;}
.ai-prompt-builder-entry-copy{font-size:14px;color:#475569;flex:1 1 280px;}
@media (max-width:640px){.ai-prompt-builder-entry .btn-blue{width:100%;text-align:center;}}


/* Prompt builder entry button - simplified test patch */
.ai-prompt-builder-entry{margin:0 0 0px!important;padding:0!important;background:transparent!important;border:0!important;display:block!important;}
.ai-prompt-builder-entry-copy{display:none!important;}
.ai-prompt-builder-entry-button{display:inline-flex!important;align-items:center!important;justify-content:center!important;border-radius:999px!important;padding:10px 18px!important;font-weight:700!important;text-decoration:none!important;}
@media (max-width:640px){.ai-prompt-builder-entry-button{width:100%!important;text-align:center!important;}}

.ai-prompt-builder-entry-button{font-weight:700!important;}


/* Prompt builder and prompt library helpers */
.ai-prompt-builder-entry {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.ai-prompt-library-mini {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ai-prompt-mini-icon,
.ai-prompt-library-icon,
.ai-recent-generated-arrow {
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #2563eb;
    border-radius: 999px;
    min-width: 36px;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    line-height: 1;
}

.ai-prompt-mini-icon:hover,
.ai-prompt-library-icon:hover,
.ai-recent-generated-arrow:hover {
    background: #eff6ff;
    border-color: #2563eb;
}

.ai-prompt-mini-icon:disabled,
.ai-prompt-mini-icon.is-disabled,
.ai-prompt-builder-entry-button.ai-disabled {
    opacity: .55;
    cursor: not-allowed;
    pointer-events: auto;
}

.ai-recent-generated-carousel {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0 0;
    min-height: 120px;
}

.ai-recent-generated-track {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 4px 2px 8px;
    scrollbar-width: thin;
    flex: 1 1 auto;
}

.ai-recent-generated-thumb {
    flex: 0 0 118px;
    width: 118px;
    height: 118px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 0;
    overflow: hidden;
    background: #f8fafc;
    cursor: pointer;
}

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

.ai-prompt-library-modal[hidden] {
    display: none !important;
}

.ai-prompt-library-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
}

.ai-prompt-library-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .55);
}

.ai-prompt-library-box {
    position: relative;
    width: min(680px, calc(100vw - 24px));
    max-height: min(74vh, 680px);
    overflow: auto;
    margin: 10vh auto 0;
    background: #fff;
    border-radius: 18px;
    padding: 18px;
    box-shadow: 0 24px 80px rgba(15, 23, 42, .28);
}

.ai-prompt-library-close {
    position: absolute;
    right: 12px;
    top: 12px;
    border: 0;
    background: transparent;
    color: #334155;
    cursor: pointer;
    font-size: 20px;
}

.ai-prompt-library-box h2 {
    margin: 0 40px 14px 0;
    font-size: 22px;
}

.ai-prompt-library-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-prompt-library-row {
    display: flex;
    gap: 10px;
    align-items: center;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 10px;
    background: #fafbfc;
}

.ai-prompt-library-load {
    flex: 1 1 auto;
    border: 0;
    background: transparent;
    text-align: left;
    color: #0f172a;
    font-weight: 700;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-prompt-library-row-actions {
    display: flex;
    gap: 6px;
    flex: 0 0 auto;
}

.ai-prompt-library-empty {
    color: #64748b;
    margin: 0;
}

@media (max-width: 520px) {
    .ai-recent-generated-carousel {
        min-height: 110px;
    }

    .ai-recent-generated-thumb {
        flex-basis: calc((100vw - 116px) / 2);
        width: calc((100vw - 116px) / 2);
        height: 104px;
    }

    .ai-prompt-library-row {
        align-items: flex-start;
    }
}


/* v7: prompt builder row, prompt library import/thumbnail, mobile I2I generate button */
.ai-prompt-builder-entry{
    margin:0 0 0px!important;
    padding:0!important;
    background:transparent!important;
    border:0!important;
    display:flex!important;
    flex-direction:row!important;
    align-items:center!important;
    gap:8px!important;
    flex-wrap:nowrap!important;
}
.ai-prompt-builder-entry-button{
    flex:1 1 auto!important;
    min-width:0!important;
    width:auto!important;
    white-space:nowrap!important;
    text-align:center!important;
    font-weight:700!important;
}
.ai-prompt-library-mini{
    flex:0 0 auto!important;
    display:flex!important;
    flex-direction:row!important;
    align-items:center!important;
    gap:6px!important;
}
.ai-prompt-library-import-row{
    margin:0 0 12px;
}
.ai-prompt-library-import-button{
    display:inline-flex!important;
    align-items:center!important;
    gap:7px!important;
    border-radius:999px!important;
    font-weight:700!important;
}
.ai-prompt-library-thumb{
    flex:0 0 38px;
    width:38px;
    height:38px;
    border-radius:10px;
    background:#eaf1ff;
    border:1px solid #bfdbfe;
    color:#1d4ed8;
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:12px;
    font-weight:800;
    letter-spacing:.03em;
}
.ai-prompt-library-row{
    align-items:center!important;
}
.ai-prompt-library-load{
    min-width:0;
}
.ai-mobile-i2i-generate{
    display:none!important;
}
@media (max-width:640px){
    .ai-prompt-builder-entry{
        width:100%!important;
    }
    .ai-prompt-builder-entry-button{
        width:auto!important;
        padding-left:12px!important;
        padding-right:12px!important;
    }
    .ai-prompt-mini-icon{
        min-width:38px!important;
        width:38px!important;
        height:38px!important;
    }
    .ai-mobile-i2i-generate:not([hidden]){
        display:flex!important;
        width:100%!important;
        grid-column:1 / -1!important;
        justify-content:center!important;
        margin:4px 0 10px!important;
    }
}


/* v8: desktop button sizing, mobile I2I duplicate button, prompt library image thumbnails */
@media (min-width:641px){
    .ai-prompt-builder-entry-button{
        flex:0 0 auto!important;
        width:auto!important;
        min-width:170px!important;
        max-width:230px!important;
        padding-left:16px!important;
        padding-right:16px!important;
    }
}
.ai-mobile-i2i-generate[hidden]{
    display:none!important;
}
@media (max-width:640px){
    #aiMobileImageToImageGenerateButton.ai-mobile-i2i-generate:not([hidden]){
        display:flex!important;
        width:100%!important;
        grid-column:1 / -1!important;
        justify-content:center!important;
        margin:4px 0 10px!important;
    }
}
.ai-prompt-library-thumb.has-image{
    padding:0;
    overflow:hidden;
    background:#f8fafc;
}
.ai-prompt-library-thumb.has-image img{
    display:block;
    width:100%;
    height:100%;
    object-fit:cover;
}
.ai-prompt-library-import-button span{
    font-weight:700;
}


/* v8b: restore Recent generated images carousel with title */
.ai-recent-generated-carousel[hidden]{
    display:none!important;
}
.ai-recent-generated-carousel{
    display:block!important;
    margin:12px 0 0!important;
    min-height:0!important;
}
.ai-recent-generated-title{
    margin:0 0 8px!important;
    font-size:16px!important;
    line-height:1.25!important;
    font-weight:800!important;
    color:#0f172a!important;
}
.ai-recent-generated-scroller{
    display:flex!important;
    align-items:center!important;
    gap:8px!important;
    min-height:118px!important;
}
.ai-recent-generated-track{
    min-width:0!important;
}
@media (max-width:520px){
    .ai-recent-generated-title{
        font-size:15px!important;
    }
    .ai-recent-generated-scroller{
        min-height:104px!important;
    }
}


/* v9: prompt controls, larger saved-prompt thumbnails, prompt copy/share icons */
@media (min-width:641px){
    .ai-prompt-builder-entry-button{
        flex:0 0 auto!important;
        width:auto!important;
        min-width:0!important;
        padding:9px 16px!important;
    }
}
@media (max-width:640px){
    .ai-prompt-builder-entry-button{
        flex:1 1 auto!important;
    }
}
.ai-prompt-library-mini{
    flex-wrap:nowrap!important;
}
.ai-prompt-library-thumb{
    flex:0 0 56px!important;
    width:56px!important;
    height:56px!important;
    border-radius:12px!important;
    font-size:14px!important;
    overflow:hidden!important;
}
.ai-prompt-library-thumb.has-image{
    background:#000!important;
    border-color:#cbd5e1!important;
    padding:0!important;
}
.ai-prompt-library-thumb.has-image img{
    width:100%!important;
    height:100%!important;
    object-fit:cover!important;
    display:block!important;
}
@media (max-width:520px){
    .ai-prompt-library-thumb{
        flex-basis:50px!important;
        width:50px!important;
        height:50px!important;
    }
}


/* v10b: mobile index prompt tools - show Save/Open only, desktop keeps Save/Open/Copy/Share */
@media (max-width:640px){
    .ai-prompt-library-mini #aiPromptLibraryCopyButton,
    .ai-prompt-library-mini #aiPromptLibraryShareButton{
        display:none!important;
    }
    .ai-prompt-library-mini{
        gap:6px!important;
        flex:0 0 auto!important;
    }
}
@media (min-width:641px){
    .ai-prompt-library-mini #aiPromptLibraryCopyButton,
    .ai-prompt-library-mini #aiPromptLibraryShareButton{
        display:inline-flex!important;
    }
}


.ai-batch-actions-top {
    display: flex;
    justify-content: center;
    margin: 0 0 14px;
}

.ai-download-all-button {
    min-width: 180px;
    font-weight: 700;
}


/* v4.50: recent carousel download icon and download-all fix */
.ai-recent-generated-thumb-wrap {
    position: relative;
    flex: 0 0 118px;
    width: 118px;
    height: 118px;
}

.ai-recent-generated-thumb-wrap .ai-recent-generated-thumb {
    width: 100%;
    height: 100%;
}

.ai-recent-generated-download {
    position: absolute;
    right: 7px;
    bottom: 7px;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,.88);
    background: rgba(15,23,42,.78);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(15,23,42,.22);
}

.ai-recent-generated-download:hover,
.ai-recent-generated-download:focus {
    background: rgba(37,99,235,.92);
    outline: none;
}

@media (max-width:520px) {
    .ai-recent-generated-thumb-wrap {
        flex-basis: 104px;
        width: 104px;
        height: 104px;
    }

    .ai-recent-generated-download {
        width: 32px;
        height: 32px;
    }
}


/* v4.51: recent download icon height and Download all spacing */
.ai-batch-actions-top {
    margin-top: 16px !important;
    margin-bottom: 14px !important;
}

.ai-recent-generated-download {
    min-height: 34px !important;
    height: 34px !important;
    max-height: 34px !important;
    line-height: 1 !important;
    flex: 0 0 34px !important;
}


/* v4.52: remove button for Recent Images carousel */
.ai-recent-generated-remove {
    position: absolute;
    right: 7px;
    top: 7px;
    width: 30px;
    min-width: 30px;
    height: 30px;
    min-height: 30px !important;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,.88);
    background: rgba(15,23,42,.78);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(15,23,42,.22);
    z-index: 2;
}
.ai-recent-generated-remove:hover,
.ai-recent-generated-remove:focus {
    background: rgba(220,38,38,.94);
    outline: none;
}
.ai-recent-generated-download {
    z-index: 2;
}


/* v4.53: smaller Recent Images remove X icon */
.ai-recent-generated-remove{
    right:-6px!important;
    top:-6px!important;
    width:18px!important;
    min-width:18px!important;
    height:18px!important;
    min-height:18px!important;
    max-height:18px!important;
    padding:0!important;
    font-size:9px!important;
    line-height:1!important;
    border-radius:999px!important;
    box-shadow:0 3px 8px rgba(15,23,42,.22)!important;
}
.ai-recent-generated-remove i{
    font-size:9px!important;
    line-height:1!important;
}


/* Browser-private storage notices and shared NSFW switch */
.ai-private-storage-note,
.ai-gallery-note.ai-private-storage-note {
    background: #ecfdf5 !important;
    border: 1px solid #86efac !important;
    color: #14532d !important;
    border-radius: 16px;
    padding: 14px 16px;
    font-weight: 600;
    line-height: 1.55;
}
.ai-nsfw-toggle-wrap { width: 100%; display: flex; justify-content: center; margin-top: 10px; }
.ai-nsfw-toggle { border: 1px solid #bbf7d0; background: #ecfdf5; color: #14532d; border-radius: 999px; padding: 9px 14px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; font-weight: 700; cursor: pointer; min-height: 44px; }
.ai-nsfw-toggle.is-enabled { background: #fff1f2; border-color: #fda4af; color: #9f1239; }
.ai-nsfw-toggle-track { width: 44px; height: 24px; border-radius: 999px; background: #22c55e; position: relative; display: inline-block; flex: 0 0 auto; }
.ai-nsfw-toggle.is-enabled .ai-nsfw-toggle-track { background: #e11d48; }
.ai-nsfw-toggle-knob { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(15,23,42,.25); transition: transform .16s ease; }
.ai-nsfw-toggle.is-enabled .ai-nsfw-toggle-knob { transform: translateX(20px); }
.ai-nsfw-toggle-label { white-space: nowrap; }


/* Version 3 NSFW toggle sizing */
.ai-nsfw-toggle { font-size: .92rem !important; min-height: 40px !important; padding: 7px 12px !important; }
.ai-nsfw-toggle-label { font-size: .92rem !important; line-height: 1.15 !important; }


/* v4 NSFW toggle and toast/layout tweaks */
.ai-nsfw-toggle .ai-nsfw-toggle-label { line-height: 1.25; }
@media (max-width: 520px) {
    .ai-nsfw-toggle-wrap .ai-nsfw-toggle,
    .ai-nsfw-toggle-wrap .ai-nsfw-toggle .ai-nsfw-toggle-label {
        font-size: 0.95rem !important;
    }
}


.ai-inline-toast-anchor {
    display: grid;
    gap: 10px;
    margin: 0 0 10px;
}

.ai-inline-toast-anchor:empty {
    display: none;
}

.ai-temp-toast.ai-temp-toast-inline {
    position: static !important;
    inset: auto !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12) !important;
    transform: none !important;
}

.ai-temp-toast.ai-temp-toast-inline.is-visible {
    opacity: 1 !important;
}


/* v4.6 image generator NSFW sizing */
.ai-nsfw-toggle-wrap .ai-nsfw-toggle,
.ai-nsfw-toggle-wrap .ai-nsfw-toggle .ai-nsfw-toggle-label {
    font-size: 1rem !important;
}
@media (max-width: 520px) {
    .ai-nsfw-toggle-wrap .ai-nsfw-toggle,
    .ai-nsfw-toggle-wrap .ai-nsfw-toggle .ai-nsfw-toggle-label {
        font-size: 1.04rem !important;
    }
}


.ai-image-chat-overlay {
    position: absolute;
    left: 10px;
    bottom: 10px;
    z-index: 5;
    width: 44px;
    height: 44px;
    min-height: 44px !important;
    border-radius: 999px !important;
    border: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    background: rgba(255, 255, 255, 0.94) !important;
    color: #111827 !important;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.22);
    cursor: pointer;
}
.ai-image-chat-overlay:hover,
.ai-image-chat-overlay:focus {
    background: #ffffff !important;
    color: var(--ai-blue) !important;
    outline: none;
    transform: translateY(-1px);
}
.ai-image-chat-overlay[hidden] { display:none !important; }
.ai-image-chat-overlay:disabled { opacity:0.65; cursor:wait; }


/* v4.9b prompt block inline toast */
.ai-inline-toast-anchor {
    width: 100% !important;
    grid-column: 1 / -1 !important;
    align-self: stretch !important;
}
.ai-temp-toast.ai-temp-toast-inline.ai-temp-toast-error {
    background: #fff1f2 !important;
    color: #9f1239 !important;
    border: 1px solid #fecdd3 !important;
    box-shadow: 0 10px 24px rgba(159, 18, 57, 0.14) !important;
}
.ai-temp-toast.ai-temp-toast-inline.ai-temp-toast-error .ai-temp-toast-close {
    background: rgba(159, 18, 57, 0.10) !important;
    color: #9f1239 !important;
}
.ai-temp-toast.ai-temp-toast-inline.ai-temp-toast-error .ai-temp-toast-close:hover,
.ai-temp-toast.ai-temp-toast-inline.ai-temp-toast-error .ai-temp-toast-close:focus {
    background: rgba(159, 18, 57, 0.18) !important;
    color: #881337 !important;
}
.ai-image-chat-overlay-icon {
    width: 23px;
    height: 23px;
    display: block;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.05;
    stroke-linecap: round;
    stroke-linejoin: round;
}


/* v4.12 inline prompt toast above NSFW toggle */
.ai-nsfw-toggle-wrap.ai-secondary-actions-wrap {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 10px !important;
}
.ai-nsfw-toggle-wrap .ai-inline-toast-anchor {
    width: 100% !important;
    margin: 0 0 6px !important;
    order: 1;
}
.ai-nsfw-toggle-wrap #aiNsfwToggle,
.ai-nsfw-toggle-wrap [data-ai-nsfw-toggle] {
    order: 2;
}
.ai-nsfw-toggle-wrap .ai-temp-toast.ai-temp-toast-inline {
    width: 100% !important;
}


/* v4.13 global error/warning toast colours */
.ai-temp-toast.ai-temp-toast-error,
.ai-temp-toast.ai-temp-toast-warning {
    background: #fff1f2 !important;
    color: #9f1239 !important;
    border: 1px solid #fecdd3 !important;
    box-shadow: 0 18px 50px rgba(159, 18, 57, 0.18) !important;
}
.ai-temp-toast.ai-temp-toast-error .ai-temp-toast-close,
.ai-temp-toast.ai-temp-toast-warning .ai-temp-toast-close {
    background: rgba(159, 18, 57, 0.10) !important;
    color: #9f1239 !important;
}
.ai-temp-toast.ai-temp-toast-error .ai-temp-toast-close:hover,
.ai-temp-toast.ai-temp-toast-error .ai-temp-toast-close:focus,
.ai-temp-toast.ai-temp-toast-warning .ai-temp-toast-close:hover,
.ai-temp-toast.ai-temp-toast-warning .ai-temp-toast-close:focus {
    background: rgba(159, 18, 57, 0.18) !important;
    color: #881337 !important;
    outline: 2px solid rgba(159, 18, 57, 0.28) !important;
}



/* v3.4.1: private-gallery confirmations remain visible for 15 seconds and use a compact green style. */
.ai-temp-toast.ai-temp-toast-success {
    background: #ecfdf3 !important;
    color: #166534 !important;
    border: 1px solid #86efac !important;
    box-shadow: 0 18px 50px rgba(22, 101, 52, 0.18) !important;
}
.ai-temp-toast.ai-temp-toast-success .ai-temp-toast-close {
    background: rgba(22, 101, 52, 0.10) !important;
    color: #166534 !important;
}
.ai-temp-toast.ai-temp-toast-success .ai-temp-toast-close:hover,
.ai-temp-toast.ai-temp-toast-success .ai-temp-toast-close:focus {
    background: rgba(22, 101, 52, 0.18) !important;
    outline: 2px solid rgba(22, 101, 52, 0.28) !important;
}
.ai-temp-toast.ai-temp-toast-compact .ai-temp-toast-message {
    font-size: 14px !important;
    line-height: 1.35 !important;
}

/* v4.62: Recent Images preview modal */
body.ai-recent-image-modal-open {
    overflow: hidden !important;
}
.ai-recent-image-modal[hidden] {
    display: none !important;
}
.ai-recent-image-modal {
    position: fixed !important;
    inset: 0 !important;
    z-index: 99999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 18px !important;
}
.ai-recent-image-modal-backdrop {
    position: absolute !important;
    inset: 0 !important;
    background: rgba(15, 23, 42, .72) !important;
    backdrop-filter: blur(3px) !important;
}
.ai-recent-image-modal-card {
    position: relative !important;
    z-index: 1 !important;
    width: min(94vw, 900px) !important;
    max-height: min(92vh, 920px) !important;
    overflow: auto !important;
    border-radius: 20px !important;
    background: #fff !important;
    box-shadow: 0 26px 80px rgba(15,23,42,.35) !important;
    border: 1px solid rgba(226,232,240,.95) !important;
}
.ai-recent-image-modal-close {
    position: absolute !important;
    top: -14px !important;
    right: -14px !important;
    z-index: 6 !important;
    width: 38px !important;
    height: 38px !important;
    border-radius: 999px !important;
    border: 1px solid rgba(255,255,255,.86) !important;
    background: rgba(15,23,42,.76) !important;
    color: #fff !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
}
.ai-recent-image-modal-image-wrap {
    position: relative !important;
    background: #020617 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 280px !important;
}
.ai-recent-image-modal-img {
    display: block !important;
    width: 100% !important;
    max-height: 72vh !important;
    object-fit: contain !important;
}
.ai-recent-image-modal-icon,
.ai-recent-image-modal-copy {
    position: absolute !important;
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    min-height: 42px !important;
    border-radius: 999px !important;
    border: 1px solid rgba(255,255,255,.86) !important;
    background: rgba(15,23,42,.78) !important;
    color: #fff !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    box-shadow: 0 8px 24px rgba(15,23,42,.25) !important;
    z-index: 5 !important;
}
.ai-recent-image-modal-chat {
    left: 12px !important;
    bottom: 12px !important;
}
.ai-recent-image-modal-regenerate {
    left: 62px !important;
    bottom: 12px !important;
}

.ai-recent-image-modal-regenerate .ai-regenerate-svg {
    width: 24px !important;
    height: 24px !important;
}
.ai-recent-image-modal-share {
    top: 12px !important;
    right: 12px !important;
}
.ai-recent-image-modal-download {
    right: 12px !important;
    bottom: 12px !important;
}
.ai-recent-image-modal-icon:hover,
.ai-recent-image-modal-icon:focus,
.ai-recent-image-modal-copy:hover,
.ai-recent-image-modal-copy:focus,
.ai-recent-image-modal-close:hover,
.ai-recent-image-modal-close:focus {
    background: rgba(37,99,235,.94) !important;
    outline: none !important;
}
.ai-recent-image-modal-prompt-wrap {
    padding: 14px 16px 16px !important;
}
.ai-recent-image-modal-prompt-head {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 10px !important;
    margin-bottom: 8px !important;
    color: #0f172a !important;
}
.ai-recent-image-modal-copy {
    position: static !important;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    background: #2563eb !important;
}
.ai-recent-image-modal-prompt {
    margin: 0 !important;
    padding: 12px 14px !important;
    border-radius: 14px !important;
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    color: #334155 !important;
    font-size: 14px !important;
    line-height: 1.55 !important;
    white-space: pre-wrap !important;
    word-break: break-word !important;
}
@media (max-width: 640px) {
    .ai-recent-image-modal {
        padding: 10px !important;
    }
    .ai-recent-image-modal-card {
        width: 96vw !important;
        max-height: 92dvh !important;
        border-radius: 16px !important;
    }
    .ai-recent-image-modal-img {
        max-height: 66dvh !important;
    }
    .ai-recent-image-modal-icon {
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
        min-height: 38px !important;
    }
    .ai-recent-image-modal-close {
        top: 8px !important;
        right: 8px !important;
    }
}

/* v4.63: recent image modal close button belongs to the popup chrome, not over the image. Keep bottom ad strip clear. */
.ai-recent-image-modal {
    align-items: flex-start !important;
    padding: 18px 18px 118px !important;
    overflow: auto !important;
}
.ai-recent-image-modal-card {
    margin-top: clamp(12px, 4vh, 48px) !important;
    max-height: calc(100dvh - 140px) !important;
    border-radius: 22px !important;
    overflow: auto !important;
}
.ai-recent-image-modal-topbar {
    display: flex !important;
    justify-content: flex-end !important;
    align-items: center !important;
    padding: 10px 10px 8px !important;
    background: #fff !important;
    border-bottom: 1px solid rgba(226, 232, 240, .9) !important;
    border-radius: 22px 22px 0 0 !important;
}
.ai-recent-image-modal-close {
    position: static !important;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    border-radius: 999px !important;
    border: 1px solid rgba(203, 213, 225, .95) !important;
    background: #f8fafc !important;
    color: #0f172a !important;
    box-shadow: none !important;
}
.ai-recent-image-modal-image-wrap {
    border-radius: 0 !important;
}
.ai-recent-image-modal-img {
    border-radius: 0 !important;
}

@media (max-width: 640px) {
    .ai-recent-image-modal {
        padding: 10px 10px 110px !important;
    }
    .ai-recent-image-modal-card {
        max-height: calc(100dvh - 124px) !important;
        border-radius: 18px !important;
    }
    .ai-recent-image-modal-topbar {
        border-radius: 18px 18px 0 0 !important;
    }
    .ai-recent-image-modal-close {
        top: auto !important;
        right: auto !important;
    }
}


/* v4.65: keep desktop recent-image popup clear of the 100px bottom ad strip. Mobile rules above are unchanged. */
@media (min-width: 761px) {
    .ai-recent-image-modal {
        padding-bottom: 132px !important;
    }
    .ai-recent-image-modal-card {
        max-height: calc(100dvh - 172px) !important;
        margin-top: clamp(10px, 3vh, 34px) !important;
    }
    .ai-recent-image-modal-img {
        max-height: calc(100dvh - 300px) !important;
        cursor: zoom-in !important;
    }
}


/* v90: keep temporary toast messages visible above bottom ads by centering them. */
.ai-temp-toast:not(.ai-temp-toast-inline) {
    position: fixed !important;
    left: 50% !important;
    top: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translate(-50%, -50%) scale(.96) !important;
    z-index: 2147483000 !important;
    max-width: min(92vw, 560px) !important;
}
.ai-temp-toast:not(.ai-temp-toast-inline).is-visible {
    transform: translate(-50%, -50%) scale(1) !important;
}
.ai-regenerate-svg {
    width: 19px !important;
    height: 19px !important;
    display: block !important;
    color: currentColor !important;
}


/* v4.71: recent-image popup re-generate button sits above download and uses a full-size icon. */
.ai-recent-image-modal .ai-recent-image-modal-regenerate {
    right: 12px !important;
    left: auto !important;
    bottom: 64px !important;
    width: 46px !important;
    height: 46px !important;
    min-width: 46px !important;
    min-height: 46px !important;
    padding: 0 !important;
    font-size: 26px !important;
    line-height: 1 !important;
}
.ai-recent-image-modal .ai-recent-image-modal-regenerate .ai-regenerate-svg {
    width: 30px !important;
    height: 30px !important;
    min-width: 30px !important;
    min-height: 30px !important;
    display: block !important;
    flex: 0 0 30px !important;
}
.ai-recent-image-modal .ai-recent-image-modal-regenerate .ai-regenerate-svg path {
    transform-box: fill-box !important;
    transform-origin: center !important;
    transform: scale(1.08) !important;
}
@media (max-width: 640px) {
    .ai-recent-image-modal .ai-recent-image-modal-regenerate {
        bottom: 58px !important;
        width: 42px !important;
        height: 42px !important;
        min-width: 42px !important;
        min-height: 42px !important;
    }
    .ai-recent-image-modal .ai-recent-image-modal-regenerate .ai-regenerate-svg {
        width: 28px !important;
        height: 28px !important;
        min-width: 28px !important;
        min-height: 28px !important;
        flex-basis: 28px !important;
    }
}


/* v4.72: match recent-image popup regenerate button to the 42x42 download button. */
.ai-recent-image-modal .ai-recent-image-modal-regenerate {
    right: 12px !important;
    left: auto !important;
    bottom: 64px !important;
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    min-height: 42px !important;
    padding: 0 !important;
}
.ai-recent-image-modal .ai-recent-image-modal-regenerate .ai-regenerate-svg {
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    min-height: 24px !important;
    flex-basis: 24px !important;
}
@media (max-width: 640px) {
    .ai-recent-image-modal .ai-recent-image-modal-regenerate {
        bottom: 58px !important;
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
        min-height: 38px !important;
    }
    .ai-recent-image-modal .ai-recent-image-modal-regenerate .ai-regenerate-svg {
        width: 22px !important;
        height: 22px !important;
        min-width: 22px !important;
        min-height: 22px !important;
        flex-basis: 22px !important;
    }
}


/* v4.73: make NSFW toggle wording a little more readable on mobile. */
@media (max-width: 640px) {
    .ai-nsfw-toggle-wrap .ai-nsfw-toggle,
    .ai-nsfw-toggle-wrap .ai-nsfw-toggle .ai-nsfw-toggle-label {
        font-size: 1rem !important;
        line-height: 1.2 !important;
    }
}


/* v4.74: mobile-only NSFW toggle wording readability. Desktop is unchanged. */
@media (max-width: 640px) {
    .ai-nsfw-toggle-wrap #aiNsfwToggle,
    .ai-nsfw-toggle-wrap #aiNsfwToggle .ai-nsfw-toggle-label,
    .ai-nsfw-toggle-wrap [data-ai-nsfw-toggle],
    .ai-nsfw-toggle-wrap [data-ai-nsfw-toggle] .ai-nsfw-toggle-label,
    .ai-nsfw-toggle-wrap .ai-nsfw-toggle,
    .ai-nsfw-toggle-wrap .ai-nsfw-toggle .ai-nsfw-toggle-label {
        font-size: 1.12rem !important;
        line-height: 1.22 !important;
    }
}


@media (max-width: 640px) {
    .ai-niche-page-button {
        font-size: 0.78rem;
        min-height: 36px;
        min-width: 36px;
        padding: 7px 9px;
    }
    .ai-niche-example-card-body { padding: 10px; }
}


.ai-niche-modal-status {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 9px;
    color: #065f46;
    font-size: 0.86rem;
    margin: 10px 0 0;
    padding: 8px 10px;
}
.ai-niche-modal-status.is-error {
    background: #fff1f2;
    border-color: #fecdd3;
    color: #9f1239;
}

/* v4.77 niche layout, typography and CTA refinements */
.ai-niche-search-icon {
    font-size: 1.28rem;
    left: 14px;
}

.ai-niche-search-input {
    font-size: 1rem;
    padding-left: 48px;
}

.ai-niche-card h3 {
    font-size: 1.34rem;
    line-height: 1.25;
}

.ai-niche-card p {
    font-size: 1.08rem;
    line-height: 1.48;
}

.ai-niche-card-cta {
    font-size: 1rem;
    line-height: 1.3;
}

.ai-niche-example-card h3 {
    font-size: 1.2rem;
    line-height: 1.34;
}

.ai-niche-example-prompt {
    font-size: 1.04rem !important;
    line-height: 1.58 !important;
}

.ai-niche-page .ai-niche-hero.ai-rws-section {
    min-height: 0 !important;
    height: auto !important;
    margin-bottom: 18px !important;
    padding-bottom: 20px;
}

.ai-niche-page .ai-niche-hero > p:last-child,
.ai-niche-page .ai-niche-prompt-section > p:last-child {
    margin-bottom: 0;
}

.ai-niche-page .ai-niche-gallery-section {
    margin-top: 0;
}

.ai-niche-create-button.btn-green {
    align-items: center !important;
    border-radius: 14px !important;
    display: inline-flex !important;
    justify-content: center !important;
    line-height: 1.25 !important;
    min-height: 54px !important;
    padding: 14px 28px !important;
    text-align: center;
}

@media (max-width: 640px) {
    .ai-niche-search-icon {
        font-size: 1.22rem;
        left: 13px;
    }

    .ai-niche-search-input {
        font-size: 1rem;
        padding-left: 46px;
    }

    .ai-niche-card h3 {
        font-size: 1.14rem;
        line-height: 1.3;
    }

    .ai-niche-card p {
        font-size: 1rem;
        line-height: 1.42;
    }

    .ai-niche-card-cta {
        font-size: 0.96rem;
        line-height: 1.3;
    }

    .ai-niche-example-card h3 {
        font-size: 1.08rem;
        line-height: 1.35;
    }

    .ai-niche-example-prompt {
        font-size: 0.98rem !important;
        line-height: 1.52 !important;
    }

    .ai-niche-create-button.btn-green {
        min-height: 52px !important;
        padding: 13px 22px !important;
    }
}

/* v4.78: final niche typography, hidden chat action and CTA refinements */
.ai-niche-hub-hint {
    font-size: 1.18rem !important;
    line-height: 1.5 !important;
    font-weight: 650 !important;
}
.ai-niche-search-input,
.ai-niche-search-input::placeholder {
    font-size: 1.16rem !important;
    line-height: 1.35 !important;
}
.ai-niche-search-icon {
    font-size: 1.48rem !important;
    left: 15px !important;
}
.ai-niche-search-input {
    min-height: 52px !important;
    padding-left: 52px !important;
}
.ai-niche-card h3 {
    font-size: 1.48rem !important;
    line-height: 1.28 !important;
}
.ai-niche-card p {
    font-size: 1.18rem !important;
    line-height: 1.52 !important;
}
.ai-niche-card-cta {
    font-size: 1.1rem !important;
    line-height: 1.35 !important;
}
.ai-niche-example-card h3 {
    font-size: 1.32rem !important;
    line-height: 1.4 !important;
}
.ai-niche-example-prompt {
    font-size: 1.16rem !important;
    line-height: 1.65 !important;
}
.ai-niche-prompt-copy {
    font-size: 0.98rem !important;
}
.ai-niche-create-button.btn-green {
    font-weight: 800 !important;
    font-size: 1.08rem !important;
}
.ai-recent-image-modal-chat[hidden],
.ai-recent-image-modal-chat.is-not-applicable {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}
@media (max-width: 640px) {
    .ai-niche-hub-hint {
        font-size: 1.08rem !important;
        line-height: 1.48 !important;
    }
    .ai-niche-search-input,
    .ai-niche-search-input::placeholder {
        font-size: 1.08rem !important;
    }
    .ai-niche-search-icon {
        font-size: 1.4rem !important;
    }
    .ai-niche-card h3 {
        font-size: 1.3rem !important;
        line-height: 1.3 !important;
    }
    .ai-niche-card p {
        font-size: 1.08rem !important;
        line-height: 1.48 !important;
    }
    .ai-niche-card-cta {
        font-size: 1.04rem !important;
        line-height: 1.35 !important;
    }
    .ai-niche-example-card h3 {
        font-size: 1.2rem !important;
    }
    .ai-niche-example-prompt {
        font-size: 1.08rem !important;
        line-height: 1.6 !important;
    }
    .ai-niche-prompt-copy {
        font-size: 0.94rem !important;
    }
    .ai-niche-create-button.btn-green {
        font-size: 1.04rem !important;
        font-weight: 800 !important;
    }
}

/* v4.80: force readable niche typography across legacy and responsive rules */
#aiNicheHub .ai-niche-hub-hint {
    font-size: 1.4rem !important;
    line-height: 1.55 !important;
    font-weight: 700 !important;
}
#aiNicheHub .ai-niche-search-input,
#aiNicheHub .ai-niche-search-input::placeholder {
    font-size: 1.25rem !important;
    line-height: 1.4 !important;
}
#aiNicheHub .ai-niche-search-icon {
    font-size: 1.7rem !important;
    width: 1.7rem !important;
    height: 1.7rem !important;
    line-height: 1.7rem !important;
}
#aiNicheHub .ai-niche-card .ai-niche-card-body h3,
#aiNicheHub .ai-niche-card h3 {
    font-size: 1.7rem !important;
    line-height: 1.28 !important;
    font-weight: 750 !important;
}
#aiNicheHub .ai-niche-card .ai-niche-card-body p,
#aiNicheHub .ai-niche-card p {
    font-size: 1.3rem !important;
    line-height: 1.55 !important;
}
#aiNicheHub .ai-niche-card .ai-niche-card-cta,
#aiNicheHub .ai-niche-card-cta {
    font-size: 1.22rem !important;
    line-height: 1.4 !important;
    font-weight: 700 !important;
}
body.ai-niche-page .ai-niche-example-card .ai-niche-example-card-body h3,
body.ai-niche-page .ai-niche-example-card h3 {
    font-size: 1.55rem !important;
    line-height: 1.4 !important;
    font-weight: 750 !important;
}
body.ai-niche-page .ai-niche-example-card .ai-niche-example-prompt,
body.ai-niche-page .ai-niche-example-prompt {
    font-size: 1.28rem !important;
    line-height: 1.68 !important;
}
body.ai-niche-page .ai-niche-example-card .ai-niche-prompt-copy,
body.ai-niche-page .ai-niche-prompt-copy {
    font-size: 1.08rem !important;
    font-weight: 700 !important;
}
body.ai-niche-page a.btn-green.ai-niche-create-button,
body.ai-niche-page .btn-green.ai-niche-create-button {
    font-size: 1.2rem !important;
    font-weight: 800 !important;
    padding: 16px 32px !important;
    min-height: 58px !important;
}

@media (max-width: 640px) {
    #aiNicheHub .ai-niche-hub-hint {
        font-size: 1.22rem !important;
    }
    #aiNicheHub .ai-niche-search-input,
    #aiNicheHub .ai-niche-search-input::placeholder {
        font-size: 1.16rem !important;
    }
    #aiNicheHub .ai-niche-search-icon {
        font-size: 1.58rem !important;
        width: 1.58rem !important;
        height: 1.58rem !important;
        line-height: 1.58rem !important;
    }
    #aiNicheHub .ai-niche-card .ai-niche-card-body h3,
    #aiNicheHub .ai-niche-card h3 {
        font-size: 1.48rem !important;
    }
    #aiNicheHub .ai-niche-card .ai-niche-card-body p,
    #aiNicheHub .ai-niche-card p {
        font-size: 1.18rem !important;
    }
    #aiNicheHub .ai-niche-card .ai-niche-card-cta,
    #aiNicheHub .ai-niche-card-cta {
        font-size: 1.12rem !important;
    }
    body.ai-niche-page .ai-niche-example-card .ai-niche-example-card-body h3,
    body.ai-niche-page .ai-niche-example-card h3 {
        font-size: 1.36rem !important;
    }
    body.ai-niche-page .ai-niche-example-card .ai-niche-example-prompt,
    body.ai-niche-page .ai-niche-example-prompt {
        font-size: 1.16rem !important;
        line-height: 1.62 !important;
    }
    body.ai-niche-page .ai-niche-example-card .ai-niche-prompt-copy,
    body.ai-niche-page .ai-niche-prompt-copy {
        font-size: 1rem !important;
    }
    body.ai-niche-page a.btn-green.ai-niche-create-button,
    body.ai-niche-page .btn-green.ai-niche-create-button {
        font-size: 1.12rem !important;
        padding: 15px 26px !important;
        min-height: 56px !important;
    }
}

/* v4.81: explicit pixel sizes so mobile/root-font rules cannot shrink niche text */
#aiNicheHub .ai-niche-hub-hint {
    font-size: 23px !important;
    line-height: 1.5 !important;
}
#aiNicheHub .ai-niche-search-input,
#aiNicheHub .ai-niche-search-input::placeholder {
    font-size: 20px !important;
    line-height: 1.4 !important;
}
#aiNicheHub .ai-niche-card .ai-niche-card-body h3,
#aiNicheHub .ai-niche-card h3 {
    font-size: 27px !important;
    line-height: 1.25 !important;
}
#aiNicheHub .ai-niche-card .ai-niche-card-body p,
#aiNicheHub .ai-niche-card p {
    font-size: 20px !important;
    line-height: 1.5 !important;
}
#aiNicheHub .ai-niche-card .ai-niche-card-cta,
#aiNicheHub .ai-niche-card-cta {
    font-size: 19px !important;
    line-height: 1.4 !important;
}
body.ai-niche-page .ai-niche-example-card .ai-niche-example-card-body h3,
body.ai-niche-page .ai-niche-example-card h3 {
    font-size: 23px !important;
    line-height: 1.35 !important;
}
body.ai-niche-page .ai-niche-example-card .ai-niche-example-prompt,
body.ai-niche-page .ai-niche-example-prompt {
    font-size: 19px !important;
    line-height: 1.62 !important;
}
body.ai-niche-page a.btn-green.ai-niche-create-button,
body.ai-niche-page .btn-green.ai-niche-create-button {
    font-size: 22px !important;
    line-height: 1.25 !important;
    font-weight: 800 !important;
    padding: 17px 34px !important;
    min-height: 60px !important;
}

@media (max-width: 640px) {
    #aiNicheHub .ai-niche-hub-hint {
        font-size: 21px !important;
    }
    #aiNicheHub .ai-niche-search-input,
    #aiNicheHub .ai-niche-search-input::placeholder {
        font-size: 19px !important;
    }
    #aiNicheHub .ai-niche-card .ai-niche-card-body h3,
    #aiNicheHub .ai-niche-card h3 {
        font-size: 24px !important;
    }
    #aiNicheHub .ai-niche-card .ai-niche-card-body p,
    #aiNicheHub .ai-niche-card p {
        font-size: 19px !important;
    }
    #aiNicheHub .ai-niche-card .ai-niche-card-cta,
    #aiNicheHub .ai-niche-card-cta {
        font-size: 18px !important;
    }
    body.ai-niche-page .ai-niche-example-card .ai-niche-example-card-body h3,
    body.ai-niche-page .ai-niche-example-card h3 {
        font-size: 22px !important;
    }
    body.ai-niche-page .ai-niche-example-card .ai-niche-example-prompt,
    body.ai-niche-page .ai-niche-example-prompt {
        font-size: 18px !important;
        line-height: 1.58 !important;
    }
    body.ai-niche-page a.btn-green.ai-niche-create-button,
    body.ai-niche-page .btn-green.ai-niche-create-button {
        width: 100% !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 21px !important;
        line-height: 1.25 !important;
        padding: 17px 24px !important;
        min-height: 60px !important;
    }
}


/* v4.82: mobile niche gallery and prompt-only example cards */
@media (max-width: 449px) {
    body.ai-niche-page .ai-niche-example-grid {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 18px !important;
    }
    body.ai-niche-page .ai-niche-example-card {
        width: 100% !important;
        max-width: none !important;
    }
    body.ai-niche-page .ai-niche-example-card-body {
        padding: 14px 14px 16px !important;
    }
    body.ai-niche-page .ai-niche-example-prompt {
        font-size: 19px !important;
        line-height: 1.58 !important;
        margin-top: 0 !important;
    }
}

/* v4.83: one-column landing cards on small phones and larger copy-prompt controls */
body.ai-niche-page .ai-niche-prompt-copy,
body.ai-niche-page .ai-niche-example-card .ai-niche-prompt-copy {
    font-size: 20px !important;
    line-height: 1.3 !important;
    font-weight: 800 !important;
    min-height: 48px !important;
    padding: 10px 17px !important;
}

@media (max-width: 449px) {
    #aiNicheHub .ai-niche-card-grid {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 20px !important;
    }
    #aiNicheHub .ai-niche-card {
        width: 100% !important;
        max-width: none !important;
    }
    #aiNicheHub .ai-niche-card-image-button {
        margin: 10px 10px 0 !important;
        width: calc(100% - 20px) !important;
    }
    body.ai-niche-page .ai-niche-prompt-copy,
    body.ai-niche-page .ai-niche-example-card .ai-niche-prompt-copy {
        font-size: 19px !important;
        min-height: 50px !important;
        padding: 11px 16px !important;
    }
}



/* v4.84: two-column niche grids, balanced typography and strict hidden NSFW control */
.ai-nsfw-toggle-wrap[hidden],
#aiNsfwToggleWrap[hidden] {
    display: none !important;
    visibility: hidden !important;
}

#aiNicheHub .ai-niche-card-grid,
body.ai-niche-page .ai-niche-example-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 18px !important;
}

#aiNicheHub .ai-niche-hub-hint {
    font-size: 19px !important;
    line-height: 1.45 !important;
    font-weight: 650 !important;
}
#aiNicheHub .ai-niche-search-input,
#aiNicheHub .ai-niche-search-input::placeholder {
    font-size: 18px !important;
    line-height: 1.35 !important;
}
#aiNicheHub .ai-niche-search-icon {
    font-size: 25px !important;
    width: 25px !important;
    height: 25px !important;
    line-height: 25px !important;
}
#aiNicheHub .ai-niche-card .ai-niche-card-body h3,
#aiNicheHub .ai-niche-card h3 {
    font-size: 23px !important;
    line-height: 1.24 !important;
}
#aiNicheHub .ai-niche-card .ai-niche-card-body p,
#aiNicheHub .ai-niche-card p {
    font-size: 17px !important;
    line-height: 1.45 !important;
}
#aiNicheHub .ai-niche-card .ai-niche-card-cta,
#aiNicheHub .ai-niche-card-cta {
    font-size: 17px !important;
    line-height: 1.35 !important;
}

body.ai-niche-page .ai-niche-gallery-section > p,
body.ai-niche-page .ai-niche-hero > p,
body.ai-niche-page .ai-niche-prompt-section > p,
body.ai-niche-page .ai-niche-faq-section > p {
    font-size: 18px !important;
    line-height: 1.52 !important;
}
body.ai-niche-page .ai-niche-example-card .ai-niche-example-prompt,
body.ai-niche-page .ai-niche-example-prompt {
    font-size: 16px !important;
    line-height: 1.5 !important;
}
body.ai-niche-page .ai-niche-example-card .ai-niche-prompt-copy,
body.ai-niche-page .ai-niche-prompt-copy {
    font-size: 17px !important;
    line-height: 1.25 !important;
    min-height: 46px !important;
    padding: 10px 16px !important;
}

@media (max-width: 640px) {
    #aiNicheHub .ai-niche-hub-hint {
        font-size: 17px !important;
    }
    #aiNicheHub .ai-niche-search-input,
    #aiNicheHub .ai-niche-search-input::placeholder {
        font-size: 17px !important;
    }
    #aiNicheHub .ai-niche-card .ai-niche-card-body h3,
    #aiNicheHub .ai-niche-card h3 {
        font-size: 21px !important;
    }
    #aiNicheHub .ai-niche-card .ai-niche-card-body p,
    #aiNicheHub .ai-niche-card p {
        font-size: 16px !important;
    }
    #aiNicheHub .ai-niche-card .ai-niche-card-cta,
    #aiNicheHub .ai-niche-card-cta {
        font-size: 17px !important;
    }
    body.ai-niche-page .ai-niche-gallery-section > p,
    body.ai-niche-page .ai-niche-hero > p,
    body.ai-niche-page .ai-niche-prompt-section > p,
    body.ai-niche-page .ai-niche-faq-section > p {
        font-size: 17px !important;
    }
    body.ai-niche-page .ai-niche-example-card .ai-niche-example-prompt,
    body.ai-niche-page .ai-niche-example-prompt {
        font-size: 16px !important;
        line-height: 1.48 !important;
    }
    body.ai-niche-page .ai-niche-example-card .ai-niche-prompt-copy,
    body.ai-niche-page .ai-niche-prompt-copy {
        font-size: 17px !important;
    }
}

@media (max-width: 449px) {
    #aiNicheHub .ai-niche-card-grid,
    body.ai-niche-page .ai-niche-example-grid {
        grid-template-columns: minmax(0, 1fr) !important;
    }
}

/* v3.4.1: restore signed-in Image to Image controls. */
.ai-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}
.ai-controls #aiAspectRatio {
    grid-column: 1 / 2 !important;
    width: 100% !important;
}
.ai-controls .ai-image-reference-toggle,
.ai-controls .ai-image-reference-teaser {
    grid-column: 2 / 3 !important;
    width: 100% !important;
}
.ai-controls #aiBatchSize {
    grid-column: 1 / 2 !important;
    width: 100% !important;
}
.ai-controls #aiModel {
    grid-column: 2 / 3 !important;
    width: 100% !important;
}
.ai-controls .ai-reference-panel {
    grid-column: 1 / -1 !important;
    display: block !important;
}
.ai-controls .ai-reference-panel[hidden] {
    display: none !important;
}
.ai-batch-actions-top[hidden] { display: none !important; }
@media (max-width: 700px) {
    .ai-controls #aiAspectRatio,
    .ai-controls .ai-image-reference-toggle,
    .ai-controls .ai-image-reference-teaser,
    .ai-controls #aiBatchSize,
    .ai-controls #aiModel,
    .ai-controls .ai-reference-panel {
        grid-column: 1 / -1 !important;
        width: 100% !important;
    }
}


/* v4.75: regeneration feedback inside the recent-image popup. */
.ai-recent-image-modal-regenerate.is-regenerating .ai-regenerate-svg {
    animation: aiRecentRegenerateSpin .9s linear infinite !important;
}
@keyframes aiRecentRegenerateSpin {
    to { transform: rotate(360deg); }
}
.ai-recent-image-modal-progress {
    position: absolute !important;
    left: 50% !important;
    bottom: 16px !important;
    transform: translateX(-50%) !important;
    width: min(430px, calc(100% - 132px)) !important;
    z-index: 6 !important;
    padding: 10px 12px 12px !important;
    border: 1px solid rgba(255,255,255,.82) !important;
    border-radius: 14px !important;
    background: rgba(15,23,42,.86) !important;
    box-shadow: 0 10px 30px rgba(15,23,42,.28) !important;
    color: #fff !important;
    pointer-events: none !important;
}
.ai-recent-image-modal-progress[hidden] {
    display: none !important;
}
.ai-recent-image-modal-progress-label {
    margin: 0 0 7px !important;
    font-size: .92rem !important;
    line-height: 1.25 !important;
    font-weight: 800 !important;
    text-align: center !important;
}
.ai-recent-image-modal-progress-track {
    width: 100% !important;
    height: 8px !important;
    overflow: hidden !important;
    border-radius: 999px !important;
    background: rgba(255,255,255,.28) !important;
}
.ai-recent-image-modal-progress-fill {
    width: 0;
    height: 100% !important;
    border-radius: inherit !important;
    background: #2563eb !important;
    transition: width .18s linear !important;
}
@media (max-width: 640px) {
    .ai-recent-image-modal-progress {
        width: min(300px, calc(100% - 104px)) !important;
        bottom: 12px !important;
        padding: 9px 10px 10px !important;
    }
    .ai-recent-image-modal-progress-label {
        font-size: .84rem !important;
    }
}


/* v4.76: iframe application sizing and two-column desktop results. */
body.ai-embedded-mode,
body.ai-embedded-mode #main-page,
body.ai-embedded-mode #page-content-basicpage,
body.ai-embedded-mode .main-center-column {
    min-height: 0 !important;
    height: auto !important;
    overflow: visible !important;
}
@media (min-width: 680px) {
    body.ai-embedded-mode #aiBatchGrid.ai-batch-grid:not([data-batch-size="1"]) {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}
@media (max-width: 679.98px) {
    body.ai-embedded-mode #aiBatchGrid.ai-batch-grid:not([data-batch-size="1"]) {
        grid-template-columns: minmax(0, 1fr) !important;
    }
}

/* v4.76: clear queued/running feedback in the recent-image popup. */
.ai-recent-image-modal-regenerate.is-regenerating .ai-regenerate-svg,
.ai-recent-image-modal-regenerate.is-queued .ai-regenerate-svg {
    animation: aiRecentRegenerateSpin .9s linear infinite !important;
}
.ai-recent-image-modal-regenerate.is-queued .ai-regenerate-svg {
    animation-duration: 1.45s !important;
    opacity: .84 !important;
}

/* v4.86: secure iframe viewport alignment, exact two-column batches and restored popup feedback. */
@media (min-width: 680px) {
    body.ai-embedded-mode #aiBatchGrid.ai-batch-grid[data-batch-size]:not([data-batch-size="1"]) {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        align-items: start !important;
    }
    body.ai-embedded-mode #aiBatchGrid.ai-batch-grid[data-batch-size]:not([data-batch-size="1"]) > .ai-batch-card {
        grid-column: auto !important;
        width: auto !important;
        max-width: none !important;
        min-width: 0 !important;
    }
}
@media (max-width: 679.98px) {
    body.ai-embedded-mode #aiBatchGrid.ai-batch-grid[data-batch-size] {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) !important;
    }
}

body.ai-embedded-mode.ai-recent-image-modal-open {
    overflow: hidden !important;
}
body.ai-embedded-mode .ai-recent-image-modal {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    min-height: 320px !important;
    padding: 10px 18px 18px !important;
    align-items: center !important;
    overflow: hidden !important;
}
body.ai-embedded-mode .ai-recent-image-modal-card {
    width: min(94%, 900px) !important;
    max-height: calc(100dvh - 28px) !important;
    margin: auto !important;
    overflow: auto !important;
}
body.ai-embedded-mode .ai-recent-image-modal-img {
    max-height: calc(100dvh - 190px) !important;
}
@media (max-width: 640px) {
    body.ai-embedded-mode .ai-recent-image-modal { padding: 6px !important; }
    body.ai-embedded-mode .ai-recent-image-modal-card {
        width: 100% !important;
        max-height: calc(100dvh - 12px) !important;
        margin: auto !important;
    }
    body.ai-embedded-mode .ai-recent-image-modal-img { max-height: calc(100dvh - 178px) !important; }
}

.ai-recent-image-modal-progress-label {
    font-size: 1.06rem !important;
    line-height: 1.3 !important;
}
@media (max-width: 640px) {
    .ai-recent-image-modal-progress-label {
        font-size: .96rem !important;
    }
}
.ai-recent-image-modal-progress-fill {
    width: var(--ai-recent-modal-progress, 0%) !important;
    transition: width .1s linear !important;
}
.ai-recent-image-modal-copy.is-copied {
    background: #16a34a !important;
    color: #fff !important;
}

#aiBatchGrid .ai-batch-card.ai-batch-cancelled .ai-batch-card-preview {
    min-height: 145px !important;
    height: auto !important;
    aspect-ratio: auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #e5e7eb !important;
}
#aiBatchGrid .ai-batch-card.ai-batch-cancelled .ai-batch-card-placeholder {
    display: block !important;
    visibility: visible !important;
    padding: 28px 64px !important;
    margin: 0 !important;
    color: #334155 !important;
    text-align: center !important;
    font-weight: 700 !important;
}
#aiBatchGrid .ai-batch-card.ai-batch-cancelled .ai-image-regenerate-overlay {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* v8.98: hidden cancelled-image elements must stay hidden even when generic image rules use display:block. */
#aiBatchGrid .ai-batch-image-link[hidden],
#aiBatchGrid .ai-batch-card-preview img[hidden],
#aiBatchGrid .ai-batch-card.ai-batch-cancelled .ai-batch-image-link,
#aiBatchGrid .ai-batch-card.ai-batch-cancelled .ai-batch-card-preview img {
    display: none !important;
    visibility: hidden !important;
}

/* v8.99: viewport iframe form layout.
   Generate stays in normal document flow immediately below the model selector;
   the prompt is compact enough for the control to remain easy to reach while
   generated results continue to scroll inside the private iframe. */
body.ai-embedded-mode {
    padding-bottom: 10px !important;
}
body.ai-embedded-mode .ai-card textarea,
body.ai-embedded-mode #aiPrompt {
    min-height: 130px !important;
    height: 130px;
    max-height: min(60dvh, 520px) !important;
    resize: vertical !important;
    overflow-y: auto !important;
}
body.ai-embedded-mode #aiGenerateButton {
    position: static !important;
    inset: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    transform: none !important;
    z-index: auto !important;
    width: 100% !important;
    box-shadow: none !important;
    grid-column: 1 / -1 !important;
}
@media (max-width: 640px) {
    body.ai-embedded-mode .ai-card textarea,
    body.ai-embedded-mode #aiPrompt {
        min-height: 112px !important;
        height: 112px;
        max-height: min(60dvh, 460px) !important;
        resize: vertical !important;
        overflow-y: auto !important;
    }
}

/* v4.85 / iframe package v3.1.0:
   Position the generated-image popup inside the portion of a tall content-sized
   iframe that is actually visible in the parent browser viewport. */
body.ai-embedded-mode .ai-recent-image-modal {
    position: absolute !important;
    inset: auto auto auto 0 !important;
    top: var(--rws-parent-visible-top, 0px) !important;
    width: 100% !important;
    height: var(--rws-parent-visible-height, 100dvh) !important;
    min-height: 280px !important;
    padding: 8px 12px !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
}
body.ai-embedded-mode .ai-recent-image-modal-card {
    width: min(94%, 900px) !important;
    max-height: calc(var(--rws-parent-visible-height, 100dvh) - 16px) !important;
    margin: auto !important;
    overflow: auto !important;
}
body.ai-embedded-mode .ai-recent-image-modal-img {
    max-height: max(220px, calc(var(--rws-parent-visible-height, 100dvh) - 190px)) !important;
}
@media (max-width: 640px) {
    body.ai-embedded-mode .ai-recent-image-modal { padding: 6px !important; }
    body.ai-embedded-mode .ai-recent-image-modal-card {
        width: 100% !important;
        max-height: calc(var(--rws-parent-visible-height, 100dvh) - 12px) !important;
    }
    body.ai-embedded-mode .ai-recent-image-modal-img {
        max-height: max(190px, calc(var(--rws-parent-visible-height, 100dvh) - 178px)) !important;
    }
}


/* iframe follow-up v9.02: keep the recent-image dialog above the 90px bottom advert and show copied feedback clearly. */
.ai-recent-image-modal-copy .ai-copy-success-tick {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 1em !important;
    height: 1em !important;
    color: #ffffff !important;
    font-size: 1.25rem !important;
    font-weight: 900 !important;
    line-height: 1 !important;
}
body.ai-embedded-mode .ai-recent-image-modal {
    --ai-recent-modal-bottom-clearance: 90px;
    height: max(210px, calc(var(--rws-parent-visible-height, 100dvh) - var(--ai-recent-modal-bottom-clearance))) !important;
    min-height: 210px !important;
    padding: 8px 12px 10px !important;
}
body.ai-embedded-mode .ai-recent-image-modal-card {
    max-height: max(190px, calc(var(--rws-parent-visible-height, 100dvh) - var(--ai-recent-modal-bottom-clearance) - 14px)) !important;
}
body.ai-embedded-mode .ai-recent-image-modal-img {
    max-height: max(150px, calc(var(--rws-parent-visible-height, 100dvh) - var(--ai-recent-modal-bottom-clearance) - 190px)) !important;
}
@media (max-width: 640px) {
    body.ai-embedded-mode .ai-recent-image-modal {
        --ai-recent-modal-bottom-clearance: 90px;
        padding: 6px 6px 8px !important;
    }
    body.ai-embedded-mode .ai-recent-image-modal-card {
        max-height: max(180px, calc(var(--rws-parent-visible-height, 100dvh) - var(--ai-recent-modal-bottom-clearance) - 10px)) !important;
    }
    body.ai-embedded-mode .ai-recent-image-modal-img {
        max-height: max(130px, calc(var(--rws-parent-visible-height, 100dvh) - var(--ai-recent-modal-bottom-clearance) - 176px)) !important;
    }
}


/* v9.03 / package v3.1.9: a shorter prompt box keeps the model and Generate controls nearby. */
body.ai-embedded-mode .ai-card textarea,
body.ai-embedded-mode #aiPrompt {
    min-height: 96px !important;
    height: 104px;
    max-height: min(60dvh, 520px) !important;
    resize: vertical !important;
    overflow-y: auto !important;
}
@media (max-width: 640px) {
    body.ai-embedded-mode .ai-card textarea,
    body.ai-embedded-mode #aiPrompt {
        min-height: 82px !important;
        height: 92px;
        max-height: min(60dvh, 460px) !important;
        resize: vertical !important;
        overflow-y: auto !important;
    }
}

/* v3.3.2: restore the prompt textarea resize handle. */
body.ai-embedded-mode #aiPrompt, body.ai-embedded-mode .ai-card #aiPrompt { resize: vertical !important; overflow-y: auto !important; min-height: 82px !important; max-height: min(60dvh, 520px) !important; }


/* v3.3.3: responsive niche cards, readable prompts, centred actions and a resizable prompt field. */
@media (min-width:900px) and (max-width:1200px) {
    #aiNicheHub .ai-niche-card-grid,
    body.ai-niche-page .ai-niche-example-grid { grid-template-columns:repeat(2,minmax(0,1fr)) !important; }
}
@media (min-width:1200.01px) {
    #aiNicheHub .ai-niche-card-grid,
    body.ai-niche-page .ai-niche-example-grid { grid-template-columns:repeat(3,minmax(0,1fr)) !important; }
}
body.ai-niche-page .ai-niche-example-card .ai-niche-example-prompt,
body.ai-niche-page .ai-niche-example-prompt { font-size:15px !important;line-height:1.5 !important; }
body.ai-niche-page .ai-niche-example-prompt-actions { display:flex !important;justify-content:center !important;align-items:center !important;width:100% !important;padding:8px 12px 14px !important; }
body.ai-niche-page .ai-niche-example-card .ai-niche-prompt-copy,
body.ai-niche-page .ai-niche-prompt-copy { display:inline-flex !important;align-items:center !important;justify-content:center !important;margin:0 auto !important; }
body.ai-embedded-mode #aiPrompt,
body.ai-embedded-mode .ai-card #aiPrompt { resize:vertical !important;overflow-y:auto !important;min-height:82px !important;max-height:min(60dvh,520px) !important; }


/* v3.4.1: keep the page title and share control in one stable row on every viewport. */
.ai-embedded-heading-block {
    position: relative !important;
    padding-right: 0 !important;
}
.ai-title-share-row {
    display: flex !important;
    align-items: flex-start !important;
    justify-content: space-between !important;
    gap: 12px !important;
    width: 100% !important;
    margin: 0 0 5px !important;
}
.ai-title-share-row > h1 {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}
.ai-page-share-button {
    position: static !important;
    order: 2 !important;
    flex: 0 0 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: transparent !important;
    color: #0802f5 !important;
    font-size: 30px !important;
    line-height: 1 !important;
    cursor: pointer !important;
}
.ai-page-share-button:hover,
.ai-page-share-button:focus-visible {
    background: #eef2ff !important;
    outline: 2px solid transparent !important;
}
#aiBatchActionsTop[hidden],
#aiBatchSummary[hidden],
#aiBatchGrid[hidden],
.ai-batch-actions-top[hidden],
.ai-batch-summary[hidden],
.ai-batch-grid[hidden] {
    display: none !important;
    min-height: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
}
body.ai-embedded-mode .ai-temp-toast:not(.ai-temp-toast-inline) {
    position: absolute !important;
    top: calc(var(--rws-parent-visible-top, 0px) + (var(--rws-parent-visible-height, 100dvh) / 2)) !important;
}
@media (max-width: 520px) {
    .ai-title-share-row { gap: 8px !important; margin-bottom: 4px !important; }
    .ai-title-share-row > h1 { line-height: 1.12 !important; }
    .ai-page-share-button { flex-basis: 40px !important; width: 40px !important; height: 40px !important; min-width: 40px !important; font-size: 26px !important; }
}

/* v3.4.0 final: every empty generator result surface must occupy zero space. */
#aiProgress[hidden],
#aiError[hidden],
#aiResult[hidden],
#aiRecentGeneratedCarousel[hidden],
#aiBatchActionsTop[hidden],
#aiBatchSummary[hidden],
#aiBatchGrid[hidden] {
    display:none !important;
    visibility:hidden !important;
    min-height:0 !important;
    height:0 !important;
    max-height:0 !important;
    margin:0 !important;
    padding:0 !important;
    border:0 !important;
    box-shadow:none !important;
    overflow:hidden !important;
}

/* v3.4.2: give desktop prompts a little more writing room without enlarging mobile. */
@media (min-width: 701px) {
    body.ai-embedded-mode #aiPrompt,
    body.ai-embedded-mode .ai-card #aiPrompt {
        min-height: 124px;
        height: 124px;
    }
}



/* v4.87: private-gallery overlay positions and timed storage notice. */
.ai-gallery-overlay-actions-left {
    inset: 8px auto auto 8px !important;
}
.ai-gallery-overlay-actions-right {
    inset: 8px 8px auto auto !important;
}
.ai-gallery-image-card > .ai-gallery-download-button {
    position: absolute !important;
    right: 8px !important;
    bottom: 8px !important;
    z-index: 3 !important;
}
.ai-gallery-note.ai-private-storage-note {
    font-size: .88rem !important;
    line-height: 1.45 !important;
    transition: opacity .35s ease, transform .35s ease !important;
}
.ai-gallery-note.ai-private-storage-note.is-auto-hiding {
    opacity: 0 !important;
    transform: translateY(-5px) !important;
}

/* v4.88: keep the mobile title and share control in the same top row. */
@media (max-width: 700px) {
    body.ai-embedded-mode .ai-embedded-heading-block {
        padding-top: 0 !important;
        margin-top: 0 !important;
    }
    body.ai-embedded-mode .ai-title-share-row {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) 44px !important;
        grid-template-rows: auto !important;
        align-items: start !important;
        column-gap: 10px !important;
        width: 100% !important;
        margin-top: 0 !important;
        margin-bottom: 8px !important;
    }
    body.ai-embedded-mode .ai-title-share-row > h1 {
        grid-column: 1 !important;
        grid-row: 1 !important;
        align-self: start !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    body.ai-embedded-mode .ai-title-share-row > .ai-page-share-button {
        grid-column: 2 !important;
        grid-row: 1 !important;
        align-self: start !important;
        justify-self: end !important;
        position: static !important;
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        margin: 0 !important;
    }
}

/* v4.88: a slightly taller desktop writing area. */
@media (min-width: 701px) {
    body.ai-embedded-mode #aiPrompt,
    body.ai-embedded-mode .ai-card #aiPrompt {
        min-height: 136px;
        height: 136px;
    }
}


/* v4.89: deterministic Image to Image placement beside the model selector. */
.ai-controls > .ai-control-field { min-width:0 !important; width:100% !important; }
.ai-controls .ai-control-field > select,
.ai-controls .ai-control-field > button,
.ai-controls .ai-control-field > .ai-image-reference-teaser { width:100% !important; max-width:none !important; margin:0 !important; }
.ai-controls > .ai-aspect-field { grid-column:1 !important; }
.ai-controls > .ai-batch-field { grid-column:2 !important; }
.ai-controls > .ai-model-field { grid-column:1 !important; }
.ai-controls > .ai-reference-toggle-field { grid-column:2 !important; }
.ai-controls.ai-reference-mode-active > .ai-model-field { display:none !important; }
.ai-controls.ai-reference-mode-active > .ai-reference-toggle-field { grid-column:1 / -1 !important; justify-self:center !important; width:min(100%,360px) !important; }
.ai-controls.ai-reference-mode-active .ai-image-reference-toggle { width:100% !important; max-width:none !important; }
@media(max-width:700px){
 .ai-controls > .ai-aspect-field,.ai-controls > .ai-batch-field,.ai-controls > .ai-model-field,.ai-controls > .ai-reference-toggle-field{grid-column:1 / -1 !important;}
 .ai-controls.ai-reference-mode-active > .ai-reference-toggle-field{width:100% !important;}
}


/* v3.5.7: desktop prompt is taller by default and remains user-resizable; mobile sizing is unchanged. */
@media (min-width:701px) {
    body.ai-embedded-mode #aiPrompt,
    body.ai-embedded-mode .ai-card #aiPrompt {
        min-height: 180px;
        height:180px;
        max-height:min(70dvh,680px) !important;
        resize:vertical !important;
        overflow-y:auto !important;
    }
}


/* v3.6.9: layout and dark-mode fixes */
.ai-image-to-image-wrap { margin-top: 12px !important; }
.ai-image-to-image-wrap .ai-image-to-image-button,
.ai-image-to-image-wrap .ai-link-to-page-button { display: inline-flex !important; width: 100% !important; justify-content: center !important; }
.ai-reference-panel-standalone { margin-top: 10px !important; }
.ai-reference-panel-standalone[hidden] { display: none !important; }
.ai-controls { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
.ai-controls .ai-aspect-field,
.ai-controls .ai-batch-field,
.ai-controls .ai-model-field { grid-column: auto !important; }
.ai-controls #aiAspectRatio,
.ai-controls #aiBatchSize,
.ai-controls #aiModel { width: 100% !important; }
@media (max-width: 980px) {
    .ai-controls { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
    .ai-controls .ai-model-field { grid-column: 1 / -1 !important; }
}
@media (max-width: 700px) {
    .ai-controls { grid-template-columns: minmax(0, 1fr) !important; }
    .ai-controls .ai-aspect-field,
    .ai-controls .ai-batch-field,
    .ai-controls .ai-model-field { grid-column: 1 / -1 !important; }
}
body.dark-mode .adhesion_wrapper.adhesion_container,
body.ai-dark-mode .adhesion_wrapper.adhesion_container,
html.dark-mode body .adhesion_wrapper.adhesion_container { background-color:#090d14 !important; }
body.dark-mode .ai-progress,
body.ai-dark-mode .ai-progress,
html.dark-mode body .ai-progress { background:#0f172a !important; border-color:rgba(148,163,184,.28) !important; color:#e5eefc !important; box-shadow:0 22px 60px rgba(2,6,23,.55) !important; }
body.dark-mode .ai-progress p,
body.ai-dark-mode .ai-progress p,
html.dark-mode body .ai-progress p { color:#e5eefc !important; }
body.dark-mode .ai-progress .ai-bar,
body.ai-dark-mode .ai-progress .ai-bar,
html.dark-mode body .ai-progress .ai-bar { background:rgba(30,41,59,.9) !important; }
body.dark-mode .ai-recent-image-modal-card,
body.ai-dark-mode .ai-recent-image-modal-card,
html.dark-mode body .ai-recent-image-modal-card { background:#0f172a !important; color:#e5eefc !important; border:1px solid rgba(148,163,184,.24) !important; }
body.dark-mode .ai-recent-image-modal-prompt-wrap,
body.ai-dark-mode .ai-recent-image-modal-prompt-wrap,
html.dark-mode body .ai-recent-image-modal-prompt-wrap { background:#111827 !important; border-color:rgba(148,163,184,.24) !important; }
body.dark-mode .ai-recent-image-modal-prompt-head,
body.ai-dark-mode .ai-recent-image-modal-prompt-head,
html.dark-mode body .ai-recent-image-modal-prompt-head { border-bottom-color:rgba(148,163,184,.24) !important; color:#f8fafc !important; }
body.dark-mode .ai-recent-image-modal-prompt,
body.ai-dark-mode .ai-recent-image-modal-prompt,
html.dark-mode body .ai-recent-image-modal-prompt { color:#e5eefc !important; background:#111827 !important; }
body.dark-mode .ai-recent-image-modal-progress,
body.ai-dark-mode .ai-recent-image-modal-progress,
html.dark-mode body .ai-recent-image-modal-progress { background:rgba(15,23,42,.96) !important; border-color:rgba(148,163,184,.34) !important; box-shadow:0 16px 46px rgba(2,6,23,.55) !important; }
body.dark-mode .ai-recent-image-modal-progress-label,
body.ai-dark-mode .ai-recent-image-modal-progress-label,
html.dark-mode body .ai-recent-image-modal-progress-label { color:#e5eefc !important; }
body.dark-mode .ai-recent-image-modal-progress-track,
body.ai-dark-mode .ai-recent-image-modal-progress-track,
html.dark-mode body .ai-recent-image-modal-progress-track { background:rgba(30,41,59,.96) !important; }
@media (prefers-color-scheme: dark) {
    .adhesion_wrapper.adhesion_container { background-color:#090d14 !important; }
    .ai-progress { background:#0f172a !important; border-color:rgba(148,163,184,.28) !important; color:#e5eefc !important; box-shadow:0 22px 60px rgba(2,6,23,.55) !important; }
    .ai-progress p { color:#e5eefc !important; }
    .ai-progress .ai-bar { background:rgba(30,41,59,.9) !important; }
    .ai-recent-image-modal-card { background:#0f172a !important; color:#e5eefc !important; border:1px solid rgba(148,163,184,.24) !important; }
    .ai-recent-image-modal-prompt-wrap,
    .ai-recent-image-modal-prompt { background:#111827 !important; color:#e5eefc !important; border-color:rgba(148,163,184,.24) !important; }
    .ai-recent-image-modal-prompt-head { color:#f8fafc !important; border-bottom-color:rgba(148,163,184,.24) !important; }
    .ai-recent-image-modal-progress { background:rgba(15,23,42,.96) !important; border-color:rgba(148,163,184,.34) !important; box-shadow:0 16px 46px rgba(2,6,23,.55) !important; }
    .ai-recent-image-modal-progress-label { color:#e5eefc !important; }
    .ai-recent-image-modal-progress-track { background:rgba(30,41,59,.96) !important; }
}


/* v3.7.1 final image-generator layout and dark-mode corrections. */
@media (min-width: 701px) {
    body.ai-embedded-mode #aiPrompt,
    body.ai-embedded-mode .ai-card #aiPrompt {
        min-height: 180px;
        height: 180px;
        max-height: min(70dvh, 680px) !important;
        resize: vertical !important;
        overflow: auto !important;
    }
}

.ai-controls {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 10px !important;
}
.ai-controls > .ai-aspect-field,
.ai-controls > .ai-batch-field,
.ai-controls > .ai-model-field {
    grid-column: auto !important;
    width: 100% !important;
    min-width: 0 !important;
}
@media (max-width: 650px) and (min-width: 521px) {
    .ai-controls { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
    .ai-controls > .ai-model-field { grid-column: 1 / -1 !important; }
}
@media (max-width: 520px) {
    .ai-controls { grid-template-columns: minmax(0, 1fr) !important; }
    .ai-controls > .ai-aspect-field,
    .ai-controls > .ai-batch-field,
    .ai-controls > .ai-model-field { grid-column: 1 / -1 !important; }
}

.ai-image-to-image-wrap {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100% !important;
    margin: 18px auto 0 !important;
}
.ai-image-to-image-wrap .ai-image-to-image-button {
    width: 96px !important;
    min-width: 96px !important;
    max-width: 96px !important;
    height: 48px !important;
    min-height: 48px !important;
    padding: 5px 7px !important;
    margin: 0 auto !important;
    border-radius: 999px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}
.ai-image-to-image-icon { width: 82px !important; height: 34px !important; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.ai-image-to-image-icon .ai-image-to-image-arrow { stroke-width: 4; }

body.ai-dark-mode .ai-progress,
html.ai-dark-mode body .ai-progress {
    background: #111827 !important;
    border: 1px solid #475569 !important;
    color: #f8fafc !important;
    box-shadow: 0 22px 60px rgba(0,0,0,.52) !important;
}
body.ai-dark-mode .ai-progress p,
html.ai-dark-mode body .ai-progress p { color: #f8fafc !important; }
body.ai-dark-mode .ai-progress .ai-bar,
html.ai-dark-mode body .ai-progress .ai-bar { background: #334155 !important; }
body.ai-dark-mode .ai-recent-image-modal-card,
html.ai-dark-mode body .ai-recent-image-modal-card { background:#111827 !important; border-color:#475569 !important; color:#f8fafc !important; }
body.ai-dark-mode .ai-recent-image-modal-prompt-wrap,
body.ai-dark-mode .ai-recent-image-modal-prompt,
html.ai-dark-mode body .ai-recent-image-modal-prompt-wrap,
html.ai-dark-mode body .ai-recent-image-modal-prompt { background:#0f172a !important; color:#f8fafc !important; border-color:#475569 !important; }
body.ai-dark-mode .ai-recent-image-modal-prompt-head,
html.ai-dark-mode body .ai-recent-image-modal-prompt-head { color:#f8fafc !important; border-bottom-color:#475569 !important; }
body.ai-dark-mode .ai-recent-image-modal-progress,
html.ai-dark-mode body .ai-recent-image-modal-progress { background:#111827 !important; border-color:#64748b !important; }
body.ai-dark-mode .ai-recent-image-modal-progress-label,
html.ai-dark-mode body .ai-recent-image-modal-progress-label { color:#f8fafc !important; }
body.ai-dark-mode .ai-recent-image-modal-progress-track,
html.ai-dark-mode body .ai-recent-image-modal-progress-track { background:#334155 !important; }

body.ai-dark-mode .adhesion_wrapper.adhesion_container,
html.ai-dark-mode body .adhesion_wrapper.adhesion_container { background-color:#090d14 !important; }

/* v3.7.2: corrected desktop control row and compact Image to Image icon button. */
.ai-controls {
    display:grid !important;
    grid-template-columns:repeat(3,minmax(0,1fr)) !important;
    gap:10px !important;
}
.ai-controls > .ai-aspect-field,
.ai-controls > .ai-batch-field,
.ai-controls > .ai-model-field {
    grid-column:auto !important;
    grid-row:auto !important;
    width:100% !important;
    min-width:0 !important;
    max-width:none !important;
}
.ai-controls > .ai-control-field > select {
    width:100% !important;
    min-width:0 !important;
    max-width:none !important;
}
@media (max-width:480px) and (pointer:fine) {
    .ai-controls { grid-template-columns:repeat(2,minmax(0,1fr)) !important; }
    .ai-controls > .ai-model-field { grid-column:1 / -1 !important; }
}
@media (max-width:760px) and (pointer:coarse), (max-width:420px) {
    .ai-controls { grid-template-columns:minmax(0,1fr) !important; }
    .ai-controls > .ai-aspect-field,
    .ai-controls > .ai-batch-field,
    .ai-controls > .ai-model-field { grid-column:1 / -1 !important; }
}
.ai-image-to-image-wrap.ai-secondary-actions-wrap {
    display:flex !important;
    justify-content:center !important;
    align-items:center !important;
    width:100% !important;
    margin:18px auto 0 !important;
    padding:0 !important;
}
.ai-image-to-image-wrap .ai-image-to-image-button,
.ai-image-to-image-wrap .ai-link-to-page-button.ai-image-to-image-button {
    flex:0 0 92px !important;
    width:92px !important;
    min-width:92px !important;
    max-width:92px !important;
    height:44px !important;
    min-height:44px !important;
    padding:0 12px !important;
    margin:0 auto !important;
    border:1px solid #cbd5e1 !important;
    border-radius:999px !important;
    background:#fff !important;
    color:#111827 !important;
    box-shadow:0 2px 8px rgba(15,23,42,.08) !important;
    display:inline-flex !important;
    align-items:center !important;
    justify-content:center !important;
    text-decoration:none !important;
    line-height:1 !important;
}
.ai-image-to-image-wrap .ai-image-to-image-button:hover,
.ai-image-to-image-wrap .ai-image-to-image-button:focus {
    background:#f8fafc !important;
    border-color:#94a3b8 !important;
    color:#0802f5 !important;
}
.ai-image-to-image-icon {
    display:inline-flex !important;
    align-items:center !important;
    justify-content:center !important;
    gap:7px !important;
    width:auto !important;
    height:auto !important;
    font-size:18px !important;
    color:inherit !important;
    fill:none !important;
    stroke:none !important;
}
.ai-image-to-image-icon i { display:inline-block !important; width:auto !important; height:auto !important; }
.ai-image-to-image-icon .ai-image-to-image-arrow { font-size:19px !important; font-weight:900 !important; }
body.ai-dark-mode .ai-image-to-image-wrap .ai-image-to-image-button,
html.ai-dark-mode body .ai-image-to-image-wrap .ai-image-to-image-button {
    background:#111827 !important;
    border-color:#475569 !important;
    color:#f8fafc !important;
}

/* v3.7.5 prompt controls and desktop drag-resize handle */
.ai-prompt-builder-entry-button{min-height:34px!important;padding:6px 14px!important;font-size:.92rem!important}
.ai-prompt-mini-icon{width:34px!important;height:34px!important;min-width:34px!important;min-height:34px!important}
@media (min-width:700px){body.ai-embedded-mode #aiPrompt{height:220px;min-height:130px!important;max-height:min(72dvh,720px)!important;resize:vertical!important;overflow:auto!important}.ai-prompt-resize-handle{display:flex!important;height:14px;margin:-5px 4px 7px;align-items:center;justify-content:center;cursor:ns-resize;touch-action:none}.ai-prompt-resize-handle span{width:54px;height:4px;border-radius:999px;background:#94a3b8}.ai-prompt-resize-handle:hover span{background:#475569}}


/* v3.7.6: desktop prompt resize, slightly smaller prompt-builder controls, and stable mobile control rows. */
body.ai-embedded-mode #aiPrompt,
body.ai-embedded-mode .ai-card #aiPrompt,
#aiPrompt {
    resize: vertical !important;
    overflow-y: auto !important;
}
@media (min-width: 700px) {
    body.ai-embedded-mode #aiPrompt,
    body.ai-embedded-mode .ai-card #aiPrompt {
        min-height: 104px !important;
        height: 160px !important;
        max-height: min(72dvh, 760px) !important;
    }
    .ai-prompt-resize-handle {
        display: flex !important;
        height: 14px !important;
        margin: -2px 4px 8px !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: ns-resize !important;
        touch-action: none !important;
    }
}
.ai-prompt-builder-entry-button {
    min-height: 32px !important;
    padding: 5px 12px !important;
    font-size: 0.95rem !important;
}
.ai-prompt-library-mini {
    gap: 6px !important;
}
.ai-prompt-mini-icon {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    min-height: 34px !important;
    /*font-size: 0.95rem !important;*/
}
@media (max-width: 699px) {
    .ai-controls {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
    .ai-controls > .ai-aspect-field,
    .ai-controls > .ai-batch-field {
        grid-column: auto !important;
    }
    .ai-controls > .ai-model-field {
        grid-column: 1 / -1 !important;
    }
    .ai-controls > .ai-control-field > select {
        width: 100% !important;
    }
}


/* v3.7.19: central pink model-failure toast. */
.ai-temp-toast.ai-temp-toast-model-error {
    background:#fce7f3 !important;
    color:#9d174d !important;
    border:2px solid #f9a8d4 !important;
    box-shadow:0 18px 55px rgba(157,23,77,.28) !important;
}
.ai-temp-toast.ai-temp-toast-model-error .ai-temp-toast-close {
    background:rgba(157,23,77,.12) !important;
    color:#9d174d !important;
}
