*{box-sizing:border-box}body{margin:0;background:#11141a;color:#e9edf5;font:14px system-ui}header{height:58px;padding:16px 28px;border-bottom:1px solid #303642;display:flex;justify-content:space-between;font-size:20px}header span{font-size:13px;color:#aebbd0}.editor{padding:18px 24px}.panels{display:flex;gap:18px;min-height:55vh}.panel{flex:1;background:#0b0e13;border:1px solid #303846;border-radius:8px;padding:10px;text-align:center;overflow:hidden}.panel h3{margin:0 0 8px;font-size:14px;color:#b9c3d4}.panel canvas{max-width:100%;max-height:52vh;background:#202631;cursor:crosshair}.filebar{padding:10px 0;color:#aebbd0}.controls{display:flex;align-items:end;gap:10px;flex-wrap:wrap;border-top:1px solid #303642;padding-top:14px}.controls label{display:flex;flex-direction:column;gap:5px;color:#b9c3d4}.controls textarea{width:220px;height:52px}.controls input,.controls select,.controls textarea,.controls button{padding:8px;border:1px solid #3d4655;border-radius:6px;background:#272e3a;color:#fff}.controls button{min-width:110px;background:#3867d6;font-weight:600;cursor:pointer}.controls button:last-of-type{background:#22a06b}.controls button:disabled{opacity:.5}#status{width:100%;max-height:90px;overflow:auto;color:#9eb7ff;font-size:12px}.modal{position:fixed;inset:0;background:#0009;display:flex;align-items:center;justify-content:center;z-index:5}.hidden{display:none}.dialog{width:min(500px,90vw);padding:26px;border:1px solid #52617a;border-radius:12px;background:#202631;box-shadow:0 20px 80px #000b}.dialog h2{margin-top:0}.progressTrack{height:9px;background:#394354;border-radius:8px;overflow:hidden;margin:16px 0}.progressTrack div{height:100%;width:5%;background:#43a7ff;transition:width .3s}.dialog ol{padding-left:22px;color:#b9c3d4}.dialog li.active{color:#fff;font-weight:600}.dialog li.done{color:#54d38b}

.panels{align-items:flex-start;overflow-x:auto;min-height:0;padding-bottom:12px}
.panel{flex:0 0 auto;width:calc(50% - 9px);min-width:280px;height:58vh;min-height:240px;resize:both;overflow:auto;display:flex;flex-direction:column}
.panel h3{flex:none;text-align:left}.panel small{display:block;font-size:11px;font-weight:400;color:#8491a5;margin-top:4px}
#inputViewport{flex:1;min-height:0;display:flex;align-items:center;justify-content:center;overflow:hidden}
#inputCanvas{max-height:100%;touch-action:none}
#results{display:flex;gap:16px;flex:1;min-height:0;overflow-x:auto;overflow-y:hidden;align-items:stretch;text-align:left;padding-bottom:12px;scrollbar-color:#6682a6 #202631;scrollbar-width:auto}
.result-card{margin:0;flex:0 0 auto;display:flex;flex-direction:column;min-width:180px}
.result-card img{display:block;height:calc(100% - 60px);width:auto;max-width:none;object-fit:contain}
.result-card figcaption{font-size:12px;white-space:pre-line;color:#bbcada;padding-top:8px}
#brushDiameter{float:right;margin-left:22px;color:#70c5ff;font-variant-numeric:tabular-nums}
#elapsedTimer{font-size:clamp(48px,8vw,80px);font-weight:800;font-variant-numeric:tabular-nums;text-align:center;letter-spacing:-2px;color:#81d1ff;line-height:1.2;margin-bottom:20px}
#closeProgress{padding:10px 24px;background:#3867d6;color:white;border:0;border-radius:6px;cursor:pointer}
#closeProgress:disabled{opacity:.4;cursor:wait}.dialog{width:min(620px,94vw)}
@media(max-width:700px){.editor{padding:12px}.panels{flex-direction:column}.panel{width:100%;max-width:100%}header{height:auto;gap:12px;flex-wrap:wrap}}
#elapsedTimer{font-family:Consolas,'Courier New',monospace;font-variant-numeric:tabular-nums;letter-spacing:0}
#results::-webkit-scrollbar{height:var(--results-scrollbar-size,16px)}
#results::-webkit-scrollbar-track{background:#202631;border-radius:8px}
#results::-webkit-scrollbar-thumb{background:#6682a6;border-radius:8px;border:2px solid #202631}
.mask-tools{display:flex;flex-wrap:wrap;gap:6px;margin:4px 0 10px;flex:none}
.mask-tools button{background:#272e3a;color:#e9edf5;border:1px solid #52617a;border-radius:5px;padding:6px 10px;cursor:pointer}
.mask-tools button[aria-pressed=true]{background:#3867d6}.mask-tools button:disabled{opacity:.4;cursor:default}
.editor{padding-top:68px}.panels{display:flex;flex-direction:row;gap:0;align-items:stretch;overflow:visible;height:62vh;min-height:400px;--input-share:50%}
.panel{width:auto;max-width:none;min-width:0;height:100%;min-height:0;resize:none;overflow:hidden}
#inputPanel{position:relative;overflow:visible}
#inputPanel .mask-tools{position:absolute;z-index:3;left:0;top:-48px;margin:0}
#inputPanel .mask-tools button{min-width:42px}
#inputPanel .mask-tools button:last-child{margin-left:2px}
#inputPanel #inputViewport{height:100%;position:relative}
body:not(.has-image) #inputCanvas{display:none}
body:not(.has-image) #inputPanel #inputViewport{min-height:0}
body:not(.has-image) .input-upload{position:absolute;z-index:2;left:50%;top:50%;transform:translate(-50%,-65%);width:90%;margin:0}
body:not(.has-image) #info{position:absolute;z-index:2;left:50%;top:calc(50% + 38px);transform:translateX(-50%);width:90%;margin:0;text-align:center}
.input-upload{position:absolute;left:0;right:0;top:84px;z-index:2}
#info{position:absolute;left:12px;right:12px;top:128px;z-index:2}
body.has-image .input-upload,body.has-image #info{display:none}
#inputPanel{flex:0 0 calc(var(--input-share) - 7px)}
#resultPanel{flex:1 1 0;min-width:0}
#panelDivider{flex:0 0 14px;position:relative;cursor:col-resize;touch-action:none;user-select:none;outline:none}
#panelDivider:after{content:'';position:absolute;top:0;bottom:0;left:5px;width:4px;border-radius:4px;background:#46566d;transition:background .15s}
#panelDivider:hover:after,#panelDivider:focus-visible:after{background:#81d1ff}
.input-upload{display:flex;flex-wrap:wrap;gap:6px;align-items:center;flex:none;text-align:left;padding:4px 0;color:#aebbd0;font-size:12px}
.input-upload input{width:100%;max-width:100%;min-width:0;font-size:12px}
#info{flex:none;text-align:left;font-size:12px;color:#aebbd0;overflow-wrap:anywhere;padding:6px 0 10px}
.mask-tools button{display:inline-flex;align-items:center;justify-content:center;min-height:34px}
.mask-tools svg{pointer-events:none;flex:none}
/* APGQ Upscale visual language: violet/blue hero, pale cards, rounded controls. */
body{background:#fff;color:#2d3436}
body>header{height:auto;min-height:48px;background:#f8f9fa;border-color:#dfe6e9;align-items:center;gap:12px;flex-wrap:wrap}
header span{color:#636e72}
.tool-hero{text-align:center;padding:30px 24px;background:linear-gradient(135deg,#6a11cb,#2575fc);color:white;border-radius:0 0 25px 25px;max-height:220px;overflow:hidden;opacity:1;transition:max-height .7s,padding .7s,opacity .5s}
.tool-hero h1{font-size:clamp(28px,4vw,46px);margin:0 0 12px;line-height:1.2}.tool-hero p{font-size:18px;opacity:.9;margin:0}
.tool-hero.collapsed{max-height:0;padding-top:0;padding-bottom:0;opacity:0}
.tool-summary{margin:0;padding:0 24px;max-height:0;opacity:0;overflow:hidden;text-align:center;color:#636e72;transition:opacity .5s,max-height .5s,padding .5s}
.tool-summary.visible{max-height:120px;opacity:1;padding:18px 24px}
.panel{background:#f8f9fa;border:1px solid #dfe6e9;border-radius:15px;box-shadow:0 5px 15px #0000000d}
.panel h3{color:#2d3436}.panel small,.input-upload,#info{color:#636e72}
#inputViewport,#results{background:#edf1f7;border-radius:8px}
.controls{background:#f8f9fa;padding:22px;border:1px solid #e3e9f0;border-radius:15px;box-shadow:0 5px 15px #0000000d}
.controls label{color:#2d3436}.controls input,.controls select,.controls textarea{background:#fff;border-color:#dfe6e9;color:#2d3436}
.controls button,.controls button:last-of-type{background:linear-gradient(135deg,#6a11cb,#2575fc);color:white;border:0;box-shadow:0 4px 10px #6a11cb33}
#process small{display:block;font-size:10px;margin-top:4px;opacity:.85}
#process{margin-right:0;flex:0 0 auto}
.seed-controls{display:flex;align-items:center;gap:8px}
.seed-controls input[type=range]{width:150px;min-width:100px}
.seed-controls input[type=number]{width:115px;min-width:0;font-variant-numeric:tabular-nums}
.mask-tools button{background:white;color:#636e72;border-color:#dfe6e9}.mask-tools button[aria-pressed=true]{background:linear-gradient(135deg,#6a11cb,#2575fc);color:white}
#brushDiameter{color:#673ab7}#status{color:#374e79}
.dialog{background:#fff;color:#2d3436;border-color:#dfe6e9;max-height:92vh;overflow:auto}
#elapsedTimer{color:#673ab7;margin-bottom:14px}.dialog ol{color:#636e72;max-height:140px;overflow:auto}
.progressTrack{background:#e5eaf3}.progressTrack div{background:linear-gradient(135deg,#6a11cb,#2575fc)}
.processing-ad{text-align:center;border:1px solid #e1e6ee;background:#f8f9fa;border-radius:12px;padding:10px;margin:0 0 18px}
.processing-ad>span{display:block;font-size:11px;color:#636e72;margin-bottom:6px}.processing-ad a{display:block}
.processing-ad img{display:block;width:100%;max-height:220px;object-fit:contain;border-radius:8px}
.result-card{width:340px;max-width:none}.result-image-frame{position:relative;flex:1;min-height:0;width:100%}
.result-image-frame img{display:block;width:100%;height:100%;object-fit:contain}
.reuse-result{position:absolute;bottom:10px;left:10px;background:#fff;color:#5628ab;border:1px solid #cabde9;border-radius:7px;padding:8px 14px;cursor:pointer;font-weight:600;box-shadow:0 2px 10px #0003}
.reuse-result:hover{background:#6a11cb;color:#fff}.result-card figcaption{color:#546277;min-height:60px}
.controls output{display:block;color:#673ab7;font-variant-numeric:tabular-nums;font-weight:600}.controls input[type=range]{accent-color:#6a11cb;min-width:130px}
.input-upload{justify-content:center;text-align:center;flex-direction:column}.input-upload input{width:auto;max-width:100%}body.has-image .input-upload,body.has-image #info{display:none}
.remove-result{position:absolute;top:10px;right:10px;width:30px;height:30px;border-radius:50%;border:1px solid #d7c8ec;background:#fff;color:#673ab7;font-size:23px;line-height:20px;cursor:pointer;box-shadow:0 2px 8px #0003}.remove-result:hover{background:#d9304f;color:#fff}
@media(prefers-reduced-motion:reduce){.tool-hero,.tool-summary{transition:none}}
.editor{padding-top:18px}
.editor>.mask-tools{position:static;align-items:center;flex-wrap:nowrap;overflow-x:auto;margin:0 0 12px;gap:6px}
.editor>.mask-tools button{flex:none;min-height:34px;white-space:nowrap}
.brush-tools-control{display:flex;flex-direction:column;gap:3px;flex:0 0 180px;margin-left:12px;color:#2d3436}
.brush-tools-control input{width:100%;margin:0;accent-color:#6a11cb}
.controls{display:grid;grid-template-columns:minmax(125px,.85fr) minmax(145px,1.3fr) minmax(145px,1.3fr) minmax(115px,1fr) minmax(115px,1fr) minmax(145px,1fr) 110px;align-items:end;gap:12px;overflow-x:auto}
.controls label{min-width:0}
.controls textarea,.controls select,.controls input[type=range]{width:100%;min-width:0}
.controls .seed-controls{display:flex;justify-content:space-between;align-items:center;gap:6px;min-height:32px}
.controls .seed-controls input[type=number]{width:100px;min-width:0;padding:5px 6px}
.controls #status{grid-column:1 / -1;min-width:0}
.shape-options{grid-column:1 / -1;border:1px solid #dfe6e9;border-radius:10px;padding:12px;background:#fff}
.shape-options[hidden]{display:none}
.controls .shape-options label{display:flex;flex-direction:row;align-items:center;gap:12px}
.controls .shape-options input[type=range]{display:block;width:280px;max-width:100%;margin:8px 0}
.shape-options p{margin:4px 0;color:#636e72;font-size:12px}
[hidden],.controls label[hidden],.editor>.mask-tools[hidden]{display:none!important}
.controls.dedicated-controls{grid-template-columns:minmax(145px,1.3fr) minmax(145px,1.3fr) minmax(115px,1fr) minmax(115px,1fr) minmax(145px,1fr) 110px}
.controls.removal-controls{grid-template-columns:repeat(3,minmax(145px,1fr)) 110px}
.reference-panel{margin:16px 0;padding:16px;border:1px solid #dfe6e9;border-radius:12px;background:#f8f9fa}
.reference-panel h3{margin:0 0 8px}.reference-panel p{color:#636e72;font-size:13px}
.reference-panel img{display:block;max-width:100%;max-height:220px;margin:12px 0;object-fit:contain}
.reference-panel button{padding:8px 12px;margin:8px;border:1px solid #dfe6e9;border-radius:6px;background:#fff;color:#5628ab;cursor:pointer}
.reference-panel button:disabled{opacity:.5}
.controlnet-options fieldset{border:0;padding:0;margin:0;opacity:.65}
.controls .controlnet-options label{display:flex;flex-direction:row;align-items:center;gap:10px;margin:10px 0;flex-wrap:wrap}
.controlnet-types{display:flex;gap:16px;flex-wrap:wrap}
.controlnet-options input[type=checkbox],.controlnet-options input[type=radio]{width:auto;min-width:0}
