*{box-sizing:border-box}body{font:16px system-ui,sans-serif;background:#f4f6f8;color:#18212b;margin:0;padding:24px}
main{max-width:520px;margin:6vh auto;background:white;padding:28px;border-radius:18px;box-shadow:0 8px 32px #10203012}
h1{font-size:25px;margin-top:0}p{color:#536171;line-height:1.5}
label,.button{display:block;width:100%;padding:14px;border-radius:10px;text-align:center;font-weight:600}
label{border:2px dashed #aab6c2;cursor:pointer;margin:20px 0}
input[type=file]{display:none}
.button{border:0;background:#1769d2;color:white;font-size:16px;cursor:pointer}
.button:disabled{opacity:.5;cursor:wait}
.muted{font-size:13px;color:#778391}
label.disabled{opacity:.5;pointer-events:none}
#preview-block{margin-top:14px}
#preview-block[hidden]{display:none}
#crop-stage{display:flex;justify-content:center;align-items:center;background:#eef2f7;border-radius:8px;padding:8px;margin:10px 0;min-height:160px}
#crop-wrap{position:relative;display:inline-block;line-height:0;max-width:100%}
#crop-canvas{display:block;border-radius:4px;max-width:100%}
#crop-overlay{position:absolute;inset:0;overflow:hidden;touch-action:none}
#crop-box{position:absolute;border:2px solid #fff;box-shadow:0 0 0 9999px rgba(15,23,42,.55);cursor:move;touch-action:none}
#crop-overlay.disabled{pointer-events:none}
.crop-handle{position:absolute;width:16px;height:16px;background:#fff;border:2px solid #1769d2;border-radius:3px;touch-action:none}
.crop-handle[data-handle=nw]{left:0;top:0;transform:translate(-50%,-50%);cursor:nwse-resize}
.crop-handle[data-handle=ne]{right:0;top:0;transform:translate(50%,-50%);cursor:nesw-resize}
.crop-handle[data-handle=sw]{left:0;bottom:0;transform:translate(-50%,50%);cursor:nesw-resize}
.crop-handle[data-handle=se]{right:0;bottom:0;transform:translate(50%,50%);cursor:nwse-resize}
.rotate-row{display:flex;gap:10px;margin-top:6px}
.rotate-row .button{flex:1;width:auto;margin:0;background:#e9eef6;color:#1769d2;border:1px solid #cdd9e8}
.link-button{display:block;margin:2px auto 0;padding:4px 0;border:0;background:none;color:#1769d2;font:inherit;font-size:13px;text-decoration:underline;cursor:pointer}
.link-button:disabled{opacity:.5;cursor:wait}
#process{margin-top:12px}
#status{display:flex;align-items:center;gap:10px;min-height:24px;margin-top:10px;font-size:14px;color:#536171}
#status.error{color:#b42318}
.spinner{width:18px;height:18px;border:2px solid #cdd9e8;border-top-color:#1769d2;border-radius:50%;animation:spin .8s linear infinite;flex:0 0 auto}
.spinner[hidden]{display:none}
@keyframes spin{to{transform:rotate(360deg)}}
#result{margin-top:20px;padding:16px;border-radius:12px;background:#f1f5f9}
#result[hidden]{display:none}
a{color:#1769d2}
