/* The H5 viewport excludes browser chrome. Reserve navigation before laying out
   the hero and notes; very short screens scroll above, never behind, the tabs. */
.studio[data-screen="mirror"] {
  --mirror-safe-bottom: max(0px, calc(env(safe-area-inset-bottom, 0px) - 20px));
  --mirror-navigation-height: calc(97px + var(--mirror-safe-bottom));
  height: 100vh;
  height: var(--visual-viewport-height, 100dvh);
}

#studio[data-screen="mirror"] > #screen {
  bottom: var(--mirror-navigation-height);
  overscroll-behavior-y: contain;
}

#studio[data-screen="mirror"] > #navigation {
  height: var(--mirror-navigation-height);
  background-size: 100% 109px;
  background-position: center -8px;
}

#studio[data-screen="mirror"] > #navigation .nav-item {
  top: 10px;
}

#studio[data-screen="mirror"] > #navigation .nav-ai {
  top: 13px;
}

#studio[data-screen="mirror"] .mirror-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding: env(safe-area-inset-top, 0px) 0 0;
}

#studio[data-screen="mirror"] .mirror-stage {
  --mirror-top-gap: clamp(24px, 7%, 42px);
  flex: 1 0 260px;
  height: auto;
  min-height: 260px;
  max-height: none;
}

.mirror-recommendations {
  flex: none;
  min-width: 0;
  padding: 0 0 4px;
}

.mirror-recommendations-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  margin: 0 17px;
}

.mirror-recommendations-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 8px;
  min-width: 0;
}

.mirror-recommendations-title h2 {
  margin: 0;
  color: #54453e;
  font-size: 15px;
  font-weight: 600;
  line-height: 22px;
}

.mirror-recommendations-hint {
  color: #857167;
  font-size: 12px;
}

.mirror-refresh {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  min-width: 64px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: #757575;
  font-size: 16px;
  line-height: 20px;
  white-space: nowrap;
}

.mirror-refresh:disabled {
  opacity: .55;
  cursor: wait;
}

.mirror-refresh:active {
  color: #444;
}

#studio[data-screen="mirror"] .mirror-history {
  position: absolute;
  top: calc(var(--mirror-top-gap) + 52px);
  left: calc(84.48% - 8px);
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 60px;
  min-height: 64px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #666;
  font-size: 12px;
  line-height: 17px;
  white-space: nowrap;
}

.mirror-history img {
  display: block;
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.mirror-screen .mirror-recommendations .strip {
  margin-top: 0;
}

.mirror-recommendations .mirror-pagination {
  margin-top: 6px;
}

/* Keep the complete portrait and its actions inside the hero's allocated row. */
#studio[data-screen="mirror"] .model-mode .stage-background {
  height: calc(100% - 16px);
  /* The artwork keeps its intrinsic aspect ratio. Cover the changing hero bounds
     without side bands; anchor the upper-left pin so it stays visible. */
  object-fit: cover;
  object-position: left top;
}

#studio[data-screen="mirror"] .model-mode .arch,
#studio[data-screen="mirror"] .model-mode .mirror-photo-frame,
#studio[data-screen="mirror"] .model-mode .model-photo:not(.personal) {
  top: var(--mirror-top-gap);
  height: calc(100% - var(--mirror-top-gap));
}

#studio[data-screen="mirror"] .model-mode .result-expand,
#studio[data-screen="mirror"] .mirror-favorite {
  top: auto;
  bottom: 0;
}

#studio[data-screen="mirror"] .mirror-result-actions {
  top: var(--mirror-top-gap);
}

#studio[data-screen="mirror"] .mirror-edit-tools {
  top: auto;
  bottom: 18%;
}

/* The reverse keeps its shared garment-coordinate box and clear undo controls. */
#studio[data-screen="mirror"] .styling .arch,
#studio[data-screen="mirror"] .outfit-composition,
#studio[data-screen="mirror"] .composition-actions {
  top: 60px;
  height: calc(100% - 60px);
}

@media (min-width: 700px) {
  .studio[data-screen="mirror"] {
    height: min(852px, calc(var(--visual-viewport-height, 100dvh) - 48px));
  }
}

/* Loading artwork shares the original 393:478 canvas. Never stretch its text
   when the responsive mirror allocates a taller or shorter hero. */
#studio[data-screen="mirror"] .mirror-generation img {
  object-fit: contain;
  object-position: center;
}

/* Photo readiness never replaces the entire mirror with a blank loading page. */
.mirror-photo-status{position:absolute;left:25%;top:35%;width:50%;text-align:center;z-index:6;color:#807477;font-size:14px;padding:12px}
.photo-pending .model-photo,.photo-pending .empty-stage,.photo-pending .result-expand,.photo-pending .mirror-favorite{visibility:hidden}
.photo-pending .mirror-edit-tools{visibility:hidden}
