/* Shared phone/tablet safeguards, loaded after page-specific styles. */
.own-profile-body,
.own-profile-body > div,
.match-interests-section,
.match-interest-content,
.portal-dashboard-grid > *,
.wizard-panel .data-row,
.portal-notification-row > span:nth-child(2) {
    min-width: 0;
}
.own-profile-body h2,
.own-profile-meta span,
.portal-profile-intro h2,
.portal-notification-row strong,
.wizard-panel .list-group-item a {
    overflow-wrap: anywhere;
}
.match-interests-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.lookup-table-scroll { max-width: 100%; overflow-x: auto; }
.lookup-table-scroll table { width: 100% !important; }
.messages-page .portal-chat-launcher { display: none; }
.portal-message-history { overscroll-behavior: contain; }
.portal-chat-header,
.portal-chat-trust,
.portal-message-status,
.portal-composer,
.portal-composer-note { flex-shrink: 0; }
.compact-chat .portal-chat-trust,
.compact-chat .portal-composer-note,
.compact-chat .portal-chat-header p { display: none; }
.compact-chat .portal-chat-header { padding: 10px 12px; }
.compact-chat .portal-chat-avatar { width: 36px; height: 36px; }
.wizard-panel { scroll-margin-top: 100px; }
#wizardProgress { font-size: 0 !important; line-height: 0; }
#documentPreview .list-group-item { flex-wrap: wrap; gap: 10px; }
#documentPreview .list-group-item > span,
#documentPreview .list-group-item > a { flex: 1 1 150px; min-width: 0; overflow-wrap: anywhere; }

@media (max-width: 991px) {
    .site-header .navbar-collapse {
        max-height: calc(100vh - 80px);
        max-height: calc(100dvh - 80px);
        overflow-y: auto;
        overscroll-behavior: contain;
    }
    .site-header .navbar-nav .nav-link { min-height: 44px; }
    .site-header .account-navigation { position: relative; }
    .site-header .account-navigation > .dropdown { position: static; }
    .site-header .account-menu {
        left: 0 !important;
        right: 0 !important;
        top: calc(100% + 4px) !important;
        transform: none !important;
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }
    .match-interests-layout { grid-template-columns: minmax(0, 1fr); }
    /* 16px prevents focus zoom on iOS; controls remain comfortably tappable. */
    input.form-control,
    select.form-select,
    textarea.form-control,
    .portal-message-search input,
    .portal-composer textarea,
    .dataTables_wrapper input,
    .dataTables_wrapper select {
        font-size: 16px !important;
        max-width: 100%;
        min-height: 44px;
    }
    .btn,
    .password-toggle,
    .navbar-toggler,
    .btn-close,
    .portal-inbox-tabs button,
    .portal-search-tabs button,
    #wizardSteps .nav-link,
    .match-save {
        min-height: 44px;
    }
    .password-toggle,
    .navbar-toggler,
    .btn-close,
    .match-save { min-width: 44px; }
}

@media (max-width: 767px) {
    .match-tabs,
    .portal-filter-chips,
    .recommendation-strip,
    #wizardSteps {
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
    }
    .match-tabs::-webkit-scrollbar,
    .portal-filter-chips::-webkit-scrollbar,
    .recommendation-strip::-webkit-scrollbar,
    #wizardSteps::-webkit-scrollbar { display: none; }
    .match-tabs > a,
    .portal-filter-chips > a { min-height: 44px; display: inline-flex; align-items: center; }
    .member-portal #wizardSteps .nav-link { font-size: 12px; }
    #profileForm > .wizard-actions { gap: 12px; flex-wrap: wrap; align-items: stretch !important; }
    #profileForm > .wizard-actions > div { flex: 1 1 100%; }
    #profileForm > .wizard-actions > div > .btn { flex: 1 1 120px; }
    #profileForm .data-row { padding: 14px !important; }
    .wizard-panel fieldset { min-width: 0; }
    .wizard-panel .row > * { min-width: 0; }
    .wizard-panel .form-check { min-height: 44px; padding-top: 8px; }
    .wizard-panel input[type="file"] { width: 100%; }
    #imagePreview img { height: auto !important; max-height: 360px; object-fit: contain !important; }
    .own-profile-card .own-profile-body { min-width: 0; }
    .own-profile-card .own-profile-progress { flex: 1 1 100%; width: 100%; }
    .own-profile-card > .btn { margin-left: 0; }
    .member-portal .match-interests-section { padding: 18px 14px; }
    .member-portal .match-interest-card { flex-direction: column; }
    .member-portal .match-interest-content .btn { font-size: 12px !important; padding: 10px 14px !important; }
    .member-portal .match-interest-content .d-flex { flex-wrap: wrap; }
    .portal-profile-photos .match-detail-portrait { height: auto; aspect-ratio: 4 / 5; }
    .portal-message-search { min-height: 44px; }
    .portal-inbox-copy strong { font-size: 15px; }
    .portal-message-preview { font-size: 13px; }
    .portal-inbox-copy small, .portal-inbox-copy time { font-size: 11px; }
    .portal-chat-header strong { font-size: 16px; }
    .portal-chat-header p { font-size: 11px; }
    .portal-message-bubble p { font-size: 14px; line-height: 1.6; }
    .portal-message-bubble small { font-size: 11px; }
    .portal-message-status, .portal-composer-note { font-size: 11px; }
    .portal-composer button { width: 44px; height: 44px; }
    .portal-messages-page.has-conversation .portal-chat {
        height: calc(100vh - 170px);
        height: calc(var(--chat-viewport-height, 100dvh) - 170px);
        min-height: 260px;
    }
    .portal-messages-page.has-conversation .portal-messenger { min-height: 0; }
    .portal-message-history { min-height: 40px; }
    .portal-chat-launcher {
        right: max(16px, env(safe-area-inset-right));
        bottom: max(16px, env(safe-area-inset-bottom));
    }
    .settings-card form > .btn { margin: 8px 0 0 !important; width: 100%; }
    .modal-dialog { margin: 12px; }
    .modal-body, .modal-footer { overflow-wrap: anywhere; }
    .modal-footer { gap: 8px; }
    .lookup-table-scroll .btn { min-width: 60px; margin: 3px 0; }
    .dataTables_wrapper .pagination { flex-wrap: wrap; }
}

@media (max-width: 359px) {
    .member-portal .container { padding-left: 14px; padding-right: 14px; }
    .own-profile-body { width: 100%; flex-basis: 100%; }
    .portal-dashboard-actions { gap: 8px; }
    .portal-dashboard-actions a { overflow-wrap: anywhere; }
    .portal-definition-list > div { grid-template-columns: 95px minmax(0, 1fr); gap: 10px; }
    .portal-hero-actions { flex-wrap: wrap; }
    .portal-hero-actions .btn { flex-basis: 100%; }
    .portal-messages-page.has-conversation .portal-chat-header { padding: 12px 10px; gap: 8px; }
}
