/* Create: one calm column (the conversation) with the chat box anchored at the bottom. References attach inside
   the chat box; Results open as a drawer. The window never scrolls: only the thread does. */
main:has(> #legacyStudio:not([hidden])){overflow:hidden;display:flex;flex-direction:column;padding-bottom:0}
main:has(> #legacyStudio:not([hidden]))>footer{display:none}
main>#legacyStudio.create:not([hidden]){flex:1;min-height:0;display:flex;justify-content:center;padding-bottom:14px}
#legacyStudio{--create-pill:color-mix(in srgb,var(--text) 7%,transparent);--create-pill-hover:color-mix(in srgb,var(--text) 12%,transparent);--create-surface:color-mix(in srgb,var(--panel) 88%,transparent)}
:root[data-theme="light"] #legacyStudio{--create-pill:#f0f0f2;--create-pill-hover:#e6e6ea;--create-surface:color-mix(in srgb,#fff 90%,transparent)}

/* Column */
#legacyStudio .create-main{width:min(100%,900px);min-width:0;min-height:0;display:flex;flex-direction:column;gap:8px;padding:0;border:0;border-radius:0;background:transparent;overflow:visible;grid-template-columns:none}
.create-top{display:flex;align-items:center;gap:8px;min-height:36px}
.create-top-spacer{flex:1}
.create-top .generator-context{margin:0;padding:0;border:0;background:none;font-size:13px;color:var(--muted)}
.create-for{display:inline-flex;align-items:center;gap:8px;padding:4px 6px 4px 12px;border-radius:999px;background:var(--create-pill)}
.create-for strong{color:var(--text);font-weight:600}
.create-for .text-button{min-height:0;padding:2px 8px;border-radius:999px;font-size:12px;color:var(--text)}
.create-top .mode-control{padding:2px;gap:2px;border:0;border-radius:999px;background:var(--create-pill)}
.create-top .mode-control button{min-height:28px;padding:2px 12px;border-radius:999px;font-size:12px;color:var(--muted);background:transparent}
.create-top .mode-control .selected{background:var(--panel);color:var(--text);box-shadow:0 1px 2px #0000001f}
:root[data-theme="light"] .create-top .mode-control .selected{background:#fff}
.create-top-button,.create-more>summary{display:inline-flex;align-items:center;gap:6px;min-height:32px;padding:4px 12px;border:0;border-radius:999px;background:var(--create-pill);color:var(--text);font-size:13px;cursor:pointer;list-style:none;transition:background .15s ease}
.create-top-button:hover,.create-more>summary:hover,.create-more[open]>summary,.create-top-button[aria-expanded="true"]{background:var(--create-pill-hover)}
.create-top-button svg,.create-more svg,.create-pill svg,.create-icon-button svg{width:16px;height:16px;flex:none;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.create-more svg circle{fill:currentColor;stroke:none}
.create-more>summary{width:32px;padding:0;justify-content:center}
.create-badge{min-width:18px;padding:0 5px;border-radius:999px;background:var(--create-pill-hover);font-size:11px;line-height:18px;text-align:center;color:var(--muted)}

/* Thread */
.create-thread{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;display:flex;flex-direction:column;gap:28px;padding:16px 4px 20px}
.gen-item{display:flex;flex-direction:column;gap:10px;border-radius:18px;transition:background .25s ease}
.gen-item.is-flash{background:color-mix(in srgb,var(--focus,#0a84ff) 9%,transparent)}
.gen-prompt{align-self:flex-end;max-width:min(78%,600px);padding:10px 15px;border-radius:20px 20px 6px 20px;background:var(--create-pill)}
.gen-prompt p{margin:0;font-size:15px;line-height:1.5;color:var(--text);white-space:pre-wrap}
.gen-refs{display:flex;flex-wrap:wrap;gap:4px;margin-top:6px}
.gen-refs span{padding:1px 8px;border-radius:999px;background:var(--create-pill-hover);font-size:11px;color:var(--muted)}
.gen-result{align-self:flex-start;width:min(100%,640px);display:grid;gap:8px}
.gen-visual{border-radius:18px;overflow:hidden;background:var(--create-pill)}
.gen-visual img,.gen-visual video{display:block;width:100%;max-height:min(62vh,560px);object-fit:contain;background:#000}
.gen-state{display:grid;place-items:center;min-height:200px;color:var(--muted);font-size:13px}
.gen-state.busy{animation:gen-pulse 1.4s ease-in-out infinite}
@keyframes gen-pulse{50%{opacity:.5}}
.gen-meta{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap;padding:0 4px;font-size:12px;color:var(--muted)}
.gen-actions{display:flex;gap:14px}
.gen-actions .text-button{min-height:0;padding:0;font-size:12px}
.gen-empty{margin:auto;display:grid;justify-items:center;gap:18px;text-align:center}
.gen-empty h3{margin:0;font-size:clamp(26px,3vw,34px);font-weight:600;letter-spacing:-.03em;color:var(--text)}
.gen-starters{display:flex;flex-wrap:wrap;justify-content:center;gap:8px}
.gen-starters button{min-height:36px;padding:6px 14px;border:0;border-radius:999px;background:var(--create-pill);color:var(--text);font-size:13px;cursor:pointer;transition:background .15s ease}
.gen-starters button:hover{background:var(--create-pill-hover)}
#legacyStudio .upcoming-generator{margin:auto;max-width:420px;text-align:center}
#legacyStudio .upcoming-generator h2{font-size:22px;margin:0 0 6px}

/* Chat box */
.create-dock{display:grid;gap:6px}
.create-dock .validation:empty{display:none}
.create-dock .validation{margin:0 8px;font-size:12px;white-space:pre-line}
.create-composer{display:flex;flex-direction:column;gap:4px;padding:10px 10px 8px;border:1px solid color-mix(in srgb,var(--line) 70%,transparent);border-radius:24px;background:var(--panel);box-shadow:0 8px 28px #00000014,0 1px 2px #0000000f;transition:border-color .15s ease,box-shadow .15s ease}
@supports (backdrop-filter:blur(1px)){.create-composer{background:var(--create-surface);backdrop-filter:blur(18px) saturate(1.2)}}
.create-composer:focus-within{border-color:color-mix(in srgb,var(--text) 22%,transparent)}
.create-composer.is-dropping{border-color:var(--focus,#0a84ff);box-shadow:0 0 0 3px color-mix(in srgb,var(--focus,#0a84ff) 25%,transparent)}
.create-composer .prompt-wrap,:root[data-theme="light"] #legacyStudio .create-composer .prompt-wrap{border:0;border-radius:0;background:transparent;overflow:visible}
#legacyStudio .create-composer textarea#prompt{display:block;width:100%;height:auto;min-height:44px;max-height:240px;field-sizing:content;resize:none;overflow-y:auto;border:0;border-radius:0;padding:6px 8px;background:transparent;color:var(--text);font:inherit;font-size:15px;line-height:1.5;outline:none;box-shadow:none}
#legacyStudio .create-composer textarea#prompt::placeholder{color:var(--muted)}
/* Attached references: compact thumbnails with preview, @tag and remove. */
#legacyStudio .create-refs{display:flex;flex-wrap:wrap;gap:8px;padding:2px 4px 4px}
#legacyStudio .create-refs:empty{display:none}
#legacyStudio #references .ref-card,:root[data-theme="light"] #legacyStudio #references .ref-card{flex:0 0 64px;width:64px;height:64px;border:0;border-radius:14px;background:var(--create-pill);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--text) 8%,transparent);animation:ref-in .2s ease both}
@keyframes ref-in{from{opacity:0;transform:scale(.94)}}
#legacyStudio #references .ref-preview{background:var(--create-pill)}
#legacyStudio #references .media-symbol{font-size:22px}
#legacyStudio #references .ref-tag{left:4px;bottom:4px;max-width:calc(100% - 8px);padding:2px 5px;border-radius:6px;font-size:10px;font-weight:600}
#legacyStudio #references .ref-remove{right:4px;top:4px;width:20px;height:20px;border:0;border-radius:50%;font-size:14px;opacity:0;transition:opacity .15s ease}
#legacyStudio #references .ref-card:hover .ref-remove,#legacyStudio #references .ref-card:focus-within .ref-remove{opacity:1}
@media (hover:none){#legacyStudio #references .ref-remove{opacity:1}}

/* Toolbar */
.create-tools{display:flex;align-items:center;gap:6px;flex-wrap:nowrap;min-width:0}
.create-tools-spacer{flex:1;min-width:4px}
.create-pill{position:relative;margin:0;font-size:13px;color:var(--text)}
.create-pill>summary,.create-cost .rate-details>summary{display:inline-flex;align-items:center;gap:6px;min-height:34px;padding:4px 12px;border:0;border-radius:999px;background:var(--create-pill);color:var(--text);font-size:13px;list-style:none;cursor:pointer;white-space:nowrap;transition:background .15s ease}
.create-pill>summary::-webkit-details-marker,.create-cost .rate-details>summary::-webkit-details-marker,.create-menu-disclosure>summary::-webkit-details-marker{display:none}
.create-pill>summary::after,.create-cost .rate-details>summary::after{content:none}
.create-pill>summary:hover,.create-pill[open]>summary{background:var(--create-pill-hover)}
.create-pill>summary span{margin:0;color:inherit;font-size:inherit;overflow:hidden;text-overflow:ellipsis;max-width:160px}
.create-attach>summary{width:34px;padding:0;justify-content:center}
.create-pill>summary svg:last-child:not(:first-child){width:14px;height:14px;opacity:.6}
.create-pill .create-menu{position:absolute;z-index:40;bottom:calc(100% + 10px);left:0;display:grid;gap:6px;width:300px;max-height:min(60vh,480px);overflow:auto;padding:10px;border:1px solid var(--popover-line);border-radius:18px;background:var(--popover-bg);box-shadow:var(--popover-shadow);transform-origin:bottom left;animation:create-menu-up .18s ease both}
.create-pill .create-menu-narrow{width:180px}
.create-menu-right{left:auto!important;right:0;transform-origin:bottom right!important}
.create-menu-down{bottom:auto!important;top:calc(100% + 8px);transform-origin:top right!important;animation-name:create-menu-down!important}
@keyframes create-menu-up{from{opacity:0;transform:scale(.97) translateY(4px)}}
@keyframes create-menu-down{from{opacity:0;transform:scale(.97) translateY(-4px)}}
.create-menu-item,#legacyStudio .create-menu label.create-menu-item{display:flex;align-items:center;justify-content:space-between;gap:10px;width:100%;min-height:38px;margin:0;padding:8px 10px;border:0;border-radius:10px;background:transparent;color:var(--text);font:inherit;font-size:14px;text-align:left;cursor:pointer}
.create-menu-item:hover,.create-menu-item:focus-visible{background:var(--create-pill)}
.create-menu-item>span{display:grid;gap:2px}
.create-menu-item small{display:block;font-size:12px;color:var(--muted);font-weight:400}
.create-menu-item kbd{font:inherit;font-size:12px;padding:1px 7px;border-radius:6px;background:var(--create-pill);color:var(--muted)}
#legacyStudio .create-menu .dropzone{border:0;margin:0;background:transparent}
#legacyStudio .create-menu .dropzone.busy{opacity:.6}
.create-menu .generator-modes{display:grid;gap:2px;margin:0;padding:0;border:0;background:none}
.create-menu .generator-modes button{min-height:36px;padding:6px 10px;border:0;border-radius:10px;background:transparent;color:var(--text);font-size:14px;text-align:left}
.create-menu .generator-modes button:hover{background:var(--create-pill)}
.create-menu .generator-modes button[aria-pressed="true"]{background:var(--create-pill);font-weight:600}
.create-menu select,.create-menu input[type=number]{width:100%}
.create-menu .field-label{margin:4px 0 0;font-size:12px;color:var(--muted);text-transform:none;letter-spacing:0}
.create-menu .control-help,.create-menu small{font-size:12px;color:var(--muted);line-height:1.4;margin:0}
.create-menu .field-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.create-menu .audio-row{padding:10px 0 2px;border:0;margin:0}
.create-director{display:grid;gap:6px;padding:4px 4px 10px;margin-bottom:4px;border-bottom:1px solid var(--line)}
.create-menu-disclosure{margin:0;padding:6px 10px;font-size:13px;color:var(--muted)}
.create-menu-disclosure summary{cursor:pointer;list-style:none}
.create-menu-note{margin:2px 10px 4px;font-size:12px;color:var(--muted)}
.create-count{font-size:11px;color:var(--muted);white-space:nowrap}
.create-cost{display:flex;align-items:center;gap:6px;margin:0;padding:0;border:0;background:none;white-space:nowrap}
.create-live-cost{display:inline-flex;align-items:baseline;gap:6px}
.create-cost #costUSD{font-weight:600;font-size:13px;color:var(--text)}
.create-cost #costCredits{font-size:12px;color:var(--muted)}
.create-demo-chip{display:none;padding:3px 10px;border-radius:999px;background:var(--create-pill);font-size:12px;color:var(--muted)}
#legacyStudio[data-mode="demo"] .create-demo-chip{display:inline-block}
#legacyStudio[data-mode="demo"] .create-live-cost,#legacyStudio[data-mode="demo"] .create-cost .rate-details{display:none}
.create-cost .rate-details{position:relative;margin:0}
.create-cost .rate-details>summary{width:22px;min-height:22px;padding:0;justify-content:center;font-size:11px;color:var(--muted)}
#legacyStudio .create-make{min-height:36px;padding:6px 18px;border-radius:999px;font-weight:600;justify-content:center}

/* Results drawer */
.create-outputs{position:fixed;z-index:70;top:calc(var(--app-top,90px) + 8px);right:12px;bottom:14px;width:min(360px,calc(100vw - 24px));display:flex;flex-direction:column;gap:12px;padding:14px;overflow-y:auto;border:1px solid var(--popover-line);border-radius:22px;background:var(--popover-bg);box-shadow:var(--popover-shadow);transform:translateX(calc(100% + 24px));visibility:hidden;transition:transform .22s ease,visibility 0s linear .22s}
@supports (backdrop-filter:blur(1px)){.create-outputs{background:color-mix(in srgb,var(--popover-bg) 86%,transparent);backdrop-filter:blur(22px) saturate(1.2)}}
#legacyStudio.show-outputs .create-outputs{transform:none;visibility:visible;transition:transform .22s ease}
.create-outputs .library-heading{display:flex;align-items:center;justify-content:space-between;margin:0}
#legacyStudio .create-outputs .library-heading h2{margin:0;font-family:inherit;font-size:16px;font-weight:600;letter-spacing:0}
.create-icon-button{display:grid;place-items:center;width:32px;height:32px;padding:0;border:0;border-radius:50%;background:var(--create-pill);color:var(--text);cursor:pointer}
.create-icon-button:hover{background:var(--create-pill-hover)}
.create-outputs .library-filter{display:inline-flex;align-self:flex-start;gap:2px;padding:2px;border:0;border-radius:999px;background:var(--create-pill)}
.create-outputs .library-filter button{min-height:28px;padding:2px 12px;border-radius:999px;font-size:12px;color:var(--muted);background:transparent}
.create-outputs .library-filter .selected{background:var(--panel);color:var(--text)}
.create-outputs .jobs{display:grid;grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:8px}
.create-outputs .job-card{cursor:pointer;border:0;border-radius:14px;overflow:hidden;background:var(--create-pill);transition:transform .15s ease}
.create-outputs .job-card:hover{transform:translateY(-1px)}
.create-outputs .job-card .job-content{display:none}
.create-outputs .job-card .job-visual{aspect-ratio:1;border-radius:14px}
.create-outputs .job-card .job-visual img,.create-outputs .job-card .job-visual video{width:100%;height:100%;object-fit:cover}
.create-outputs .job-card .badge{display:none}
.create-results-empty{grid-column:1/-1;margin:8px 2px;font-size:13px;color:var(--muted)}
.create-outputs .upcoming-library{font-size:13px;color:var(--muted)}

/* Audio isn't connected yet: keep the type switch, hide what can't be used. */
#legacyStudio[data-generator-mode="audio"] :is(.create-needs-model,#createThread,.create-refs,.prompt-wrap,.create-attach,.create-count,.create-outputs .library-filter){display:none!important}

/* Narrow: pills turn into icons; Generate stays on the right. */
@media (max-width:640px){
 .create-pill>summary span:not(#createTypeLabel):not(#createModelLabel),.create-top-button>span:not(.create-badge),.create-pill-text{display:none}
 .create-settings>summary,.create-assist>summary{width:34px;padding:0;justify-content:center}
 .create-model>summary span{max-width:72px}
 .create-type>summary svg,.create-model>summary svg{display:none}
 .create-tools{gap:4px}
 #legacyStudio .create-make{padding:6px 14px}
 .create-demo-chip{display:none!important}
 .create-pill .create-menu{width:min(300px,calc(100vw - 40px))}
 .create-model .create-menu,.create-settings .create-menu,.create-assist .create-menu{left:auto;right:-120px}
 .gen-prompt{max-width:88%}
}
@media (max-width:760px){main>#legacyStudio.create:not([hidden]){padding-bottom:96px}}
@media (prefers-reduced-motion:reduce){.create-pill .create-menu,.create-outputs,#legacyStudio #references .ref-card,.gen-item,.gen-state.busy{animation:none!important;transition:none!important}}
/* Smaller results in the thread (aspect kept), so more of the conversation fits. */
.gen-result{width:auto;max-width:min(100%,440px)}
.gen-visual{width:fit-content;max-width:100%}
.gen-visual img,.gen-visual video{width:auto;max-width:100%;max-height:360px;cursor:zoom-in}
.gen-visual video{cursor:auto}
.create-thread{gap:22px}
/* Prompt assist: toggle in the Assist menu, and its card just above the chat box. */
.create-assist-toggle{display:flex;align-items:flex-start;gap:10px;padding:6px 6px 10px;border-bottom:1px solid var(--line);cursor:pointer}
.create-assist-toggle input{flex:none;margin-top:3px}
.create-assist-toggle span{display:grid;gap:3px}
.create-assist-toggle strong{font-size:14px;font-weight:600}
.create-assist-style{display:grid;gap:4px;padding:2px 4px}
.create-assist>summary.is-on{background:color-mix(in srgb,var(--focus,#0a84ff) 16%,var(--create-pill));color:var(--text)}
.create-assist-card{display:grid;gap:10px;padding:12px 14px;border:1px solid var(--line);border-radius:18px;background:var(--panel);animation:create-menu-up .2s ease both}
.create-assist-card[hidden]{display:none}
.assist-card-head{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 10px}
.assist-card-head strong{font-size:14px}
.assist-card-head span{font-size:12.5px;color:var(--muted)}
.assist-q{margin:0;padding:0;border:0;display:grid;gap:6px}
.assist-q legend{padding:0;margin-bottom:6px;font-size:13px;font-weight:500}
.assist-q-options{display:flex;flex-wrap:wrap;gap:6px;align-items:center}
.assist-q-option{min-height:30px;padding:4px 12px;border:1px solid var(--line);border-radius:999px;background:transparent;color:var(--text);font:inherit;font-size:13px;cursor:pointer}
.assist-q-option[aria-pressed="true"]{background:var(--text);color:var(--panel);border-color:var(--text)}
.assist-q-options input{flex:1;min-width:140px;min-height:30px;padding:4px 10px;border:1px solid var(--line);border-radius:999px;background:transparent;color:var(--text);font:inherit;font-size:13px}
.assist-prompt{margin:0;padding:10px 12px;border-radius:12px;background:var(--create-pill);font-size:14px;line-height:1.5;white-space:pre-wrap;max-height:160px;overflow:auto}
.assist-card-actions{display:flex;flex-wrap:wrap;align-items:center;gap:8px}
.assist-card-actions .primary{min-height:34px;padding:6px 16px;border-radius:999px}
@media (prefers-reduced-motion:reduce){.create-assist-card{animation:none}}

/* ---- Result viewer: the take floats on a dark backdrop (no card, no title); its prompt and actions sit in a bar
   underneath, like ChatGPT's image view. Dark in both themes so the picture reads true. */
.result-viewer{width:100vw;height:100vh;max-width:none;max-height:none;margin:0;padding:0;border:0;background:transparent;color:#f2f2f2;overflow:hidden}
.result-viewer[open]{display:grid;grid-template-rows:auto minmax(0,1fr) auto;animation:rv-in .18s ease}
.result-viewer::backdrop{background:rgba(8,8,10,.88);backdrop-filter:blur(10px)}
@keyframes rv-in{from{opacity:0;transform:scale(.985)}to{opacity:1;transform:none}}
.rv-top{display:flex;justify-content:flex-end;gap:8px;padding:16px 18px 0}
.rv-icon{display:grid;place-items:center;width:38px;height:38px;padding:0;border:0;border-radius:50%;background:rgba(255,255,255,.1);color:#f2f2f2;cursor:pointer;transition:background .15s ease}
.rv-icon:hover{background:rgba(255,255,255,.2)}
.rv-icon svg,.rv-actions svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.rv-stage{display:grid;place-items:center;min-height:0;padding:8px 24px}
.rv-stage img,.rv-stage video{display:block;max-width:min(100%,1400px);max-height:calc(100vh - 170px);max-height:calc(100dvh - 170px);object-fit:contain;border-radius:14px;box-shadow:0 20px 70px rgba(0,0,0,.55)}
.rv-bar{display:flex;align-items:center;gap:14px;width:min(860px,calc(100vw - 32px));margin:6px auto 22px;padding:8px 8px 8px 16px;border:1px solid rgba(255,255,255,.1);border-radius:16px;background:rgba(32,32,36,.92);box-shadow:0 10px 40px rgba(0,0,0,.45)}
.rv-prompt{flex:1;min-width:0;display:grid;gap:2px}
.rv-text{padding:0;border:0;background:none;color:#f2f2f2;font:inherit;font-size:13.5px;line-height:1.45;text-align:left;cursor:pointer;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
.rv-text[aria-expanded="true"]{white-space:pre-wrap;max-height:7.5em;overflow:auto}
.rv-prompt small{color:rgba(242,242,242,.55);font-size:11.5px}
.rv-actions{display:flex;align-items:center;gap:2px;flex:none}
.rv-actions i{width:1px;height:20px;margin:0 4px;background:rgba(255,255,255,.14)}
.rv-actions button{display:inline-flex;align-items:center;gap:6px;min-height:34px;padding:0 12px;border:0;border-radius:10px;background:none;color:#f2f2f2;font:inherit;font-size:13px;cursor:pointer;transition:background .15s ease}
.rv-actions button:hover:not(:disabled){background:rgba(255,255,255,.1)}
.rv-actions button:disabled{opacity:.4;cursor:default}
.rv-actions .rv-icon-btn{padding:0 9px}
.result-viewer :focus-visible{outline:2px solid #fff;outline-offset:2px}
@media (max-width:700px){.rv-stage img,.rv-stage video{max-height:calc(100dvh - 230px)}.rv-bar{flex-wrap:wrap;padding:10px 12px}.rv-actions{width:100%;justify-content:flex-end}.rv-stage{padding:8px 12px}}
@media (prefers-reduced-motion:reduce){.result-viewer[open]{animation:none}.rv-icon,.rv-actions button{transition:none}}
