@font-face { font-family: Lato; font-style: normal; font-weight: 400; font-display: swap; src: url(/fonts/lato-400.woff2) format("woff2"); }
@font-face { font-family: Lato; font-style: normal; font-weight: 700; font-display: swap; src: url(/fonts/lato-700.woff2) format("woff2"); }
@font-face { font-family: Montserrat; font-style: normal; font-weight: 600 700; font-display: swap; src: url(/fonts/montserrat.woff2) format("woff2"); }

:root {
  /* spacing on a 4 px base */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 72px;
  --t-sm: .875rem; --t-md: 1rem; --t-lg: 1.125rem; --t-xl: clamp(2.1rem, 5vw, 3.5rem);
  /* an inner corner is its container's radius minus the padding between them */
  --r-stage: 32px; --p-stage: var(--s4); --r-media: calc(var(--r-stage) - var(--p-stage));
  --r-pill: 999px;
  --stroke: 1.8;
  --ease-spring: cubic-bezier(.3, 1.35, .5, 1);

  /* Blush */
  --bg: #FBF1EE; --ink: #1A1012; --muted: #574A4E;
  --primary: #FF6A55; --on-primary: #1A1012; --accent: #0A7A6E; --danger: #B3261E;
  --glass: rgba(255, 255, 255, .42); --glass-strong: rgba(255, 255, 255, .68);
  --edge: rgba(255, 255, 255, .9); --shine: rgba(255, 255, 255, .95); --shadow: rgba(90, 30, 30, .14);
  --blob-a: #FFC2B5; --blob-b: #9FE3D6; --blob-c: #F6D9E0;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 400 var(--t-md)/1.55 Lato, system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2, .brand, .btn { font-family: Montserrat, system-ui, sans-serif; }
a { color: var(--accent); }
svg.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: var(--stroke); stroke-linecap: round; stroke-linejoin: round; }

.field { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.field i { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .5; }
.field i:nth-child(1) { width: 46vmax; height: 46vmax; background: var(--blob-a); left: -12vmax; top: -10vmax; }
.field i:nth-child(2) { width: 38vmax; height: 38vmax; background: var(--blob-b); right: -10vmax; top: 18vh; opacity: .35; }
.field i:nth-child(3) { width: 50vmax; height: 50vmax; background: var(--blob-c); left: 20vw; bottom: -30vmax; }

/* liquid glass; the refraction only where the engine takes an SVG backdrop filter */
.glass {
  position: relative;
  background: linear-gradient(160deg, var(--glass-strong), var(--glass) 45%);
  -webkit-backdrop-filter: blur(22px) saturate(170%);
  backdrop-filter: blur(22px) saturate(170%);
  border: 1px solid var(--edge);
  box-shadow: inset 0 1px 0 var(--shine), 0 18px 50px -18px var(--shadow);
}
.refract .glass.lens { backdrop-filter: url(#lens) blur(14px) saturate(170%); }

.wrap { width: min(1080px, 100% - 2 * var(--s4)); margin-inline: auto; }

header { display: flex; align-items: center; justify-content: space-between; padding: max(var(--s4), env(safe-area-inset-top)) 0 var(--s4); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.2rem; letter-spacing: -.01em; color: var(--ink); text-decoration: none; }
.brand svg { width: 32px; height: 32px; }

.hero { text-align: center; padding: clamp(var(--s5), 5vh, var(--s7)) 0 0; }
h1 { font-size: var(--t-xl); line-height: 1.06; letter-spacing: -.025em; margin: 0 auto var(--s3); font-weight: 700; max-width: 24ch; text-wrap: balance; }
.lede { color: var(--muted); margin: 0 auto var(--s6); max-width: 38ch; font-size: var(--t-lg); text-wrap: balance; }

:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
button:focus:not(:focus-visible) { outline: none; }

/* the stage: compare on top, action bar below, same shape before and after an upload */
/* --ar is the photo's width over height; the panel hugs the photo, which stays within the viewport
   height, but never gets narrower than the action bar needs */
.stage {
  --ar: 1; --maxh: 56svh;
  width: min(100%, max(440px, min(860px, var(--maxh) * var(--ar) + 2 * var(--p-stage))));
  border-radius: var(--r-stage); padding: var(--p-stage); margin: 0 auto; transition: box-shadow .2s, transform .2s var(--ease-spring); }
.stage.over { box-shadow: inset 0 1px 0 var(--shine), 0 0 0 3px var(--primary), 0 24px 60px -18px var(--shadow); transform: scale(1.01); }

.compare {
  --pos: 50%;
  position: relative; border-radius: var(--r-media); overflow: hidden; user-select: none; touch-action: pan-y;
  aspect-ratio: var(--ar); width: min(100%, var(--maxh) * var(--ar)); margin-inline: auto;
  background: #0d0809;
}
.compare img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.compare .before { clip-path: inset(0 0 0 var(--pos)); }
.compare .line { position: absolute; top: 0; bottom: 0; left: var(--pos); width: 2px; margin-left: -1px; background: rgba(255,255,255,.92); box-shadow: 0 0 0 1px rgba(0,0,0,.12); pointer-events: none; }
.compare .knob {
  position: absolute; top: 50%; left: var(--pos); width: 48px; height: 48px; border-radius: 50%;
  transform: translate(-50%, -50%); display: grid; place-items: center; pointer-events: none; color: #fff;
  background: rgba(255,255,255,.18); -webkit-backdrop-filter: blur(10px) saturate(180%); backdrop-filter: blur(10px) saturate(180%);
  border: 1px solid rgba(255,255,255,.7); box-shadow: inset 0 1px 0 rgba(255,255,255,.8), 0 8px 24px rgba(0,0,0,.35);
}
.compare input[type=range] { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: ew-resize; }
.compare input[type=range]:focus-visible ~ .knob { outline: 3px solid #fff; outline-offset: 3px; }
.tag {
  position: absolute; top: var(--s3); padding: 2px 10px; border-radius: var(--r-pill); font-size: .8rem; font-weight: 700; color: #fff;
  background: rgba(20, 10, 12, .4); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); pointer-events: none;
}
.tag.l { left: var(--s3); } .tag.r { right: var(--s3); }

.scan .after { opacity: 0; }
.scan .line, .scan .knob, .scan input, .scan .tag { display: none; }
.scan::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 38%;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--primary) 45%, transparent) 70%, rgba(255,255,255,.85) 99%, transparent);
  mix-blend-mode: screen; animation: sweep 1.25s cubic-bezier(.5, 0, .3, 1) infinite;
}
@keyframes sweep { from { left: -40%; } to { left: 100%; } }

/* edit mode: the working canvas takes the place of the compare, strokes paint over it */
.compare canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.compare .strokes { opacity: .5; touch-action: none; cursor: none; }
.compare.editing { touch-action: none; }
.compare.editing > img, .compare.editing .line, .compare.editing .knob, .compare.editing input, .compare.editing .tag { display: none; }
.compare .strokes.pending { animation: pend .9s ease-in-out infinite alternate; }
@keyframes pend { from { opacity: .55; } to { opacity: .2; } }
.brush {
  position: absolute; left: 0; top: 0; border-radius: 50%; pointer-events: none;
  border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.45), inset 0 0 0 1px rgba(0,0,0,.25);
}

.bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; padding: var(--s4) var(--s1) var(--s1); min-height: 76px; }
.bar .meta { color: var(--muted); font-size: var(--t-sm); }
.bar .actions { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 52px; padding: 0 var(--s6); border-radius: var(--r-pill); border: 0; cursor: pointer;
  font-weight: 700; font-size: var(--t-md); text-decoration: none; white-space: nowrap;
}
.btn.primary {
  color: var(--on-primary); background: var(--primary);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 10px 28px -12px var(--primary);
  transition: transform .15s, filter .2s;
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.primary:active { transform: scale(.97); }
.btn.primary[aria-disabled="true"] { filter: saturate(.3) brightness(.9); cursor: progress; pointer-events: none; }
#download { min-width: 196px; }
.btn.quiet { color: var(--muted); background: none; padding: 0 var(--s4); min-height: 48px; font-weight: 600; }
.btn.quiet:hover { color: var(--ink); }
.btn.soft { color: var(--ink); background: var(--glass-strong); border: 1px solid var(--edge); padding: 0 var(--s5); }
.btn.soft:hover { background: #fff; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.icon { width: 48px; min-height: 48px; padding: 0; color: var(--ink); background: var(--glass-strong); border: 1px solid var(--edge); }

.btn.icon.view[aria-pressed="true"] { color: #fff; background: var(--accent); border-color: var(--accent); }
.tools { display: flex; align-items: center; gap: var(--s3); flex: 1 1 320px; }
.tools .size { flex: 1; min-width: 60px; width: auto; }
.seg { display: inline-flex; padding: 4px; border-radius: var(--r-pill); background: rgba(26, 16, 18, .07); }
.seg-b {
  min-height: 44px; padding: 0 var(--s5); border: 0; border-radius: var(--r-pill); cursor: pointer;
  font: 700 var(--t-md) Montserrat, system-ui, sans-serif; color: var(--muted); background: none; transition: background .15s, color .15s;
}
.seg-b[aria-pressed="true"] { color: var(--ink); background: #fff; box-shadow: 0 2px 8px -2px var(--shadow); }
.seg-b::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: var(--s2); vertical-align: 1px; }
.seg-b.keep::before { background: var(--accent); }
.seg-b.remove::before { background: var(--primary); }

.size { -webkit-appearance: none; appearance: none; width: 140px; height: 44px; background: none; margin: 0; cursor: pointer; }
.size::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: rgba(26, 16, 18, .14); }
.size::-moz-range-track { height: 6px; border-radius: 3px; background: rgba(26, 16, 18, .14); }
.size::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -9px; border-radius: 50%; background: #fff; border: 1px solid var(--edge); box-shadow: 0 2px 8px var(--shadow); }
.size::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 1px solid var(--edge); box-shadow: 0 2px 8px var(--shadow); }

.btn .spin { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }
.btn .done-ic { animation: pop .35s var(--ease-spring); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }

.samples { display: flex; align-items: center; gap: var(--s2); }
.chip { width: 44px; height: 44px; border-radius: 12px; padding: 0; border: 1px solid var(--edge); overflow: hidden; cursor: pointer; background: none; }
.chip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chip[aria-current="true"] { outline: 2px solid var(--primary); outline-offset: 2px; }

.err { order: 3; flex-basis: 100%; color: var(--danger); font-size: var(--t-sm); font-weight: 700; margin: 0; }

.points { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s6); padding: var(--s8) 0 var(--s7); }
.points h2 { font-size: var(--t-lg); margin: 0 0 var(--s1); font-weight: 600; }
.points p { margin: 0; color: var(--muted); font-size: .96rem; max-width: 34ch; text-wrap: pretty; }
.ad { padding: 0 0 var(--s6); }
.ad:not(:has(* *)) { display: none; }
footer { color: var(--muted); font-size: var(--t-sm); padding: var(--s5) 0 var(--s7); display: flex; justify-content: space-between; flex-wrap: wrap; gap: var(--s4); border-top: 1px solid var(--edge); }
footer a { color: var(--muted); }
footer a:hover { color: var(--ink); }

/* plain text pages */
.doc { max-width: 68ch; margin: 0 auto; padding: var(--s6) 0 var(--s8); }
.doc h1 { font-size: clamp(1.8rem, 4vw, 2.4rem); margin: 0 0 var(--s5); text-align: left; max-width: none; }
.doc h2 { font-size: var(--t-lg); margin: var(--s6) 0 var(--s2); }
.doc p, .doc li { color: var(--muted); }

/* wide screens: text on the left, the panel on the right, all of it on one screen */
@media (min-width: 960px) {
  .wrap { width: min(1280px, 100% - 2 * var(--s6)); }
  .hero {
    display: grid; grid-template-columns: minmax(0, 30rem) auto; justify-content: center;
    grid-template-areas: "intro stage" "points stage";
    grid-template-rows: auto 1fr; column-gap: var(--s8);
    align-items: start; text-align: left;
    padding: var(--s4) 0 var(--s7);
    min-height: calc(100svh - 72px);
  }
  .intro { grid-area: intro; align-self: end; padding-top: var(--s6); }
  h1 { font-size: clamp(2.2rem, 3.6vw, 3.4rem); margin-left: 0; max-width: none; }
  .lede { margin: 0; }
  .stage {
    grid-area: stage; align-self: center;
    --maxh: calc(100svh - 230px);
    width: min(58vw, 780px, max(440px, var(--maxh) * var(--ar) + 2 * var(--p-stage)));
  }
  .points { grid-area: points; grid-template-columns: 1fr; gap: var(--s5); padding: var(--s7) 0 0; }
  .points p { max-width: none; }
}

@media (max-width: 640px) {
  :root { --r-stage: 26px; --p-stage: var(--s3); }
  .stage { --maxh: 62svh; }
  .bar { flex-direction: column; align-items: stretch; }
  .bar .actions { flex-direction: column; align-items: stretch; }
  .bar .btn { width: 100%; }
  .tools { justify-content: space-between; flex-wrap: nowrap; gap: var(--s2); }
  .tools .seg-b { padding: 0 var(--s3); }
  .tools .size { flex: 1; min-width: 60px; width: auto; }
  .bar .btn.icon { width: 48px; flex: none; }
  .samples { justify-content: center; }
  .bar .meta, .err { text-align: center; }
  .points { padding-top: var(--s7); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
