:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --ink: #23302b;
  --muted: #6b7570;
  --line: #e8e2d8;
  --green: #2f6b5a;
  --green-soft: #e6f0ec;
  --coral: #e2674c;
  --coral-soft: #fdece7;
  --amber: #c98a12;
  --amber-soft: #fbf1dc;
  --blue: #3b6fb6;
  --radius: 16px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: Pretendard, -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  font-size: 16px; line-height: 1.6; word-break: keep-all; overflow-wrap: anywhere;
}
a { color: inherit; }
img { max-width: 100%; display: block; }
.wrap { max-width: 560px; margin: 0 auto; padding: 0 16px; }

/* 헤더 */
#header {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  max-width: 560px; margin: 0 auto; padding: 10px 16px; background: rgba(250, 247, 242, .92);
  backdrop-filter: saturate(1.4) blur(8px); -webkit-backdrop-filter: saturate(1.4) blur(8px);
}
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 19px; text-decoration: none; color: var(--green); }
.logo-mark { width: 28px; height: 28px; border-radius: 9px; background: var(--green); color: #fff; display: grid; place-items: center; font-size: 15px; }
.logo-txt { display: flex; flex-direction: column; line-height: 1.1; }
.logo-txt small { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.slogan { font-size: 13px; font-weight: 600; color: var(--green); background: var(--green-soft); padding: 5px 10px; border-radius: 999px; white-space: nowrap; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--coral); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.badge[hidden] { display: none; }

/* 공통 */
main { padding-bottom: 32px; }
body { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px; margin: 14px 0; }
.h1 { font-size: 24px; line-height: 1.35; margin: 4px 0 12px; letter-spacing: -.02em; }
.h2 { font-size: 18px; margin: 0 0 12px; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.hl { color: var(--coral); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; cursor: pointer;
  background: var(--green); color: #fff; font: inherit; font-weight: 700; font-size: 16px;
  padding: 14px 20px; border-radius: 14px; text-decoration: none; min-height: 48px;
}
.btn:active { transform: translateY(1px); }
.btn.sm { font-size: 14px; padding: 8px 14px; min-height: 38px; border-radius: 10px; flex: none; }
.btn.ghost { background: var(--green-soft); color: var(--green); }
.btn[disabled] { opacity: .75; cursor: default; }
.btn.wide { width: 100%; margin-top: 10px; }
.chip { font: inherit; color: inherit; cursor: pointer; display: inline-block; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; text-decoration: none; font-size: 14.5px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

/* 홈 히어로 */
.hero { padding: 28px 0 8px; }
.eyebrow { display: inline-block; font-size: 13px; font-weight: 700; color: var(--green); background: var(--green-soft); padding: 4px 10px; border-radius: 999px; }
.hero h1 { font-size: 30px; line-height: 1.3; margin: 14px 0 10px; letter-spacing: -.03em; }
.hero p { color: var(--muted); margin: 0 0 20px; }
.hero .btn { width: 100%; font-size: 17px; min-height: 56px; }
.hero .sub { display: block; text-align: center; margin-top: 10px; font-size: 13.5px; color: var(--muted); }
.steps { display: grid; gap: 10px; counter-reset: s; padding: 0; margin: 0; list-style: none; }
.steps li { display: flex; gap: 12px; align-items: flex-start; }
.steps li::before { counter-increment: s; content: counter(s); flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--green); color: #fff; font-weight: 800; display: grid; place-items: center; font-size: 14px; margin-top: 1px; }
.steps b { display: block; }
.features { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.feature { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.feature .ic { font-size: 22px; }
.feature b { display: block; margin: 4px 0 2px; font-size: 15px; }
.feature p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; }

/* 제품 행 */
.prow { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.prow:first-of-type { border-top: 0; }
.h2 + .prow, .muted + .prow { border-top: 0; }
.prow-main { display: flex; gap: 12px; align-items: center; flex: 1; min-width: 0; text-decoration: none; }
.pthumb { flex: none; width: 46px; height: 46px; border-radius: 12px; background: var(--green-soft); color: var(--green); font-weight: 800; font-size: 13px; display: grid; place-items: center; }
.pinfo { display: flex; flex-direction: column; min-width: 0; }
.pbrand { font-size: 12.5px; color: var(--muted); }
.pname { font-weight: 700; line-height: 1.35; }
.pmeta { font-size: 13.5px; color: var(--muted); }
.pmeta b { color: var(--ink); }
.down { color: var(--blue); font-style: normal; font-weight: 700; }

/* 찍어 보기 */
.shoot { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; border: 2px dashed #bcd3ca; background: var(--green-soft); border-radius: 20px; padding: 32px 16px; cursor: pointer; }
.shoot .cam { font-size: 40px; }
.shoot b { font-size: 18px; color: var(--green); }
.shoot input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.preview { margin-top: 12px; border-radius: 14px; overflow: hidden; max-height: 260px; }
.preview img { width: 100%; object-fit: cover; max-height: 260px; }
.status { display: flex; align-items: center; gap: 8px; margin: 12px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--amber-soft); font-size: 14.5px; }
.status[hidden], .preview[hidden] { display: none; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 3px solid #e7cf9b; border-top-color: var(--amber); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.search { width: 100%; font: inherit; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.search:focus { outline: 2px solid var(--green); outline-offset: 1px; }
.or { text-align: center; color: var(--muted); font-size: 13.5px; margin: 16px 0 8px; }
.sticky-go { position: sticky; bottom: calc(80px + env(safe-area-inset-bottom)); }
.sticky-go[hidden] { display: none; }

/* 내 영양제함 */
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; padding: 14px 10px; }
.sum-item span { display: block; font-size: 12.5px; color: var(--muted); }
.sum-item b { font-size: 18px; letter-spacing: -.02em; }
.sum-item.bad b { color: var(--coral); }
.sum-item.good b { color: var(--green); }
.alert { background: var(--coral-soft); border-color: #f5c9bd; }
.alert-row { padding: 10px 0; border-top: 1px solid #f3cfc5; }
.alert-row:first-of-type { border-top: 0; padding-top: 0; }
.alert-row p { margin: 0 0 2px; }
.bars { display: grid; gap: 14px; }
.bar-head, .bar-foot { display: flex; justify-content: space-between; font-size: 14px; }
.bar-head span:first-child { font-weight: 700; }
.bar-foot { font-size: 12.5px; color: var(--muted); }
.bar { position: relative; height: 10px; background: #efebe4; border-radius: 999px; margin: 6px 0 4px; overflow: hidden; }
.bar .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; }
.bar .mark { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink); opacity: .45; }
.fill.ok { background: var(--green); }
.fill.low { background: #9db8ae; }
.fill.warn { background: var(--amber); }
.fill.over { background: var(--coral); }
.st { font-size: 12.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
.st.ok { background: var(--green-soft); color: var(--green); }
.st.low { background: #eef1ef; color: var(--muted); }
.st.warn { background: var(--amber-soft); color: var(--amber); }
.st.over { background: var(--coral-soft); color: var(--coral); }
.save { border-color: #cfe0d8; }
.swap { padding: 12px 0; border-top: 1px solid var(--line); }
.swap p { margin: 0; }
.empty { text-align: center; padding: 32px 18px; }
.empty .big { font-size: 18px; font-weight: 700; margin: 0 0 6px; }

/* 쿠팡 박스 */
.cp { margin-top: 10px; }
.cp-btn { width: 100%; background: #fff; color: var(--ink); border: 1.5px solid var(--ink); min-height: 44px; font-size: 15px; }
.disc { margin: 0 0 8px; font-size: 13px; color: #4a524e; line-height: 1.55; }

/* 제품 상세 */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 10px; }
.stats div { background: var(--bg); border-radius: 12px; padding: 10px 8px; text-align: center; }
.stats span { display: block; font-size: 12.5px; color: var(--muted); }
.stats b { font-size: 17px; }
.vs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.vs div { background: var(--bg); border-radius: 12px; padding: 12px; }
.vs span { display: block; font-size: 12.5px; color: var(--muted); }
.vs b { font-size: 22px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.tbl th { text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 0 0 6px; }
.tbl td { padding: 8px 0; border-top: 1px solid var(--line); vertical-align: top; }
.tbl td.muted { font-size: 12.5px; }

/* 푸터·토스트 */
#footer { max-width: 560px; margin: 24px auto 0; padding: 20px 16px 40px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line); }
#footer p { margin: 0 0 8px; }
.sample-flag { color: var(--coral); }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px; font-size: 14.5px; opacity: 0; transition: .25s; pointer-events: none; z-index: 50; max-width: calc(100% - 32px); text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 600px) {
  .hero h1 { font-size: 34px; }
}

/* 하단 탭 바 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr);
  max-width: 560px; margin: 0 auto; background: rgba(255,255,255,.97); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 600; padding: 4px 0; min-height: 50px; justify-content: center; }
.tab .ti { position: relative; display: grid; place-items: center; }
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--green); }
.tab .badge { position: absolute; top: -4px; right: -10px; }
.tab-cam .ti { width: 52px; height: 52px; margin-top: -22px; border-radius: 50%; background: var(--green); color: #fff; box-shadow: 0 4px 14px rgba(47,107,90,.35); border: 3px solid #fff; }
.tab-cam { color: var(--green); }
.tab-cam[aria-current="page"] .ti { background: var(--coral); box-shadow: 0 4px 14px rgba(226,103,76,.35); }

/* 칩 상태 */
.chip.on { background: var(--green); color: #fff; border-color: var(--green); }
.chip.dim { color: var(--muted); background: #f4f1ec; }
.chip.static { cursor: default; }
.tabs-chips { margin: 4px 0 14px; }
.scroll-chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 6px; scrollbar-width: none; }
.scroll-chips::-webkit-scrollbar { display: none; }
.scroll-chips .chip { flex: none; }

/* 성분백과 */
.glist { display: grid; gap: 10px; }
.gitem { display: flex; flex-direction: column; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; text-decoration: none; }
.gitem b { font-size: 17px; }
.gitem.soon { background: #f6f3ee; }
.gtags { display: flex; gap: 6px; }
.gtags i { font-style: normal; font-size: 12px; font-weight: 600; color: var(--green); background: var(--green-soft); padding: 2px 8px; border-radius: 999px; }
.back { display: inline-block; margin: 14px 0 0; font-size: 14px; color: var(--muted); text-decoration: none; }
.ghead .h1 { margin-bottom: 6px; }
.lead { margin: 0; font-size: 16.5px; }
.claims { margin: 0; padding-left: 20px; }
.claims li { margin: 4px 0; font-weight: 600; }
.form-row { padding: 10px 0; border-top: 1px solid var(--line); }
.form-row:first-of-type { border-top: 0; padding-top: 0; }
.form-row p { margin: 2px 0 0; }
.card p:last-child { margin-bottom: 0; }
.card .h2 + p { margin-top: 0; }
.stats.two { grid-template-columns: 1fr 1fr; }
.seg { display: flex; background: var(--bg); border-radius: 10px; padding: 3px; margin-bottom: 6px; }
.seg button { flex: 1; font: inherit; font-size: 14px; font-weight: 600; border: 0; background: transparent; padding: 8px; border-radius: 8px; color: var(--muted); cursor: pointer; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.amt { flex: none; font-weight: 800; font-size: 14.5px; color: var(--green); }

/* 비교·랭킹 */
.ranked { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); }
.ranked:first-of-type, .h2 + .ranked, .muted + .ranked { border-top: 0; }
.ranked .prow { flex: 1; border-top: 0; min-width: 0; }
.rk { flex: none; width: 22px; font-weight: 800; color: var(--coral); text-align: center; }
.guide-link { display: block; text-decoration: none; background: var(--green-soft); border-color: #cfe0d8; font-size: 15px; }
.mgroup { padding: 8px 0; border-top: 1px solid var(--line); }
.mgroup:first-of-type { border-top: 0; }
.mgroup > p { margin: 0; }

/* 홈 버튼 두 개 */
.two-btn { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }

/* 퀴즈 */
.quiz-intro { text-align: center; padding: 32px 18px; }
.quiz-intro .h1 { font-size: 28px; margin-top: 12px; }
.qprog { display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 700; color: var(--muted); }
.qbar { flex: 1; height: 6px; background: #efebe4; border-radius: 999px; overflow: hidden; }
.qbar i { display: block; height: 100%; background: var(--green); transition: width .3s; }
.qtext { font-size: 20px; line-height: 1.45; margin: 16px 0; letter-spacing: -.01em; }
.qopts { display: grid; gap: 10px; }
.qopt { font: inherit; font-size: 16px; font-weight: 600; text-align: left; padding: 15px 16px; border-radius: 14px; border: 1.5px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; min-height: 52px; }
.qopt:not([disabled]):active { border-color: var(--green); }
.qopt.right { border-color: var(--green); background: var(--green-soft); color: var(--green); }
.qopt.wrong { border-color: var(--coral); background: var(--coral-soft); color: var(--coral); }
.qopt[disabled] { cursor: default; }
.qfeed { margin-top: 14px; padding: 14px; border-radius: 14px; }
.qfeed.ok { background: var(--green-soft); }
.qfeed.no { background: var(--amber-soft); }
.qfeed p { margin: 4px 0 0; font-size: 15px; }
.quiz-result { text-align: center; padding: 28px 18px; }
.qscore { margin: 10px 0 0; font-size: 22px; color: var(--muted); }
.qscore b { font-size: 56px; color: var(--ink); letter-spacing: -.03em; }
.quiz-result .h1 { color: var(--coral); margin: 0 0 6px; }
.qshare { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.qreview { padding: 12px 0; border-top: 1px solid var(--line); }
.qreview:first-of-type { border-top: 0; padding-top: 0; }
.qreview p { margin: 0 0 4px; }
.qimg-box { position: fixed; inset: 0; z-index: 60; background: rgba(20,28,25,.85); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px 16px; color: #fff; }
.qimg-box img { max-height: 70vh; width: auto; border-radius: 12px; }
.qimg-box .btn { max-width: 320px; }
@media (prefers-reduced-motion: reduce) { .qbar i, #toast { transition: none; } .spinner { animation: none; } }

/* 실제 데이터 연결 후 추가 */
.loading { text-align: center; padding: 24px 0; }
.mk-row { flex: 1; display: flex; justify-content: space-between; gap: 8px; padding: 10px 0; min-width: 0; }
.mk-row b { overflow-wrap: anywhere; }
details.mgroup { padding: 0; }
details.mgroup summary { display: flex; align-items: center; gap: 8px; padding: 12px 0; cursor: pointer; list-style: none; }
details.mgroup summary::-webkit-details-marker { display: none; }
details.mgroup summary b { flex: 1; min-width: 0; overflow-wrap: anywhere; }
details.mgroup summary::after { content: '▾'; color: var(--muted); }
details.mgroup[open] summary::after { content: '▴'; }
.mlist { padding-bottom: 8px; }

/* 서버 렌더링 페이지 */
.crumbs { margin: 14px 0 0; overflow-wrap: anywhere; }
.crumbs a { color: inherit; }

/* 빼기·바꾸기 제안 */
.fix { margin-top: 10px; padding: 12px; background: #fff; border-radius: 12px; border: 1px solid #f3cfc5; }
.fix-row { padding: 8px 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.fix-row:first-of-type { border-top: 0; }
.fix-row p { margin: 0; }
.fixbtn { width: 100%; justify-content: flex-start; text-align: left; height: auto; white-space: normal; line-height: 1.4; padding: 9px 12px; min-height: 40px; }

/* 오늘의 특가 */
.dstrip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; margin: 0 -2px; }
.dstrip::-webkit-scrollbar { display: none; }
.dstrip .dcard { flex: none; width: 150px; }
.dgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0 10px; }
.dcard { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit; min-width: 0; }
.dimg-wrap { display: block; aspect-ratio: 1 / 1; border-radius: 12px; overflow: hidden; background: #efebe4; }
.dimg { width: 100%; height: 100%; object-fit: cover; display: block; }
.dname { font-size: 13.5px; font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.7em; }
.dprice { font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.dbadges { display: flex; gap: 4px; flex-wrap: wrap; min-height: 18px; }
.dbadges i { font-style: normal; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: #eef1ef; color: var(--muted); white-space: nowrap; flex: none; }
.dbadges i.rk { background: var(--green-soft); color: var(--green); }

.dunit { font-size: 13px; color: var(--coral); font-weight: 700; }
.dunit b { font-size: 16px; }
.dprice { font-size: 14px !important; font-weight: 600 !important; color: var(--muted); letter-spacing: 0 !important; }

/* 특가 바로가기·계산기 */
.dlinks { display: grid; gap: 8px; }
.dlink { justify-content: flex-start; text-align: left; }
.calc-grid { display: grid; gap: 6px; margin: 10px 0; }
.calc-grid label { font-size: 13.5px; font-weight: 700; margin-top: 4px; }
.calc-out { margin-top: 10px; }
.tips { margin: 0; padding-left: 20px; display: grid; gap: 8px; font-size: 15px; }

.traits ul { margin: 4px 0 10px; padding-left: 18px; }
.traits li { margin: 4px 0; line-height: 1.6; font-size: 14.5px; }
.traits h3 { margin: 12px 0 2px; font-size: 15px; }
.traits h3.tg { color: #1f6b4a; }
.traits h3.tw { color: #8a5a00; }
.legal { max-width: 640px; margin: 0 auto; padding: 16px; line-height: 1.75; }
.legal h2 { font-size: 17px; margin: 22px 0 6px; }
.legal p, .legal li { font-size: 14.5px; }
.tips { margin: 4px 0 8px; padding-left: 18px; }
.tips li { margin: 8px 0; line-height: 1.65; font-size: 14.5px; }

.deal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.deal-card { position: relative; display: flex; flex-direction: column; gap: 3px; padding: 10px; border: 1px solid #e3e7e4; border-radius: 14px; background: #fff; color: var(--ink); text-decoration: none; }
.deal-card img { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 10px; background: #f6f7f6; }
.deal-off { position: absolute; top: 8px; left: 8px; z-index: 1; background: #d63a2f; color: #fff; font-weight: 800; font-size: 13px; padding: 3px 8px; border-radius: 999px; }
.deal-name { font-size: 13px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.deal-price { font-size: 19px; color: #d63a2f; }
.deal-sub { font-size: 11.5px; color: #6b736f; }

.amt { text-align: right; line-height: 1.35; }
.over-tag { font-style: normal; font-size: 11.5px; font-weight: 700; color: #c0392b; }
.prow .pname + .pbrand { margin-top: 2px; }
