/* Omar's image optimiser. One ultramarine canvas is where you start; white trays, chips and rows sit on a bright
   cool-white ground; sunshine yellow is kept for one thing only: how much smaller a file got. */

@font-face {
  font-family: "Madefor Display";
  src: url("fonts/wix-madefor-display.woff2") format("woff2");
  font-weight: 500 700;
  font-display: swap;
}
@font-face {
  font-family: "Madefor Text";
  src: url("fonts/wix-madefor-text.woff2") format("woff2");
  font-weight: 400 600;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ground: #f4f5fa;
  --surface: #ffffff;
  --sunk: #eef0f7;
  --line: #e3e6f0;
  --line-strong: #cbd0e2;
  --ink: #0d1135;
  --ink-2: #4c5276;
  --ink-3: #8a8fab;

  --brand: #2b3ff5;
  --brand-hover: #1f32de;
  --brand-press: #1928bf;
  --brand-ink: #2235d9;      /* brand-coloured text and rings on white */
  --brand-wash: #eceeff;
  --on-brand: #ffffff;
  --on-brand-2: rgb(255 255 255 / 0.92);
  --on-brand-line: rgb(255 255 255 / 0.5);

  --pop: #ffd43b;            /* how much smaller: nothing else uses it */
  --on-pop: #0d1135;
  --pop-wash: #fff2bf;       /* the saved part of a size gauge */

  --danger: #c22a32;
  --danger-wash: #fdecee;
  --veil: rgb(13 17 53 / 0.45);
  --check-a: #eceef6;
  --check-b: #f8f9fc;

  --shadow-card: 0 1px 2px rgb(16 24 80 / 0.05), 0 12px 32px -18px rgb(16 24 80 / 0.22);
  --shadow-lift: 0 2px 6px rgb(16 24 80 / 0.08), 0 28px 56px -20px rgb(16 24 80 / 0.38);
  --shadow-canvas: 0 2px 4px rgb(27 40 191 / 0.12), 0 34px 60px -34px rgb(27 40 191 / 0.7);
  --shadow-knob: 0 1px 3px rgb(16 24 80 / 0.25), 0 4px 10px -4px rgb(16 24 80 / 0.3);

  --display: "Madefor Display", "Segoe UI", system-ui, sans-serif;
  --text: "Madefor Text", "Segoe UI", system-ui, sans-serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  /* A soft spring for presses: settles with one small overshoot. */
  --spring: linear(0, 0.18 4%, 0.6 13%, 0.92 24%, 1.04 34%, 1.06 41%, 1.03 54%, 1 70%, 1);
}
@supports not (transition-timing-function: linear(0, 1)) {
  :root { --spring: var(--ease-out); }
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding: 96px 0 120px; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 16px/1.55 var(--text);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
.sprite { position: absolute; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
/* On the ultramarine canvas a blue ring would vanish: the target, and the buttons sitting straight on blue, ring in white. */
.target:focus-visible, .target :focus-visible, .band :focus-visible { outline-color: var(--on-brand); }
.icon {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }

.wrap { width: min(100% - 32px, 1040px); margin-inline: auto; }

/* Phones and tablets can't drag or paste files onto a page, so they get their own words. */
.for-touch { display: none; }
@media (hover: none) and (pointer: coarse) {
  .for-pointer { display: none; }
  .for-touch { display: inline; }
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border: 1.5px solid transparent; border-radius: 14px;
  font: 600 15px/1 var(--text); white-space: nowrap; text-decoration: none;
  transition: transform 520ms var(--spring), background-color 160ms, border-color 160ms, color 160ms;
}
.btn:active:not(:disabled) { transform: scale(0.96); transition-duration: 90ms; transition-timing-function: ease-out; }
.btn .icon { width: 18px; height: 18px; }
.btn-lg { min-height: 54px; padding: 0 26px; font-size: 16px; border-radius: 16px; }
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn-primary:active:not(:disabled) { background: var(--brand-press); }
/* On the ultramarine canvas the action turns white. */
.btn-invert { background: var(--surface); color: var(--brand-ink); box-shadow: 0 1px 2px rgb(13 17 53 / 0.16), 0 8px 20px -10px rgb(13 17 53 / 0.5); }
.btn-invert:hover:not(:disabled) { background: var(--brand-wash); }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-secondary:hover:not(:disabled) { border-color: var(--brand-ink); color: var(--brand-ink); }
.btn-quiet { background: transparent; color: var(--ink-2); padding: 0 12px; }
.btn-quiet:hover:not(:disabled) { color: var(--ink); background: var(--sunk); }
/* Disabled actions lose the colour entirely. */
.btn:disabled { background: var(--sunk); border-color: transparent; color: var(--ink-3); cursor: not-allowed; box-shadow: none; }

.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 0; border-radius: 14px; background: transparent; color: var(--ink-2);
  transition: transform 520ms var(--spring), background-color 160ms, color 160ms;
}
.icon-btn:hover { background: var(--sunk); color: var(--ink); }
.icon-btn:active { transform: scale(0.92); transition-duration: 90ms; }

.link-btn {
  border: 0; background: none; padding: 8px 2px; flex: none;
  font-weight: 600; color: var(--ink-2);
  text-decoration: underline; text-decoration-color: var(--line-strong);
  text-underline-offset: 4px; text-decoration-thickness: 1.5px;
}
.link-btn:hover { color: var(--ink); text-decoration-color: currentColor; }

/* ---------- header ---------- */

.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 0 14px; }
.brand {
  display: inline-flex; align-items: center; gap: 12px; text-decoration: none;
  font: 600 17px/1.2 var(--display); letter-spacing: -0.01em;
}
.mark { width: 34px; height: 34px; flex: none; }
.mark-tile { fill: var(--brand); }
.mark-frame { fill: none; stroke: #fff; stroke-opacity: 0.55; stroke-width: 1.75; }
.mark-fill { fill: #fff; }
.top-link {
  font-weight: 600; font-size: 15px; color: var(--ink-2); text-decoration: none;
  padding: 10px 12px; margin-right: -12px; border-radius: 12px;
}
.top-link:hover { color: var(--ink); background: var(--sunk); }

/* ---------- the canvas ---------- */

.canvas {
  position: relative; isolation: isolate; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px 44px;
  padding: clamp(22px, 4vw, 44px);
  border-radius: 32px;
  background: var(--brand); color: var(--on-brand);
  box-shadow: var(--shadow-canvas);
}
/* The transparency grid every image editor shows behind a picture, faint, and fading out toward the middle. */
.canvas::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: repeating-conic-gradient(rgb(255 255 255 / 0.075) 0 25%, transparent 0 50%) 0 0 / 32px 32px;
  -webkit-mask-image: radial-gradient(130% 110% at 0% 100%, #000 0%, transparent 62%);
  mask-image: radial-gradient(130% 110% at 0% 100%, #000 0%, transparent 62%);
}

.intro { align-self: center; padding-block: 8px; }
.intro h1 {
  font: 600 clamp(2.6rem, 1.5rem + 4vw, 4.4rem)/1 var(--display);
  letter-spacing: -0.038em;
  text-wrap: balance;
}
.lede {
  margin-top: 20px; max-width: 34ch;
  font-size: clamp(1.05rem, 1rem + 0.3vw, 1.2rem); line-height: 1.5; color: var(--on-brand-2);
  text-wrap: pretty;
}

.target {
  display: grid; justify-items: center; align-content: center; text-align: center; gap: 6px;
  min-height: 300px; padding: 28px 20px;
  border-radius: 24px; border: 2px dashed var(--on-brand-line);
  background: rgb(255 255 255 / 0.07);
  cursor: pointer;
  transition: background-color 200ms, border-color 200ms;
}
.target:hover { background: rgb(255 255 255 / 0.11); border-color: rgb(255 255 255 / 0.75); }
.target-icon {
  display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 8px;
  border-radius: 18px; background: rgb(255 255 255 / 0.14); color: var(--on-brand);
}
.target-icon .icon { width: 28px; height: 28px; stroke-width: 1.6; }
.target-title { font: 600 clamp(1.4rem, 1.25rem + 0.6vw, 1.7rem)/1.15 var(--display); letter-spacing: -0.02em; }
.target-sub { color: var(--on-brand-2); }
.target .btn { margin-top: 16px; }
.target-formats { margin-top: 8px; font-size: 14px; color: var(--on-brand-2); }

.band { display: none; }

/* The tray: what the images are for, chosen in the same place they're dropped. */
.tray {
  grid-column: 1 / -1;
  display: grid; gap: 10px;
  padding: 12px 12px 14px 20px;
  border-radius: 22px; background: var(--surface); color: var(--ink);
}
.tray-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; }
.tray-label { font-weight: 600; font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 auto; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px;
  border-radius: 999px; border: 1.5px solid var(--line);
  font-weight: 600; font-size: 15px; color: var(--ink-2); white-space: nowrap;
  transition: background-color 160ms, border-color 160ms, color 160ms, transform 520ms var(--spring);
}
.chip:hover span { border-color: var(--line-strong); color: var(--ink); }
.chip:active span { transform: scale(0.95); transition-duration: 90ms; }
.chip input:checked + span { background: var(--brand-wash); border-color: var(--brand-ink); color: var(--brand-ink); box-shadow: inset 0 0 0 1px var(--brand-ink); }
.chip input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 3px; }
.tune-btn {
  display: inline-flex; align-items: center; gap: 8px; margin-left: auto;
  min-height: 40px; padding: 0 14px; border: 0; border-radius: 12px; background: var(--sunk);
  font-weight: 600; font-size: 15px; color: var(--ink);
  transition: background-color 160ms, transform 520ms var(--spring);
}
.tune-btn:hover { background: var(--line); }
.tune-btn:active { transform: scale(0.96); transition-duration: 90ms; }
.tune-btn .icon { width: 18px; height: 18px; }
.tray-copy { color: var(--ink-2); font-size: 14.5px; text-wrap: pretty; }
.tray-copy b { color: var(--ink); font-weight: 600; }
.tray-short { display: none; }
.tune-legend { font: 600 1.05rem/1.3 var(--display); letter-spacing: -0.01em; margin-bottom: -8px; }
#tune-purpose { padding-bottom: 6px; }

/* Once images are in, the canvas folds into a band and the results take the page. */
body[data-view="work"] .canvas {
  grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 14px 20px;
  padding: 12px; border-radius: 26px;
}
body[data-view="work"] .canvas::before { -webkit-mask-image: linear-gradient(90deg, #000, transparent 40%); mask-image: linear-gradient(90deg, #000, transparent 40%); }
body[data-view="work"] .intro {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
body[data-view="work"] .target { display: none; }
body[data-view="work"] .band { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 0 4px 0 6px; }
.band-copy { color: var(--on-brand-2); font-size: 13.5px; line-height: 1.35; white-space: nowrap; }
body[data-view="work"] .tray { grid-column: auto; padding: 10px 10px 12px 18px; }

/* ---------- fine-tune panel ---------- */

.tune {
  position: fixed; inset: 12px 12px 12px auto; margin: 0;
  width: min(440px, 100vw - 24px); height: auto; max-height: none;
  padding: 0; border: 0; border-radius: 26px;
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-lift);
  overflow-y: auto; overscroll-behavior: contain;
}
.tune:popover-open { display: flex; flex-direction: column; animation: sheet-in 340ms var(--ease-out); }
@keyframes sheet-in { from { opacity: 0; transform: translateX(28px); } }
.tune-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 14px 0 24px; }
.tune-head h2 { font: 600 1.4rem/1.2 var(--display); letter-spacing: -0.02em; }
.tune-intro { padding: 2px 24px 0; color: var(--ink-2); font-size: 14.5px; }
.tune-group { display: grid; gap: 22px; margin: 18px 12px 0; padding: 18px 12px 20px; border-top: 1px solid var(--line); }
.tune-group legend { float: left; width: 100%; padding: 0; margin-bottom: -4px; font: 600 1.05rem/1.3 var(--display); letter-spacing: -0.01em; }
.tune-group:disabled { opacity: 0.45; }
.tune-group:disabled * { cursor: not-allowed; }
.graphic-note { margin: 0 24px; padding: 12px 14px; border-radius: 14px; background: var(--sunk); color: var(--ink-2); }
.tune-foot {
  position: sticky; bottom: 0; margin-top: auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px 16px 24px; background: var(--surface); border-top: 1px solid var(--line);
}
.field-label { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-weight: 600; margin-bottom: 10px; }
.field-label output { font: 600 16px/1 var(--display); font-variant-numeric: tabular-nums; color: var(--brand-ink); }
.hint { margin-top: 8px; color: var(--ink-2); font-size: 14px; line-height: 1.5; text-wrap: pretty; }
.tune-group > .hint { margin-top: -12px; }

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { position: relative; cursor: pointer; }
.pill input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.pill span {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 15px;
  border-radius: 999px; border: 1.5px solid var(--line-strong); background: var(--surface);
  font: 500 15px/1 var(--display); font-variant-numeric: tabular-nums;
  transition: background-color 160ms, border-color 160ms, color 160ms, transform 520ms var(--spring);
}
.pill:hover span { border-color: var(--ink-3); }
.pill:active span { transform: scale(0.95); transition-duration: 90ms; }
.pill input:checked + span { background: var(--brand-wash); border-color: var(--brand-ink); color: var(--brand-ink); box-shadow: inset 0 0 0 1px var(--brand-ink); }
.pill input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 3px; }

.segments { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 16px; background: var(--sunk); }
.segment { position: relative; cursor: pointer; }
.segment input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segment span {
  display: inline-flex; align-items: center; min-height: 38px; padding: 0 14px; border-radius: 12px;
  font-weight: 600; font-size: 14.5px; color: var(--ink-2); white-space: nowrap;
  transition: background-color 160ms, color 160ms;
}
.segment:hover span { color: var(--ink); }
.segment input:checked + span { background: var(--surface); color: var(--brand-ink); box-shadow: 0 1px 2px rgb(16 24 80 / 0.12), inset 0 0 0 1.5px var(--brand-ink); }
.segment input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

input[type="range"] {
  --p: 50%;
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 28px; margin: 0; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 99px;
  background: linear-gradient(to right, var(--brand) var(--p), var(--sunk) var(--p));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 24px; height: 24px; margin-top: -9px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--brand);
  box-shadow: var(--shadow-knob);
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 99px; background: var(--sunk); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 99px; background: var(--brand); }
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--brand); box-shadow: var(--shadow-knob);
}
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--brand); outline-offset: 3px; }
input[type="range"]:focus-visible::-moz-range-thumb { outline: 2px solid var(--brand); outline-offset: 3px; }

.check { display: grid; grid-template-columns: 24px 1fr; column-gap: 12px; row-gap: 2px; cursor: pointer; position: relative; }
.check input { position: absolute; opacity: 0; width: 24px; height: 24px; margin: 0; cursor: pointer; }
.check-box {
  grid-row: span 2; display: grid; place-items: center; width: 24px; height: 24px; margin-top: 1px;
  border-radius: 8px; border: 1.5px solid var(--line-strong); background: var(--surface); color: transparent;
  transition: background-color 160ms, border-color 160ms;
}
.check-box .icon { width: 15px; height: 15px; stroke-width: 2.4; }
.check input:checked + .check-box { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.check input:focus-visible + .check-box { outline: 2px solid var(--brand); outline-offset: 3px; }
.check-name { font-weight: 600; }
.check-desc { color: var(--ink-2); font-size: 14px; line-height: 1.5; text-wrap: pretty; }

/* ---------- notice ---------- */

.notice {
  display: flex; gap: 12px; align-items: flex-start;
  margin-top: 16px; padding: 16px 20px;
  border-radius: 18px; background: var(--danger-wash); color: var(--danger);
  font-weight: 500;
}
.notice .icon { margin-top: 2px; }

/* ---------- results ---------- */

.results { margin-top: 20px; }
.bar {
  position: sticky; top: 12px; z-index: 5;
  display: flex; align-items: center; gap: 12px 20px;
  padding: 12px 12px 12px 22px; min-height: 72px;
  border-radius: 22px; background: rgb(255 255 255 / 0.92);
  -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.bar-status { min-width: 0; flex: 1 1 auto; }
.bar-title {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px;
  font: 600 clamp(1.15rem, 1.05rem + 0.5vw, 1.45rem)/1.25 var(--display); letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.bar-title.arrive { animation: rise 600ms var(--ease-out); }
.bar-sub { font-size: 14px; line-height: 1.45; color: var(--ink-2); text-wrap: pretty; }
.bar-sub:empty { display: none; }
.bar-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.bar-actions .btn-primary { margin-left: 8px; }
.btn-quiet.armed { color: var(--danger); background: var(--danger-wash); }
.bar-progress { position: absolute; inset: auto 0 0; height: 3px; background: var(--sunk); }
.bar-progress span {
  display: block; height: 100%; background: var(--brand);
  transform-origin: left center; transform: scaleX(var(--p, 0)); transition: transform 1s linear;
}

/* The reward: sunshine yellow, only ever for how much smaller something got. */
.saving {
  display: inline-flex; align-items: center; min-height: 28px; padding: 0 11px;
  border-radius: 999px; background: var(--pop); color: var(--on-pop);
  font: 600 14px/1 var(--text); letter-spacing: 0; white-space: nowrap;
}
.bar-title .saving { min-height: 32px; padding: 0 13px; font-size: 15px; }


.items {
  list-style: none; margin: 12px 0 0; padding: 0;
  background: var(--surface); border-radius: 24px; box-shadow: var(--shadow-card);
}
.item {
  display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 18px;
  padding: 20px 22px;
}
.item + .item { border-top: 1px solid var(--line); }
.thumb {
  width: 64px; height: 64px; border-radius: 14px; overflow: hidden;
  background: repeating-conic-gradient(var(--check-a) 0 25%, var(--check-b) 0 50%) 0 0 / 12px 12px;
}
.thumb img { display: block; width: 100%; height: 100%; object-fit: contain; }
.thumb.on-dark, .cmp-stage.on-dark { --check-a: #20254f; --check-b: #2a3060; }
.item-main { min-width: 0; display: grid; gap: 12px; }
.item-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; }
.item-title { min-width: 0; flex: 1 1 240px; }
.item-name {
  font: 600 17px/1.3 var(--display); letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.item-meta { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 2px; color: var(--ink-2); font-size: 14.5px; font-variant-numeric: tabular-nums; }
.item-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.item-actions .btn { min-height: 38px; padding: 0 13px; font-size: 14.5px; border-radius: 12px; }

.item-status { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: 15px; }
.item-status .icon { width: 18px; height: 18px; }
.item[data-state="error"] .item-status { color: var(--danger); font-weight: 500; align-items: flex-start; }
.item[data-state="error"] .item-status .icon { margin-top: 2px; }
.item-note { color: var(--ink-2); font-size: 14.5px; line-height: 1.5; text-wrap: pretty; }
.item-advice, .item-copied {
  display: grid; gap: 10px; padding: 12px 14px; border-radius: 14px;
  background: var(--sunk); font-size: 14.5px; line-height: 1.5; text-wrap: pretty;
}
.item-copied .code {
  width: 100%; resize: vertical; field-sizing: content; max-height: 18em;
  padding: 10px 12px; border-radius: 12px; border: 1.5px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: 13px/1.5 ui-monospace, "Cascadia Code", Consolas, monospace;
}
.item-copied .code:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.meter { height: 6px; border-radius: 99px; background: var(--sunk); overflow: hidden; }
.meter span {
  display: block; height: 100%; width: 100%; border-radius: inherit; background: var(--brand);
  transform-origin: left center; transform: scaleX(var(--p, 0));
  transition: transform 1s linear;
}

.outs { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.out {
  display: grid; align-items: center; gap: 16px;
  grid-template-columns: 8.5rem minmax(80px, 1fr) 5.2rem 8.4rem 40px;
  min-height: 42px; font-size: 15px;
}
.out-label { font-weight: 600; white-space: nowrap; }
.out-label small { font-weight: 500; color: var(--ink-2); font-size: inherit; }
/* The gauge: the track is the original, the fill is the new file, and what it uncovers (yellow) is the saving. It starts full and shrinks once, when the
   file is ready: the one authored motion in the app. Clipped, so it never does layout work, with an 8px floor. */
.gauge { position: relative; height: 8px; border-radius: 99px; background: var(--pop-wash); }
.gauge span {
  position: absolute; inset: 0; border-radius: inherit; background: var(--brand);
  clip-path: inset(0 0 0 0 round 99px); transition: clip-path 1.2s var(--ease-out);
}
.gauge span.settled { clip-path: inset(0 min(calc((1 - var(--r)) * 100%), calc(100% - 8px)) 0 0 round 99px); }
.out-size { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.out-save { justify-self: start; }
.out-save.same { font-size: 14px; color: var(--ink-2); font-weight: 500; white-space: nowrap; }
.out .icon-btn { width: 40px; height: 40px; border-radius: 12px; }
.out.skipped { color: var(--ink-2); grid-template-columns: 8.5rem minmax(0, 1fr); }
.out.skipped .out-label { color: var(--ink-2); }
.out-why { font-size: 14px; line-height: 1.45; text-wrap: pretty; }

/* ---------- how it works ---------- */

.how { margin-top: clamp(56px, 9vw, 104px); }
.how h2 { font: 600 clamp(1.5rem, 1.3rem + 0.8vw, 2rem)/1.15 var(--display); letter-spacing: -0.025em; }
.steps {
  list-style: none; counter-reset: step; margin: 26px 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  border-radius: 24px; background: var(--surface); box-shadow: var(--shadow-card);
}
.steps li { counter-increment: step; padding: 26px 28px 30px; }
.steps li + li { border-left: 1px solid var(--line); }
.steps li::before {
  content: counter(step);
  display: grid; place-items: center; width: 36px; height: 36px; margin-bottom: 16px;
  border-radius: 12px; background: var(--brand); color: var(--on-brand);
  font: 600 17px/1 var(--display);
}
.steps h3 { font: 600 17px/1.3 var(--display); letter-spacing: -0.01em; margin-bottom: 6px; }
.steps p { color: var(--ink-2); font-size: 15px; line-height: 1.6; text-wrap: pretty; }
.how-note { margin-top: 18px; max-width: 72ch; color: var(--ink-2); font-size: 15px; line-height: 1.6; text-wrap: pretty; }

.foot { padding: 36px 0 40px; color: var(--ink-2); font-size: 14px; }

/* ---------- drag veil ---------- */

.veil {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 24px;
  background: var(--veil); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  pointer-events: none;
  animation: fade 160ms ease-out;
}
.veil-card {
  display: grid; justify-items: center; gap: 12px;
  padding: 40px 56px; border-radius: 32px;
  background: var(--brand); color: var(--on-brand); box-shadow: var(--shadow-canvas);
  outline: 2px dashed var(--on-brand-line); outline-offset: -14px;
  font: 600 1.45rem/1.2 var(--display); letter-spacing: -0.02em;
}
.veil-card .target-icon { margin: 0; }

/* ---------- compare ---------- */

.compare {
  width: min(100vw - 24px, 1240px); height: min(100dvh - 24px, 940px);
  max-width: none; max-height: none; margin: auto; padding: 0; border: 0;
  border-radius: 28px; background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-lift); overflow: hidden;
}
.compare[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; animation: rise 260ms var(--ease-out); }
.compare::backdrop { background: var(--veil); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.cmp-head { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 12px 16px; padding: 16px 16px 14px 24px; }
.cmp-titles { min-width: 0; }
.cmp-titles h2 { font: 600 18px/1.3 var(--display); letter-spacing: -0.01em; overflow-wrap: anywhere; }
.cmp-titles p { color: var(--ink-2); font-size: 14.5px; }
.cmp-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
/* Flex with auto margins centres the image when it fits and lets it scroll from its edge when it doesn't
   (grid centring would push an oversized image's left and top out of reach). */
.cmp-stage {
  position: relative; overflow: auto; display: flex; padding: 20px;
  background: repeating-conic-gradient(var(--check-a) 0 25%, var(--check-b) 0 50%) 0 0 / 16px 16px;
  overscroll-behavior: contain;
}
.cmp-frame { position: relative; margin: auto; flex: none; touch-action: none; cursor: ew-resize; user-select: none; --pos: 50%; }
.cmp-frame img { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; -webkit-user-drag: none; }
.cmp-frame #cmp-after { position: absolute; inset: 0; clip-path: inset(0 0 0 var(--pos)); }
.cmp-divider { position: absolute; top: 0; bottom: 0; left: var(--pos); width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.18), 0 0 14px rgb(0 0 0 / 0.25); }
.cmp-knob {
  position: absolute; top: 50%; left: 50%; translate: -50% -50%;
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: #fff; color: var(--brand-ink); box-shadow: 0 2px 10px rgb(0 0 0 / 0.3);
}
.cmp-knob .icon { width: 20px; height: 20px; stroke-width: 2; }
.cmp-tag {
  position: absolute; top: 12px; padding: 5px 11px; border-radius: 99px;
  background: rgb(13 17 53 / 0.74); color: #fff; font-size: 13px; font-weight: 600;
  pointer-events: none;
}
.cmp-tag-left { left: 12px; }
.cmp-tag-right { right: 12px; background: var(--brand); }
.cmp-view { position: relative; display: grid; grid-template-rows: minmax(0, 1fr); min-height: 0; }
.cmp-note { position: absolute; inset: auto 16px 16px; padding: 10px 14px; border-radius: 14px; background: var(--surface); color: var(--ink-2); font-size: 14px; box-shadow: var(--shadow-card); }
.cmp-foot { display: grid; grid-template-columns: minmax(0, 1fr) minmax(140px, 2fr) minmax(0, 1fr); align-items: center; gap: 20px; padding: 14px 24px 18px; }
.cmp-side { display: grid; font-size: 14.5px; min-width: 0; }
.cmp-side-right { text-align: right; }
.cmp-side-name { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-side-size { font: 600 18px/1.3 var(--display); font-variant-numeric: tabular-nums; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(0.985); } }

/* ---------- tablets ---------- */

@media (max-width: 900px) {
  .canvas { grid-template-columns: minmax(0, 1fr); }
  .target { min-height: 0; }
  .lede { max-width: 46ch; }
  body[data-view="work"] .canvas { grid-template-columns: minmax(0, 1fr); }
  body[data-view="work"] .band { flex-direction: row; align-items: center; gap: 14px; padding: 4px 4px 2px; }
  .band-copy { white-space: normal; }
  .out { grid-template-columns: 7.5rem minmax(60px, 1fr) 4.8rem auto 40px; gap: 12px; }
  .steps { grid-template-columns: minmax(0, 1fr); }
  .steps li { display: grid; grid-template-columns: 36px minmax(0, 1fr); column-gap: 16px; padding: 20px 20px 22px; }
  .steps li + li { border-left: 0; border-top: 1px solid var(--line); }
  .steps li::before { grid-row: span 2; margin-bottom: 0; }
}

/* ---------- phones ---------- */

@media (max-width: 640px) {
  .wrap { width: min(100% - 24px, 1040px); }
  .top { padding: 14px 0 10px; }
  .brand { font-size: 16px; gap: 10px; }
  .mark { width: 30px; height: 30px; }
  .canvas { padding: 22px 16px 16px; border-radius: 26px; gap: 20px; }
  .intro h1 { font-size: clamp(2.15rem, 1.2rem + 5vw, 2.6rem); }
  .lede { margin-top: 12px; font-size: 1rem; }
  .target { padding: 22px 16px; border-radius: 18px; }
  .target-icon { display: none; }
  .target .btn { width: 100%; margin-top: 12px; }
  .tray { padding: 14px; border-radius: 18px; }
  .tray-label { flex: 1 1 auto; }
  .tune-btn { order: 1; margin-left: auto; min-height: 38px; }
  .chips { order: 2; flex-basis: 100%; }
  body[data-view="work"] .canvas { padding: 10px; border-radius: 22px; }
  body[data-view="work"] .band .btn { flex: 1; }
  body[data-view="work"] .tray { padding: 10px 10px 10px 16px; }
  /* Results showing: the tray folds to one row, a summary and Fine-tune (the chips move into the sheet). */
  body[data-view="work"] .tray-label, body[data-view="work"] .tray-copy { display: none; }
  body[data-view="work"] .tray-row { flex-wrap: nowrap; gap: 12px; }
  body[data-view="work"] .tray-short { display: block; flex: 1 1 0; min-width: 0; color: var(--ink-2); font-size: 14px; line-height: 1.35; }
  body[data-view="work"] .tray-short b { color: var(--ink); font-weight: 600; }
  body[data-view="work"] .tune-btn { order: 0; flex: none; }

  /* The bar moves to the bottom of the screen, under the thumb. */
  body[data-view="work"] { padding-bottom: calc(170px + env(safe-area-inset-bottom)); }
  body[data-view="work"] .band-copy { display: none; }
  .bar {
    position: fixed; top: auto; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
    flex-wrap: wrap; row-gap: 10px;
    min-height: 0; padding: 14px 12px 12px; border-radius: 22px;
    background: rgb(255 255 255 / 0.95); box-shadow: var(--shadow-lift);
    animation: bar-in 420ms var(--ease-out);
  }
  @keyframes bar-in { from { opacity: 0; transform: translateY(24px); } }
  .bar-status { flex-basis: 100%; padding: 0 6px; }
  .bar-title { font-size: 1.05rem; gap: 2px 8px; flex-wrap: nowrap; }
  .bar-title > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bar-title .saving { flex: none; }
  .bar-actions { width: 100%; gap: 6px; }
  .bar-actions .btn-quiet:not(.armed) { background: var(--sunk); }
  .bar-title .saving { min-height: 26px; font-size: 13.5px; padding: 0 10px; }
  .bar-sub { font-size: 13px; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
  /* Quiet actions shrink to their icons (the label stays for screen readers), and speak up when Clear asks to confirm. */
  .bar-actions .btn-quiet { width: 44px; padding: 0; }
  .bar-actions .btn-quiet .bar-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .bar-actions .btn-quiet.armed { width: auto; padding: 0 10px; }
  .bar-actions .btn-quiet.armed .bar-label { position: static; width: auto; height: auto; clip: auto; white-space: normal; text-align: left; }
  .bar-actions .btn-primary { flex: 1; margin-left: 0; padding: 0 16px; }
  .items { margin-top: 12px; border-radius: 22px; }
  .item { grid-template-columns: 52px minmax(0, 1fr); gap: 14px; padding: 16px; }
  .thumb { width: 52px; height: 52px; border-radius: 12px; }
  .item-main { display: contents; }
  .item-top { display: contents; }
  .item-title { grid-column: 2; align-self: center; }
  .item-status, .meter, .outs, .item-note, .item-advice, .item-copied { grid-column: 1 / -1; }
  .item-actions { grid-column: 1 / -1; order: 9; display: grid; grid-template-columns: repeat(3, auto); gap: 6px; }
  .item-actions .btn { padding: 0 6px; gap: 6px; font-size: 14px; white-space: nowrap; }
  .item-actions .btn .icon { width: 16px; height: 16px; }
  .out { grid-template-columns: minmax(0, 1fr) auto auto; row-gap: 8px; column-gap: 12px; padding: 4px 0; }
  .out-label { grid-column: 1; grid-row: 1; }
  .out-size { grid-column: 2; grid-row: 1; }
  .out-save { grid-column: 3; grid-row: 1; justify-self: end; }
  .gauge { grid-column: 1 / -1; grid-row: 2; }
  .out .icon-btn { display: none; }
  .out.skipped { grid-template-columns: minmax(0, 1fr); }
  .out.skipped .out-why { grid-column: 1; grid-row: 2; }
  .tune { inset: auto 0 0 0; width: 100%; max-height: 88dvh; border-radius: 26px 26px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  @keyframes sheet-in { from { opacity: 0; transform: translateY(40px); } }
  .compare { width: 100vw; height: 100dvh; border-radius: 0; }
  .cmp-head { grid-template-columns: minmax(0, 1fr) auto; padding: 12px 12px 10px 16px; }
  .cmp-controls { grid-column: 1 / -1; grid-row: 2; }
  #cmp-close { grid-column: 2; grid-row: 1; }
  .cmp-foot { grid-template-columns: 1fr 1fr; padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); gap: 10px 16px; }
  .cmp-foot input { grid-column: 1 / -1; grid-row: 1; }
  .cmp-stage { padding: 12px; }
}

/* The smallest phones: item buttons keep their words and lose their icons. */
@media (max-width: 360px) {
  .item-actions .btn:not(:last-child) .icon { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
  .btn:active:not(:disabled), .chip:active span, .pill:active span, .icon-btn:active, .tune-btn:active { transform: none; }
}
