/* Keep generation results and history visible beside the controls on laptops.
   Breakpoints use workspace width, including inside the embedded studios. */
.film-v3-inspector #historySection {margin:16px 0 0!important;padding:14px;max-width:100%;border-top:1px solid var(--k3-border)}
.film-v3-inspector #historyList {display:grid;grid-template-columns:minmax(0,1fr)!important}
.director-v3-inspector .director-history {margin:0;padding:14px;border-top:1px solid var(--line)}
.director-v3-inspector .director-history-grid {grid-template-columns:minmax(0,1fr)}
.storyboard-stage #result-section .storyboard-history {margin:0!important;border:0;border-top:1px solid var(--line);border-radius:0}
.storyboard-stage #result-section .history-grid {grid-template-columns:minmax(0,1fr)}
.generation-history-panel > .v2-kling-history {min-width:0}
@media (min-width:900px) {
  .kamod-film-studio-v3 {grid-template-columns:minmax(250px,.9fr) minmax(0,1.15fr) minmax(230px,.8fr)!important}
  .kamod-film-studio-v3 > .film-v3-inspector {display:block;position:sticky;top:12px;max-height:850px;overflow:auto}
  .kamod-film-studio-v3 > #filmDirectorCard {grid-row:2}
  .kamod-film-studio-v3 .film-v3-stage-empty {min-height:320px;padding:24px}
  .kamod-film-studio-v3 > #results {min-height:340px}
  .kamod-audio-v3 .wrapper,.kamod-images-v3 .wrapper,.kamod-avatars-v3 .wrapper {
    grid-template-columns:minmax(240px,.85fr) minmax(0,1fr) minmax(220px,.75fr)!important;
  }
  .kamod-audio-v3 .wrapper > .audio-recent-section,
  .kamod-images-v3 .wrapper > .images-recent-section,
  .kamod-avatars-v3 .avatars-v3-aside {display:block;top:12px;max-height:850px;overflow:auto}
  :is(.kamod-audio-v3,.kamod-images-v3,.kamod-avatars-v3) .section.active > .grid-2 {
    grid-template-columns:minmax(230px,.85fr) minmax(0,1fr)!important;
  }
  :is(.kamod-audio-v3,.kamod-images-v3,.kamod-avatars-v3) .grid-2 > * {min-width:0}
  .kamod-embed-v3 .wrapper:has(>#ugc-history-section) {grid-template-columns:minmax(250px,.85fr) minmax(0,1fr) minmax(230px,.75fr)}
  .kamod-embed-v3 .wrapper > #ugc-history-section {display:block;top:12px;max-height:850px}
  .director-stage {grid-template-columns:minmax(240px,.85fr) minmax(0,1fr) minmax(230px,.8fr)!important}
  .director-v3-inspector {display:block;max-height:calc(100dvh - 100px);overflow:auto}
  .storyboard-stage {grid-template-columns:minmax(240px,.8fr) minmax(0,1fr) minmax(250px,1fr)!important}
  .storyboard-stage > * {min-width:0}
  .storyboard-stage #result-section {max-height:calc(100dvh - 100px);overflow:auto}
  /* Each provider keeps its own original history and result handlers. */
  .v2-workspace {grid-template-columns:190px minmax(0,1fr)!important}
  .v2-workspace.workflow-active {grid-template-columns:minmax(0,1fr)!important}
  .generation-history-panel.active {display:grid;grid-template-columns:minmax(0,1fr) minmax(220px,.45fr);align-items:start}
  .generation-history-panel > * {grid-column:1;min-width:0}
  .generation-history-panel > .v2-panel-head {grid-column:1/-1}
  .generation-history-panel > .v2-kling-history {grid-column:2;grid-row:2 / span 30;position:sticky;top:76px;max-height:calc(100dvh - 100px);overflow:auto;padding:0 12px 16px}
  .generation-history-panel :is(.v2-kling-history-grid,.v2-analysis-history-grid) {grid-template-columns:minmax(0,1fr)}
  .generation-history-panel .v2-grid {grid-template-columns:minmax(0,1fr) minmax(0,1fr)!important;padding:12px;gap:12px}
  .generation-history-panel .v2-grid > * {min-width:0}
}
@media (max-width:899px) {
  .kamod-film-studio-v3 {display:flex!important;flex-direction:column}
  .kamod-film-studio-v3 > .film-v3-inspector {display:block;width:100%;position:static}
  .director-stage,.storyboard-stage {grid-template-columns:minmax(0,1fr)!important}
  .director-v3-inspector,.storyboard-stage #result-section {display:block;position:static;max-height:none}
}
.avatars-v3-aside :is(#avatar-results,#motion-results,#heygen-results) {margin-top:16px;min-width:0}
.avatars-v3-aside .result-item {min-width:0;overflow-wrap:anywhere}
.avatars-v3-aside :is(video,img) {width:100%;max-height:340px;object-fit:contain}
.avatars-v3-aside .empty-state {min-height:80px;padding:16px}
@media (min-width:900px) and (max-width:1300px) {
  .v2-workspace {grid-template-columns:minmax(0,1fr)!important}
  .v2-provider-rail {flex-direction:row!important;overflow-x:auto}
  .v2-provider-rail .v2-provider-btn {min-width:150px}
  .v2-provider-rail .v2-rail-label {display:none}
}
@media (min-width:900px) {
  .storyboard-stage #result-section {display:block}
}
@media (max-width:899px) {
  .kamod-audio-v3 .wrapper,.kamod-images-v3 .wrapper,.kamod-avatars-v3 .wrapper {display:flex!important;flex-direction:column}
  :is(.kamod-audio-v3,.kamod-images-v3,.kamod-avatars-v3) .wrapper > * {min-width:0;max-width:100%;box-sizing:border-box}
  :is(.kamod-audio-v3,.kamod-avatars-v3) :is(.grid-2,.vo-layout) {grid-template-columns:minmax(0,1fr)!important}
  :is(.kamod-audio-v3,.kamod-avatars-v3) .grid-2 > * {min-width:0}
  .kamod-avatars-v3 .avatars-v3-aside {display:block;position:static;width:100%}
}
.kamod-audio-v3 > .history-section {box-sizing:border-box;width:calc(100% - 16px)}
.generation-history-panel .v2-kling-history-head {flex-wrap:wrap;align-items:flex-start}
.generation-history-panel .v2-kling-history-copy {overflow-wrap:anywhere}
.generation-relocated-result {display:none}
.kamod-avatars-v3 .grid-2 > div:has(> .generation-relocated-result:only-child) {display:none}
.kamod-avatars-v3 #section-avatars > .grid-2,
.kamod-avatars-v3 #section-motion > .grid-2 {grid-template-columns:minmax(0,1fr)!important}
/* The current V4 workspace also defines these slots; keep its theme while
   restoring the same desktop arrangement as the other generation pages. */
@media (min-width:900px) {
  body.kamod-film-studio-v3 {grid-template-columns:minmax(250px,.9fr) minmax(0,1.15fr) minmax(230px,.8fr)!important;gap:12px!important}
  .kamod-film-studio-v3 > .film-v3-inspector {grid-column:3;grid-row:1 / span 3}
  .kamod-film-studio-v3 .film-v3-result-preview {display:block}
}
/* Keep active shot planning ahead of archived frames in the V4 workspace. */
@media (min-width:900px) {
  .kamod-uix-v3 .director-stage {grid-template-columns:minmax(240px,.8fr) minmax(0,1.4fr) minmax(220px,.7fr)!important;gap:16px!important;align-items:start}
  .kamod-uix-v3 .director-stage > .director-card {grid-column:1;grid-row:1}
  .kamod-uix-v3 .director-stage > div:nth-child(2) {grid-column:2;grid-row:1}
  .kamod-uix-v3 .director-stage > .director-v3-inspector {grid-column:3;grid-row:1;position:sticky;top:76px}
  .kamod-uix-v3 .director-v3-preview {min-height:0;aspect-ratio:16/9}
  .generation-history-panel.active {grid-auto-flow:row dense}
  .generation-history-panel > .v2-panel-head {grid-row:1}
}
.director-v3-inspector .director-history-grid {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
.director-v3-inspector .director-history-card {min-width:0}
.director-v3-inspector :is(.director-history-thumb,.director-history-thumb-wrap) {width:100%;height:auto;aspect-ratio:16/9;object-fit:contain}
.director-v3-inspector .director-history-info {padding:8px}
@media (max-width:899px) {
  .kamod-uix-v3 .director-stage {grid-template-columns:minmax(0,1fr)!important}
  .kamod-uix-v3 .director-stage > * {grid-column:1!important;grid-row:auto!important;min-width:0}
}

/* A complete scene plan stays scannable; expand only the shot being reviewed. */
.v2-scenes-shot > summary {cursor:pointer;list-style:none;margin:0;gap:12px}
.v2-scenes-shot > summary::-webkit-details-marker {display:none}
.v2-scenes-shot[open] > summary {margin-bottom:16px}
.v2-scenes-shot > summary:focus-visible {outline:2px solid var(--warm);outline-offset:4px}
.v2-scenes-shot[open] > summary .v2-badge {transform:rotate(45deg)}
.v2-scenes-shot-list {max-height:55vh;overflow:auto;overscroll-behavior:contain;padding-right:4px}
.v2-scenes-output-card {align-self:start;min-width:0}
#v2MultiSceneSeedanceVideo {max-height:40vh;object-fit:contain}
@media(min-width:900px){.v2-scenes-output-card {position:sticky;top:76px;max-height:calc(100dvh - 96px);overflow:auto}}

#storyboard-frame-prompts {margin-top:20px;max-height:55vh;overflow:auto;grid-template-columns:repeat(2,minmax(0,1fr))}
#storyboard-frame-prompts:empty {display:none}
@media(max-width:600px){#storyboard-frame-prompts {grid-template-columns:1fr}}
