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

body {
  font-family: 'Arial', 'Helvetica Neue', sans-serif;
  background: #fdf8f5;
  color: #2d2d2d;
  min-height: 100vh;
  direction: rtl;
}

.analysis-card, .routine-card, .product-reason, .product-how {
  direction: rtl;
  text-align: right;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 32px;
}
.header h1 {
  font-size: 1.8rem;
  color: #4a3728;
  margin-bottom: 8px;
}
.header p {
  color: #7a6a5e;
  font-size: 0.95rem;
  line-height: 1.5;
}

/* Progress */
.progress-bar {
  height: 4px;
  background: #e8ddd8;
  border-radius: 2px;
  margin-bottom: 6px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(270deg, #c9836a, #a0614d);
  border-radius: 2px;
  transition: width 0.4s ease;
  width: 25%;
  margin-right: auto;
  margin-left: 0;
  float: right;
}
.step-label {
  text-align: right;
  font-size: 0.8rem;
  color: #9a8880;
  margin-bottom: 28px;
}

/* Steps */
.step { display: none; }
.step.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.step h2 {
  font-size: 1.4rem;
  color: #4a3728;
  margin-bottom: 6px;
}
.hint {
  font-size: 0.88rem;
  color: #9a8880;
  margin-bottom: 22px;
}

/* Fields */
.field {
  margin-bottom: 22px;
}
.field label {
  display: block;
  font-size: 0.9rem;
  color: #6a5a50;
  margin-bottom: 8px;
  font-weight: 600;
}
.field input,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #ddd5cf;
  border-radius: 10px;
  font-size: 0.95rem;
  background: #fff;
  color: #2d2d2d;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}
.field input:focus,
.field textarea:focus {
  border-color: #c9836a;
}

/* Pills */
.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.pill {
  padding: 8px 16px;
  border: 1.5px solid #ddd5cf;
  border-radius: 50px;
  background: #fff;
  color: #6a5a50;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.pill:hover {
  border-color: #c9836a;
  color: #c9836a;
}
.pill.selected {
  background: #c9836a;
  border-color: #c9836a;
  color: #fff;
}

/* Large texture pills */
.pill.pill-large {
  flex: 1;
  min-width: 140px;
  padding: 18px 20px;
  text-align: center;
  font-size: 1.1rem;
  line-height: 1.6;
}
.pill-sub {
  display: block;
  font-size: 0.78rem;
  font-weight: normal;
  opacity: 0.8;
  margin-top: 4px;
}

/* Photo options */
.photo-options {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}
.btn-photo-option {
  flex: 1;
  padding: 20px 16px;
  border: 2px solid #ddd5cf;
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  font-size: 1rem;
  color: #4a3728;
  font-weight: 600;
  transition: border-color 0.2s, background 0.2s;
  text-align: center;
}
.btn-photo-option:hover {
  border-color: #c9836a;
  background: #fef6f3;
}
.btn-photo-option:active {
  background: #f9ebe5;
}

/* Camera viewfinder */
.camera-viewfinder {
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  background: #000;
  margin-bottom: 16px;
}
.camera-viewfinder video {
  width: 100%;
  display: block;
  border-radius: 14px;
  transform: scaleX(-1); /* mirror for selfie */
}
.camera-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 12px;
  background: rgba(0,0,0,0.4);
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
}
.btn-camera-snap {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: #c9836a;
  font-size: 1.5rem;
  cursor: pointer;
  transition: transform 0.15s;
}
.btn-camera-snap:active { transform: scale(0.9); }
.btn-camera-cancel {
  background: none;
  border: 1px solid rgba(255,255,255,0.6);
  color: #fff;
  padding: 6px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
}

/* Upload */
.upload-area {
  border: 2px dashed #ddd5cf;
  border-radius: 14px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: #fff;
  margin-bottom: 14px;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.upload-area:hover {
  border-color: #c9836a;
  background: #fef6f3;
}
.upload-area.has-photo {
  border-style: solid;
  border-color: #c9836a;
  padding: 16px;
}
.upload-icon { font-size: 2.5rem; }
.upload-area p { color: #7a6a5e; font-size: 0.92rem; }
.upload-sub { color: #aaa !important; font-size: 0.8rem !important; }
#photoPreview {
  max-width: 100%;
  max-height: 280px;
  border-radius: 10px;
  object-fit: cover;
}
.privacy-note {
  font-size: 0.78rem;
  color: #aaa;
  text-align: center;
  margin-bottom: 24px;
}

/* Buttons */
.btn-next, .btn-submit {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #c9836a, #a0614d);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.2s;
  margin-top: 8px;
}
.btn-next:hover, .btn-submit:hover { opacity: 0.88; }

.btn-back {
  padding: 12px 20px;
  background: transparent;
  color: #9a8880;
  border: 1.5px solid #ddd5cf;
  border-radius: 12px;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.2s;
}
.btn-back:hover { border-color: #c9836a; color: #c9836a; }

.nav-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 8px;
}
.nav-row .btn-next,
.nav-row .btn-submit { flex: 1; margin-top: 0; }

/* Loading */
.loading {
  text-align: center;
  padding: 60px 20px;
  animation: fadeIn 0.4s ease;
}
/* legacy spinner kept for reference but unused */
.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid #e8ddd8;
  border-top-color: #c9836a;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 24px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading h2 { color: #4a3728; margin-bottom: 10px; }
.loading p { color: #9a8880; font-size: 0.92rem; line-height: 1.6; }

.loading-icon {
  font-size: 2.8rem;
  margin-bottom: 20px;
  display: block;
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1);   opacity: 1; }
  50%       { transform: scale(1.12); opacity: 0.75; }
}
.loading-title {
  color: #4a3728;
  font-size: 1.25rem;
  margin-bottom: 8px;
  min-height: 1.8em;
  transition: opacity 0.4s ease;
}
.loading-desc {
  color: #9a8880;
  font-size: 0.88rem;
  margin-bottom: 28px;
  min-height: 1.4em;
  transition: opacity 0.4s ease;
}
.loading-bar-wrap {
  width: 100%;
  max-width: 320px;
  height: 6px;
  background: #f0e6e0;
  border-radius: 3px;
  margin: 0 auto 10px;
  overflow: hidden;
}
.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(270deg, #c9836a, #a0614d);
  border-radius: 3px;
  transition: width 0.8s ease;
}
.loading-stage-label {
  color: #c9836a;
  font-size: 0.78rem;
  margin-bottom: 24px;
}
.loading-email-note {
  background: #fff8f5;
  border: 1px solid #f0e0d8;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.84rem;
  color: #7a6a5e;
  max-width: 320px;
  margin: 0 auto;
  line-height: 1.5;
}

/* Results */
.results { animation: fadeIn 0.4s ease; }
.results-header {
  text-align: center;
  margin-bottom: 28px;
}
.results-header h2 { font-size: 1.5rem; color: #4a3728; }

.analysis-card {
  background: linear-gradient(135deg, #fff8f5, #fef3ee);
  border: 1.5px solid #f0e0d8;
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 32px;
}
.analysis-card h3 { color: #4a3728; margin-bottom: 14px; font-size: 1.1rem; }
.analysis-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.analysis-tag {
  padding: 5px 12px;
  background: #c9836a22;
  border: 1px solid #c9836a55;
  color: #a0614d;
  border-radius: 50px;
  font-size: 0.82rem;
}
.analysis-skin-type {
  font-size: 0.9rem;
  font-weight: 600;
  color: #4a3728;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid #f0e0d8;
}
.analysis-section {
  margin-top: 14px;
}
.analysis-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #c9836a;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.analysis-text { color: #6a5a50; font-size: 0.92rem; line-height: 1.7; }

.section-title { color: #4a3728; font-size: 1.1rem; margin-bottom: 16px; }

.products-grid { display: flex; flex-direction: column; gap: 16px; margin-bottom: 32px; }

.product-card {
  background: #fff;
  border: 1.5px solid #ede5e0;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  gap: 0;
  transition: box-shadow 0.2s;
}
.product-card:hover { box-shadow: 0 4px 20px #c9836a22; }

.product-badge {
  writing-mode: vertical-lr;
  transform: rotate(180deg);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 6px;
  color: #fff;
  min-width: 28px;
  text-align: center;
}
.badge-must { background: #c9836a; }
.badge-recommended { background: #a0b89a; }
.badge-bonus { background: #b4a8d0; }

.product-image {
  width: 90px;
  min-width: 90px;
  object-fit: cover;
  background: #f5eeea;
}
.product-image-placeholder {
  width: 90px;
  min-width: 90px;
  background: linear-gradient(135deg, #f5eeea, #ede5e0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
}

.product-body {
  padding: 16px;
  flex: 1;
}
.product-name { font-size: 1rem; color: #4a3728; margin-bottom: 4px; }
.product-price { font-size: 0.85rem; color: #9a8880; margin-bottom: 10px; }
.product-reason { font-size: 0.88rem; color: #6a5a50; line-height: 1.55; margin-bottom: 8px; }
.product-how { font-size: 0.82rem; color: #a09088; font-style: italic; margin-bottom: 12px; }
.product-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.product-link {
  display: inline-block;
  padding: 7px 14px;
  background: #4a3728;
  color: #fff;
  border-radius: 8px;
  font-size: 0.82rem;
  text-decoration: none;
  transition: background 0.2s;
  white-space: nowrap;
}
.product-link:hover { background: #c9836a; }

.btn-add-cart {
  padding: 7px 14px;
  background: #c9836a;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  white-space: nowrap;
}
.btn-add-cart:hover { background: #a0614d; }
.btn-add-cart--added,
.btn-add-cart:disabled {
  background: #a0b89a;
  opacity: 0.85;
  cursor: default;
}

.btn-add-all-cart {
  display: none;
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, #c9836a, #a0614d);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.2s;
  margin-bottom: 20px;
  font-weight: 600;
}
.btn-add-all-cart:hover { opacity: 0.88; }
.btn-add-all-cart:disabled { background: #a0b89a; cursor: default; }

.routine-card {
  background: #f5f2ff;
  border: 1.5px solid #ddd5f5;
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 28px;
}
.routine-card h3 { color: #4a3728; margin-bottom: 10px; }
.routine-card p { color: #6a5a50; font-size: 0.92rem; line-height: 1.65; }

.btn-restart {
  display: block;
  width: 100%;
  padding: 13px;
  background: transparent;
  border: 1.5px solid #ddd5cf;
  border-radius: 12px;
  color: #9a8880;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-restart:hover { border-color: #c9836a; color: #c9836a; }

/* Inline field errors */
.field-error {
  display: block;
  font-size: 0.82rem;
  color: #c0392b;
  margin-top: 6px;
  min-height: 1em;
}

/* ── Mobile Responsive ──────────────────────────────── */
@media (max-width: 640px) {
  .app {
    padding: 20px 14px 48px;
  }

  .header {
    margin-bottom: 20px;
  }
  .header h1 {
    font-size: 1.4rem;
  }
  .header p {
    font-size: 0.88rem;
  }

  .step h2 {
    font-size: 1.2rem;
  }
  .hint {
    font-size: 0.82rem;
    margin-bottom: 16px;
  }

  /* Smaller pills on mobile */
  .pill {
    padding: 7px 12px;
    font-size: 0.82rem;
  }
  .pill.pill-large {
    min-width: 120px;
    padding: 14px 12px;
    font-size: 1rem;
  }

  /* Upload area */
  .upload-area {
    padding: 28px 16px;
    min-height: 160px;
  }

  /* ── Products: horizontal swipe carousel ── */
  .products-grid {
    flex-direction: row;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 4px 14px 12px;
    margin: 0 -14px 8px;
    gap: 12px;
  }
  .products-grid::-webkit-scrollbar { display: none; }

  /* Each card: full-height column, snaps into place */
  .product-card {
    flex-direction: column;
    min-width: min(82vw, 300px);
    max-width: min(82vw, 300px);
    flex-shrink: 0;
    scroll-snap-align: start;
    position: relative;
  }

  /* Badge becomes a pill overlay on the image */
  .product-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    writing-mode: horizontal-tb;
    transform: none;
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 0.72rem;
    font-weight: 700;
    min-width: unset;
    z-index: 2;
    letter-spacing: 0.5px;
  }

  /* Image fills full card width */
  .product-image {
    width: 100%;
    height: 190px;
    min-width: unset;
    object-fit: cover;
  }
  .product-image-placeholder {
    width: 100%;
    height: 190px;
    min-width: unset;
    font-size: 3rem;
  }

  .product-body {
    padding: 14px;
  }
  .product-name {
    font-size: 0.95rem;
  }
  .product-reason {
    font-size: 0.84rem;
  }
  .product-how {
    font-size: 0.8rem;
  }

  /* Analysis card */
  .analysis-card,
  .routine-card {
    padding: 16px;
  }

  /* Results header */
  .results-header h2 {
    font-size: 1.25rem;
  }

  /* Buttons */
  .btn-next, .btn-submit {
    padding: 13px;
    font-size: 0.95rem;
  }
  .btn-back {
    padding: 10px 14px;
    font-size: 0.85rem;
  }

  /* Loading */
  .loading {
    padding: 40px 16px;
  }
}

/* ── Carousel swipe hint (mobile only) ── */
.carousel-hint {
  display: none;
  text-align: center;
  font-size: 0.78rem;
  color: #b0a09a;
  margin-bottom: 20px;
}
@media (max-width: 640px) {
  .carousel-hint { display: block; }
}

/* Error */
.error-box {
  background: #fff5f5;
  border: 1.5px solid #f5c2c2;
  border-radius: 14px;
  padding: 28px;
  text-align: center;
  animation: fadeIn 0.3s ease;
}
.error-box p { color: #c0392b; margin-bottom: 16px; font-size: 0.95rem; }
