/* PlaceAI viewport and dialog resilience.
   Loaded after the primary UI styles so every modal remains operable at 100% zoom,
   on short laptop screens, mobile dynamic viewports, and browser zoom. */

body.modal-open,
body.sidebar-open {
  overflow: hidden;
}

.modal-overlay {
  overflow: auto;
  overscroll-behavior: contain;
  padding:
    max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
}

.auth-modal {
  height: min(760px, calc(100dvh - 48px));
  min-height: min(610px, calc(100dvh - 48px));
  max-height: calc(100dvh - 48px);
  overflow: hidden;
  align-items: stretch;
}

.auth-brand-panel,
.auth-form-panel {
  min-height: 0;
}

.auth-form-panel {
  align-self: stretch;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding-top: 58px;
  padding-bottom: 40px;
}

.modal-close {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 30;
  flex: 0 0 auto;
  box-shadow: 0 4px 18px rgba(16, 24, 39, .10);
}

.auth-inline-cancel {
  margin-top: 12px;
  position: sticky;
  bottom: 0;
  z-index: 5;
  box-shadow: 0 -10px 22px rgba(255,255,255,.94);
}

.generic-modal-card {
  max-height: calc(100dvh - 32px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.generic-modal-content {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding-right: 2px;
}

.generic-modal-actions {
  flex: 0 0 auto;
  position: relative;
  z-index: 2;
  background: #fff;
  padding-top: 16px;
}

.app-sidebar {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.app-nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  padding-right: 2px;
}

.sidebar-bottom {
  flex: 0 0 auto;
}

/* If a known signed-in session is being restored, do not flash the public/sign-in
   surface before the HttpOnly refresh-cookie bootstrap finishes. */
html.placeai-session-restoring #marketing-site {
  visibility: hidden;
}

html.placeai-session-restoring body::before {
  content: "Restoring your PlaceAI workspace…";
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: #f6f7fa;
  color: #647084;
  font: 600 13px/1.4 "DM Sans", sans-serif;
}

html.placeai-session-restoring #app-shell:not(.hidden) ~ * {
  pointer-events: auto;
}

@media (max-height: 700px) and (min-width: 761px) {
  .modal-overlay {
    place-items: start center;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .auth-modal {
    height: calc(100dvh - 24px);
    min-height: 0;
    max-height: calc(100dvh - 24px);
  }

  .auth-form-panel {
    padding: 48px 42px 28px;
  }
}

@media (max-width: 760px) {
  .auth-modal {
    height: calc(100dvh - 24px);
    min-height: 0;
    max-height: calc(100dvh - 24px);
    overflow: hidden;
  }

  .auth-form-panel {
    padding: 54px 25px 28px;
    overflow-y: auto;
  }

  .generic-modal-card {
    max-height: calc(100dvh - 24px);
  }

  .auth-inline-cancel {
    bottom: -1px;
  }
}

@media (max-width: 430px) {
  .auth-form-panel {
    padding-left: 20px;
    padding-right: 20px;
  }
}
