:root{color-scheme:dark;font:14px/1.45 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:#eef5fb;background:#0e202b;--border:#32677f;--muted:#bed9e5;--panel:#1c3545;--focus:#42d3f5}
*{box-sizing:border-box}
[hidden]{display:none!important}
body{margin:0;background:radial-gradient(ellipse at 53% 5%,#245a72 0,transparent 56%),radial-gradient(ellipse at 65% 100%,#1f4c65 0,transparent 60%),#0e202b;min-height:100dvh}
header{height:104px;padding:8px 26px;display:flex;align-items:center;justify-content:space-between;gap:20px}
h1{margin:0;font-size:22px}.brand{min-width:0}.brand h1{line-height:0}.brand-logo{display:block;width:200px;max-width:100%;height:auto}
main{display:grid;grid-template-columns: minmax(300px,340px) minmax(0,1fr);height:calc(100dvh - 104px);gap:18px;padding:0 24px 16px 18px}
aside{min-width:0;overflow-x:hidden;overflow-y:auto;overscroll-behavior-x:none;touch-action:pan-y pinch-zoom;scrollbar-gutter:stable;scrollbar-width:thin;scrollbar-color:#3d7f99 transparent;padding-right:2px}
details{background:linear-gradient(130deg,#244554db,#193441df);border:1px solid var(--border);border-radius:13px;margin:0 0 13px;padding:14px;box-shadow:inset 0 1px 0 #65d7f51a,0 5px 15px #060e141c}
summary{font-weight:650;cursor:pointer;line-height:1.5}details[open]>summary{margin-bottom:10px}
.row{display:grid;grid-template-columns:minmax(0,35fr) minmax(0,65fr);align-items:center;gap:10px;margin:12px 0}
input:not([type=checkbox]),select,textarea{font:inherit;width:100%;min-width:0;border:1px solid #94d6ea;border-radius:7px;background:linear-gradient(140deg,#e0f7fc,#b5e4f2);color:#102738;padding:7px 9px;box-shadow:inset 0 1px 1px #ffffffa8,0 2px 3px #07121a20}
#inputs input:not([type=checkbox]):not([type=file]),#inputs select,#inputs textarea{text-align:center}
#inputs select{text-align-last:center}select{color-scheme:light;cursor:pointer}select option,select optgroup{background:#d9f1f8;color:#102738}
#inputs .compact-input{width:6.4rem;max-width:100%;justify-self:end}
textarea{resize:vertical;min-height:72px}input[type=checkbox]{accent-color:#28bfe8}
button,a.file,.file,#download{font:inherit;font-weight:550;border:1px solid #40849e;border-radius:10px;background:linear-gradient(160deg,#326177,#1e4257);color:#f4f8fc;padding:8px 13px;cursor:pointer;text-decoration:none;box-shadow:inset 0 1px 2px #8de6ff30,0 3px 8px #07121b24;transition:background .15s,border-color .15s}
button:hover,.file:hover,#download:hover{background:linear-gradient(160deg,#3c7890,#285a72);border-color:#60c8e6}
button:disabled{opacity:.45;cursor:default}
button.primary{background:linear-gradient(155deg,#b9effb,#4fc6e9);border-color:#7edbf1;color:#102331;box-shadow:inset 0 1px 3px #ffffff80,0 4px 14px #07121b40}
button.primary:hover{background:linear-gradient(155deg,#d6f7ff,#7edcf3)}
#connection,#connect,#forget,.render-actions button,#download{border-radius:999px;padding:10px 24px;min-height:44px}
.actions{display:flex;flex-wrap:wrap;gap:10px;margin:12px 0}aside>.actions:first-child{margin-top:0}
.workspace{min-width:0;min-height:0;overflow:auto;display:flex;flex-direction:column;scrollbar-width:thin}
.artboard{flex:1;min-height:320px;display:flex;flex-direction:column;padding:16px 24px 22px;background:linear-gradient(130deg,#244554c9,#193442db);border:1px solid #3c839d;border-radius:24px;box-shadow:inset 0 1px 0 #81def52b,0 12px 30px #07121b28}
#status{font-size:17px;font-weight:600;overflow-wrap:anywhere;line-height:1.5;margin-bottom:14px}
.canvas{flex:1;min-height:0;display:flex;align-items:center;justify-content:center;padding:4px 3%}
#result{display:block;max-width:100%;max-height:calc(100dvh - 240px);height:auto;width:auto;object-fit:contain;background:white;border-radius:19px;box-shadow:0 2px 10px #0003}
.render-actions{flex-shrink:0;margin:14px 8px 0;gap:14px}.render-actions button,#download{min-width:140px}#generate{min-width:170px}
#gallery{display:flex;gap:12px;flex-wrap:wrap;margin-top:14px}#gallery:empty{display:none}#gallery img{display:block;width:100%;height:100px;object-fit:contain;background:white;border-radius:5px}
#dirty{color:#ffd092;font-size:13px}#dirty:empty{display:none}p{line-height:1.45}small{display:block;font-size:12px;color:var(--muted)}
.file input{display:block;font-size:12px;margin-top:8px}
.inspiration-preview{display:block;width:100%;max-height:210px;object-fit:contain;margin-top:12px;border:1px solid #40849e;border-radius:10px;background:#10212e;box-shadow:inset 0 1px 2px #0004}
.inspiration-filename{overflow-wrap:anywhere;margin:7px 0;color:var(--muted);font-size:12px}
dialog{width:min(580px,calc(100vw - 28px));max-height:90dvh;overflow:auto;border:1px solid #4c9ab5;border-radius:22px;padding:26px;background:linear-gradient(145deg,#234b60,#122d3b);color:#eef5fb;box-shadow:0 24px 80px #0008}
dialog::backdrop{background:#07111bd1;backdrop-filter:blur(4px)}dialog label{display:block;margin:15px 0}dialog h2{margin-top:0}.rendering-disclosure{margin-top:22px}
.spinner{display:inline-block;width:30px;height:30px;border:3px solid #376f86;border-top-color:#54d6f5;border-radius:50%;animation:spin 1s linear infinite}#progress{text-align:center;padding:16px}
:where(button,a,input,select,textarea,summary):focus-visible{outline:2px solid var(--focus);outline-offset:3px}
@keyframes spin{to{transform:rotate(360deg)}}
@media(min-width:1700px){main{grid-template-columns:360px minmax(0,1fr)}}
@media(max-width:900px){main{grid-template-columns:300px minmax(0,1fr);gap:12px;padding-right:14px}.artboard{padding:14px;border-radius:18px}.canvas{padding:0}.render-actions{gap:8px;margin-left:0}.render-actions button,#download{min-width:0;padding:10px 16px}}
@media(max-width:700px){header{height:auto;min-height:76px;padding:10px 16px;flex-wrap:wrap;gap:10px}.brand-logo{width:195px}#connection{padding:9px 15px}main{display:flex;flex-direction:column;height:auto;padding:0 12px 18px;gap:14px}aside{overflow-x:clip;overflow-y:visible;padding:0;scrollbar-gutter:auto}.workspace{overflow:visible}.artboard{min-height:300px}.canvas{min-height:200px}#result{max-height:none;border-radius:12px}.render-actions{margin-top:12px}.render-actions button,#download{flex:1}input:not([type=checkbox]),select,button,.file,#download{min-height:44px}summary{min-height:30px}}
@media(prefers-reduced-motion:reduce){.spinner{animation:none}button,a{transition:none}}

/* Align the account controls with the white wordmark, below the mannequin. */
.header-account{padding-top:13px;max-width:650px;min-width:0}
.login-fields{display:flex;align-items:center;justify-content:flex-end;gap:10px}
.login-fields input{width:160px}
.login-meta{display:flex;justify-content:flex-end;align-items:center;gap:14px;font-size:12px;min-height:22px;color:var(--muted)}
.login-meta label{white-space:nowrap}.login-meta span{overflow-wrap:anywhere}
.visually-hidden{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
@media(max-width:900px){header{height:auto;min-height:104px;flex-wrap:wrap}main{height:calc(100dvh - 150px)}.header-account{padding-top:0}.login-fields input{width:140px}}
@media(max-width:700px){header{min-height:99px}.header-account{width:100%;max-width:none}.login-fields{flex-wrap:wrap;justify-content:flex-start}.login-fields input{flex:1;width:120px}.login-meta{justify-content:flex-start;flex-wrap:wrap;gap:4px 12px}main{height:auto}}
@media(min-width:701px){body{height:100dvh;display:flex;flex-direction:column}header{flex-shrink:0}main{flex:1;min-height:0;height:auto}}
@media(max-width:700px){.login-fields input{flex:1 1 140px;min-width:120px}}

/* Fixed preview viewport keeps zoomed artwork clipped inside the render window. */
#renderViewport{position:relative;overflow:hidden;min-height:180px;padding:0;isolation:isolate}
#renderViewport:has(#result:not([hidden])){touch-action:none}
#renderViewport.zoomed{cursor:grab}#renderViewport.zoomed:active{cursor:grabbing}
#renderViewport #result{position:absolute;left:50%;top:50%;margin:0;translate:-50% -50%;max-width:none;max-height:none;transform-origin:center;user-select:none;pointer-events:none;border-radius:3px}
.view-controls{display:flex;align-items:center;justify-content:center;gap:10px;flex-wrap:wrap;margin-top:12px;flex-shrink:0}
.view-controls button{min-width:40px;min-height:40px;padding:6px 12px}.view-controls output{min-width:48px;text-align:center;font-variant-numeric:tabular-nums}
.view-controls span{font-size:12px;color:var(--muted)}
@media(max-width:700px){#renderViewport{flex:none;height:55dvh;min-height:260px;max-height:550px}.view-controls span{flex-basis:100%;text-align:center}}

/* Keep long custom descriptions inside the fixed-width input panel. */
aside>*,#inputs, #inputs details{min-width:0;max-width:100%}
#inputs .row>span{min-width:0;overflow-wrap:anywhere}
aside .actions>*{max-width:100%;overflow-wrap:anywhere}

.gallery-card{width:160px;max-width:100%;display:flex;flex-direction:column;gap:6px;flex-shrink:0}
.gallery-open{display:flex;flex-direction:column;gap:8px;padding:8px;text-align:center;width:100%}
.gallery-open span{font-size:12px;overflow-wrap:anywhere}.gallery-card>button:last-child{font-size:12px;padding:5px 10px}

/* Independent right-hand gallery; compact screens use a right-side drawer. */
@media(min-width:1000px){main{grid-template-columns:minmax(280px,340px) minmax(0,1fr) 180px}}
@media(min-width:1700px){main{grid-template-columns:360px minmax(0,1fr) 200px}}
.gallery-panel{min-width:0;min-height:0;display:flex;flex-direction:column;border:1px solid var(--border);border-radius:16px;background:linear-gradient(145deg,#234554,#152e3d);padding:12px;overflow:hidden}
.gallery-heading{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-shrink:0;margin-bottom:10px}
.gallery-heading h2{font-size:16px;margin:0}
#gallery{display:flex;flex:1;min-height:0;flex-direction:column;flex-wrap:nowrap;align-items:stretch;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;touch-action:pan-y pinch-zoom;scrollbar-width:thin;margin:0;padding:3px;gap:14px}
#gallery:empty{display:block}#gallery:empty::after{content:'Saved renders appear here.';font-size:13px;color:var(--muted)}
#gallery .gallery-card{width:100%}
#toggleGallery,#closeGallery{display:none}
@media(max-width:999px){
 .gallery-panel{position:fixed;right:12px;top:112px;bottom:16px;width:min(220px,85vw);z-index:20;box-shadow:0 15px 60px #0009;visibility:hidden;pointer-events:none}
 .gallery-panel.is-open{visibility:visible;pointer-events:auto}
 #toggleGallery,#closeGallery{display:inline-block}#closeGallery{font-size:22px;min-width:40px;min-height:40px;padding:0 8px}
}
@media(max-width:700px){.gallery-panel{top:16px}}

#inputs .input-info{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;min-width:22px;min-height:22px;padding:0;margin-left:6px;border-radius:50%;font:italic 600 14px Georgia,serif;vertical-align:middle;color:#d6f7ff}
#customGuidelines{font-size:13px;color:var(--muted)}

.signed-out{margin:24px;color:var(--muted)}#syncStatus{font-size:12px;color:var(--muted);overflow-wrap:anywhere}

/* Centered account entry screen; the compact studio header returns after sign-in. */
.auth-screen{min-height:100dvh;display:flex;flex-direction:column;justify-content:center;align-items:center;padding:40px 24px 80px;gap:16px;background:radial-gradient(ellipse at 50% 48%,#20566a 0,#12313f 48%,#091b23 100%)}
.auth-logo{width:min(850px,85vw);height:auto;margin-bottom:28px;object-fit:contain}
.auth-screen h1:not(.visually-hidden){font-size:24px;text-align:center}
.auth-screen #loginForm{display:block;width:min(850px,100%)}
.auth-fields{display:flex;align-items:center;gap:16px;flex-wrap:wrap}
.auth-fields input{flex:1 1 240px;min-width:0;width:auto;min-height:52px;text-align:left;padding:12px 18px;font-size:18px;background:linear-gradient(125deg,#dbf3fb,#b7e5f3);border:1px solid #8cd8ec;border-radius:11px;color:#153847}
.auth-fields button{flex:0 0 auto;min-height:52px;border-radius:32px;padding:12px 34px;font-size:18px;font-weight:600}
.auth-meta{display:flex;justify-content:flex-end;margin-top:20px}
.auth-meta label{display:flex;align-items:center;gap:9px;color:var(--muted)}
.auth-meta input{width:18px;height:18px;accent-color:#18c4e4}
.auth-links{display:flex;justify-content:center;gap:22px;flex-wrap:wrap}
.auth-links button,.auth-secondary{background:none;border:0;box-shadow:none;color:#bce8f8;padding:6px 10px;text-decoration:underline;text-underline-offset:4px}
.auth-secondary{font-size:12px;color:var(--muted)}
#authMessage,#authDescription{max-width:660px;text-align:center;margin:0;overflow-wrap:anywhere}
#authMessage:empty{display:none}
.header-account{display:flex;align-items:center;justify-content:flex-end;gap:12px;flex-wrap:wrap}
#connectionStatus{overflow-wrap:anywhere;max-width:380px}
@media(max-width:640px){.auth-screen{padding:28px 20px;gap:18px}.auth-logo{width:100%;margin-bottom:20px}.auth-fields{flex-direction:column;gap:14px}.auth-fields input,.auth-fields button{flex:auto;width:100%}.auth-meta{justify-content:center}.auth-links{gap:8px}.header-account{gap:6px}#connectionStatus{font-size:12px;max-width:180px}}

/* Keep account setup readable and its submit action next to the password flow. */
#authDescription,#authMessage{max-width:62ch;line-height:1.5;text-wrap:pretty;overflow-wrap:anywhere}
#loginForm[data-mode="register"],#loginForm[data-mode="forgot"],#loginForm[data-mode="finish"]{max-width:760px}
#loginForm.password-setup .auth-fields{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr)}
#loginForm.password-setup #username{grid-column:1 / -1}
#loginForm.password-setup #connect{grid-column:1 / -1;justify-self:end}
#loginForm.password-setup input{width:100%}
.auth-fields button{white-space:normal;text-wrap:balance}
@media(max-width:640px){
 #loginForm.password-setup .auth-fields{grid-template-columns:minmax(0,1fr)}
 #loginForm.password-setup #connect{width:auto;max-width:100%;justify-self:end}
}

/* Stacked account fields and comfortably sized mobile artwork actions. */
.auth-screen #loginForm{max-width:520px}
.auth-fields,#loginForm.password-setup .auth-fields{display:grid;grid-template-columns:minmax(0,1fr);gap:16px}
.auth-fields input,.auth-fields button{width:100%;min-width:0;box-sizing:border-box}
#loginForm.password-setup #connect{width:auto;justify-self:end}
.render-actions button,.render-actions a{display:inline-flex;align-items:center;justify-content:center;text-align:center;line-height:1.3}
@media(max-width:700px){
 .render-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
 .render-actions button,.render-actions a{width:100%;min-width:0;min-height:48px;margin:0;padding:12px 14px;box-sizing:border-box;border-radius:24px;white-space:normal}
 .render-actions #generate{grid-column:1 / -1}
}
