:root {
  --bg: #0a0a0a;
  --surface: #121212;
  --surface-2: #171717;
  --border: rgba(255,255,255,0.08);
  --white: #ffffff;
  --gray: #8b8b8b;
  --gray-dim: #666666;
  --red: #ff3131;

  --sp-1: 8px;
  --sp-2: 16px;
  --sp-3: 24px;
  --sp-4: 32px;
  --sp-5: 48px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  background-image: linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
                     linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 56px 56px;
  color: var(--white);
  font-family: "Inter", sans-serif;
  overflow-x: hidden;
}

.container { width: min(1300px, 92%); margin: auto; }

.hero {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: var(--sp-5);
  padding: var(--sp-5) 0;
}

/* ---------- LEFT ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: 50px;
  color: #d6c4a8;
  font-size: 12px;
  letter-spacing: 3px;
  font-family: "IBM Plex Mono", monospace;
  margin-bottom: var(--sp-4);
}

.left h1 {
  font-family: "Space Grotesk", sans-serif;
  font-size: 76px;
  line-height: 0.95;
  font-weight: 700;
  margin-bottom: var(--sp-2);
}

.left span { color: var(--red); }

.left h2 {
  font-family: "Space Grotesk", sans-serif;
  font-size: 34px;
  font-weight: 500;
  color: #d4d4d4;
  margin-bottom: var(--sp-3);
}

.left p {
  color: var(--gray);
  font-size: 16px;
  line-height: 1.7;
  max-width: 480px;
}

/* ---------- RIGHT / CARD ---------- */

.right { display: flex; justify-content: center; }

.card {
  width: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  position: relative;
}

.view { display: none; flex-direction: column; align-items: center; text-align: center; }

.card[data-state="upload"] #uploadView { display: flex; }
.card[data-state="loading"] #loadingView { display: flex; }
.card[data-state="result"] #resultView { display: flex; }

/* ---------- UPLOAD STATE ---------- */

.scanner {
  position: relative;
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--sp-3);
}

.scanner-ring {
  position: absolute;
  inset: 0;
  border: 2px solid #2a2a2a;
  border-radius: 50%;
  animation: pulse 2.5s infinite;
}

.scanner-ring.second { inset: 18px; animation-delay: 0.4s; }

.scanner-core {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 16px var(--red);
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.06); opacity: 1; border-color: var(--red); }
}

.preview {
  width: 100%;
  height: 220px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin-bottom: var(--sp-3);
}

.hidden { display: none !important; }

#uploadTitle {
  font-family: "Space Grotesk", sans-serif;
  font-size: 24px;
  margin-bottom: var(--sp-1);
}

#uploadText { color: var(--gray); font-size: 14px; margin-bottom: var(--sp-1); }

.view small {
  color: var(--gray-dim);
  letter-spacing: 2px;
  font-size: 11px;
  font-family: "IBM Plex Mono", monospace;
}

.btn-row {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
}

.btn {
  width: 100%;
  padding: 15px;
  border-radius: var(--radius-md);
  font-family: "Space Grotesk", sans-serif;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, opacity 0.2s ease;
}

.btn:active { transform: scale(0.98); }

.btn-ghost {
  background: transparent;
  color: var(--white);
  border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--red); }

.btn-primary {
  background: var(--red);
  color: var(--white);
  border: 1px solid var(--red);
}
.btn-primary:hover { background: #ff4d4d; }
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-full { margin-top: var(--sp-3); }

/* ---------- LOADING STATE ---------- */

.loader-circle {
  width: 72px; height: 72px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--red);
  animation: spin 0.9s linear infinite;
  margin-bottom: var(--sp-3);
}

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

#loadingView h3 {
  font-family: "Space Grotesk", sans-serif;
  font-size: 22px;
  margin-bottom: var(--sp-3);
}

.progress {
  width: 100%;
  height: 6px;
  background: var(--surface-2);
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: var(--sp-2);
}

#progressBar {
  width: 0%;
  height: 100%;
  background: var(--red);
  transition: width 0.4s ease;
}

#loadingStatus {
  color: var(--gray);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  letter-spacing: 1px;
}

/* ---------- RESULT STATE ---------- */

#resultView { align-items: stretch; text-align: left; }

.result-image {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin-bottom: var(--sp-3);
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}

.info-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-2);
}

.info-card.full { grid-column: 1 / -1; }

.info-card label {
  display: block;
  color: var(--gray-dim);
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-family: "IBM Plex Mono", monospace;
  margin-bottom: 6px;
}

.info-card h4 {
  font-size: 18px;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  line-height: 1.3;
}

.analysis {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-2);
  margin-bottom: var(--sp-2);
}

.analysis label {
  display: block;
  color: var(--gray-dim);
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-family: "IBM Plex Mono", monospace;
  margin-bottom: 8px;
}

.analysis p { color: #d8d8d8; font-size: 13px; line-height: 1.6; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: var(--sp-3);
}

.chip {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--red);
  border: 1px solid rgba(255,49,49,0.4);
  border-radius: 4px;
  padding: 4px 8px;
}

.error-box {
  background: #1b1616;
  border: 1px solid var(--red);
  border-radius: var(--radius-md);
  padding: var(--sp-2);
  color: var(--gray);
  font-size: 13px;
}

/* ---------- RESPONSIVE ---------- */

@media (max-width: 1000px) {
  .hero { grid-template-columns: 1fr; text-align: center; padding: var(--sp-4) 0; }
  .left p { margin: auto; }
  .left h1 { font-size: 56px; }
  .left h2 { font-size: 26px; }
  .card { width: 100%; max-width: 460px; }
}
