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

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

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

header {
  text-align: center;
  margin-bottom: 2rem;
}

h1 {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, #6366f1, #8b5cf6, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: #71717a;
  margin-top: 0.25rem;
}

/* Upload area */
.upload-area {
  border: 2px dashed #27272a;
  border-radius: 12px;
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
  overflow: hidden;
}

.upload-area:hover,
.upload-area.dragover {
  border-color: #6366f1;
  background: rgba(99, 102, 241, 0.05);
}

.upload-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  color: #71717a;
}

.upload-prompt svg {
  color: #6366f1;
}

.hint {
  font-size: 0.8rem;
  color: #52525b;
}

.preview {
  max-width: 100%;
  max-height: 400px;
  border-radius: 8px;
  object-fit: contain;
}

/* Button */
.btn {
  display: block;
  width: 100%;
  margin-top: 1rem;
  padding: 0.85rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn:hover {
  opacity: 0.9;
}

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

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
  color: #a1a1aa;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #27272a;
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* Results */
.results {
  margin-top: 2rem;
}

.best-guess {
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 1rem;
  color: #a78bfa;
}

/* Keywords badges */
.keywords-section {
  text-align: center;
  margin-bottom: 1.5rem;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  border-radius: 999px;
  background: #1e1b4b;
  color: #a5b4fc;
  border: 1px solid #312e81;
}

.badge-category {
  background: #14532d;
  color: #86efac;
  border-color: #166534;
  font-weight: 600;
}

/* ─── Store products grid ─── */
.store-section {
  margin-bottom: 2rem;
}

.section-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: #e4e4e7;
}

.store-count {
  font-size: 0.85rem;
  color: #71717a;
  margin-bottom: 1rem;
}

.store-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.store-card {
  background: #18181b;
  border: 1px solid #27272a;
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
}

.store-card:hover {
  border-color: #6366f1;
  transform: translateY(-2px);
}

.store-card-img {
  position: relative;
  width: 100%;
  height: 180px;
  background: #0f0f13;
}

.store-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.match-score {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.9);
  color: #fff;
}

.store-card-body {
  padding: 0.85rem;
}

.store-card-body h4 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: #e4e4e7;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.store-card-meta {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

.category-tag {
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: #1e1b4b;
  color: #a5b4fc;
}

.rating-tag {
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: #422006;
  color: #fbbf24;
}

.store-card-price {
  margin-bottom: 0.3rem;
}

.price {
  font-size: 1rem;
  font-weight: 700;
  color: #22c55e;
}

.original-price {
  font-size: 0.8rem;
  color: #52525b;
  text-decoration: line-through;
  margin-left: 0.4rem;
}

.in-stock {
  font-size: 0.75rem;
  color: #4ade80;
}

.out-stock {
  font-size: 0.75rem;
  color: #ef4444;
}

/* Vision details collapsible */
.vision-details {
  margin-top: 1.5rem;
  border: 1px solid #27272a;
  border-radius: 10px;
  overflow: hidden;
}

.vision-details summary {
  padding: 0.85rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #71717a;
  cursor: pointer;
  background: #18181b;
  transition: color 0.2s;
}

.vision-details summary:hover {
  color: #a1a1aa;
}

.vision-details[open] summary {
  border-bottom: 1px solid #27272a;
}

.vision-details .results-grid,
.vision-details .result-card {
  margin: 1rem;
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.result-card {
  background: #18181b;
  border: 1px solid #27272a;
  border-radius: 10px;
  padding: 1.25rem;
}

.result-card h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #71717a;
  margin-bottom: 0.75rem;
}

.result-card ul {
  list-style: none;
}

.result-card li {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
  border-bottom: 1px solid #1e1e22;
  font-size: 0.9rem;
}

.result-card li:last-child {
  border-bottom: none;
}

.confidence {
  color: #6366f1;
  font-weight: 600;
  font-size: 0.8rem;
}

.full-width {
  grid-column: 1 / -1;
  margin-top: 1rem;
}

.result-card a {
  color: #818cf8;
  text-decoration: none;
  font-size: 0.9rem;
  word-break: break-all;
}

.result-card a:hover {
  text-decoration: underline;
}

.result-card pre {
  white-space: pre-wrap;
  font-size: 0.85rem;
  color: #a1a1aa;
  max-height: 150px;
  overflow-y: auto;
}

/* Similar images grid */
.similar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.similar-grid a {
  display: block;
}

.similar-grid img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #27272a;
  transition: border-color 0.2s;
}

.similar-grid img:hover {
  border-color: #6366f1;
}

/* Utility */
.hidden {
  display: none !important;
}

@media (max-width: 600px) {
  .results-grid {
    grid-template-columns: 1fr;
  }

  .store-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 420px) {
  .store-grid {
    grid-template-columns: 1fr;
  }
}
