/* App-only viewport contract. Load after style.css; do not apply to homepage/admin. */
#app-shell {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
}

/* Keep the desktop phone presentation, but never exceed the visible viewport. */
.phone-frame {
  width: min(390px, 100%);
  height: min(844px, 100%);
  max-height: 100%;
  min-height: 0;
  min-width: 0;
}

/* A native screen's height is the frame's remaining space, not another 100dvh. */
.screen-container,
html.native-app .screen-container {
  flex: 1 1 0%;
  height: auto;
  min-height: 0;
  min-width: 0;
}

.screen {
  min-height: 0;
  min-width: 0;
}

/* Each screen owns its scroll; the shell must stay still for transitions/nav/maps. */
.screen > .scrollable-content,
.screen > .screen-content,
.screen > .auth-page {
  flex: 1 1 0%;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-padding-block: 16px calc(var(--bottom-nav-height) + var(--app-bottom-inset) + 24px);
  /* Some legacy screens have inline shorthand padding, hence this narrow override. */
  padding-bottom: calc(var(--bottom-nav-height) + var(--app-bottom-inset) + 24px) !important;
}

/* Auth previously had two competing flex/scroll owners. Scroll the whole form,
   including validation and its final action, rather than shrinking its contents. */
.auth-page > .auth-content {
  flex: 0 0 auto;
  min-height: 0;
  min-width: 0;
}

.auth-page > .auth-content.scrollable-content {
  overflow: visible;
  padding-bottom: 24px !important;
}

/* Keep the location card centered when it fits; on short screens its top remains
   reachable (justify-content:center otherwise overflows in both directions). */
.screen > .location-setup-shell {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  justify-content: flex-start;
}

.location-setup-shell > .location-setup-card {
  flex-shrink: 0;
  margin-block: auto;
}

/* A folded phone uses the complete dynamic viewport, without the old 6px offset. */
@media (max-width: 480px) {
  .phone-frame {
    width: 100%;
    height: 100%;
    margin-top: 0;
  }
}

/* This also covers unfolded Fold/tablet WebViews and standalone native updates. */
html.native-app .phone-frame {
  width: 100%;
  height: 100%;
  margin-top: 0;
}
