/* Add animations for the saved notification */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(200%);
    }
}

/* Smooth hover effect for the saved notification link */
.saved-notification a:hover {
    text-decoration-color: rgba(255, 255, 255, 1) !important;
    transition: text-decoration-color 0.2s ease;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Saved thumbnail templates */
.style-options-tabs {
    display: flex;
    gap: 4px;
    margin: 0 0 10px;
    border-bottom: 1px solid #e2e8f0;
}

.style-options-tab {
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 7px 10px;
}

.style-options-tab.active {
    border-bottom-color: #2563eb;
    color: #1d4ed8;
}

.style-options-panel[hidden] {
    display: none;
}

.title-use-case-inference {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.title-use-case-inference[hidden] {
    display: none;
}

.title-use-case-label {
    color: #64748b;
    font-size: 0.68rem;
    font-weight: 600;
    white-space: nowrap;
}

.title-use-case-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.title-use-case-tag {
    appearance: none;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: #fff;
    color: #475569;
    cursor: pointer;
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1;
    padding: 5px 8px;
    transition:
        border-color 150ms ease,
        background-color 150ms ease,
        color 150ms ease,
        transform 150ms ease;
}

.title-use-case-tag:hover {
    border-color: #7967ef;
    transform: translateY(-1px);
}

.title-use-case-tag[aria-pressed='true'] {
    border-color: #bbb;
    background: #fbf5e9;
}

.title-use-case-tag.is-loading {
    cursor: default;
    opacity: 0.65;
}

.style-option.is-use-case-recommended::after {
    content: 'thumb_up';
    position: absolute;
    z-index: 2;
    left: 4px;
    top: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #222;
    color: #fff;
    font-family: 'Material Icons';
    font-size: 11px;
    font-style: normal;
    font-weight: 400;
    font-feature-settings: 'liga';
    letter-spacing: normal;
    text-transform: none;
    line-height: 1;
    pointer-events: none;
}

@media (max-width: 600px) {
    .title-use-case-tag {
        font-size: 0.66rem;
    }
}

.style-reference-action {
    margin-bottom: 12px;
}

.style-reference-action .add-reference-btn {
    flex-direction: row;
    gap: 8px;
    justify-content: center;
    min-height: 44px;
    padding: 8px 12px;
}

.style-reference-action .reference-style-icon {
    background: transparent;
    height: auto;
    margin: 0;
    width: auto;
}

.style-reference-action .reference-style-container {
    margin-top: 10px;
}

.my-templates-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.my-template-card {
    position: relative;
    min-width: 0;
    overflow: hidden;
    border: 1px solid #dbe3ec;
    border-radius: 7px;
    background: #fff;
    cursor: pointer;
    text-align: left;
    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease,
        transform 0.15s ease;
}

.my-template-card:hover,
.my-template-card.active {
    border-color: #60a5fa;
    box-shadow: 0 3px 12px rgba(37, 99, 235, 0.14);
    transform: translateY(-1px);
}

.my-template-preview,
.my-template-preview-placeholder {
    display: block;
    width: 100%;
    height: 72px;
    object-fit: cover;
    background: #f1f5f9;
}

.my-template-preview-placeholder {
    display: grid;
    place-items: center;
    color: #94a3b8;
    font-size: 1.2rem;
}

.my-template-name {
    overflow: hidden;
    padding: 7px 25px 7px 8px;
    color: #334155;
    font-size: 0.72rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.my-template-prompt-badge {
    margin: -3px 8px 7px;
    color: #64748b;
    font-size: 0.62rem;
    font-weight: 600;
}

.my-template-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 21px;
    height: 21px;
    border: 0;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.72);
    color: #fff;
    cursor: pointer;
    font-size: 0.95rem;
    line-height: 1;
}

.my-templates-empty {
    padding: 16px 8px;
    color: #64748b;
    font-size: 0.78rem;
    line-height: 1.45;
    text-align: center;
}

.save-template-btn {
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    background: #eff6ff;
    color: #1d4ed8;
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 6px 8px;
}

.save-template-btn:hover {
    background: #dbeafe;
}

.recent-generations-load-more-wrap {
    display: flex;
    justify-content: center;
    padding-top: 12px;
}

.recent-generations-load-more {
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: #fff;
    color: #475569;
    cursor: pointer;
    font-size: 0.76rem;
    font-weight: 700;
    padding: 7px 16px;
}

.recent-generations-load-more:hover {
    border-color: #94a3b8;
    background: #f8fafc;
    color: #0f172a;
}

.recent-generations-load-more:disabled {
    cursor: wait;
    opacity: 0.65;
}

@media (max-width: 575px) {
    .my-templates-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Force visibility for preview container */
.image-preview-container.force-visible {
    display: block !important;
}

/* AI Engine Selection Styles */
.ai-engine-selection {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    text-align: center;
}

.engine-option {
    position: relative;
    min-width: 0;
}

.engine-option input[type='radio'],
.engine-option input[type='checkbox'] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.engine-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5px 6px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: linear-gradient(45deg, #f6fdff, transparent);
    position: relative; /* Needed for the checkmark positioning */
}

/* Faded background checkmark for selected engines */
.engine-label::before {
    /* content: "";
     position: absolute;
     inset: 0;
     background-image: url('/images/assets/checkcircle.png');
     background-position: bottom;
     background-repeat: no-repeat;
     background-size: 20% auto;
     opacity: 0;
     transition: opacity 0.55s ease;
     pointer-events: none; */
}

.engine-option input:checked + .engine-label::before {
    opacity: 0.44; /* faded out, watermark-like */
}

.engine-label:hover {
    border-color: #bbbbbb;
    background: #f8fafc;
}

.engine-option input:checked + .engine-label {
    border-color: #7b9aac;
    background: #b5daf5;
    border-width: 1px;
}

.engine-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    margin: 0;
    min-width: 0;
}

.engine-info .fa {
    color: #ffd700;
}

.engine-name {
    font-weight: 600;
    color: #1e293b;
    font-size: 0.95em;
}

.engine-badge {
    font-size: 0.74rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
    color: white;
    white-space: nowrap;
}

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

.engine-badge.auto {
    background: linear-gradient(135deg, #475569, #334155);
}

#engine-picker {
    flex-direction: column;
    align-items: stretch;
}

#engine-picker .engine-label-row {
    margin-bottom: 8px;
}

#engine-picker .engine-label {
    background: #fff;
    border-color: #e2e8f0;
    padding-block: 8px;
    margin: 0;
}

#engine-picker .engine-label:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

#engine-picker input:checked + .engine-label {
    background: #f2f7fc;
    border-color: #7ca8ca;
}

#engine-picker .engine-badge,
#engine-picker .engine-name-badge {
    background: rgb(var(--engine-accent, 71 85 105) / 14%) !important;
    color: var(--engine-ink, #334155);
    padding: 2px 4px;
    font-weight: 600;
}

#engine-picker .nano-2 {
    --engine-accent: 25 135 84;
    --engine-ink: #176b45;
}

#engine-picker .gpt-image-2\.5-sunburst {
    --engine-accent: 67 170 255;
    --engine-ink: #216ca6;
}

#engine-picker .gpt-image-2\.5-flare {
    --engine-accent: 0 34 224;
    --engine-ink: #253fb0;
}

#engine-picker .grok-imagine {
    --engine-accent: 17 24 39;
    --engine-ink: #263244;
}

#engine-picker .nano-2-lite {
    --engine-accent: 100 116 139;
    --engine-ink: #475569;
}

#engine-picker .dream {
    --engine-accent: 13 202 240;
    --engine-ink: #08788e;
}

#engine-picker .engine-info > div {
    color: #64748b;
    font-size: 0.72rem;
}

#engine-picker .engine-info .fa {
    color: #ffd775;
    font-size: 0.65rem;
}

#engine-picker .new-badge {
    left: auto;
    right: 5px;
    top: -7px;
    background: #fff1f2;
    color: #be3450;
    padding: 1px 4px;
    font-size: 7px;
}

#engine-picker.engine-picker-collapsed {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 10px;
}

.engine-picker-collapsed .engine-label-row {
    grid-column: 1 / -1;
}

.engine-picker-toggle {
    align-self: flex-start;
    padding: 6px 0;
    margin-top: 6px;
    border: 0;
    background: none;
    color: #475569;
    font: inherit;
    font-size: 0.8rem;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.engine-picker-toggle:focus-visible,
.engine-option input:focus-visible + .engine-label {
    outline: 2px solid #4299e1;
    outline-offset: 3px;
}

#engine-picker.engine-picker-collapsed .engine-picker-toggle {
    align-self: stretch;
    margin: 0;
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #fff;
    font-size: 0.75rem;
    text-decoration: none;
    white-space: nowrap;
}

.engine-picker-collapsed .engine-picker-toggle:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.engine-auto-summary,
.engine-picker-collapsed .engine-label-right,
.engine-picker-collapsed #engine-description-display,
.engine-picker-collapsed .ai-engine-selection > .engine-option:not(.engine-option-auto) {
    display: none !important;
}

.engine-picker-collapsed .engine-option-auto {
    grid-column: 1 / -1;
}

.engine-picker-collapsed .engine-option-auto input:checked + .engine-label {
    align-items: flex-start;
    gap: 7px;
    padding: 12px;
    background: #f8fafc;
    border-color: #cbd5e1;
    text-align: left;
}

.engine-picker-collapsed .engine-option-auto .engine-info {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
}

.engine-picker-collapsed .engine-option-auto .engine-info > div {
    font-size: 0.72rem;
    color: #64748b;
}

.engine-picker-collapsed .engine-auto-summary {
    display: block !important;
    font-size: 0.8rem;
    color: #475569;
}

.engine-badge.openai {
    background-color: #4299e1;
}

.engine-badge.gpt-image-2 {
    background-color: #2563eb;
}

.engine-badge.gpt-image-2\.5-sunburst {
    background-color: #43aaff;
}

.engine-badge.gpt-image-2\.5-flare {
    background-color: #0022e0;
}

.engine-badge.grok-imagine {
    background-color: #111827;
}

.engine-badge.imagen {
    background-color: #f59e0b;
}
.engine-badge.ideogram {
    background-color: rgb(89, 12, 171);
}
.engine-badge.nano-pro {
    background-color: #77408f;
}

.engine-badge.nano-banana {
    background-color: #010b0c;
}

.engine-badge.nano-2 {
    background-color: #0f766e;
}

.engine-badge.nano-2-lite {
    background-color: #64748b;
}

.prompt-options-toggle {
    align-items: center;
    background: transparent;
    border: 0;
    color: #64748b;
    cursor: pointer;
    display: inline-flex;
    font-size: 0.76rem;
    font-weight: 100;
    gap: 4px;
    margin: 0 0 4px;
    padding: 0;
}

.prompt-options-toggle:hover {
    color: #0f172a;
}

.prompt-options-toggle-icon {
    display: inline-block;
    transition: transform 0.18s ease;
}

.prompt-options-toggle[aria-expanded='true'] .prompt-options-toggle-icon {
    transform: rotate(180deg);
}

.prompt-controls-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
    margin-bottom: 0;
    justify-content: space-between;
}

.font-color-group {
    display: inline-grid;
    grid-template-columns: 1fr;
    align-items: center;
    gap: 4px;
    width: auto;
    max-width: 100%;
    margin: 0;
    justify-content: space-between;
    padding: 4px;
}

.font-color-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 0;
    padding: 0 5px;
}

.font-color-header label {
    margin: 0;
    font-size: 0.72rem;
    line-height: 1;
}

.font-color-enable {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
    color: #475569;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    user-select: none;
}

.font-color-enable input {
    width: 12px;
    height: 12px;
    margin: 0;
    accent-color: #ffe596;
}

.font-color-enable span {
    font-size: 0.62rem;
    line-height: 1;
}

.font-color-reset {
    border: 0;
    background: transparent;
    color: #64748b;
    font-size: 0.66rem;
    line-height: 1;
    padding: 0;
    cursor: pointer;
}

.font-color-reset:hover {
    color: #1e293b;
}

.font-color-picker-row {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.font-color-picker {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 5px;
    padding: 4px 5px;
    border-radius: 6px;
    color: #475569;
    font-size: 0.68rem;
    font-weight: 500;
    line-height: 1;
}

.font-color-picker span {
    display: block;
    font-size: 7px;
    text-transform: uppercase;
}

.font-color-picker input[type='color'] {
    width: 28px;
    height: 20px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.font-color-group:not(.has-font-colors) .font-color-picker {
    opacity: 0.72;
}

.font-color-group .description {
    margin-top: 4px;
    font-size: 0.66rem;
    line-height: 1.1;
}

.prompt-constraints-group {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    width: auto;
    max-width: 100%;
    margin: 0;
    padding: 4px;
}

.prompt-constraint-item {
    display: inline-flex;
    align-items: center;
    width: auto;
}

.prompt-constraint-option {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 5px 9px;
    color: #475569;
    background: transparent;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    user-select: none;
    transition:
        background-color 0.16s ease,
        border-color 0.16s ease,
        color 0.16s ease;
}
.prompt-constraint-item span {
    font-size: 0.7em;
    text-transform: uppercase;
}

.prompt-constraint-icon {
    height: 16px;
    width: 16px;
}

.prompt-constraint-option input {
    width: 12px;
    height: 12px;
    margin: 0;
    accent-color: #ffe596;
    vertical-align: middle;
}

.prompt-constraint-option:has(input:checked) {
    color: #0f172a;
    background: #ffffff;
    border-color: #cbd5e1;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.prompt-constraint-option:hover {
    background: #ffffff;
    border-color: #e2e8f0;
}

.logo-upload-section {
    flex: 1 0 100%;
    min-width: 0;
    margin-top: 8px;
}

.logo-section-toggle {
    width: fit-content;
    color: #64748b;
    font-size: 0.8rem;
    cursor: pointer;
    list-style: none;
}

.logo-section-toggle:hover,
.logo-upload-section[open] > .logo-section-toggle {
    color: #334155;
    text-decoration: underline;
}

.logo-section-toggle::-webkit-details-marker,
.brand-logo-picker-trigger::-webkit-details-marker {
    display: none;
}

.brand-overlay-group {
    display: grid;
    margin-top: 8px;
    margin-bottom: 8px;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
}

.brand-overlay-group > * {
    width: 100%;
}

.brand-overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 4px;
}

.brand-overlay-header label {
    margin: 0;
    font-size: 0.72rem;
    line-height: 1;
}

.brand-overlay-header span {
    color: #64748b;
    font-size: 0.62rem;
    line-height: 1;
}

.brand-overlay-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.brand-overlay-row select {
    min-width: 0;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #fff;
    color: #334155;
    font-size: 0.68rem;
    line-height: 1;
    padding: 5px 6px;
}

.brand-overlay-row > select[hidden] {
    display: none;
}

.brand-logo-picker {
    position: relative;
    min-width: 0;
}

.brand-logo-picker-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    min-height: 32px;
    padding: 5px 6px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #fff;
    color: #334155;
    font-size: 0.68rem;
    cursor: pointer;
    list-style: none;
}

.brand-logo-picker-trigger::after {
    content: '⌄';
}

#brand-logo-selected,
.brand-logo-option {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

#brand-logo-selected > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-logo-preview {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    object-fit: contain;
}

.brand-logo-options {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 30;
    max-height: 220px;
    overflow-y: auto;
    padding: 4px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 4px 12px rgb(15 23 42 / 12%);
}

.brand-logo-option {
    width: 100%;
    min-height: 32px;
    padding: 5px 6px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: #334155;
    font-size: 0.68rem;
    text-align: left;
}

.brand-logo-option:hover,
.brand-logo-option[aria-pressed="true"] {
    background: #f1f5f9;
}

.brand-logo-option:focus-visible,
.brand-logo-picker-trigger:focus-visible,
.logo-section-toggle:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.logo-overlay-btn {
    display: none;
}

.logo-overlay-dropdown {
    margin: 0 10px 10px;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.logo-overlay-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 120px auto auto;
    gap: 8px;
    align-items: center;
}

.logo-overlay-controls select {
    min-width: 0;
    border: 1px solid #dbe3ec;
    border-radius: 6px;
    color: #334155;
    font-size: 0.74rem;
    padding: 6px 7px;
}

.logo-overlay-apply-btn,
.logo-overlay-cancel-btn {
    border: 1px solid #dbe3ec;
    border-radius: 6px;
    background: #f8fafc;
    color: #334155;
    font-size: 0.72rem;
    line-height: 1;
    padding: 7px 9px;
    cursor: pointer;
}

.logo-overlay-apply-btn {
    background: linear-gradient(135deg, #7c3aed, #8b5cf6);
    border-color: #7c3aed;
    color: #fff;
    font-weight: 700;
    box-shadow: 0 3px 10px rgba(124, 58, 237, 0.28);
    transition:
        background 160ms ease,
        box-shadow 160ms ease,
        transform 160ms ease;
}

.logo-overlay-apply-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #6d28d9, #7c3aed);
    border-color: #6d28d9;
    box-shadow: 0 4px 13px rgba(109, 40, 217, 0.38);
    transform: translateY(-1px);
}

.logo-overlay-apply-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

.logo-overlay-help {
    margin-top: 6px;
    color: #64748b;
    font-size: 0.66rem;
    line-height: 1.15;
}

.logo-brand-create-form {
    display: grid;
    gap: 8px;
}

.logo-brand-create-header {
    display: grid;
    gap: 2px;
}

.logo-brand-create-header strong {
    color: #111827;
    font-size: 0.82rem;
    line-height: 1;
}

.logo-brand-create-header span {
    color: #64748b;
    font-size: 0.68rem;
    line-height: 1.2;
}

.logo-upload-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.logo-upload-picker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    margin: 0;
    padding: 7px 12px;
    border: 1px solid #111827;
    border-radius: 7px;
    background: #111827;
    color: #fff;
    cursor: pointer;
    font-size: 0.74rem;
    font-weight: 600;
    line-height: 1;
}

.logo-upload-picker:hover {
    background: #1f2937;
}

.logo-upload-picker.is-uploading {
    cursor: wait;
    opacity: 0.7;
}

.logo-upload-picker .material-icons {
    font-size: 16px;
}

.logo-upload-picker input[type='file'] {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

@media (max-width: 640px) {
    .logo-overlay-controls {
        grid-template-columns: 1fr 1fr;
    }

    .logo-upload-actions {
        width: 100%;
    }

    .logo-upload-picker {
        flex: 1;
    }
}

.brand-preview-logo {
    position: absolute;
    z-index: 4;
    object-fit: contain;
    cursor: move;
    pointer-events: auto;
    touch-action: none;
    user-select: none;
    filter: drop-shadow(0 2px 7px rgba(15, 23, 42, 0.32));
}

.thumbnail-image img.brand-preview-logo {
    height: auto;
    object-fit: contain;
}

.brand-preview-resize-handle {
    position: absolute;
    z-index: 5;
    width: 14px;
    height: 14px;
    border: 2px solid #ffffff;
    border-radius: 999px;
    background: #2563eb;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.28);
    cursor: nwse-resize;
    touch-action: none;
}

.engine-info div {
    font-size: 0.8em;
}
.engine-description {
    font-size: 0.85em;
    color: #64748b;
    line-height: 1.3;
}

.engine-option input:checked + .engine-label .engine-name {
    color: #1e40af;
}

.engine-option input:checked + .engine-label .engine-description {
    color: #1e40af;
}

/* Auto-selected State */
.engine-option.auto-selected .engine-label {
    border-color: #22c55e;
    background: linear-gradient(180deg, #86efac, #ffffff);
    border-style: dashed;
    opacity: 0.9;
}

.engine-option.auto-selected .engine-name {
    color: #16a34a;
}

.engine-option.auto-selected .engine-description {
    color: #16a34a;
}

.engine-option.auto-selected .engine-label::after {
    content: 'AUTO';
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 0.6em;
    font-weight: bold;
    color: #16a34a;
    opacity: 0.8;
}

/* Warning and Required States */
.engine-option.warning .engine-label {
    border-color: #f59e0b;
    background: #fef3c7;
}

.engine-option.required .engine-label {
    border-color: #ef4444;
    background: #fee2e2;
}

.engine-warning {
    font-size: 0.8em;
    color: #d97706;
    margin-top: 4px;
    font-weight: 500;
}

.engine-option.required .engine-warning {
    color: #dc2626;
}

.engine-description-display {
    margin-top: 5px;
    padding: 7px;
    color: #4a5568;
    font-size: 0.875rem;
    transition: opacity 0.3s ease;
}

/* Video Demo Styles */
.video-demo-container {
    margin-bottom: 24px;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    background: #f8fafc;
    display: none; /* Initially hidden */
}

.video-placeholder {
    position: relative;
    cursor: pointer;
    display: block;
    width: 200px;
    float: left;
}

.video-placeholder img {
    width: 100%;
    display: block;
    border-radius: 12px;
    transition: transform 0.3s ease;
}

.video-placeholder:hover img {
    transform: scale(1.03);
}

.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.6) 0%, rgba(0, 0, 0, 0.1) 50%, rgba(0, 0, 0, 0) 100%);
    border-radius: 12px;
    pointer-events: none;
}

.play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    color: #ef4444; /* red */
    border-radius: 50%;
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.play-button svg {
    width: 32px;
    height: 32px;
    margin-left: 4px;
}

.video-placeholder:hover .play-button {
    background: #ef4444;
    color: white;
    transform: translate(-50%, -50%) scale(1.1);
}

.hide-video-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.4);
    color: white;
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    font-size: 16px;
    line-height: 26px;
    text-align: center;
    cursor: pointer;
    transition: background 0.2s ease;
    z-index: 10;
}
.hide-video-btn:hover {
    background: rgba(0, 0, 0, 0.7);
}

.video-iframe-container {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
}

.video-iframe-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Video Popout Modal */
.video-popout-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    z-index: 1050; /* Higher than other content */
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.video-popout-content {
    position: relative;
    width: 85vw;
    max-width: 1280px;
    background: black;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    animation: scaleIn 0.3s ease;
}

@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.video-popout-iframe-container {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
    border-radius: 12px;
    overflow: hidden;
}

.video-popout-iframe-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.video-popout-close {
    position: absolute;
    top: -40px;
    right: -10px;
    background: transparent;
    border: none;
    color: white;
    font-size: 40px;
    font-weight: 300;
    cursor: pointer;
    transition: transform 0.2s ease;
    line-height: 1;
}

.video-popout-close:hover {
    transform: scale(1.1);
    color: #ddd;
}

.marketing-section-prose {
    padding: 24px;
    background-color: #f8fafc;
    border-radius: 12px;
    margin-bottom: 24px;
    border: 1px solid #e2e8f0;
}
.marketing-section-prose h2 {
    font-size: 1.5em;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 16px;
}
.marketing-section-prose p {
    font-size: 1rem;
    color: #4a5568;
    line-height: 1.6;
    margin-bottom: 12px;
}
.marketing-section-prose strong,
.faq-answer strong {
    font-weight: normal;
}

/* Edit with AI Button and Dropdown Styles */
.edit-with-ai-btn {
}

.edit-with-ai-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.edit-with-ai-btn:active {
    transform: translateY(0);
}

/* AI Edit Dropdown */
.ai-edit-dropdown {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    margin-top: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    gap: 8px;
    align-items: center;
    animation: slideDown 0.2s ease;
}

.ai-edit-prompt-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.2s ease;
}

.ai-edit-prompt-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.ai-edit-prompt-input::placeholder {
    color: #9ca3af;
}

.ai-edit-engine-select {
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.875rem;
    background: white;
    color: #495057;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
    min-width: 100px;
    font-weight: 500;
}

.ai-edit-engine-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.ai-edit-engine-select:hover {
    border-color: #cbd5e1;
}

.ai-edit-apply-btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.ai-edit-apply-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.ai-edit-apply-btn:active {
    transform: translateY(0);
}

.ai-edit-cancel-btn {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    background: white;
    color: #6b7280;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    transition: all 0.2s ease;
}

.ai-edit-cancel-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

/* Shared generation and editing purchase modal */
.purchase-overlay {
    background: rgba(15, 23, 42, 0.68);
    backdrop-filter: blur(4px);
    padding: 1rem;
}

.purchase-modal.pricing-modal {
    border: 1px solid #dbe4f0;
    border-radius: 1.25rem;
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.24);
    max-height: min(90vh, 850px);
    max-width: 900px;
    padding: 2rem;
    width: 100%;
}

.purchase-modal .purchase-modal-close {
    align-items: center;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    color: #64748b;
    display: flex;
    font-size: 1.45rem;
    height: 34px;
    justify-content: center;
    right: 16px;
    top: 16px;
    transition: background-color 0.18s ease, color 0.18s ease;
    width: 34px;
}

.purchase-modal .purchase-modal-close:hover,
.purchase-modal .purchase-modal-close:focus-visible {
    background: #eef2ff;
    color: #312e81;
}

.purchase-modal .pricing-header {
    margin: 0 auto 1.5rem;
    max-width: 760px;
    padding: 0 2rem;
}

.purchase-modal .pricing-header h2 {
    color: #0f172a;
    font-size: clamp(1.55rem, 4vw, 1.9rem);
    font-weight: 750;
    letter-spacing: -0.035em;
    line-height: 1.12;
    margin: 0;
}

.purchase-modal .pricing-header p {
    color: #64748b;
    font-size: 0.92rem;
    line-height: 1.55;
    margin: 0.65rem 0 0;
}

.purchase-modal .pricing-grid {
    align-items: stretch;
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 0;
}

.purchase-modal .pricing-plan {
    background: #ffffff;
    border: 1px solid #dbe4f0;
    border-radius: 0.95rem;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.045);
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 1.15rem;
    position: relative;
}

.purchase-modal .pricing-plan.popular {
    border: 2px solid #4f46e5;
    box-shadow: 0 16px 34px rgba(79, 70, 229, 0.16);
    transform: translateY(-0.3rem);
}

.purchase-modal .pricing-plan:hover {
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.1);
    transform: translateY(-2px);
}

.purchase-modal .pricing-plan.popular:hover {
    transform: translateY(-0.4rem);
}

.pricing-plan-badge {
    background: #4f46e5;
    border-radius: 999px;
    color: #ffffff;
    font-size: 0.67rem;
    font-weight: 720;
    left: 50%;
    padding: 0.36rem 0.65rem;
    position: absolute;
    top: 0;
    transform: translate(-50%, -55%);
    white-space: nowrap;
}

.purchase-modal .plan-header {
    margin: 0 0 0.9rem;
    text-align: left;
}

.purchase-modal .plan-name {
    color: #0f172a;
    font-size: 1rem;
    font-weight: 740;
    margin: 0 0 0.55rem;
}

.purchase-modal .plan-price {
    color: #0f172a;
    font-size: 2.15rem;
    font-weight: 780;
    letter-spacing: -0.055em;
    line-height: 1;
    margin: 0;
}

.purchase-modal .plan-price span {
    font-size: 0.95rem;
    margin-right: 0.12rem;
    vertical-align: 0.72rem;
}

.purchase-modal .plan-billing {
    color: #64748b;
    font-size: 0.72rem;
    margin-top: 0.35rem;
}

.purchase-modal .plan-description {
    color: #64748b;
    font-size: 0.78rem;
    line-height: 1.4;
    margin: 0.7rem 0 0;
    min-height: 2rem;
}

.purchase-modal .plan-features {
    border-top: 1px solid #e2e8f0;
    margin: 0 0 1rem;
    padding-top: 0.9rem;
}

.purchase-modal .plan-feature {
    align-items: flex-start;
    color: #334155;
    font-size: 0.8rem;
    gap: 0.38rem;
    line-height: 1.35;
    margin-bottom: 0.58rem;
}

.purchase-modal .plan-feature svg {
    color: #16a34a;
    margin-top: 0.02rem;
}

.purchase-modal .plan-cta {
    border-radius: 0.7rem;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 740;
    margin-top: auto;
    min-height: 42px;
    padding: 0.65rem 0.7rem;
}

.purchase-modal .plan-cta.primary {
    background: #4f46e5;
    border: 1px solid #4f46e5;
    box-shadow: 0 9px 20px rgba(79, 70, 229, 0.19);
}

.purchase-modal .plan-cta.primary:hover,
.purchase-modal .plan-cta.primary:focus-visible {
    background: #4338ca;
    border-color: #4338ca;
}

.purchase-modal .plan-cta.secondary {
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    color: #3730a3;
}

.purchase-modal .plan-cta.secondary:hover,
.purchase-modal .plan-cta.secondary:focus-visible {
    background: #e0e7ff;
    border-color: #a5b4fc;
}

.purchase-modal .plan-cta.current,
.purchase-modal .plan-cta.current:disabled {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #047857;
    cursor: default;
    opacity: 1;
    transform: none;
}

.purchase-modal .plan-cta:disabled,
.purchase-modal .credit-pack:disabled {
    cursor: wait;
    opacity: 0.55;
    transform: none;
}

.purchase-modal .plan-cta.is-loading,
.purchase-modal .credit-pack.is-loading {
    opacity: 1;
}

.purchase-options-switch {
    display: flex;
    justify-content: center;
    gap: 0.3rem;
    width: fit-content;
    max-width: 100%;
    margin: 0 auto 1.8rem;
    padding: 0.3rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.85rem;
    background: #f1f5f9;
}

.purchase-options-switch button {
    border: 0;
    border-radius: 0.6rem;
    background: transparent;
    color: #475569;
    cursor: pointer;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    min-height: 44px;
    padding: 0.65rem 1rem;
}

.purchase-options-switch button[aria-pressed="true"] {
    background: #4f46e5;
    color: #fff;
    box-shadow: 0 3px 8px rgba(79, 70, 229, 0.18);
}

.purchase-options-switch button:focus-visible {
    outline: 2px solid #4f46e5;
    outline-offset: 3px;
}

.purchase-options-switch span {
    display: block;
    font-size: 0.65rem;
    font-weight: 400;
    margin-top: 0.15rem;
}

.purchase-modal .credits-section[hidden],
.purchase-modal .pricing-grid[hidden] {
    display: none;
}

.purchase-modal .credits-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.purchase-modal .credit-pack-card {
    padding: 1.65rem;
}

.purchase-modal .credit-pack-card.best-value {
    background: #faf9ff;
    border: 2px solid #4f46e5;
}

.purchase-modal .credit-pack-card .plan-name {
    font-size: 1.4rem;
}

.purchase-modal .credit-pack-quantity {
    color: #475569;
    font-size: 1rem;
    font-weight: 600;
    margin: -0.1rem 0 1rem;
}

.purchase-modal .credit-pack-card .plan-price {
    font-size: 3.25rem;
}

.purchase-modal .credit-pack-card .plan-description {
    min-height: 0;
}

.purchase-modal .credits-note {
    color: #64748b;
    font-size: 0.75rem;
    line-height: 1.5;
    margin: 1rem 0 0;
    text-align: center;
}

.purchase-modal .pricing-guarantees {
    align-items: center;
    background: #f8fafc;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    justify-content: center;
    margin-top: 1rem;
    padding: 0.75rem;
}

.purchase-modal .guarantee-item {
    font-size: 0.7rem;
    margin: 0;
}

@media (max-width: 768px) {
    .purchase-modal.pricing-modal {
        max-height: 92vh;
        max-width: 520px;
        padding: 1.75rem 1.1rem 1.1rem;
    }

    .purchase-modal .pricing-header {
        padding: 0 1.5rem;
    }

    .purchase-modal .pricing-grid {
        grid-template-columns: 1fr;
    }

    .purchase-modal .pricing-plan.popular {
        order: -1;
        transform: none;
    }

    .purchase-modal .pricing-plan.popular:hover {
        transform: translateY(-2px);
    }

    .purchase-modal .plan-description {
        min-height: 0;
    }
}

@media (max-width: 480px) {
    .purchase-overlay {
        padding: 0.5rem;
    }

    .purchase-modal .credits-grid {
        grid-template-columns: 1fr;
    }
}

/* Slide down animation for dropdown */
@keyframes slideDownEdit {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Variations Preview Dots */
.variations-preview {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    border-radius: 20px;
    z-index: 10;
}

.variation-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.variation-dot:hover {
    background: rgba(255, 255, 255, 0.8);
    transform: scale(1.2);
}

.variation-dot.active {
    background: white;
    border-color: #667eea;
    box-shadow: 0 0 8px rgba(102, 126, 234, 0.6);
}

/* AI Edit Loading Overlay */
.ai-edit-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.loading-spinner-container {
    text-align: center;
    color: white;
}

.loading-spinner-container p {
    margin-top: 16px;
    font-size: 14px;
    font-weight: 500;
    color: white;
}

.loading-spinner-container .loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

/* Emotion Picker */
.optional-prompt-toggle {
    display: flex;
    width: fit-content;
    margin-bottom: 12px;
}

.optional-prompt-group[hidden] {
    display: none !important;
}

.optional-prompt-group {
    margin-top: 10px;
    position: relative;
}

#video-desc-label {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.emotion-picker-btn {
    background: none;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 2px 4px;
    cursor: pointer;
    line-height: 1;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    color: #ff7154;
    float: right;
}

.emotion-picker-btn .material-icons {
    font-size: 16px;
    color: #64748b;
}

.emotion-picker-btn:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e0;
}

.emotion-picker-popup {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: #fcfcf3;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    min-width: 340px;
}

.emotion-picker-popup.show {
    display: grid;
}

.emotion-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}
.emotion-option .material-icons {
    font-size: 34px;
    color: #475569;
}
.emotion-option:hover {
    background-color: #f1f5f9;
}

.emotion-option .material-icons {
    font-size: 24px;
    color: #475569;
}

.emotion-option span:last-child {
    font-size: 0.65em;
    color: #64748b;
    margin-top: 2px;
}

/* A selected logo is separate from the four source-image slots. */
.image-preview-container.has-logo {
    display: flex;
    flex: 1 1 0;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 4px;
    min-width: 0;
    background: #fff;
}

.image-preview-container.has-logo::before {
    content: none;
}

.image-preview-container.has-logo > .image-previews {
    flex: 0 1 auto;
}

.image-preview-container.has-logo > .image-previews:empty {
    display: none;
}

.selected-logo-preview {
    position: relative;
    display: flex;
    flex: 0 0 80px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 45px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    font-size: 9px;
    color: #475569;
}

.selected-logo-preview[hidden] {
    display: none;
}

.selected-logo-preview img {
    width: 48px;
    height: 26px;
    object-fit: contain;
}

#remove-selected-logo {
    position: absolute;
    top: 2px;
    right: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #334155;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
}

.logo-toggle-icon {
    display: inline-block;
    margin-left: 4px;
    transition: transform 0.2s ease;
}

.logo-upload-section[open] .logo-toggle-icon {
    transform: rotate(180deg);
}

.brand-logo-add {
    border-top: 1px solid #e2e8f0;
    color: #2563eb;
}

.brand-logo-add:disabled {
    color: #64748b;
    cursor: wait;
}

.logo-placement-note {
    margin: 0;
    color: #64748b;
    font-size: 0.68rem;
    line-height: 1.4;
}

/* Transparent generation is available only on the OpenAI engines. */
.engine-option.transparent-unavailable {
    opacity: 0.4;
}
.engine-option.transparent-unavailable .engine-label {
    cursor: not-allowed;
}
