/* PhotoCleaner – the one stylesheet. Calm neutrals, one accent, light and dark. */
:root {
  color-scheme: light dark;
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #efefec;
  --text: #1d1d1b;
  --muted: #6b6b66;
  --line: #deded9;
  --accent: #2f6f6a;
  --accent-text: #ffffff;
  --accent-soft: #e3efed;
  --warn-bg: #fff4dc;
  --warn-line: #e9c46a;
  --danger: #b4443a;
  --ok: #3c7d4f;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 16px rgb(0 0 0 / 5%);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615;
    --surface: #1f1f1d;
    --surface-2: #2a2a27;
    --text: #ecece8;
    --muted: #a2a29b;
    --line: #34342f;
    --accent: #6fb3ab;
    --accent-text: #0f1f1d;
    --accent-soft: #23302e;
    --warn-bg: #3a3020;
    --warn-line: #8a6d2a;
    --danger: #e0786d;
    --ok: #7cc18f;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
  }
}

* { box-sizing: border-box; }
html { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; }
body { margin: 0; }
a { color: var(--accent); }
h1 { font-size: 1.6rem; font-weight: 600; margin: 0 0 .75rem; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; font-weight: 600; margin: 2rem 0 .75rem; }
h3 { font-size: 1rem; font-weight: 600; margin: 0 0 .5rem; }
.lead { font-size: 1.05rem; color: var(--muted); max-width: 60ch; }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Shell */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem; padding: .9rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-weight: 650; color: var(--text); text-decoration: none; letter-spacing: -0.01em; }
.nav { display: flex; flex-wrap: wrap; gap: .25rem; }
.nav a { padding: .35rem .7rem; border-radius: 999px; color: var(--muted); text-decoration: none; }
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); font-weight: 600; }
.who { margin-left: auto; font-size: .9rem; }
.signout { margin: 0; }
.page { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }
.banner { padding: .75rem 1.5rem; border-bottom: 1px solid var(--warn-line); background: var(--warn-bg); }
.hero { max-width: 34rem; margin: 4rem auto; text-align: center; }

/* Building blocks */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.5rem; box-shadow: var(--shadow); }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.empty { text-align: center; padding: 3rem 1.5rem; }
.btn { display: inline-flex; align-items: center; gap: .4rem; font: inherit; font-size: .95rem; padding: .5rem 1rem; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--danger); }
.btn-small { padding: .25rem .65rem; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.linklike { font: inherit; background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; text-decoration: underline; }
.badge { display: inline-block; font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.badge-default { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.notice { padding: .75rem 1rem; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }
.notice-error { border-color: var(--danger); color: var(--danger); }
.notice-warn { border-color: var(--warn-line); background: var(--warn-bg); }
.notice-ok { border-color: var(--ok); color: var(--ok); }
.inline { display: inline; margin: 0; }

/* Forms */
.field { display: grid; gap: .3rem; margin-bottom: 1rem; }
.field label { font-weight: 600; font-size: .9rem; }
.hint { font-size: .85rem; color: var(--muted); }
.error-text { color: var(--danger); font-size: .85rem; }
input[type="text"], input[type="email"], input[type="number"], input[type="month"], select, textarea {
  font: inherit; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); width: 100%; max-width: 40rem;
}
textarea { min-height: 7rem; resize: vertical; }

/* Tables */
table.data { border-collapse: collapse; width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.data th, table.data td { text-align: left; padding: .6rem .9rem; border-bottom: 1px solid var(--line); }
table.data th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Recipes */
.recipes { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.recipe .instruction { color: var(--muted); font-size: .9rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* Batch view */
.batch-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.batch-picker { width: auto; }
.counts { color: var(--muted); }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); margin-bottom: 1.5rem; }
.tile { font: inherit; color: inherit; text-align: left; display: grid; gap: .4rem; cursor: pointer; border-radius: var(--radius); padding: .5rem; background: var(--surface); border: 1px solid var(--line); }
.tile:hover { box-shadow: var(--shadow); }
.tile-img, .tile-placeholder { display: block; aspect-ratio: 1; width: 100%; border-radius: 6px; object-fit: cover; background: var(--surface-2); }
.tile-placeholder.working { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .tile-placeholder.working { animation: none; } }
.tile-name { font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status { font-size: .75rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px; justify-self: start; background: var(--surface-2); color: var(--muted); }
.status-working { background: var(--accent-soft); color: var(--accent); }
.status-edited { background: var(--accent-soft); color: var(--ok); }
.status-failed { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.reason { color: var(--danger); }

/* Viewer: the batch modal and the test page */
dialog.viewer { width: min(1100px, 96vw); max-height: 94vh; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 0; }
dialog.viewer::backdrop { background: rgb(0 0 0 / 55%); }
.viewer-head { display: flex; align-items: center; gap: 1rem; padding: .9rem 1.25rem; border-bottom: 1px solid var(--line); }
.viewer-head h2 { margin: 0; font-size: 1rem; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-body { padding: 1.25rem; }
.viewer-body > * + * { margin-top: 1rem; }
.tabs { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.tabs button { font: inherit; font-size: .9rem; padding: .4rem .9rem; border: 0; background: var(--surface); color: var(--muted); cursor: pointer; }
.tabs button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); font-weight: 600; }
.compare { position: relative; overflow: hidden; border-radius: 8px; background: var(--surface-2); user-select: none; touch-action: none; cursor: ew-resize; }
.compare img { display: block; width: 100%; height: auto; pointer-events: none; -webkit-user-drag: none; }
.compare .after { position: absolute; inset: 0; width: 100%; height: 100%; }
.compare .divider { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 0 1px rgb(0 0 0 / 35%); pointer-events: none; }
.compare input[type="range"] { position: absolute; left: 1rem; right: 1rem; bottom: .75rem; width: calc(100% - 2rem); }
.compare .label { position: absolute; top: .6rem; font-size: .75rem; padding: .15rem .5rem; border-radius: 999px; background: rgb(0 0 0 / 55%); color: #fff; }
.compare .label-before { left: .6rem; }
.compare .label-after { right: .6rem; }
.single img { display: block; width: 100%; height: auto; border-radius: 8px; }
.crops { margin-top: 1.5rem; }
.crop-pair { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.crop-pair figure { margin: 0; }
.crop-pair img { display: block; width: 100%; height: auto; border-radius: 6px; }
.crop-pair figcaption { font-size: .8rem; color: var(--muted); margin-top: .25rem; }

/* Upload */
.dropzone { display: grid; place-items: center; gap: .5rem; padding: 3rem 1.5rem; border: 2px dashed var(--line); border-radius: var(--radius); background: var(--surface); text-align: center; cursor: pointer; }
.dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.file-list { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: .5rem; }
.file-row { display: grid; grid-template-columns: minmax(0, 1fr) 10rem auto; align-items: center; gap: 1rem; padding: .6rem .9rem; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.file-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row progress { width: 100%; accent-color: var(--accent); }
.file-row .state { font-size: .85rem; color: var(--muted); min-width: 7rem; text-align: right; }
.file-row.failed .state { color: var(--danger); }
.file-row.done .state { color: var(--ok); }
.file-row .batch-link { white-space: nowrap; margin-left: .35rem; }

@media (max-width: 640px) {
  .page { padding: 1.25rem 1rem 3rem; }
  .topbar { padding: .75rem 1rem; }
  .file-row { grid-template-columns: 1fr; }
  .crop-pair { grid-template-columns: 1fr; }
}

/* Front page (signed out) */
.compare [hidden] { display: none; }
.front { --mono: ui-monospace, 'Cascadia Mono', 'SF Mono', Menlo, Consolas, monospace; --magenta: #d81b8c; }
.front-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 26rem); gap: 3rem; align-items: center; padding: 1.5rem 0 1rem; }
.front-eyebrow { font-family: var(--mono); font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 1rem; }
.front-title { font-size: clamp(2.2rem, 5vw, 3.7rem); line-height: 1.02; font-weight: 700; letter-spacing: -0.035em; margin: 0 0 1.25rem; }
.front-title { text-wrap: balance; }
.front-lead { font-size: 1.1rem; color: var(--muted); max-width: 34rem; margin: 0 0 1.75rem; }
.front-actions { margin: 0 0 .75rem; }
.btn-large { font-size: 1.05rem; padding: .75rem 1.4rem; }
.front-note { font-size: .9rem; max-width: 34rem; }
.front-demo { margin: 0; }
.front-compare { border-radius: var(--radius); box-shadow: var(--shadow); }
.front-compare .changes { position: absolute; inset: 0; width: 100%; height: 100%; }
.front-compare.is-static { cursor: default; }
.front-demo figcaption { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; margin-top: .75rem; }
.front-toggle { display: inline-flex; gap: .35rem; }
.front-toggle .btn[aria-pressed='true'] { background: var(--text); border-color: var(--text); color: var(--bg); }
.front-toggle .btn[data-view='changes'][aria-pressed='true'] { background: var(--magenta); border-color: var(--magenta); color: #fff; }
.front-meta { font-family: var(--mono); font-size: .75rem; color: var(--muted); }
.front-section { border-top: 1px solid var(--line); margin-top: 3.5rem; padding-top: 2rem; }
.front-section h2 { margin-top: 0; }
.front-steps { margin: 0; padding-left: 1.25rem; display: grid; gap: .9rem; max-width: 46rem; }
.front-steps li::marker { font-family: var(--mono); color: var(--muted); }
.front-steps code, .front-formats { font-family: var(--mono); font-size: .9em; }
.front-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem 3rem; max-width: 52rem; }
.front-grid p { margin: 0; }
.front-formats { margin: 2rem 0 0; }
@media (max-width: 860px) {
  .front-hero { grid-template-columns: 1fr; gap: 2rem; }
  .front-demo { max-width: 26rem; }
  .front-grid { grid-template-columns: 1fr; }
}
