:root {
  color-scheme: light dark;
  --bg: #0b0d12;
  --bg-grad: radial-gradient(1200px 600px at 50% -10%, #1a2440 0%, #0b0d12 55%);
  --panel: #161922;
  --panel-2: #1d212c;
  --border: #2a2f3d;
  --text: #eef0f4;
  --muted: #97a0b3;
  --accent: #6d9fff;
  --accent-2: #8a7bff;
  --good: #3fd07a;
  --mid: #f0c04c;
  --bad: #ff6b6b;
  --radius: 14px;
  --shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg-grad), var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 3rem 1.25rem 4rem;
}

/* Hero / header */

.hero {
  text-align: center;
  margin-bottom: 2.25rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 1.1rem;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #060810;
  font-weight: 800;
  font-size: 0.8rem;
}

h1 {
  font-size: clamp(1.6rem, 3.2vw, 2.1rem);
  margin: 0 0 0.5rem;
  letter-spacing: -0.01em;
}

.subtitle {
  color: var(--muted);
  max-width: 46rem;
  margin: 0 auto;
  line-height: 1.5;
}

.subtitle code {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
  font-size: 0.9em;
}

/* Uploader */

.uploader {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: stretch;
  margin: 0 0 1.75rem;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 2.25rem 1.5rem;
  border-radius: var(--radius);
  border: 1.5px dashed var(--border);
  background: var(--panel);
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.dropzone:hover,
.dropzone:focus-within {
  border-color: var(--accent);
  color: var(--text);
  background: var(--panel-2);
}

.dropzone.drag-over {
  border-color: var(--accent);
  background: var(--panel-2);
  color: var(--text);
}

.dropzone.has-file {
  border-style: solid;
  border-color: var(--accent);
  color: var(--text);
}

.dropzone-icon { color: var(--accent); }

.dropzone-text code {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
}

button[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #060810;
  border: none;
  border-radius: 10px;
  padding: 0.75rem 1.25rem;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.1s ease, opacity 0.15s ease;
}

button[type="submit"]:hover:not(:disabled) { transform: translateY(-1px); }
button[type="submit"]:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* Panels: status / error */

.panel {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
}

.status-panel {
  background: var(--panel);
  color: var(--text);
  flex-direction: column;
  align-items: stretch;
  gap: 0.6rem;
}

.status-panel .status-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.status-panel #status-line { margin: 0; }

.progress-track {
  height: 6px;
  border-radius: 999px;
  background: var(--panel-2);
  overflow: hidden;
}

.progress-track[hidden] { display: none !important; }

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.15s ease;
}

.error-panel {
  background: rgba(255, 107, 107, 0.08);
  border-color: rgba(255, 107, 107, 0.35);
  color: var(--bad);
}

.error-panel svg { flex: none; color: var(--bad); }

.error { color: var(--bad); font-weight: 600; margin: 0; }

/* Spinner */

.spinner {
  flex: none;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

button .spinner {
  width: 0.95rem;
  height: 0.95rem;
  border-color: rgba(6, 8, 16, 0.35);
  border-top-color: #060810;
}

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

/* Results */

h2 {
  font-size: 1.05rem;
  margin: 2rem 0 0.85rem;
  color: var(--text);
  letter-spacing: -0.005em;
}

h2:first-of-type { margin-top: 0.5rem; }

.score-grid, .image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.image-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.score-card {
  background: var(--panel);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  transition: border-color 0.15s ease;
}

.score-card:hover { border-color: #3a4155; }

.score-card .label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.score-card .value {
  font-size: 1.75rem;
  font-weight: 800;
  margin-top: 0.25rem;
  font-variant-numeric: tabular-nums;
}

.score-card.combined {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, rgba(109, 159, 255, 0.12), rgba(138, 123, 255, 0.08));
  border-color: var(--accent);
}

.value.good { color: var(--good); }
.value.mid { color: var(--mid); }
.value.bad { color: var(--bad); }

.image-grid img {
  width: 100%;
  display: block;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
}

.detailed-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.detailed-link:hover { text-decoration: underline; }

iframe#detailed-frame {
  width: 100%;
  height: 420px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.note {
  color: var(--muted);
  font-size: 0.85rem;
}

.footer {
  margin-top: 3rem;
  text-align: center;
}

.footer .note { margin: 0; }
