.cpm-overlay {
    position: fixed;
    inset: 0;
    z-index: 999998;
    display: none;
    box-sizing: border-box;
    padding: 20px;
    background: rgba(0, 0, 0, .52);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.cpm-overlay.cpm-open {
    display: flex;
    align-items: center;
    justify-content: center;
}

.cpm-box {
    position: relative;
    min-width: 0;
    max-height: calc(100vh - 48px);
    overflow-x: hidden;
    overflow-y: auto;
    box-sizing: border-box;
    padding: 26px;
    border-radius: 12px;
    box-shadow: 0 12px 45px rgba(0, 0, 0, .28);
    font-family: Arial, sans-serif;
    overflow-wrap: anywhere;
    word-break: normal;
    -webkit-overflow-scrolling: touch;
}

.cpm-box *,
.cpm-box *::before,
.cpm-box *::after { box-sizing: border-box; }

.cpm-title,
.cpm-box h1,
.cpm-box h2,
.cpm-box h3,
.cpm-box h4,
.cpm-box h5,
.cpm-box h6 {
    max-width: 100%;
    margin-top: 0;
    overflow-wrap: anywhere;
}

.cpm-title { margin-bottom: 12px; }

.cpm-content {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.cpm-content img,
.cpm-content video,
.cpm-content canvas,
.cpm-content svg,
.cpm-content iframe,
.cpm-content embed,
.cpm-content object,
.cpm-newsletter-form img,
.cpm-image {
    display: block;
    max-width: 100% !important;
    height: auto !important;
}

.cpm-content iframe,
.cpm-content embed,
.cpm-content object { width: 100% !important; }

.cpm-content table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
    -webkit-overflow-scrolling: touch;
}

.cpm-image {
    width: auto;
    max-height: 240px;
    object-fit: contain;
    margin: 0 auto 16px;
}

.cpm-close {
    position: absolute;
    z-index: 2;
    top: 7px;
    right: 10px;
    min-width: 36px;
    min-height: 36px;
    padding: 3px 8px;
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 27px;
    line-height: 1;
    cursor: pointer;
}

.cpm-button {
    display: inline-block;
    max-width: 100%;
    margin-top: 18px;
    padding: 11px 20px;
    border-radius: 5px;
    text-align: center;
    text-decoration: none;
    font-weight: 700;
    white-space: normal;
    overflow-wrap: anywhere;
}

.cpm-newsletter-form {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin-top: 18px;
}

.cpm-newsletter-form form,
.cpm-newsletter-form fieldset,
.cpm-newsletter-form .form,
.cpm-newsletter-form .row,
.cpm-newsletter-form div { max-width: 100%; }

.cpm-newsletter-form input[type="text"],
.cpm-newsletter-form input[type="email"],
.cpm-newsletter-form input[type="tel"],
.cpm-newsletter-form input[type="url"],
.cpm-newsletter-form select,
.cpm-newsletter-form textarea,
.cpm-newsletter-form button,
.cpm-newsletter-form input[type="submit"] {
    width: 100%;
    max-width: 100%;
}

.cpm-bottom-right,
.cpm-bottom-left {
    align-items: flex-end !important;
    background: transparent;
    pointer-events: none;
}
.cpm-bottom-right { justify-content: flex-end !important; }
.cpm-bottom-left { justify-content: flex-start !important; }
.cpm-bottom-right .cpm-box,
.cpm-bottom-left .cpm-box {
    width: min(380px, calc(100vw - 40px)) !important;
    max-width: 380px !important;
    pointer-events: auto;
}

@media (max-width: 768px) {
    .cpm-overlay { padding: 18px; }
    .cpm-box {
        max-width: calc(100vw - 36px) !important;
        max-height: calc(100dvh - 56px);
        padding: 23px 18px 19px;
        border-radius: 10px;
    }
    .cpm-image { max-height: 210px; }
    .cpm-bottom-right,
    .cpm-bottom-left {
        align-items: flex-end !important;
        justify-content: center !important;
    }
    .cpm-bottom-right .cpm-box,
    .cpm-bottom-left .cpm-box {
        width: min(360px, calc(100vw - 36px)) !important;
        max-width: 360px !important;
    }
}

@media (max-width: 480px) {
    .cpm-overlay { padding: 20px; }
    .cpm-box {
        width: min(390px, calc(100vw - 40px)) !important;
        max-width: calc(100vw - 40px) !important;
        max-height: calc(100dvh - 64px);
        padding: 21px 16px 17px;
        border-radius: 10px;
        font-size: 15px;
    }
    .cpm-title,
    .cpm-box h2 {
        padding-right: 28px;
        font-size: 1.25rem;
        line-height: 1.25;
    }
    .cpm-image { max-height: 180px; margin-bottom: 13px; }
    .cpm-close { top: 4px; right: 5px; }
    .cpm-button { padding: 10px 16px; }
    .cpm-bottom-right .cpm-box,
    .cpm-bottom-left .cpm-box {
        width: min(340px, calc(100vw - 40px)) !important;
        max-width: 340px !important;
    }
}
