.chapter-cta,
.chapter-slide-cta,
.demo-chapter-slide-cta,
.cta-slide-button {
    margin-top: 4px;
    padding: calc(12px * var(--chapter-cta-scale, 1)) calc(24px * var(--chapter-cta-scale, 1));
    background: rgb(108, 99, 255);
    color: white;
    border: none;
    border-radius: var(--radius-md, 10px);
    font-size: calc(19px * var(--chapter-cta-scale, 1));
    font-weight: var(--font-weight-semibold, 600);
    cursor: pointer;
    transition: all var(--transition-base, 0.2s);
    align-self: flex-start;
    position: relative;
}

.chapter-cta:hover,
.chapter-slide-cta:hover,
.demo-chapter-slide-cta:hover,
.cta-slide-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    background: rgb(123, 117, 255);
}

.chapter-cta-button-wrapper {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.chapter-cta.pulsating::after,
.chapter-slide-cta.pulsating::after,
.demo-chapter-slide-cta.pulsating::after,
.cta-slide-button.pulsating::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    width: 100%;
    height: 100%;
    border: 2px solid rgb(108, 99, 255);
    border-radius: var(--radius-md, 10px);
    animation: pulse-ring 1.8s ease-out infinite;
    pointer-events: none;
    opacity: 0.6;
}

.chapter-cta.pulsating::before,
.chapter-slide-cta.pulsating::before,
.demo-chapter-slide-cta.pulsating::before,
.cta-slide-button.pulsating::before {
    content: '';
    position: absolute;
    inset: 8%;
    border-radius: calc(var(--radius-md, 10px) * 0.9);
    background: rgba(255, 255, 255, 0.28);
    animation: pulse-inner-soft 1.8s ease-in-out infinite;
    pointer-events: none;
    opacity: 0.7;
}

.chapter-cta-text,
.chapter-slide-cta-text,
.demo-chapter-slide-cta-text {
    background: none;
    padding: 2px 0;
    border-radius: 4px;
    transition: background var(--transition-base, 0.2s);
}

.chapter-cta.cta-disabled,
.chapter-slide-cta.cta-disabled,
.demo-chapter-slide-cta.cta-disabled,
.cta-slide-button.cta-disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* @keyframes pulse-ring {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.7;
    }
    70% {
        transform: translate(-50%, -50%) scale(1.35);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.35);
        opacity: 0.7;
    }
} */

@keyframes pulse-inner-soft {
    0% {
        opacity: 0.7;
        transform: scale(0.7);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    100% {
        opacity: 0.7;
        transform: scale(0.7);
    }
}

/* ===== CTA SLIDE STYLES ===== */

.cta-slide-layout {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 32px;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}

/* Decorative gradient elements */
.cta-slide-layout::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -25%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(108, 99, 255, 0.08) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.cta-slide-layout::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -20%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(108, 99, 255, 0.05) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.cta-slide-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
    max-width: 100%; /* fill the available slide width */
    z-index: 1;
}

.cta-slide-title {
    font-size: clamp(18px, 5.5vw, 42px);
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 16px 0;
    line-height: 1.2;
    width: 100%;
}

.cta-slide-title:focus {
    outline: 2px solid rgba(108, 99, 255, 0.5);
    outline-offset: 4px;
    border-radius: 4px;
}

.cta-slide-subtitle {
    font-size: clamp(14px, 3.2vw, 18px);
    font-weight: 400;
    color: #6b7280;
    margin: 0 0 32px 0;
    line-height: 1.5;
    width: 100%;
}

.cta-slide-subtitle:focus {
    outline: 2px solid rgba(108, 99, 255, 0.5);
    outline-offset: 4px;
    border-radius: 4px;
}

.cta-slide-button-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.cta-slide-button {
    /* width: 100%; */
    max-width: 420px;
    padding: 14px 32px;
    background: rgb(108, 99, 255);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(108, 99, 255, 0.35), inset 0 1px 2px rgba(255,255,255,0.25);
    align-self: center;
}

@media (max-width: 768px) {
    .cta-slide-layout {
        padding: 32px 16px;
        overflow: hidden;
    }

    .cta-slide-content {
        padding: 0 12px;
        max-width: none;
    }

    .cta-slide-title {
        font-size: clamp(18px, 5.5vw, 32px);
        margin-bottom: 12px;
    }

    .cta-slide-subtitle {
        font-size: clamp(14px, 3.2vw, 16px);
        margin-bottom: 20px;
    }

    .cta-slide-button {
        max-width: 100%;
        padding: 12px 24px;
    }
}

.cta-slide-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(108, 99, 255, 0.4);
    background: rgb(123, 117, 255);
}

.cta-slide-button:active {
    transform: translateY(0);
}

.cta-slide-button.cta-disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.cta-slide-button-text {
    background: none;
    border: none;
    color: inherit;
    font: inherit;
    padding: 0;
}

.cta-button-edit-panel {
    position: absolute;
    bottom: calc(100% + 10px); /* render above the button to avoid clipping in small viewports */
    left: 50%;
    transform: translateX(-50%);
    display: none;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    min-width: 260px;
    max-width: min(340px, 90vw);
    z-index: 5;
    pointer-events: auto;
}

.cta-button-edit-input {
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.cta-button-edit-label {
    font-size: 12px;
    font-weight: 600;
    color: #4b5563;
    text-align: left;
    width: 100%;
}

.cta-button-edit-input:focus {
    outline: none;
    border-color: rgb(108, 99, 255);
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.1);
}

.cta-button-edit-input::placeholder {
    color: #9ca3af;
}

/* ===== CHAPTER SLIDE STYLES (SHARED BETWEEN EDIT AND VIEW MODES) ===== */

.chapter-slide-layout,
.demo-chapter-slide-layout {
    width: 100%;
    max-width: 100%;
    min-width: 200px;
    min-height: 200px;
    aspect-ratio: 16 / 9;
    display: flex;
    flex-direction: row;
    box-shadow: none;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 0;
    overflow: hidden;
    position: relative;
    flex-shrink: 1;
}

.chapter-slide-layout::before,
.demo-chapter-slide-layout::before,
.chapter-slide-layout::after,
.demo-chapter-slide-layout::after {
    content: '';
    position: absolute;
    pointer-events: none;
    border-radius: 50%;
    z-index: 0;
}

.chapter-slide-layout::before,
.demo-chapter-slide-layout::before {
    top: -50%;
    right: -25%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(108, 99, 255, 0.08) 0%, transparent 70%);
}

.chapter-slide-layout::after,
.demo-chapter-slide-layout::after {
    bottom: -30%;
    left: -20%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(108, 99, 255, 0.05) 0%, transparent 70%);
}

.chapter-slide-layout.hidden,
.demo-chapter-slide-layout.hidden {
    display: none;
}

.chapter-slide-content,
.demo-chapter-slide-content {
    position: relative;
    display: flex;
    align-items: stretch;
    height: 100%;
    width: 100%;
    padding: 0;
    box-sizing: border-box;
    gap: 0;
    z-index: 1;
}

.chapter-slide-text,
.demo-chapter-slide-text {
    display: flex;
    flex-direction: column;
    gap: 16px;
    color: #1f2937;
    justify-content: center;
    background: transparent;
    flex: 1;
    padding: 48px 40px;
}

.chapter-slide-title,
.demo-chapter-slide-title {
    font-size: calc(clamp(20px, 4.2vw, 42px) * var(--chapter-text-scale, 1));
    font-weight: 700;
    line-height: 1.2;
    margin: 0;
    color: #1f2937;
}

.chapter-slide-subtitle,
.demo-chapter-slide-subtitle {
    font-size: calc(clamp(14px, 2.6vw, 18px) * var(--chapter-text-scale, 1));
    font-weight: 400;
    line-height: 1.5;
    margin: 0;
    color: #6b7280;
}

.chapter-slide-hero,
.demo-chapter-slide-hero {
    flex: 0 0 50%;
    height: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    overflow: hidden;
    pointer-events: none;
    padding: 0;
}

.chapter-slide-hero-image,
.demo-chapter-slide-hero-image {
    width: 100%;
    height: 70%;
    display: block;
    object-fit: cover;
    object-position: left center;
    filter: none;
    border-top-left-radius: 16px;
}

@media (max-width: 767px) {
    .chapter-slide-layout {
        max-width: 100%;
        height: auto;
        max-height: none;
    }

    .chapter-slide-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 16px 12px;
    }

    .chapter-slide-text {
        max-width: 100%;
        width: 100%;
    }

    .chapter-slide-title {
        font-size: clamp(18px, 5vw, 26px);
    }

    .chapter-slide-subtitle {
        font-size: clamp(13px, 3.5vw, 15px);
    }

    .chapter-slide-hero {
        flex: 0 0 auto;
        width: 100%;
        height: 120px;
        justify-content: center;
    }
}

@media (max-width: 520px) {
    .demo-chapter-slide-layout {
        max-width: 100%;
        height: auto;
        max-height: none;
    }

    .demo-chapter-slide-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 16px 12px;
    }

    .demo-chapter-slide-text {
        max-width: 100%;
        width: 100%;
    }

    .demo-chapter-slide-title {
        font-size: clamp(18px, 5vw, 26px);
    }

    .demo-chapter-slide-subtitle {
        font-size: clamp(13px, 3.5vw, 15px);
    }

    .demo-chapter-slide-hero {
        flex: 0 0 auto;
        width: 100%;
        height: 120px;
        justify-content: center;
    }
}
