/* Tool pages (/compress-image/ and the tools after it). Loaded after /site.css, which defines every token used here.
   Tokens only: no colour literals, and --accent is only ever a fill (tokens.test.ts pins both). */

/* layout: the tool area is wide, the writing stays in the 760 px column */
.page.tool-page { max-width: 1200px; }
html:has(.tool-page) { scroll-padding-bottom: calc(var(--s-8) + var(--s-5)); } /* a focused control is never hidden under the phone's sticky download */
.page.tool-page > :not(.tool) { max-width: 760px; margin-left: auto; margin-right: auto; }
.page.tool-page .tool-hero { text-align: left; padding: var(--s-6) 0 var(--s-4); }
.page.tool-page .tool-hero::before { content: none; }
.page.tool-page .tool-hero h1 { font-size: clamp(28px, 4.5vw, 40px); line-height: 1.12; font-weight: 800; letter-spacing: -.03em; margin: 0 0 var(--s-3); }
.page.tool-page .tool-hero .lead { margin: 0; max-width: none; font-size: 16px; line-height: 1.6; }
.tool-page p, .tool-page li { font-size: 16px; line-height: 1.6; }

/* the tool area: height reserved before the island mounts, so nothing below jumps */
.tool { min-height: 360px; margin: 0 auto var(--s-6); padding: var(--s-5); display: grid; gap: var(--s-4); align-content: start;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }

/* The slot: the first row of the tool, the same height before and after use. The dropzone fills it; a chosen photo's card (its name while
   it works, then sizes and Download) takes the dropzone's place, so the status line, the settings and the guide under the tool never move.
   The before and after picture (.tool-picture, after the settings in the page) sits in the slot's left column on a wide screen; on a
   phone it follows the settings. */
.tool { --slot-h: 400px; grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--slot-h); }
.tool > *, .tool-island > * { grid-column: 1 / -1; }
.dropzone, .sample-button, .tool-result, .tool-batch { grid-row: 1; }
.tool-result, .tool-batch { display: grid; gap: var(--s-3); align-content: start; min-width: 0; }
.tool-result > button, .tool-batch > button, .result > .another { justify-self: start; }
/* a batch list starts in the slot and keeps at least its height (nothing below moves for a short list); a long list grows the slot */
.tool:has(.tool-batch) { grid-template-rows: minmax(var(--slot-h), auto); }
@media (min-width: 761px) {
  .tool { grid-template-columns: minmax(0, 1fr) minmax(260px, 320px); }
  .tool-picture > .compare, .tool-picture > .preview { grid-column: 1; grid-row: 1; }
  /* beside the picture, inside the slot's height: a card longer than the slot scrolls in its column instead of pushing the page */
  .tool-result { grid-column: 2; min-height: 0; overflow: auto; padding: var(--s-1); }
}
.tool-page .tool p, .tool-page .tool li { font-size: 14px; line-height: 1.4; }

/* dropzone: the real file input is visually hidden but focusable, and its label shows the focus ring */
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.dropzone { position: relative; display: grid; justify-items: center; align-content: center; gap: var(--s-2); text-align: center; cursor: pointer;
  padding: var(--s-7) var(--s-5) calc(var(--s-8) + var(--s-4)); /* the bottom keeps clear of "Try a sample", which sits inside the dashed area */
  background: var(--surface-0); border: 2px dashed var(--border); border-radius: var(--r-lg); transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease); }
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); }
.dropzone:focus-within { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 2px; } /* opaque: --focus-ring alone is under 3:1 */
.dropzone-button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 var(--s-5); border-radius: var(--r-pill);
  background: var(--accent); color: var(--accent-ink); font-size: 16px; font-weight: 650; line-height: 1.4; }
.dropzone-hint { margin: 0; color: var(--text-2); font-size: 14px; line-height: 1.4; }
.tool-page .tool .dropzone-caption { margin: 0; color: var(--text-3); font-size: 13px; line-height: 1.4; font-variant-numeric: tabular-nums; } /* beats the 14 px tool paragraphs above */
.sample-button { position: relative; justify-self: center; align-self: end; margin-bottom: var(--s-4); min-height: 24px; padding: var(--s-2) var(--s-3); background: none; border: 0; border-radius: var(--r-sm);
  color: var(--violet-2); font: inherit; font-size: 14px; line-height: 1.4; text-decoration: underline; cursor: pointer; }
.noscript { margin: 0; color: var(--text-2); }
@media (scripting: none) { .sample-button { display: none; } } /* the sample needs the script that loads it */

/* settings */
.tool-settings { display: grid; gap: var(--s-4); font-size: 14px; line-height: 1.4; color: var(--text-1); }
.tool-settings fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-4); }
.tool-settings legend { float: left; margin: 0 var(--s-2) 0 0; padding: 0; color: var(--text-1); } /* floated: a legend sits on the fieldset's line, in the same row as its options */
.tool-settings label { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-2) var(--s-3); }
.tool-settings input[type="range"] { flex: 1 1 200px; min-height: 24px; accent-color: var(--accent); }
.tool-settings input[type="radio"], .tool-settings input[type="checkbox"] { width: 24px; height: 24px; margin: 0; accent-color: var(--accent); }
.tool-settings input[type="number"] { min-width: 24px; min-height: 36px; width: 8em; padding: 0 var(--s-2); font: inherit; color: var(--text-1);
  background: var(--surface-0); border: 1px solid var(--border); border-radius: var(--r-sm); font-variant-numeric: tabular-nums; }
.tool-settings select { min-height: 36px; padding: 0 var(--s-2); font: inherit; color: var(--text-1);
  background: var(--surface-0); border: 1px solid var(--border); border-radius: var(--r-sm); }
/* a control belongs to a mode (data-when); :has() hides what does not apply to the checked mode, Keep proportions or Crop, so no script moves anything */
.tool-settings:has(input[name="mode"]:checked:not([value="size"])) [data-when~="size"],
.tool-settings:has(input[name="mode"]:checked:not([value="percent"])) [data-when~="percent"],
.tool-settings:has(input[name="mode"]:checked:not([value="longest"])) [data-when~="longest"],
.tool-settings:has(input[name="keep"]:checked) [data-when~="exact"],
.tool-settings:has(input[name="fit"][value="crop"]:checked) [data-when~="pad"] { display: none; }
/* Convert's rules, keyed to its own "Convert to" select (no other tool has a control named "to"): PNG has no Quality; Behind transparent areas is for JPG only,
   and More settings goes with it when it holds nothing else */
.tool-settings:has(select[name="to"] option[value="png"]:checked) [data-when~="lossy"],
.tool-settings:has(select[name="to"] option[value="jpeg"]:not(:checked)) [data-when~="jpg"] { display: none; }
.tool-settings:has(select[name="to"] option[value="jpeg"]:not(:checked)) .more-settings:not(:has(> :not(summary, [data-when~="jpg"]))) { display: none; }
.tool-size { margin: 0; min-height: calc(2 * 1.4em); color: var(--text-2); font-variant-numeric: tabular-nums; } /* two lines kept, so the size arriving moves nothing */
.tool-settings output { font-variant-numeric: tabular-nums; color: var(--text-2); min-width: 4ch; }
/* why a control is disabled (Never enlarge for an exact size, Transparent for JPG): one short line under it */
.tool-page .tool .setting-note { flex-basis: 100%; margin: 0; color: var(--text-2); font-size: 13px; line-height: 1.4; }
.more-settings summary { min-height: 24px; cursor: pointer; color: var(--text-2); }
.more-settings[open] summary { margin-bottom: var(--s-3); }
.tool-privacy { margin: 0; color: var(--text-2); }
.editor-link { font-size: 14px; color: var(--text-2); }

/* progress, errors */
.tool [role="status"] { min-height: var(--s-5); margin: 0; color: var(--text-2); display: flex; align-items: center; gap: var(--s-3); }
.tool [role="alert"] { padding: var(--s-3) var(--s-4); background: var(--surface-0); border: 1px solid var(--danger-text); border-radius: var(--r-md); color: var(--danger-text); }
.tool [role="alert"] p { margin: 0; }
.tool [role="alert"] a { display: inline-block; min-height: 24px; color: var(--violet-2); }

/* buttons: controls are at least 24 x 24 px, the primary one is 44 px high */
.tool button { min-width: 24px; min-height: 36px; padding: 0 var(--s-4); font: inherit; font-size: 14px; line-height: 1.4; color: var(--text-1);
  background: var(--surface-0); border: 1px solid var(--border); border-radius: var(--r-pill); cursor: pointer; transition: border-color var(--t-fast) var(--ease); }
.tool button:hover:not(:disabled) { border-color: var(--text-3); }
.tool button[aria-pressed="true"] { background: var(--surface-2); border-color: var(--text-3); }
.tool button:disabled { cursor: default; opacity: .6; }
/* focus is an opaque outline (at least 3:1 on every surface, tokens.test.ts): the translucent --focus-ring alone is about 1.9:1 */
.tool :focus-visible, .tool-page a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.button-primary { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 var(--s-5); border-radius: var(--r-pill);
  background: var(--accent); color: var(--accent-ink); font-size: 16px; font-weight: 650; line-height: 1.4; text-decoration: none; transition: filter var(--t-fast) var(--ease); }
.button-primary:hover { filter: brightness(.94); }
.download-anyway { display: inline-block; min-height: 24px; color: var(--violet-2); font-size: 14px; line-height: 1.4; }

/* result: revealed with a fade and an 8 px rise */
.result { display: grid; gap: var(--s-3); animation: tool-reveal var(--t-base) var(--ease) both; }
.result-title { margin: 0; font-size: 20px; line-height: 1.3; overflow-wrap: anywhere; }
.result-title:focus, .batch-summary:focus { outline: none; } /* focus targets for the screen reader, not controls */
/* the island hides a control the browser cannot use (WebP) or the format ignores (Quality for PNG); the label rules above set display */
.tool [hidden] { display: none !important; }
.result-meta { margin: 0; color: var(--text-2); font-variant-numeric: tabular-nums; }
.result-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
@keyframes tool-reveal { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* compare: the "after" image is clipped by the range */
/* the picture fills what the slot leaves after the controls: the frame is a size container, and the stage takes the largest box of the
   result's ratio that fits it (from the width and height the island already knows, so it never resizes when the pictures decode) */
.compare { display: flex; flex-direction: column; gap: var(--s-3); min-height: 0; }
.compare, .compare-frame { min-width: 0; } /* a grid item would otherwise grow to the 100 % image's width instead of scrolling */
.compare-frame { position: relative; flex: 1 1 0; min-height: 0; container-type: size; display: grid; place-items: center; overflow: hidden; border-radius: var(--r-md); }
.compare-stage { position: relative; width: min(100cqw, 100cqh * var(--ratio)); aspect-ratio: var(--ratio); background: var(--surface-check); }
.compare-stage img { display: block; width: 100%; height: 100%; }
.compare-stage .compare-after { position: absolute; inset: 0; }
.compare-frame.is-actual { overflow: auto; place-items: start; } /* "View at 100 %": natural size, the frame scrolls */
.compare-frame.is-actual .compare-stage { width: var(--w); }
/* Resize's result: one picture in a box of the slot's height, sized before it decodes (the box never changes with the photo) */
.tool-picture > .preview { display: block; width: 100%; height: var(--slot-h); min-width: 0; object-fit: contain; border-radius: var(--r-md); background: var(--surface-check); }
/* Rotate's picture and its five buttons. The frame is a box of the slot's height less the button row; the picture is sized to the box's
   shorter side by its larger side (--k is its shape, from the island), so a quarter turn stays inside the box and nothing moves. The
   island sets the turn as a CSS transform, so a press moves the picture at once. */
.orient-stage { display: flex; flex-direction: column; gap: var(--s-3); min-width: 0; height: var(--slot-h); }
.orient-frame { flex: 1 1 0; min-height: 0; min-width: 0; container-type: size; display: grid; place-items: center; overflow: hidden; border-radius: var(--r-md); background: var(--surface-check); }
.orient-frame > .preview { display: block; max-width: none; height: auto; width: calc(min(100cqw, 100cqh) * var(--k, 1)); }
.orient { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-2); }
@media (min-width: 761px) { .tool-picture > .orient-stage { grid-column: 1; grid-row: 1; } }
.result-device { margin: 0; display: flex; align-items: center; gap: var(--s-2); color: var(--text-2); }
.result-note, .batch-summary, .batch-note { margin: 0; color: var(--text-2); }
/* Convert's result: the link to Compress when the new file is larger or the format is unchanged; PSD's: the link to the editor for the layers */
.result .compress-link, .result .layers-link { display: inline-block; min-height: 24px; color: var(--violet-2); font-size: 14px; line-height: 1.4; }
/* PSD's result: what the file uses that was left out, a heading line and a short list; a long feature name wraps instead of widening the card */
.result-warnings { display: grid; gap: var(--s-1); overflow-wrap: anywhere; }
.result-warnings p, .result-warnings ul { margin: 0; }
.result-warnings ul { padding-left: 1.25em; }
.batch { display: grid; gap: var(--s-3); }
.batch-actions { display: flex; flex-wrap: wrap; gap: var(--s-3); }
.compare-controls { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.compare-controls input[type="range"] { flex: 1 1 200px; min-height: 24px; accent-color: var(--accent); }

/* batch rows */
.batch-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.batch-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-4); margin: 0; padding: var(--s-3) var(--s-4);
  background: var(--surface-0); border: 1px solid var(--border); border-radius: var(--r-md); font-size: 14px; line-height: 1.4; }
.batch-row .name { flex: 1 1 12em; min-width: 0; overflow-wrap: anywhere; color: var(--text-1); }
.batch-row .sizes, .batch-row .status { color: var(--text-2); font-variant-numeric: tabular-nums; }
.batch-row.is-error .status { color: var(--danger-text); }
.batch-row.is-done .status { color: var(--ok); }

/* related tools */
.related { margin-top: var(--s-7); }
.related ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--s-3); }
.related li { margin: 0; }
.related a { display: block; min-height: 24px; padding: var(--s-3) var(--s-4); background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-md); color: var(--text-1); text-decoration: none; }
.related a:hover { border-color: var(--text-3); }

/* phone: one column, and the download stays in reach */
@media (max-width: 760px) {
  /* the slot is at least the card's usual height; a card made longer by a note and the resize offer grows it rather than overlap */
  .tool { padding: var(--s-4); min-height: 320px; --slot-h: 360px; grid-template-rows: minmax(var(--slot-h), auto); }
  .dropzone { padding: var(--s-6) var(--s-4) calc(var(--s-8) + var(--s-4)); }
  .tool-picture > .compare { height: var(--slot-h); }
  /* the status line and the batch summary hold the done line, which takes two lines here: they keep two lines, so the line arriving
     moves nothing; a batch row keeps its name on one line and its sizes and state on the next, and a list of three with its ZIP link
     fits the slot */
  .tool [role="status"], .batch-summary { min-height: calc(2em * 1.4); }
  .tool-batch { gap: var(--s-2); }
  .batch-row { padding: var(--s-2) var(--s-3); }
  .batch-row .name { flex-basis: 100%; }
  .result-actions { position: sticky; bottom: 0; z-index: 5; padding: var(--s-3) 0; background: var(--surface-1); border-top: 1px solid var(--border); }
  .result-actions .button-primary { flex: 1 1 100%; }
}

/* forced colours drop the pressed background, so a pressed toggle shows it by shape: underline and a thicker border */
@media (forced-colors: active) {
  .tool button[aria-pressed="true"] { text-decoration: underline; border-width: 3px; border-color: ButtonText; }
}

@media (prefers-reduced-motion: reduce) {
  .result { animation: none; }
  .dropzone, .tool button, .button-primary { transition: none; }
}

/* Crop's box (shell/CropBox.tsx). The stage has the picture's shape (--ratio, from the component) and takes the width it is given; the
   box and the hole in the dimmed surround are placed in percent of it. Lines over a photo do not follow the page theme: a white line
   with a dark edge (--bg and --ink, which the dark theme leaves alone) shows on light and dark pictures alike. Every hit area is
   --crop-hit square (24 px, 44 px under a coarse pointer), centred on the outline, or just outside it when the box is small (.is-small,
   set by the component under 72 px a side); the visible knob inside it is 10 px. touch-action: none on the box and handles only. */
.crop { --crop-hit: 24px; position: relative; width: 100%; aspect-ratio: var(--ratio); user-select: none; -webkit-user-select: none; background: var(--surface-check); }
@media (pointer: coarse) { .crop { --crop-hit: 44px; } }
.crop-image { display: block; width: 100%; height: 100%; pointer-events: none; }
.crop-shade { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.crop-hole { position: absolute; box-shadow: 0 0 0 100vmax color-mix(in srgb, var(--ink) 55%, transparent); }
.crop-box { position: absolute; cursor: move; touch-action: none; box-shadow: inset 0 0 0 1px var(--bg), 0 0 0 1px var(--ink); transition: box-shadow var(--t-fast) var(--ease); }
.crop-box.is-dragging { box-shadow: inset 0 0 0 2px var(--bg), 0 0 0 1px var(--ink); }
/* focus: the accent outline sits on a white band with a dark ring outside it, so the ring shows over a light or a dark photo */
.crop-box:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; box-shadow: inset 0 0 0 1px var(--bg), 0 0 0 1px var(--ink), 0 0 0 4px var(--bg), 0 0 0 6px var(--ink); }
.crop-box.is-dragging:focus-visible { box-shadow: inset 0 0 0 2px var(--bg), 0 0 0 1px var(--ink), 0 0 0 4px var(--bg), 0 0 0 6px var(--ink); }
.crop-grid { position: absolute; inset: 0; pointer-events: none; }
.crop-grid::before, .crop-grid::after { content: ""; position: absolute; border: 0 solid color-mix(in srgb, var(--bg) 70%, transparent); }
.crop-grid::before { inset: 0 calc(100% / 3); border-left-width: 1px; border-right-width: 1px; }
.crop-grid::after { inset: calc(100% / 3) 0; border-top-width: 1px; border-bottom-width: 1px; }
.crop-handle { --crop-o: calc(var(--crop-hit) / -2); position: absolute; width: var(--crop-hit); height: var(--crop-hit); touch-action: none; }
.crop-box.is-small .crop-handle { --crop-o: calc(var(--crop-hit) * -1); }
.crop-handle::after { content: ""; position: absolute; inset: calc(50% - 5px); background: var(--bg); box-shadow: 0 0 0 1px var(--ink); border-radius: 2px; }
.crop-handle[data-handle="nw"] { left: var(--crop-o); top: var(--crop-o); cursor: nwse-resize; }
.crop-handle[data-handle="n"] { left: calc(50% - var(--crop-hit) / 2); top: var(--crop-o); cursor: ns-resize; }
.crop-handle[data-handle="ne"] { right: var(--crop-o); top: var(--crop-o); cursor: nesw-resize; }
.crop-handle[data-handle="e"] { right: var(--crop-o); top: calc(50% - var(--crop-hit) / 2); cursor: ew-resize; }
.crop-handle[data-handle="se"] { right: var(--crop-o); bottom: var(--crop-o); cursor: nwse-resize; }
.crop-handle[data-handle="s"] { left: calc(50% - var(--crop-hit) / 2); bottom: var(--crop-o); cursor: ns-resize; }
.crop-handle[data-handle="sw"] { left: var(--crop-o); bottom: var(--crop-o); cursor: nesw-resize; }
.crop-handle[data-handle="w"] { left: var(--crop-o); top: calc(50% - var(--crop-hit) / 2); cursor: ew-resize; }
@media (prefers-reduced-motion: reduce) { .crop-box { transition: none; } }
/* forced colours drop the box shadows that draw the outline and the knobs: system colours draw them instead */
@media (forced-colors: active) {
  .crop-box:not(:focus-visible) { outline: 1px solid CanvasText; }
  .crop-handle::after { background: Canvas; border: 1px solid CanvasText; }
}

/* Crop's picture, its Ratio list and its fields (crop/island.tsx). The stage has the slot's height and is drawn as soon as a photo is
   chosen, so nothing moves when the picture arrives or a ratio is chosen. The frame is padded by the handles' hit size (--crop-hit, as
   on .crop), so a handle on the picture's edge stays inside it; nothing here clips (no overflow), and the room inside the padding is a
   size container whose largest box of the picture's shape (--ratio, from the island) holds the box, which takes all of its width. */
.crop-stage { --crop-hit: 24px; display: flex; flex-direction: column; gap: var(--s-3); min-width: 0; height: var(--slot-h); }
/* any-pointer, not pointer: the padding is never smaller than the box's own hit size (.crop's (pointer: coarse) rule), and is the larger
   one wherever any coarse pointer exists */
@media (any-pointer: coarse) { .crop-stage { --crop-hit: 44px; } }
.crop-frame { flex: 1 1 0; min-height: 0; min-width: 0; display: flex; padding: var(--crop-hit); border-radius: var(--r-md); background: var(--surface-0); }
.crop-room { flex: 1 1 0; min-width: 0; min-height: 0; container-type: size; display: grid; place-items: center; }
.crop-fit { width: min(100cqw, 100cqh * var(--ratio)); }
.crop-controls { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-4); font-size: 14px; line-height: 1.4; color: var(--text-1); }
.crop-controls label, .crop-custom { display: flex; align-items: center; gap: var(--s-2); }
.crop-custom { gap: var(--s-2) var(--s-4); flex-wrap: wrap; }
.crop-fields { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-4); }
.crop-fields legend { float: left; margin: 0 var(--s-2) 0 0; padding: 0; color: var(--text-2); }
.crop-controls select, .crop-controls input { min-width: 24px; min-height: 36px; padding: 0 var(--s-2); font: inherit; color: var(--text-1);
  background: var(--surface-0); border: 1px solid var(--border); border-radius: var(--r-sm); }
.crop-controls input { width: 6.5em; font-variant-numeric: tabular-nums; }
.crop-controls :disabled { opacity: .6; }
@media (min-width: 761px) { .tool-picture > .crop-stage { grid-column: 1; grid-row: 1; } }
/* phone: the picture keeps the slot's height and the fields wrap under it, so a long row of fields never shrinks the box */
@media (max-width: 760px) {
  .crop-stage { height: auto; }
  .crop-frame { flex: none; height: var(--slot-h); }
}

/* Rotate's angle (rotate/AngleControl.tsx and island.tsx). The picture and the guide share the frame's one grid cell, centred, so the
   guide sits on the picture's centre. The guide is sized in parts of the picture's longer side as drawn (--gw, --gh, from the island):
   with Fill the frame it is the rectangle the file keeps, outlined in --bg and --ink as Crop's box is, and the rest of the frame is
   dimmed (the frame clips the dim); with Keep everything the picture is drawn smaller (--tilt-scale) so the whole tilted picture fits.
   The grid shows only while the slider or the field is in use. Nothing here moves by itself, so there is no motion to reduce. */
.orient-frame > .preview, .orient-frame > .tilt-guide { grid-area: 1 / 1; }
.orient-frame > .preview.tilt-all { width: calc(min(100cqw, 100cqh) * var(--k, 1) * var(--tilt-scale, 1)); }
.tilt-guide { position: relative; width: calc(min(100cqw, 100cqh) * var(--gw)); height: calc(min(100cqw, 100cqh) * var(--gh)); pointer-events: none; }
.tilt-outline { box-shadow: inset 0 0 0 1px var(--bg), 0 0 0 1px var(--ink), 0 0 0 100vmax color-mix(in srgb, var(--ink) 55%, transparent); }
.tilt-grid { position: absolute; inset: 0; }
.tilt-grid::before, .tilt-grid::after { content: ""; position: absolute; border: 0 solid color-mix(in srgb, var(--bg) 70%, transparent); }
.tilt-grid::before { inset: 0 calc(100% / 3); border-left-width: 1px; border-right-width: 1px; }
.tilt-grid::after { inset: calc(100% / 3) 0; border-top-width: 1px; border-bottom-width: 1px; }
.tilt-hint { margin: 0; color: var(--text-2); }
/* the slider and the field are 44 px tall under a coarse pointer; touch-action is left to the browser */
@media (pointer: coarse) { .tool-settings .tilt-range, .tool-settings .tilt-field { min-height: 44px; } }
/* forced colours drop the shadows that draw the outline: a system-colour line instead */
@media (forced-colors: active) { .tilt-outline { outline: 1px solid CanvasText; } }

/* JPG to PDF (pdf/island.tsx, PdfList.tsx, PdfResult.tsx). With no list the island's wrapper adds no box: the dropzone fills the slot as on
   every tool page. With a list the wrapper is the slot's content, at least the slot's height, and the dropzone becomes a short bar that
   still takes more images; "Try a sample" is for the first choice only. Make PDF and the card sit above the list, so they stay near when
   a hundred rows make it long. */
.tool-pdf { grid-row: 1; display: grid; gap: var(--s-3); align-content: start; min-width: 0; }
.tool-pdf.is-empty { display: contents; }
.tool-pdf.is-empty > * { grid-column: 1 / -1; }
.tool-pdf.is-empty > .pdf-actions { justify-self: start; }
.tool:has(.tool-pdf:not(.is-empty)) { grid-template-rows: minmax(var(--slot-h), auto); }
.tool-pdf:not(.is-empty) > .dropzone { grid-row: auto; padding: var(--s-4) var(--s-5); gap: var(--s-1); }
.tool-pdf:not(.is-empty) .sample-button { display: none; }
.pdf-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
/* a primary action that is a button: the page's pill, filled (.tool button's own rules come first and are one class weaker) */
.tool button.button-primary { min-height: 44px; padding: 0 var(--s-5); background: var(--accent); color: var(--accent-ink); border-color: transparent; font-size: 16px; font-weight: 650; }
.tool button.button-primary:hover:not(:disabled) { border-color: transparent; filter: brightness(.94); }
/* Make PDF keeps the primary's size whether or not it is the primary (a fresh card makes Download PDF the primary): nothing moves when it changes */
.tool button.make { min-height: 44px; padding: 0 var(--s-5); font-size: 16px; font-weight: 650; }
/* with a list, "Choose images" is the way to add more, not the main action: the pill is outlined, so Make PDF (or Download PDF) is the one filled button */
.tool-pdf:not(.is-empty) .dropzone-button { background: var(--surface-0); color: var(--text-1); box-shadow: inset 0 0 0 1px var(--border); }
/* forced colours remove shadows: the outlined pill keeps an edge as a border */
@media (forced-colors: active) { .tool-pdf:not(.is-empty) .dropzone-button { border: 1px solid ButtonText; } }
/* The card's place: the job running, the PDF, or the stale line, one at a time, directly above the list, each at the height of the card (a
   little over it), so the list and the settings under it do not move when one replaces another. The card is 225 px on a computer and 250 on a
   phone at the default type size; a card made taller grows the place rather than overlap. Nothing is reserved before the first Make PDF. */
.tool-pdf { --pdf-slot-h: 232px; }
@media (max-width: 760px) { .tool-pdf { --pdf-slot-h: 256px; } }
.tool-pdf .result, .tool-pdf .pdf-making { min-height: var(--pdf-slot-h); align-content: start; }
.pdf-making { display: grid; gap: var(--s-3); padding: var(--s-4); border: 1px dashed var(--border); border-radius: var(--r-md); background: var(--surface-0); justify-items: start; }
.pdf-making p { margin: 0; color: var(--text-2); }
.tool-pdf .pdf-stale { padding: var(--s-4); border: 1px dashed var(--border); border-radius: var(--r-md); background: var(--surface-0); }
.pdf-stale p { margin: 0; color: var(--text-2); }
.pdf-refused ul { margin: var(--s-2) 0 0; padding-left: 1.25em; display: grid; gap: var(--s-1); }
.pdf-refused-name { font-weight: 650; overflow-wrap: anywhere; }
.pdf-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.pdf-row { display: grid; grid-template-columns: 56px minmax(0, 1fr); align-items: center; gap: var(--s-1) var(--s-3); margin: 0; padding: var(--s-2) var(--s-3);
  background: var(--surface-0); border: 1px solid var(--border); border-radius: var(--r-md); font-size: 14px; line-height: 1.4; }
.pdf-thumb { grid-row: 1 / span 2; width: 56px; height: 56px; object-fit: contain; background: var(--surface-2); border-radius: var(--r-sm); } /* the box is fixed, so a thumbnail arriving moves nothing */
.pdf-name { min-width: 0; overflow-wrap: anywhere; color: var(--text-1); }
.pdf-size { color: var(--text-2); font-variant-numeric: tabular-nums; }
.pdf-row-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: var(--s-2); }
@media (min-width: 761px) {
  .pdf-row { grid-template-columns: 56px minmax(0, 1fr) auto auto; gap: var(--s-2) var(--s-4); }
  .pdf-thumb { grid-row: auto; }
  .pdf-row-actions { grid-column: auto; flex-wrap: nowrap; }
}
/* touch: every button of a row is 44 px, and so is the main action */
@media (pointer: coarse) { .tool .pdf-row button, .tool button.button-primary { min-height: 44px; min-width: 44px; } }

/* PDF to JPG (pdfjpg/island.tsx, PageGrid.tsx, PdfJpgResult.tsx). With no PDF the island's wrapper adds no box: the dropzone fills the slot
   as on every tool page. With a PDF the wrapper is the slot's content, at least the slot's height: the dropzone becomes a short bar that
   takes another PDF, then the file's name and page count, Convert pages, the result's place and the pages. The page has no sample PDF, so
   render.ts prints no "Try a sample" button for it (R-19). Transparent background is for PNG only. */
.tool-settings:has(select[name="to"] option[value="png"]:not(:checked)) [data-when~="png"] { display: none; }
.tool-pdfjpg { --pdfjpg-place-h: 280px; --pdfjpg-pages-h: 300px; grid-row: 1; display: grid; gap: var(--s-3); align-content: start; min-width: 0; }
.tool-pdfjpg.is-empty { display: contents; }
.tool-pdfjpg.is-empty > * { grid-column: 1 / -1; }
.tool:has(.tool-pdfjpg:not(.is-empty)) { grid-template-rows: minmax(var(--slot-h), auto); }
.tool-pdfjpg:not(.is-empty) > .dropzone { grid-row: auto; padding: var(--s-4) var(--s-5); gap: var(--s-1); }
/* with a PDF, "Choose a PDF" replaces it and is not the main action: the pill is outlined, so Convert pages (or a download) is the one filled button */
.tool-pdfjpg:not(.is-empty) .dropzone-button { background: var(--surface-0); color: var(--text-1); box-shadow: inset 0 0 0 1px var(--border); }
/* Page range is the one text field of the tool pages: the number field's box, so it is a 36 px target like the selects beside it */
.tool-settings input[type="text"] { min-width: 24px; min-height: 36px; width: 10em; padding: 0 var(--s-2); font: inherit; color: var(--text-1);
  background: var(--surface-0); border: 1px solid var(--border); border-radius: var(--r-sm); }
.pdfjpg-file { margin: 0; color: var(--text-1); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.pdfjpg-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.pdfjpg-note { margin: 0; color: var(--text-2); }
/* Convert pages keeps the primary's size whether or not it is the primary: nothing moves when a result makes a download the primary */
.tool button.convert { min-height: 44px; padding: 0 var(--s-5); font-size: 16px; font-weight: 650; }
.tool button.convert[aria-disabled="true"] { cursor: default; opacity: .6; }
/* the range's message, beside the field; empty, it takes no room */
.tool-page .tool .pdfjpg-range-note { color: var(--danger-text); }
.pdfjpg-range-note:empty { display: none; }
/* The result's place: the run, the result or the stale line, one at a time, directly above the pages, each at the same fixed height, so the
   pages and the settings under them never move when one replaces another; a long result scrolls inside it. Nothing is reserved before the
   first Convert pages (the panel arrives with that click). The pages' place has its own fixed height: the opening panel, then the pages,
   which scroll inside it, so a PDF of 500 pages is as tall on the page as one of 3, and a page's picture arriving moves nothing. */
.pdfjpg-place { height: var(--pdfjpg-place-h); overflow: auto; box-sizing: border-box; }
.tool-pdfjpg .result.pdfjpg-place { align-content: start; padding: var(--s-1); }
.pdfjpg-making, .pdfjpg-opening, .tool-pdfjpg .pdfjpg-stale { display: grid; gap: var(--s-3); align-content: start; justify-items: start; padding: var(--s-4);
  border: 1px dashed var(--border); border-radius: var(--r-md); background: var(--surface-0); }
.pdfjpg-making p, .pdfjpg-opening p, .pdfjpg-stale p { margin: 0; color: var(--text-2); font-variant-numeric: tabular-nums; }
.pdfjpg-opening { height: var(--pdfjpg-pages-h); box-sizing: border-box; }
.pdfjpg-grid { list-style: none; margin: 0; padding: var(--s-2); height: var(--pdfjpg-pages-h); box-sizing: border-box; overflow-y: auto; display: grid;
  grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); align-content: start; gap: var(--s-3); background: var(--surface-0); border: 1px solid var(--border); border-radius: var(--r-md); }
.pdfjpg-page { margin: 0; min-width: 0; }
.pdfjpg-cell { display: grid; justify-items: center; gap: var(--s-2); padding: var(--s-2); background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-md); cursor: pointer; }
/* the picture's box is fixed (an A4 page's shape at 120 px wide): a picture arriving, or a wide page, moves nothing */
.pdfjpg-thumb { display: block; width: 120px; height: 170px; background: var(--surface-2); border-radius: var(--r-sm); overflow: hidden; }
.pdfjpg-thumb img { display: block; width: 100%; height: 100%; object-fit: contain; }
.pdfjpg-page.is-off .pdfjpg-thumb { opacity: .45; }
.pdfjpg-check { display: flex; align-items: center; gap: var(--s-2); min-height: 24px; font-size: 14px; line-height: 1.4; color: var(--text-1); font-variant-numeric: tabular-nums; }
.pdfjpg-check input { width: 24px; height: 24px; margin: 0; accent-color: var(--accent); }
.pdfjpg-made { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.pdfjpg-made-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; align-items: center; gap: var(--s-1) var(--s-3); margin: 0; padding: var(--s-2) var(--s-3);
  background: var(--surface-0); border: 1px solid var(--border); border-radius: var(--r-md); font-size: 14px; line-height: 1.4; }
/* a made page's picture is the grid's 120 px one drawn small (never the made file), or a plain box when the grid has not drawn it */
.pdfjpg-made-thumb { display: block; grid-row: 1 / span 2; width: 56px; height: 56px; object-fit: contain; background: var(--surface-2); border-radius: var(--r-sm); }
.pdfjpg-made-page { color: var(--text-1); }
.pdfjpg-made-size { grid-column: 2; color: var(--text-2); font-variant-numeric: tabular-nums; }
.pdfjpg-made-row > a { grid-column: 3; grid-row: 1 / span 2; }
.pdfjpg-made-row a.download:not(.button-primary) { display: inline-flex; align-items: center; min-height: 36px; padding: 0 var(--s-4); background: var(--surface-0);
  border: 1px solid var(--border); border-radius: var(--r-pill); color: var(--text-1); text-decoration: none; }
.pdfjpg-not-made { display: grid; gap: var(--s-1); }
.tool-page .tool .pdfjpg-not-made-title { margin: 0; font-size: 16px; line-height: 1.4; }
.pdfjpg-not-made ul { margin: 0; padding-left: 1.25em; display: grid; gap: var(--s-1); color: var(--text-2); }
/* forced colours remove shadows and backgrounds: the outlined pill keeps an edge, and a page's picture box keeps its outline */
@media (forced-colors: active) {
  .tool-pdfjpg:not(.is-empty) .dropzone-button { border: 1px solid ButtonText; }
  .pdfjpg-thumb, .pdfjpg-made-thumb { outline: 1px solid CanvasText; }
}
/* touch: every button and download of the page is 44 px, and so is each page's check box line (its whole cell toggles it too). The
   download's selector is as specific as the row's own 36 px rule above and comes after it, so it wins */
@media (pointer: coarse) { .tool .tool-pdfjpg button, .tool .pdfjpg-made-row a.download, .tool .pdfjpg-check { min-height: 44px; min-width: 44px; } }
