/* AI 生图结果：按窗口高度缩放，完整显示；不影响原图与导出。 */
html body .materials-workbench #aiStudio .ai-queue-img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(48vh, var(--ai-preview-fit-height, calc(100vh - 620px)));
  max-height: min(48dvh, var(--ai-preview-fit-height, calc(100dvh - 620px)));
  object-fit: contain;
  margin: 0 auto 10px;
  border-radius: 4px;
}
/* 小屏改为上下布局，图片仍完整显示，避免竖图占满数屏。 */
@media (max-width: 1050px) {
  html body .materials-workbench #aiStudio .ai-queue-img {
    max-height: 56vh;
    max-height: 56dvh;
  }
}
@media (min-width: 1051px) and (max-height: 500px) {
  html body .materials-workbench #aiStudio .ai-queue-img { max-height: 28vh; }
}

/* 右侧从创作标题处开始，给整图留出更多高度。隐藏的 tab 保持隐藏。 */
@media (min-width: 1051px) {
  html body .materials-workbench #aiStudio:not([style*="display: none"]):not([style*="display:none"]) {
    display: grid !important;
    grid-template-columns: minmax(0, 1.12fr) minmax(300px, .88fr);
    gap: 20px;
    align-items: start;
  }
  html body .materials-workbench #aiStudio > .ai-page-header {
    grid-column: 1;
    grid-row: 1;
    margin-bottom: 0 !important;
    flex-wrap: wrap;
  }
  html body .materials-workbench #aiStudio > .ms-studio-layout { display: contents !important; }
  html body .materials-workbench #aiStudio .ms-image-config { grid-column: 1; grid-row: 2; }
  html body .materials-workbench #aiStudio .ms-studio-layout > .ai-history {
    grid-column: 2 !important;
    grid-row: 1 / span 2;
  }
}
@media (min-width: 1600px) {
  html body .materials-workbench #aiStudio:not([style*="display: none"]):not([style*="display:none"]) {
    grid-template-columns: minmax(0, 1fr) minmax(420px, 1fr);
  }
}
