.listivky-generator {
    padding: calc(var(--page-hero-overlap) + 32px) 0 72px;
}

.greeting-card-container {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 500px);
    gap: 40px;
    align-items: start;
}

.card-form {
    padding: 32px;
    border: 1.5px solid #218bd2;
    border-radius: 22px;
    background: linear-gradient(180deg, #0a3683, #06235d 85%);
    box-shadow: 0 0 15px #0b94fe80;
}

.card-form__title {
    margin: 0 0 24px;
    font-size: clamp(22px, 2.2vw, 30px);
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.card-form__intro {
    margin: -10px 0 24px;
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1.5;
    letter-spacing: 0.01em;
}

.card-form__intro-icon {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 2px;
    vertical-align: -1px;
    color: var(--gold);
    filter: drop-shadow(0 0 4px rgba(255, 212, 0, 0.6));
}

.card-form__group {
    min-width: 0;
    margin: 0 0 24px;
    padding: 0;
    border: 0;
}

.card-form__label {
    display: block;
    margin: 0 0 12px;
    padding: 0;
    color: var(--text-muted);
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.03em;
}

.card-form__styles {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.style-option {
    position: relative;
}

.style-option input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.style-option label {
    position: relative;
    display: block;
    border: 1.5px solid rgba(130, 185, 255, 0.45);
    border-radius: 16px;
    background: rgba(2, 18, 64, 0.55);
    overflow: hidden;
    cursor: pointer;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.2s ease;
}

.style-option img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    object-position: center bottom;
}

.style-option span {
    display: block;
    padding: 10px 6px 11px;
    font-size: 15px;
    font-weight: 500;
    text-align: center;
}

.style-option label::after {
    content: "";
    position: absolute;
    top: 8px;
    right: 8px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--gold)
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='%23061a5c' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
        center / 16px no-repeat;
    box-shadow: 0 0 10px rgba(255, 212, 0, 0.6);
    opacity: 0;
    transform: scale(0.6);
    transition:
        opacity 0.2s ease,
        transform 0.2s ease;
}

.style-option input:hover + label {
    border-color: rgba(130, 185, 255, 0.9);
    transform: translateY(-2px);
}

.style-option input:checked + label {
    border-color: var(--gold);
    box-shadow:
        0 0 0 1px var(--gold),
        0 0 18px rgba(255, 212, 0, 0.35);
}

.style-option input:checked + label::after {
    opacity: 1;
    transform: scale(1);
}

.style-option input:focus-visible + label {
    outline: 2px solid var(--gold);
    outline-offset: 3px;
}

/* ---------- Акордеон «Готові промпти» ---------- */

.prompts {
    margin: 0 0 24px;
    border: 1.5px solid rgba(130, 185, 255, 0.45);
    border-radius: 14px;
    background: rgba(2, 18, 64, 0.55);
    transition: border-color 0.2s ease;
}

.prompts[open],
.prompts:hover {
    border-color: rgba(130, 185, 255, 0.9);
}

.prompts__toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.03em;
    list-style: none;
    cursor: pointer;
}

.prompts__toggle::-webkit-details-marker {
    display: none;
}

.prompts__title {
    flex: none;
}

/* Назва обраного промпту поруч із заголовком (не влазить — обрізається з «…») */
.prompts__chosen {
    min-width: 0;
    overflow: hidden;
    color: var(--gold);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.prompts__chosen:not(:empty)::before {
    content: "· ";
    color: var(--text-muted);
}

.prompts__chevron {
    flex: none;
    width: 18px;
    height: 18px;
    margin-left: auto;
    transition: transform 0.2s ease;
}

.prompts[open] .prompts__chevron {
    transform: rotate(180deg);
}

.prompts__list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 0 12px 12px;
}

.prompts__item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 14px;
    border: 1.5px solid rgba(130, 185, 255, 0.3);
    border-radius: 12px;
    background: rgba(10, 54, 131, 0.5);
    color: var(--white);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

.prompts__item:hover {
    border-color: rgba(130, 185, 255, 0.9);
}

.prompts__item[aria-pressed="true"] {
    border-color: var(--gold);
    box-shadow:
        0 0 0 1px var(--gold),
        0 0 14px rgba(255, 212, 0, 0.25);
}

.prompts__name {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
}

/* Повний текст промпту з'явиться в полі після кліку, тут — перші два рядки */
.prompts__text {
    display: -webkit-box;
    overflow: hidden;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.45;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.card-form__textarea {
    display: block;
    width: 100%;
    min-height: 132px;
    padding: 14px 16px;
    border: 1.5px solid rgba(130, 185, 255, 0.45);
    border-radius: 14px;
    background: rgba(2, 18, 64, 0.55);
    color: var(--white);
    font-family: inherit;
    font-size: 16px;
    line-height: 1.5;
    resize: vertical;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

.card-form__textarea:focus {
    border-color: var(--gold);
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 212, 0, 0.2);
}

.error-msg {
    margin: -8px 0 20px;
    padding: 12px 16px;
    border: 1px solid rgba(255, 120, 120, 0.55);
    border-radius: 12px;
    background: rgba(120, 10, 30, 0.35);
    color: #ffd0d0;
    font-size: 14px;
    line-height: 1.4;
}

.error-msg:empty {
    display: none;
}

.card-form__submit {
    min-width: 230px;
}

.card-form__submit-busy {
    display: none;
}

.card-form__submit:disabled {
    cursor: progress;
    opacity: 0.85;
    transform: none;
    box-shadow: 0 0 20px rgba(255, 212, 0, 0.2);
}

.card-form__submit:disabled .card-form__submit-idle {
    display: none;
}

.card-form__submit:disabled .card-form__submit-busy {
    display: inline;
}

.card-form__submit:disabled .btn__icon {
    animation: listivky-spin 1.2s linear infinite;
}

.card-result {
    position: relative;
    display: grid;
    aspect-ratio: 1 / 1;
    border: 1.5px dashed rgba(130, 185, 255, 0.55);
    border-radius: 22px;
    background: rgba(2, 18, 64, 0.45);
    overflow: hidden;
}

.card-result > * {
    grid-area: 1 / 1;
}

.card-result__placeholder,
.card-result__loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    text-align: center;
}

.card-result__icon {
    width: 48px;
    height: 48px;
    margin-bottom: 18px;
    color: var(--gold);
    filter: drop-shadow(0 0 10px rgba(255, 212, 0, 0.6));
}

.card-result__text {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 500;
}

.card-result__hint {
    max-width: 300px;
    margin: 0;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.45;
}

.card-result__spinner {
    width: 56px;
    height: 56px;
    margin-bottom: 20px;
    border: 4px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: listivky-spin 0.9s linear infinite;
}

.card-result__loader {
    display: none;
}

.greeting-card-container:has(.card-form__submit:disabled) .card-result__loader {
    display: flex;
}

.greeting-card-container:has(.card-form__submit:disabled) .card-result__placeholder,
.card-result:has(#generated-image-container img) .card-result__placeholder {
    display: none;
}

.card-result:has(#generated-image-container img) {
    border-style: solid;
    border-color: #218bd2;
    box-shadow: 0 0 15px #0b94fe80;
}

#generated-image-container:empty {
    display: none;
}

#generated-image-container img {
    width: 100% !important;
    height: 100% !important;
    aspect-ratio: 1 / 1;
    object-fit: cover;
}

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

@media (prefers-reduced-motion: reduce) {
    .card-result__spinner,
    .card-form__submit:disabled .btn__icon {
        animation-duration: 2.4s;
    }

    .style-option label,
    .style-option label::after,
    .prompts,
    .prompts__chevron,
    .prompts__item {
        transition: none;
    }
}

@media (max-width: 900px) {
    .greeting-card-container {
        grid-template-columns: minmax(0, 1fr);
        gap: 28px;
    }

    .card-result {
        width: 100%;
        max-width: 520px;
        justify-self: center;
    }

    .card-result:not(:has(#generated-image-container img)) {
        aspect-ratio: auto;
        min-height: 240px;
    }
}

@media (max-width: 600px) {
    .listivky-generator {
        padding-bottom: 48px;
    }

    .card-form {
        padding: 22px 16px;
        border-radius: 18px;
    }

    .card-form__title {
        margin-bottom: 18px;
    }

    .card-form__intro {
        margin-top: -6px;
        font-size: 14px;
    }

    .prompts__toggle {
        padding: 12px 14px;
        font-size: 14px;
    }

    .prompts__list {
        grid-template-columns: minmax(0, 1fr);
        padding: 0 10px 10px;
    }

    .card-form__styles {
        gap: 8px;
    }

    .style-option label {
        border-radius: 12px;
    }

    .style-option span {
        padding: 8px 2px 9px;
        font-size: 13px;
    }

    .style-option label::after {
        top: 6px;
        right: 6px;
        width: 22px;
        height: 22px;
        background-size: 14px;
    }

    .card-form__submit {
        width: 100%;
        min-width: 0;
    }

    .card-result__placeholder,
    .card-result__loader {
        padding: 24px 16px;
    }
}
