#crop-editor[hidden], #range-field[hidden] { display: none; }
@media (min-width: 621px) {
  .zt-surface:has(#crop-editor:not([hidden])) .crop-bar:not(.is-ready) {
    position: sticky;
    bottom: 8px;
    z-index: 2;
    background: var(--ws);
  }
  .crop-bar .zt-bar-actions { display: flex; flex-wrap: nowrap; justify-content: flex-end; }
  .crop-bar .zt-primary { width: auto; white-space: nowrap; }
}
#crop-editor :is(button, input, select) { scroll-margin-bottom: 116px; }
@media (min-width: 801px) {
  .zt-surface:has(#crop-editor:not([hidden])) .crop-bar {
    position: sticky;
    bottom: 8px;
    z-index: 2;
    width: calc((100% - 24px) * .416667);
    margin-inline-start: auto;
    background: var(--ws);
  }
}
.crop-layout { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 24px; margin-block: 20px; }
.crop-preview, .crop-settings { min-width: 0; }
.crop-nav, .crop-actions, .crop-heading, .crop-unit { display: flex; align-items: center; gap: 12px; }
.crop-nav { justify-content: space-between; margin-bottom: 8px; }
.crop-nav button { min-width: 44px; }
.crop-mat { background: var(--ws-2); border: 1px solid var(--ws-line); border-radius: 10px; display: grid; justify-items: center; padding: 26px; }
.crop-sheet { position: relative; width: min(100%, var(--sheet-width, 100%)); align-self: center; background: white; outline: 1px solid var(--ws-line); }
#crop-image canvas { display: block; width: 100%; height: auto; }
.crop-mask { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.crop-mask::after, #crop-rect { inset: var(--top, 0) var(--right, 0) var(--bottom, 0) var(--left, 0); }
.crop-mask::after { content: ''; position: absolute; box-shadow: 0 0 0 9999px #0004; }
#crop-rect { position: absolute; outline: 2px solid #111; outline-offset: -1px; box-shadow: inset 0 0 0 3px white; cursor: move; touch-action: none; }
#crop-rect:focus-visible { outline: 3px double #111; box-shadow: inset 0 0 0 5px white; }
#crop-rect button { position: absolute; width: 44px; height: 44px; min-height: 44px; padding: 0; margin: 0; background: transparent; border: 0; border-radius: 4px; transform: translate(-50%, -50%); touch-action: none; }
#crop-rect button::after { content: ''; display: block; width: 11px; height: 11px; margin: auto; background: var(--ws-ink); border: 2px solid white; outline: 1px solid var(--ws-ink); }
[data-handle^=n] { top: 0; }
[data-handle^=s] { top: 100%; }
[data-handle$=w] { left: 0; }
[data-handle$=e] { left: 100%; }
[data-handle=n], [data-handle=s] { left: 50%; cursor: ns-resize; }
[data-handle=w], [data-handle=e] { top: 50%; cursor: ew-resize; }
[data-handle=ne], [data-handle=sw] { cursor: nesw-resize; }
[data-handle=nw], [data-handle=se] { cursor: nwse-resize; }
.crop-preview small { display: block; margin-top: 10px; }
.crop-heading { justify-content: space-between; }
.crop-heading h2 { font: 400 2rem/1.1 var(--font-display); margin: 0; }
.crop-inputs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; }
.crop-settings { display: flex; flex-direction: column; align-self: start; gap: 10px; }
.crop-settings input, .crop-settings select { box-sizing: border-box; width: 100%; min-width: 0; font: inherit; font-size: 16px; min-height: 44px; }
.crop-unit select { width: auto; padding-inline: 8px; border: 1px solid var(--ws-ink); border-radius: 8px; background: var(--ws); color: var(--ws-ink); }
.crop-settings small:empty { display: none; }
.crop-actions button, .crop-layout .zt-button { min-height: 44px; }
.crop-actions { border-bottom: 1px solid var(--ws-line); padding-bottom: 4px; }
.crop-auto-mode { border-top: 1px solid var(--ws-line); padding-top: 12px; }
@media (max-width: 760px) { .crop-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; } }
@media (max-width: 620px) {
  #tool .zt-ux-presets { flex-wrap: wrap; }
}

@media (min-width: 1001px) {
  #tool {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    grid-template-areas: 'instruction instruction' 'error error' 'source presets';
    column-gap: 24px;
  }
  #tool > * {
    grid-column: 1 / -1;
  }
  #tool .zt-do {
    grid-area: instruction;
    margin-bottom: 4px;
  }
  #tool > .zt-error {
    grid-area: error;
  }
  #tool .pdf-source {
    grid-area: source;
  }
  #tool .zt-ux-presets {
    grid-area: presets;
    align-self: start;
  }
}

@media (max-width: 620px) {
  #tool .zt-bar.is-ready {
    position: static;
    padding: 12px;
    border-radius: var(--r-sm);
    box-shadow: none;
  }
  #tool .zt-bar.is-ready .zt-summary {
    white-space: normal;
  }
  #tool .zt-bar.is-ready .zt-primary {
    position: fixed;
    inset: auto max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    z-index: 3;
    width: auto;
    box-shadow: 0 0 0 8px var(--ws);
  }
}
