/* Shared by preview and live pages. Prompts scroll; model/submit controls stay put. */
.editor-scroll>.field{margin-bottom:15px}
.editor-scroll>.field:has(#prompt),.editor-scroll>.field:has(.batch-editor){display:flex;flex-direction:column}
.creation-submit-bar.is-single{display:contents}

@media (min-width:900px) and (min-height:800px){
  body:has(.work-layout){height:100dvh;overflow:hidden}
  .shell:has(.work-layout){height:100dvh;display:flex;flex-direction:column;min-height:0}
  .shell:has(.work-layout)>.topbar{flex:none}
  #workspace:has(.work-layout){flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden;padding-top:16px;padding-bottom:12px}
  #workspace:has(.work-layout)>.page-heading{flex:none;margin-bottom:12px}
  .work-layout{flex:1;min-height:0;overflow:hidden}
  .work-layout>.editor,.work-layout>.result-panel{height:100%;min-height:0;position:static;overflow:hidden;align-self:stretch;padding:16px}
  .editor>.panel-heading,.editor>.creation-submit-bar,.creation-submit-bar.is-single>.parameter-section,.creation-submit-bar.is-single>.generate-area{flex:none}
  .editor>.panel-heading{margin-bottom:12px}
  .editor-scroll{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;scrollbar-gutter:stable;outline-offset:-2px}
  .editor-scroll:has(#prompt){display:flex;flex-direction:column}
  .editor-scroll>.compact-reference{margin-bottom:0}
  .editor-scroll:has(#prompt) .field-title{margin-bottom:4px}
  .editor-scroll>.field:has(#prompt){flex:1 0 180px;margin-bottom:8px}
  .editor-scroll:has(#prompt) .text-wrap{min-height:0;flex:1}
  .editor-scroll:has(#prompt) .text-footer{flex:none;padding-top:4px}
  /* Budget each batch row from the real content viewport, not the window. */
  .editor-scroll:has(.batch-editor){container-type:size;scroll-snap-type:y mandatory;scroll-padding-top:48px}
  .editor-scroll>.field:has(.batch-editor)>.field-title{position:sticky;top:0;z-index:6;min-height:48px;margin:0;padding:8px 4px;background:var(--dz-surface);border-bottom:1px solid var(--dz-border)}
  .editor .prompt-row{height:calc(100cqh - 56px);min-height:180px;flex:none;scroll-snap-align:start;scroll-snap-stop:always}
  .editor .prompt-row>.rich-prompt{min-height:0;overflow-y:auto;scrollbar-gutter:stable;overscroll-behavior:auto;flex:1 1 0}
  .editor .prompt-row>.row-top{flex:none}
  .editor .prompt-row .compact-reference-body{max-height:clamp(64px,25cqh,190px)}
  .editor-scroll .batch-hint{min-height:34px;padding:8px 4px;scroll-snap-align:end;scroll-snap-stop:always}
  .editor-scroll textarea#prompt,.editor-scroll #single-rich-prompt{min-height:130px;flex:1;resize:none;overflow:auto}
  .editor .parameter-section{padding-top:10px}
  .editor .parameter-section .advanced[open]{max-height:90px;overflow-y:auto;overscroll-behavior:contain}
  .editor .generate-area{margin-top:10px;padding-top:10px}
  .creation-submit-bar.is-single,.creation-submit-bar.is-batch{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:12px;align-items:end;border-top:1px solid var(--dz-border);padding-top:8px}
  .creation-submit-bar.is-single .parameter-section,.creation-submit-bar.is-batch .parameter-section,.editor:has([data-param-select=duration]) .creation-submit-bar.is-single .parameter-section,.editor:has([data-param-select=duration]) .creation-submit-bar.is-batch .parameter-section{grid-template-columns:minmax(180px,1.35fr) minmax(0,4fr);gap:8px;border:0;padding:0;margin:0}
  .creation-submit-bar.is-single .parameter-section>.field-title,.creation-submit-bar.is-batch .parameter-section>.field-title{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
  .creation-submit-bar.is-single .parameter-grid,.creation-submit-bar.is-batch .parameter-grid{gap:7px}
  .creation-submit-bar.is-single .model-field>span,.creation-submit-bar.is-single .parameter-field>span,.creation-submit-bar.is-batch .model-field>span,.creation-submit-bar.is-batch .parameter-field>span{font-size:10px;margin-bottom:3px}
  .creation-submit-bar.is-single .model-select,.creation-submit-bar.is-single .parameter-field select,.creation-submit-bar.is-single .parameter-grid .stepper,.creation-submit-bar.is-batch .model-select,.creation-submit-bar.is-batch .parameter-field select,.creation-submit-bar.is-batch .parameter-grid .stepper{height:36px;font-size:12px}
  .creation-submit-bar.is-single .model-status,.creation-submit-bar.is-batch .model-status{display:none}
  .creation-submit-bar.is-single .generate-area,.creation-submit-bar.is-batch .generate-area{display:flex;align-items:flex-end;gap:10px;border:0;margin:0;padding:0}
  .creation-submit-bar.is-single .generate-area .cost,.creation-submit-bar.is-batch .generate-area .cost{min-width:220px;gap:0;text-align:right;white-space:nowrap;font-size:11px;line-height:1.45}
  .creation-submit-bar.is-single .generate-area .cost strong,.creation-submit-bar.is-batch .generate-area .cost strong{font-size:12px}
  .creation-submit-bar.is-single .generate-area .primary,.creation-submit-bar.is-batch .generate-area .primary{min-width:184px;height:40px;padding-inline:18px;font-size:13px}
  .creation-submit-bar.is-single .generate-area .save-state,.creation-submit-bar.is-batch .generate-area .save-state{display:none}
  .result-panel>.panel-heading,.result-panel>.filter-row,.result-panel>.batchbar,.result-panel>.result-bottom{flex:none}
  .result-panel>.task-grid{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain}
  .result-panel>.request-warning{max-height:90px;overflow-y:auto;flex:none}
  .shell:has(.work-layout)>footer{flex:none;margin-top:0;padding-top:6px;padding-bottom:6px}
}

@media (min-width:900px) and (min-height:800px) and (max-width:1450px){
  .creation-submit-bar.is-single,.creation-submit-bar.is-batch{grid-template-columns:1fr}
  .creation-submit-bar.is-single .generate-area,.creation-submit-bar.is-batch .generate-area{justify-content:flex-end}
}

@media (min-width:900px) and (min-height:800px) and (max-height:900px){
  .editor .creation-tools .import-storyboard{height:40px;min-height:40px;padding:6px 12px}
  .editor .creation-tools .creation-mode-switch{padding:2px}
  .editor .creation-tools .creation-mode-switch button{min-height:34px;padding:5px 12px}
}

/* Keep the estimate to a clear total and one compact calculation line. */
.editor .generate-area .cost.cost-preview{min-width:160px;gap:2px;white-space:normal;line-height:1.4}
.editor .generate-area .cost.cost-preview strong{display:flex;align-items:baseline;justify-content:flex-end;gap:5px;font-weight:500}
.cost-preview .estimate-label{font-size:12px;color:var(--muted);font-weight:400}
.cost-preview .estimate-amount{font-size:20px;font-weight:600;font-variant-numeric:tabular-nums;color:var(--accent)}
.cost-preview #estimate-count{font-size:12px;color:var(--muted)}

/* Keep price copy from taking width away from model and parameter controls. */
.editor .generate-area .cost.cost-preview{min-width:0;width:240px;max-width:100%;overflow-wrap:anywhere}
.editor .generate-area .cost.cost-preview strong{flex-wrap:wrap}
.cost-preview #estimate-count{display:flex;justify-content:flex-end;align-items:center;gap:4px}
.cost-preview .estimate-summary{min-width:0}
.wan-billing-notice{display:inline-flex;flex:none}
.wan-billing-help{display:inline-flex;align-items:center;justify-content:center;width:26px;height:26px;padding:0;border:0;border-radius:50%;background:transparent;color:var(--accent);font-size:17px;cursor:pointer}
.wan-billing-help:hover,.wan-billing-help:focus-visible{background:var(--dz-border);outline-offset:2px}
.wan-billing-popover{position:fixed;inset:auto;margin:0;width:320px;max-width:calc(100vw - 16px);max-height:calc(100dvh - 16px);overflow:auto;padding:14px 16px;border:1px solid var(--dz-border);border-radius:12px;background:var(--dz-surface,#fff);color:var(--dz-text,#333);box-shadow:0 6px 24px #0002;font-size:13px;line-height:1.65;text-align:left;white-space:normal;overflow-wrap:anywhere}
.wan-billing-popover ul{margin:8px 0 0;padding-left:18px}.wan-billing-popover li+li{margin-top:6px}
@media(min-width:900px) and (min-height:800px){
  .editor .creation-submit-bar{display:flex;flex-wrap:wrap;align-items:flex-end}
  .editor .creation-submit-bar .parameter-section{flex:1 1 560px;min-width:0}
  .editor .creation-submit-bar .generate-area{flex:0 1 auto;margin-left:auto;max-width:100%}
  .editor .creation-submit-bar .model-field{min-width:180px}
}
@media(max-width:600px){.editor .generate-area .cost.cost-preview{width:auto}}
