/* ===========================================================================
   PixelFace — "Workspace" layout
   App shell: fixed sidebar (brand, batch summary, photo list) + full-height
   canvas (topbar, stage, action bar). Light + dark via prefers-color-scheme.
   Vendored Plus Jakarta Sans (offline).
   =========================================================================== */

@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("fonts/PlusJakartaSans.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
  font-style: normal;
}

:root {
  /* light palette */
  --bg: #f2f3f7;
  --surface: #ffffff;
  --surface-2: #f4f4f8;
  --hover: #eef0f5;
  --text: #191a2b;
  --muted: #6b6f80;
  --faint: #9aa0b0;
  --line: #e8eaf0;
  --green: #1a9d55;
  --amber: #c98a1a;
  --red: #e5484d;
  --grey: #8b91a0;
  --grey-soft: #eef0f4;
  --shadow-sm: 0 1px 2px rgba(25, 26, 43, .05);
  --shadow: 0 2px 6px rgba(25, 26, 43, .06), 0 12px 30px rgba(25, 26, 43, .08);

  /* accent (themeable): only the hue changes; soft/line derive from surface.
     Warm, gender-neutral coral. */
  --accent-hue: #f2795b;
  --violet: var(--accent-hue);
  --violet-ink: #ffffff;
  --violet-soft: color-mix(in srgb, var(--violet) 13%, var(--surface));
  --violet-line: color-mix(in srgb, var(--violet) 30%, var(--surface));
  --green-soft: color-mix(in srgb, var(--green) 14%, var(--surface));
  --amber-soft: color-mix(in srgb, var(--amber) 16%, var(--surface));
  --red-soft: color-mix(in srgb, var(--red) 13%, var(--surface));

  /* shape / type (themeable) */
  --r: 16px;
  --r-sm: 12px;
  --r-xs: 9px;
  --btn-radius: var(--r-sm);
  --speed: 200ms;
  --sidebar-w: 320px;
  --font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
}

/* ---- dark palette (auto via system preference) ---- */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f0f14; --surface: #17171f; --surface-2: #1e1e28; --hover: #25252f;
    --text: #f2f2f7; --muted: #a2a4b3; --faint: #71727f; --line: #262630;
    --grey-soft: #23232d;
    --violet: color-mix(in srgb, var(--accent-hue) 80%, white);
    --violet-ink: #10101a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 2px 6px rgba(0, 0, 0, .4), 0 16px 40px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body:not(.has-images) .only-with-images { display: none !important; }

/* Visible keyboard focus everywhere (WCAG 2.4.7) */
button:focus-visible, .row:focus-visible, input:focus-visible,
summary:focus-visible, a:focus-visible {
  outline: 2px solid var(--violet);
  outline-offset: 2px;
}

html { height: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  letter-spacing: -.011em;
  -webkit-font-smoothing: antialiased;
}
h1, h2 { margin: 0; }

/* ==========================================================================
   Shell — sidebar | main
   ========================================================================== */
.shell { min-height: 100dvh; display: flex; flex-direction: column; }
.main { display: flex; flex-direction: column; min-width: 0; flex: 1; }

@media (min-width: 821px) {
  body.has-images { height: 100dvh; overflow: hidden; }
  body.has-images .shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    height: 100dvh;
  }
  body.has-images .main { height: 100dvh; }
}

/* ==========================================================================
   Sidebar
   ========================================================================== */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 14px 16px 12px; flex: none; }
.brand-logo { width: 42px; height: 42px; border-radius: 11px; flex: none; box-shadow: var(--shadow-sm); }
.brand-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.wordmark { font-size: 16px; font-weight: 800; letter-spacing: -.02em; }
.tagline {
  font-size: 11px; color: var(--green); font-weight: 700;
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
}
.tagline svg { flex: none; }

/* batch summary card */
.summary {
  flex: none;
  margin: 0 14px 12px;
  display: flex; flex-direction: column; gap: 12px;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--violet) 7%, var(--surface)),
    color-mix(in srgb, var(--violet) 14%, var(--surface)));
  border: 1px solid color-mix(in srgb, var(--violet) 26%, var(--surface));
  border-radius: var(--r);
  padding: 14px;
}
.bs-stats { display: flex; gap: 22px; }
.bs-stat { display: flex; flex-direction: column; gap: 1px; }
.bs-num { font-size: 23px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.bs-label { font-size: 11px; font-weight: 600; color: var(--muted); }
.bs-progress { display: flex; flex-direction: column; gap: 7px; }
.summary-text { font-weight: 700; font-size: 12px; color: var(--muted); }
.summary-bar { height: 6px; background: color-mix(in srgb, var(--text) 8%, transparent); border-radius: 999px; overflow: hidden; }
.summary-bar .bar { height: 100%; width: 0; background: var(--violet); border-radius: 999px; transition: width 350ms ease; }
.summary-actions { display: flex; flex-direction: column; gap: 8px; }
.summary-actions .btn { width: 100%; }

/* list label + add link */
.list-label {
  flex: none;
  display: flex; justify-content: space-between; align-items: center;
  padding: 2px 18px 6px;
  font-size: 11.5px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
}
.list-label .list-count { color: var(--faint); }
.add-link {
  display: inline-flex; align-items: center; gap: 5px;
  border: 0; background: none; color: var(--violet);
  font-family: inherit; font-size: 12.5px; font-weight: 700;
  text-transform: none; letter-spacing: 0;
  padding: 4px 6px; border-radius: 8px; cursor: pointer;
}
.add-link:hover { background: var(--violet-soft); }

/* photo list */
.photo-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 10px 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.row {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 7px 8px;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--speed), border-color var(--speed);
  animation: card-in 220ms ease both;
}
@keyframes card-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.row:hover { background: var(--hover); }
.row.selected { background: var(--violet-soft); border-color: var(--violet); }
.row-thumb {
  position: relative; flex: none;
  width: 44px; height: 44px;
  border-radius: 9px; overflow: hidden;
  background: var(--surface-2); line-height: 0;
}
.row-thumb img, .row-thumb canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.row-thumb canvas { opacity: 0; transition: opacity 250ms ease; }
.row.has-result .row-thumb canvas { opacity: 1; }
.row-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.row-name { font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta1 { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.busy .row-meta1 { color: var(--violet); }
.row-check { flex: none; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; }
.row-check svg { width: 13px; height: 13px; }
.row-check.done  { color: var(--green); background: var(--green-soft); }
.row-check.busy  { color: var(--violet); }
.row-check.warn  { color: var(--amber); }
.row-check.error { color: var(--red); }
.row-check.queued { color: var(--grey); }
.row-remove {
  flex: none; width: 26px; height: 26px;
  display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted); cursor: pointer;
  opacity: 0;
  transition: background var(--speed), color var(--speed), border-color var(--speed), opacity var(--speed);
}
.row:hover .row-remove, .row.selected .row-remove, .row:focus-within .row-remove { opacity: 1; }
.row-remove:hover { background: var(--red-soft); color: var(--red); border-color: var(--red-soft); }
.row-remove svg { width: 14px; height: 14px; }

.side-foot {
  flex: none;
  display: flex; align-items: center; gap: 6px;
  padding: 11px 16px;
  border-top: 1px solid var(--line);
  font-size: 11.5px; font-weight: 600; color: var(--faint);
}
.side-foot svg { color: var(--green); flex: none; }

/* ==========================================================================
   Topbar (settings)
   ========================================================================== */
.topbar {
  flex: none;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 11px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.tb-spacer { flex: 1; }
.tb-field { display: flex; align-items: center; gap: 8px; }
.tb-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.tb-val { font-size: 12px; font-weight: 700; color: var(--violet); min-width: 36px; text-align: right; }
#strength { width: 120px; }

.segmented { display: inline-flex; background: var(--surface-2); border-radius: 11px; padding: 3px; gap: 2px; }
.segmented button {
  border: 0; background: transparent; color: var(--muted);
  padding: 8px 13px; border-radius: 8px;
  font-family: inherit; font-size: 13px; font-weight: 600;
  white-space: nowrap; cursor: pointer;
  transition: background var(--speed), color var(--speed);
}
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface); color: var(--violet); box-shadow: var(--shadow-sm); }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 7px;
  border-radius: 999px; background: var(--surface-2); outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 2px solid var(--violet);
  cursor: pointer; box-shadow: var(--shadow-sm);
}
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 2px solid var(--violet); cursor: pointer;
}
.range-ends { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--faint); font-weight: 600; margin-top: 4px; }

.emoji-picker { display: flex; gap: 3px; flex-wrap: wrap; }
.emoji-btn {
  font-size: 14px; line-height: 1;
  width: 26px; height: 26px;
  border: 2px solid transparent;
  background: var(--surface-2);
  border-radius: var(--r-xs);
  cursor: pointer;
  transition: transform var(--speed), border-color var(--speed), background var(--speed);
}
.emoji-btn:hover { transform: translateY(-2px); }
.emoji-btn.selected { border-color: var(--violet); background: var(--violet-soft); }

/* Detection popover */
.detection { position: relative; }
.detection > summary { list-style: none; display: inline-flex; }
.detection > summary::-webkit-details-marker { display: none; }
.detection-pop {
  position: absolute;
  top: calc(100% + 8px); right: 0;
  z-index: 40;
  width: 260px;
  max-height: 80vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex; flex-direction: column; gap: 16px;
}
.detection-pop .field { display: flex; flex-direction: column; gap: 8px; }
.detection-pop .tb-label { font-weight: 700; }
.field-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.pop-sep { height: 1px; background: var(--line); margin: 2px -2px; }

/* small pill segmented (download format) */
.seg2 { display: flex; flex-wrap: wrap; gap: 6px; }
.seg2 button {
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  font-family: inherit; font-size: 12.5px; font-weight: 600;
  padding: 7px 11px; border-radius: 999px; cursor: pointer;
  transition: background var(--speed), color var(--speed), border-color var(--speed);
}
.seg2 button:hover { background: var(--hover); }
.seg2 button.on { background: var(--violet-soft); border-color: var(--violet-line); color: var(--violet); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--btn-radius);
  padding: 11px 16px;
  font-family: inherit; font-size: 14px; font-weight: 700;
  cursor: pointer; white-space: nowrap;
  transition: filter var(--speed), background var(--speed), transform var(--speed), opacity var(--speed);
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--violet); color: var(--violet-ink); box-shadow: 0 6px 16px color-mix(in srgb, var(--violet) 28%, transparent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn.ghost:hover { background: var(--hover); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-soft); border-color: var(--red-soft); }

/* ==========================================================================
   Work area — stage + action bar
   ========================================================================== */
.workarea { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.stage {
  flex: 1;
  min-height: 0;
  position: relative;
  display: grid;
  place-items: center;
  padding: 26px;
}
.canvas {
  position: relative;
  line-height: 0;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 18px 50px color-mix(in srgb, var(--text) 16%, transparent);
  max-width: 100%;
  max-height: 100%;
}
.pv-img, .pv-canvas {
  max-width: 100%;
  max-height: calc(100dvh - 220px);
  object-fit: contain;
  display: block;
  cursor: zoom-in;
}
.pv-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }

/* chips over the image */
.chip {
  position: absolute; z-index: 3;
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(20, 22, 30, .55);
  backdrop-filter: blur(6px);
  color: #fff;
  font-family: inherit; font-size: 12px; font-weight: 700;
  padding: 6px 11px; border-radius: 999px;
  border: 0;
}
.chip.act { cursor: pointer; transition: background var(--speed); }
.chip.act:hover { background: rgba(20, 22, 30, .75); }
.chip.on { background: var(--violet); color: var(--violet-ink); }
.chip svg { width: 14px; height: 14px; }
.pv-index { top: 12px; left: 12px; }
.pv-facetoggle { top: 12px; right: 52px; }
.pv-open { top: 12px; right: 12px; padding: 6px 8px; }
.pv-compare { bottom: 12px; right: 12px; user-select: none; -webkit-user-select: none; touch-action: none; }

/* nav arrows float in the stage, outside the image */
.pv-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: var(--surface); color: var(--muted);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--text) 14%, transparent);
  font-size: 1.4rem; line-height: 1; cursor: pointer;
  display: grid; place-items: center;
  z-index: 4;
  transition: color var(--speed), transform var(--speed);
}
.pv-nav:hover { color: var(--text); transform: translateY(-50%) scale(1.06); }
.pv-nav.prev { left: 20px; } .pv-nav.next { right: 20px; }

/* action bar */
.actionbar {
  flex: none;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 18px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.ab-status { display: flex; align-items: center; gap: 10px; border-radius: var(--r-sm); padding: 8px 12px; }
.ab-status.ok { background: var(--green-soft); }
.ab-status.ok .ab-icon { color: var(--green); }
.ab-status.warn { background: var(--amber-soft); }
.ab-status.warn .ab-icon { color: var(--amber); }
.ab-status.danger { background: var(--red-soft); }
.ab-status.danger .ab-icon { color: var(--red); }
.ab-status.busy { background: var(--violet-soft); }
.ab-status.busy .ab-icon { color: var(--violet); }
.ab-icon { width: 30px; height: 30px; border-radius: 9px; background: var(--surface); display: grid; place-items: center; flex: none; }
.ab-icon svg { width: 17px; height: 17px; }
.ab-text { display: flex; flex-direction: column; min-width: 0; }
.ab-text b { font-size: 13px; font-weight: 800; }
.ab-text span { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-meta { font-size: 12px; color: var(--faint); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 34ch; }
.ab-spacer { flex: 1; }
.ab-actions { display: flex; gap: 9px; }
.ab-actions .btn { padding: 10px 15px; font-size: 13.5px; }

/* ==========================================================================
   Upload state (empty)
   ========================================================================== */
.upload-state {
  display: flex; flex-direction: column; gap: 18px;
  width: 100%; max-width: 1000px;
  margin: 0 auto;
  padding: 30px 26px 20px;
}
body.has-images .upload-state { display: none; }

.hero-brand { display: flex; align-items: center; gap: 16px; justify-content: center; }
.hero-brand img { width: 72px; height: 72px; border-radius: 18px; box-shadow: var(--shadow-sm); }
.hero-brand .wordmark { font-size: 24px; }
.hero-brand .tagline {
  font-size: 13px; color: var(--muted); font-weight: 500;
  white-space: normal; max-width: 34ch; line-height: 1.4; display: block;
}

.stepper {
  list-style: none; margin: 0; padding: 0;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  flex-wrap: wrap;
}
.step { display: inline-flex; align-items: center; gap: 9px; color: var(--faint); font-weight: 700; font-size: 13.5px; }
.step:not(:last-child)::after {
  content: ""; width: 46px; height: 2px; border-radius: 2px;
  background: var(--line); margin-left: 8px;
}
.step-dot {
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--faint);
  font-size: 12.5px; font-weight: 800;
  border: 1.5px solid var(--line);
}
.step.is-active { color: var(--text); }
.step.is-active .step-dot { background: var(--violet); color: var(--violet-ink); border-color: var(--violet); }
.step.is-done { color: var(--text); }
.step.is-done .step-dot { background: var(--green); color: #fff; border-color: var(--green); font-size: 0; }
.step.is-done .step-dot::before { content: "✓"; font-size: 13px; }

.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--r);
  background: var(--surface);
  min-height: min(44vh, 380px);
  display: grid; place-items: center; text-align: center;
  padding: 32px;
  cursor: pointer;
  transition: border-color var(--speed), background var(--speed);
}
.dropzone:hover, .dropzone:focus-visible { border-color: color-mix(in srgb, #6b8bd6 55%, var(--line)); background: color-mix(in srgb, #6b8bd6 6%, var(--surface)); outline: none; }
body.dragging .dropzone { border-color: #6b8bd6; background: color-mix(in srgb, #6b8bd6 9%, var(--surface)); }
.dz-inner { display: flex; flex-direction: column; align-items: center; }
.dz-icon {
  width: 88px; height: 88px;
  margin: 0 auto 18px;
  display: grid; place-items: center;
  background: color-mix(in srgb, #6b8bd6 14%, var(--surface));
  color: #4f74c9;
  border-radius: 24px;
}
.dz-title { font-size: 1.5rem; font-weight: 800; margin: 0 0 .3rem; letter-spacing: -.02em; }
.dz-sub { color: var(--muted); margin: 0 0 18px; }
.dz-btn { padding: 12px 22px; }
.dz-formats { color: var(--faint); font-size: 12.5px; margin: 16px 0 0; font-weight: 600; }
.dz-trust {
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--green); font-size: 12.5px; font-weight: 700;
  margin: 10px 0 0;
}

/* Short privacy note under the dropzone */
.privacy-note {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  max-width: 620px; margin: 4px auto 0; padding: 0 12px;
  text-align: center; font-size: 13.5px; line-height: 1.5; color: var(--muted);
}
.privacy-note svg { flex: none; color: var(--green); }
.privacy-note strong { color: var(--text); font-weight: 800; }

/* FAQ (empty state, crawlable SEO content) */
.faq { width: 100%; max-width: 720px; margin: 22px auto 0; }
.faq h2 { font-size: 17px; font-weight: 800; text-align: center; margin: 0 0 12px; letter-spacing: -.01em; }
.faq details {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  margin-bottom: 8px;
}
.faq summary {
  cursor: pointer; list-style: none;
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  font-weight: 700; font-size: 13.5px;
  padding: 13px 16px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "＋"; color: var(--faint); font-weight: 800; flex: none; }
.faq details[open] summary::after { content: "−"; }
.faq details p { margin: 0; padding: 0 16px 14px; font-size: 13px; color: var(--muted); line-height: 1.55; }

.app-footer {
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  flex-wrap: wrap;
  padding: 30px 0 10px; font-size: 12.5px; color: var(--faint);
}
.app-footer .dot { opacity: .5; }
.app-footer a { color: var(--muted); font-weight: 600; }

/* ==========================================================================
   Drag overlay
   ========================================================================== */
.drop-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: none; place-items: center;
  background: color-mix(in srgb, var(--violet) 12%, transparent);
  backdrop-filter: blur(3px);
}
body.dragging .drop-overlay { display: grid; }
.drop-overlay > div {
  border: 3px dashed var(--violet);
  color: var(--violet);
  background: var(--surface);
  font-size: 1.25rem; font-weight: 800;
  padding: 2rem 3rem; border-radius: var(--r);
  box-shadow: var(--shadow);
}

/* ==========================================================================
   Spinner
   ========================================================================== */
.spin { animation: spin 900ms linear infinite; transform-origin: center; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Image editor / large viewer (one overlay)
   ========================================================================== */
.editor-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15, 15, 20, .82);
  backdrop-filter: blur(6px);
  display: grid; grid-template-columns: auto 1fr auto;
  align-items: center; gap: .5rem; padding: 1rem;
}
.editor-topbar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 14px 18px; color: #fff;
  background: linear-gradient(rgba(0, 0, 0, .5), transparent);
  z-index: 2;
}
.editor-titles strong { font-size: 15px; font-weight: 700; }
.editor-hint { display: block; font-size: 12.5px; color: rgba(255, 255, 255, .7); margin-top: 2px; }
.editor-tools { display: flex; align-items: center; gap: 12px; flex: none; }
.editor-idx { font-weight: 700; font-size: 13px; background: rgba(255, 255, 255, .16); padding: 5px 11px; border-radius: 999px; }
/* Stage is a scroll container: zoomed images pan with plain scroll/drag;
   margin:auto keeps the image centered when it fits. */
.editor-stage {
  grid-column: 2;
  align-self: stretch;
  min-width: 0; min-height: 0;
  display: flex;
  overflow: auto;
  padding: 70px 10px 14px; /* clear the absolute topbar */
  overscroll-behavior: contain;
}
.editor-imgwrap { position: relative; line-height: 0; touch-action: none; margin: auto; }
.editor-img {
  display: block;
  max-width: min(86vw, 1300px);
  max-height: 80vh;
  border-radius: var(--r-sm);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
  user-select: none; -webkit-user-drag: none;
}
.editor-img.zoomed { max-width: none; max-height: none; border-radius: 4px; }

/* zoom controls in the topbar */
.ez { display: flex; align-items: center; gap: 5px; }
.ez-btn {
  min-width: 30px; height: 30px; padding: 0 8px;
  border: 0; border-radius: 8px;
  background: rgba(255, 255, 255, .16); color: #fff;
  font-family: inherit; font-size: 15px; font-weight: 700; line-height: 1;
  cursor: pointer;
  transition: background var(--speed);
}
.ez-btn:hover { background: rgba(255, 255, 255, .3); }
.ez-btn.ez-fit { font-size: 12px; }
.ez-label { font-size: 12px; font-weight: 700; color: rgba(255, 255, 255, .8); min-width: 42px; text-align: center; }
.editor-layer { position: absolute; inset: 0; cursor: crosshair; }
.editor-nav {
  width: 52px; height: 52px;
  border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .14); color: #fff;
  font-size: 2rem; line-height: 1; cursor: pointer; z-index: 2;
  transition: background var(--speed);
}
.editor-nav:hover { background: rgba(255, 255, 255, .3); }
.ebox {
  position: absolute;
  border: 2px solid var(--violet);
  background: color-mix(in srgb, var(--violet) 18%, transparent);
  cursor: move; box-sizing: border-box;
}
.ebox.manual { border-color: var(--green); background: rgba(26, 157, 85, .18); }
.ebox-del {
  position: absolute; top: -11px; right: -11px;
  width: 22px; height: 22px;
  border: 0; border-radius: 50%;
  background: var(--red); color: #fff;
  font-size: .9rem; line-height: 1; cursor: pointer;
  display: grid; place-items: center; box-shadow: var(--shadow-sm);
}
.ebox-handle {
  position: absolute; right: -7px; bottom: -7px;
  width: 14px; height: 14px;
  background: #fff; border: 2px solid var(--violet);
  border-radius: 3px; cursor: nwse-resize;
}
.ebox.manual .ebox-handle { border-color: var(--green); }
/* Tiny boxes: the normal ×/handle chrome would bury the box itself. Hide the
   resize handle (zoom or double-click the box to resize) and shrink the × to a
   small chip floating just above the box, keeping the box itself visible. */
.ebox.tiny { border-width: 1.5px; }
.ebox.tiny .ebox-handle { display: none; }
.ebox.tiny .ebox-del {
  width: 15px; height: 15px;
  top: -19px; right: auto; left: 50%; transform: translateX(-50%);
  font-size: .68rem;
}

/* ==========================================================================
   App dialog (replaces window.confirm/alert)
   ========================================================================== */
.app-dialog {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  padding: 22px;
  width: min(92vw, 380px);
}
.app-dialog::backdrop {
  background: rgba(15, 15, 20, .5);
  backdrop-filter: blur(3px);
}
.dlg-title { font-size: 16.5px; font-weight: 800; margin: 0 0 6px; letter-spacing: -.01em; }
.dlg-message { font-size: 13.5px; color: var(--muted); line-height: 1.5; margin: 0 0 18px; }
.dlg-actions { display: flex; gap: 9px; justify-content: flex-end; }
.dlg-actions .btn { padding: 10px 16px; }
.btn.danger-solid { background: var(--red); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--red) 28%, transparent); }

/* ==========================================================================
   Touch targets — enlarge small hit areas on coarse pointers
   ========================================================================== */
@media (pointer: coarse) {
  .row-remove { width: 40px; height: 40px; }
  .ebox-del { width: 30px; height: 30px; top: -15px; right: -15px; font-size: 1.05rem; }
  .ebox-handle { width: 22px; height: 22px; right: -11px; bottom: -11px; }
  .pv-facetoggle, .pv-compare { padding: 10px 14px; }
}

/* ==========================================================================
   Mobile
   ========================================================================== */
@media (max-width: 820px) {
  /* single column: topbar, then the stage (preview of the selected photo),
     then summary + photo list. Tapping a row previews it above. */
  .shell { display: flex; flex-direction: column; }
  .main { order: -1; flex: none; }
  .workarea { scroll-margin-top: 70px; }  /* scrollIntoView clears sticky topbar */
  .stage { padding: 12px; }
  .pv-img, .pv-canvas, .pv-overlay { max-height: 56vh; }
  .pv-nav { width: 36px; height: 36px; font-size: 1.2rem; }
  .pv-nav.prev { left: 10px; } .pv-nav.next { right: 10px; }
  .actionbar { padding: 10px 12px; gap: 10px; }
  .pv-meta { max-width: none; }
  .ab-actions { width: 100%; }
  .ab-actions .btn { flex: 1; }
  .sidebar { border-right: 0; flex: 1; }
  .photo-list { overflow: visible; }
  .row-remove { opacity: 1; }          /* no hover on touch — keep remove reachable */
  .topbar { position: sticky; top: 0; z-index: 30; }
  .detection-pop { right: auto; left: 0; }
  .step:not(:last-child)::after { width: 24px; }
  .upload-state { padding: 20px 16px; }
  .hero-brand { flex-direction: column; text-align: center; gap: 10px; }
  .hero-brand .tagline { margin: 0 auto; }
}
@media (max-width: 560px) {
  .step-label { display: none; }       /* dots-only stepper on very small screens */
  .step:not(:last-child)::after { width: 32px; }
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .spin { animation: spin 900ms linear infinite; }
}
