/* Layout */
.analyze-container {
  max-width: 800px;
  padding-top: 4rem;
  padding-bottom: 4rem;
  min-height: calc(100vh - 100px);
}

.analyze-title {
  font-size: 3rem;
  margin-bottom: 1rem;
  color: var(--neutral-900);
  text-wrap: balance;
}

.analyze-subtitle {
  color: var(--neutral-600);
  margin-bottom: 2rem;
  font-size: 1.125rem;
}


/* Photo tips */
.photo-tips {
  margin-bottom: 1.5rem;
  padding: 1.25rem 1.5rem;
  text-align: left;
}

.photo-tips-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--neutral-800);
  margin-bottom: 0.75rem;
}

.photo-tips-list {
  list-style: decimal;
  padding-left: 1.25rem;
  color: var(--neutral-600);
  font-size: 0.875rem;
  line-height: 1.7;
}

.photo-tips-list li { margin-bottom: 0.5rem; }

/* Upload Box */
.upload-box {
  padding: 2rem 2rem 1.5rem;
  text-align: center;
  border: 2px dashed rgba(245, 88, 142, 0.25);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  transition: border-color 0.25s;
}

.upload-box.drag-active {
  border-color: var(--primary-400);
  background: rgba(245, 88, 142, 0.04);
}

.upload-eyebrow {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--primary-500);
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.upload-title {
  font-size: 1.4rem;
  margin-bottom: 1.5rem;
  color: var(--neutral-900);
}

/* 3-Slot grid */
.upload-slots-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.upload-slot {
  aspect-ratio: 3/4;
  border: 2px dashed rgba(245, 88, 142, 0.20);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-out),
              background var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
  position: relative;
  overflow: hidden;
  background: var(--bg-secondary);
}

.upload-slot:hover:not(.filled) {
  border-color: var(--primary-400);
  background: rgba(245, 88, 142, 0.06);
  transform: translateY(-2px);
}

.upload-slot.drag-over {
  border-color: var(--primary-300);
  background: rgba(245, 88, 142, 0.10);
}

.upload-slot.filled {
  border-style: solid;
  border-color: rgba(245, 88, 142, 0.40);
  cursor: default;
}

.slot-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--neutral-400);
  padding: 1rem;
}

.slot-placeholder svg {
  color: var(--neutral-400);
  transition: color var(--duration-fast);
}

.upload-slot:hover .slot-placeholder svg {
  color: var(--primary-400);
}

.slot-label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--neutral-600);
}

.slot-hint {
  font-size: 0.7rem;
  color: var(--neutral-400);
}

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

.slot-clear-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(245, 88, 142, 0.20);
  color: var(--primary-600);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background var(--duration-fast);
}

.slot-clear-btn:hover {
  background: rgba(245, 88, 142, 0.15);
}

/* Upload actions */
.upload-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin: 0 0 1rem;
}

.upload-hint {
  font-size: 0.8rem;
  color: var(--neutral-500);
}

/* Camera & Preview */
#camera-container, #preview-container {
  padding: 2rem;
  text-align: center;
}

#camera-feed {
  width: 100%;
  max-width: 500px;
  border-radius: var(--radius-md);
  margin: 0 auto 1.5rem;
  display: block;
}

.camera-actions, .preview-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
}

/* Loading Section */
.loading-section {
  text-align: center;
  padding: 4rem 0;
}

/* Layered concentric ring spinner — pastel */
.spinner-ring {
  width: 72px;
  height: 72px;
  margin: 0 auto 2rem;
  position: relative;
}

.spinner-ring::before,
.spinner-ring::after,
.spinner-ring-inner {
  content: '';
  position: absolute;
  border-radius: 50%;
  border: 3px solid transparent;
}

.spinner-ring::before {
  inset: 0;
  border-top-color: var(--primary-400);
  animation: spin 0.8s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.spinner-ring::after {
  inset: 10px;
  border-top-color: var(--accent-400);
  animation: spin 1.4s cubic-bezier(0.4, 0, 0.6, 1) infinite reverse;
}

.spinner-ring-inner {
  inset: 20px;
  border-top-color: var(--mint-500);
  animation: spin 2s linear infinite;
}

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

.loading-section h2 {
  animation: pulse-text 1.8s ease-in-out infinite;
  margin-bottom: 0.5rem;
  color: var(--neutral-800);
}

.loading-section #loading-msg {
  font-size: 0.9rem;
  color: var(--neutral-500);
  transition: opacity 0.4s;
}

@keyframes pulse-text {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}

/* Results Section */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.overall-score {
  padding: 1rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.score-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary-500);
  font-family: var(--font-display);
}

.score-label {
  font-size: 0.75rem;
  color: var(--neutral-500);
}

.concerns-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.concern-card {
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  transition: transform var(--duration-base) var(--ease-out),
              box-shadow var(--duration-base) var(--ease-out);
}

.concern-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-pop);
}

.concern-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.concern-name {
  font-weight: 600;
  font-size: 1.125rem;
  color: var(--neutral-900);
}

.severity-badge {
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.severity-low    { background: rgba(90, 216, 163, 0.12); color: #2a8a64; }
.severity-medium { background: rgba(255, 170, 122, 0.15); color: #9a5416; }
.severity-high   { background: rgba(245, 88, 142, 0.12); color: var(--primary-700); }

.concern-description {
  font-size: 0.875rem;
  color: var(--neutral-600);
  line-height: 1.6;
}

/* Ingredient chips on each concern card */
.concern-ingredients {
  margin-top: 0.875rem;
  padding-top: 0.875rem;
  border-top: 1px solid var(--border, rgba(0,0,0,0.06));
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  font-size: 0.75rem;
}

.ing-prefix {
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--neutral-500);
  font-size: 0.7rem;
  margin-right: 0.25rem;
}

.ing-chip {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: rgba(245, 88, 142, 0.08);
  color: var(--primary-700);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  border: 1px solid rgba(245, 88, 142, 0.18);
  white-space: nowrap;
}

/* Deduped shortlist below concerns grid */
.ingredient-shortlist {
  margin: 0 0 2.5rem;
  padding: 1.75rem 1.75rem 1.5rem;
  background: var(--bg-card, #fff);
  border: 1px solid var(--border, rgba(0,0,0,0.06));
  border-radius: var(--radius-lg, 24px);
  box-shadow: var(--shadow-md);
}

.ingredient-shortlist.hidden { display: none; }

.shortlist-header {
  margin-bottom: 1.25rem;
}

.shortlist-title {
  margin: 0 0 0.25rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--neutral-900);
  letter-spacing: -0.01em;
}

.shortlist-sub {
  margin: 0;
  font-size: 0.8rem;
  color: var(--neutral-500);
}

.shortlist-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1.25rem;
  display: grid;
  gap: 0.5rem;
}

.shortlist-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.625rem 0.875rem;
  background: rgba(0,0,0,0.025);
  border-radius: var(--radius-md, 12px);
  font-size: 0.875rem;
}

.shortlist-name {
  font-weight: 600;
  color: var(--neutral-900);
  text-transform: lowercase;
}

.shortlist-tier {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--mint-500, #2a8a64);
  background: rgba(90, 216, 163, 0.12);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
  justify-self: end;
}

.shortlist-targets {
  grid-column: 1 / -1;
  font-size: 0.75rem;
  color: var(--neutral-500);
  text-transform: capitalize;
}

.shortlist-cta {
  width: 100%;
  text-align: center;
}

@media (max-width: 600px) {
  .ingredient-shortlist { padding: 1.25rem; }
}

.results-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* Step progress dots */
.step-progress {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  padding: 1rem 0 0.25rem;
}

.step-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-glass);
  transition: background 0.3s;
}

.step-dot.active { background: var(--primary-400); }
.step-dot.done   { background: var(--mint-500); }

/* Capture instruction */
.capture-instruction {
  text-align: center;
  padding: 0.75rem 1rem 1rem;
}

.step-counter {
  font-size: 0.75rem;
  color: var(--neutral-500);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: block;
  margin-bottom: 0.5rem;
}

.step-text {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--neutral-900);
  margin: 0;
}

/* Thumbnails preview grid */
.thumbnails-grid {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
  padding: 1rem 0 1.5rem;
}

.thumbnail {
  width: 140px;
  height: 140px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-glass);
}

/* Responsive */
@media (max-width: 600px) {
  .upload-slots-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
  }

  .slot-label { font-size: 0.75rem; }
  .slot-hint  { display: none; }

  .upload-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .upload-actions .btn {
    justify-content: center;
  }

  .results-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .analyze-title { font-size: 2rem; }
  .analyze-subtitle { font-size: 1rem; }

  /* Make slots square so they're usable on phones — portrait slots at ~100px wide are too narrow */
  .upload-slot { aspect-ratio: 1; }

  .camera-actions,
  .preview-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .camera-actions .btn,
  .preview-actions .btn {
    justify-content: center;
  }

  .thumbnail {
    width: 100px;
    height: 100px;
  }
}

.hidden {
  display: none !important;
}

/* ── Save-photo opt-in toggle ─────────────────────────────────────── */
.save-photo-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--neutral-500);
  cursor: pointer;
  margin-top: 0.875rem;
  user-select: none;
}
.save-photo-toggle input {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--primary-500);
  flex-shrink: 0;
}

/* ── Step 2 — optional close-ups ────────────────────────────────────
   Reveals after the user clicks "next →" on the preview container.
   Visually distinct from the required step-1 surface so it reads as
   "you're done with the required part, this is the bonus".
*/
#closeup-section {
  margin-top: 2rem;
  padding: 1.75rem 1.5rem;
}

.closeup-title {
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0.5rem 0 0.75rem;
  color: var(--neutral-900);
}

.closeup-subtitle {
  margin: 0 auto 1.5rem;
  max-width: 56ch;
  color: var(--neutral-600);
  font-size: 0.95rem;
  line-height: 1.55;
}

.closeup-slots-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin: 1.5rem 0;
}

.closeup-slot-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.closeup-slot {
  position: relative;
  aspect-ratio: 1;
  border: 2px dashed var(--primary-300);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: border-color var(--duration-fast), background var(--duration-fast), transform var(--duration-fast);
}
.closeup-slot:hover {
  border-color: var(--primary-500);
  background: rgba(245, 88, 142, 0.04);
}
.closeup-slot.cu-filled {
  border-style: solid;
  border-color: var(--primary-500);
  padding: 0;
  cursor: default;
}
.closeup-slot:focus-visible {
  outline: none;
  box-shadow: var(--shadow-glow);
}

.cu-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 1rem 0.5rem;
  color: var(--primary-600);
  text-align: center;
}
.cu-label {
  font-size: 0.85rem;
  font-weight: 700;
  margin-top: 0.25rem;
  text-transform: lowercase;
  letter-spacing: 0.02em;
}
.cu-hint {
  font-size: 0.7rem;
  color: var(--neutral-500);
  text-transform: lowercase;
}

.cu-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: calc(var(--radius-md) - 2px);
  display: block;
}

.cu-remove {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: none;
  background: rgba(20, 20, 14, 0.7);
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cu-remove:hover { background: rgba(20, 20, 14, 0.9); }

.cu-note {
  width: 100%;
  min-height: 56px;
  resize: vertical;
  padding: 0.5rem 0.65rem;
  font: inherit;
  font-size: 0.85rem;
  color: var(--text-body);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-primary);
  line-height: 1.4;
}
.cu-note:focus-visible {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(245, 88, 142, 0.12);
}
.cu-note:disabled {
  background: var(--neutral-100);
  color: var(--neutral-400);
  cursor: not-allowed;
}

.cu-note-counter {
  text-align: right;
  font-size: 0.7rem;
  color: var(--neutral-500);
}

.closeup-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1.25rem;
}

.closeup-disclaimer {
  margin: 1.25rem auto 0;
  max-width: 56ch;
  padding: 0.75rem 1rem;
  background: rgba(255, 179, 128, 0.12);
  border: 1px solid var(--peach-300);
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--neutral-700);
  text-align: left;
}

@media (max-width: 600px) {
  .closeup-slots-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }
  .closeup-title { font-size: 1.75rem; }
}

/* Spot-finding styles live in base.css so both analyze.html and
 * recommendations.html get them without duplication. */

