/* BirchallArchive mobile interface 1.0.0.
   Loaded last in both editions. Diagram card geometry stays in tree.css. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@supports (font: -apple-system-body) {
  html { font: -apple-system-body; }
}
.app-shell { min-height: 100vh; min-height: 100dvh; }
#mainView, .catalogue-layout > *, .tree-workspace > * { min-width: 0; }
.catalogue-mobile-label { display: none; }
.mobile-tree-zoom { display: none; }
.catalogue-mobile-sort { display: none; gap: .75rem; padding: 0 1.125rem 1rem; }
.catalogue-mobile-sort.is-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.catalogue-inspector-navigation {
  display: flex; flex: 0 0 auto; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: .375rem; padding: .5rem var(--inspector-gutter);
  border-bottom: 1px solid var(--line); background: #fbfcf8;
}
.catalogue-inspector-navigation > span { font-size: .75rem; color: var(--muted); }
.catalogue-inspector-navigation button { min-height: 2.75rem; white-space: normal; }
.portal-header [hidden] { display: none !important; }
.portal-header .portal-menu-toggle {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .5rem .75rem; min-height: 2.75rem; border: 1px solid #c9d3c4;
  border-radius: .625rem; background: #fff; color: #315f48;
  font: 600 .9375rem/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  cursor: pointer; flex: 0 0 auto;
}
.portal-menu-toggle[aria-expanded="true"] { background: #edf3e7; }
.portal-header .portal-menu-toggle:focus-visible { outline: 3px solid #729660; outline-offset: 3px; }
.portal-header .account-identity { min-height: 2.75rem; }

/* A compact site header leaves room for the archive itself on a phone. */
@media screen and (max-width: 64rem) {
  .portal-header {
    display: grid; grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center; gap: .5rem; padding: max(.75rem, env(safe-area-inset-top))
      max(1rem, env(safe-area-inset-right)) .75rem max(1rem, env(safe-area-inset-left));
    font-size: 1rem;
  }
  .portal-header .portal-brand { gap: .625rem; font-size: 1.25rem; flex: auto; line-height: 1.2; }
  .portal-header .portal-brand small { font-size: .75rem; line-height: 1.4; }
  .portal-header .brand-symbol { width: 2rem; height: 2.5rem; flex-basis: 2rem; font-size: 1.625rem; }
  .portal-header .portal-menu-toggle { grid-column: 3; grid-row: 1; }
  .portal-header .account-identity { grid-column: 2; grid-row: 1; margin: 0; padding: .25rem; }
  .portal-header .account-identity > span:not(.avatar) { display: none; }
  .portal-header .avatar { width: 2.25rem; height: 2.25rem; flex-basis: 2.25rem; font-size: .875rem; }
  .portal-header #portalNavigation {
    grid-column: 1 / -1; grid-row: 2; order: initial; margin: .25rem 0 0;
    padding-top: .5rem; width: 100%; display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
    gap: .25rem; border-top: 1px solid #dce3d9;
  }
  .portal-header #portalNavigation a {
    min-width: 0; min-height: 2.75rem; padding: .625rem .75rem;
    border-radius: .5rem; font-size: .9375rem; line-height: 1.4; overflow-wrap: anywhere;
  }
  .portal-header #portalNavigation a[aria-current="page"] {
    background: #eaf1e4; text-decoration: none; box-shadow: inset 3px 0 #648953;
  }
}

@media screen and (max-width: 48rem) {
  .app-header { position: static; }
  .archive-portal .collection-context {
    padding: .75rem max(1rem, env(safe-area-inset-right)) .5rem max(1rem, env(safe-area-inset-left));
    gap: .375rem .75rem;
  }
  .archive-portal .collection-context strong { font-size: 1rem; }
  .archive-portal .collection-context > span:first-child,
  .archive-portal .publication-audience { font-size: .75rem; }
  .archive-portal .section-row, .section-row {
    display: flex; flex-wrap: wrap; gap: .5rem; padding: 0 max(.75rem, env(safe-area-inset-right))
      .75rem max(.75rem, env(safe-area-inset-left));
  }
  .archive-portal .primary-tabs, .section-row .primary-tabs {
    flex: 1 0 100%; display: flex; flex-wrap: nowrap; height: auto; min-height: 3rem;
    max-width: 100%; min-width: 0; gap: .125rem; overflow-x: auto;
    overscroll-behavior-x: contain; scroll-padding-inline: .25rem; scrollbar-width: thin;
  }
  .archive-portal .nav-tab, .section-row .nav-tab {
    flex: 0 0 auto; min-height: 2.75rem; padding: .75rem .875rem;
    font-size: .9375rem; line-height: 1.3;
  }
  .archive-portal .global-search, .section-row .global-search {
    flex: 1 1 100%; min-width: 0; width: 100%; max-width: none;
    min-height: 2.875rem; height: auto; margin: 0; padding: .625rem .875rem;
  }
  .global-search input { font-size: max(1rem, 16px); min-width: 0; line-height: 1.5; }
  .content-wrap, .people-directory, .places-view, .events-registry-view, .gallery-view {
    padding: 1.25rem max(1rem, env(safe-area-inset-right))
      max(2rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  }
  .places-view, .events-registry-view { width: 100%; }
  .view-title-row, .places-header-actions { flex-wrap: wrap; gap: .75rem; }
  .view-title-row h1 { font-size: 1.75rem; overflow-wrap: anywhere; }
  .section-heading, .family-directory-heading { flex-wrap: wrap; align-items: start; }
  .section-heading-actions { flex-wrap: wrap; }
  .people-controls, .people-controls label, .people-controls select { width: 100%; min-width: 0; }
  .people-controls label { font-size: .8125rem; }
  .people-controls select { font-size: max(1rem, 16px); }
  .people-list-card, .people-list-card.compact { grid-template-columns: 2.75rem minmax(0, 1fr) 1rem; padding: .75rem; gap: .75rem; }
  .person-list-main b, .relationship-name, .source-title { font-size: 1rem; line-height: 1.4; overflow-wrap: anywhere; }
  .person-list-main span, .relationship-dates, .source-subtitle { font-size: .875rem; white-space: normal; line-height: 1.5; }
  .person-list-code { display: none; }
  .family-directory-adults, .facts-grid { grid-template-columns: minmax(0, 1fr); }
  .person-hero { padding: 3.5rem 1rem 1.5rem; gap: 1rem; flex-wrap: wrap; }
  .person-heading { flex: 1 1 12rem; }
  .person-heading h1 { font-size: clamp(1.75rem, 6vw, 2.5rem); line-height: 1.18; overflow-wrap: anywhere; }
  .person-vitals { font-size: 1rem; line-height: 1.5; overflow-wrap: anywhere; }
  .person-vitals b { width: auto; min-width: 3.5em; margin-right: .5rem; font-size: .8125rem; }
  .hero-actions { flex-wrap: wrap; width: 100%; margin: 0; }
  .profile-back-button { min-height: 2.75rem; top: .375rem; font-size: .9375rem; }
  .profile-tabs { height: auto; justify-content: flex-start; gap: 0; overflow-x: auto; padding-inline: .75rem; scrollbar-width: thin; }
  .profile-tab { flex: 0 0 auto; min-height: 3rem; padding: .625rem 1rem; font-size: .9375rem; white-space: nowrap; }
  .event-card h3 { font-size: 1rem; }
  .event-card p, .library-meta, .photo-caption, .file-card-copy p { font-size: .9375rem; line-height: 1.6; }
  .event-footer { flex-wrap: wrap; gap: .5rem; font-size: .8125rem; }
  .timeline-row { grid-template-columns: 3rem 1.25rem minmax(0, 1fr); }
  .timeline-list::before { left: 3.55rem; }
  .timeline-year { font-size: .8125rem; padding-right: .375rem; }
  .source-card > div, .source-card > span { min-width: 0; }
  .gallery-grid, .source-library-grid, .gallery-library-grid, .profile-gallery-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr)); }
  .photo-card-title { font-size: 1rem; overflow-wrap: anywhere; line-height: 1.4; }
  .photo-card-meta { font-size: .875rem; line-height: 1.5; }
  .filter-row { max-width: 100%; }
  .filter-chip { min-height: 2.75rem; font-size: .9375rem; }
  .event-registry-heading h2, .place-card-heading b { font-size: 1rem; white-space: normal; line-height: 1.45; }
  .event-registry-copy p, .event-link-line, .place-card-meta, .place-card-main small { font-size: .875rem; white-space: normal; line-height: 1.5; }
  .event-registry-actions, .places-filter-bar, .place-card-actions { flex-wrap: wrap; }
  .place-card-heading, .places-filter-bar > *, .events-controls > * { min-width: 0; }
  .places-map { min-height: 18rem; height: 55svh; }
  .section-heading h2, .library-title { overflow-wrap: anywhere; }
  .field, .form-grid > *, .source-linking-grid > * { min-width: 0; }
  .field label, .field > span, .field-help, .detail-list dt { font-size: .875rem; }
  .field input, .field select, .field textarea,
  .events-controls select, .places-filter-bar select {
    min-width: 0; max-width: 100%; min-height: 2.75rem; font-size: max(1rem, 16px);
  }
  .events-search input, .source-link-search input { font-size: max(1rem, 16px); min-height: 2.75rem; }
  .events-controls > label:not(.events-search), .places-filter-bar .compact-filter > span { font-size: .8125rem; }
  .primary-button, .secondary-button, .text-button, .pill-button, .hero-button,
  .inline-link, .mini-button, .linked-chip, .linked-fact, .photo-person-tag {
    min-height: 2.75rem; font-size: .9375rem; line-height: 1.4; white-space: normal;
  }
  .detail-list, .source-detail-grid { grid-template-columns: minmax(0, 1fr); }
  .detail-list dd, .library-title, .file-card-copy { min-width: 0; overflow-wrap: anywhere; font-size: 1rem; }
  .search-result { padding: .75rem; min-height: 3.5rem; align-items: start; }
  .search-result > span:nth-child(2) { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 1rem; }
  .search-result small { font-size: .875rem; }
  .search-result-type { display: none; }

  /* The close button never moves into the scrolling content. */
  .modal-backdrop { padding: 0; height: 100dvh; }
  .modal, .modal.wide, .modal.tree-print-modal {
    display: flex; flex-direction: column; width: 100%; height: 100%;
    max-height: none; min-height: 0; border: 0; border-radius: 0; overflow: hidden;
  }
  .modal-header {
    position: relative; flex: 0 0 auto; align-items: start; gap: .75rem;
    padding: max(.75rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
      .75rem max(1rem, env(safe-area-inset-left));
  }
  .modal-header h2 { font-size: 1.375rem; line-height: 1.35; margin: .375rem 0; }
  .modal-close { flex: 0 0 auto; width: 2.75rem; height: 2.75rem; }
  .modal-body { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 1rem; }
  .modal-footer {
    position: relative; flex: 0 0 auto; padding: .75rem 1rem max(.75rem, env(safe-area-inset-bottom));
    gap: .5rem; max-height: 32dvh; overflow: auto;
  }
  .modal-footer button { flex: 1 1 8rem; }
  .source-page-title { padding: .5rem; overflow-wrap: anywhere; }
  .preview-frame { min-height: 10rem; }
  .preview-frame img { max-height: 60svh; }
  .preview-frame embed { height: 60svh; min-height: 16rem; }
  .source-page-title span { font-size: .875rem; white-space: normal; }
  .source-page-counter { gap: .5rem; flex-wrap: wrap; font-size: .875rem; }
  .source-page-dots { flex-wrap: wrap; justify-content: center; gap: 0; }
  .source-page-dots button { width: 2.75rem; height: 2.75rem; border: 1rem solid #fff; }
  .source-page-dots button.active { transform: none; }
  .image-lightbox {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto minmax(0, 1fr);
    align-items: stretch; justify-items: stretch; gap: .75rem; height: 100dvh;
    padding: max(.625rem, env(safe-area-inset-top)) max(.625rem, env(safe-area-inset-right))
      max(.625rem, env(safe-area-inset-bottom)) max(.625rem, env(safe-area-inset-left));
  }
  .lightbox-close { position: static; grid-column: 2; grid-row: 1; width: 2.75rem; height: 2.75rem; }
  .lightbox-toolbar {
    position: static; grid-column: 1; grid-row: 1; transform: none;
    display: flex; flex-wrap: wrap; justify-content: flex-start; gap: .25rem; padding: 0; border: 0; background: none;
  }
  .lightbox-toolbar button { min-width: 2.75rem; height: auto; min-height: 2.75rem; padding: .375rem .625rem; font-size: 1rem; }
  .lightbox-zoom-label { font-size: .875rem; min-width: 2.5rem; }
  .lightbox-image-wrap { grid-column: 1 / -1; grid-row: 2; width: 100%; height: 100%; min-height: 0; max-width: none; max-height: none; touch-action: pinch-zoom; }
  .lightbox-image-wrap img { max-height: 100%; }
  .tree-person-popover { max-height: calc(100dvh - 2rem); overflow: auto; }
  .tree-person-popover-main { grid-template-columns: 3.5rem minmax(0, 1fr) 2.75rem; }
  .tree-popover-menu-button { width: 2.75rem; height: 2.75rem; }
}

/* Catalogue rows reflow into labelled records, preserving all chosen columns. */
@media screen and (max-width: 44rem) {
  .catalogue-workspace { padding: 1rem max(.75rem, env(safe-area-inset-right)) max(2rem, env(safe-area-inset-bottom)) max(.75rem, env(safe-area-inset-left)); font-size: 1rem; }
  .catalogue-heading { flex-wrap: wrap; align-items: center; gap: .75rem; }
  .catalogue-heading h1 { font-size: 1.75rem; }
  .catalogue-heading p, .catalogue-eyebrow { font-size: .8125rem; line-height: 1.5; }
  .catalogue-heading-actions { margin-left: auto; }
  .catalogue-layout, .has-inspector .catalogue-layout, .is-sidebar-open.has-inspector .catalogue-layout { display: block; min-height: 0; height: auto; }
  .catalogue-results { min-height: 0; }
  .has-inspector .catalogue-results { display: none; }
  .has-inspector .catalogue-inspector, .is-sidebar-open.has-inspector .catalogue-inspector { display: flex; border: 0; }
  .catalogue-record-scroll { max-height: none; min-height: 0; overflow: visible; }
  .catalogue-sidebar { display: none; max-height: 60svh; border-right: 0; border-bottom: 1px solid var(--line); }
  .is-sidebar-open .catalogue-sidebar { display: block; }
  .catalogue-sidebar-toggle { display: inline-flex; }
  .catalogue-inspector-empty { display: none; }
  .catalogue-inspector { --inspector-gutter: 1rem; height: calc(100svh - 1rem); min-height: 0; scroll-margin-top: .5rem; }
  .catalogue-inspector-top .catalogue-mini { width: 2.75rem; height: 2.75rem; flex-basis: 2.75rem; }
  .catalogue-inspector h2 { font-size: 1.375rem; line-height: 1.4; }
  .catalogue-inspector-body { padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
  .catalogue-inspector .catalogue-details { font-size: 1rem; }
  .catalogue-details { grid-template-columns: minmax(0, 1fr); gap: .25rem; }
  .catalogue-details dd { margin-bottom: .75rem; }
  .catalogue-details dt { font-size: .8125rem; }
  .catalogue-inspector-section summary, .catalogue-linked-records button { font-size: .9375rem; min-height: 2.75rem; }
  .catalogue-button, .catalogue-text-button, .catalogue-nav-item { min-height: 2.75rem; font-size: .875rem !important; white-space: normal; }
  .catalogue-mini { width: 2.75rem; height: 2.75rem; flex-basis: 2.75rem; }
  .catalogue-segmented button { min-width: 2.75rem; min-height: 2.75rem; }
  .catalogue-disclosure { width: 2.75rem; flex-basis: 2.75rem; min-height: 2.75rem; }
  .catalogue-nav-item > span, .catalogue-node-row .catalogue-nav-item { white-space: normal; overflow-wrap: anywhere; }
  .catalogue-nav-item > small, .catalogue-accession-link span small { font-size: .8125rem; }
  .catalogue-results-heading { flex-wrap: wrap; gap: .5rem; }
  .catalogue-results-heading h2 { font-size: 1.125rem; overflow-wrap: anywhere; }
  .catalogue-search-row { flex-wrap: wrap; gap: .5rem; }
  .catalogue-search { flex-basis: 100%; padding: .75rem; }
  .catalogue-search input, .catalogue-filter-field select, .catalogue-filter-field input { font-size: max(1rem, 16px); min-height: 2.75rem; }
  .catalogue-search input { min-height: 1.5rem; }
  .catalogue-filter-field > span { font-size: .875rem; }
  .catalogue-filters { grid-template-columns: minmax(0, 1fr); max-height: none; overflow: visible; }
  .catalogue-mobile-sort, .catalogue-mobile-sort.is-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding-inline: .75rem; }
  .catalogue-mobile-select-all { grid-column: 1 / -1; display: flex; align-items: center; gap: .75rem; min-height: 2.75rem; font-size: .875rem; }
  .catalogue-mobile-select-all input { width: 1.5rem; height: 1.5rem; accent-color: #5c814a; }
  .catalogue-list-toolbar { flex-wrap: wrap; font-size: .875rem; }
  .catalogue-list-toolbar > div { justify-content: flex-start; gap: .75rem; }
  .catalogue-table, .catalogue-table tbody { display: block; width: 100%; }
  .catalogue-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .catalogue-table tbody tr { display: grid; grid-template-columns: minmax(0, 1fr); padding: 1rem; border-bottom: 1px solid var(--line); gap: .625rem; }
  .catalogue-table tr.is-current { background: #edf3e7; box-shadow: inset 3px 0 #678d55; }
  .catalogue-table td, .catalogue-table .catalogue-cell-title, .catalogue-table .catalogue-cell-date_text {
    display: block; min-width: 0; max-width: none; width: auto; height: auto; padding: 0; border: 0; font-size: .9375rem;
  }
  .catalogue-table td[data-label]:not(.catalogue-cell-title) { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: .75rem; align-items: start; }
  .catalogue-table td[data-label]:not(.catalogue-cell-title)::before { content: attr(data-label); color: var(--catalogue-muted); font-size: .8125rem; line-height: 1.5; }
  .catalogue-table td > span { white-space: normal; max-width: none; overflow-wrap: anywhere; line-height: 1.5; }
  .catalogue-table .catalogue-title-button { display: block; font-size: 1.0625rem; line-height: 1.45; min-height: 2.75rem; overflow: visible; overflow-wrap: anywhere; }
  .catalogue-table .catalogue-cell-title { order: -1; }
  .catalogue-table tr.is-current td:first-child { box-shadow: none; }
  .catalogue-table .catalogue-check-cell { display: flex; align-items: center; min-height: 2.75rem; }
  .catalogue-check-cell input, .catalogue-grid-card input { width: 1.5rem; height: 1.5rem; }
  .catalogue-table .catalogue-open-cell .catalogue-mini { width: auto; min-width: 2.75rem; padding: .5rem .75rem; border: 1px solid var(--line); font-size: .875rem; gap: .5rem; }
  .catalogue-mobile-label { display: inline; }
  .catalogue-status { font-size: .8125rem; white-space: normal; }
  .catalogue-reference, .catalogue-inspector-status > span:last-child { font-size: .8125rem; }
  .catalogue-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); }
  .catalogue-grid-copy .catalogue-title-button { font-size: 1rem; }
  .catalogue-grid-copy p, .catalogue-grid-card footer label { font-size: .875rem; }
  .catalogue-grid-card footer label { min-height: 2.75rem; }
  .catalogue-pagination { flex-wrap: wrap; font-size: .875rem; gap: .75rem; }
  .catalogue-pagination > div { flex-wrap: wrap; width: 100%; justify-content: space-between; gap: .5rem; }

  .tree-workspace { height: auto; min-height: 0; padding: 1rem .75rem; gap: .75rem; overflow: visible; }
  .tree-heading { flex-wrap: wrap; gap: .75rem; }
  .tree-heading h1 { font-size: 1.75rem; }
  .tree-heading p, .tree-eyebrow { font-size: .8125rem; line-height: 1.5; }
  .tree-heading-actions { flex-direction: row; flex-wrap: wrap; }
  .tree-heading-actions button, .tree-button, .tree-workspace .tree-selected-summary button { min-height: 2.75rem; font-size: .875rem; line-height: 1.4; }
  .tree-workspace .tree-toolbar, .tree-workspace .tree-toolbar-actions { width: 100%; max-width: none; gap: .75rem; }
  .tree-mode-control { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .tree-mode-control button { min-height: 2.75rem; font-size: .875rem; padding: .5rem; white-space: normal; }
  .tree-depth, .tree-card-design { flex-wrap: wrap; font-size: .875rem; }
  .tree-depth select, .tree-finder input { min-height: 2.75rem; font-size: max(1rem, 16px); }
  .tree-design-button { min-height: 2.75rem; font-size: .875rem; }
  .tree-finder { min-width: 0; flex-basis: 100%; width: 100%; margin: 0; }
  .tree-workspace .tree-selected-summary { flex-wrap: wrap; min-width: 0; flex-basis: 100%; }
  .tree-workspace .tree-selected-summary b { max-width: 100%; white-space: normal; overflow-wrap: anywhere; font-size: 1rem; }
  .tree-workspace .tree-control-button { min-width: 2.75rem; min-height: 2.75rem; height: auto; font-size: 1rem; }
  .tree-viewport-frame { flex: none; height: 65svh; min-height: 18rem; }
  .tree-viewport-frame { display: grid; grid-template-rows: auto minmax(0, 1fr); }
  .tree-diagram-toolbar { position: static; padding: .5rem; justify-content: space-between; background: #fbfcf8; border-bottom: 1px solid var(--tree-line); }
  .tree-workspace .tree-scroll-area { position: relative; inset: auto; min-height: 0; }
  .mobile-tree-zoom { display: flex; align-items: center; }
  .is-fullscreen .mobile-tree-zoom { display: none; }
  .mobile-tree-settings { border: 1px solid var(--tree-line); border-radius: .625rem; padding: .25rem .75rem; background: #fff; }
  .mobile-tree-settings summary { cursor: pointer; min-height: 2.75rem; padding: .75rem 0; font-size: .9375rem; font-weight: 600; }
  .mobile-tree-settings .tree-toolbar, .mobile-tree-settings .tree-toolbar-actions { margin-block: .5rem 1rem; }
  .tree-workspace .tree-scroll-area { touch-action: pan-x pan-y pinch-zoom; }
  .tree-find-results { max-height: 40dvh; }
  .tree-find-result b { font-size: 1rem; }
  .tree-find-result small { font-size: .875rem; }
  .tree-caption { flex-wrap: wrap; font-size: .8125rem; line-height: 1.5; }
  .tree-print-dialog { grid-template-columns: minmax(0, 1fr); }
  .tree-print-controls { grid-template-columns: minmax(0, 1fr); position: static; }
  .tree-print-controls input, .tree-print-controls select { font-size: max(1rem, 16px); min-height: 2.75rem; }
  .tree-print-controls p, .tree-print-controls label, .tree-print-summary { font-size: .875rem; }
}

/* The expanded diagram reserves real space for its wrapping toolbar. */
@media screen {
  .tree-viewport-frame.is-fullscreen {
    display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0;
    padding: max(.5rem, env(safe-area-inset-top)) max(.5rem, env(safe-area-inset-right))
      max(.5rem, env(safe-area-inset-bottom)) max(.5rem, env(safe-area-inset-left));
  }
  .is-fullscreen .tree-diagram-toolbar { position: static; width: 100%; margin: 0 0 .5rem; transform: none; }
  .is-fullscreen .tree-scroll-area { position: relative; top: auto; right: auto; bottom: auto; left: auto; height: 100%; min-height: 0; }
  .is-fullscreen .tree-minimap { bottom: max(.75rem, env(safe-area-inset-bottom)); right: max(.75rem, env(safe-area-inset-right)); }
}
@media screen and (pointer: coarse) {
  .tree-workspace .tree-scroll-area { touch-action: pan-x pan-y pinch-zoom; }
  .tree-diagram-toolbar button { min-height: 2.75rem; min-width: 2.75rem; }
}

/* Public home, accounts and Research desk share the same responsive rhythm. */
.portal-pages :is(.panel, .identity-panel, .row-actions, .filters, .account-person, .research-item) { min-width: 0; }
.portal-pages :is(p, dd, td, small, .evidence-card, .selected-evidence) { overflow-wrap: anywhere; }
@media screen and (max-width: 48rem) {
  .portal-pages { font-size: 1rem; }
  .portal-pages main { padding: 1.5rem max(1rem, env(safe-area-inset-right)) 2rem max(1rem, env(safe-area-inset-left)); }
  .portal-pages .panel { padding: 1rem; border-radius: .875rem; margin-bottom: 1rem; }
  .portal-pages .two-column, .portal-pages .auth-layout, .portal-pages .form-grid,
  .portal-pages .role-grid, .portal-pages .discovery-grid { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .portal-pages .form-grid .full { grid-column: 1 / -1; }
  .portal-pages .page-heading { flex-direction: column; align-items: flex-start; gap: 1rem; }
  .portal-pages h1, .portal-pages .auth-layout h1 { font-size: 2rem; }
  .portal-pages .welcome h1 { font-size: clamp(2rem, 8vw, 3rem); }
  .portal-pages h2 { font-size: 1.5rem; }
  .portal-pages h3 { font-size: 1.125rem; }
  .portal-pages .lead { font-size: 1.125rem; line-height: 1.6; }
  .portal-pages :is(.hint, .badge, small, label > span, .discovery-card p, .discovery-card b) { font-size: .875rem; }
  .portal-pages .eyebrow { font-size: .75rem; }
  .portal-pages :is(input, select, textarea) { font-size: max(1rem, 16px); }
  .portal-pages :is(button, .button, summary) { min-height: 2.75rem; font-size: 1rem; white-space: normal; }
  .portal-pages .filters { display: flex; flex-wrap: wrap; gap: .75rem; }
  .portal-pages .filters label { flex: 1 1 100%; min-width: 0; }
  .portal-pages .row-actions { flex-wrap: wrap; }
  .portal-pages .row-actions > * { min-width: 0; max-width: 100%; }
  .portal-pages .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .portal-pages .identity-panel { gap: 1rem; }
  .portal-pages .identity-panel > div { min-width: 0; flex: 1 1 10rem; }
  .portal-pages .identity-panel dl { margin: 0; flex-basis: 100%; grid-template-columns: minmax(0, 1fr); }
  .portal-pages .photo-editor { grid-template-columns: minmax(0, 1fr); padding: 1rem; }
  .portal-pages .evidence-card, .portal-pages .selected-evidence li { flex-wrap: wrap; gap: .75rem; }
  .portal-pages .evidence-picker { padding: 1rem; }
  .portal-pages .selected-evidence button { flex: 0 0 auto; }
  .portal-pages .check { min-height: 2.75rem; font-size: .9375rem; }
  .portal-pages .check input { width: 1.25rem; height: 1.25rem; min-height: 1.25rem; }
  .portal-pages .discovery-card { padding: 1.25rem; min-height: 0; }
  .portal-pages .discovery-card span { margin-bottom: .75rem; font-size: .8125rem; }
  .portal-pages .welcome { padding-block: .5rem 1.5rem; }
  .portal-pages .portal-record-table, .portal-pages .portal-record-table tbody { display: block; width: 100%; min-width: 0; }
  .portal-pages .portal-record-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .portal-pages .portal-record-table tr { display: grid; gap: .75rem; padding: 1rem 0; border-bottom: 1px solid var(--line); }
  .portal-pages .portal-record-table td { display: block; min-width: 0; padding: 0; border: 0; font-size: 1rem; white-space: normal; }
  .portal-pages .portal-record-table td::before { content: attr(data-label); display: block; font-size: .8125rem; color: var(--muted); margin-bottom: .25rem; }
  .portal-pages .portal-record-table td[data-label=""]::before { display: none; }
  .portal-pages .portal-record-table td a { display: inline-flex; align-items: center; min-height: 2.75rem; }
  .portal-pages .portal-footer { font-size: .875rem; padding-bottom: max(1.5rem, env(safe-area-inset-bottom)); }
}
@media screen and (max-width: 24rem) {
  .portal-header .brand-symbol, .portal-header .portal-brand small { display: none; }
  .catalogue-mobile-sort, .catalogue-mobile-sort.is-grid { grid-template-columns: minmax(0, 1fr); }
  .catalogue-table td[data-label]:not(.catalogue-cell-title) { grid-template-columns: minmax(0, 1fr); gap: .125rem; }
  .tree-mode-control { grid-template-columns: minmax(0, 1fr); }
  .portal-pages .metrics { grid-template-columns: minmax(0, 1fr); }
}
@media print {
  .catalogue-mobile-sort, .catalogue-inspector-navigation, .catalogue-mobile-label, .portal-menu-toggle, .mobile-tree-settings, .mobile-tree-zoom { display: none !important; }
}
