/* Four-screen phone checkout built from the existing form controls. */
@media (max-width: 639px) {
    /* Hide desktop choices before the mobile script mounts, too. */
    #stamp-constructor:not(.msp-admin) #msp-product-type-selector,
    #stamp-constructor.msp-mobile-wizard #msp-mobile-editor {
        display: none !important;
    }
    body.msp-mobile-active .msp-quick-intro,
    body.msp-mobile-active .msp-tutorial-fab,
    body.msp-mobile-active .msp-seo-heading:has(+ #stamp-constructor.msp-mobile-wizard) {
        display: none !important;
    }

    #stamp-constructor.msp-mobile-wizard {
        display: block !important;
        width: 100%;
        max-width: 100% !important;
        min-width: 0;
        margin: 0 auto !important;
        padding: 0 !important;
        border: 0;
        border-radius: 0;
        background: #fff;
        overflow: visible;
        color: #0f172a;
        font-size: 16px;
        line-height: 1.45;
        -webkit-text-size-adjust: 100%;
    }

    #stamp-constructor.msp-mobile-wizard *,
    #stamp-constructor.msp-mobile-wizard *::before,
    #stamp-constructor.msp-mobile-wizard *::after {
        box-sizing: border-box;
    }

    #stamp-constructor.msp-mobile-wizard [hidden],
    #stamp-constructor.msp-mobile-wizard .msp-mobile-step[hidden] {
        display: none !important;
    }

    #stamp-constructor.msp-mobile-wizard #msp-mobile-editing-note,
    #stamp-constructor.msp-mobile-wizard .msp-quick-steps,
    #stamp-constructor.msp-mobile-wizard #msp-autofill-bar,
    #stamp-constructor.msp-mobile-wizard #msp-inn-panel-inline,
    #stamp-constructor.msp-mobile-wizard #msp-quick-order-card,
    #stamp-constructor.msp-mobile-wizard #msp-shape-filter-block,
    #stamp-constructor.msp-mobile-wizard #order-button,
    #stamp-constructor.msp-mobile-wizard #msp-duplicate-order-button,
    #stamp-constructor.msp-mobile-wizard #order-status,
    #stamp-constructor.msp-mobile-wizard #msp-autosave-status,
    #stamp-constructor.msp-mobile-wizard #msp-restore-draft-btn {
        display: none !important;
    }

    #stamp-constructor.msp-mobile-wizard > .ctor-columns,
    #stamp-constructor.msp-front.msp-mobile-wizard > #msp-mobile-manual-data:not([hidden]),
    #stamp-constructor.msp-mobile-wizard #msp-mobile-manual-data,
    #stamp-constructor.msp-mobile-wizard #msp-mobile-footer.msp-mobile-footer-away {
        display: none !important;
    }

    #stamp-constructor.msp-mobile-wizard #msp-mobile-shell {
        width: 100%;
        max-width: 480px;
        min-width: 0;
        margin: 0 auto;
        padding-bottom: calc(106px + env(safe-area-inset-bottom, 0px));
        overflow-wrap: anywhere;
    }

    #stamp-constructor.msp-mobile-wizard #msp-mobile-header {
        display: grid;
        grid-template-columns: 48px minmax(0, 1fr);
        align-items: center;
        column-gap: 10px;
        margin: 0 0 18px;
        padding: 8px 0 14px;
        border-bottom: 1px solid #e2e8f0;
        background: #fff;
        scroll-margin-top: 12px;
    }

    #stamp-constructor.msp-mobile-wizard #msp-mobile-back {
        grid-column: 1;
        grid-row: 1 / span 2;
        width: 48px;
        min-width: 48px;
        min-height: 48px;
        margin: 0;
        padding: 4px;
        border: 1px solid #cbd5e1;
        border-radius: 10px;
        background: #fff;
        color: #334155;
        font-size: 13px;
        line-height: 1.2;
    }

    #stamp-constructor.msp-mobile-wizard #msp-mobile-progress-text {
        grid-column: 2;
        margin: 0 0 3px;
        color: #64748b;
        font-size: 13px;
        line-height: 1.4;
    }

    #stamp-constructor.msp-mobile-wizard #msp-mobile-title {
        grid-column: 2;
        margin: 0;
        padding: 0;
        border: 0;
        color: #0f172a;
        font-size: 21px;
        font-weight: 700;
        line-height: 1.2;
        overflow-wrap: anywhere;
    }

    #stamp-constructor.msp-mobile-wizard #msp-mobile-header:has(#msp-mobile-back[hidden]) { grid-template-columns: minmax(0, 1fr); }
    #stamp-constructor.msp-mobile-wizard #msp-mobile-header:has(#msp-mobile-back[hidden]) #msp-mobile-title,
    #stamp-constructor.msp-mobile-wizard #msp-mobile-header:has(#msp-mobile-back[hidden]) #msp-mobile-progress-text { grid-column: 1; }

    #stamp-constructor.msp-mobile-wizard .msp-mobile-progress {
        grid-column: 1 / -1;
        display: flex;
        gap: 8px;
        width: 100%;
        margin-top: 12px;
        margin-bottom: 0;
        padding: 0;
        list-style: none;
    }

    #stamp-constructor.msp-mobile-wizard .msp-mobile-progress > * {
        flex: 1;
        min-width: 0;
        padding-top: 7px;
        border-top: 3px solid #e2e8f0;
        color: #64748b;
        font-size: 12px;
        line-height: 1.3;
        text-align: center;
    }

    #stamp-constructor.msp-mobile-wizard .msp-mobile-progress > .active,
    #stamp-constructor.msp-mobile-wizard .msp-mobile-progress > .complete,
    #stamp-constructor.msp-mobile-wizard .msp-mobile-progress > [aria-current="step"] {
        border-top-color: #2563eb;
        color: #1d4ed8;
        font-weight: 700;
    }

    #stamp-constructor.msp-mobile-wizard #msp-mobile-body,
    #stamp-constructor.msp-mobile-wizard .msp-mobile-step {
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }

    #stamp-constructor.msp-mobile-wizard .msp-mobile-step:not([hidden]) {
        display: block;
    }

    #stamp-constructor.msp-mobile-wizard .msp-mobile-step[data-step="1"]:not([hidden]) { display: flex; flex-direction: column; }
    #stamp-constructor.msp-mobile-wizard .msp-mobile-step[data-step="1"] > .msp-mobile-note { order: 1; }
    #stamp-constructor.msp-mobile-wizard .msp-mobile-step[data-step="1"] > #msp-product-type-selector { order: 2; }
    #stamp-constructor.msp-mobile-wizard .msp-mobile-step[data-step="1"] > #msp-mobile-duplicate { order: 3; }

    #stamp-constructor.msp-mobile-wizard button,
    #stamp-constructor.msp-mobile-wizard summary,
    #stamp-constructor.msp-mobile-wizard [role="button"] {
        min-height: 48px;
        margin: 0;
        padding: 11px 12px;
        border-radius: 9px;
        font: inherit;
        font-size: 15px;
        line-height: 1.35;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    #stamp-constructor.msp-mobile-wizard button:disabled {
        cursor: default;
        opacity: .55;
    }

    #stamp-constructor.msp-mobile-wizard :focus-visible {
        outline: 3px solid #93c5fd;
        outline-offset: 2px;
    }

    #stamp-constructor.msp-mobile-wizard input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    #stamp-constructor.msp-mobile-wizard select,
    #stamp-constructor.msp-mobile-wizard textarea {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        min-height: 48px;
        margin: 0;
        padding: 11px 12px;
        border: 1px solid #94a3b8;
        border-radius: 9px;
        background: #fff;
        color: #0f172a;
        font: inherit;
        font-size: 16px !important;
        font-weight: 400;
        line-height: 1.4;
        scroll-margin-top: 20px;
        scroll-margin-bottom: 130px;
    }

    #stamp-constructor.msp-mobile-wizard textarea { min-height: 74px; resize: vertical; }
    #stamp-constructor.msp-mobile-wizard input[type="range"] { min-height: 44px; padding: 0; }
    #stamp-constructor.msp-mobile-wizard input[type="checkbox"],
    #stamp-constructor.msp-mobile-wizard input[type="radio"] {
        flex: 0 0 auto;
        width: 21px;
        height: 21px;
        min-height: 21px;
        margin: 2px 0;
        accent-color: #2563eb;
    }

    #stamp-constructor.msp-mobile-wizard .msp-mobile-field,
    #stamp-constructor.msp-mobile-wizard .msp-mobile-manual-grid label,
    #stamp-constructor.msp-mobile-wizard .msp-order-field-label {
        display: flex;
        flex-direction: column;
        gap: 6px;
        margin: 0 0 14px;
        color: #334155;
        font-size: 14px;
        font-weight: 600;
    }

    #stamp-constructor.msp-mobile-wizard .msp-mobile-note,
    #stamp-constructor.msp-mobile-wizard .msp-mobile-hint,
    #stamp-constructor.msp-mobile-wizard .sub {
        margin: 6px 0 12px;
        color: #64748b;
        font-size: 14px;
        font-weight: 400;
        line-height: 1.45;
    }

    #stamp-constructor.msp-mobile-wizard .msp-mobile-error,
    #stamp-constructor.msp-mobile-wizard .msp-field-error {
        display: block;
        margin: 5px 0 0;
        color: #b91c1c;
        font-size: 13px;
        font-weight: 400;
        line-height: 1.4;
    }

    #stamp-constructor.msp-mobile-wizard .msp-mobile-error:empty,
    #stamp-constructor.msp-mobile-wizard .msp-field-error:empty { display: none; }
    #stamp-constructor.msp-mobile-wizard [aria-invalid="true"] { border-color: #dc2626 !important; }
    #stamp-constructor.msp-mobile-wizard [aria-busy="true"] { cursor: progress; }

    #stamp-constructor.msp-mobile-wizard #msp-product-type-selector,
    #stamp-constructor.msp-mobile-wizard #msp-template-selector {
        width: 100%;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        background: #fff !important;
    }

    #stamp-constructor.msp-mobile-wizard .msp-product-selector-head,
    #stamp-constructor.msp-mobile-wizard #msp-template-selector label[for="msp-template-select"] { display: none !important; }
    #stamp-constructor.msp-mobile-wizard .msp-product-selector-note { margin: 0; font-size: 14px; }
    #stamp-constructor.msp-mobile-wizard .msp-product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    #stamp-constructor.msp-mobile-wizard .msp-product-card { display: grid; grid-template-columns: 26px minmax(0, 1fr); column-gap: 7px; row-gap: 2px; align-items: center; min-height: 72px; padding: 9px; border-radius: 10px; text-align: left; }
    #stamp-constructor.msp-mobile-wizard .msp-product-name { font-size: 12px; line-height: 1.3; }
    #stamp-constructor.msp-mobile-wizard .msp-product-icon { grid-row: 1 / span 2; font-size: 28px; }
    #stamp-constructor.msp-mobile-wizard .msp-product-meta { display: block; grid-column: 2; font-size: 12px; }
    #stamp-constructor.msp-mobile-wizard .msp-product-card.active { border-color: #2563eb; background: #eff6ff; }

    #stamp-constructor.msp-mobile-wizard #msp-template-selector .msp-template-selector-head { gap: 10px; }
    #stamp-constructor.msp-mobile-wizard #msp-template-select { display: none !important; }
    #stamp-constructor.msp-mobile-wizard #msp-mobile-use-text { width: 100%; min-height: 48px; margin: 12px 0; border-color: #bfdbfe; background: #fff; color: #1d4ed8; font-size: 14px; }
    #stamp-constructor.msp-mobile-wizard #msp-mobile-fixed-text-note { margin: 8px 0 14px; padding: 10px 12px; border-left: 3px solid #d97706; border-radius: 4px; background: #fffbeb; color: #78350f; font-size: 13px; }
    #stamp-constructor.msp-mobile-wizard #msp-template-hint { font-size: 13px; }
    #stamp-constructor.msp-mobile-wizard #msp-template-quick-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    #stamp-constructor.msp-mobile-wizard #msp-template-quick-list .msp-template-choice { padding: 8px; white-space: normal; }
    #stamp-constructor.msp-mobile-wizard .msp-template-choice-title { font-size: 13px; white-space: normal; overflow-wrap: anywhere; }
    #stamp-constructor.msp-mobile-wizard .msp-template-choice-badge { top: 10px; left: 10px; font-size: 9px; }

    #stamp-constructor.msp-mobile-wizard .center-column.canvas-holder {
        display: block !important;
        position: relative;
        width: 100% !important;
        min-width: 0 !important;
        min-height: 0 !important;
        max-height: none;
        margin: 0 0 12px !important;
        padding: 0 !important;
        border: 0 !important;
        border-radius: 0 !important;
        background: #fff !important;
        box-shadow: none !important;
        overflow: visible;
    }

    #stamp-constructor.msp-mobile-wizard .msp-canvas-frame { width: 300px; max-width: 100%; margin: 0 auto; }
    #stamp-constructor.msp-mobile-wizard #stamp-canvas { width: 100% !important; max-width: 100% !important; height: auto !important; touch-action: pan-y; }
    #stamp-constructor.msp-mobile-wizard .msp-preview-open-btn { right: 6px; bottom: 6px; min-height: 44px; padding: 10px 12px; background: #0f172a; color: #fff; font-size: 13px; }
    #stamp-constructor.msp-mobile-wizard .msp-mobile-step[data-step="4"] > .msp-layout-confirm-label {
        display: flex;
        align-items: flex-start;
        gap: 10px;
        min-height: 48px;
        margin: 10px 0;
        padding: 12px;
        border: 1px solid #bfdbfe;
        border-radius: 10px;
        background: #eff6ff;
        color: #1e3a8a;
        font-size: 14px;
        line-height: 1.4;
    }
    #stamp-constructor.msp-mobile-wizard label:has(> .msp-mobile-error) { display: block !important; }
    #stamp-constructor.msp-mobile-wizard label:has(> .msp-mobile-error) > input[type="checkbox"],
    #stamp-constructor.msp-mobile-wizard label:has(> .msp-mobile-error) > input[type="radio"] { margin-right: 7px; vertical-align: middle; }

    #stamp-constructor.msp-mobile-wizard #msp-mobile-review-text { margin: 14px 0; padding: 0; border: 0; background: #fff; }
    #stamp-constructor.msp-mobile-wizard #msp-mobile-review-text summary,
    #stamp-constructor.msp-mobile-wizard #msp-mobile-more-data summary { padding-left: 0; font-weight: 600; color: #1d4ed8; }
    #stamp-constructor.msp-mobile-wizard #msp-mobile-review-fields { margin-top: 12px; }
    #stamp-constructor.msp-mobile-wizard #msp-mobile-lookup { width: 100%; margin-bottom: 8px; border-color: #bfdbfe; background: #eff6ff; color: #1d4ed8; font-weight: 600; }
    #stamp-constructor.msp-mobile-wizard .msp-mobile-inn-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; margin-bottom: 14px; }
    #stamp-constructor.msp-mobile-wizard .msp-mobile-inn-row .msp-mobile-field,
    #stamp-constructor.msp-mobile-wizard .msp-mobile-inn-row #msp-mobile-lookup { margin-bottom: 0; }
    #stamp-constructor.msp-mobile-wizard #msp-mobile-lookup-status { margin: 0 0 14px; color: #475569; font-size: 13px; line-height: 1.4; }
    #stamp-constructor.msp-mobile-wizard #msp-mobile-lookup-status:empty { display: none; }
    #stamp-constructor.msp-mobile-wizard #msp-mobile-duplicate { width: 100%; margin: 12px 0; color: #1d4ed8; border-color: #bfdbfe; font-size: 14px; }
    #stamp-constructor.msp-mobile-wizard #msp-mobile-more-data { margin-top: 4px; }
    #stamp-constructor.msp-mobile-wizard #msp-mobile-design-options,
    #stamp-constructor.msp-mobile-wizard #msp-mobile-production-options,
    #stamp-constructor.msp-mobile-wizard #msp-mobile-cost-details { margin: 12px 0; padding: 0 12px; border: 1px solid #e2e8f0; border-radius: 10px; background: #f8fafc; }
    #stamp-constructor.msp-mobile-wizard #msp-mobile-design-options > summary,
    #stamp-constructor.msp-mobile-wizard #msp-mobile-production-options > summary,
    #stamp-constructor.msp-mobile-wizard #msp-mobile-cost-details > summary { padding-left: 0; color: #1d4ed8; font-weight: 600; }
    #stamp-constructor.msp-mobile-wizard #msp-mobile-design-options[open] { background: #fff; }
    #stamp-constructor.msp-mobile-wizard #msp-mobile-production-options[open] > summary { margin-bottom: 8px; }
    #stamp-constructor.msp-mobile-wizard #msp-mobile-lookup-inn { display: none !important; }

    /* Advanced controls are reachable only after their explicit disclosure. */
    #stamp-constructor.msp-mobile-wizard #msp-mobile-editor .msp-editor-mode-bar { display: flex !important; margin: 12px 0; padding: 0; border: 0; background: #fff; }
    #stamp-constructor.msp-mobile-wizard #msp-mobile-editor .msp-editor-mode-bar > div { display: none; }
    #stamp-constructor.msp-mobile-wizard #msp-toggle-advanced { width: 100%; min-height: 48px; white-space: normal; font-size: 14px; }
    #stamp-constructor.msp-mobile-wizard .msp-mobile-advanced:not([hidden]) #msp-button-row { display: flex !important; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
    #stamp-constructor.msp-mobile-wizard .msp-mobile-advanced:not([hidden]) #msp-button-row button { flex: 1 1 120px; font-size: 13px; }
    #stamp-constructor.msp-mobile-wizard .msp-mobile-advanced:not([hidden]) #msp-layers-panel,
    #stamp-constructor.msp-mobile-wizard .msp-mobile-advanced:not([hidden]) #layer-list,
    #stamp-constructor.msp-mobile-wizard .msp-mobile-advanced:not([hidden]) .right-column { display: block !important; }
    #stamp-constructor.msp-mobile-wizard .msp-mobile-advanced .right-column { width: 100%; min-width: 0; min-height: 0; max-height: none; margin: 14px 0 0; padding: 0; border: 0; background: #fff; box-shadow: none; overflow: visible; }
    #stamp-constructor.msp-mobile-wizard .msp-mobile-advanced .msp-panel-title { display: block !important; margin: 12px 0; padding-bottom: 8px; font-size: 16px; }
    #stamp-constructor.msp-front.msp-mobile-wizard #msp-layers-panel .msp-panel-title { display: block !important; }
    #stamp-constructor.msp-mobile-wizard .msp-mobile-advanced #layer-list { max-height: none; overflow: visible; }
    #stamp-constructor.msp-mobile-wizard .msp-mobile-advanced #layer-list li { min-height: 48px; padding: 6px; }
    #stamp-constructor.msp-mobile-wizard .msp-mobile-advanced #layer-list .more-btn { width: 44px; height: 44px; min-height: 44px; padding: 0; line-height: 42px; }
    #stamp-constructor.msp-mobile-wizard .msp-mobile-advanced .text-controls-top { flex-wrap: wrap; gap: 6px; }
    #stamp-constructor.msp-mobile-wizard .msp-mobile-advanced .control-row > div { max-width: 100%; flex-wrap: wrap; }
    #stamp-constructor.msp-mobile-wizard .msp-mobile-advanced .control-panel { padding: 12px; }

    /* The existing checkout retains its fields and events, but joins the page flow. */
    #stamp-constructor.msp-mobile-wizard #msp-order-screen {
        position: static !important;
        inset: auto !important;
        width: 100%;
        min-width: 0;
        background: transparent;
        z-index: auto;
        overflow: visible !important;
    }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen .wrap { width: 100%; max-width: 100%; margin: 0; padding: 0; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen .card { min-height: 0; border: 0; border-radius: 0; box-shadow: none; overflow: visible; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen .hd,
    #stamp-constructor.msp-mobile-wizard #msp-order-screen .msp-order-progress,
    #stamp-constructor.msp-mobile-wizard #msp-order-screen .msp-order-mobile-footer,
    #stamp-constructor.msp-mobile-wizard #msp-order-compact-summary,
    #stamp-constructor.msp-mobile-wizard #msp-order-screen #msp-submit-order,
    #stamp-constructor.msp-mobile-wizard #msp-order-screen #msp-layout-review-section { display: none !important; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen .bd { display: block; width: 100%; margin: 0; padding: 0; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen .col { display: block; min-width: 0; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen .section { margin: 0 0 16px; padding: 0; border: 0; border-radius: 0; transition: none; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen [data-mobile-step]:not([hidden]) { display: block !important; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen #msp-contacts-section { margin-top: 22px; padding-top: 18px; border-top: 1px solid #e2e8f0; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen .msp-section-title { margin: 0 0 10px; color: #0f172a; font-size: 16px; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; max-height: none; overflow: visible; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen .item { min-width: 0; padding: 10px; gap: 5px; border: 1px solid #cbd5e1; border-radius: 10px; touch-action: manipulation; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen .item.selected { border-color: #2563eb; background: #eff6ff; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen .item img { height: 88px; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen .item .nm { font-size: 14px; line-height: 1.3; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen .item .sub { margin: 0; font-size: 13px; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen #msp-imprint-section:has(#msp-imprints-grid > .item:only-child) > .msp-section-title { display: none; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen #msp-imprints-grid:has(> .item:only-child) { grid-template-columns: minmax(0, 1fr); }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen #msp-imprints-grid > .item:only-child { display: flex; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 6px 12px; min-height: 48px; padding: 10px; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen #msp-holders-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen #msp-holders-grid > :not(.item) { grid-column: 1 / -1; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen #msp-holders-grid .item { display: flex; flex-direction: column; align-items: stretch; min-height: 0; padding: 9px; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen #msp-holders-grid .item img { align-self: center; width: 100%; max-width: 104px; height: 88px; object-fit: contain; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen #msp-holders-grid .item .nm { font-size: 13px; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen #msp-holders-grid .item .sub { margin-top: auto; }
    #stamp-constructor.msp-mobile-wizard #msp-mobile-more-holders { width: 100%; min-height: 48px; margin-top: 10px; border-color: #bfdbfe; color: #1d4ed8; background: #fff; font-size: 14px; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen label:has(> input[type="radio"]):not([style*="display:none"]):not([style*="display: none"]),
    #stamp-constructor.msp-mobile-wizard #msp-order-screen label:has(> input[type="checkbox"]):not([style*="display:none"]):not([style*="display: none"]) { display: flex; align-items: flex-start !important; gap: 10px !important; min-height: 48px; margin: 0 !important; padding: 12px 0; font-size: 15px !important; line-height: 1.4; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen label:has(> .msp-mobile-error) { display: block !important; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen #msp-edo-wrap { margin-left: 0 !important; padding: 4px 12px; border-radius: 9px; background: #f8fafc; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen #msp-ownership-block { padding: 12px !important; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen .msp-order-field-label { margin-bottom: 4px; font-size: 14px; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen .status:empty,
    #stamp-constructor.msp-mobile-wizard #msp-ownership-error:empty,
    #stamp-constructor.msp-mobile-wizard #msp-duplicate-source-error:empty,
    #stamp-constructor.msp-mobile-wizard #msp-layout-review-error:empty,
    #stamp-constructor.msp-mobile-wizard #msp-order-screen .actions:has(> #msp-submit-order) { display: none !important; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen .msp-optional-files { margin-top: 14px; padding: 0 10px; font-size: 13px; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen #msp-totals-section { margin: 16px 0; padding: 12px; border: 1px solid #e2e8f0; border-radius: 10px; background: #f8fafc; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen #msp-cash-tooltip,
    #stamp-constructor.msp-mobile-wizard #msp-order-screen #msp-surcharge-tooltip { max-width: 100%; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen .msp-order-success { min-height: 0; padding: 22px 10px; }
    #stamp-constructor.msp-mobile-wizard #msp-order-screen .msp-order-success-title { font-size: 24px; }

    #stamp-constructor.msp-mobile-wizard #msp-mobile-footer {
        position: fixed;
        left: 0;
        right: 0;
        bottom: var(--msp-keyboard-offset, 0px);
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 12px;
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding: 12px max(12px, env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
        border-top: 1px solid #e2e8f0;
        background: #fff;
        box-shadow: 0 -4px 16px rgba(15, 23, 42, .08);
        z-index: 1000;
    }

    #stamp-constructor.msp-mobile-wizard #msp-mobile-total { flex: 0 1 120px; min-width: 0; color: #0f172a; font-size: 13px; font-weight: 600; line-height: 1.4; overflow-wrap: normal; }
    #stamp-constructor.msp-mobile-wizard #msp-mobile-total .msp-mobile-total-amount { display: block; white-space: nowrap; font-weight: 700; }
    #stamp-constructor.msp-mobile-wizard #msp-mobile-total:empty { display: none; }
    #stamp-constructor.msp-mobile-wizard #msp-mobile-next { flex: 1 1 180px; max-width: 480px; min-width: 0; min-height: 50px; margin: 0; padding: 12px; border: 1px solid #2563eb; border-radius: 10px; background: #2563eb; color: #fff; font-size: 16px; font-weight: 700; line-height: 1.3; }

    #stamp-constructor.msp-mobile-wizard[data-mobile-step="1"] #msp-mobile-shell { padding-bottom: 24px; }
    #stamp-constructor.msp-mobile-wizard[data-mobile-step="1"] #msp-mobile-header { margin-bottom: 12px; padding-bottom: 0; border-bottom: 0; }
    #stamp-constructor.msp-mobile-wizard[data-mobile-step="1"] #msp-mobile-footer {
        position: static;
        padding: 0;
        margin-top: 16px;
        border: 0;
        box-shadow: none;
    }
    #stamp-constructor.msp-mobile-wizard #msp-mobile-manual-entry { width: 100%; margin-bottom: 12px; border: 1px solid #cbd5e1; background: #fff; color: #1d4ed8; }

    body.msp-mobile-active #msp-template-modal { padding: 0; }
    body.msp-mobile-active #msp-template-modal .modal-dialog { width: 100%; height: 100vh; height: 100dvh; max-height: 100dvh; border-radius: 0; }
    body.msp-mobile-active #msp-template-modal .modal-header { flex: 0 0 auto; gap: 10px; padding: 12px; }
    body.msp-mobile-active #msp-template-modal .modal-close { flex: 0 0 44px; width: 44px; height: 44px; padding: 0; }
    body.msp-mobile-active #msp-template-modal .msp-template-catalog-tools { padding: 10px 12px; }
    body.msp-mobile-active #msp-template-modal #msp-template-modal-search { min-height: 48px; font-size: 16px; }
    body.msp-mobile-active #msp-template-modal .msp-template-filter-row { gap: 6px; }
    body.msp-mobile-active #msp-template-modal .msp-template-filter { min-height: 44px; padding: 9px; font-size: 13px; }
    body.msp-mobile-active #msp-template-modal .modal-body { flex: 1 1 auto; min-height: 0; padding: 12px; overscroll-behavior: contain; }
    body.msp-mobile-active #msp-template-modal .modal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    body.msp-mobile-active #msp-template-modal .modal-card { min-width: 0; padding: 7px; }
    body.msp-mobile-active #msp-template-modal .modal-card .preview { min-height: 100px; padding: 4px; }
    body.msp-mobile-active #msp-template-modal .modal-card .preview img { min-height: 100px; }
    body.msp-mobile-active #msp-template-modal .modal-footer { flex: 0 0 auto; flex-wrap: wrap; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); }
    body.msp-mobile-active #msp-template-modal .modal-footer button { flex: 1; min-height: 48px; margin: 0; padding: 10px; font-size: 14px; }

    body.msp-mobile-active .msp-preview-zoom-modal { padding: 12px; }
    body.msp-mobile-active .msp-preview-zoom-card { display: flex; flex-direction: column; gap: 10px; width: min(100%, calc(100vh - 84px)); width: min(100%, calc(100dvh - 84px)); height: min(calc(100vw + 36px), calc(100vh - 24px)); height: min(calc(100vw + 36px), calc(100dvh - 24px)); max-height: calc(100dvh - 24px); min-width: 0; aspect-ratio: auto; }
    body.msp-mobile-active .msp-preview-zoom-close { top: 6px; right: 6px; width: 44px; height: 44px; min-height: 44px; margin: 0; padding: 0; line-height: 42px; }
    body.msp-mobile-active #msp-mobile-zoom-viewport { flex: 1 1 auto; width: 100%; height: 100%; min-width: 0; min-height: 0; overflow: auto; overscroll-behavior: contain; touch-action: pan-x pan-y pinch-zoom; background: #fff; border-radius: 8px; cursor: auto; }
    body.msp-mobile-active #msp-mobile-zoom-viewport #msp-preview-zoom-img { display: block; width: 100%; min-width: 0; max-width: none; height: 100%; object-fit: contain; border: 0; border-radius: 0; box-shadow: none; }
    body.msp-mobile-active #msp-mobile-zoom-viewport.msp-zoom-expanded #msp-preview-zoom-img { width: 200%; min-width: 200%; max-width: none !important; height: auto; cursor: grab; }
    body.msp-mobile-active #msp-mobile-zoom-toggle { flex: 0 0 50px; width: 100%; min-height: 50px; margin: 0; padding: 12px; border: 1px solid #bfdbfe; border-radius: 9px; background: #fff; color: #1d4ed8; font-family: inherit; font-size: 16px; font-weight: 600; line-height: 1.4; cursor: pointer; touch-action: manipulation; }
    body.msp-mobile-active #msp-mobile-zoom-toggle:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }

    body.msp-mobile-active #msp-icon-library-modal > div { width: 100% !important; max-width: 100% !important; max-height: 100dvh !important; border-radius: 0 !important; }
    body.msp-mobile-active #msp-icon-library-modal > div > div { min-width: 0; padding: 12px !important; }
    body.msp-mobile-active #msp-icon-library-modal input { box-sizing: border-box; min-height: 48px; font-size: 16px !important; }
    body.msp-mobile-active #msp-icon-library-modal button { min-height: 44px; }
    body.msp-mobile-active #msp-icon-library-modal #msp-icon-library-close { width: 44px !important; height: 44px !important; flex-shrink: 0; }
    body.msp-mobile-active #msp-icon-library-modal #msp-icon-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; min-height: 0; }
    body.msp-mobile-active #msp-icon-library-modal > div > div:last-child { flex-wrap: wrap; gap: 8px; }
}

@media (min-width: 480px) and (max-width: 639px) {
    #stamp-constructor.msp-mobile-wizard #msp-order-screen #msp-holders-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 639px) and (prefers-reduced-motion: reduce) {
    #stamp-constructor.msp-mobile-wizard *,
    body.msp-mobile-active #msp-template-modal * {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}

/* Integration with the public Nogins Foto theme and its inline page wrappers. */
@media (max-width: 639px) {
    body.msp-mobile-active #msp-mobile-editing-note,
    body.msp-mobile-active #stamp-constructor #msp-mobile-editing-note {
        display: none !important;
    }

    body.msp-mobile-in-view .pcaa-widget {
        display: none !important;
    }

    body.msp-mobile-active .nf-page-content > .nf-container:has(#stamp-constructor.msp-mobile-wizard) {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    body.msp-mobile-active .nf-page-content #stamp-constructor.msp-mobile-wizard #msp-mobile-header {
        scroll-margin-top: 72px;
    }

    /* Only ancestors of this constructor lose their nested decorative gutters. */
    body.msp-mobile-active .nf-entry-content div:has(#stamp-constructor.msp-mobile-wizard) {
        min-width: 0;
        min-height: 0 !important;
        max-width: 100%;
        padding-left: 0 !important;
        padding-right: 0 !important;
        border-left-width: 0 !important;
        border-right-width: 0 !important;
        overflow: visible !important;
    }

    body.msp-mobile-active .nf-top-bar > .nf-container,
    body.msp-mobile-active .nf-top-bar__left {
        min-width: 0;
        max-width: 100%;
        flex-wrap: wrap;
    }

    body.msp-mobile-active .nf-top-bar__left {
        width: 100%;
        gap: 6px 12px;
        justify-content: center;
    }

    body.msp-mobile-active .nf-top-bar__item {
        min-width: 0;
        max-width: 100%;
        white-space: normal;
        overflow-wrap: anywhere;
    }
}
