/* One native action per step; reserve its measured height in the normal flow. */
.koshi-commerce-action-total[hidden] { display: none !important; }
.koshi-commerce-action-space { height: 0; }
@media (max-width: 680px) {
    body.koshi-commerce-action-present :is(input, select, textarea, button, .field-error, .checkout-agreements) { scroll-margin-bottom: calc(var(--koshi-commerce-action-height, 0px) + 16px); }
    .checkout-index-index .koshi-commerce-action-fixed,
    .checkout-cart-index .koshi-commerce-action-fixed {
        box-sizing: border-box;
        position: fixed;
        z-index: 90;
        inset: auto 0 0;
        width: 100%;
        margin: 0 !important;
        padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
        border-top: 1px solid var(--koshi-border, #b9a890);
        background: var(--koshi-cream, #f4f1e6);
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        list-style: none;
        align-items: center;
        gap: 8px 16px;
    }
    /* The cart theme gives both the UL and its LI children height:100%.
       Once fixed, that percentage resolves against the whole viewport. */
    .checkout-cart-index .koshi-cart-summary-actions .checkout-methods-items.koshi-commerce-action-fixed,
    .checkout-cart-index .koshi-cart-summary-actions .checkout-methods-items.koshi-commerce-action-fixed > li {
        height: auto !important;
        min-height: 0;
        max-height: none;
    }
    .checkout-cart-index .koshi-cart-summary-actions .checkout-methods-items.koshi-commerce-action-fixed { flex-direction: row; }
    .koshi-commerce-action-fixed > .primary,
    .koshi-commerce-action-fixed > .item { flex: 1 1 180px; margin: 0 !important; }
    .koshi-commerce-action-fixed .action.checkout,
    .koshi-commerce-action-fixed .action.continue { width: 100%; margin: 0; min-height: 48px; }
    .koshi-commerce-action-total { color: var(--koshi-ink, #322a22); font: 600 20px/1.3 var(--koshi-sans, sans-serif); white-space: nowrap; }
    .checkout-index-index #payment .checkout-billing-address.koshi-billing-same { min-height: 0; padding-bottom: 0; margin-bottom: 8px; }
    .checkout-index-index #payment .koshi-billing-same .koshi-billing-current-card { display: none; }
    .checkout-index-index #payment .checkout-billing-address.koshi-billing-same .billing-address-details { border: 0; padding: 0; margin: 0; background: transparent; }
    .checkout-index-index #payment .checkout-billing-address.koshi-billing-same .billing-address-details:empty { display: none; }
    .checkout-index-index #checkout-payment-method-load { margin-top: 8px; }
    .checkout-index-index #payment .payment-methods,
    .checkout-index-index #payment .payment-group { display: flex; flex-direction: column; }
    .checkout-index-index #payment .payment-group > .step-title { order: -2; }
    .checkout-index-index #payment .payment-method:has(#koshi_monetico) { order: -1; }
    .checkout-cart-index .cart-summary { margin-top: 16px; }
    .checkout-cart-index .koshi-cart-collection { margin-bottom: 12px; }
    .checkout-index-index .koshi-relay-modal .koshi-relay-draft-summary { margin: 0 0 8px; color: var(--koshi-ink, #322a22); font-size: 13px; line-height: 1.35; }
    .checkout-index-index .koshi-relay-modal .koshi-relay-draft-summary strong,
    .checkout-index-index .koshi-relay-modal .koshi-relay-draft-summary span { display: block; }
}

/* The address summary is the only way back from delivery on small screens. */
:is(.koshi-checkout-address-summary, .koshi-checkout-delivery-summary) { display: none; }
@media (max-width: 680px) {
    .checkout-index-index :is(.koshi-checkout-address-summary, .koshi-checkout-delivery-summary) {
        display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px;
        margin: 0 0 16px; padding: 12px 0; border: 0; border-bottom: 1px solid var(--koshi-border, #b9a890);
        border-radius: 0; box-shadow: none; background: transparent; color: var(--koshi-ink, #322a22);
        text-align: left; font: inherit; text-transform: none; letter-spacing: normal;
    }
    .checkout-index-index :is(.koshi-checkout-address-summary, .koshi-checkout-delivery-summary) > span:first-child { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
    .checkout-index-index :is(.koshi-checkout-address-summary, .koshi-checkout-delivery-summary)::after { content: '\203a'; flex: 0 0 auto; font-size: 24px; }
    .checkout-index-index #shipping-method-buttons-container { list-style: none; }
}

/* A single native agreement component belongs to the whole payment step. */
.checkout-index-index #koshi-checkout-shared-agreements .checkout-agreements { margin: 16px 0; }
.checkout-index-index #payment .checkout-agreements-block:not(:has(> *)) { display: none; }

/* Keep the methods and their shared agreements in the same visual column. */
.checkout-index-index #payment .koshi-checkout-payment-options { min-width: 0; }
@media (max-width: 980px) {
    .checkout-index-index #payment .koshi-checkout-payment-options { order: 2; }
}
@media (min-width: 981px) {
    .checkout-index-index #payment .koshi-checkout-payment-options { grid-column: 2; grid-row: 1; }
}
