/* Shared mobile layout refinements. Desktop layouts and permission visibility are unchanged. */
.app-connection-notice,
.app-recovery-offer,
.app-recovery-status {
    box-sizing: border-box;
    max-inline-size: 100%;
    min-inline-size: 0;
    margin-block: 10px;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    background: #f8fafc;
    color: #334155;
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}
.app-connection-notice[hidden], .app-recovery-offer[hidden], .app-recovery-status[hidden] { display: none !important; }
.app-connection-notice[data-state="offline"] { background: #fffbeb; border-color: #fcd34d; color: #92400e; }
.app-connection-notice[data-state="error"] { background: #fff1f2; border-color: #fda4af; color: #9f1239; }
.app-recovery-offer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.app-recovery-offer p { flex: 1 1 100%; margin: 0; }
.app-recovery-button {
    min-block-size: 44px;
    max-inline-size: 100%;
    padding: 9px 14px;
    border: 1px solid #2563eb;
    border-radius: 10px;
    background: #2563eb;
    color: #fff;
    font: inherit;
    font-weight: 650;
    white-space: normal;
    overflow-wrap: anywhere;
    cursor: pointer;
    touch-action: manipulation;
}
.app-recovery-button.app-recovery-secondary { background: #fff; border-color: #94a3b8; color: #334155; }
.app-recovery-button:focus-visible { outline: 3px solid #2563eb; outline-offset: 3px; }
@media (max-width: 767px) {
    html { scroll-padding-bottom: calc(160px + env(safe-area-inset-bottom, 0px)); }

    .mobile-topbar:has(.mobile-brand-copy) { gap: 8px; padding: 7px 10px; }
    .mobile-topbar:has(.mobile-brand-copy) .mobile-icon-button {
        min-inline-size: 44px;
        min-block-size: 44px;
        flex: 0 0 44px;
    }
    .mobile-topbar .mobile-brand-copy strong {
        min-inline-size: 0;
        max-inline-size: 100%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    :is(.sw, .sale-ui-shell, .ph-mobile-form-page, .delivery-detail, .pod-surface),
    :is(.sw, .sale-ui-shell, .ph-mobile-form-page, .delivery-detail, .pod-surface) :is(fieldset, .sw-field, .sale-ui-field, .workflow-proof-field, .pod-field) {
        min-inline-size: 0;
        max-inline-size: 100%;
    }

    :is(.sw, .sale-ui-shell, .ph-mobile-form-page, .delivery-detail, .pod-surface) :is(label, legend, .field-error, [role="alert"], [role="status"]),
    :is(.workflow-step-copy, .workflow-review-item, .pod-card-title, .sale-ui-line-header, .sw-head, .sw-footer, .sw-actions) > * {
        min-inline-size: 0;
        overflow-wrap: anywhere;
    }

    :is(.sw, .sale-ui-shell, .ph-mobile-form-page, .delivery-detail, .pod-surface) :is(input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]), select, textarea) {
        box-sizing: border-box;
        min-inline-size: 0 !important;
        max-inline-size: 100%;
        min-block-size: 44px;
        font-size: 16px !important;
        scroll-margin-block: 100px 200px;
    }

    :is(.sw, .sale-ui-shell, .ph-mobile-form-page, .delivery-detail, .pod-surface) :is(button, .sw-btn, .detail-btn, .detail-btn-secondary, .workflow-proof-trigger, .fieldops-icon-action, .ops-button, .ops-button-secondary, .pod-button, .pod-link),
    .ph-mobile-action-bar .ph-mobile-action-button {
        box-sizing: border-box;
        min-block-size: 44px !important;
        max-inline-size: 100%;
        white-space: normal !important;
        overflow-wrap: anywhere;
        line-height: 1.35;
        touch-action: manipulation;
    }

    .delivery-detail .workflow-mobile-shell-close {
        inline-size: 44px;
        block-size: 44px;
        flex-basis: 44px;
    }

    .sw :is(summary, .sw-tabs a), .pod-surface summary {
        min-block-size: 44px;
        align-content: center;
        overflow-wrap: anywhere;
    }

    :is(.sw, .sale-ui-shell, .ph-mobile-form-page, .delivery-detail, .pod-surface) :is(button, a, input, select, textarea, summary):focus-visible {
        outline: 3px solid #2563eb;
        outline-offset: 3px;
    }

    :is(.sw-footer, .sw-editor-actions, .workflow-step-actions, .pod-action-buttons) > * {
        min-inline-size: 0;
        max-inline-size: 100%;
    }

    html[data-mobile-keyboard-open="true"] .mobile-bottom-nav,
    html[data-mobile-keyboard-open="true"] .mobile-fab {
        display: none !important;
    }

    /* Leave all actions in the document while typing; users can scroll to them. */
    html[data-mobile-keyboard-open="true"] :is(.ph-mobile-action-bar, .rn-sticky-mobile-actions, .rental-mobile-action-bar, .entry-mobile-footer, .mobile-entry-actions, .pod-actions),
    html[data-mobile-keyboard-open="true"] .workflow-mobile-shell[data-mobile-shell-state="open"] .workflow-mobile-stepper[data-mobile-workflow-active="true"] [data-workflow-step-panel].is-current .workflow-step-actions {
        position: static !important;
        inset: auto !important;
        margin-block-start: 12px;
        box-shadow: none;
    }

    html[data-mobile-keyboard-open="true"] .workflow-mobile-shell[data-mobile-shell-state="open"] {
        height: var(--app-visible-height, 100dvh);
        max-height: var(--app-visible-height, 100dvh);
        top: var(--app-visible-top, 0px);
        bottom: auto;
    }

    html[data-mobile-keyboard-open="true"] :is(dialog[open], .sale-ui-modal[open]) {
        max-height: calc(var(--app-visible-height, 100dvh) - 24px);
        overflow-y: auto;
        overscroll-behavior: contain;
    }
}

@media (max-width: 390px) {
    /* The wordmark already identifies the app; keep the compact header's actions distinct. */
    .mobile-topbar:has(.mobile-brand-copy) .mobile-brand { flex: 1 1 0; min-inline-size: 0; }
    .mobile-topbar:has(.mobile-brand-copy) .mobile-brand-logo {
        inline-size: 88px;
        max-inline-size: 100%;
        block-size: 38px;
        max-block-size: 38px;
        flex: 0 1 88px;
    }
    .mobile-topbar .mobile-brand-copy { display: none; }
    .mobile-topbar .mobile-topbar-search {
        box-sizing: border-box;
        flex: 0 0 44px;
        inline-size: 44px;
        min-block-size: 44px;
        padding: 0;
        justify-content: center;
    }
    .mobile-topbar .mobile-topbar-search span { display: none; }
    .sw .sw-footer { align-items: stretch; }
    .sw .sw-footer .sw-actions { inline-size: 100%; }
    .pod-surface .pod-meta { grid-template-columns: minmax(0, 1fr); }
    .pod-surface .pod-card-title { align-items: flex-start; flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
    :is(.sw, .sale-ui-shell, .ph-mobile-form-page, .delivery-detail, .pod-surface) *,
    .mobile-bottom-nav * {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
