:root {
  --bg: #0f1b14;
  --card: #17271e;
  --line: #24382c;
  --fg: #eaf3ec;
  --muted: #9fb3a6;
  --accent: #58d68d;
  --good: #58d68d;
  --ok: #e9c46a;
  --bad: #ef7a6d;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  padding: 0 16px calc(32px + env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", sans-serif;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}
header { padding: 28px 0 16px; text-align: center; }
h1 { margin: 0; font-size: 26px; letter-spacing: -0.5px; }
.sub { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
main { max-width: 640px; margin: 0 auto; }
h2 { margin: 0 0 10px; font-size: 15px; color: var(--muted); font-weight: 600; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 14px;
}
.card ul { margin: 0; padding-left: 18px; }
.card li { margin-bottom: 6px; }

.pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.shoot {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 22px 12px; border: 2px dashed var(--line); border-radius: 14px;
  cursor: pointer; text-align: center;
}
.shoot:active { border-color: var(--accent); }
.shoot-icon { font-size: 30px; }
.shoot-text { font-weight: 600; font-size: 14px; }
.shoot-hint { margin: 10px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
#preview { width: 100%; margin-top: 12px; border-radius: 12px; }

input[type=text] {
  width: 100%; margin-top: 12px; padding: 12px 14px; font-size: 15px;
  background: #101c15; color: var(--fg);
  border: 1px solid var(--line); border-radius: 10px;
}
button {
  width: 100%; margin-top: 12px; padding: 14px; font-size: 16px; font-weight: 600;
  color: #06200f; background: var(--accent); border: 0; border-radius: 12px; cursor: pointer;
}
button:disabled { opacity: .4; cursor: default; }
button.ghost { background: transparent; color: var(--fg); border: 1px solid var(--line); }

#status { text-align: center; padding: 24px 0; color: var(--muted); }
.spinner {
  width: 34px; height: 34px; margin: 0 auto 12px;
  border: 3px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error { border-color: var(--bad); color: #ffd9d4; }

.score-card { display: flex; align-items: center; gap: 16px; }
.grade {
  flex: 0 0 76px; height: 76px; display: grid; place-items: center;
  font-size: 38px; font-weight: 800; border-radius: 20px;
  background: var(--accent); color: #06200f;
}
.grade[data-grade=C] { background: var(--ok); }
.grade[data-grade=D], .grade[data-grade=E] { background: var(--bad); }
.score-meta { min-width: 0; }
.product { font-size: 13px; color: var(--muted); }
.score-line { font-size: 30px; font-weight: 700; }
.score-max { font-size: 15px; color: var(--muted); font-weight: 400; }
.headline { font-size: 15px; }

.tts-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.tts-bar button { margin-top: 0; flex: 1; }
#stop { background: var(--line); color: var(--fg); }
.tts-mode { font-size: 12px; color: var(--muted); white-space: nowrap; }

.ing-list, .nut-list { list-style: none; padding: 0; }
.nut-list li {
  display: flex; gap: 10px; align-items: baseline;
  padding: 10px 0; border-top: 1px solid var(--line);
}
.nut-list li:first-child { border-top: 0; }

/* 재료 카드 (접었다 펴기) */
.ing-item { border-top: 1px solid var(--line); }
.ing-item:first-child { border-top: 0; }
.ing-item summary {
  display: flex; align-items: center; gap: 8px; flex-wrap: nowrap;
  padding: 11px 0; cursor: pointer; list-style: none;
}
.ing-item summary::-webkit-details-marker { display: none; }
.ing-grade {
  flex: 0 0 24px; height: 24px; display: grid; place-items: center;
  font-size: 12px; font-weight: 800; border-radius: 7px;
  background: var(--accent); color: #06200f;
}
.ing-grade[data-grade=C] { background: var(--ok); }
.ing-grade[data-grade=D], .ing-grade[data-grade=E] { background: var(--bad); }
.ing-name { font-weight: 600; min-width: 0; font-size: 14px; }
.ing-raw {
  min-width: 0; font-size: 11px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ing-item summary .chev { margin-left: auto; }
.ing-tag {
  flex: 0 0 auto; font-size: 11px; color: var(--muted);
  padding: 2px 7px; border-radius: 999px; background: var(--line);
}
.chev { flex: 0 0 auto; color: var(--muted); font-size: 11px; transition: transform .15s; }
.ing-item details[open] .chev { transform: rotate(180deg); }
.ing-detail { padding: 2px 0 12px 32px; }
.detail-row { margin-bottom: 9px; }
.detail-row:last-child { margin-bottom: 0; }
.detail-row p { margin: 2px 0 0; font-size: 13px; color: var(--muted); line-height: 1.6; }
.detail-label { font-size: 11px; font-weight: 700; color: var(--fg); opacity: .75; }
.evidence {
  margin-left: 6px; font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 999px; background: var(--line); color: var(--muted);
}
.evidence.established { background: #3a2018; color: var(--bad); }
.evidence.limited { background: #3a2f16; color: var(--ok); }
.evidence.disputed { background: var(--line); color: var(--muted); }
.evidence.none { display: none; }
.nut-value { margin-left: auto; font-variant-numeric: tabular-nums; }
.nut-value.good { color: var(--good); }
.nut-value.ok { color: var(--ok); }
.nut-value.bad { color: var(--bad); }
.quality { font-size: 13px; color: var(--muted); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.two-col .card { margin-bottom: 14px; }
@media (max-width: 480px) { .two-col { grid-template-columns: 1fr; gap: 0; } }
.disclaimer { font-size: 12px; color: var(--muted); margin-top: 18px; }

/* ── 탭 / 배지 ─────────────────────────────────────────── */
header { position: relative; }
.badge {
  position: absolute; top: 28px; right: 0;
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: var(--accent); color: #06200f;
}
.badge.free { background: var(--line); color: var(--muted); }
.tabs {
  display: flex; gap: 6px; max-width: 640px; margin: 0 auto 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px;
}
.tabs .tab {
  flex: 1; margin: 0; padding: 9px 0; font-size: 14px;
  background: transparent; color: var(--muted); border-radius: 9px;
}
.tabs .tab.on { background: var(--line); color: var(--fg); }

.lead { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.mt { margin-top: 18px; }

/* ── 여러 장 촬영 ──────────────────────────────────────── */
.shots { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.shots:empty { display: none; }
.shot { position: relative; width: 84px; height: 84px; }
.shot img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.shot-del {
  position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; padding: 0;
  margin: 0; font-size: 14px; line-height: 1; border-radius: 50%;
  background: var(--line); color: var(--fg);
}
.profile-chip { margin-top: 10px; font-size: 12px; color: var(--muted); }

/* ── 결과 보강 ─────────────────────────────────────────── */
.hint { font-size: 13px; color: var(--muted); border-style: dashed; }

/* ── 광고 ──────────────────────────────────────────────── */
.ad { border-style: dashed; }
.ad-tag {
  display: inline-block; font-size: 10px; font-weight: 700; padding: 2px 7px;
  border-radius: 999px; background: var(--line); color: var(--muted); margin-bottom: 8px;
}
.ad-title { display: block; }
.ad-body { margin: 4px 0 0; font-size: 13px; color: var(--muted); }

/* ── 히스토리 ──────────────────────────────────────────── */
.history-list { list-style: none; padding: 0; margin: 0; }
.history-item {
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 10px 12px; margin-bottom: 10px;
}
.history-thumb { width: 52px; height: 52px; object-fit: cover; border-radius: 10px; flex: 0 0 auto; }
.history-body { flex: 1; min-width: 0; }
.history-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-meta { font-size: 12px; color: var(--muted); }
.history-grade {
  flex: 0 0 34px; height: 34px; display: grid; place-items: center;
  font-weight: 800; border-radius: 10px; background: var(--accent); color: #06200f;
}
.history-grade[data-grade=C] { background: var(--ok); }
.history-grade[data-grade=D], .history-grade[data-grade=E] { background: var(--bad); }
.history-del {
  width: auto; margin: 0; padding: 6px 8px; font-size: 14px;
  background: transparent; color: var(--muted);
}
.locked { text-align: center; }
.locked p { color: var(--muted); font-size: 14px; }

/* ── 설정 ──────────────────────────────────────────────── */
.choice-list { display: grid; gap: 8px; }
.choice {
  width: 100%; margin: 0; padding: 12px; text-align: left;
  background: #101c15; color: var(--fg); border: 1px solid var(--line); border-radius: 12px;
}
.choice.on { border-color: var(--accent); background: #13281c; }
.choice b { display: block; font-size: 14px; }
.choice span { display: block; margin-top: 3px; font-size: 12px; color: var(--muted); font-weight: 400; }


.tier-row { display: grid; gap: 8px; }
.tier-btn {
  margin: 0; padding: 12px; font-size: 13px; text-align: left;
  background: #101c15; color: var(--fg); border: 1px solid var(--line); border-radius: 12px;
}
.tier-btn.on { border-color: var(--accent); background: #13281c; }
.saved { text-align: center; color: var(--accent); font-size: 13px; }

/* ── 재료 / 유의사항 ───────────────────────────────────── */
.count { font-weight: 400; color: var(--muted); }
.ing-list .none { display: block; color: var(--muted); font-size: 13px; padding: 4px 0; border: 0; }
.caution-list { list-style: none; padding: 0; }
.caution-list li { padding: 12px 0; border-top: 1px solid var(--line); }
.caution-list li:first-child { border-top: 0; }
.caution-head { display: flex; align-items: center; gap: 8px; }
.caution-title { font-size: 15px; }
.caution-detail { margin: 5px 0 0; font-size: 14px; color: var(--muted); }
.basis {
  flex: 0 0 auto; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  background: var(--line); color: var(--muted);
}
.basis.inference { background: #3a2f16; color: var(--ok); }
.raw {
  margin: 0; font-size: 13px; line-height: 1.7; color: var(--muted);
  word-break: keep-all;
}

/* ── 구입 판단 ─────────────────────────────────────────── */
.verdict { border-left: 3px solid var(--accent); }
.verdict p { margin: 5px 0 0; font-size: 14px; color: var(--muted); }
.verdict-stance { font-weight: 700; color: var(--good); }
.verdict-stance[data-stance=not_recommended] { color: var(--ok); }
.verdict-stance[data-stance=avoid] { color: var(--bad); }
.verdict-stance[data-stance=neutral] { color: var(--fg); }

/* ── 재분석 ────────────────────────────────────────────── */
.reanalyze-bar {
  background: var(--card); border: 1px dashed var(--line);
  border-radius: 14px; padding: 14px; margin-bottom: 14px;
}
.reanalyze-bar p { margin: 0; font-size: 13px; color: var(--muted); }
.reanalyze-bar button { margin-top: 10px; }
.alt { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.alt p { margin: 5px 0 0; font-size: 14px; color: var(--muted); }
.alt-tag {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: #13281c; color: var(--accent);
}
.alt-tag[data-exists=no] { background: var(--line); color: var(--muted); }
