/* Shared mobile ergonomics. Loaded after domain styles to keep one touch baseline. */
.header-page-actions { display: contents; }

@media screen and (max-width: 767px) {
    html { scroll-padding-block: 150px calc(110px + env(safe-area-inset-bottom)); }
    body { -webkit-text-size-adjust: 100%; }
    .main-content { padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right)); }

    /* Keep page commands on their own row so the page title remains readable. */
    .workspace .header { height: auto; }
    .workspace .header-content { display: flex; flex-wrap: wrap; gap: 8px; padding-top: max(8px, env(safe-area-inset-top)); }
    .workspace .header-title { flex: 1 1 100px; overflow-wrap: normal; font-size: 16px; }
    .workspace .header-actions { display: contents; }
    .workspace .header-page-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; order: 2; width: 100%; min-width: 0; }
    .header-page-actions > form { min-width: 0; }
    .workspace .header-page-actions .btn { font-size: 13px; min-height:44px; min-width:44px; }
    .workspace .page-return a { width: 44px; height: 44px; }
    .workspace .user-btn, .workspace .notification-button { width: 44px; height: 44px; flex-shrink: 0; }
    .workspace .user-btn { display: grid; place-items: center; }
    .workspace .user-dropdown { position: fixed; top: calc(64px + env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); max-height: calc(100dvh - 164px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; }
    .workspace .user-menu-item { min-height: 44px; }

    /* 44px is the comfort target; inline prose links and calendar cells are separate. */
    body.workspace .btn, body.workspace .btn-sm, body.workspace .btn-icon,
    body .modal-close, body .flash-close, body .btn-toggle-password,
    body .credential-copy-btn, body .tag-add-btn, body .tag-filter,
    body .pagination-number, body .filter-summary-close,
    body .invoice-price-toggle-btn, body .bank-status,
    body .bank-settings-trigger, body .assistant-new, body .assistant-send,
    body .cal-icon-button, body .cal-text-button, body .cal-view-switch button,
    body .notification-panel button, body .notification-toast button,
    body .period-switch button, body .agenda-open {
        min-height: 44px; min-width: 44px;
    }
    body .flash-close, body .filter-summary-close { flex-shrink: 0; }
    body .list-filter-summary { min-height: 60px; padding-right: 58px; }
    body:has(.mobile-filters-ready) .list-filter-summary { padding-right: 58px; }
    body .bank-status, body .tag-filter, body .pagination-number { display: inline-flex; align-items: center; justify-content: center; }
    body .bank-status { white-space: nowrap; }
    body .memo-colors label, body .cal-check, body .cal-choice,
    body .notification-preferences label, body .notification-preferences summary { min-height: 44px; }
    body .btn-toggle-password { right: 0; }
    body .credential-field .form-input { padding-right: 52px; }
    body .notification-close { flex-shrink: 0; }

    /* iOS can focus inputs without automatically zooming a small font. */
    body input:not([type=checkbox]):not([type=radio]):not([type=hidden]),
    body select, body textarea { font-size: 16px; max-width: 100%; }
    body input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not(.app-select-source),
    body select:not(.app-select-source) { min-height: 44px; }
    body .form-label, body .form-hint { font-size: 13px; line-height: 1.5; }
    .form-input, .search-box, .editor-form, .record-body, .card-body > form { min-width: 0; }
    .form-row { grid-template-columns: minmax(0, 1fr); }
    .form-row .form-group:empty { display: none; }
    .form-actions { gap: 10px; }
    .editor-status { flex-basis: 100%; }
    .editor-form > .form-actions > .btn { flex: 1 1 120px; }
    .list-item-title, .detail-title, .quote-line p, .commercial-link strong { overflow-wrap: anywhere; }
    .list-item-title { white-space: normal; }
    body[data-page="tags.index"] .list-item { flex-wrap: wrap; }
    body[data-page="tags.index"] .list-item > .flex { margin-left: auto; }
    .card-header { gap: 12px; flex-wrap: wrap; }
    .card-title { min-width: 0; }
    .list-pagination { flex-wrap: wrap; gap: 12px; }
    .list-pagination > div { flex-wrap: wrap; }

    /* Dialogs remain scrollable when the viewport is short or the keyboard is open. */
    .modal-overlay { padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
    .modal-overlay .modal { max-height: calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; border-radius: 14px; }
    .modal-overlay .modal-body { max-height: none; overflow: visible; padding: 16px; }
    .modal-header { padding: 12px 16px; gap: 12px; }
    .modal-title { overflow-wrap: anywhere; min-width: 0; }
    .modal-footer { flex-wrap: wrap; padding: 16px; }
    .modal-footer > .btn { flex: 1 1 120px; }
    body dialog { max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overscroll-behavior: contain; }
    .cal-dialog-footer > div { flex-wrap: wrap; }
    .cal-dialog .cal-field-row { grid-template-columns: minmax(0, 1fr); }
    .cal-dialog .cal-title-input { font-size: 18px; }
    .notification-panel .notification-filters { flex-wrap: wrap; }
    .notification-panel .notification-tools { flex-wrap: wrap; gap: 8px; }
    .notification-toast { bottom: calc(100px + env(safe-area-inset-bottom)); }
    .cal-toast { bottom: calc(100px + env(safe-area-inset-bottom)); }

    /* Keep operational labels readable without enlarging chart axes or decoration. */
    .director .director-link, .director .agenda-foot a,
    .director .director-section-footer a { display: inline-flex; align-items: center; min-height: 44px; font-size: 13px; }
    .director .period-switch button { font-size: 12px; }
    .director .agenda-event-copy > strong { font-size: 14px; }
    .director .agenda-event-copy > small, .director .agenda-time,
    .director .agenda-kind, .director .agenda-foot { font-size: 12px; }
    .director .agenda-time b { font-size: 11px; }
    .assistant-suggestions { grid-template-columns: minmax(0, 1fr); }
    .assistant-suggestions strong { font-size: 14px; }
    .assistant-suggestions small, .assistant-welcome-copy { font-size: 13px; }
    .assistant-welcome-hint { font-size: 12px; }
    .assistant-composer { min-width: 0; }

    @media (hover: none) {
        .btn:hover { transform: none; }
    }
}

/* Focus must not disappear behind a sticky header or a bottom toolbar. */
body.has-overlay { overflow: hidden; }

@media screen and (max-width:767px) {
    body .client-tag-removable, body .tag-selector-item,
    body .btn-remove-item, body .assistant-icon-button,
    body .assistant-message-actions button, body .assistant-latest { min-width:44px; min-height:44px; }
    .client-tag-removable .tag-remove { opacity:1; }
    .tag-selector { gap:8px; }
}
@media screen and (max-width:767px) {
    #tagModal .form-group > .flex { flex-wrap:wrap; }
    #tagModal #newTagName { flex:1 1 100% !important; width:100%; }
    #tagModal .app-select { flex:1 1 120px; width:auto; }
    .workspace .bank-settings-trigger { min-height:44px; }
}
