html.ios-input-scroll-guard {
    overscroll-behavior: none;
    scroll-behavior: auto;
}

/* The embedded document scrolls; its surrounding site must stay at the origin,
   including Safari's extra native scroll area while the keyboard is open. */
html.ios-input-scroll-guard:has(.embedded-form-page),
html.ios-input-scroll-guard:has(.embedded-form-page) body {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    overscroll-behavior: none;
    scroll-behavior: auto;
}

html.ios-input-scroll-guard .page-wrapper.embedded-form-page {
    position: fixed;
    top: 0;
    left: 0;
    height: var(--embedded-keyboard-height, 100dvh);
    max-height: var(--embedded-keyboard-height, 100dvh);
    min-height: 0;
    animation: none;
    transform: none;
    opacity: 1;
}

html.ios-input-scroll-guard .embedded-form-page main.container {
    padding-bottom: max(6px, var(--embedded-keyboard-bottom-inset, env(safe-area-inset-bottom)));
}

/* Notes and verification dialogs must also fit above the keyboard now that
   the outer page can no longer pan to bring an off-screen field into view. */
html.ios-input-scroll-guard:has(.embedded-form-page) :is(.popup-overlay, .modal-overlay) {
    height: var(--embedded-keyboard-height, 100dvh) !important;
}

html.ios-input-scroll-guard:has(.embedded-form-page) :is(.popup-card, .modal-box) {
    max-height: calc(var(--embedded-keyboard-height, 100dvh) - 2rem);
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Reserve only the space covered by the keyboard so a field near the bottom
   can be revealed without Safari's native pan. The scroll guard still caps
   scrolling at the real page content, and this space disappears on blur. */
html.ios-keyboard-page-scroll body {
    padding-bottom: var(--ios-keyboard-inset);
}
