/* ImageTools stylesheet.
 *
 * One file, no build step, no framework. Everything below is driven by the
 * tokens in :root, so the dark theme is a second block of values rather than a
 * second set of rules.
 *
 * Light is the default on purpose: the OS preference is deliberately ignored so
 * the site looks the same to everybody until they press the theme button, and
 * an inline script in <head> applies their saved choice before first paint.
 */

/* ---------------------------------------------------------------- tokens -- */
:root {
  color-scheme: light;

  --bg: #ffffff;
  --bg-sunk: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --fg: #11161b;
  --fg-2: #39444e;
  --muted: #667281;
  --line: #e2e7ec;
  --line-strong: #cfd6de;

  --accent: #1763d6;
  --accent-hover: #114fad;
  --accent-soft: #eaf1fd;
  --accent-fg: #ffffff;

  --ok: #0a7a42;
  --ok-bg: #e9f7ef;
  --ok-line: #bde3cd;
  --ai: #6b3fd0;
  --ai-bg: #f2edfd;
  --ai-line: #d9ccf8;
  --warn: #8a5a00;
  --warn-bg: #fff6e3;
  --warn-line: #f0dcae;
  --danger: #b4231c;
  --danger-bg: #fdeceb;
  --danger-line: #f3c6c3;

  /* One spacing scale. Every gap on the page is a step on it. */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px; --s8: 72px;

  --r1: 6px; --r2: 10px; --r3: 14px; --r4: 20px; --rp: 999px;

  --shadow-1: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-2: 0 2px 4px rgba(16, 24, 40, .05), 0 6px 16px -6px rgba(16, 24, 40, .10);
  --shadow-3: 0 8px 28px -8px rgba(16, 24, 40, .18);

  --ease: cubic-bezier(.32, .72, .35, 1);
  --fast: 120ms var(--ease);
  --slow: 240ms var(--ease);

  --head-h: 60px;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0e1216;
  --bg-sunk: #0a0d11;
  --surface: #161b21;
  --surface-2: #1c232b;
  --fg: #eef2f6;
  --fg-2: #c2ccd6;
  --muted: #8b97a5;
  --line: #262e37;
  --line-strong: #37414d;

  --accent: #5a9bff;
  --accent-hover: #7cb0ff;
  --accent-soft: #14233c;
  --accent-fg: #06101f;

  --ok: #4ad68d;
  --ok-bg: #0f2a1d;
  --ok-line: #1d4a33;
  --ai: #b79bff;
  --ai-bg: #211a36;
  --ai-line: #3b2f5f;
  --warn: #f0c065;
  --warn-bg: #2c2312;
  --warn-line: #4a3c1c;
  --danger: #ff8a80;
  --danger-bg: #2c1614;
  --danger-line: #4d2722;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, .45), 0 10px 24px -10px rgba(0, 0, 0, .6);
  --shadow-3: 0 12px 34px -10px rgba(0, 0, 0, .7);
}

/* ------------------------------------------------------------- structure -- */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.62 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: "kern", "liga";
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 820px;
  margin: 0 auto;
  padding: var(--s6) var(--s4) var(--s8);
}
body.wide main { max-width: 1280px; }

h1, h2, h3 { line-height: 1.22; letter-spacing: -.018em; margin: 0 0 var(--s3); }
h1 { font-size: clamp(1.7rem, 1.25rem + 1.9vw, 2.4rem); font-weight: 750; }
h2 { font-size: 1.3rem; font-weight: 680; margin-top: var(--s6); }
h3 { font-size: 1.05rem; font-weight: 650; margin-top: var(--s5); }
p { margin: 0 0 var(--s3); }

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r1);
}

.lede { font-size: 1.08rem; color: var(--fg-2); max-width: 62ch; margin-bottom: var(--s5); }
.note { font-size: .92rem; color: var(--muted); }
.note a { color: inherit; text-decoration: underline; }
.sep, .arrow { color: var(--muted); }

.ic { width: 1.25em; height: 1.25em; flex: none; vertical-align: -.22em; }

/* ---------------------------------------------------------------- header -- */
.site-head {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  height: var(--head-h);
  padding: 0 var(--s4);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font-weight: 700;
  font-size: 1.06rem;
  letter-spacing: -.02em;
  color: var(--fg);
  text-decoration: none;
}
.brandmark { color: var(--accent); width: 1.5em; height: 1.5em; }
.site-head nav { display: flex; align-items: center; gap: var(--s1); }
.site-head nav a {
  padding: var(--s2) var(--s3);
  border-radius: var(--r2);
  color: var(--fg-2);
  text-decoration: none;
  font-size: .94rem;
  font-weight: 550;
  transition: background var(--fast), color var(--fast);
}
.site-head nav a { white-space: nowrap; }
.site-head nav a:hover { background: var(--surface-2); color: var(--fg); }
/* Three nav items plus the theme button is the ceiling at 375px. Tighten the
   padding rather than let "All tools" wrap and double the header height. */
@media (max-width: 420px) {
  .site-head { padding: 0 var(--s3); gap: var(--s2); }
  .site-head nav a { padding: var(--s2) 6px; font-size: .86rem; }
  .site-head .brand span { font-size: .98rem; }
  .themebtn { margin-left: 2px; width: 34px; height: 34px; }
}

.themebtn {
  display: inline-grid;
  place-items: center;
  width: 38px; height: 38px;
  margin-left: var(--s2);
  border: 1px solid var(--line);
  border-radius: var(--rp);
  background: var(--surface);
  color: var(--fg-2);
  cursor: pointer;
  transition: border-color var(--fast), color var(--fast), transform var(--fast);
}
.themebtn:hover { border-color: var(--line-strong); color: var(--fg); }
.themebtn:active { transform: scale(.94); }
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }

/* ---------------------------------------------------------------- footer -- */
.site-foot {
  border-top: 1px solid var(--line);
  margin-top: var(--s8);
  padding: var(--s6) var(--s4);
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
  background: var(--bg-sunk);
}
.site-foot p { margin: 0 0 var(--s2); }
.site-foot a { color: var(--fg-2); }

/* --------------------------------------------------------------- badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3.6rem;
  padding: 3px var(--s2);
  border-radius: var(--rp);
  border: 1px solid;
  font-size: .64rem;
  font-weight: 750;
  letter-spacing: .07em;
  text-transform: uppercase;
  white-space: nowrap;
  flex: none;
}
.b-free { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-line); }
.b-ai   { color: var(--ai); background: var(--ai-bg); border-color: var(--ai-line); }
.b-soon { color: var(--muted); background: var(--surface-2); border-color: var(--line); }

.legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s4);
  color: var(--muted); font-size: .88rem; margin-bottom: var(--s6);
}
.legend .badge { margin-right: var(--s1); }

/* --------------------------------------------------------------- cards ---- */
.cats { display: grid; gap: var(--s5); grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.cat { min-width: 0; }
.cat h2, section > h2 { display: flex; align-items: center; gap: var(--s2); margin-top: 0; font-size: 1.15rem; }
.cat h2 a, section > h2 a { color: var(--fg); text-decoration: none; display: inline-flex; align-items: center; gap: var(--s2); }
.cat h2 a:hover, section > h2 a:hover { color: var(--accent); }
.cat-ic, .h1-ic { color: var(--accent); }
.cat > p { color: var(--muted); font-size: .93rem; margin-bottom: var(--s3); }
.more { margin-top: var(--s3); font-size: .9rem; }

.tcards { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
body.wide .tcards { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }

.tcard > a, .tcard .tc-inner {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  padding: var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--r3);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  height: 100%;
  box-shadow: var(--shadow-1);
  transition: border-color var(--fast), box-shadow var(--fast), transform var(--fast);
}
.tcard > a:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-2);
  transform: translateY(-2px);
}
.tcard.is-soon .tc-inner { background: var(--surface-2); box-shadow: none; opacity: .78; }
.tc-ic {
  display: grid; place-items: center;
  width: 40px; height: 40px; flex: none;
  border-radius: var(--r2);
  background: var(--accent-soft);
  color: var(--accent);
}
.tcard.is-soon .tc-ic { background: var(--bg-sunk); color: var(--muted); }
.tc-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tc-top { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.tc-name { font-weight: 640; letter-spacing: -.01em; }
.tc-blurb { color: var(--muted); font-size: .88rem; line-height: 1.45; }
.tcard.empty { color: var(--muted); font-size: .9rem; padding: var(--s3); }

.wip { margin-top: var(--s3); }
.wip summary { cursor: pointer; color: var(--muted); font-size: .9rem; padding: var(--s2) 0; }
.wip[open] summary { margin-bottom: var(--s2); }

/* ---------------------------------------------------------- breadcrumbs --- */
.breadcrumbs ol {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1);
  list-style: none; margin: 0 0 var(--s3); padding: 0;
  font-size: .85rem; color: var(--muted);
}
.breadcrumbs li { display: inline-flex; align-items: center; gap: var(--s1); }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent); text-decoration: underline; }
.breadcrumbs .sep { opacity: .6; }
.breadcrumbs [aria-current] { color: var(--fg-2); }

.toolmark {
  display: flex; align-items: center; gap: var(--s2);
  font-size: .9rem; margin-bottom: var(--s3);
}
.toolmark-ic { color: var(--accent); }
.toolmark a { color: var(--fg-2); text-decoration: none; font-weight: 550; }
.toolmark a:hover { color: var(--accent); }

/* ------------------------------------------------------------ tool page --- */
/* The workbench is one grid. On a wide screen the controls sit beside the
 * result instead of above it, so a slider and the image it changes are visible
 * at the same time - the single biggest usability problem with the old layout
 * was scrolling away from the control to see what it did. */
.tool { display: grid; gap: 0 var(--s5); grid-template-columns: 1fr; }
.tool > * { min-width: 0; }

@media (min-width: 1040px) {
  body.tool-page main { max-width: 1200px; }
  .tool {
    grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
    grid-template-areas:
      "crumbs crumbs" "mark mark" "h1 h1" "lede lede" "adtop adtop"
      "drop  result" "controls result" "pad result"
      "spec spec" "admid admid" "faq faq" "related related" "cross cross";
    align-items: start;
  }
  .tool > .breadcrumbs { grid-area: crumbs; }
  .tool > .toolmark { grid-area: mark; }
  .tool > h1 { grid-area: h1; }
  .tool > .lede { grid-area: lede; }
  .tool > .ad-top { grid-area: adtop; }
  .tool > .dropzone { grid-area: drop; }
  .tool > .controls { grid-area: controls; position: sticky; top: calc(var(--head-h) + var(--s4)); }
  .tool > .result { grid-area: result; margin-top: 0; }
  .tool > .spec { grid-area: spec; }
  .tool > .ad-mid { grid-area: admid; }
  .tool > .faq { grid-area: faq; }
  .tool > .related { grid-area: related; }
  .tool > .crosslinks { grid-area: cross; }
}

/* ------------------------------------------------------------- dropzone --- */
.dropzone {
  position: relative;
  display: block;
  padding: var(--s6) var(--s4);
  margin-bottom: var(--s4);
  border: 2px dashed var(--line-strong);
  border-radius: var(--r4);
  background:
    linear-gradient(var(--surface-2), var(--surface-2)) padding-box;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--fast), background var(--fast), transform var(--fast);
}
.dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.over {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: scale(1.005);
}
.dropzone:focus-within { border-color: var(--accent); }
/* The native file input is the most dated-looking element a browser has, and
 * the whole panel is the click target anyway. */
.dropzone input[type=file] {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.dropzone p { margin: 0; font-weight: 550; color: var(--fg-2); }
.dropzone p + p { margin-top: var(--s2); font-weight: 400; }
.dropzone label { color: var(--accent); text-decoration: underline; cursor: pointer; }
.dropzone::before {
  content: "";
  display: block;
  width: 40px; height: 40px;
  margin: 0 auto var(--s3);
  border-radius: var(--r2);
  background: var(--accent-soft);
  color: var(--accent);
  /* An upload glyph, inlined so there is nothing extra to fetch. */
  -webkit-mask: center / 22px 22px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpath d='M7 9l5-5 5 5M12 4v12'/%3E%3C/svg%3E");
          mask: center / 22px 22px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpath d='M7 9l5-5 5 5M12 4v12'/%3E%3C/svg%3E");
  background-color: var(--accent);
}
.dropzone.has-file { padding: var(--s4); border-style: solid; border-color: var(--line); }
.dropzone.has-file::before { display: none; }

.picked {
  display: flex; align-items: center; justify-content: center;
  flex-wrap: wrap; gap: var(--s2) var(--s3);
  margin: var(--s3) 0 0 !important;
  font-size: .9rem;
}
.pk-name {
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--fg-2); font-weight: 550;
}
.pk-change {
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--fg-2); border-radius: var(--rp);
  padding: 5px var(--s3); font: inherit; font-size: .85rem; cursor: pointer;
  transition: border-color var(--fast), color var(--fast);
}
.pk-change:hover { border-color: var(--accent); color: var(--accent); }

/* ------------------------------------------------------------- controls --- */
.controls {
  display: grid;
  gap: var(--s3);
  padding: var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--r3);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  margin-bottom: var(--s4);
}
.controls > label {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px var(--s3);
  font-size: .88rem;
  font-weight: 550;
  color: var(--fg-2);
}
.controls > label > input[type=range] { grid-column: 1 / -1; }
.controls > label > output {
  grid-row: 1;
  grid-column: 2;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  color: var(--fg);
  font-size: .86rem;
  min-width: 2.6em;
  text-align: right;
}
.controls > label.chk, .controls > label:has(> input[type=checkbox]) {
  grid-template-columns: auto 1fr;
  align-items: center;
}
.controls > label > input[type=checkbox] { grid-column: 1; margin: 0; }
.controls p.note { margin: 0; grid-column: 1 / -1; }

.controls input[type=number],
.controls input[type=text],
.controls select,
.controls textarea {
  grid-column: 1 / -1;
  width: 100%;
  padding: 9px var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r2);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: .92rem;
  transition: border-color var(--fast), box-shadow var(--fast);
}
.controls input:focus, .controls select:focus, .controls textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}
.controls input[type=color] {
  grid-column: 2; grid-row: 1;
  width: 46px; height: 30px; padding: 2px;
  border: 1px solid var(--line-strong); border-radius: var(--r1);
  background: var(--bg); cursor: pointer;
}
.controls label.focus {
  padding: var(--s2) var(--s3);
  margin: calc(var(--s2) * -1) calc(var(--s3) * -1);
  border: 1px solid var(--accent);
  border-radius: var(--r2);
  background: var(--accent-soft);
}

/* Sliders. The primary interaction on this site was the least designed element
 * on it: a native range wrapped in a border, with no indication of where the
 * value sat along the track. */
.controls input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 22px;
  background: transparent; cursor: pointer; padding: 0; border: 0;
}
.controls input[type=range]::-webkit-slider-runnable-track {
  height: 5px; border-radius: var(--rp); background: var(--line);
}
.controls input[type=range]::-moz-range-track {
  height: 5px; border-radius: var(--rp); background: var(--line);
}
.controls input[type=range]::-moz-range-progress {
  height: 5px; border-radius: var(--rp); background: var(--accent);
}
.controls input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 17px; height: 17px; margin-top: -6px;
  border-radius: var(--rp);
  background: var(--accent);
  border: 2px solid var(--surface);
  box-shadow: var(--shadow-1);
  transition: transform var(--fast);
}
.controls input[type=range]::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: var(--rp);
  background: var(--accent); border: 2px solid var(--surface);
}
.controls input[type=range]:active::-webkit-slider-thumb { transform: scale(1.18); }
.controls input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--accent-soft); }

/* --------------------------------------------------------------- result --- */
.result { margin-top: var(--s4); }
.preview {
  margin: 0 0 var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--r3);
  overflow: hidden;
  background:
    conic-gradient(from 90deg at 50% 50%, #e9edf1 25%, #fff 0 50%, #e9edf1 0 75%, #fff 0) 0 0 / 18px 18px;
}
:root[data-theme="dark"] .preview {
  background: conic-gradient(from 90deg at 50% 50%, #1b2128 25%, #131820 0 50%, #1b2128 0 75%, #131820 0) 0 0 / 18px 18px;
}
.preview img, .result > img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 70vh;
  object-fit: contain;
}
.preview-inline {
  display: block; max-width: 100%; height: auto;
  border: 1px solid var(--line); border-radius: var(--r2); margin-bottom: var(--s3);
}

.resultbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3);
  justify-content: space-between;
  padding: var(--s3) var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--r3);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  margin-bottom: var(--s4);
}
.stats { margin: 0; font-size: .95rem; color: var(--fg-2); font-variant-numeric: tabular-nums; }
.stats strong { color: var(--fg); }
.pill {
  display: inline-block; padding: 1px var(--s2); margin-left: var(--s1);
  border-radius: var(--rp); font-size: .78rem; font-weight: 650;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.pill.good { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }

.download {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 42px;
  padding: 10px var(--s5);
  border: 0; border-radius: var(--r2);
  background: var(--accent); color: var(--accent-fg);
  font: inherit; font-weight: 650; font-size: .94rem;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow-1);
  transition: background var(--fast), transform var(--fast), box-shadow var(--fast);
}
.download:hover { background: var(--accent-hover); color: var(--accent-fg); box-shadow: var(--shadow-2); }
.download:active { transform: translateY(1px); }
.download[disabled] { opacity: .55; cursor: progress; }

/* ---------------------------------------------------- busy and failures --- */
.busy {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s5);
  border: 1px solid var(--line); border-radius: var(--r3);
  background: var(--surface-2); color: var(--fg-2);
}
.busy p { margin: 0; font-size: .95rem; }
.spinner {
  width: 20px; height: 20px; flex: none;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: var(--rp);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.errorcard {
  padding: var(--s4);
  border: 1px solid var(--danger-line);
  border-left: 3px solid var(--danger);
  border-radius: var(--r3);
  background: var(--danger-bg);
}
.err-title { margin: 0 0 var(--s1); font-weight: 650; color: var(--danger); }
.err-detail { margin: 0 0 var(--s2); font-size: .92rem; color: var(--fg-2); }
.err-hint { margin: 0; font-size: .9rem; color: var(--fg-2); }
.error { color: var(--danger); }

.warn {
  padding: var(--s3) var(--s4);
  margin-bottom: var(--s4);
  border: 1px solid var(--warn-line);
  border-left: 3px solid var(--warn);
  border-radius: var(--r2);
  background: var(--warn-bg);
  color: var(--warn);
  font-size: .92rem;
}

/* ---------------------------------------------- interactive tool stages --- */
.stage {
  position: relative;
  display: block;
  width: 100%;
  line-height: 0;
  touch-action: none;
  border-radius: var(--r3);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.stage canvas { width: 100%; height: auto; display: block; }
.stage .overlay { position: absolute; inset: 0; pointer-events: none; }
.stage.picking { cursor: crosshair; }
.stage.checker {
  background: conic-gradient(from 90deg at 50% 50%, #e9edf1 25%, #fff 0 50%, #e9edf1 0 75%, #fff 0) 0 0 / 18px 18px;
}
:root[data-theme="dark"] .stage.checker {
  background: conic-gradient(from 90deg at 50% 50%, #1b2128 25%, #131820 0 50%, #1b2128 0 75%, #131820 0) 0 0 / 18px 18px;
}

.cropbox {
  position: absolute;
  border: 1px solid #fff;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .45);
  cursor: move;
}
.cropbox .thirds {
  position: absolute; inset: 0;
  background:
    linear-gradient(to right, transparent 33.33%, rgba(255,255,255,.45) 33.33% 33.5%, transparent 33.5% 66.5%, rgba(255,255,255,.45) 66.5% 66.66%, transparent 66.66%),
    linear-gradient(to bottom, transparent 33.33%, rgba(255,255,255,.45) 33.33% 33.5%, transparent 33.5% 66.5%, rgba(255,255,255,.45) 66.5% 66.66%, transparent 66.66%);
  pointer-events: none;
}
.grip {
  position: absolute;
  width: 16px; height: 16px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, .35);
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
}
.g-nw { left: -8px; top: -8px; cursor: nwse-resize; }
.g-n  { left: calc(50% - 8px); top: -8px; cursor: ns-resize; }
.g-ne { right: -8px; top: -8px; cursor: nesw-resize; }
.g-e  { right: -8px; top: calc(50% - 8px); cursor: ew-resize; }
.g-se { right: -8px; bottom: -8px; cursor: nwse-resize; }
.g-s  { left: calc(50% - 8px); bottom: -8px; cursor: ns-resize; }
.g-sw { left: -8px; bottom: -8px; cursor: nesw-resize; }
.g-w  { left: -8px; top: calc(50% - 8px); cursor: ew-resize; }

.btnrow { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin: var(--s4) 0; }
.btnrow .spacer { flex: 1 1 auto; }
.btnrow button:not(.download) {
  min-height: 38px;
  padding: var(--s2) var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r2);
  background: var(--surface);
  color: var(--fg-2);
  font: inherit; font-size: .9rem; cursor: pointer;
  transition: border-color var(--fast), color var(--fast), background var(--fast);
}
.btnrow button:not(.download):hover:not([disabled]) { border-color: var(--accent); color: var(--accent); }
.btnrow button[disabled] { opacity: .45; cursor: not-allowed; }

.brushbar {
  display: grid; gap: var(--s3);
  padding: var(--s3);
  border: 1px solid var(--line); border-radius: var(--r3);
  background: var(--surface); box-shadow: var(--shadow-1);
  margin-bottom: var(--s3);
}
.toolpicker { display: flex; flex-wrap: wrap; gap: var(--s1); }
.tbtn {
  min-height: 38px;
  padding: var(--s2) var(--s3);
  border: 1px solid var(--line); border-radius: var(--r2);
  background: var(--surface-2); color: var(--fg-2);
  font: inherit; font-size: .88rem; font-weight: 550; cursor: pointer;
  transition: all var(--fast);
}
.tbtn:hover { border-color: var(--accent); color: var(--accent); }
.tbtn.on { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.brushopts { display: flex; flex-wrap: wrap; gap: var(--s3) var(--s4); align-items: center; }
.brushopts label { display: flex; align-items: center; gap: var(--s2); font-size: .86rem; color: var(--fg-2); }
.brushopts input[type=range] { width: 130px; }
.brushopts output { font-variant-numeric: tabular-nums; font-weight: 650; min-width: 2.2em; }
.brushopts input[type=color] { width: 38px; height: 28px; padding: 2px; border: 1px solid var(--line-strong); border-radius: var(--r1); background: var(--bg); }

/* ------------------------------------------------------------- readouts --- */
.swatches, .tiles {
  list-style: none; padding: 0; margin: var(--s4) 0;
  display: grid; gap: var(--s3);
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.swatch { border: 1px solid var(--line); border-radius: var(--r2); overflow: hidden; background: var(--surface); }
.swatch .chip { height: 60px; }
.swatch .vals { padding: var(--s2); font-size: .78rem; line-height: 1.6; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.swatch .share { color: var(--muted); }

.tiles li { display: flex; flex-direction: column; gap: var(--s2); }
.tiles img { width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--r2); display: block; }
.tiles .download { padding: 6px var(--s3); font-size: .84rem; min-height: 34px; }

.meta, .spec {
  width: 100%; border-collapse: collapse; margin: var(--s4) 0; font-size: .92rem;
  border: 1px solid var(--line); border-radius: var(--r2); overflow: hidden;
}
.meta th, .meta td, .spec th, .spec td {
  text-align: left; padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line); vertical-align: top;
}
.meta tr:last-child td, .meta tr:last-child th, .spec tr:last-child td, .spec tr:last-child th { border-bottom: 0; }
.meta th, .spec th { color: var(--muted); font-weight: 550; width: 40%; background: var(--surface-2); }
.spec caption { text-align: left; font-weight: 650; padding-bottom: var(--s2); }

.fieldlist { margin: var(--s3) 0; padding-left: var(--s5); font-size: .92rem; color: var(--fg-2); }
.fieldlist li { margin-bottom: var(--s1); }

.copybox {
  width: 100%;
  padding: var(--s3);
  border: 1px solid var(--line-strong); border-radius: var(--r2);
  background: var(--surface-2); color: var(--fg);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .8rem; line-height: 1.55; resize: vertical;
}
img.hist {
  width: 100%; max-width: 560px; height: auto;
  border: 1px solid var(--line); border-radius: var(--r2); background: #0d1117;
}

/* ----------------------------------------------------------------- FAQ ---- */
.faq { margin-top: var(--s6); }
.faq details {
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: var(--surface);
  margin-bottom: var(--s2);
  overflow: hidden;
}
.faq summary {
  cursor: pointer;
  padding: var(--s3) var(--s4);
  font-weight: 600;
  font-size: .96rem;
  list-style: none;
  display: flex; justify-content: space-between; align-items: center; gap: var(--s3);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--muted); font-size: 1.25rem; line-height: 1; }
.faq details[open] summary::after { content: "\2212"; }
.faq details[open] summary { border-bottom: 1px solid var(--line); }
.faq .answer { padding: var(--s3) var(--s4); color: var(--fg-2); font-size: .94rem; }
.faq .answer p:last-child { margin-bottom: 0; }

/* -------------------------------------------------------------- guides ---- */
/* Long-form editorial. The tool pages are an interface; these are something to
   read, so the type gets more room and the measure is held near 70 characters -
   past that the eye loses the line on the way back. */
.guide { max-width: 68ch; }
.guide h2 { margin-top: var(--s7); padding-top: var(--s2); }
.guide h3 { margin-top: var(--s5); font-size: 1.06rem; font-weight: 650; }
.guide p { margin-bottom: var(--s4); color: var(--fg-2); }
.guide p.lede { color: var(--fg); font-size: 1.12rem; }
.guide ul, .guide ol { margin: 0 0 var(--s4); padding-left: var(--s5); color: var(--fg-2); }
.guide li { margin-bottom: var(--s2); }
.guide li:last-child { margin-bottom: 0; }
.guide strong { color: var(--fg); font-weight: 650; }
.guide code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .88em;
  padding: 1px 5px;
  border-radius: var(--r1);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.guide .byline { color: var(--muted); font-size: .85rem; margin: calc(-1 * var(--s2)) 0 var(--s5); }

/* The comparison tables here are matrices, not the two-column key/value shape
   .spec was written for, so the 40% first column and the row-header colouring
   both have to be undone. */
.guide .spec { margin: 0 0 var(--s5); }
.guide .spec th { width: auto; }
.guide .spec th:first-child { text-align: left; }
.guide .spec tr:first-child th { color: var(--fg); font-weight: 650; text-align: left; }
.guide .spec td { text-align: left; }

/* Guide cards, on the index and at the foot of every guide. */
.gcards { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3);
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
/* The index is a wide page and gets three across; the foot of a guide is inside
   a 68ch measure and gets two. */
body.wide .gcards { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.gcard a {
  display: flex; flex-direction: column; gap: 6px; height: 100%;
  padding: var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--r3);
  background: var(--surface);
  text-decoration: none;
  transition: border-color var(--fast), transform var(--fast);
}
.gcard a:hover { border-color: var(--accent); transform: translateY(-1px); }
.gcard .gc-title { color: var(--fg); font-weight: 650; line-height: 1.3; }
.gcard .gc-desc { color: var(--fg-2); font-size: .9rem; line-height: 1.45; }
.gcard .gc-date { color: var(--muted); font-size: .78rem; margin-top: auto; padding-top: var(--s2); }

@media (max-width: 560px) {
  /* A five-column matrix cannot fit a phone; let it scroll rather than wrap
     every cell onto four lines. */
  .guide .spec { display: block; overflow-x: auto; white-space: nowrap; }
}

/* ---------------------------------------------------------------- gear ---- */
/* Affiliate block at the foot of a guide. Deliberately reads as an aside rather
   than as content: tinted, boxed, and labelled. Anything that could be mistaken
   for editorial recommendation is both dishonest and, for AdSense, dangerous. */
.gear {
  margin-top: var(--s7);
  padding: var(--s4) var(--s5);
  border: 1px solid var(--line);
  border-radius: var(--r3);
  background: var(--surface-2);
}
.gear h2 { margin-top: 0; font-size: 1.05rem; }
.gear ul { list-style: none; margin: 0; padding: 0; }
.gear li { display: flex; flex-direction: column; gap: 2px; padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
.gear li:last-child { border-bottom: 0; padding-bottom: 0; }
.gear .amzn { font-weight: 620; }
.gear .amzn-note { color: var(--muted); font-size: .88rem; line-height: 1.45; }
.gear .disclosure { margin: var(--s3) 0 0; color: var(--muted); font-size: .78rem; line-height: 1.5; }

/* ------------------------------------------------------------- related ---- */
/* Sideways links out of the long tail. Visually quieter than the hub grids -
   this is a footnote to the tool, not the main event - but still real cards,
   because a row of bare text links reads as boilerplate and gets ignored. */
.crosslinks { margin-top: var(--s7); padding-top: var(--s5); border-top: 1px solid var(--line); }
.crosslinks h2 { font-size: 1.05rem; margin-bottom: var(--s3); }
.crosslinks .tcards { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.crosslinks .tcard .tc-blurb { display: none; }
@media (min-width: 640px) { .crosslinks .tcard .tc-blurb { display: block; } }

.related { margin-top: var(--s6); }
.related h2 { font-size: 1.05rem; margin-bottom: var(--s3); }
.related ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s2); }
.related a {
  display: inline-block;
  padding: 6px var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--rp);
  background: var(--surface);
  color: var(--fg-2);
  font-size: .87rem;
  text-decoration: none;
  transition: border-color var(--fast), color var(--fast);
}
.related a:hover { border-color: var(--accent); color: var(--accent); }

/* -------------------------------------------------------------- pricing --- */
.packs { list-style: none; padding: 0; margin: var(--s4) 0; display: grid; gap: var(--s3); }
.packs li {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3);
  padding: var(--s4); border: 1px solid var(--line); border-radius: var(--r3);
  background: var(--surface); box-shadow: var(--shadow-1);
}
.per { color: var(--muted); font-size: .88rem; flex: 1 1 auto; }
.buy {
  min-height: 40px; padding: var(--s2) var(--s5);
  border: 0; border-radius: var(--r2);
  background: var(--accent); color: var(--accent-fg);
  font: inherit; font-weight: 650; cursor: pointer;
}
.buy:hover { background: var(--accent-hover); }

/* ------------------------------------------------------------------ ads --- */
/* Reserving the height stops the page jumping under the pointer when the slot
 * fills, which used to happen directly above the dropzone people were aiming at. */
.ad { min-height: 100px; margin: var(--s5) 0; }
.ad:empty { display: none; }

/* ----------------------------------------------------------- responsive --- */
@media (max-width: 640px) {
  :root { --head-h: 54px; }
  main { padding: var(--s5) var(--s4) var(--s7); }
  .site-head { padding: 0 var(--s3); }
  .site-head nav a { padding: var(--s2); font-size: .88rem; }
  .cats { grid-template-columns: 1fr; }
  .dropzone { padding: var(--s5) var(--s3); }
  .resultbar { flex-direction: column; align-items: stretch; }
  .resultbar .download { width: 100%; }
  /* Comfortable touch targets: 30px controls are a miss on a phone. */
  .controls input[type=number], .controls input[type=text], .controls select { min-height: 44px; }
  .btnrow button:not(.download), .tbtn { min-height: 44px; }
  .grip { width: 22px; height: 22px; }
  .g-nw, .g-w, .g-sw { left: -11px; }
  .g-ne, .g-e, .g-se { right: -11px; }
  .g-nw, .g-n, .g-ne { top: -11px; }
  .g-sw, .g-s, .g-se { bottom: -11px; }
  .g-n, .g-s { left: calc(50% - 11px); }
  .g-e, .g-w { top: calc(50% - 11px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .site-head, .site-foot, .ad, .dropzone, .controls, .related, .crosslinks, .gear, .btnrow, .themebtn { display: none !important; }
  body { background: #fff; color: #000; }
  main { max-width: none; padding: 0; }
  .meta, .spec { border-color: #999; }
}
