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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0a0a14;
  color: #e0e0e0;
  min-height: 100vh;
}

/* Subtle background glow */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(233,69,96,0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(68,170,255,0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.2rem 2rem;
  position: relative;
  z-index: 1;
}

/* ── Header ─────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid #1a1a2e;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-icon {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
}
.brand-icon span {
  width: 12px;
  height: 18px;
  border-radius: 2px;
}
.brand-icon .filled { background: #e94560; }
.brand-icon .outline { border: 2px solid #e94560; background: transparent; }
.brand-text h1 {
  font-size: 1.4rem;
  font-weight: 900;
  color: #fff;
  line-height: 1;
  letter-spacing: -0.5px;
}
.brand-text .tagline {
  font-size: 0.6rem;
  color: #e94560;
  text-transform: uppercase;
  letter-spacing: 4px;
  font-weight: 600;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ── Helper pill ────────────────────────────── */
.helper-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.72rem;
  transition: all 0.3s;
}
.helper-pill.connected {
  background: rgba(107,255,107,0.08);
  border: 1px solid rgba(107,255,107,0.2);
  color: #6bff6b;
}
.helper-pill.disconnected {
  background: rgba(255,107,107,0.08);
  border: 1px solid rgba(255,107,107,0.2);
  color: #ff6b6b;
}
.helper-pill.connecting {
  background: rgba(123,140,255,0.08);
  border: 1px solid rgba(123,140,255,0.2);
  color: #7b8cff;
}
.helper-pill .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.helper-pill.connected .dot {
  background: #6bff6b;
  box-shadow: 0 0 6px rgba(107,255,107,0.5);
}
.helper-pill.disconnected .dot {
  background: #ff6b6b;
  box-shadow: 0 0 6px rgba(255,107,107,0.5);
}
.helper-pill.connecting .dot {
  background: #7b8cff;
  animation: pulse 1.5s ease-in-out infinite;
}

.scan-order { color: #666; font-size: 0.78rem; }
.scan-order a { color: #4af; text-decoration: none; font-weight: 600; }
.scan-order a:hover { text-decoration: underline; }

/* ── Controls bar ───────────────────────────── */
.controls {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1rem;
  min-height: 2rem;
}
.scan-controls-inline {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
.scan-controls-inline.hidden { display: none; }
.scan-btn {
  padding: 0.6rem 1.6rem;
  background: #e94560;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.scan-btn:hover:not(:disabled) { background: #c73552; }
.scan-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.scan-btn.scanning {
  background: #1a2e3e;
  color: #6baaff;
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }
.dpi-sel {
  padding: 0.4rem 0.5rem;
  background: #1a1a2e;
  color: #aaa;
  border: 1px solid #333;
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: pointer;
}
.dpi-sel:hover { border-color: #888; }
.scan-status-text { color: #6bff6b; font-size: 0.78rem; }

.controls-right {
  margin-left: auto;
  display: flex;
  gap: 0.5rem;
}
.queue-tag {
  font-size: 0.68rem;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 600;
}
.queue-tag.front { background: rgba(106,170,255,0.15); color: #6baaff; }
.queue-tag.back { background: rgba(196,123,255,0.15); color: #c47bff; }

/* ── Status ─────────────────────────────────── */
.status {
  text-align: center;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.82rem;
}
.status.loading { background: #1a1a3e; color: #7b8cff; }
.status.ready   { background: #1a2e1a; color: #6bff6b; }
.status.error   { background: #2e1a1a; color: #ff6b6b; }

/* ── Dropzone ───────────────────────────────── */
.dropzone {
  border: 2px dashed #2a2a4a;
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 1rem;
}
.dropzone:hover, .dropzone.dragover {
  border-color: #e94560;
  background: rgba(233,69,96,0.04);
}
.dropzone.disabled { opacity: 0.3; pointer-events: none; }
.dropzone input { display: none; }
.dropzone-icon { font-size: 1.3rem; margin-bottom: 0.1rem; }
.dropzone p { color: #888; font-size: 0.78rem; }
.dropzone .hint { font-size: 0.65rem; color: #444; margin-top: 0.1rem; }

/* ── Stats ──────────────────────────────────── */
.stats {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
  margin-bottom: 0.8rem;
}
.stats.hidden { display: none; }
.stat { font-size: 0.7rem; color: #888; }
.stat strong { color: #fff; font-size: 0.8rem; }

/* ── Pairs grid — 4 across ──────────────────── */
.pairs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.pair-card {
  background: #12122a;
  border: 1px solid #1e1e3a;
  border-radius: 8px;
  padding: 0.5rem;
  transition: all 0.15s;
}
.pair-card:hover {
  border-color: #333;
  background: #151530;
}
.pair-card.mismatch-card {
  border-color: rgba(255,68,68,0.3);
}

.pair-images {
  display: flex;
  gap: 4px;
  margin-bottom: 0.3rem;
}
.pair-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.pair-img {
  width: 100%;
  aspect-ratio: 0.59;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  cursor: zoom-in;
}
.pair-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
}
.pair-img .side-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.5rem;
  color: rgba(255,255,255,0.7);
  background: linear-gradient(transparent, rgba(0,0,0,0.6));
  padding: 6px 0 2px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.pair-img.waiting {
  border: 1px dashed #2a2a4a;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
  font-size: 0.55rem;
  font-style: italic;
  cursor: default;
}
.pair-img.waiting.drop-hover {
  border-color: #4af;
  background: rgba(68,170,255,0.06);
  color: #4af;
}
.pair-img[draggable="true"] { cursor: grab; }
.pair-img[draggable="true"]:active { cursor: grabbing; opacity: 0.6; }

/* Cert under each image */
.cert-under {
  margin-top: 3px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.62rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.3px;
  cursor: pointer;
  padding: 1px 4px;
  border-radius: 3px;
  border: 1px solid transparent;
  transition: all 0.15s;
  text-align: center;
  white-space: nowrap;
}
.cert-under:hover {
  border-color: #4af;
  background: rgba(68,170,255,0.06);
}
.cert-under.pending {
  color: #444;
  font-weight: 400;
  font-size: 0.55rem;
  font-style: italic;
  font-family: inherit;
}
.cert-under.mismatch {
  color: #ff4444;
}

.pair-status {
  text-align: center;
  font-size: 0.55rem;
  margin-bottom: 0.3rem;
}
.pair-status.ok { color: #6bff6b; }
.pair-status.warn { color: #ff4444; }
.pair-status.wait { color: #ff6b6b; }

.pair-actions {
  display: flex;
  gap: 4px;
  justify-content: center;
}
.pair-actions button {
  padding: 4px 10px;
  border: 1px solid #333;
  background: rgba(255,255,255,0.03);
  color: #aaa;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.pair-actions button:hover {
  border-color: #e94560;
  color: #e94560;
  background: rgba(233,69,96,0.08);
}
.pair-actions .del-btn {
  color: #f66;
  border-color: rgba(255,102,102,0.3);
}
.pair-actions .del-btn:hover {
  background: rgba(255,102,102,0.1);
  border-color: #f66;
}

/* ── Actions bar ────────────────────────────── */
.actions-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.8rem;
  background: #12122a;
  border-radius: 10px;
  border: 1px solid #1e1e3a;
}
.actions-bar.hidden { display: none; }
.folder-input {
  padding: 0.5rem 0.8rem;
  background: #0a0a14;
  color: #fff;
  border: 1px solid #333;
  border-radius: 6px;
  font-size: 0.8rem;
  width: 200px;
}
.folder-input:focus { border-color: #e94560; outline: none; }
.folder-input::placeholder { color: #555; }

.primary-btn {
  padding: 0.5rem 1.2rem;
  background: #e94560;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.primary-btn:hover { background: #c73552; }

.secondary-btn {
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid #333;
  color: #888;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}
.secondary-btn:hover { border-color: #888; color: #ccc; }

/* ── Lightbox ───────────────────────────────── */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.92);
  cursor: zoom-out;
  justify-content: center;
  align-items: center;
}
.lightbox.open { display: flex; }
.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 0 40px rgba(0,0,0,0.6);
}
