:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-elev: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #475569;
  --accent: #0f172a;
  --accent-text: #ffffff;
  --good: #16a34a;
  --good-bg: #dcfce7;
  --caution: #f59e0b;
  --caution-bg: #fef3c7;
  --replace: #dc2626;
  --replace-bg: #fee2e2;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #111827;
    --surface-elev: #1f2937;
    --border: #1f2937;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #f8fafc;
    --accent-text: #0b1120;
    --good: #22c55e;
    --good-bg: rgba(34, 197, 94, 0.12);
    --caution: #fbbf24;
    --caution-bg: rgba(251, 191, 36, 0.12);
    --replace: #ef4444;
    --replace-bg: rgba(239, 68, 68, 0.12);
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.04), 0 8px 24px rgba(0, 0, 0, 0.5);
  }
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

.hero {
  text-align: left;
  padding: 16px 0 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 16px;
  text-transform: uppercase;
}

.brand-mark {
  font-size: 18px;
}

.hero h1 {
  font-size: 38px;
  line-height: 1.1;
  margin: 0 0 12px;
  letter-spacing: -1px;
  font-weight: 800;
}

.hero .lead {
  margin: 0;
  color: var(--text-muted);
  font-size: 17px;
  max-width: 640px;
}

.uploader {
  margin-top: 24px;
}

.dropzone {
  display: block;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: 18px;
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.dropzone:hover,
.dropzone:focus-visible {
  border-color: var(--text-muted);
  outline: none;
}

.dropzone.dragging {
  border-color: var(--accent);
  background: var(--surface-elev);
  transform: translateY(-1px);
}

.dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.dropzone-icon {
  font-size: 36px;
  margin-bottom: 4px;
}

.dropzone-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.dropzone-hint {
  font-size: 13px;
  color: var(--text-muted);
}

.thumbnails {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

.thumbnails:empty {
  display: none;
}

.thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: none;
  background: rgba(15, 23, 42, 0.7);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.thumb-remove:hover {
  background: rgba(220, 38, 38, 0.85);
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.primary,
.secondary {
  font: inherit;
  font-weight: 600;
  border-radius: 12px;
  padding: 12px 22px;
  cursor: pointer;
  transition: opacity 120ms ease, transform 80ms ease;
  min-height: 48px;
}

.primary {
  background: var(--accent);
  color: var(--accent-text);
  border: 1px solid var(--accent);
}

.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.primary:not(:disabled):hover {
  opacity: 0.9;
}

.primary:not(:disabled):active {
  transform: translateY(1px);
}

.secondary {
  background: transparent;
  color: var(--text);
  border: 1.5px solid var(--border);
}

.secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.secondary:not(:disabled):hover {
  border-color: var(--text-muted);
}

.counter {
  font-size: 13px;
  color: var(--text-muted);
  margin-left: auto;
}

.banner {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--replace-bg);
  color: var(--replace);
  border: 1px solid color-mix(in srgb, var(--replace) 25%, transparent);
  font-size: 14px;
  font-weight: 500;
}

.banner.info {
  background: var(--caution-bg);
  color: var(--caution);
  border-color: color-mix(in srgb, var(--caution) 25%, transparent);
}

.results {
  margin-top: 32px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 16px;
  box-shadow: var(--shadow);
}

@media (max-width: 520px) {
  .result-card {
    grid-template-columns: 1fr;
  }
  .result-card .preview {
    aspect-ratio: 16 / 9;
    width: 100%;
  }
}

.result-card .preview {
  width: 120px;
  aspect-ratio: 1 / 1;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.result-card .preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.result-card .body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 999px;
  color: #fff;
}

.badge.good { background: var(--good); }
.badge.caution { background: var(--caution); }
.badge.replace { background: var(--replace); }
.badge.muted { background: var(--text-muted); }

.kv {
  font-size: 14px;
}

.kv .key {
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 4px;
}

.summary {
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  margin: 4px 0 0;
}

.error-text {
  color: var(--replace);
  font-size: 14px;
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid color-mix(in srgb, var(--text-muted) 30%, transparent);
  border-top-color: var(--text-muted);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 8px;
  vertical-align: -2px;
}

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

.footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

.footer p {
  margin: 0;
  max-width: 540px;
  margin-inline: auto;
}
