#modal .retouch-steps{display:flex;gap:.35rem;overflow:auto;max-width:100%;margin:.45rem 0}
.retouch-steps button,.retouch-controls button{min-height:44px;padding:.4rem .65rem;border-radius:10px}
.retouch-steps button[aria-current=step],.retouch-controls [aria-pressed=true]{background:#252322;color:white}
.retouch-controls{display:grid;gap:.65rem;margin:.75rem 0;min-width:0}
.retouch-controls fieldset{border:0;padding:0;margin:0;min-width:0}
.retouch-controls input[type=range]{width:100%}
.retouch-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(65px,1fr));gap:6px}
.retouch-grid canvas,.retouch-grid img{display:block;width:100%;aspect-ratio:1;object-fit:contain}
.retouch-target{display:grid;grid-template-columns:auto 1fr;align-items:center;overflow-wrap:anywhere}
.retouch-target canvas{grid-column:1/-1}
#modal:has(.retouch-steps) .editor-tabs,#modal:has(.retouch-steps) .apply-all9,#modal:has(.retouch-steps) .reset-photo11{display:none}
#modal:has(.retouch-steps) [hidden]{display:none!important}
.canvas-stage .portrait-mask{pointer-events:auto;cursor:crosshair;z-index:2}

/* Desktop dialog and phone sheet share a pinned stage and a bounded inspector. */
#modal.studio-modal9:has(.retouch-steps)[open]{display:flex;flex-direction:column;width:min(100%,760px);height:min(92dvh,860px);max-height:100dvh;max-width:100%;overflow:hidden;padding:0;overscroll-behavior:contain;box-sizing:border-box}
#modal:has(.retouch-steps) .modal-top{flex:none;position:static;padding:10px 16px}
#modal:has(.retouch-steps) .modal-top h3{font-size:18px;margin:0}
#modal:has(.retouch-steps) .modal-body{min-height:0;min-width:0;flex:1;display:grid;grid-template-rows:auto minmax(0,1fr) minmax(0,clamp(148px,27dvh,226px)) auto;gap:7px;padding:0 12px;overflow:hidden}
#modal:has(.retouch-steps) .modal-body>:not(.retouch-steps,.canvas-stage,.retouch-controls,.retouch-footer){display:none!important}
#modal:has(.retouch-steps) .retouch-steps{margin:0;overflow-x:auto;overflow-y:hidden;touch-action:pan-x;white-space:nowrap;scrollbar-width:none}
#modal:has(.retouch-steps) .retouch-steps button{flex:1;min-height:36px;font-size:12px}
#modal:has(.retouch-steps) .canvas-stage{position:relative;inset:auto;min-height:0;max-height:none!important;width:100%;height:100%;margin:0;overflow:hidden;display:flex;align-items:center;justify-content:center;isolation:isolate;background:#211f1e}
#modal:has(.retouch-steps) .canvas-stage .cleanup-image{flex:none}
#modal:has(.retouch-steps) .retouch-controls{display:block;position:relative;margin:0;min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin}
#modal:has(.retouch-steps) .retouch-footer{display:flex;align-items:center;justify-content:space-between;gap:12px;border-top:1px solid #8883;padding:7px 0 max(7px,env(safe-area-inset-bottom));background:inherit}
.retouch-footer button{min-height:44px;padding:0 18px}.retouch-footer button:disabled{opacity:.4}
.retouch-tool-rail,.portrait-actions,.retouch-look-rail{position:relative;display:flex;gap:8px;overflow-x:auto;overflow-y:hidden;scrollbar-width:none;touch-action:pan-x;align-items:center;padding:2px}
.retouch-tool-rail button,.retouch-look-rail button,.portrait-actions button{flex:none;white-space:nowrap;font-size:11px}.retouch-tool-rail button{background:transparent;display:grid;gap:3px;justify-items:center}
.retouch-tool-rail button span{width:32px;height:32px;border-radius:50%;border:1px solid currentColor;display:grid;place-items:center;font-size:17px}
.retouch-tool-rail button[aria-pressed=true]{color:#bb3800;background:#ffefe6}
.retouch-slider{display:grid;grid-template-columns:1fr auto;align-items:center;margin:4px 4px 2px;font-size:12px}.retouch-slider input[type=range]{grid-column:1/-1;min-height:34px;touch-action:none;accent-color:#ff4e00}
.retouch-look-rail canvas{width:57px;height:38px;aspect-ratio:auto}
.portrait-actions canvas{width:26px;height:26px;vertical-align:middle}
.retouch-controls p{margin:3px 0;font-size:12px}.retouch-exports{display:flex;flex-wrap:wrap;gap:6px;margin:9px 0}
#modal[data-retouch-step="4"]:has(.retouch-steps) .modal-body{grid-template-rows:auto minmax(0,.46fr) minmax(0,1fr) auto}
@media(max-width:600px){#modal.studio-modal9:has(.retouch-steps)[open]{inset:0;margin:0;height:100dvh;border-radius:0;padding-top:env(safe-area-inset-top)}}
#modal.studio-modal9 .retouch-steps{position:static;inset:auto;transform:none;width:auto;height:auto;z-index:auto;box-shadow:none;border:0;border-radius:0;padding:0;background:transparent;justify-content:flex-start}
#modal.studio-modal9 .retouch-steps button{width:auto;position:static;display:block}

/* Platform editor: expanded dock, gesture compare, and atomic apply/export progress. */
#modal.studio-modal9 .retouch-steps button{min-width:max-content}
#modal:has(.retouch-steps) .canvas-stage #studio-photo{touch-action:none;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none;-webkit-user-drag:none}
#modal:has(.retouch-steps) .canvas-stage .retouch-original-hold{position:absolute;inset:0;width:100%;height:100%;max-width:none;max-height:none;object-fit:contain;background:#211f1e;pointer-events:none;z-index:9}
#modal:has(.retouch-steps) .canvas-stage:has(.retouch-original-hold) .portrait-mask{opacity:0}
#modal:has(.retouch-steps) .original-hold9,.retouch-compare-a11y{position:absolute;width:1px;height:1px;clip-path:inset(50%);overflow:hidden;white-space:nowrap}
#modal:has(.retouch-steps) .original-hold9:focus-visible,.retouch-compare-a11y:focus-visible{top:8px;left:8px;width:auto;height:auto;clip-path:none;z-index:10}
#modal:has(.retouch-steps) .modal-body:has(.retouch-progress){position:relative;}
#modal:has(.retouch-steps) .modal-body .retouch-progress{position:absolute;inset:0;z-index:16;display:grid!important;align-content:center;justify-items:center;gap:12px;background:color-mix(in srgb,Canvas 90%,transparent);color:CanvasText}
.retouch-progress progress{width:min(65%,260px);accent-color:#ff4e00}.retouch-inline,.retouch-copy{display:flex;align-items:center;flex-wrap:wrap;gap:6px;margin:.45rem 0}.retouch-copy label{display:flex;align-items:center;gap:4px;font-size:12px}
.retouch-copy legend{font-weight:700;font-size:13px}.retouch-inline button{min-height:37px}
#modal[data-retouch-step="0"] #mask-canvas,#modal[data-retouch-step="3"] #mask-canvas,#modal[data-retouch-step="4"] #mask-canvas,#modal[data-retouch-step="6"] #mask-canvas{pointer-events:none}

/* Stage and inspector keep separate scroll boundaries. Compact viewports stack
   the inspector; wide viewports keep the photo visible beside longer tools. */
#modal:has(.retouch-steps) .modal-top h3{min-width:0;overflow-wrap:anywhere}
#modal:has(.retouch-steps) .modal-top .round{flex:none;min-width:44px;min-height:44px}
#modal:has(.retouch-steps) .retouch-steps button,.retouch-slider input[type=range]{min-height:44px}
#modal:has(.retouch-steps) .retouch-steps{scroll-padding-inline:5px}
#modal:has(.retouch-steps) .retouch-controls{min-width:0;overflow-x:hidden}
.retouch-copy label{min-height:36px;max-width:100%;overflow-wrap:anywhere}
.retouch-exports select,.retouch-exports button{max-width:100%;min-height:44px}
.retouch-exports :focus-visible,.retouch-steps :focus-visible,.retouch-tool-rail :focus-visible{outline:2px solid #bb3800;outline-offset:-2px}
.photo-album .album-title9{column-gap:10px;row-gap:4px}
.photo-album .album-title9>h3{max-width:100%;overflow-wrap:anywhere}
@media(max-width:600px){
 #modal:has(.retouch-steps) .modal-body{padding-inline:max(10px,env(safe-area-inset-left)) max(10px,env(safe-area-inset-right))}
 .retouch-slider,.retouch-tool-rail{margin-inline:1px}
}
@media(min-width:601px) and (max-width:959px) and (min-height:600px){
 #modal.studio-modal9:has(.retouch-steps)[open]{width:min(calc(100% - 48px),850px);height:min(91dvh,980px)}
 #modal:has(.retouch-steps) .modal-body{padding-inline:18px;gap:10px}
}
@media(min-width:960px), (min-width:600px) and (max-height:520px){
 #modal.studio-modal9:has(.retouch-steps)[open]{width:min(calc(100% - 40px),1240px);height:min(89dvh,880px)}
 #modal:has(.retouch-steps) .modal-body,#modal[data-retouch-step="4"]:has(.retouch-steps) .modal-body{
  grid-template-columns:minmax(0,1.65fr) minmax(260px,1fr);grid-template-rows:auto minmax(0,1fr) auto;
  grid-template-areas:"steps steps" "preview controls" "footer footer";gap:10px 16px;padding-inline:16px
 }
 #modal:has(.retouch-steps) .retouch-steps{grid-area:steps}
 #modal:has(.retouch-steps) .canvas-stage{grid-area:preview}
 #modal:has(.retouch-steps) .retouch-controls{grid-area:controls;padding:.25rem .25rem 1rem}
 #modal:has(.retouch-steps) .retouch-footer{grid-area:footer}
 #modal:has(.retouch-steps) .retouch-tool-rail,#modal:has(.retouch-steps) .retouch-look-rail{padding-block-end:6px}
}
@media(min-width:600px) and (max-height:520px){
 #modal.studio-modal9:has(.retouch-steps)[open]{inset:0;margin:0;width:100%;height:100dvh;border-radius:0}
 #modal:has(.retouch-steps) .modal-body{padding-inline:max(8px,env(safe-area-inset-left)) max(8px,env(safe-area-inset-right));gap:4px 8px}
 #modal:has(.retouch-steps) .modal-top{padding-block:1px}
}
.photo-library-head ~ .photo-album .photo-grid{grid-template-columns:repeat(auto-fill,minmax(min(100%,clamp(118px,21vw,186px)),1fr));gap:clamp(8px,1.5vw,16px)}
.photo-library-head ~ .photo-album .photo-tile{min-width:0}
