/* Keep confirmation outside the scrolling editor: finger scrolling must never
   carry the primary action away or leave it in an overflowing grid track. */
.upload-editor-dialog{max-height:calc(100vh - 32px);max-height:min(calc(100dvh - 32px),920px);grid-template-rows:auto minmax(0,1fr) auto}
.upload-editor-dialog>.upload-editor-footer{margin:0;padding:10px 0 max(8px,env(safe-area-inset-bottom));position:relative;z-index:1}
.upload-editor-footer button{touch-action:manipulation}
/* Keep the reference shortcut in the scrolling body, not above the phone viewport. */
.upload-editor-dialog .crop-workspace{display:flex;flex-direction:column;align-items:stretch}
.upload-reference-entry{flex-shrink:0;width:100%;display:flex;align-items:center;gap:10px;padding:10px 12px;background:#fff;border:1px solid #690730;border-radius:12px;color:#27384e;text-align:left;cursor:pointer;touch-action:manipulation}
.upload-reference-entry>svg{flex-shrink:0;color:#cda2b4;background:#e40a65;box-sizing:content-box;padding:7px;border-radius:9px}
.upload-reference-entry>span{display:grid;gap:4px;min-width:0}
.upload-reference-entry small{font-size:10px;font-weight:650;color:#441629}
.upload-reference-entry strong{font-size:14px;line-height:1.4;color:#27384e}
.upload-reference-entry span span{font-size:11px;line-height:1.45;color:#7b8997}
.upload-reference-entry>b{margin-left:auto;font-size:20px;color:#cfa2b5}
.upload-reference-entry:hover{background:#f5fbf8;border-color:#8a1244}
.upload-reference-entry:focus-visible,.upload-crop-toolbar button:focus-visible{outline:3px solid #bb7693;outline-offset:3px}
.upload-crop-editor{display:grid;gap:8px;flex-shrink:0;min-width:0}
.upload-crop-toolbar{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap}
.upload-crop-tools{display:flex;gap:6px;flex-wrap:wrap}
.upload-crop-toolbar button{min-height:36px;padding:7px 10px;border:1px solid #8b0f43;border-radius:8px;background:#fff;color:#c08fa3;font-size:12px;font-weight:700;cursor:pointer;touch-action:manipulation}
.upload-crop-tools button[aria-pressed=true]{background:#d19cb2;color:#fff;border-color:#d19cb2}
.upload-crop-toolbar button:disabled{opacity:.4;cursor:default}
.upload-crop-zoom{margin-left:auto}
.upload-crop-editor .upload-preview-stage{flex-shrink:0;max-width:100%;border:1px solid #880c3f;isolation:isolate}
.upload-crop-editor .free-crop-box{box-shadow:0 0 0 200vmax #141f2d80,0 0 0 1px #fff}
.upload-crop-editor .free-crop-box:focus-visible{outline:3px solid #fff;outline-offset:4px}
.upload-crop-editor .is-panning,.upload-crop-editor .is-panning .free-crop-box{cursor:grab}
.upload-crop-drag-tip{margin:0;color:#59273c;font-size:11px;line-height:1.6}
.handmade-size-page{min-height:0;overflow:auto;display:flex;flex-direction:column;gap:12px;padding:20px 24px;background:#fff}
.handmade-size-page h3{margin:0;color:#25364e;font-size:20px}
.handmade-size-page p{margin:0;color:#738395;font-size:13px;line-height:1.65}
.handmade-size-page .handmade-size-options{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin-top:4px}
.handmade-size-page .handmade-size-options button{min-height:64px;padding:12px;background:#fff;border:1px solid #690730;border-radius:12px;color:#27384e;font:inherit;font-weight:700;cursor:pointer}
.handmade-size-page .handmade-size-options button:hover,.handmade-size-page .handmade-size-options button:focus-visible{background:#db0961;border-color:#a92159}
.handmade-size-page .handmade-size-back{align-self:flex-start;min-height:42px;padding:8px 15px;background:#f7faf9;border:1px solid #690730;border-radius:9px;color:#b26887;font:inherit;cursor:pointer}
/* Canvas backing resolution must never contribute to the CSS layout. This also
   prevents resize-observer/scrollbar feedback at fractional browser zoom. */
.upload-crop-editor .upload-preview-stage{overflow:hidden;overflow-anchor:none}
.upload-crop-editor .upload-preview-stage.is-zoomed{overflow:auto;scrollbar-gutter:stable}
.upload-crop-editor .upload-preview-zoom-layer{min-height:0!important;aspect-ratio:12 / 7}
.upload-crop-editor .upload-preview-stage .upload-crop-preview{position:absolute!important;inset:0!important;width:100%!important;height:100%!important;aspect-ratio:auto!important}
.upload-editor-layout,.upload-editor-dialog .crop-workspace,.upload-settings-panel{overflow-anchor:none;overscroll-behavior:contain}
.upload-editor-backdrop,.reference-align-backdrop{display:flex;align-items:center;justify-content:center;box-sizing:border-box;overflow:hidden}
.upload-editor-backdrop>.upload-editor-dialog,.reference-align-backdrop>.reference-align-dialog{max-height:100%;min-height:0}
@media(max-width:900px){
 .upload-editor-dialog{max-height:calc(100vh - 24px);max-height:calc(100dvh - 24px);gap:10px}
 .upload-editor-layout{display:block;overflow-y:auto;touch-action:pan-y;overflow-anchor:none}
 .upload-settings-panel{display:grid;height:auto;min-height:auto;overflow:visible;margin-top:12px}
 .upload-editor-dialog>.upload-editor-footer .button{min-height:44px;font-size:13px;line-height:1.4;white-space:normal}
 .upload-reference-entry{padding:11px;gap:9px}
 .upload-reference-entry strong{font-size:13px}
 .handmade-size-page{padding:16px}
 .handmade-size-page .handmade-size-options{grid-template-columns:1fr}
 .handmade-size-page .handmade-size-options button{min-height:54px}
 .upload-crop-toolbar button{min-height:40px;padding:7px 9px;font-size:11px}
 .upload-crop-editor .crop-handle{width:26px!important;min-width:26px;height:26px!important;min-height:26px}
}
