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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f5f5;
  color: #1a1a1a;
  line-height: 1.5;
}

main {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 16px;
}

h1 {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.subtitle {
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 24px;
}

form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

label {
  font-weight: 600;
  font-size: 0.95rem;
}

.optional {
  font-weight: 400;
  color: #888;
  font-size: 0.85rem;
}

input[type="url"],
input[type="text"],
input[type="number"],
textarea,
select {
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 16px; /* prevents zoom on iOS */
  background: #fff;
  -webkit-appearance: none;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input[type="file"] {
  padding: 12px;
  background: #fff;
  border: 2px dashed #ddd;
  border-radius: 8px;
  cursor: pointer;
}

small {
  color: #888;
  font-size: 0.8rem;
}

button[type="submit"] {
  padding: 14px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}

button[type="submit"]:active {
  background: #1d4ed8;
}

button[type="submit"]:disabled {
  background: #93c5fd;
  cursor: not-allowed;
}

button[type="button"] {
  padding: 12px;
  background: #fff;
  color: #2563eb;
  border: 1px solid #2563eb;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  width: 100%;
  margin-top: 12px;
}

.hidden {
  display: none;
}

#result {
  margin-top: 24px;
  text-align: center;
}

#result h2 {
  font-size: 1.2rem;
  margin-bottom: 8px;
}

#result code {
  background: #e5e7eb;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
  word-break: break-all;
}

#result-error h2 {
  color: #dc2626;
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid #fff;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

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

/* Enrichment status indicator */
#enrichment-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #eff6ff;
  border-radius: 6px;
  font-size: 0.85rem;
  color: #2563eb;
  margin-top: 4px;
}

#enrichment-status.hidden {
  display: none;
}

.enrichment-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #93c5fd;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}

/* Duplicate warning */
.dup-warning {
  margin-top: 8px;
  padding: 12px;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 8px;
  font-size: 0.85rem;
}

.dup-warning.hidden {
  display: none;
}

.dup-warning strong {
  color: #92400e;
}

.dup-warning p {
  margin: 4px 0;
  color: #78350f;
}

.dup-match {
  padding: 4px 0;
  color: #92400e;
  font-weight: 500;
}

.dup-note {
  font-size: 0.8rem;
  color: #a16207;
  font-style: italic;
}

/* AI-populated fields */
.ai-fields {
  border: 1px solid #d1fae5;
  background: #f0fdf4;
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-fields.hidden {
  display: none;
}

.ai-label {
  font-size: 0.8rem;
  color: #065f46;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.field-row {
  display: flex;
  gap: 12px;
}

.field-row .field {
  flex: 1;
}
