/* ============================================================
   BelleMore 두피·모발 자가진단 — 모바일 전용 스타일
   ============================================================ */

/* ── 기본 변수 ─────────────────────────────────────────────── */
:root {
  --bg:        #FAF8F2;
  --white:     #FFFFFF;
  --green:     #1F4D3A;
  --green-light: #2E7D5A;
  --beige:     #E8DDC7;
  --beige-dark:#D4C5A9;
  --gold:      #C6A45D;
  --gold-light:#E8D5A0;
  --text:      #222222;
  --text-sub:  #666666;
  --text-mute: #999999;
  --border:    #E4DDD0;
  --shadow:    0 2px 16px rgba(31,77,58,0.08);
  --shadow-lg: 0 8px 32px rgba(31,77,58,0.12);
  --radius:    16px;
  --radius-sm: 10px;
  --font:      'Noto Sans KR', sans-serif;
}

/* ── 리셋 ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
ul { list-style: none; }
img { max-width: 100%; display: block; }

/* ── 앱 래퍼 ─────────────────────────────────────────────── */
#app {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--white);
  position: relative;
}

/* ── 화면 전환 ───────────────────────────────────────────── */
.screen { display: none; min-height: 100vh; flex-direction: column; }
.screen.active { display: flex; }

/* 결과지·상품 화면: 헤더 sticky + 나머지 스크롤 */
#screen-result,
#screen-products {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* sticky 헤더가 작동하려면 overflow hidden 아닌 auto 필요 */
}

/* ── 헤더 ────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 20px 12px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}
.survey-header { justify-content: space-between; }

.brand-logo { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.brand-logo.small .brand-text { font-size: 18px; }
.brand-text {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--green);
  letter-spacing: 0.04em;
}
.brand-accent { color: var(--gold); }
.brand-sub { font-size: 10px; color: var(--text-sub); letter-spacing: 0.12em; text-transform: uppercase; }

.btn-back {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--green);
}
.btn-back svg { width: 20px; height: 20px; }
.btn-back:active { background: var(--bg); }

/* ── 버튼 공통 ───────────────────────────────────────────── */
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  padding: 18px 24px;
  background: var(--green);
  color: var(--white);
  font-size: 16px;
  font-weight: 600;
  border-radius: 14px;
  transition: background 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary:active { background: #163A2B; transform: scale(0.98); }
.btn-primary.btn-gold { background: var(--gold); }
.btn-primary.btn-gold:active { background: #A8883E; }
.btn-primary.btn-large { padding: 20px 24px; font-size: 17px; }

.btn-secondary {
  display: flex; align-items: center; justify-content: center;
  padding: 18px 24px;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  transition: background 0.2s;
}
.btn-secondary:active { background: var(--beige); }

.btn-arrow { width: 18px; height: 18px; flex-shrink: 0; }

/* ── 랜딩 ────────────────────────────────────────────────── */
.landing-main { flex: 1; padding: 24px 20px 40px; display: flex; flex-direction: column; gap: 20px; overflow-y: auto; }
.landing-hero { text-align: center; padding: 8px 0 4px; }
.landing-desc { font-size: 15px; line-height: 1.7; color: var(--text-sub); }
.landing-desc-sub { font-size: 12px; color: var(--text-mute); }
.landing-title { font-size: 18px; font-weight: 700; color: var(--green); line-height: 1.5; }
.landing-notice { text-align: center; font-size: 12px; color: var(--text-mute); }
.hidden { display: none !important; }

/* ── 폼 카드 ─────────────────────────────────────────────── */
.form-card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 24px 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-label { font-size: 14px; font-weight: 600; color: var(--text); }
.required { color: var(--gold); }

.form-input {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color 0.2s;
}
.form-input:focus { border-color: var(--green); background: var(--white); }
.form-input::placeholder { color: var(--text-mute); }

/* 자동완성 */
.autocomplete-wrap { position: relative; }
.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--white);
  border: 1.5px solid var(--green);
  border-radius: var(--radius-sm);
  max-height: 200px;
  overflow-y: auto;
  z-index: 200;
  box-shadow: var(--shadow-lg);
}
.autocomplete-item {
  padding: 12px 16px;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:active, .autocomplete-item.highlighted { background: var(--bg); }

/* 칩 선택 */
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 10px 18px;
  border: 1.5px solid var(--border);
  border-radius: 50px;
  font-size: 14px;
  color: var(--text-sub);
  background: var(--white);
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.chip.selected, .chip:active {
  background: var(--green);
  color: var(--white);
  border-color: var(--green);
}

/* 개인정보 동의 */
.privacy-box {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.privacy-label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.privacy-checkbox { position: absolute; opacity: 0; width: 0; height: 0; }
.privacy-check-custom {
  flex-shrink: 0;
  width: 20px; height: 20px;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  background: var(--white);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
  margin-top: 1px;
}
.privacy-checkbox:checked + .privacy-check-custom {
  background: var(--green);
  border-color: var(--green);
}
.privacy-checkbox:checked + .privacy-check-custom::after {
  content: '';
  width: 10px; height: 6px;
  border-left: 2px solid white;
  border-bottom: 2px solid white;
  transform: rotate(-45deg) translateY(-1px);
  display: block;
}
.privacy-text { font-size: 12px; line-height: 1.6; color: var(--text-sub); }

.form-error {
  font-size: 13px;
  color: #C0392B;
  padding: 4px 0;
}
.survey-error { text-align: center; padding: 8px 0; }

/* ── 진행률 바 ───────────────────────────────────────────── */
.progress-wrap {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.progress-bar { flex: 1; height: 6px; background: var(--beige); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--green); border-radius: 3px; transition: width 0.4s ease; }
.progress-text { font-size: 12px; color: var(--text-sub); font-weight: 500; white-space: nowrap; }

/* ── 설문 ────────────────────────────────────────────────── */
.survey-container {
  flex: 1;
  padding: 20px 20px 8px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.question-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 28px 20px 20px;
}
.animate-in { animation: fadeSlideIn 0.25s ease; }
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.question-header { margin-bottom: 24px; }
.question-step { font-size: 12px; color: var(--gold); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.question-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.5;
  margin-top: 8px;
}
.question-note { font-size: 12px; color: var(--text-mute); margin-top: 6px; }

.options-list { display: flex; flex-direction: column; gap: 10px; }
.option-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 16px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: left;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.option-btn:active { transform: scale(0.98); }
.option-btn.selected {
  background: rgba(31,77,58,0.06);
  border-color: var(--green);
}
.option-btn.selected .option-label { color: var(--green); font-weight: 600; }
.option-check svg { width: 20px; height: 20px; color: var(--border); flex-shrink: 0; }
.option-btn.selected .option-check svg { color: var(--green); }
.option-btn.selected .check-dot { display: block !important; }
.option-label { font-size: 15px; color: var(--text); line-height: 1.4; }

.survey-nav {
  display: flex;
  gap: 10px;
  padding: 12px 20px 24px;
  background: var(--white);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.survey-nav .btn-primary { flex: 1.6; }
.survey-nav .btn-secondary { flex: 1; }

/* ── 휴대폰 번호 입력 ────────────────────────────────────── */
.phone-main { flex: 1; display: flex; flex-direction: column; padding: 32px 20px 40px; gap: 24px; overflow-y: auto; }
.result-ready-card {
  text-align: center;
  padding: 32px 20px;
  background: linear-gradient(135deg, var(--green) 0%, #2E7D5A 100%);
  border-radius: var(--radius);
  color: white;
}
.result-ready-icon { font-size: 32px; margin-bottom: 12px; color: var(--gold-light); }
.result-ready-title { font-size: 24px; font-weight: 700; line-height: 1.4; margin-bottom: 10px; }
.result-ready-desc { font-size: 15px; line-height: 1.6; opacity: 0.9; }
.phone-form-card { gap: 16px; }
.phone-notice { font-size: 12px; color: var(--text-mute); text-align: center; }

/* ── 결과지 ──────────────────────────────────────────────── */
.result-container { flex: 1; }

/* result-header: 녹색 배경 + 흰색 텍스트 */
.result-header {
  background: var(--green);
  border-bottom: none;
  /* sticky는 부모(#screen-result)가 overflow:auto일 때만 작동 */
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}
.result-header .brand-text  { color: rgba(255,255,255,0.95); }
.result-header .brand-sub   { color: rgba(255,255,255,0.70); }
.result-header .brand-accent { color: var(--gold-light); }

.result-section { padding: 28px 20px; border-bottom: 8px solid var(--bg); }
.result-section:last-child { border-bottom: none; }

.result-section-header { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.result-section-num {
  font-family: 'Playfair Display', serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--gold);
  background: var(--gold-light);
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.result-section-title { font-size: 18px; font-weight: 700; color: var(--green); }

/* 점수 섹션 */
.score-card { text-align: center; }
.score-intro { font-size: 15px; color: var(--text-sub); margin-bottom: 16px; }
.score-chart-wrap { position: relative; width: 200px; margin: 0 auto 16px; }
.score-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  display: flex; align-items: baseline; gap: 2px;
}
.score-number { font-family: 'Playfair Display', serif; font-size: 48px; font-weight: 600; color: var(--green); }
.score-unit { font-size: 16px; color: var(--text-sub); }

.score-grade-badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 50px;
  border: 1.5px solid;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 20px;
}

.score-compare { display: flex; flex-direction: column; gap: 10px; }
.score-compare-item { display: flex; align-items: center; gap: 10px; }
.score-compare-label { font-size: 12px; color: var(--text-sub); width: 100px; flex-shrink: 0; text-align: right; }
.score-compare-bar { flex: 1; height: 8px; background: var(--beige); border-radius: 4px; overflow: hidden; }
.score-compare-fill { height: 100%; border-radius: 4px; transition: width 0.8s ease; }
.score-compare-val { font-size: 13px; font-weight: 600; color: var(--text); width: 36px; flex-shrink: 0; }

.tags-wrap { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.result-tag {
  padding: 6px 14px;
  background: rgba(31,77,58,0.08);
  color: var(--green);
  border-radius: 50px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid rgba(31,77,58,0.15);
}

.personal-highlight {
  margin-top: 16px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(198,164,93,0.1), rgba(198,164,93,0.05));
  border-left: 3px solid var(--gold);
  border-radius: 0 8px 8px 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}

.result-desc-card {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}

/* 원인 섹션 */
.reason-card {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 18px;
  margin-bottom: 14px;
}
.reason-intro { font-size: 14px; color: var(--text-sub); margin-bottom: 12px; }
.factor-list { display: flex; flex-direction: column; gap: 8px; }
.factor-item { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; color: var(--text); line-height: 1.5; }
.factor-dot { color: var(--gold); font-size: 18px; line-height: 1; flex-shrink: 0; }
.reason-desc { font-size: 14px; line-height: 1.7; color: var(--text-sub); padding: 14px; background: var(--white); border-radius: var(--radius-sm); border: 1px solid var(--border); }

/* 루틴 섹션 */
.routine-list { display: flex; flex-direction: column; gap: 12px; }
.routine-item { padding: 14px 16px; background: var(--bg); border-radius: var(--radius-sm); }
.routine-item-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.routine-name { font-size: 14px; font-weight: 600; color: var(--text); }
.routine-stars { font-size: 16px; }
.star-on { color: var(--gold); }
.star-off { color: var(--beige-dark); }
.routine-desc { font-size: 12px; color: var(--text-sub); line-height: 1.5; }

/* 레시피 섹션 */
.recipe-card {
  background: linear-gradient(135deg, var(--green) 0%, #2E6B4F 100%);
  border-radius: var(--radius);
  padding: 24px 20px;
  color: white;
}
.recipe-header { margin-bottom: 20px; }
.recipe-name { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.recipe-no { font-size: 12px; opacity: 0.75; letter-spacing: 0.08em; }
.recipe-items { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.recipe-item {}
.recipe-item-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.recipe-label { font-size: 13px; opacity: 0.9; }
.recipe-pct { font-size: 14px; font-weight: 700; color: var(--gold-light); }
.recipe-bar { height: 6px; background: rgba(255,255,255,0.15); border-radius: 3px; overflow: hidden; }
.recipe-bar-fill { height: 100%; background: var(--gold-light); border-radius: 3px; transition: width 0.8s ease; }
.recipe-fit {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.15);
}
.recipe-fit-label { font-size: 13px; opacity: 0.85; }
.recipe-fit-score { font-size: 22px; font-weight: 700; color: var(--gold-light); }

/* 코멘트 섹션 */
.comment-card {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 24px 20px;
  border: 1px solid var(--border);
}
.comment-icon { font-size: 20px; color: var(--gold); margin-bottom: 12px; }
.comment-text { font-size: 15px; line-height: 1.8; color: var(--text); }

/* 법적 고지 */
.legal-notice {
  padding: 16px 20px;
  font-size: 11px;
  color: var(--text-mute);
  line-height: 1.6;
  border-top: 1px solid var(--border);
  text-align: center;
}

.result-cta-wrap {
  padding: 16px 20px 32px;
  background: var(--white);
  border-top: 1px solid var(--border);
}

/* ── 상품 추천 ────────────────────────────────────────────── */
/* #screen-products 는 overflow-y:auto 이므로 헤더 sticky 작동 */
.products-container { flex: 1; padding-bottom: 120px; }

.products-header {
  padding: 28px 20px 20px;
  text-align: center;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.products-title { font-size: 22px; font-weight: 700; color: var(--green); line-height: 1.4; margin-bottom: 6px; }
.products-sub { font-size: 13px; color: var(--text-sub); }

.products-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px 4px;
}
.products-divider::before,
.products-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.products-divider-text { font-size: 12px; font-weight: 600; color: var(--gold); white-space: nowrap; }

.product-cards { padding: 0 20px; display: flex; flex-direction: column; gap: 20px; margin-top: 12px; }

.product-card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow);
  position: relative;
}
.product-card-primary { border-color: var(--green); }

.product-badge {
  position: absolute;
  top: 12px; left: 12px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 50px;
  z-index: 10;
}
.product-badge-primary { background: var(--green); color: white; }
.product-badge-sub { background: var(--gold); color: white; }

.product-img-wrap {
  width: 100%;
  background: #fff;
  position: relative;
  /* 높이는 이미지 비율에 맞게 auto */
}
/* 실제 상품 이미지 */
.product-img {
  width: 100%;
  height: auto;
  max-height: 260px;
  object-fit: contain;
  display: block;
}
/* 이미지 로드 실패 시에만 표시 */
.product-img-fallback {
  width: 100%;
  height: 180px;
  display: none; /* 기본 숨김 — onerror 시 JS에서 flex로 변경 */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-mute);
  font-size: 13px;
  background: var(--bg);
}
.product-img-icon { font-size: 32px; color: var(--beige-dark); }

.product-info { padding: 20px; }
.product-volume { font-size: 12px; color: var(--text-mute); margin-bottom: 4px; }
.product-name { font-size: 18px; font-weight: 700; color: var(--green); margin-bottom: 10px; line-height: 1.3; }
.product-emphasis {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 10px;
  padding: 8px 12px;
  background: rgba(198,164,93,0.08);
  border-radius: 8px;
}
.emphasis-icon { font-size: 12px; }

.product-fit-types { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.fit-type-tag {
  font-size: 11px;
  padding: 4px 10px;
  background: rgba(31,77,58,0.07);
  color: var(--green);
  border-radius: 50px;
}

.product-reason { font-size: 14px; line-height: 1.6; color: var(--text-sub); margin-bottom: 12px; }

.product-benefits { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.product-benefit-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
}
.benefit-check { color: var(--green); font-size: 13px; font-weight: 700; flex-shrink: 0; }

.btn-buy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px;
  background: var(--green);
  color: white;
  font-size: 15px;
  font-weight: 600;
  border-radius: 12px;
  transition: background 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.btn-buy:active { background: #163A2B; transform: scale(0.98); }

.products-note { font-size: 12px; color: var(--text-mute); text-align: center; padding: 16px 20px 0; }

/* 하단 고정 CTA — #screen-products가 overflow:auto이므로 fixed 유지 */
.products-final-cta {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  padding: 12px 20px 28px;
  background: linear-gradient(to top, var(--white) 70%, transparent);
  z-index: 50;
}

/* ── 로딩 ────────────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(250,248,242,0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 999;
}
.loading-overlay.hidden { display: none; }
.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--beige);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 14px; color: var(--text-sub); }

/* ── 반응형 ──────────────────────────────────────────────── */
@media (max-width: 360px) {
  .question-title { font-size: 18px; }
  .option-label { font-size: 14px; }
  .score-number { font-size: 40px; }
}

@media (min-width: 431px) {
  #app {
    box-shadow: 0 0 40px rgba(0,0,0,0.08);
    min-height: 100vh;
  }
}
