/* ==========================================================================
   Unmark Me — image workspace
   One neutral palette, one accent, system type, 4px spacing rhythm.
   ========================================================================== */

:root {
  color-scheme: light;

  /* Palette */
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --fill: rgba(120, 120, 128, 0.12);
  --fill-hover: rgba(120, 120, 128, 0.18);
  --fill-press: rgba(120, 120, 128, 0.24);
  --label: #1d1d1f;
  --label-2: #6e6e73;
  --label-3: #86868b;
  --separator: rgba(0, 0, 0, 0.08);
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-press: #006edb;
  --accent-tint: rgba(0, 113, 227, 0.1);
  --on-accent: #ffffff;
  --success: #248a3d;
  --warning: #b25000;
  --danger: #d70015;
  --nav-material: rgba(245, 245, 247, 0.72);
  --scrim: rgba(245, 245, 247, 0.62);
  --checker-a: #f2f2f4;
  --checker-b: #fbfbfd;
  --cord: #c7c7cc;

  /* Depth */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.04), 0 12px 32px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.06), 0 24px 56px rgba(0, 0, 0, 0.12);

  /* Shape */
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --radius-pill: 980px;

  /* Motion */
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --fast: 120ms;
  --base: 240ms;
  --slow: 480ms;

  /* Vertical space taken by nav, page padding and viewer padding.
     The comparison image gets the rest so the page never scrolls. */
  --chrome: 127px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --surface: #161617;
  --surface-raised: #1d1d1f;
  --fill: rgba(120, 120, 128, 0.24);
  --fill-hover: rgba(120, 120, 128, 0.32);
  --fill-press: rgba(120, 120, 128, 0.4);
  --label: #f5f5f7;
  --label-2: #a1a1a6;
  --label-3: #86868b;
  --separator: rgba(255, 255, 255, 0.1);
  --accent: #0a84ff;
  --accent-hover: #2b95ff;
  --accent-press: #0077ed;
  --accent-tint: rgba(10, 132, 255, 0.16);
  --success: #30d158;
  --warning: #ff9f0a;
  --danger: #ff453a;
  --nav-material: rgba(22, 22, 23, 0.72);
  --scrim: rgba(0, 0, 0, 0.55);
  --checker-a: #1c1c1e;
  --checker-b: #232325;
  --cord: #48484a;
  --shadow-sm: 0 0 0 1px rgba(255, 255, 255, 0.06);
  --shadow-md: 0 0 0 1px rgba(255, 255, 255, 0.07), 0 12px 32px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 24px 56px rgba(0, 0, 0, 0.6);
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

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

html, body { height: 100%; }

body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--label);
  font: 400 1rem/1.47 var(--font);
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.loading { opacity: 0; }

::selection { background: var(--accent-tint); }

a { color: inherit; text-decoration: none; }

p { margin: 0; }

button, input { font: inherit; color: inherit; }

button {
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

img { -webkit-user-drag: none; }

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
}

.hidden { display: none !important; }

/* Layout helpers the comparison viewer relies on (see tests/regression). */
.w-fit { width: fit-content; }
.w-auto { width: auto; }
.h-auto { height: auto; }
.max-w-full { max-width: 100%; }
.object-right-bottom { object-position: right bottom; }

/* ---------- Navigation (translucent material) ---------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--nav-material);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 1px 0 var(--separator);
}

.nav-inner {
  max-width: 1120px;
  height: 52px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius-sm);
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--label);
  color: var(--bg);
}

.brand-mark svg { width: 16px; height: 16px; fill: currentColor; }

.brand-name {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.022em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.875rem;
  color: var(--label-2);
  transition: color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}

.nav-link:hover { color: var(--label); }

.nav-link[aria-current="page"] {
  color: var(--label);
  font-weight: 500;
  background: var(--fill);
}

/* ---------- Theme pull switch ---------- */

.nav-end {
  align-self: stretch;
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-pull {
  position: relative;
  align-self: stretch;
  width: 36px;
  height: auto;
  margin-right: -6px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  cursor: grab;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.theme-pull:hover:not(:disabled),
.theme-pull:active:not(:disabled) { background: none; transform: none; }

.theme-pull.is-pulling { cursor: grabbing; }

.theme-pull:focus-visible { outline: none; }

.theme-pull-cord {
  position: absolute;
  top: 0;
  left: 50%;
  width: 1.5px;
  height: calc(14px + var(--pull, 0px));
  margin-left: -0.75px;
  background: var(--cord);
}

.theme-pull-bulb {
  position: absolute;
  top: 14px;
  left: 50%;
  width: 24px;
  height: 24px;
  margin-left: -12px;
  border-radius: 50%;
  background: radial-gradient(circle at center, #facc15, #fcd34d, #fef9c3);
  box-shadow: 0 0 16px 5px rgba(250, 204, 21, 0.45);
  transform: translateY(var(--pull, 0px));
  transition: box-shadow var(--base) var(--ease);
}

.theme-pull:hover .theme-pull-bulb { box-shadow: 0 0 20px 7px rgba(250, 204, 21, 0.55); }

:root[data-theme="dark"] .theme-pull-bulb {
  background: radial-gradient(circle at center, #4b5563, #1f2937, #000);
  box-shadow: 0 0 16px 5px rgba(31, 41, 55, 0.7), inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

:root[data-theme="dark"] .theme-pull:hover .theme-pull-bulb {
  box-shadow: 0 0 20px 7px rgba(75, 85, 99, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.theme-pull:focus-visible .theme-pull-bulb {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 3px;
}

::view-transition-old(root),
::view-transition-new(root) { animation-duration: 320ms; }

/* ---------- Account: log in button, sign-in sheet, profile menu ---------- */

.account-button {
  height: 32px;
  padding: 0 14px 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--label);
  color: var(--bg);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
  transition: opacity var(--fast) var(--ease), transform var(--fast) var(--ease);
}

.account-button svg { width: 16px; height: 16px; flex: none; }
.account-button:hover:not(:disabled) { background: var(--label); opacity: 0.84; }
.account-button:active:not(:disabled) { background: var(--label); transform: scale(0.96); }

.account-button.is-signed-in,
.account-button.is-signed-in:hover:not(:disabled),
.account-button.is-signed-in:active:not(:disabled) {
  width: 32px;
  padding: 0;
  background: linear-gradient(135deg, #5e5ce6, var(--accent));
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.auth-sheet {
  width: min(400px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--label);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.auth-sheet[open] { animation: account-rise var(--slow) var(--ease-out) both; }

.auth-sheet::backdrop {
  background: rgba(0, 0, 0, 0.32);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: account-fade var(--base) var(--ease) both;
}

.auth-body {
  position: relative;
  padding: 40px 32px 28px;
}

.auth-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--fill);
  color: var(--label-2);
  transition: background-color var(--fast) var(--ease), transform var(--fast) var(--ease);
}

.auth-close:hover:not(:disabled) { background: var(--fill-hover); color: var(--label); }
.auth-close:active:not(:disabled) { background: var(--fill-press); transform: scale(0.92); }
.auth-close svg { width: 13px; height: 13px; }

.auth-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--label);
  color: var(--bg);
  box-shadow: var(--shadow-md);
}

.auth-mark svg { width: 30px; height: 30px; fill: currentColor; }

.auth-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.auth-lede {
  margin: 6px 0 0;
  font-size: 0.9375rem;
  color: var(--label-2);
}

.auth-options {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}

.auth-option {
  width: 100%;
  height: 46px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid var(--separator);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--label);
  font-size: 0.9375rem;
  font-weight: 500;
  transition: background-color var(--fast) var(--ease), transform var(--fast) var(--ease);
}

.auth-option:hover:not(:disabled) { background: var(--fill); }
.auth-option:active:not(:disabled) { background: var(--fill-hover); transform: scale(0.98); }
.auth-option svg { width: 18px; height: 18px; flex: none; }

.auth-status {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--fill);
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--label);
}

.auth-status:empty { display: none; }

.auth-form {
  display: grid;
  gap: 10px;
  margin-top: 24px;
  text-align: left;
}

.auth-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--label-2);
}

.auth-input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--separator);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--label);
  font: inherit;
  font-size: 1rem;
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}

.auth-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.auth-code {
  padding-left: calc(14px + 0.4em);
  text-align: center;
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.4em;
}

.auth-submit {
  height: 46px;
  margin-top: 4px;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #fff;
  font-size: 0.9375rem;
  font-weight: 600;
  transition: background-color var(--fast) var(--ease), transform var(--fast) var(--ease), opacity var(--fast) var(--ease);
}

.auth-submit:hover:not(:disabled) { background: var(--accent-hover); }
.auth-submit:active:not(:disabled) { background: var(--accent-press); transform: scale(0.98); }
.auth-submit:disabled { opacity: 0.6; cursor: default; }

.auth-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 16px;
}

.auth-link {
  justify-self: center;
  height: auto;
  padding: 4px 6px;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 500;
}

.auth-link:hover:not(:disabled) { background: none; text-decoration: underline; text-underline-offset: 3px; }
.auth-link:active:not(:disabled) { background: none; transform: none; }

.auth-sent {
  margin: 0 0 4px;
  text-align: center;
  font-size: 0.875rem;
  color: var(--label-2);
}

.auth-sent strong { color: var(--label); font-weight: 600; overflow-wrap: anywhere; }

.auth-privacy,
.profile-privacy {
  display: flex;
  gap: 8px;
  margin: 20px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--separator);
  text-align: left;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--label-3);
}

.auth-privacy svg,
.profile-privacy svg { width: 14px; height: 14px; flex: none; margin-top: 1px; }

.profile-popover {
  position: fixed;
  inset: auto;
  margin: 0;
  width: 300px;
  max-width: calc(100vw - 24px);
  padding: 20px;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--label);
  box-shadow: var(--shadow-lg);
  transform-origin: top right;
}

.profile-popover:popover-open { animation: account-pop var(--base) var(--ease-out) both; }

.profile-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile-avatar {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #5e5ce6, var(--accent));
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
}

.profile-id { min-width: 0; }

.profile-name,
.profile-email {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-name { font-size: 1rem; font-weight: 600; letter-spacing: -0.016em; }
.profile-email { font-size: 0.8125rem; color: var(--label-2); }

.profile-plan {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--fill);
  font-size: 0.875rem;
}

.profile-plan-label { color: var(--label-2); }

.profile-plan-badge {
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-size: 0.75rem;
  font-weight: 600;
}

.profile-plan-link { margin-left: auto; color: var(--accent); font-weight: 500; }
.profile-plan-link:hover { text-decoration: underline; text-underline-offset: 3px; }

.profile-actions {
  display: grid;
  gap: 2px;
  margin-top: 12px;
}

.profile-action {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--label);
  font-size: 0.9375rem;
  font-weight: 400;
  text-decoration: none;
  transition: background-color var(--fast) var(--ease);
}

.profile-action:hover:not(:disabled) { background: var(--fill); }
.profile-action:active:not(:disabled) { background: var(--fill-hover); transform: none; }
.profile-logout { color: var(--danger); }

.profile-privacy { margin-top: 12px; padding-top: 12px; }

@keyframes account-rise {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

@keyframes account-pop {
  from { opacity: 0; transform: translateY(-4px) scale(0.94); }
  to { opacity: 1; transform: none; }
}

@keyframes account-fade { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 480px) {
  .account-button { width: 32px; padding: 0; }
  .account-label { display: none; }
}

/* ---------- Page ---------- */

.page {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  padding: 24px;
}

/* Home view: hero centred in the space below the nav. */
.hero {
  width: 100%;
  max-width: 880px;
  margin: auto;
  text-align: center;
}

body[data-view="single"] .hero,
body[data-view="batch"] .hero { display: none; }

.display {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.25rem, min(6.5vw, 7.5vh), 4rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.lede {
  max-width: 34rem;
  margin: clamp(10px, 2vh, 20px) auto 0;
  font-size: clamp(1.0625rem, 2.2vw, 1.3125rem);
  line-height: 1.42;
  letter-spacing: -0.016em;
  color: var(--label-2);
}

/* ---------- Drop zone ---------- */

.dropzone {
  position: relative;
  max-width: 640px;
  margin: clamp(20px, 5vh, 48px) auto 0;
  padding: clamp(24px, 6vh, 56px) 32px clamp(20px, 5vh, 48px);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  user-select: none;
  transition:
    transform var(--base) var(--ease-out),
    box-shadow var(--base) var(--ease-out),
    background-color var(--base) var(--ease);
}

.dropzone::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: calc(var(--radius-xl) - 10px);
  border: 1.5px dashed var(--separator);
  pointer-events: none;
  transition: border-color var(--base) var(--ease);
}

.dropzone:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.dropzone:active { transform: translateY(0) scale(0.995); transition-duration: var(--fast); }

.dropzone.is-dragging {
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
  box-shadow: 0 0 0 3px var(--accent), var(--shadow-lg);
  transform: scale(1.01);
}

.dropzone.is-dragging::after { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }

.dropzone-icon {
  width: clamp(48px, 7vh, 60px);
  height: clamp(48px, 7vh, 60px);
  margin: 0 auto clamp(12px, 2.4vh, 20px);
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--accent);
  transition: transform var(--base) var(--ease-out);
}

.dropzone-icon svg { width: 28px; height: 28px; }

.dropzone:hover .dropzone-icon,
.dropzone.is-dragging .dropzone-icon { transform: translateY(-3px); }

.dropzone-title {
  font-size: 1.3125rem;
  font-weight: 600;
  letter-spacing: -0.021em;
}

.dropzone-hint {
  margin-top: 6px;
  font-size: 1rem;
  color: var(--label-2);
}

.link-text { color: var(--accent); }

.dropzone:hover .link-text { text-decoration: underline; text-underline-offset: 3px; }

.dropzone-formats {
  margin-top: clamp(12px, 2.4vh, 20px);
  font-size: 0.8125rem;
  letter-spacing: -0.005em;
  color: var(--label-3);
}

.privacy-note {
  margin-top: clamp(14px, 3vh, 24px);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: var(--label-3);
}

.privacy-note svg { width: 15px; height: 15px; flex: none; }

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* ---------- Single image workspace ---------- */

.workspace {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(0, 1fr) 300px;
  align-content: center;
  align-items: start;
}

.workspace, .batch { animation: rise var(--slow) var(--ease-out) both; }

.viewer { padding: 12px; }

.stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: repeating-conic-gradient(var(--checker-a) 0 25%, var(--checker-b) 0 50%) 0 0 / 20px 20px;
}

/* Before / after compare (see src/shared/imageCompare.js). The original sits
   in flow and sizes the frame; the cleaned layer lies underneath it. */
.cmp {
  position: relative;
  margin: 0 auto;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
  outline: none;
}

.workspace[data-state="done"] .cmp { cursor: ew-resize; }
.cmp[data-held] { cursor: grabbing !important; }

.cmp-before {
  position: relative;
  z-index: 2;
  display: block;
  border-radius: var(--radius-sm);
  max-height: calc(100dvh - var(--chrome));
  object-fit: contain;
}

.cmp-after {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  border-radius: var(--radius-sm);
}

.cmp-img {
  display: block;
  width: 100%;
  height: 100%;
}

.cmp-line {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  fill: none;
  stroke: rgba(255, 255, 255, 0.95);
  stroke-width: 2;
  filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.28));
}

.cmp-grip {
  position: absolute;
  top: 50%;
  z-index: 4;
  width: 0;
  height: 0;
  pointer-events: none;
}

.cmp-knob {
  position: absolute;
  top: -20px;
  left: -20px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  backdrop-filter: blur(12px) saturate(160%);
  color: #1d1d1f;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 4px 14px rgba(0, 0, 0, 0.2);
  transition: transform var(--base) var(--ease-out), box-shadow var(--base) var(--ease-out);
}

.cmp:hover .cmp-knob { transform: scale(1.06); }
.cmp[data-held] .cmp-knob {
  transform: scale(0.92);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.14), 0 2px 8px rgba(0, 0, 0, 0.22);
}
.cmp:focus-visible .cmp-knob { box-shadow: 0 0 0 3px var(--accent), 0 4px 14px rgba(0, 0, 0, 0.2); }

.cmp-tag {
  position: absolute;
  top: 12px;
  z-index: 3;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  backdrop-filter: blur(12px) saturate(160%);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  pointer-events: none;
  opacity: 0;
}

.cmp-tag-before { left: 12px; }
.cmp-tag-after { right: 12px; }

/* The line, knob and tags only exist once there is a result to compare. */
.workspace:not([data-state="done"]) .cmp-line,
.workspace:not([data-state="done"]) .cmp-tag { visibility: hidden; }

/* Processing shimmer over the original while the result is computed. */
.workspace[data-state="processing"] .stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 40;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.28) 50%, transparent 70%) 0 0 / 250% 100%;
  animation: shimmer 1.4s linear infinite;
  pointer-events: none;
}

/* ---------- Inspector ---------- */

.inspector {
  max-height: 100%;
  overflow-y: auto;
  padding: 24px;
}

.meta-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.021em;
}

.meta-status-icon {
  width: 24px;
  height: 24px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--success);
}

.meta-status-icon svg { width: 14px; height: 14px; }

.meta-status.is-warning .meta-status-icon { background: var(--warning); }

.meta-status.is-processing .meta-status-icon {
  background: none;
  border: 2px solid var(--fill-press);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  font-size: 0.875rem;
  border-top: 1px solid var(--separator);
}

.meta-row:last-child { border-bottom: 1px solid var(--separator); }

.meta-row span:first-child { color: var(--label-2); }

.meta-row span:last-child {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.actions {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}

.status-message {
  margin-top: 12px;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--label-2);
  text-align: center;
}

.status-message:empty { display: none; }

.text-warn, .text-warning { color: var(--warning) !important; }
.text-success, .text-primary { color: var(--success) !important; }

/* ---------- Buttons ---------- */

.btn {
  height: 44px;
  padding: 0 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-pill);
  font-size: 1.0625rem;
  font-weight: 500;
  letter-spacing: -0.016em;
  white-space: nowrap;
  transition:
    background-color var(--fast) var(--ease),
    color var(--fast) var(--ease),
    transform var(--fast) var(--ease);
}

.btn svg { width: 18px; height: 18px; flex: none; }

.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-press); }

.btn-secondary { background: var(--fill); color: var(--label); }
.btn-secondary:hover { background: var(--fill-hover); }
.btn-secondary:active { background: var(--fill-press); }

.btn-plain { color: var(--accent); height: 36px; font-size: 0.9375rem; }
.btn-plain:hover { text-decoration: underline; text-underline-offset: 3px; }

.btn-compact {
  height: 34px;
  padding: 0 16px;
  font-size: 0.875rem;
}

.btn-compact svg { width: 15px; height: 15px; }

/* ---------- Batch ---------- */

.batch {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  flex-direction: column;
}

.batch-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.section-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.14;
  letter-spacing: -0.028em;
}

.section-subtitle {
  margin-top: 4px;
  font-size: 0.9375rem;
  color: var(--label-2);
  font-variant-numeric: tabular-nums;
}

.progress-track {
  flex: none;
  height: 4px;
  margin: 16px 0 20px;
  border-radius: 2px;
  background: var(--fill);
  overflow: hidden;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width var(--slow) var(--ease-out);
}

.batch-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  grid-auto-rows: max-content;
  align-content: start;
  gap: 20px;
  /* Room for card shadows and hover lift inside the scroll box. */
  margin: -6px;
  padding: 6px;
}

.batch-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  animation: rise var(--slow) var(--ease-out) both;
  transition: box-shadow var(--base) var(--ease), transform var(--base) var(--ease-out);
}

.batch-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.batch-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  background: var(--separator);
}

.batch-pane {
  position: relative;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-conic-gradient(var(--checker-a) 0 25%, var(--checker-b) 0 50%) 0 0 / 16px 16px;
  overflow: hidden;
}

.batch-pane-label {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.batch-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  opacity: 0;
  transition: opacity var(--base) var(--ease);
}

.batch-image[src]:not([src=""]) { opacity: 1; }

.batch-main { padding: 16px 16px 4px; min-width: 0; }

.batch-title {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.016em;
}

.batch-status {
  margin-top: 2px;
  font-size: 0.8125rem;
  color: var(--label-2);
}

.batch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px 16px;
  margin-top: auto;
}

/* ---------- Loading overlay ---------- */

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  align-items: center;
  justify-content: center;
  background: var(--scrim);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  animation: fade var(--base) var(--ease) both;
}

.loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 28px 36px;
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow-lg);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--label-2);
}

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid var(--fill-press);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

/* ---------- Motion ---------- */

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

@keyframes spin { to { transform: rotate(360deg); } }

@keyframes shimmer {
  from { background-position: 150% 0; }
  to { background-position: -100% 0; }
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  /* Stacked: image on top, a compact action bar below it. */
  :root { --chrome: 327px; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .inspector { padding: 20px; }
  .meta-row { display: none; }
  .meta-status { margin-bottom: 0; }
  .actions { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); margin-top: 12px; gap: 8px; }
  .actions .btn-plain { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
  .nav-inner { padding: 0 16px; }
  .nav-link { padding: 6px 10px; }
  :root { --chrome: 287px; }
  .page { padding: 16px; }
  .dropzone { padding-left: 20px; padding-right: 20px; border-radius: var(--radius-lg); }
  .dropzone::after { border-radius: calc(var(--radius-lg) - 10px); }
  .viewer { padding: 8px; }
  .inspector { padding: 16px; }
  .btn { font-size: 1rem; padding: 0 16px; }
  .batch-list { grid-template-columns: 1fr; }
}

@media (max-height: 540px) {
  body { height: auto; min-height: 100vh; overflow: visible; }
  .batch-list { overflow: visible; }
}

@media (max-width: 420px) {
  .brand-name { display: none; }
}

/* ---------- Accessibility preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
  .dropzone:hover, .batch-card:hover, .dropzone.is-dragging { transform: none; }
  .spinner, .meta-status.is-processing .meta-status-icon { animation: spin 1.6s linear infinite !important; }
}

@media (prefers-reduced-transparency: reduce) {
  .nav { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .loading-overlay { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .cmp-tag, .cmp-knob, .batch-pane-label { -webkit-backdrop-filter: none; backdrop-filter: none; }
  .cmp-tag, .batch-pane-label { background: #1d1d1f; }
}

@media (prefers-contrast: more) {
  :root { --separator: rgba(0, 0, 0, 0.3); --label-2: #3a3a3c; --label-3: #48484a; }
  .card, .dropzone, .batch-card { box-shadow: none; border: 1px solid var(--label-3); }
}
