:root {
  --bg: #0f1115;
  --panel: #151923;
  --muted: #8b93a7;
  --text: #e6e8ee;
  --accent: #4f8cff;
  --accent-2: #22c55e;
  --danger: #ef4444;
  --divider: #2a3142;
}

* { box-sizing: border-box; }
body {
  margin: 0; padding: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg); color: var(--text);
}

/* Header */
header {
  position: sticky; top: 0; z-index: 5;
  background: linear-gradient(180deg, #10131a 0%, rgba(16,19,26,0.8) 100%);
  border-bottom: 1px solid var(--divider);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
header h1 { font-size: 18px; margin: 0; font-weight: 650; letter-spacing: 0.2px; }
.spacer { flex: 1; }

.btn {
  background: #1c2230; color: var(--text);
  border: 1px solid #2a3447; border-radius: 10px; padding: 10px 14px; cursor: pointer;
  display: inline-flex; gap: 8px; align-items: center; font-weight: 600;
}
.btn:hover { border-color: #3a4865; }
.btn.primary { background: #183055; border-color: #2f5fb6; color: #e9f0ff; }
.btn.primary:hover { background: #1e3d6e; }
.btn.success { background: #0e2a1b; border-color: #1b6b3b; color: #eafff3; }
.btn.success:hover { background: #104127; }
.btn.danger { background: #321515; border-color: #7a2a2a; color: #ffecec; }
.btn.danger:hover { background: #4a1e1e; }
.muted { color: var(--muted); }

main { padding: 18px; max-width: 1200px; margin: 0 auto; }

.uploader {
  background: var(--panel); border: 1px dashed #2b3448; border-radius: 14px; padding: 14px; margin-bottom: 18px;
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row > div { background: #0f1320; border: 1px solid #252e42; border-radius: 12px; padding: 12px; }
.row h3 { margin: 0 0 6px; font-size: 14px; font-weight: 700; }

.filebox { border: 1px dashed #33405a; border-radius: 10px; padding: 12px; display: grid; gap: 10px; }
.filebox input[type="file"] { width: 100%; }

.uploader-actions {
  display:flex; gap:10px; align-items:center; margin-top:12px; flex-wrap: wrap;
}
.uploader-actions input[type="text"] {
  flex:1; min-width: 200px; padding: 10px 12px; border-radius: 10px; border: 1px solid #2b3448; background:#0f1320; color:#e6e8ee;
}

.sets { display: grid; gap: 16px; }

.set-card {
  background: var(--panel); border: 1px solid #253047; border-radius: 14px; overflow: hidden;
}
.set-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--divider); }
.set-title { font-weight: 700; }
.set-actions { margin-left: auto; display: flex; gap: 8px; }

/* Comparison core */
.compare {
  position: relative; width: 100%; aspect-ratio: 16 / 9; background: #0b0f18;
  overflow: hidden;
}
.compare img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #0b0f18;
}
.compare .after { clip-path: inset(0 0 0 50%); } /* start at 50% split */
.handle {
  position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; background: #ffffff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.35);
}
.handle .knob {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 44px; height: 44px; border-radius: 999px; background: #0c1220; border: 2px solid #e9eefc;
  display: grid; place-items: center; box-shadow: 0 8px 20px rgba(0,0,0,0.45);
}
.handle .knob:after {
  content: "↔"; color: #e9eefc; font-weight: 800; font-size: 16px;
}
.scrim {
  position: absolute; inset: 0; pointer-events: none; display: flex; justify-content: space-between; align-items: start;
  font-size: 12px; color: #c9d1e5;
  padding: 8px; background: linear-gradient(90deg, rgba(0,0,0,0.3), transparent 30%, transparent 70%, rgba(0,0,0,0.3));
}
.tag { background: rgba(10, 12, 18, 0.6); padding: 6px 10px; border: 1px solid #2c3650; border-radius: 999px; }

/* Zoom/pan wrapper */
.compare-viewport {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: #0b0f18;
}
.compare-stage {
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
  cursor: grab;
}
.compare-stage.dragging { cursor: grabbing; }

.zoom-controls {
  position: absolute;
  top: 10px; right: 10px;
  display: flex; gap: 6px;
  z-index: 2;
}
.zoom-controls button {
  background: rgba(20, 24, 36, 0.8);
  color: #e6e8ee;
  border: 1px solid #2a3447;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}
.zoom-controls button:hover { background: rgba(28, 34, 48, 0.9); }

/* Prevent default browser image drag while panning */
.compare-stage img {
  max-width: none;
  user-select: none;
  pointer-events: none; /* slider UI remains interactive */
}

.footer-note { color: var(--muted); font-size: 12px; margin-top: 12px; }
.hidden { display: none !important; }
.inline { display: inline; }

.tabs {
  display: flex;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--divider);
}
.tab {
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab.active {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

.loading {
  display: flex; justify-content: center; align-items: center;
  padding: 20px; font-style: italic; color: var(--muted);
}

.status-message {
  padding: 12px; margin: 12px 0; border-radius: 8px;
}
.status-message.success {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #4ade80;
}
.status-message.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
}
.status-message.info {
  background: rgba(79, 140, 255, 0.1);
  border: 1px solid rgba(79, 140, 255, 0.3);
  color: #93b3ff;
}

/* Progress bar */
.progress {
  width: 100%;
  height: 10px;
  background: #1b2231;
  border: 1px solid #2a3447;
  border-radius: 999px;
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4f8cff, #22c55e);
  transition: width 0.15s linear;
}

/* Branding */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}
.brand img {
  height: 32px;
  width: auto;
  object-fit: contain;
  display: block;
}
.brand-name {
  font-weight: 700;
  letter-spacing: 0.2px;
}

.hint { margin-top: 8px; }

@media (max-width: 860px) {
  .row { grid-template-columns: 1fr; }
  .compare { aspect-ratio: 4 / 3; }
}