#editor[hidden], #tool [hidden] { display: none !important; }
.crop-work { display: grid; grid-template-columns: minmax(0, 7fr) minmax(270px, 5fr); gap: 24px; align-items: start; }
.crop-preview, .crop-settings { min-width: 0; }
.crop-mat { background: var(--ws-2); border: 1px solid var(--ws-line); border-radius: 10px; padding: 24px; min-height: 160px; display: grid; grid-template-columns: minmax(0,1fr); align-items: center; justify-items: center; }
#stage { position: relative; max-width: 100%; }
#preview { display: block; width: 100%; height: auto; background: #fff; }
#selection { position: absolute; pointer-events: none; }
.crop-mask { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.crop-mask span { position: absolute; box-shadow: 0 0 0 160vmax #0007; }
.crop-mask .circle { border-radius: 50%; }
.crop-preview button[data-edge] { position: absolute; pointer-events: auto; padding: 0; border: 0; border-radius: 0; background: transparent; touch-action: none; }
.crop-preview .crop-move { inset: 0; width: 100%; height: 100%; min-height: 0; min-width: 0; cursor: move; outline: 1px solid black; box-shadow: inset 0 0 0 2px white; }
#selection.circle .crop-move { border-radius: 50%; }
.crop-handle { width: 46px; height: 46px; transform: translate(-50%, -50%); }
.crop-handle::after { position: absolute; content: ''; left: 50%; top: 50%; transform: translate(-50%, -50%); background: white; border: 2px solid black; width: 10px; height: 10px; border-radius: 2px; }
[data-edge=nw], [data-edge=w], [data-edge=sw] { left: 0; }
[data-edge=n], [data-edge=s] { left: 50%; }
[data-edge=ne], [data-edge=e], [data-edge=se] { left: 100%; }
[data-edge=nw], [data-edge=n], [data-edge=ne] { top: 0; }
[data-edge=w], [data-edge=e] { top: 50%; }
[data-edge=sw], [data-edge=s], [data-edge=se] { top: 100%; }
[data-edge=nw], [data-edge=se] { cursor: nwse-resize; }
[data-edge=ne], [data-edge=sw] { cursor: nesw-resize; }
[data-edge=n], [data-edge=s] { cursor: ns-resize; }
[data-edge=w], [data-edge=e] { cursor: ew-resize; }
.crop-preview button[data-edge]:focus-visible { z-index: 3; outline: 3px solid black; box-shadow: 0 0 0 5px var(--go); }
.crop-history, .crop-chips, .crop-pair, #crop-output { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.crop-history { margin-top: 12px; }
.crop-work button:not([data-edge]) { min-height: 44px; padding: 8px 12px; color: var(--ws-ink); background: var(--ws); border: 1px solid var(--ws-line-strong); border-radius: 6px; font: inherit; cursor: pointer; }
.crop-work button[aria-pressed=true] { color: var(--ws); background: var(--ws-ink); }
.crop-work button:disabled { opacity: .5; cursor: default; }
.crop-settings fieldset { min-width: 0; margin: 0 0 16px; padding: 0; border: 0; }
.crop-settings legend { margin: 0 0 8px; padding: 0; font-weight: 600; }
.crop-grid, #custom-ratio { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; margin: 12px 0; }
.crop-settings .zt-field, #crop-output .zt-field { margin: 0; }
.crop-settings input, #crop-output input, #crop-output select { min-width: 0; width: 100%; font-size: 16px; min-height: 44px; }
#rotation label { display: block; margin-top: 12px; }
#angle { display: block; margin: 0; accent-color: var(--ws-ink); }
#angle-value { font-variant-numeric: tabular-nums; }
#crop-output { margin: 16px 0; }
#crop-output input { max-width: 7rem; }
#size-note, #crop-field-error:not(:empty), #quality-error:not(:empty) { margin: 8px 0 16px; }
#crop-field-error:empty, #quality-error:empty { display: none; }
.crop-input .zt-sample { margin-block: 8px; }
.crop-result { margin-block: 12px; }
.crop-result [data-ux-result] { margin: 0; font-weight: 600; }
.crop-result .zt-explain:empty,
#tool:has(.zt-bar .zt-next:not([hidden])) .crop-result .zt-next-tool { display: none; }
@media (max-width: 720px) { .crop-work { grid-template-columns: 1fr; gap: 16px; } }

@media (min-width: 621px) {
  #tool.crop-has-image .zt-bar {
    position: sticky;
    z-index: 5;
    bottom: 0;
    background: var(--ws);
  }
}
#tool.crop-has-image .zt-drop.is-small { min-height: 44px; }
#crop-preview-size { margin: 6px 0 0; }
.crop-settings summary { min-height: 44px; align-content: center; cursor: pointer; font-weight: 600; }
@media (max-width: 720px) {
  .crop-work[data-mode="rotate"] .crop-settings,
  .crop-work[data-mode="flip"] .crop-settings { grid-row: 1; }
}

@media (max-width: 620px) {
  .crop-work:is([data-mode='rotate'], [data-mode='flip']) .crop-mat {
    padding: 12px;
    scroll-margin-top: 12px;
  }
  #tool.crop-has-image .zt-bar:not(.is-ready):not(.is-docked) {
    position: sticky;
    z-index: 5;
    bottom: 0;
    background: var(--ws);
  }
}

@media (min-width: 760px) {
  #tool.crop-has-image .crop-input {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) minmax(0, 3fr);
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
  }
  #tool.crop-has-image .crop-input .zt-files { grid-area: 1 / 2 / span 2; margin: 0; }
}
@media (min-width: 1001px) {
  #tool:has(.crop-input) {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    align-items: start;
    gap: 4px 20px;
  }
  #tool:has(.crop-input) > * { grid-column: 1 / -1; }
  #tool:has(.crop-input) > :is(.zt-do, .zt-ux-presets) { margin: 0; }
  #tool:has(.crop-input) > .zt-ux-presets { grid-area: 2 / 2; }
  #tool > .crop-input { grid-area: 2 / 1; }
}
