:root {
  --bg: #1c1c1e;
  --panel: #2a2a2c;
  --sunken: #161618;
  --line: #3a3a3e;
  --text: #f0f0f2;
  --muted: #9a9aa0;
  --accent: #4c8dff;
  --ok: #7dcea0;
  --err: #e07070;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font: 13px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 28px 20px 60px;
}

.wrap { max-width: 1040px; margin: 0 auto; }

h1 { font-size: 22px; font-weight: 650; margin-bottom: 6px; }
.sub { color: var(--muted); margin-bottom: 22px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
}

.cardhead {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  font-size: 14px;
  margin-bottom: 14px;
}
.cardhead .spacer { flex: 1; }
.num {
  display: inline-grid;
  place-items: center;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

/* ---------- preset chooser ---------- */
.choices { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }

.choice {
  text-align: left;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 13px;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.choice:hover { background: #1c1c20; }
.choice.on { border-color: var(--accent); background: #1a2740; }
.choice b { display: block; font-size: 13px; margin-bottom: 3px; }
.choice small { color: var(--muted); font-size: 11px; line-height: 1.35; display: block; }

.params {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 2px 18px;
  background: var(--sunken);
  border-radius: 8px;
  padding: 11px 13px;
  margin-bottom: 12px;
}
.kv { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; font-size: 12px; }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; }

/* ---------- rows / controls ---------- */
.row { display: flex; gap: 10px; align-items: center; }
.row label { color: var(--muted); flex: none; }
.sliderrow { margin-top: 2px; }
input[type="range"] { flex: 1; accent-color: var(--accent); }
.val { width: 46px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

button {
  font: inherit;
  color: inherit;
  background: #3a3a40;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 14px;
  cursor: pointer;
}
button:hover:not(:disabled) { background: #45454c; }
button.primary { background: var(--accent); border-color: transparent; font-weight: 650; }
button.primary:hover:not(:disabled) { background: #5f9aff; }
button.ghost { background: transparent; }
button:disabled { opacity: .45; cursor: default; }

/* ---------- dropzone ---------- */
.drop {
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  padding: 18px;
  background: var(--sunken);
  transition: border-color .15s, background .15s;
}
.drop.over { border-color: var(--accent); background: #1a2740; }
.dropicon {
  display: grid; place-items: center;
  width: 42px; height: 42px; flex: none;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 22px; color: var(--muted);
}
.droptext { flex: 1; }
.droptext small { display: block; color: var(--muted); margin-top: 3px; font-size: 11px; }
.dropbtns { display: flex; gap: 8px; flex: none; }

.limits { color: var(--muted); font-size: 11px; margin-top: 10px; }

/* ---------- preview grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.grid:empty { display: none; }

.thumb {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  background: var(--sunken);
  aspect-ratio: 1 / 1;
}
.thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  /* The cards are drag targets for the before/after comparison, so suppress the
     native image drag (it would paint a ghost thumbnail instead of moving the split). */
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
}
.thumb .cap {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 14px 7px 5px;
  font-size: 10px;
  line-height: 1.3;
  background: linear-gradient(transparent, rgba(0, 0, 0, .82));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thumb .badge {
  position: absolute;
  top: 6px; right: 6px;
  padding: 2px 6px;
  border-radius: 99px;
  font-size: 10px;
  background: rgba(0, 0, 0, .65);
}
.thumb .badge.err { background: var(--err); color: #2a0d0d; font-weight: 700; }
.thumb .badge.done { background: var(--ok); color: #0d2a18; font-weight: 700; }
.thumb .drop-btn {
  position: absolute;
  top: 4px; left: 4px;
  width: 20px; height: 20px;
  padding: 0;
  border-radius: 50%;
  font-size: 13px;
  line-height: 1;
  background: rgba(0, 0, 0, .6);
  border-color: transparent;
  display: grid;
  place-items: center;
}

/* ---------- before/after compare ---------- */
.cmp { position: relative; cursor: ew-resize; user-select: none; touch-action: none; }
.cmp img { position: absolute; inset: 0; }
.cmp .after { clip-path: inset(0 0 0 50%); }
.cmp .handle {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: rgba(255, 255, 255, .9);
  left: 50%;
  pointer-events: none;
  box-shadow: 0 0 6px rgba(0, 0, 0, .6);
}
.cmp .handle::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 22px; height: 22px;
  margin: -11px 0 0 -11px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .92);
  border: 2px solid rgba(0, 0, 0, .35);
}
.cmp .tag {
  position: absolute;
  top: 6px;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  background: rgba(0, 0, 0, .6);
}
.cmp .tag.in { left: 26px; }
.cmp .tag.out { right: 26px; }

/* ---------- progress ---------- */
.runrow { margin-top: 16px; }
.bar { height: 8px; background: var(--sunken); border-radius: 99px; overflow: hidden; margin: 12px 0 6px; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.status { color: var(--muted); }
.status.err { color: var(--err); }
.status.ok { color: var(--ok); }
.progress { color: var(--muted); font-size: 11px; min-height: 1.5em; font-variant-numeric: tabular-nums; }

.hint { color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.results { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

.foot { color: var(--muted); font-size: 11px; margin-top: 26px; text-align: center; line-height: 1.9; }
.foot > span { display: block; }
.fcopy { color: var(--muted); opacity: .85; }
.fsep { margin: 0 6px; opacity: .5; }
.fver { font-variant-numeric: tabular-nums; }

/* ---------- history ---------- */
button.small { padding: 5px 10px; font-size: 11px; }
button.danger { color: var(--err); }
button.danger:hover:not(:disabled) { background: rgba(224, 112, 112, .16); }

.hstat { color: var(--muted); font-size: 11px; font-weight: 400; margin-right: 4px; }

.hlist { display: flex; flex-direction: column; gap: 8px; }
.hlist:empty::after {
  content: "还没有处理记录。上传一批照片后就出现在这里。";
  color: var(--muted);
  font-size: 12px;
  padding: 10px 2px;
}

.hrow {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 11px;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  width: 100%;
}
.hrow:hover { background: #1c1c20; border-color: #48484f; }
.hrow.on { border-color: var(--accent); background: #1a2740; }
.hrow.dead { opacity: .6; }

.hthumb {
  width: 46px; height: 46px;
  flex: none;
  border-radius: 7px;
  overflow: hidden;
  background: #101012;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
}
.hthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hthumb .none { color: var(--muted); font-size: 16px; }

.hmain { flex: 1; min-width: 0; }
.htitle {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 3px;
  font-size: 12.5px;
}
.htitle b { font-weight: 650; }
.hsub {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.chip {
  padding: 1.5px 7px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 650;
  flex: none;
}
.chip.done { background: rgba(125, 206, 160, .2); color: var(--ok); }
.chip.error { background: rgba(224, 112, 112, .2); color: var(--err); }
.chip.running { background: rgba(76, 141, 255, .22); color: var(--accent); }
.chip.queued { background: rgba(154, 154, 160, .2); color: var(--muted); }

.hacts { display: flex; gap: 6px; flex: none; }

.hmeta {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  padding-left: 4px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.htime {
  font-size: 11.5px;
  color: #c9c9d1;
  font-weight: 600;
  white-space: nowrap;
}
.hago {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}

.rwhen {
  margin-left: 10px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hbar {
  height: 3px;
  background: #101012;
  border-radius: 99px;
  overflow: hidden;
  margin-top: 5px;
}
.hbar > i { display: block; height: 100%; background: var(--accent); transition: width .3s; }

@media (max-width: 720px) {
  .hacts { display: none; }
  .hthumb { width: 38px; height: 38px; }
  .hago { display: none; }
}

/* ---------- fullscreen viewer ---------- */
.thumb .zoom {
  position: absolute;
  top: 4px; right: 4px;
  width: 22px; height: 22px;
  padding: 0;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1;
  background: rgba(0, 0, 0, .55);
  border-color: transparent;
  display: grid;
  place-items: center;
  color: #fff;
}
.thumb .zoom:hover { background: var(--accent); }

.viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: rgba(10, 10, 12, .97);
}
.viewer[hidden] { display: none; }

/* When the viewer itself is the fullscreen element, `inset: 0` and the translucent
   backdrop must give way to the real screen: flush background, no rounded chrome. */
.viewer:fullscreen,
.viewer:-webkit-full-screen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: #08080a;
  border-radius: 0;
}
.viewer:fullscreen .vtop,
.viewer:fullscreen .vbottom,
.viewer:-webkit-full-screen .vtop,
.viewer:-webkit-full-screen .vbottom {
  background: rgba(0, 0, 0, .5);
}

.vtop, .vbottom {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  flex: none;
  background: rgba(0, 0, 0, .35);
}
.vtop { border-bottom: 1px solid var(--line); }
.vbottom { border-top: 1px solid var(--line); }

.vname {
  font-weight: 600;
  max-width: 46vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vspacer { flex: 1; }
.vhint, .vcounter, .vsizes { color: var(--muted); font-size: 11px; }
.vsizes { flex: 1; text-align: center; }

.vbtn {
  background: rgba(255, 255, 255, .08);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 7px;
  padding: 6px 11px;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
}
.vbtn:hover:not(:disabled) { background: rgba(255, 255, 255, .18); }
.vbtn:disabled { opacity: .35; cursor: default; }
.vbtn.wide { min-width: 108px; text-align: center; }

.vstage {
  position: relative;
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: ew-resize;
  user-select: none;
  touch-action: none;
}
.vstage img {
  position: absolute;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  /* Dragging the split handle starts on top of an <img>. Without this, the browser
     runs its own image drag and paints a translucent thumbnail ("ghost") that follows
     the cursor and lingers until drop. */
  -webkit-user-drag: none;
  user-drag: none;
  user-select: none;
  pointer-events: none;
}
.vstage img.vAfter { clip-path: inset(0 0 0 50%); }
.vstage.single img.vAfter { display: none; }
.vstage.single { cursor: default; }

.vhandle {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 2px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 0 8px rgba(0, 0, 0, .8);
  pointer-events: none;
}
.vhandle::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 30px; height: 30px;
  margin: -15px 0 0 -15px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .94);
  border: 2px solid rgba(0, 0, 0, .4);
}
.vstage.single .vhandle, .vstage.single .vtag { display: none; }

.vtag {
  position: absolute;
  top: 12px;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11px;
  background: rgba(0, 0, 0, .65);
  pointer-events: none;
}
.vtag.left { left: 16px; }
.vtag.right { right: 16px; }

.vloading {
  position: absolute;
  bottom: 14px;
  padding: 4px 12px;
  border-radius: 99px;
  background: rgba(0, 0, 0, .7);
  color: var(--muted);
  font-size: 11px;
}
.vloading[hidden] { display: none; }

@media (max-width: 720px) {
  body { padding: 18px 12px 48px; }
  .choices { grid-template-columns: repeat(2, 1fr); }
  .drop { flex-direction: column; align-items: stretch; text-align: center; }
  .dropicon { margin: 0 auto; }
  .dropbtns { justify-content: center; }
  .vhint { display: none; }
  .vname { max-width: 34vw; }
  .vsizes { display: none; }
}
