/* MMP production UI layout improvements (2026-10-18).
   Scope: studio panel proportions and video preview DISPLAY ONLY.
   Rendering dimensions, output presets, audio processing and generation logic unchanged. */

/* Studio layout repair: the existing workspace contains settings + center
   panels. A former three-track override (42/27/31) squeezed five action
   buttons into the 27% center column. Give controls most of the workspace
   while keeping the result panel visible and independently scrollable.
   This affects layout only: generated prompts and their handlers are intact. */
@media (min-width: 1250px) {
  body:is(body,#mmpEditorial#mmpTheme#mmpStudio):is(.settings-mode-preset,.settings-mode-direct) .app > .workspace {
    grid-template-columns: minmax(0,67fr) minmax(0,33fr) !important;
  }
  body.settings-mode-bgm .app > .bgm-workspace {
    grid-template-columns: minmax(0,70fr) minmax(0,30fr) !important;
  }
  /* Playlist proportions remain as in the previously supplied build. */
  body.settings-mode-playlist .pa-layout {
    grid-template-columns: minmax(0,55%) minmax(0,45%) !important;
  }
}
@media (min-width: 1250px) and (max-width: 1499px) {
  body:is(body,#mmpEditorial#mmpTheme#mmpStudio):is(.settings-mode-preset,.settings-mode-direct) .app > .workspace {
    grid-template-columns: minmax(0,65fr) minmax(0,35fr) !important;
  }
  body.settings-mode-bgm .app > .bgm-workspace {
    grid-template-columns: minmax(0,68fr) minmax(0,32fr) !important;
  }
}
/* Keep the original small-window presentation, but avoid a compressed center
   panel when a desktop browser window is smaller than the profile breakpoint. */
@media (min-width: 1025px) and (max-width: 1249px) {
  body:is(body,#mmpEditorial#mmpTheme#mmpStudio):is(.settings-mode-preset,.settings-mode-direct) .app > .workspace {
    grid-template-columns: minmax(0,62fr) minmax(0,38fr) !important;
  }
  body.settings-mode-bgm .app > .bgm-workspace {
    grid-template-columns: minmax(0,64fr) minmax(0,36fr) !important;
  }
}
/* Five result actions must wrap into legible buttons, not five narrow
   columns with one Hangul syllable per line. BGM reuses this same toolbar. */
body:is(body,#mmpEditorial#mmpTheme#mmpStudio):is(.settings-mode-preset,.settings-mode-direct,.settings-mode-bgm)
  #mainActionRow.main-action-grid {
  grid-template-columns: repeat(2,minmax(0,1fr)) !important;
  gap:10px !important;
  align-content:start;
}
body:is(body,#mmpEditorial#mmpTheme#mmpStudio):is(.settings-mode-preset,.settings-mode-direct,.settings-mode-bgm)
  #mainActionRow.main-action-grid > button {
  height:auto !important;
  min-height:56px !important;
  padding:10px 9px !important;
  white-space:normal !important;
  overflow-wrap:break-word !important;
  word-break:keep-all !important;
  line-height:1.3 !important;
}
body:is(body,#mmpEditorial#mmpTheme#mmpStudio):is(.settings-mode-preset,.settings-mode-direct,.settings-mode-bgm)
  #mainActionRow.main-action-grid > button:last-child:nth-child(odd) {
  grid-column:1 / -1;
}
/* Avoid overflow when an especially long label or song title appears. */
body:is(.settings-mode-preset,.settings-mode-direct) .workspace > *,
body.settings-mode-bgm .bgm-workspace > :is(.bgm-sidebar,.bgm-main),
body.settings-mode-playlist .pa-layout > * {min-width:0;}

/* Existing lyric editor: let its preview keep the REAL selected aspect ratio.
   Previously grid row stretching could distort the 16:9 stage. */
body.settings-mode-video #videoWorkspace:not(.mmp-lyric-active) .video-main {
  display:flex !important;
  flex-direction:column !important;
  align-items:stretch !important;
  gap:14px;
  min-width:0;
  overflow:visible !important;
}
body.settings-mode-video #videoWorkspace:not(.mmp-lyric-active) .video-preview-stage {
  display:block;
  flex:0 0 auto;
  height:auto !important;
  min-height:0 !important;
  max-height:none !important;
  aspect-ratio:var(--preview-aspect,16 / 9) !important;
}
body.settings-mode-video #videoWorkspace:not(.mmp-lyric-active) .video-preview-stage.is-youtube {
  width:100% !important;
  max-width:none !important;
  aspect-ratio:16 / 9 !important;
  margin-inline:0 !important;
}
body.settings-mode-video #videoWorkspace:not(.mmp-lyric-active) .video-preview-stage.is-shorts {
  width:min(100%, 400px, calc(68dvh * 9 / 16)) !important;
  max-width:100% !important;
  aspect-ratio:9 / 16 !important;
  margin-inline:auto !important;
}
body.settings-mode-video #videoWorkspace:not(.mmp-lyric-active) .video-preview-stage canvas {
  position:absolute;
  inset:0;
  width:100% !important;
  height:100% !important;
  display:block;
  object-fit:contain !important;
}
/* Give the existing editor a wider result/video area where space allows. */
@media (min-width:1280px) {
  body.settings-mode-video #videoWorkspace:not(.mmp-lyric-active) {
    grid-template-columns:minmax(0,36%) minmax(0,64%) !important;
  }
}
/* New lyric creator: two clear columns on desktop, tabs full-width below;
   the preview is no longer squeezed between 2 fixed-width sidebars. */
@media (min-width:821px) {
  #mmpLyricStudio .ls-columns {
    grid-template-columns:minmax(0,34%) minmax(0,66%) !important;
    gap:14px !important;
  }
  #mmpLyricStudio .ls-preview {grid-column:2;grid-row:1;}
  #mmpLyricStudio .ls-source {grid-column:1;grid-row:1;}
  #mmpLyricStudio .ls-design {grid-column:1 / -1 !important;grid-row:2;}
  #mmpLyricStudio .ls-design-body {overflow:visible !important;max-height:none !important;}
  #mmpLyricStudio .ls-preset-grid {grid-template-columns:none !important;}
}
@media (max-width:820px) {
  #mmpLyricStudio .ls-preview {grid-column:auto;grid-row:1;}
  #mmpLyricStudio .ls-source {grid-column:auto;grid-row:2;}
  #mmpLyricStudio .ls-design {grid-column:auto;grid-row:3;}
}
#mmpLyricStudio .ls-screen {width:100%;max-width:100%;height:auto;aspect-ratio:16 / 9;overflow:hidden;}
#mmpLyricStudio .ls-main-canvas {width:100% !important;height:100% !important;object-fit:contain !important;}

/* Fullscreen mode expands the live canvas but never changes render geometry. */
#mmpLyricStudio .mmp-preview-fullscreen-btn,
#videoPreviewTransport .mmp-preview-fullscreen-btn {
  display:inline-flex;align-items:center;justify-content:center;
  gap:6px;min-height:36px;padding:8px 12px;
  border:1px solid var(--editorial-line,#cabfed);
  border-radius:9px;background:var(--editorial-card,#fff);
  color:var(--editorial-text,#29243b);font-size:calc(12px * var(--font-scale,1));font-weight:700;
  white-space:nowrap;cursor:pointer;
}
#mmpLyricStudio .ls-preview-head {gap:10px;flex-wrap:wrap;}
#mmpLyricStudio .ls-preview-head .mmp-preview-fullscreen-btn {margin-left:auto;}
:is(#videoPreviewStage,#mmpLyricStudio .ls-screen):fullscreen {
  box-sizing:border-box;
  position:relative !important;
  display:flex !important;align-items:center !important;justify-content:center !important;
  width:100vw !important;height:100dvh !important;max-width:none !important;max-height:none !important;
  margin:0 !important;padding:0 !important;border:0 !important;border-radius:0 !important;
  aspect-ratio:auto !important;background:#090909 !important;overflow:hidden !important;
}
#videoPreviewStage:fullscreen canvas,
#mmpLyricStudio .ls-screen:fullscreen canvas {
  position:relative !important;inset:auto !important;
  display:block !important;width:auto !important;height:auto !important;
  max-width:100vw !important;max-height:100dvh !important;
  object-fit:contain !important;
}
#videoPreviewStage.is-youtube:fullscreen canvas,
#mmpLyricStudio .ls-screen:fullscreen canvas {
  width:min(100vw,calc(100dvh * 16 / 9)) !important;
  height:auto !important;aspect-ratio:16 / 9 !important;
}
#videoPreviewStage.is-shorts:fullscreen canvas {
  width:min(100vw,calc(100dvh * 9 / 16)) !important;
  height:auto !important;aspect-ratio:9 / 16 !important;
}
/* Retain the no-file hint in fullscreen while keeping its overlay constrained. */
#videoPreviewStage:fullscreen .video-preview-empty {background:transparent;}
/* Higher specificity than the document-view canvas constraints when fullscreen. */
html body.settings-mode-video #videoWorkspace:not(.mmp-lyric-active) #videoPreviewStage:fullscreen canvas {
  position:relative !important;inset:auto !important;
  width:min(100vw,calc(100dvh * 16 / 9)) !important;
  height:auto !important;
  max-width:100vw !important;max-height:100dvh !important;
  aspect-ratio:16 / 9 !important;
}
html body.settings-mode-video #videoWorkspace:not(.mmp-lyric-active) #videoPreviewStage.is-shorts:fullscreen canvas {
  width:min(100vw,calc(100dvh * 9 / 16)) !important;
  aspect-ratio:9 / 16 !important;
}
:is(#videoPreviewStage,#mmpLyricStudio .ls-screen) .mmp-preview-exit-btn {display:none;}
:is(#videoPreviewStage,#mmpLyricStudio .ls-screen):fullscreen .mmp-preview-exit-btn {
  display:block !important;position:absolute;z-index:15;right:18px;top:18px;
  padding:11px 14px;border:1px solid #ffffff55;border-radius:11px;
  background:#191919dd;color:#fff;font:700 13px 'Segoe UI',sans-serif;
  cursor:pointer;
}
