body.cpc-preset-ai-open {
    overflow: hidden;
}

.cpc-preset-ai-modal[hidden],
.cpc-preset-ai-modal [hidden] {
    display: none !important;
}

.cpc-preset-ai-modal {
    position: fixed;
    inset: 0;
    z-index: 100100;
    display: grid;
    place-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.cpc-preset-ai-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 17, 17, 0.62);
}

.cpc-preset-ai-dialog {
    position: relative;
    width: min(520px, 100%);
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
    box-sizing: border-box;
    padding: 24px;
    border: 1px solid #dedede;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 20px 55px rgba(0, 0, 0, 0.24);
    color: #181818;
}

.cpc-preset-ai-dialog h2,
.cpc-preset-ai-dialog h3 {
    margin: 0;
    color: #181818;
    letter-spacing: 0;
    text-transform: none;
}

.cpc-preset-ai-dialog h2 {
    padding-right: 44px;
    font-size: 22px;
    line-height: 1.25;
    font-weight: 700;
}

.cpc-preset-ai-dialog h3 {
    font-size: 15px;
    line-height: 1.3;
    font-weight: 700;
}

.cpc-preset-ai-close {
    position: absolute;
    top: 14px;
    right: 14px;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #f1f1f1;
    color: #202020;
    font-family: Arial, sans-serif;
    font-size: 30px;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
}

.cpc-preset-ai-close:hover,
.cpc-preset-ai-close:focus-visible {
    background: #e4e4e4;
    outline: 2px solid #181818;
    outline-offset: 2px;
}

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

.cpc-preset-ai-option {
    display: grid;
    gap: 10px;
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 8px 8px 12px;
    border: 2px solid #dedede;
    border-radius: 6px;
    background: #ffffff;
    color: #181818;
    text-align: center;
    cursor: pointer;
}

.cpc-preset-ai-option:hover,
.cpc-preset-ai-option:focus-visible {
    border-color: #181818;
    outline: 0;
}

.cpc-preset-ai-option.is-disabled,
.cpc-preset-ai-option:disabled {
    opacity: 0.48;
    cursor: not-allowed;
}

.cpc-preset-ai-option-image {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 4px;
    background: #f3f3f3;
}

.cpc-preset-ai-option-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cpc-preset-ai-option-label {
    display: block;
    font-size: 15px;
    line-height: 1.25;
    font-weight: 700;
    letter-spacing: 0;
}

.cpc-preset-ai-error,
.cpc-preset-ai-limit {
    margin: 14px 0 0;
    padding: 10px 12px;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.4;
}

.cpc-preset-ai-error {
    border: 1px solid #e3a3a3;
    background: #fff4f4;
    color: #8d1717;
}

.cpc-preset-ai-limit {
    border: 1px solid #e2cc8d;
    background: #fff9e8;
    color: #5f4a0c;
}

.cpc-preset-ai-progress {
    display: grid;
    justify-items: center;
    gap: 8px;
    margin-top: 26px;
    padding: 10px 0 4px;
    text-align: center;
}

.cpc-preset-ai-progress-icon {
    display: block;
    width: 42px;
    height: 42px;
    margin-bottom: 4px;
    border: 4px solid #dedede;
    border-top-color: #181818;
    border-radius: 50%;
    animation: cpc-preset-ai-spin 0.8s linear infinite;
}

.cpc-preset-ai-progress-title {
    font-size: 17px;
    line-height: 1.3;
}

.cpc-preset-ai-progress-message {
    min-height: 20px;
    color: #5c5c5c;
    font-size: 14px;
    line-height: 1.4;
}

.cpc-preset-ai-progress-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin-top: 10px;
}

.cpc-preset-ai-progress-track {
    position: relative;
    height: 8px;
    overflow: hidden;
    border-radius: 4px;
    background: #e5e5e5;
}

.cpc-preset-ai-progress-bar {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0;
    border-radius: inherit;
    background: #181818;
    transition: width 180ms ease;
}

.cpc-preset-ai-progress-value {
    min-width: 72px;
    color: #555555;
    font-size: 12px;
    line-height: 1.2;
    text-align: right;
}

.cpc-preset-ai-history {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid #e5e5e5;
}

.cpc-preset-ai-history-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.cpc-preset-ai-history-count {
    flex: 0 0 auto;
    color: #646464;
    font-size: 12px;
    line-height: 1.2;
}

.cpc-preset-ai-carousel {
    display: flex;
    gap: 10px;
    width: 100%;
    overflow-x: auto;
    padding: 2px 2px 8px;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
}

.cpc-preset-ai-history-item {
    flex: 0 0 112px;
    width: 112px;
    scroll-snap-align: start;
}

.cpc-preset-ai-history-card {
    display: grid;
    gap: 6px;
    width: 112px;
    margin: 0;
    padding: 6px 6px 8px;
    border: 1px solid #dedede;
    border-radius: 6px;
    background: #ffffff;
    color: #181818;
    cursor: pointer;
}

.cpc-preset-ai-history-card:hover,
.cpc-preset-ai-history-card:focus-visible {
    border-color: #181818;
    outline: 2px solid #181818;
    outline-offset: 1px;
}

.cpc-preset-ai-history-card img {
    display: block;
    width: 98px;
    height: 98px;
    object-fit: contain;
    border-radius: 3px;
    background-color: #ffffff;
    background-image: linear-gradient(45deg, #eeeeee 25%, transparent 25%), linear-gradient(-45deg, #eeeeee 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #eeeeee 75%), linear-gradient(-45deg, transparent 75%, #eeeeee 75%);
    background-position: 0 0, 0 5px, 5px -5px, -5px 0;
    background-size: 10px 10px;
}

.cpc-preset-ai-history-card span {
    font-size: 12px;
    line-height: 1.2;
    font-weight: 700;
}

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

@media (max-width: 540px) {
    .cpc-preset-ai-modal {
        align-items: end;
        padding: 12px;
    }

    .cpc-preset-ai-dialog {
        width: 100%;
        max-height: calc(100dvh - 24px);
        padding: 20px 16px calc(18px + env(safe-area-inset-bottom));
    }

    .cpc-preset-ai-dialog h2 {
        font-size: 20px;
    }

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

    .cpc-preset-ai-options {
        gap: 10px;
        margin-top: 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cpc-preset-ai-progress-icon {
        animation-duration: 1.8s;
    }

    .cpc-preset-ai-progress-bar {
        transition: none;
    }
}
