:root {
  --ink: #1b2421;
  --muted: #5b6863;
  --line: #d9e0dd;
  --bg: #f6f8f7;
  --card: #fff;
  --brand: #0f5c4d;
  --brand-soft: #e6f1ee;
  --brand-ink: #fff;
  --bad: #b3261e;
  --surface-2: #f1f5f3;
  --scrim: rgba(27,36,33,.72);
  --radius: 14px;
  --r-s: 8px;
  --tap: 44px;
  --fs-s: .8125rem;
  --fs-m: 1rem;
  --fs-l: 1.25rem;
  --t-fast: 160ms;
  --t-mid: 220ms;
  --ease: ease-out;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button { font: inherit; color: inherit; }
img { max-width: 100%; }
a { color: var(--brand); }

.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: 2px; }

.top { background: var(--brand); padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; }
.brand { color: var(--brand-ink); font-weight: 800; letter-spacing: .2px; text-decoration: none; font-size: 1.05rem; }
.brand small { font-weight: 500; opacity: .8; margin-left: 8px; }
.top .right { color: #dbeee8; font-size: var(--fs-s); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 20px; }

.bench { display: grid; grid-template-columns: 1fr 360px; gap: 20px; align-items: start; }
.stage { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; gap: 12px; }

/* ---------- empty state: drop + samples ---------- */
.drop {
  display: grid; justify-items: center; gap: 10px; text-align: center; cursor: pointer;
  padding: 40px 16px 24px; border: 2px dashed var(--line); border-radius: 12px; background: var(--surface-2);
}
.drop.over, .drop:focus-within { border-color: var(--brand); background: var(--brand-soft); }
.drop .ic { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-size: var(--fs-l); }
.drop .pick { display: flex; align-items: center; justify-content: center; min-height: 52px; padding: 0 28px; border-radius: 12px; background: var(--brand); color: var(--brand-ink); font-weight: 700; font-size: var(--fs-m); }
.drop .sub { font-size: var(--fs-s); color: var(--muted); }
.drop .trust { font-size: var(--fs-s); color: var(--ink); }
.drop .trust b { font-weight: 700; }

.samples { display: grid; gap: 8px; justify-items: center; margin-top: 10px; }
.samples p { margin: 0; font-size: var(--fs-s); color: var(--muted); }
.srow { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.sample {
  min-width: var(--tap); min-height: var(--tap); border: 1px solid var(--line); background: var(--card);
  border-radius: 12px; padding: 4px 6px 6px; display: grid; gap: 4px; justify-items: center;
  font-size: var(--fs-s); font-weight: 600; cursor: pointer;
}
.sample img { width: 84px; height: 84px; border-radius: 9px; object-fit: cover; display: block; }

/* ---------- file bar ---------- */
.file { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: var(--fs-s); color: var(--muted); padding: 0 4px; }
.file b { color: var(--ink); }
.swap { color: var(--brand); font-weight: 600; text-decoration: none; min-height: var(--tap); display: inline-flex; align-items: center; font-size: var(--fs-m); }

/* ---------- A1 before/after difference slider ---------- */
.cmpwrap { display: grid; gap: 10px; }
/* S1: the stage is sized to the photo's aspect ratio (height capped as before), so the Sebelum/
   Sesudah tags and the handle sit ON the photo, not on grey letterbox bars. --ar / --ar-num are set
   from the source dims via CSSOM; --stage-h is the height cap (overridden at 390). */
.compare {
  position: relative; margin: 0 auto; width: 100%; height: auto;
  --stage-h: min(62vh, 540px);
  aspect-ratio: var(--ar, 4 / 3);
  max-height: var(--stage-h);
  max-width: calc(var(--stage-h) * var(--ar-num, 0.75));
  border-radius: 10px; overflow: hidden; background: var(--surface-2);
  touch-action: none; user-select: none; cursor: ew-resize;
}
.layer { position: absolute; inset: 0; overflow: hidden; }
.layer.after { clip-path: inset(0 0 0 var(--pos, 50%)); }
.compare img {
  width: 100%; height: 100%; object-fit: contain; display: block;
  transform: translate(var(--pan-x, 0px), var(--pan-y, 0px)) scale(var(--zoom, 1));
  transform-origin: center center;
}
.compare[data-peek="1"] .layer.after { visibility: hidden; }
.divider {
  position: absolute; top: 0; bottom: 0; left: var(--pos, 50%); width: 2px; margin-left: -1px;
  background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.18); pointer-events: none;
  transition: left var(--t-fast) var(--ease);
}
.compare[data-drag] .divider, .compare[data-drag] .handle { transition: none; }
.handle {
  position: absolute; top: 50%; left: var(--pos, 50%); width: var(--tap); height: var(--tap);
  margin: -22px 0 0 -22px; border-radius: 999px; background: #fff; border: 2px solid var(--brand);
  display: grid; place-items: center; box-shadow: 0 2px 8px rgba(0,0,0,.25); color: var(--brand);
  font-weight: 800; font-size: var(--fs-m); cursor: ew-resize; touch-action: none;
  transition: transform var(--t-fast) var(--ease);
}
.handle.drag { transform: scale(1.12); box-shadow: 0 0 0 6px rgba(15,92,77,.22), 0 2px 8px rgba(0,0,0,.25); }
.tag { position: absolute; top: 10px; background: var(--scrim); color: #fff; font-size: var(--fs-s); padding: 4px 8px; border-radius: var(--r-s); font-weight: 600; }
.tag.l { left: 10px; }
.tag.r { right: 10px; background: var(--brand); }
.busybar { position: absolute; left: 0; right: 0; top: 0; height: 3px; background: rgba(15,92,77,.18); overflow: hidden; }
.busybar i { position: absolute; top: 0; bottom: 0; left: 0; width: 40%; background: var(--brand); animation: busy 1.1s var(--ease) infinite; }
@keyframes busy { from { transform: translateX(-110%); } to { transform: translateX(320%); } }
.busychip {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); margin: 0;
  background: var(--scrim); color: #fff; font-size: var(--fs-s); padding: 6px 12px;
  border-radius: 999px; display: flex; gap: 8px; align-items: center;
}
.spin { display: inline-block; flex: none; width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tools { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.hold { min-height: var(--tap); min-width: var(--tap); padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); font-weight: 600; display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.hold[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.zoom { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--card); }
.zoom button { min-width: var(--tap); min-height: var(--tap); border: 0; background: var(--card); padding: 0 10px; font-weight: 600; font-size: var(--fs-s); cursor: pointer; }
.zoom button + button { border-left: 1px solid var(--line); }
.zoom button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }
.meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: var(--fs-s); color: var(--muted); padding: 0 4px; }
.meta b { color: var(--ink); }
.okline { color: var(--brand); font-weight: 700; }

/* ---------- A7 crop frame ---------- */
/* G4: 22 px of breathing room (>= half a 44 px handle) around the photo so all four corner handles
   sit fully inside the stage when the crop frame touches the photo edge. */
.cropwrap { position: relative; border-radius: 10px; overflow: hidden; background: #1f2926; padding: 22px; }
.cropstage { position: relative; }
.cropwrap img.base { display: block; width: 100%; height: auto; }
.frame {
  position: absolute; left: var(--fx, 20%); top: var(--fy, 20%); width: var(--fw, 60%); height: var(--fh, 60%);
  border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(15,20,18,.68); cursor: move; touch-action: none;
}
.frame:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.thirds {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(to right, transparent calc(33.333% - .5px), rgba(255,255,255,.55) calc(33.333% - .5px), rgba(255,255,255,.55) calc(33.333% + .5px), transparent calc(33.333% + .5px), transparent calc(66.666% - .5px), rgba(255,255,255,.55) calc(66.666% - .5px), rgba(255,255,255,.55) calc(66.666% + .5px), transparent calc(66.666% + .5px)),
    linear-gradient(to bottom, transparent calc(33.333% - .5px), rgba(255,255,255,.55) calc(33.333% - .5px), rgba(255,255,255,.55) calc(33.333% + .5px), transparent calc(33.333% + .5px), transparent calc(66.666% - .5px), rgba(255,255,255,.55) calc(66.666% - .5px), rgba(255,255,255,.55) calc(66.666% + .5px), transparent calc(66.666% + .5px));
}
.move { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); background: var(--scrim); color: #fff; font-size: var(--fs-s); padding: 4px 10px; border-radius: 999px; pointer-events: none; }
.crop-h { position: absolute; width: var(--tap); height: var(--tap); touch-action: none; }
.crop-h::after { content: ""; position: absolute; inset: 11px; border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.35); }
.crop-h[data-corner="tl"] { left: -22px; top: -22px; cursor: nwse-resize; }
.crop-h[data-corner="tr"] { right: -22px; top: -22px; cursor: nesw-resize; }
.crop-h[data-corner="bl"] { left: -22px; bottom: -22px; cursor: nesw-resize; }
.crop-h[data-corner="br"] { right: -22px; bottom: -22px; cursor: nwse-resize; }
/* S5: the live crop result stays small (<= 25% of the stage) and, being non-interactive, never
   intercepts a drag aimed at the crop frame. */
.cres { position: absolute; right: 10px; bottom: 10px; max-width: 25%; background: var(--card); border-radius: 10px; padding: 5px 5px 3px; display: grid; gap: 2px; justify-items: center; font-size: var(--fs-s); font-weight: 600; box-shadow: 0 2px 10px rgba(0,0,0,.3); pointer-events: none; }
.cres img { width: 72px; max-width: 100%; height: auto; aspect-ratio: 1; border-radius: 7px; display: block; object-fit: cover; }

/* ---------- A8 error panel ---------- */
.err { border: 1px solid #f0c9c6; background: #fdf4f3; border-radius: 12px; padding: 20px; display: grid; gap: 10px; }
.err .t { display: flex; gap: 10px; align-items: flex-start; font-weight: 700; }
.err .bang { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--bad); color: #fff; display: grid; place-items: center; font-weight: 800; }
.err p { margin: 0 0 0 38px; }
.err .steps { font-size: var(--fs-s); color: var(--muted); }
.err .again { margin-left: 38px; justify-self: start; min-height: var(--tap); min-width: var(--tap); padding: 0 16px; border-radius: 10px; border: 1px solid var(--brand); color: var(--brand); background: var(--card); font-weight: 700; cursor: pointer; }

.status { margin: 0; font-size: var(--fs-s); color: var(--muted); }
.status.bad { color: var(--bad); }
.status.ok { color: var(--brand); }

/* ---------- side: ops + controls + cta ---------- */
.side { display: grid; gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; gap: 10px; }
.card h2 { font-size: var(--fs-s); margin: 0; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.ops { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
/* S3: the not-yet ops are one quiet line of small, non-interactive text chips. */
.ops .soon { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 2px 0 0; font-size: var(--fs-s); color: var(--muted); }
.soon-lbl { font-weight: 700; }
.soon-chip { background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: 2px 8px; }
.op {
  min-height: var(--tap); min-width: var(--tap); border: 1px solid var(--line); border-radius: 10px;
  padding: 0 10px; font-weight: 600; font-size: var(--fs-s); background: var(--card); color: var(--ink);
  text-align: left; display: flex; align-items: center; gap: 8px; cursor: pointer;
}
.op .ic { width: 24px; height: 24px; border-radius: 6px; background: var(--brand-soft); color: var(--brand); display: inline-grid; place-items: center; font-size: var(--fs-s); flex: none; }
.op.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.op.ai { border-style: dashed; }
.op.ai .ic { background: var(--surface-2); color: var(--muted); }
.op[disabled] { cursor: not-allowed; opacity: .7; }
.op .pill { margin-left: auto; font-size: var(--fs-s); color: var(--muted); font-weight: 700; background: var(--surface-2); padding: 2px 6px; border-radius: 999px; }

.ctl { display: grid; gap: 10px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.lbl { font-size: var(--fs-s); color: var(--muted); }
.val { font-weight: 700; color: var(--ink); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex-wrap: wrap; }
.seg .chip { border: 0; border-radius: 0; }
.seg .chip + .chip { border-left: 1px solid var(--line); }
.seg .chip.on { background: var(--brand); color: var(--brand-ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-height: var(--tap); min-width: var(--tap); border: 1px solid var(--line); border-radius: 999px;
  padding: 0 14px; background: var(--card); color: var(--ink); font-weight: 600; font-size: var(--fs-s); cursor: pointer;
}
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
/* S6: a visible >= 24 px knob inside a >= 44 px hit area. */
input[type="range"] { width: 100%; height: var(--tap); min-height: var(--tap); margin: 0; background: transparent; -webkit-appearance: none; appearance: none; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 999px; background: var(--line); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 28px; height: 28px; margin-top: -11px; border-radius: 50%; background: var(--brand); border: 3px solid var(--card); box-shadow: 0 1px 4px rgba(0,0,0,.3); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 999px; background: var(--line); }
input[type="range"]::-moz-range-thumb { width: 28px; height: 28px; border: 3px solid var(--card); border-radius: 50%; background: var(--brand); box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.field { display: grid; gap: 4px; font-size: var(--fs-s); color: var(--muted); }
.field input { font: inherit; padding: 8px; border: 1px solid var(--line); border-radius: var(--r-s); min-height: var(--tap); width: 100%; }
.check { display: flex; align-items: center; gap: 8px; min-height: var(--tap); font-size: var(--fs-m); }
.hint { font-size: var(--fs-s); color: var(--muted); margin: 0; }
.rule { font-size: var(--fs-s); color: var(--muted); display: grid; gap: 4px; }
.rule p { margin: 0; }
.rule blockquote { margin: 0; padding: 6px 10px; border-left: 3px solid var(--brand); background: var(--surface-2); color: var(--ink); }
.rule a { color: var(--brand); word-break: break-all; }

.cta { display: grid; gap: 10px; align-content: start; }
.dock { display: grid; gap: 4px; }
.dock small { display: none; font-size: var(--fs-s); color: var(--muted); text-align: center; }
.btn {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: 52px;
  border: 0; border-radius: 12px; background: var(--brand); color: var(--brand-ink);
  font-weight: 700; font-size: var(--fs-m); text-align: center; text-decoration: none; cursor: pointer;
  transition: opacity var(--t-mid) var(--ease), transform var(--t-mid) var(--ease);
}
.btn.sub { background: var(--card); color: var(--brand); border: 1px solid var(--brand); min-height: var(--tap); }
/* G3: while a job runs the download stays in place but reads as unavailable. */
#download[aria-disabled="true"] { opacity: .6; cursor: progress; }
/* S2: the after-size tag trails an ellipsis while the new size is being computed. */
#after-size[data-busy="1"]::after { content: " → …"; opacity: .7; }
.privacy { font-size: var(--fs-s); color: var(--muted); margin: 0; padding: 0 2px; }
.privacy b { color: var(--ink); }

.next { margin-top: 24px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.next a { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; text-decoration: none; color: var(--ink); }
.next a b { display: block; margin-bottom: 2px; }
.next a span { color: var(--muted); font-size: var(--fs-s); }
.foot { max-width: 1180px; margin: 28px auto; padding: 0 20px; color: var(--muted); font-size: var(--fs-s); display: flex; gap: 16px; flex-wrap: wrap; }
.foot a { color: var(--brand); }

.gone { max-width: 640px; margin: 0 auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.gone code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; word-break: break-all; }
.report { display: grid; gap: 8px; margin-top: 10px; }
.report textarea { font: inherit; width: 100%; min-height: 70px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
.report button { font: inherit; justify-self: start; padding: 8px 14px; border: 1px solid var(--brand); color: var(--brand); background: var(--card); border-radius: 8px; min-height: 40px; }

@media (max-width: 720px) {
  .top { padding: 12px 14px; }
  .top .right { display: none; }
  .wrap { padding: 10px 10px 104px; }
  .bench { grid-template-columns: 1fr; gap: 10px; }
  .stage { padding: 8px; gap: 8px; }
  .compare { --stage-h: 52vh; }
  .drop { padding: 28px 12px 18px; }
  .drop .dropdesk { display: none; }
  .side { display: flex; flex-direction: column; }
  .side .ctlcard { order: -1; }
  .next { grid-template-columns: 1fr 1fr; }
  .dock {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; padding: 8px 10px 10px;
    background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(0,0,0,.08);
  }
  .dock small { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  :root { --t-fast: 0ms; --t-mid: 0ms; }
  .busybar i, .spin { animation: none; }
  .divider, .handle, .btn { transition: none; }
}
