@media (max-width: 991px) and (min-width: 768px) {
    .checkout-modal-pay .checkout-modal-pay-inner {
        width: calc(100vw - 24px);
        height: calc(100vh - 24px);
        padding: 8px;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left {
        flex: 1 1 auto;
        width: auto !important;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-right {
        flex: 0 0 300px;
        width: 300px !important;
        min-width: 0;
        padding: 14px 11px !important;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-action-body {
        padding: 20px;
    }
    .checkout-modal-pay .address-list-action {
        gap: 10px;
    }
    .checkout-modal-pay .address-list {
        padding: 0;
    }
}

@media (max-width: 767px) {
    .checkout-modal-pay {
        align-items: stretch;
        justify-content: stretch;
        padding: 0;
        background: #fff;
        backdrop-filter: none;
    }
    .checkout-modal-pay .checkout-modal-pay-inner {
        width: 100%;
        height: 100%;
        max-height: none;
        padding: 0;
        overflow: hidden;
        border-radius: 0;
        background: #fff;
        box-shadow: none;
    }
    .checkout-modal-pay .pay-inner-content {
        display: flex !important;
        flex-direction: column;
        height: 100%;
        overflow: hidden;
        border-radius: 0;
        background: #fff;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left {
        display: flex;
        flex: 1 1 auto;
        flex-direction: column;
        width: 100% !important;
        height: 100%;
        min-height: 0;
        padding: 0 !important;
        border-radius: 0;
        background: #fff;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-right {
        display: none !important;
    }
    .checkout-modal-pay .checkout-modal-pay-inner>.pay-coupons {
        inset: auto 0 0;
        width: 100%;
        height: auto;
        max-height: 78%;
        border-radius: 15px 15px 0 0;
        transform: translateY(105%);
    }
    .checkout-modal-pay .checkout-modal-pay-inner>.pay-coupons.show {
        transform: translateY(0);
    }
    .checkout-modal-pay .checkout-drawer-overlay {
        inset: 0;
        border-radius: 0;
    }
    .checkout-modal-pay .checkout-summary-drawer {
        top: auto;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        height: auto;
        max-height: 70%;
        border-radius: 15px 15px 0 0;
        transform: translateY(105%);
    }
    .checkout-modal-pay .checkout-summary-drawer.show {
        transform: translateY(0);
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-action-header {
        flex: 0 0 auto;
        min-height: 0;
        padding: 8px 16px 0;
        border-bottom: 1px solid #eee9e6;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-action-header .site-logo {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        min-height: 48px;
        margin: 0;
        padding: 0;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-action-header .site-logo img {
        display: block;
        width: auto;
        max-width: 150px;
        height: 38px;
        object-fit: contain;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-action-header .site-logo #cancel-payment {
        position: static;
        order: 2;
        width: 36px;
        height: 36px;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-innser-action-list {
        height: 54px;
        margin: 4px 0 0;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-innser-action-list ul {
        justify-content: space-between;
        gap: 6px;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-innser-action-list ul li {
        position: relative;
        display: flex;
        flex: 1 1 0;
        flex-direction: column;
        gap: 4px;
        padding: 5px 4px;
        color: #95888a;
        font-size: 11px;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-innser-action-list ul li span {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 22px;
        height: 22px;
        margin: 0;
        border: 1px solid #eadfe0;
        border-radius: 50%;
        color: #8c777b;
        background: #fff;
        font-size: 11px;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-innser-action-list ul li.active span {
        border-color: var(--checkout-red);
        color: #fff;
        background: var(--checkout-red);
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-innser-action-list ul li:nth-child(2) {
        justify-content: center;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-innser-action-list ul li:last-child {
        justify-content: center;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-action-mobile-body {
        display: flex;
        flex: 1 1 0;
        flex-direction: column;
        height: auto !important;
        min-height: 0;
        padding: 0 16px;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior-y: contain;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
        background: #fff;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-action-mobile-body .order-summary-show {
        flex: 0 0 auto;
        margin: 13px 0 5px;
        border: 1px solid #f0e2da;
        border-radius: 12px;
        background: var(--checkout-cream);
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-action-mobile-body .order-summury-title {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        min-height: 54px;
        padding: 10px 12px;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-action-mobile-body .order-summury-title .iconsfty {
        display: flex;
        align-items: center;
        gap: 8px;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-action-mobile-body .order-summury-title .iconsfty img {
        width: 19px;
        height: 19px;
        object-fit: contain;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-action-mobile-body .order-summury-title p {
        margin: 0;
        color: #5f3440;
        font-size: 12px;
        font-weight: 700;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-action-mobile-body .order-summary-body {
        max-height: 240px;
        padding: 0 12px 12px;
        overflow-y: auto;
        overscroll-behavior-y: contain;
        -webkit-overflow-scrolling: touch;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-action-mobile-body .cart-total-summary {
        padding: 10px;
        border-radius: 8px;
        background: rgba(255, 255, 255, .75);
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-action-body {
        flex: 0 0 auto;
        height: auto !important;
        min-height: 0;
        padding: 14px 0 24px;
        overflow: visible;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-action-mobile-body:has(.pay-action-body) {
        flex: 1 1 0;
        min-height: 0;
    }
    .checkout-modal-pay .address-action .pay-address-header {
        align-items: flex-start;
        margin-bottom: 16px;
    }
    .checkout-modal-pay .address-action .pay-address-header span {
        font-size: 10px;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-action-footer {
        position: relative;
        flex: 0 0 auto;
        height: auto !important;
        min-height: 70px;
        margin-top: 0;
        padding: 10px 16px calc(10px + env(safe-area-inset-bottom)) !important;
        border-top: 1px solid #eee9e6;
        background: #fff !important;
    }
    .checkout-modal-pay .pay-action-footer .minifooter {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 8px 0 0;
    }
    .checkout-modal-pay .pay-action-footer .minifooter .links-group,
    .checkout-modal-pay .pay-action-footer .minifooter .poweredby {
        display: flex;
        align-items: center;
        gap: 7px;
        color: #807477;
        font-size: 10px;
    }
    .checkout-modal-pay .pay-action-footer .minifooter .poweredby img {
        width: auto;
        height: 20px;
        object-fit: contain;
    }
    .checkout-modal-pay .pay-action-footer .mobile-action-btn button {
        width: 100% !important;
        min-height: 46px;
    }
    .checkout-modal-pay .address-section-heading {
        margin-bottom: 13px;
    }
    .checkout-modal-pay .address-section-heading .ucbsaigasb {
        font-size: 16px;
    }
    .checkout-modal-pay .pay-new-address {
        min-height: 36px;
        padding: 7px 10px;
        font-size: 11px;
    }
    .checkout-modal-pay .address-list-action {
        grid-template-columns: minmax(0, 1fr);
        gap: 10px;
    }
    .checkout-modal-pay .address-list {
        min-height: 0;
        padding: 0;
    }
    .checkout-modal-pay .address-list-card {
        padding: 13px 14px 11px;
    }
    .checkout-modal-pay .address-action .pay-address-header {
        align-items: flex-start;
    }
    .checkout-modal-pay .cancel-pay-modal-inner {
        padding: 38px 18px 24px;
    }
    .checkout-modal-pay .cancel-pay-modal {
        padding: 0;
    }
    .checkout-modal-pay .cancel-pay-modal-inner {
        width: 100%;
        max-height: min(90%, 540px);
        padding: 38px 18px 24px;
        border-radius: 16px 16px 0 0;
    }
    .checkout-modal-pay .cancel-pay-modal-illustration {
        height: 132px;
        margin-bottom: 22px;
    }
    .checkout-modal-pay .cancel-pay-modal-copy {
        margin-bottom: 24px;
    }
    .checkout-modal-pay .cancel-pay-modal-copy p:first-child {
        font-size: 16px;
    }
    .checkout-modal-pay .cancel-pay-modal-copy p+p {
        font-size: 13px;
    }
    .checkout-modal-pay .pay-coupons {
        padding: 14px;
    }
    .checkout-modal-pay .pay-coupon-header {
        margin: -14px -14px 12px;
        padding: 12px 14px 14px;
    }
    /* Mobile order checkout: branded shell, address cards, and fixed actions */
    .checkout-modal-pay {
        background: rgba(28, 16, 17, .82);
        backdrop-filter: none;
    }
    .checkout-modal-pay .checkout-modal-pay-inner {
        width: 100%;
        height: 100%;
        padding: 0;
        border-radius: 0;
        background: var(--checkout-red);
    }
    .checkout-modal-pay .pay-inner-content {
        border-radius: 0;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-action-header {
        padding: 0;
        border: 0;
        background: var(--checkout-red);
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-action-header .site-logo {
        justify-content: flex-start;
        gap: 10px;
        min-height: 52px;
        padding: 0 14px;
        background: var(--checkout-red);
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-action-header .site-logo .checkout-mobile-back {
        order: 0;
        flex: 0 0 27px;
        width: auto;
        height: auto;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
        font-size: 24px;
    }
    .checkout-modal-pay .checkout-mobile-brand {
        display: flex;
        align-items: center;
        gap: 9px;
        min-width: 0;
        color: #fff;
    }
    /* Keep the back control compact and first despite legacy ID-based rules. */
    .checkout-modal-pay #cancel-payment.checkout-mobile-back {
        order: 0 !important;
        flex: 0 0 auto;
        width: auto !important;
        height: auto !important;
        padding: 0 !important;
        border: 0 solid rgba(255, 255, 255, 0.65) !important;
        border-radius: 50% !important;
        background: transparent !important;
        color: #fff !important;
        font-size: 24px;
    }
    /* Mobile checkout summary: keep the selected delivery preview compact. */
    .checkout-modal-pay [data-selected-address-name] {
        display: none !important;
    }
    /* .checkout-modal-pay [data-selected-address-text] {
        display: block;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .checkout-modal-pay [data-selected-address-delivery] {
        display: block;
        margin-top: 4px;
        color: #a58f83;
        font-size: 12px;
        line-height: 1.35;
    } */
    .checkout-modal-pay .checkout-mobile-powered-brand {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        color: #292322;
        font-size: 11px;
        font-weight: 700;
        letter-spacing: 0.08em;
        text-transform: uppercase;
    }
    .checkout-modal-pay .checkout-mobile-powered-brand img {
        display: block;
        width: 25px;
        height: 20px;
        object-fit: contain;
    }
    .checkout-modal-pay .checkout-mobile-brand img {
        flex: 0 0 38px;
        width: 38px !important;
        height: 38px !important;
        padding: 3px;
        border-radius: 8px;
        /* background: var(--checkout-red-dark); */
        background: #fff;
        object-fit: contain;
    }
    .checkout-modal-pay .checkout-mobile-brand span {
        overflow: hidden;
        color: #fff;
        font-size: 13px;
        font-weight: 700;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-innser-action-list {
        height: 53px;
        margin: 0;
        padding: 0 14px;
        border-top: 1px solid rgba(255, 255, 255, .12);
        background: var(--checkout-red);
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-innser-action-list ul {
        justify-content: space-around;
        gap: 10px;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-innser-action-list ul li.pay-tabs {
        flex: 0 1 28%;
        min-height: unset;
        padding: 4px 12px;
        border-radius: 999px;
        color: rgba(255, 255, 255, .9);
        font-size: 12px;
        font-weight: 500;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-innser-action-list ul li.pay-tabs.active {
        color: var(--checkout-red);
        background: var(--checkout-cream);
        font-weight: 700;
    }
    .checkout-modal-pay .pay-inner-left.is-payment-step .pay-innser-action-list ul li.pay-tabs[data-action="1"] {
        color: rgba(255, 255, 255, .9);
        background: transparent;
        font-weight: 500;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-innser-action-list ul li.pay-tabs span,
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-innser-action-list ul li.checkout-step-chevron {
        display: none;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-action-mobile-body {
        gap: 0;
        padding: 0;
        background: var(--checkout-red);
    }
    .checkout-modal-pay .checkout-mobile-prelude {
        display: flex;
        flex: 0 0 auto;
        flex-direction: column;
        gap: 10px;
        padding: 10px 14px 16px;
        background: var(--checkout-red);
    }
    .checkout-modal-pay .checkout-mobile-prelude .checkout-order-summary-trigger {
        gap: 10px;
        margin: 0;
        padding: 11px 13px;
        border: 1px solid rgba(255, 255, 255, .45);
        border-radius: 13px;
        background: var(--checkout-cream);
        box-shadow: none;
    }
    .checkout-modal-pay .checkout-mobile-prelude .checkout-order-summary-trigger:hover {
        transform: none;
        background: #fff8f1;
    }
    .checkout-modal-pay .checkout-order-summary-trigger__top {
        font-size: 12px;
        font-weight: 500;
    }
    .checkout-modal-pay .checkout-order-summary-trigger__top small {
        font-size: 11px;
    }
    .checkout-modal-pay .checkout-order-summary-trigger__bottom {
        min-height: 42px;
    }
    .checkout-modal-pay .checkout-order-summary-trigger__image {
        flex-basis: 40px;
        width: 40px;
        height: 40px;
    }
    .checkout-modal-pay .checkout-order-summary-trigger__amount strong {
        font-size: 17px;
    }
    .checkout-modal-pay .checkout-coupon-panel {
        display: flex;
        flex: 0 0 auto;
        flex-direction: column;
        gap: 0;
        width: 100%;
    }
    .checkout-modal-pay .checkout-coupon-panel .coupon-form-wrapper {
        padding: 12px;
        border: 1px solid rgba(255, 255, 255, .45);
        border-radius: 13px;
        background: var(--checkout-cream);
    }
    .checkout-modal-pay .checkout-coupon-panel__title {
        margin-bottom: 9px;
        font-size: 12px;
    }
    .checkout-modal-pay .checkout-coupon-panel__form {
        height: 44px;
        border-radius: 10px;
    }
    .checkout-modal-pay .checkout-selected-address {
        border: 1px solid rgba(255, 255, 255, .45);
        border-radius: 13px;
        background: var(--checkout-cream);
    }
    .checkout-modal-pay .checkout-selected-address__heading {
        min-height: 46px;
        padding: 10px 13px;
    }
    .checkout-modal-pay .checkout-selected-address__body {
        padding: 11px 13px;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-action-body {
        flex: 0 0 auto;
        width: 100%;
        min-height: 100%;
        margin: 0;
        padding: 18px 16px 24px;
        border-radius: 16px 16px 0 0;
        background: #fff;
    }
    .checkout-modal-pay .address-view-all {
        padding: 0;
    }
    .checkout-modal-pay .address-section-heading {
        align-items: center;
        margin-bottom: 15px;
    }
    .checkout-modal-pay .address-list-action {
        gap: 10px;
    }
    .checkout-modal-pay .address-list {
        border-radius: 14px;
    }
    .checkout-modal-pay .pay-inner-content .pay-inner-left .pay-action-footer {
        z-index: 5;
        min-height: unset;
        padding: 10px 12px 5px !important;
        box-shadow: 0 -5px 16px rgba(31, 22, 24, .06);
    }
    .checkout-modal-pay .pay-action-footer .mobile-action-btn button {
        width: 70% !important;
        min-height: 40px;
        border-radius: 10px;
    }
    .checkout-modal-pay .pay-action-footer .minifooter {
        justify-content: center;
        padding-top: 7px;
    }
    .checkout-modal-pay .pay-action-footer .minifooter .links-group {
        display: none;
    }
    .checkout-modal-pay .pay-action-footer .minifooter .poweredby {
        justify-content: center;
        font-size: 10px;
    }
    .checkout-modal-pay .pay-action-mobile-body.is-payment-step {
        background: #fff;
    }
    .checkout-modal-pay .pay-action-mobile-body.is-payment-step .checkout-mobile-prelude {
        display: none;
    }
    .checkout-modal-pay .pay-action-mobile-body.is-payment-step .pay-action-body {
        display: flex;
        flex: 1 1 auto;
        align-items: center;
        justify-content: center;
        margin: 0;
        padding: 18px 16px;
        border-radius: 0;
        overflow-y: auto;
    }
    .checkout-modal-pay .pay-action-mobile-body.is-payment-step .checkout-payment-section {
        margin: 0;
    }
    .checkout-modal-pay .pay-action-mobile-body.is-payment-step .payment-section-inner {
        gap: 24px;
        padding: 8px 0 20px;
    }
    .checkout-modal-pay .pay-action-mobile-body.is-payment-step .payment-button-trigger {
        flex: 0 1 310px;
        width: min(100%, 310px);
        min-height: 160px;
        gap: 12px;
    }
    .checkout-modal-pay .checkout-summary-drawer {
        max-height: 72%;
        border-radius: 16px 16px 0 0;
        transform: translateY(105%);
    }
    .checkout-modal-pay .checkout-summary-drawer.show {
        transform: translateY(0);
    }
}