:root{font-family:Inter,"Segoe UI",Arial,sans-serif;color:#f8f7fb;background:#09090c;font-size:14px;--pink:#ff365f;--muted:#939199;--line:#2b2930;--panel:#151419;--split:50%;color-scheme:dark}
*{box-sizing:border-box}
body{margin:0}
button,input,select{font:inherit}
button,a{-webkit-tap-highlight-color:transparent}
button{cursor:pointer}
button:disabled{cursor:not-allowed;opacity:.38}
a{color:inherit;text-decoration:none}
button,a,input,select,summary{outline-offset:4px}
button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible,summary:focus-visible{outline:2px solid #ff93ab}
[hidden]{display:none!important}
button{border:0}
button,select{color:inherit}
svg{width:20px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.topbar{height:78px;padding:0 34px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid #1d1b23;gap:20px}
.brand{display:flex;align-items:center;gap:10px;white-space:nowrap}
.brand strong{font-size:21px;letter-spacing:-.5px}
.brand strong>span{font-weight:400;color:#b6b2bb}
.brand-mark{position:relative;font-size:36px;font-weight:800;line-height:1;color:var(--pink);letter-spacing:-5px;width:38px}
.brand-mark>span{position:absolute;right:0;top:-3px;font-size:17px;letter-spacing:0}
.topbar-right{display:flex;align-items:center;gap:25px}
.connection-status{display:flex;align-items:center;gap:7px;color:#a9a6af;font-size:11px;white-space:nowrap}
.connection-status i{height:6px;width:6px;border-radius:50%;background:#8c8497}
.connection-status.ready i{background:#87b993}
.connection-status.error i{background:#ff657f}
.back-link{font-size:11px;color:#c2bec8}
.download-button{background:var(--pink);padding:12px 20px;border-radius:30px;display:flex;align-items:center;justify-content:center;gap:24px;min-width:155px;font-weight:600}
.download-button[aria-disabled=true]{background:#29252c;color:#7b757f;cursor:not-allowed}
.editor-shell{height:calc(100dvh - 78px);min-height:560px;display:grid;grid-template-columns:294px minmax(0,1fr) 186px;gap:22px;padding:22px 30px 18px}
.settings-panel{background:var(--panel);border-radius:17px;display:flex;flex-direction:column;min-height:0;overflow:hidden}
.panel-heading{display:flex;gap:10px;align-items:center;justify-content:space-between;padding:21px 20px 16px}
.eyebrow{font-size:9px;letter-spacing:1.4px;color:#9b959f;font-weight:600}
.panel-heading h1{font-size:14px;margin:7px 0 0;font-weight:600}
.quiet-button{background:transparent;color:#a79fab;font-size:10px;padding:8px 0;white-space:nowrap}
.settings-scroll{overflow-y:auto;min-height:0;flex:1;padding:0 20px;scrollbar-width:thin;scrollbar-color:#49444f transparent}
.setting-section{border-bottom:1px solid var(--line);padding:15px 0 18px}
.setting-section summary{display:flex;align-items:center;gap:11px;cursor:pointer;list-style:none;font-size:12px;font-weight:600}
.setting-section summary::-webkit-details-marker{display:none}
.section-icon{width:32px;height:32px;border-radius:9px;display:grid;place-items:center;font-size:25px;flex-shrink:0;background:#313037;color:#ded8e4}
.background-icon{background:#2e644c;color:#c1f6d7;font-size:23px}
.color-icon{background:#d66d66;color:#fff;font-size:22px}
.face-icon{background:#37313e;color:#ddd1ed}
.beauty-icon{font-size:27px}
.blur-icon{font-size:28px}
.setting-section summary small{display:block;color:#88838d;font-size:10px;line-height:1.5;font-weight:400;margin-top:4px}
.accordion-mark{margin-left:auto;flex:0 0 16px;width:16px;height:16px;color:#aaa6ae;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;transition:transform .15s}
.setting-section[open] .accordion-mark{transform:rotate(180deg)}
.section-body{padding-top:16px}
.segment-options{display:flex;gap:8px}
.segment-options button{background:#302e35;border:1px solid #302e35;min-height:40px;min-width:63px;border-radius:8px;font-size:12px;font-weight:600;padding:9px 12px;transition:background .15s,border-color .15s}
.segment-options button.selected{background:#09090b;border-color:#ece7ef;box-shadow:0 0 0 1px #ece7ef}
.four-options{gap:5px}
.four-options button{min-width:0;flex:1;padding:8px 3px;font-size:9px}
.setting-hint{font-size:10px;color:#89828d;line-height:1.6;margin:12px 0 0}
.palette-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px 7px}
.palette-choice{min-width:0;background:transparent;padding:0;color:#c0b9c7;text-align:center;border-radius:8px;font-size:9px;line-height:1.4}
.palette-swatch{height:58px;display:flex;align-items:center;justify-content:center;position:relative;border-radius:8px;margin-bottom:6px;border:2px solid transparent;background:var(--swatch);overflow:hidden}
.palette-swatch::before{content:"";width:24px;height:32px;border:1px solid #ffffff65;border-radius:45% 45% 40% 40%;transform:rotate(-12deg);background:linear-gradient(130deg,#ffffff38,#ffffff05)}
.palette-choice[data-setting=color] .palette-swatch::before{width:54px;height:32px;border:0;border-radius:40px 0 0 0;transform:rotate(-20deg);background:linear-gradient(160deg,#ffffff40,#00000035);align-self:flex-end}
.palette-choice.selected{color:#fff}
.palette-choice.selected .palette-swatch{border-color:#fff;box-shadow:0 0 0 1px #fff}
.palette-choice.selected .palette-swatch::after{content:"✓";position:absolute;right:3px;top:3px;background:#fff;color:#17131a;width:13px;height:13px;border-radius:50%;display:grid;place-items:center;font-size:9px;font-weight:800}
.palette-choice:not(:disabled):hover .palette-swatch{border-color:#aaa0b0}
.range-label{display:flex;justify-content:space-between;gap:8px;color:#a69dab;font-size:10px;margin:18px 0 8px}
.range-label output{color:#e8dde9}
input[type=range]{accent-color:var(--pink);width:100%;height:13px;margin:0}
.scale-section{padding:17px 0;display:flex;align-items:center;gap:12px;justify-content:space-between;font-size:11px;color:#aaa2b0}
.scale-section .segment-options button{min-width:48px;min-height:34px;padding:7px 10px;font-size:11px}
.local-disclaimer{font-size:10px;color:#756c7c;line-height:1.6;margin:0 0 22px}
.apply-area{padding:14px 20px 15px;background:linear-gradient(#151419e0,#151419);border-top:1px solid #28232d}
.apply-area>p:first-child{min-height:14px;font-size:10px;color:#b5aaba;margin:0 0 10px;line-height:1.5}
.apply-button{display:flex;align-items:center;justify-content:center;gap:15px;border-radius:26px;background:var(--pink);width:100%;padding:13px 20px;font-size:14px;font-weight:650}
.apply-button:not(:disabled):hover,.download-button:not([aria-disabled=true]):hover{background:#ff4c73}
.apply-button:disabled{opacity:1;background:#3b2631;color:#896171}
.apply-help{font-size:9px;line-height:1.5;color:#786e80;text-align:center;margin:9px 0 0}
.workspace{display:flex;flex-direction:column;min-width:0;min-height:0}
.canvas-toolbar{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:1px 0 14px;min-height:46px}
.canvas-toolbar>div:first-child{min-width:0}
.file-name{display:block;font-size:11px;font-weight:500;max-width:300px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.result-status{display:block;font-size:9px;color:#8d8494;margin-top:5px}
.result-status.pending{color:#ff93ac}
.compare-modes{display:flex;flex-shrink:0;gap:2px;border:1px solid #2d2633;border-radius:22px;padding:3px}
.compare-modes button{font-size:10px;background:transparent;color:#8e8297;padding:6px 9px;border-radius:18px}
.compare-modes button.selected{background:#302735;color:#eee5f3}
.image-viewport{flex:1;min-height:0;position:relative;overflow:auto;background:#111014;border-radius:15px;scrollbar-width:thin;scrollbar-color:#4c4354 #151219;overscroll-behavior:contain}
.image-wrapper{min-width:100%;min-height:100%;width:max-content;display:grid;place-items:center;padding:12px}
.image-canvas{position:relative;overflow:hidden;flex-shrink:0;background:#201b24;touch-action:none}
.image-canvas>img,.after-layer>img{display:block;width:100%;height:100%;object-fit:fill;user-select:none}
.after-layer{position:absolute;inset:0;clip-path:inset(0 0 0 var(--split))}
.comparison-overlay{position:absolute;pointer-events:none;z-index:3;overflow:hidden;--split:50%}
.compare-labels{position:absolute;inset:0;pointer-events:none;z-index:2}
.compare-labels span{position:absolute;left:var(--split);top:18px;font-size:16px;font-weight:600;line-height:1.25;white-space:nowrap;border-radius:30px;background:rgba(0,0,0,.5);color:#fff;text-shadow:0 1px 2px rgba(0,0,0,.25);padding:12px 20px}
#beforeLabel{transform:translateX(calc(-100% - 30px))}
#afterLabel{transform:translateX(30px)}
.compare-handle{position:absolute;top:0;bottom:0;left:var(--split);width:40px;transform:translateX(-50%);pointer-events:auto;touch-action:none;cursor:ew-resize;z-index:5}
.compare-handle::before{content:"";position:absolute;top:0;bottom:0;left:50%;width:3px;background:#fff;transform:translateX(-50%);pointer-events:none}
.compare-handle>span{position:absolute;left:50%;top:82%;transform:translate(-50%,-50%);height:40px;width:40px;display:grid;place-items:center;border-radius:50%;background:#fff;color:#19141d;box-shadow:0 2px 8px #0002}
.compare-handle svg{width:23px;height:23px;stroke-width:2.4}
.compare-slider{position:absolute;inset:0;opacity:0;height:100%!important;z-index:4;pointer-events:none;touch-action:none}
.comparison-overlay:has(.compare-slider:focus-visible) .compare-handle>span{outline:3px solid var(--pink);outline-offset:3px}
.empty-state{height:100%;min-height:320px;display:flex;align-items:center;justify-content:center;flex-direction:column;text-align:center;background:radial-gradient(ellipse at 50% 45%,#31202d55,transparent 60%);padding:28px}
.empty-symbol{font-size:46px;color:#f0577c;margin-bottom:29px;line-height:1;filter:drop-shadow(0 0 22px #ff46764d)}
.empty-state .eyebrow{font-size:8px;color:#b690a7}
.empty-state h2{font-size:29px;font-weight:450;letter-spacing:-.9px;margin:12px 0 8px}
.empty-state p{font-size:12px;line-height:1.8;color:#9c8f9f;margin:0 0 27px}
.primary-upload{display:flex;align-items:center;gap:27px;padding:14px 22px;color:#eee2eb;background:#3d2837;border:1px solid #664254;border-radius:27px;font-size:12px;font-weight:600}
.primary-upload:hover{background:#503247}
.primary-upload span{font-size:20px}
.empty-state small{font-size:9px;color:#635768;margin-top:26px}
.view-toolbar{min-height:57px;display:flex;align-items:center;justify-content:space-between;gap:14px;flex-wrap:wrap;padding:12px 0 9px}
.image-size{font-size:10px;color:#887e8e}
.zoom-controls{display:flex;align-items:center;gap:10px}
.zoom-controls button{background:transparent;width:27px;height:29px;color:#d6cbdc;font-size:24px;font-weight:300;padding:0}
.zoom-controls select{background:#16121b;border:1px solid #2d2534;border-radius:6px;color:#d8cede;font-size:11px;padding:6px 7px;min-width:95px;cursor:pointer}
.zoom-controls .fit-button{font-size:21px;margin-left:8px}
.result-footer{flex-shrink:0;font-size:10px;line-height:1.6;color:#8d8196;max-height:150px;overflow:auto;scrollbar-width:thin}
.result-footer>p{margin:0 0 5px}
.result-footer>p.pending{color:#e7a0a6}
.result-footer details{padding:4px 0}
.result-footer summary{cursor:pointer;color:#b6a8c3;font-size:10px}
.result-footer .applied-stage{margin:5px 0;color:#9e91a6}
.result-footer .applied-stage strong{font-weight:500;color:#c6b9cf}
.error-message{padding:12px 14px;border:1px solid #714453;background:#39222c;border-radius:9px;font-size:11px;line-height:1.6;color:#ffd1dc;margin-bottom:10px}
.history-panel{background:#17151b;border-radius:15px;padding:18px 14px;overflow-y:auto;min-height:0;scrollbar-width:thin;scrollbar-color:#44394e transparent}
.history-heading{display:flex;align-items:center;justify-content:space-between;gap:10px}
.history-heading h2{font-size:12px;font-weight:600;margin:0}
.history-heading>span{font-size:10px;color:#92879d;border:1px solid #39313f;padding:2px 6px;border-radius:5px}
.source-card{margin-top:17px}
.source-card img{display:block;width:100%;aspect-ratio:1.35;object-fit:cover;border-radius:9px;border:1px solid #65516e}
.source-card>span{display:block;font-size:9px;color:#9d8da6;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:7px}
.add-photo-button{width:100%;background:#353139;color:#e6dfe9;font-size:11px;border-radius:24px;padding:12px 8px;margin-top:16px}
.add-photo-button:hover{background:#47404c}
.history-divider{font-size:7px;color:#85748f;letter-spacing:1px;margin:25px 0 12px;padding-top:18px;border-top:1px solid #302735}
.history-list{display:flex;flex-direction:column;gap:12px}
.history-empty,.history-note{font-size:9px;line-height:1.7;color:#756780;margin:0}
.history-note{margin-top:19px}
.history-item{display:block;text-align:left;position:relative;padding:0;background:transparent;border-radius:9px;border:2px solid transparent}
.history-item.selected{border-color:#f3e8f5}
.history-item img{width:100%;height:88px;object-fit:cover;border-radius:7px 7px 0 0;display:block}
.history-item>span{display:block;font-size:9px;line-height:1.6;padding:7px 6px;background:#24202a;border-radius:0 0 7px 7px;color:#c3b6cd}
.history-item small{display:block;font-size:8px;color:#96839f}
.history-item.selected::after{content:'✓';position:absolute;right:7px;top:7px;width:18px;height:18px;background:#fff;border-radius:50%;color:#29202f;font-size:11px;text-align:center;line-height:18px}
.processing-overlay{position:absolute;inset:0;z-index:8;display:flex;align-items:center;justify-content:center;flex-direction:column;background:#0d0812bc;backdrop-filter:blur(4px);text-align:center;padding:20px}
.processing-overlay strong{font-size:15px;font-weight:550;margin-top:18px}
.processing-overlay>span:not(.spinner){font-size:12px;color:#bdaccc;margin-top:10px}
.processing-overlay small{font-size:10px;color:#9885a7;margin-top:18px;line-height:1.7}
.spinner{height:32px;width:32px;border:2px solid #48303d;border-top-color:var(--pink);border-radius:50%;animation:spin 1s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}
}
.visually-hidden{position:absolute;width:1px;height:1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}

.color-strength-options{display:flex;gap:7px;margin-top:13px}.color-strength-options button{flex:1;min-width:0;padding:8px 5px;border:1px solid #3c3343;border-radius:7px;background:#242029;color:#b5a6c0;font-size:10px;line-height:1.5}.color-strength-options button span{display:block;font-size:9px;color:#83718f}.color-strength-options button.selected{border-color:#d57394;background:#482434;color:#fff}.color-strength-options button.selected span{color:#e1a3bb}.color-strength-options button:not(:disabled):hover{border-color:#e697b0;background:#39242f}

/* Viewport layout: panels scroll internally and the photo gets the remaining space. */
:root { --topbar-height: 56px; --settings-width: calc(clamp(220px, 18vw, 248px) + 70px); --history-width: calc(clamp(136px, 10.5vw, 156px) + 30px); }
html, body { width: 100%; height: 100%; overflow: hidden; }
body { height: 100dvh; }
#imageInput { position: fixed; top: 0; left: 0; }
.topbar { height: var(--topbar-height); padding: 0 16px; gap: 16px; }
.brand { gap: 8px; }
.brand strong { font-size: 19px; }
.brand-mark { font-size: 31px; width: 33px; }
.topbar-right { gap: 16px; }
.connection-status, .back-link { font-size: 12px; }
.download-button { min-width: 116px; padding: 9px 16px; gap: 16px; font-size: 14px; }
.layout-controls { display: flex; align-items: center; gap: 5px; margin-right: auto; }
.layout-toggle { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 34px; padding: 7px 10px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: #b9afbf; font-size: 12px; white-space: nowrap; }
.layout-toggle svg { width: 17px; height: 17px; flex-shrink: 0; }
.layout-toggle:hover { background: #27212d; color: #fff; }
.layout-toggle[aria-expanded=true] { color: #ede3f1; background: #242028; }
.layout-toggle[aria-pressed=true] { color: #ffc4d2; background: #442330; border-color: #764152; }
.editor-shell { height: calc(100dvh - var(--topbar-height)); min-height: 0; padding: 8px 10px 10px; gap: 10px; grid-template-columns: var(--settings-width) minmax(0, 1fr) var(--history-width); grid-template-rows: minmax(0, 1fr); position: relative; }
.editor-shell.settings-closed { grid-template-columns: minmax(0, 1fr) var(--history-width); }
.editor-shell.history-closed { grid-template-columns: var(--settings-width) minmax(0, 1fr); }
.editor-shell.settings-closed.history-closed { grid-template-columns: minmax(0, 1fr); }
.settings-panel, .history-panel { min-width: 0; border-radius: 12px; overscroll-behavior: contain; }
.panel-heading { gap: 4px; padding: 13px 12px 10px; flex-shrink: 0; }
.panel-heading .eyebrow { font-size: 10px; letter-spacing: 1px; }
.panel-heading h1 { font-size: 15px; margin-top: 5px; }
.quiet-button { font-size: 12px; }
.panel-actions { display: flex; align-items: center; gap: 6px; }
.panel-close { width: 26px; height: 30px; flex-shrink: 0; display: grid; place-items: center; background: transparent; border-radius: 6px; color: #aca1b3; font-size: 25px; padding: 0; }
.panel-close:hover { background: #35303d; color: #fff; }
.settings-scroll { padding: 0 12px; overscroll-behavior: contain; scrollbar-gutter: stable; }
.setting-section { padding: 12px 0; }
.setting-section summary { gap: 9px; font-size: 14px; line-height: 1.4; }
.setting-section summary small { margin-top: 2px; font-size: 12px; color: #a49aa9; }
.section-icon { width: 28px; height: 28px; border-radius: 7px; }
.section-body { padding-top: 12px; }
.segment-options button { min-height: 38px; min-width: 58px; padding: 7px 10px; font-size: 14px; }
.four-options button { min-width: 0; padding: 7px 2px; font-size: 11px; }
.palette-grid { gap: 9px 6px; }
.palette-choice { font-size: 12px; line-height: 1.4; }
.palette-swatch { height: 46px; margin-bottom: 5px; }
.setting-hint { margin-top: 9px; font-size: 12px; line-height: 1.6; color: #a59cac; }
.range-label { margin: 13px 0 7px; font-size: 12px; }
.scale-section { padding: 13px 0; font-size: 13px; }
.scale-section .segment-options button { font-size: 13px; }
.color-strength-options button { font-size: 12px; }
.color-strength-options button span { font-size: 11px; }
.local-disclaimer { margin-bottom: 14px; font-size: 11px; color: #93859d; }
.apply-area { flex-shrink: 0; padding: 9px 12px 11px; }
.apply-area > p:first-child { margin-bottom: 7px; font-size: 12px; }
.apply-button { padding: 10px 16px; font-size: 15px; }
.apply-help { display: none; }
.workspace { min-height: 0; min-width: 0; position: relative; }
.canvas-toolbar { flex: 0 0 44px; height: 44px; min-height: 0; padding: 0 2px 6px; gap: 10px; }
.file-name { max-width: min(28vw, 360px); font-size: 12px; }
.result-status { margin-top: 2px; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compare-modes { margin-left: auto; padding: 2px; }
.compare-modes button { padding: 5px 9px; font-size: 12px; }
.image-frame { flex: 1 1 0; min-height: 0; min-width: 0; position: relative; overflow: hidden; border-radius: 14px 0 0 14px; clip-path: inset(0 round 14px 0 0 14px); isolation: isolate; }
.image-viewport { position: absolute; inset: 0; min-height: 0; border-radius: inherit; overflow-anchor: none; touch-action: none; scrollbar-width: auto; scrollbar-color: auto; }
.image-viewport::-webkit-scrollbar { width: 8px; height: 8px; }
.image-viewport::-webkit-scrollbar-track, .image-viewport::-webkit-scrollbar-corner { background: #111014; }
.image-viewport::-webkit-scrollbar-thumb { background: #4c4354; border: 2px solid #111014; border-radius: 8px; }
.image-viewport::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
.image-viewport:focus-visible { outline: 2px solid #ff93ab; outline-offset: -2px; }
.image-wrapper { position: absolute; top: 0; left: 0; padding: 4px; }
.viewport-measure { position: absolute; inset: 0; visibility: hidden; pointer-events: none; }
.image-viewport.is-pannable { cursor: grab; background: #09090c; }
.image-canvas img { -webkit-user-drag: none; }
.image-viewport.is-panning, .image-viewport.is-panning * { cursor: grabbing; user-select: none; }
.empty-state { min-height: 0; padding: 18px; }
.empty-symbol { font-size: 38px; margin-bottom: 18px; }
.empty-state h2 { font-size: 26px; }
.empty-state p { margin-bottom: 18px; font-size: 14px; }
.empty-state small { margin-top: 16px; font-size: 11px; }
.primary-upload { font-size: 14px; }
.view-toolbar { flex: 0 0 46px; height: 46px; min-height: 0; gap: 8px; padding: 5px 2px; flex-wrap: nowrap; }
.view-info { display: flex; flex-direction: column; min-width: 0; gap: 3px; }
.viewer-help { font-size: 10px; line-height: 1.3; color: #a497ad; white-space: nowrap; }
.image-size { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.zoom-controls { flex-shrink: 0; gap: 6px; }
.zoom-controls select { padding: 5px 6px; font-size: 12px; }
.zoom-controls .fit-button { margin-left: 4px; }
.result-footer { flex: 0 0 36px; height: 36px; position: relative; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; overflow: visible; max-height: none; padding: 0 2px; font-size: 11px; }
.result-footer > p { min-width: 0; margin: 0; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.result-footer details { flex-shrink: 0; padding: 0; }
.result-footer summary { font-size: 11px; line-height: 1.6; }
#appliedStages { position: absolute; bottom: calc(100% + 6px); right: 0; z-index: 9; width: min(480px, 100%); max-height: min(300px, 50dvh); overflow: auto; padding: 12px 16px; background: #201b27; border: 1px solid #494052; border-radius: 10px; box-shadow: 0 6px 24px #0008; font-size: 11px; }
.history-panel { padding: 10px; }
.history-heading { gap: 4px; }
.history-heading h2 { font-size: 13px; }
#historyCount { font-size: 11px; color: #b3a3bc; }
.history-panel .panel-actions { gap: 2px; }
.history-panel .panel-close { width: 20px; }
.source-card { margin-top: 10px; }
.source-card img { aspect-ratio: 1.5; border-radius: 7px; }
.source-card > span { margin-top: 5px; font-size: 11px; }
.add-photo-button { margin-top: 12px; padding: 10px 5px; font-size: 13px; }
.history-divider { margin: 16px 0 10px; padding-top: 12px; font-size: 9px; line-height: 1.5; letter-spacing: .4px; }
.history-list { gap: 9px; }
.history-item img { height: auto; aspect-ratio: 1.5; }
.history-item > span { padding: 5px; font-size: 12px; }
.history-item small { font-size: 11px; }
.history-empty, .history-note { font-size: 11px; color: #9b8da5; }
.history-note { margin-top: 12px; }
.error-message { flex-shrink: 0; max-height: 22dvh; overflow: auto; padding: 8px 10px; margin-bottom: 6px; }
.source-preparation-note { flex-shrink: 0; padding: 7px 10px; margin-bottom: 6px; border-radius: 8px; background: #20252b; color: #c8dce6; font-size: 12px; line-height: 1.5; max-height: 18dvh; overflow: auto; }
.panel-backdrop { position: absolute; inset: 0; z-index: 11; background: #030206a6; }
.focus-view .canvas-toolbar, .focus-view .result-footer { display: none; }
.focus-view .editor-shell { padding-top: 6px; }

@media (max-width: 1180px) {
  .connection-status, .back-link { display: none; }
  .topbar { gap: 12px; padding: 0 12px; }
  .layout-controls { margin-left: auto; margin-right: 0; }
}
@media (max-width: 900px) {
  .editor-shell, .editor-shell.settings-closed, .editor-shell.history-closed { grid-template-columns: minmax(0, 1fr); padding: 6px 8px 8px; gap: 0; }
  .settings-panel, .history-panel { position: absolute; top: 6px; bottom: 8px; z-index: 12; box-shadow: 0 12px 40px #0009; border: 1px solid #3a303f; }
  .settings-panel { left: 8px; width: min(358px, calc(100% - 32px)); }
  .history-panel { right: 8px; width: min(260px, calc(100% - 32px)); }
  .settings-scroll { padding: 0 14px; }
  .panel-heading { padding: 12px 14px 10px; }
  .palette-swatch { height: 52px; }
  .panel-close { width: 32px; height: 32px; }
  .history-panel .panel-close { width: 30px; }
  .file-name { max-width: 45vw; }
  .brand strong { font-size: 17px; }
  .layout-toggle { padding: 7px 8px; gap: 5px; }
}
@media (max-width: 700px) {
  :root { --topbar-height: 94px; }
  .topbar { flex-wrap: wrap; align-content: center; gap: 5px 12px; padding: 6px 10px; }
  .brand { margin-right: auto; }
  .brand strong { font-size: 17px; }
  .brand-mark { font-size: 28px; width: 30px; }
  .topbar-right { margin-left: auto; }
  .download-button { min-width: 94px; padding: 8px 12px; gap: 12px; }
  .download-button svg { width: 17px; }
  .layout-controls { order: 3; flex: 0 0 100%; justify-content: space-between; gap: 4px; }
  .layout-toggle { min-height: 32px; padding: 7px 8px; font-size: 11px; }
  .layout-toggle svg { width: 16px; height: 16px; }
  .canvas-toolbar { padding-bottom: 6px; }
  .file-name { font-size: 11px; max-width: 44vw; }
  .result-status { font-size: 10px; }
  .compare-modes button { padding: 5px 7px; font-size: 11px; }
  .view-toolbar { gap: 6px; }
  .viewer-help { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); }
  .image-size { font-size: 11px; }
  .zoom-controls { gap: 2px; }
  .zoom-controls select { min-width: 82px; font-size: 11px; }
  .zoom-controls button { width: 25px; }
  .result-footer { flex: 0 0 54px; height: 54px; display: block; }
  .result-footer > p { font-size: 10px; }
  .empty-state { padding: 14px; }
  .empty-state h2 { font-size: 23px; }
  .empty-state p { font-size: 11px; }
  .empty-state .eyebrow { font-size: 7px; }
  .compare-labels span { top: 12px; padding: 9px 14px; font-size: 14px; }
  #beforeLabel { transform: translateX(calc(-100% - 24px)); }
  #afterLabel { transform: translateX(24px); }
}
@media (max-height: 560px) {
  .empty-symbol, .empty-state .eyebrow, .empty-state small { display: none; }
  .empty-state h2 { margin-top: 0; font-size: 21px; }
  .empty-state p { margin-bottom: 10px; line-height: 1.5; }
  .primary-upload { padding: 8px 18px; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
  .spinner { animation-duration: 2s; }
}

/* V21: use the same upload symbol and header entry point as Remove. */
.topbar>.brand,.topbar-right{flex-shrink:0}
.header-upload{display:flex;align-items:center;flex-shrink:0;min-height:44px;padding:4px;border:1px solid #2b2731;border-radius:10px;background:#151419}
.choose-photo{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-width:156px;min-height:34px;padding:8px 14px;border:1px solid #3c3544;border-radius:7px;background:#24212a;color:#e8e0ed;font-size:13px;font-weight:600;white-space:nowrap}
.choose-photo:not(:disabled):hover{background:#302732;border-color:#7a4d61}
.upload-icon{width:18px;height:18px;flex-shrink:0;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}
.choose-photo .upload-icon{width:17px;height:17px}
.primary-upload{gap:10px;justify-content:center}
.primary-upload span{font-size:inherit}
.primary-upload .upload-icon{width:20px;height:20px}
.add-photo-button{display:flex;align-items:center;justify-content:center;gap:8px}
body:has(#emptyState:not([hidden])) .choose-photo:not(:disabled){background:var(--pink);border-color:#fa4a70;color:#fff}
body:has(#emptyState:not([hidden])) .choose-photo:not(:disabled):hover{background:#ee2e56;border-color:#ff83a0}
@media(min-width:701px) and (max-width:1280px){.connection-status,.back-link{display:none}.topbar{gap:12px}.layout-controls{margin-left:auto;margin-right:0}}
@media(min-width:701px) and (max-width:1050px){.layout-toggle>span{position:absolute;width:1px;height:1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}.layout-toggle{width:36px;min-height:36px;padding:8px}.header-upload .choose-photo{min-width:140px}}
@media(max-width:700px){
  :root{--topbar-height:104px}
  .topbar{display:grid;grid-template-columns:minmax(0,1fr) auto;grid-template-rows:40px 44px;align-content:center;gap:6px 10px;padding:7px 10px}
  .topbar>.brand{grid-column:1;grid-row:1;margin:0}
  .topbar-right{grid-column:2;grid-row:1;margin:0}
  .header-upload{grid-column:1;grid-row:2;justify-self:start;padding:4px;min-width:0;max-width:100%}
  .choose-photo{min-width:142px;min-height:34px;padding:7px 12px}
  .layout-controls{grid-column:2;grid-row:2;order:initial;margin:0;gap:3px;justify-content:flex-end}
  .layout-toggle{width:32px;min-height:36px;padding:7px}
  .layout-toggle>span{position:absolute;width:1px;height:1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}
  .download-button{min-width:88px;gap:9px;padding:8px 10px;font-size:13px}
}


/* Locale-safe controls: allow long labels without widening the workspace. */
.choose-photo{max-width:220px;min-width:0}
.choose-photo span{overflow:hidden;text-overflow:ellipsis}
.layout-toggle{min-width:0}
.segment-options button,.palette-choice{overflow-wrap:anywhere}
.download-button span{white-space:nowrap}
[dir="rtl"] .editor-shell{direction:rtl}
[dir="rtl"] .image-frame,[dir="rtl"] .zoom-controls{direction:ltr}
[dir="rtl"] .empty-state,[dir="rtl"] .processing-overlay{direction:rtl}
[dir="rtl"] .history-item{text-align:right}
[dir="rtl"] .accordion-mark{margin-left:0;margin-right:auto}
[dir="rtl"] .connection-status i{margin-left:6px;margin-right:0}
@media(min-width:1051px) and (max-width:1500px){.connection-status,.back-link{display:none}}
@media(max-width:700px){.header-upload{max-width:min(55vw,240px)}.header-upload .choose-photo{min-width:0;max-width:100%}.topbar .download-button{min-width:0;max-width:48vw}.download-button span{overflow:hidden;text-overflow:ellipsis}.topbar>.brand{min-width:0}}
@media(max-width:420px){.topbar .brand strong{font-size:16px}.topbar .brand-mark{font-size:27px;width:29px}.topbar .brand{gap:6px}}
