#storyboardDialog { box-sizing:border-box; width:min(1000px,96vw); max-width:96vw; max-height:90dvh; padding:clamp(14px,3vw,28px); color:var(--ink); background:var(--paper); border:1px solid var(--line); border-radius:16px; }
#storyboardDialog::backdrop { background:rgb(14 30 27 / .45); }
#storyboardDialog h2, #storyboardDialog h3 { margin:.2rem 0; }
.story-heading, .story-actions, .story-library, .story-fields { display:flex; flex-wrap:wrap; gap:10px; align-items:center; }
.story-heading { justify-content:space-between; }
.story-library, .story-fields { margin:14px 0; }
.story-library select { flex:1; min-width:0; }
.story-fields label { flex:1 1 130px; }
.story-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(340px,100%),1fr)); gap:14px; margin-top:16px; align-items:start; }
.story-card { padding:14px; min-width:0; border:1px solid var(--line); border-radius:12px; }
.story-description, #storyOriginal { white-space:pre-wrap; overflow-wrap:anywhere; }
.story-pair { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin:12px 0; }
.story-card figure { margin:0; min-width:0; }
.story-card figure img { width:100%; height:auto; max-height:230px; object-fit:contain; border-radius:7px; }
.story-card figcaption, .story-placeholder { font-size:.78rem; color:var(--muted); }
.story-placeholder { display:grid; place-items:center; min-height:78px; background:var(--soft); border-radius:7px; }
#storyboardDialog .story-check { display:inline-flex; align-items:center; gap:6px; margin:0; }
#storyboardDialog .story-check input { width:auto; margin:0; }
.story-card details { margin-top:10px; }
.story-card textarea, .story-card input:not([type=checkbox]) { margin-bottom:8px; }
#storyMessage { overflow-wrap:anywhere; }
#storyboardDialog[aria-busy=true] button:not(#storyClose) { pointer-events:none; opacity:.65; }
@media(max-width:550px) { #storyboardDialog { max-height:96dvh; } .story-actions { gap:6px; } }

/* Fit the actual content box, including long unbroken titles and native file/select controls. */
#storyboardDialog, #storyCutDialog { overflow-wrap:anywhere; overscroll-behavior:contain; }
#storyboardDialog :is(h2,h3,p,summary,button,label,figcaption), #storyCutDialog :is(h2,p,label,button) { max-width:100%; min-width:0; white-space:normal; overflow-wrap:anywhere; }
#storyboardDialog :is(input:not([type=checkbox]),textarea,select), #storyCutDialog :is(input,textarea) { box-sizing:border-box; width:100%; max-width:100%; min-width:0; }
#storyboardDialog .story-library select { width:auto; flex:1 1 9rem; }
#storyboardDialog :is(.story-fields>label,.story-card,.story-pair>figure,.story-actions,.story-pinned,.story-cut-actions) { min-width:0; }
#storyboardDialog .story-actions button { flex:0 1 auto; }
#storyboardDialog .story-pair { grid-template-columns:repeat(2,minmax(0,1fr)); }
#storyCutDialog { width:min(30rem,calc(100% - 24px)); max-width:calc(100% - 24px); max-height:90dvh; overflow:auto; padding:clamp(14px,3vw,24px); color:var(--ink); background:var(--paper); border:1px solid var(--line); border-radius:12px; }
#storyCutDialog::backdrop { background:rgb(14 30 27 / .48); }
#storyCutError { color:var(--danger,#a33); }
.story-card.story-working { box-shadow:inset 4px 0 0 var(--green); border-color:var(--green); }
.story-meter:not([hidden]) { display:grid; gap:3px; padding:7px 10px; border-radius:6px; background:var(--soft); margin:.4rem 0; }
.story-meter span,.story-pinned { font-size:.85rem; }
.story-meter progress { width:100%; min-width:0; height:.45rem; accent-color:var(--green); }
.story-run-progress:not([hidden]), .story-pinned { display:flex; align-items:center; gap:6px; flex-wrap:wrap; margin:.5rem 0; }
.story-step[data-state=working] { background:var(--green); color:var(--paper); }
.story-step[data-state=done] { border-color:var(--green); }
.story-pinned { padding:8px; border:1px solid var(--green); border-radius:8px; }
.story-pinned img { max-width:10rem; }
.story-cut-actions { margin-top:8px; }
@media(max-width:480px) { #storyboardDialog .story-fields { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); } #storyboardDialog .story-fields label:last-child { grid-column:1/-1; } .story-library label { flex-basis:100%; } }
