/* Mobile adapter: keep the protected viewer bundles byte-for-byte unchanged. */
@media (max-width: 900px), (hover: none) and (pointer: coarse) {
  :root {
    --altura-mobile-left: max(12px, env(safe-area-inset-left));
    --altura-mobile-right: max(12px, env(safe-area-inset-right));
    --altura-mobile-top: max(12px, env(safe-area-inset-top));
    --altura-mobile-bottom: max(12px, env(safe-area-inset-bottom));
  }

  html, body { overscroll-behavior: none; }
  #app { width: 100%; height: 100dvh; }
  .stage { touch-action: manipulation; }
  #frame-canvas, .compass { touch-action: none; }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
    padding: var(--altura-mobile-top) var(--altura-mobile-right) 20px var(--altura-mobile-left);
  }
  .brandmark { grid-column: 1; grid-row: 1; min-width: 0; }
  .brandmark-word { font-size: 1.2rem; }
  .brandmark-by { display: none; }
  #ring-tabs-slot, .topbar > .ring-tabs { grid-column: 1 / -1; grid-row: 2; min-width: 0; width: 100%; }
  .ring-tabs {
    width: 100%; min-width: 0; max-width: none; margin: 0; gap: 16px;
    overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain;
    touch-action: pan-x; scroll-padding-inline: 4px;
  }
  .ring-tab { flex: 0 0 auto; min-height: 44px; padding: 8px 2px; }
  .ring-tab-label { white-space: nowrap; }
  .action-pill { grid-column: 2; grid-row: 1; min-height: 44px; padding: 10px 16px; white-space: nowrap; }

  .footbar {
    align-items: center; gap: 8px;
    padding: 32px var(--altura-mobile-right) var(--altura-mobile-bottom) var(--altura-mobile-left);
  }
  .readout { flex: 1; min-width: 0; }
  .readout-project { display: none; }
  .frame-label { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .transport { flex: none; gap: 6px; }
  .stepper, .icon-button { width: 44px; height: 44px; }
  .stepper-label { font-size: 10px; }
  .compass { right: var(--altura-mobile-right); bottom: calc(76px + env(safe-area-inset-bottom)); width: 64px; height: 64px; }
  .compass-face { width: 64px; height: 64px; }
  .stage:has(.selection-card) .compass { display: none; }
  .building-pin-body { min-height: 44px; align-items: center; padding-block: 10px; }

  .selection-card {
    left: var(--altura-mobile-left); right: var(--altura-mobile-right);
    bottom: calc(76px + env(safe-area-inset-bottom)); width: auto;
    max-height: calc(100dvh - 220px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    padding: 16px; overflow-y: auto; overscroll-behavior-y: contain; touch-action: pan-y;
  }
  .selection-close { flex: none; width: 44px; height: 44px; }
  .unit-tooltip { top: auto; left: var(--altura-mobile-left); right: var(--altura-mobile-right); bottom: calc(148px + env(safe-area-inset-bottom)); }
  .stage:has(.selection-card .selection-id) .unit-tooltip { display: none; }

  .finder-sheet { width: 100%; max-width: 100%; transition-duration: 240ms; }
  .finder-head {
    padding: max(20px, env(safe-area-inset-top)) max(72px, calc(env(safe-area-inset-right) + 60px)) 20px max(16px, env(safe-area-inset-left));
  }
  .finder-title { font-size: clamp(1.75rem, 6vw, 2.25rem); }
  .finder-close {
    top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right));
    width: 44px; height: 44px;
  }
  .finder-scroll {
    min-height: 0;
    padding: 20px max(16px, env(safe-area-inset-right)) max(28px, calc(env(safe-area-inset-bottom) + 20px)) max(16px, env(safe-area-inset-left));
    overscroll-behavior-y: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch;
  }
  .facet { margin-bottom: 16px; padding-bottom: 16px; }
  .facet-name, .facet-readout { font-size: 11px; }
  .option { min-height: 44px; }
  .chip { min-width: 44px; min-height: 44px; }
  .range { height: 44px; }
  .range::before { top: 21px; }
  .range-slider { height: 44px; touch-action: none; }
  .range-slider::-webkit-slider-thumb {
    box-sizing: border-box; width: 44px; height: 44px; border: 12px solid transparent;
    background: var(--ink); background-clip: content-box;
  }
  .range-slider::-moz-range-thumb {
    box-sizing: border-box; width: 44px; height: 44px; border: 12px solid transparent;
    background: var(--ink); background-clip: content-box;
  }
  .clear-all { min-height: 44px; align-items: center; }
  .results-head { flex-wrap: wrap; gap: 8px 12px; }
  .sort-control { min-height: 44px; gap: 12px; }
  .sort-link { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; font-size: 10px; }
  .result-row { min-height: 64px; }
  .result-meta { font-size: 11px; line-height: 1.6; }
  .result-status { font-size: 10px; }

  .tour-card {
    left: var(--altura-mobile-left) !important; right: var(--altura-mobile-right) !important;
    top: auto !important; bottom: calc(80px + env(safe-area-inset-bottom)) !important;
    width: auto; max-height: calc(100dvh - 200px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    padding: 16px; overflow-y: auto; overscroll-behavior-y: contain; touch-action: pan-y;
  }
  .tour-title { font-size: 1.35rem; }
  .tour-skip, .tour-back, .tour-next { min-width: 44px; min-height: 44px; }
  .tour-actions { position: sticky; bottom: 0; padding-top: 8px; background: var(--paper); }
}

@media (max-width: 900px) and (max-height: 520px) and (orientation: landscape), (hover: none) and (pointer: coarse) and (max-height: 520px) and (orientation: landscape) {
  .topbar { display: flex; flex-wrap: nowrap; align-items: center; padding-bottom: 16px; }
  .brandmark { flex: none; }
  #ring-tabs-slot, .topbar > .ring-tabs { flex: 1; min-width: 0; width: auto; }
  .ring-tabs { gap: 12px; }
  .action-pill { flex: none; margin: 0; }
  .selection-card {
    right: auto; width: min(320px, calc(100% - 24px));
    max-height: calc(100dvh - 164px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
  .tour-card { max-height: calc(100dvh - 160px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
}
