/* 체성분 식단 코치 — 화면 규칙
   정체성: 식품 포장의 "영양정보" 표. 굵은 검은 줄, 큰 숫자, 칸 나눔. 이 언어를 섹션 제목과 오늘 패널에만 쓰고 나머지는 조용하게.
   색: 탄수=곡물(금색), 단백질=고기(적갈), 지방=물(청). 행동 버튼은 짙은 초록 하나. */
:root {
  --bg: #f4f5f3; --surface: #ffffff; --ink: #111513; --ink-2: #2c332f; --muted: #66706a; --line: #e2e6e3; --line-2: #cfd5d1;
  --green: #17694a; --green-2: #0f5139; --green-soft: #e4f1ea;
  --carb: #c4860a; --carb-soft: #f8eed6; --carb-ink: #6b4704;
  --prot: #b4402e; --prot-soft: #f7e3df; --prot-ink: #7a2618;
  --fat: #2d63a3; --fat-soft: #e1eaf5; --fat-ink: #1b3f6d;
  --warn: #a5541b; --warn-soft: #fbeee2; --good: #17694a;
  --r: 16px; --r-sm: 10px; --pad: 16px;
  --nav-h: 64px;
  font-family: "Pretendard Variable", Pretendard, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color: var(--ink); background: var(--bg); -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { font-size: 16px; line-height: 1.5; word-break: keep-all; overflow-wrap: anywhere; -webkit-tap-highlight-color: transparent; }
main { max-width: 480px; margin: 0 auto; padding: 8px var(--pad) calc(var(--nav-h) + 40px + env(safe-area-inset-bottom)); }
.num, .kcal, .v { font-variant-numeric: tabular-nums; }
.ic { width: 22px; height: 22px; flex: none; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; border-radius: 6px; }
small, .muted { color: var(--muted); }
p { margin: 6px 0; }
a { color: var(--green); }
h1 { font-size: 26px; line-height: 1.25; letter-spacing: -0.03em; margin: 8px 0 14px; font-weight: 800; }
h3 { font-size: 16px; margin: 0; letter-spacing: -0.01em; }

/* 화면 머리: 날짜(작게) + 제목 */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding-top: 10px; }
.page-head .eyebrow { font-size: 14px; color: var(--muted); font-weight: 600; }
.page-head h1 { margin: 2px 0 12px; }
.icon-btn { display: inline-grid; place-items: center; width: 42px; height: 42px; min-height: 0; padding: 0; border-radius: 12px; border: 0; background: transparent; color: var(--ink); cursor: pointer; flex: none; }
.icon-btn:active { background: var(--line); }

/* 섹션 제목: 영양정보 표의 굵은 줄 */
.sec { margin: 28px 0 10px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; border-bottom: 3px solid var(--ink); padding-bottom: 6px; }
.sec h2 { font-size: 17px; margin: 0; font-weight: 800; letter-spacing: -0.02em; }
.sec .aside { font-size: 13px; color: var(--muted); }

/* 이번 주 날짜 띠 */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 2px 0 14px; }
.week button { border: 0; background: transparent; padding: 6px 0 8px; border-radius: 12px; color: var(--muted); font: inherit; cursor: pointer; display: grid; gap: 2px; justify-items: center; }
.week button b { font-size: 16px; color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.week button small { font-size: 12px; }
.week button i { width: 5px; height: 5px; border-radius: 50%; background: transparent; }
.week button.has i { background: var(--green); }
.week button[aria-current="date"] { background: var(--ink); color: #fff; }
.week button[aria-current="date"] b, .week button[aria-current="date"] small { color: #fff; }
.week button[aria-current="date"].has i { background: #fff; }
.week button:disabled { opacity: .35; }

/* 오늘의 영양정보 패널 */
.label-panel { background: var(--surface); border: 2px solid var(--ink); border-radius: 6px; padding: 12px 14px 6px; }
.label-panel .title { display: flex; justify-content: space-between; align-items: baseline; font-weight: 800; font-size: 15px; border-bottom: 8px solid var(--ink); padding-bottom: 6px; }
.label-panel .title span { font-weight: 600; color: var(--muted); font-size: 13px; }
.remain { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 6px 12px; padding: 10px 0 8px; border-bottom: 2px solid var(--ink); }
.remain .big { font-size: 46px; line-height: 1; font-weight: 800; letter-spacing: -0.045em; font-variant-numeric: tabular-nums; }
.remain .big small { font-size: 16px; color: var(--ink); font-weight: 700; letter-spacing: 0; margin-left: 2px; }
.remain .cap { font-size: 13px; color: var(--muted); grid-column: 1 / -1; }
.remain .eq { text-align: right; font-size: 13px; color: var(--muted); line-height: 1.45; font-variant-numeric: tabular-nums; }
.remain .eq b { color: var(--ink); font-weight: 700; }
.remain.over .big { color: var(--warn); }
.macro { display: grid; grid-template-columns: 58px 1fr auto; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--ink); }
.macro:last-child { border-bottom: 0; }
.macro b { font-size: 15px; }
.macro .v { font-size: 15px; font-weight: 700; white-space: nowrap; }
.macro .v small { font-weight: 500; }
.bar { height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; position: relative; }
.bar i { position: absolute; inset: 0 auto 0 0; border-radius: 5px; }
.bar.over i { background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.45) 0 4px, transparent 4px 8px); }
.c-carb { color: var(--carb); } .c-prot { color: var(--prot); } .c-fat { color: var(--fat); }
.bg-carb { background: var(--carb); } .bg-prot { background: var(--prot); } .bg-fat { background: var(--fat); }

/* 묶음 목록 (끼니·기록·설정) */
.list { background: var(--surface); border-radius: var(--r); overflow: hidden; }
.list + .list { margin-top: 10px; }
.item { display: flex; align-items: center; gap: 12px; padding: 14px var(--pad); border-top: 1px solid var(--line); min-height: 60px; background: var(--surface); width: 100%; text-align: left; font: inherit; color: inherit; border-left: 0; border-right: 0; border-bottom: 0; }
.item:first-child { border-top: 0; }
button.item, a.item { cursor: pointer; text-decoration: none; }
button.item:active, a.item:active { background: #f2f4f2; }
.item .grow { flex: 1; min-width: 0; }
.item .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.item .end { text-align: right; font-variant-numeric: tabular-nums; }
.item .chev { color: var(--line-2); }
.grow { flex: 1; min-width: 0; }

/* 끼니 줄 */
.meal-row { align-items: flex-start; }
.meal-row .when { width: 44px; flex: none; font-weight: 800; font-size: 15px; padding-top: 1px; }
.meal-row .when small { display: block; font-weight: 500; font-size: 12px; }
.meal-row .mini { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin: 8px 0 6px; }
.meal-row .mini i { display: block; height: 100%; background: var(--ink-2); border-radius: 3px; }
.meal-row .mini.over i { background: var(--warn); }
.meal-row .foods { font-size: 14px; color: var(--ink-2); }
.add { display: inline-grid; place-items: center; width: 40px; height: 40px; min-height: 0; padding: 0; border-radius: 50%; background: var(--green-soft); color: var(--green); flex: none; border: 0; cursor: pointer; aspect-ratio: 1; }
.add .ic { width: 20px; height: 20px; }

/* 영양소 칩 */
.grams { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.chip { display: inline-flex; align-items: center; gap: 3px; border-radius: 6px; padding: 2px 7px; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chip.carb { background: var(--carb-soft); color: var(--carb-ink); }
.chip.prot { background: var(--prot-soft); color: var(--prot-ink); }
.chip.fat { background: var(--fat-soft); color: var(--fat-ink); }
.chip.kcal { background: #eceeec; color: var(--ink); }
.chip.ai { background: #ede8fb; color: #4b3a8f; }
.tag { display: inline-block; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.tag.good { background: var(--green-soft); color: var(--green-2); }
.tag.over { background: var(--warn-soft); color: var(--warn); }
.tag.under { background: #eceeec; color: var(--ink-2); }

/* 알림 (제안·리마인드): 왼쪽 굵은 줄 */
.notice { background: var(--surface); border-radius: var(--r); padding: 14px var(--pad); margin: 12px 0; border-left: 5px solid var(--warn); }
.notice.good { border-left-color: var(--green); }
.notice.plain { border-left-color: var(--line-2); }
.notice h3 { margin-bottom: 4px; }
.notice .delta { font-size: 22px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; margin: 4px 0; }
.notice p { font-size: 15px; color: var(--ink-2); }

/* 카드 (폼·결과 등 덩어리) */
.card { background: var(--surface); border-radius: var(--r); padding: 16px var(--pad); margin: 12px 0; }
.card.flat { background: #eceeec; }

/* 버튼 */
button, .btn { font: inherit; border: 0; border-radius: 14px; padding: 13px 18px; background: var(--green); color: #fff; font-weight: 700; cursor: pointer; min-height: 50px; letter-spacing: -0.01em; }
button:active { filter: brightness(.94); }
button.secondary, .btn.secondary { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line-2); }
button.quiet { background: #eceeec; color: var(--ink); }
button.ghost { background: transparent; color: var(--green); padding: 8px 6px; min-height: 0; font-weight: 700; }
button.danger { background: var(--surface); color: var(--prot); box-shadow: inset 0 0 0 1.5px #e6bdb6; }
button.block { width: 100%; }
button:disabled { opacity: .45; cursor: default; }
.btns { display: flex; gap: 8px; margin-top: 12px; }
.btns > * { flex: 1; }

/* 입력 */
label { display: block; font-size: 14px; color: var(--muted); margin: 14px 0 6px; font-weight: 600; }
input, select { font: inherit; width: 100%; padding: 12px 14px; border: 1.5px solid var(--line-2); border-radius: 12px; background: var(--surface); color: var(--ink); min-height: 50px; }
input:focus { border-color: var(--green); outline: none; box-shadow: 0 0 0 3px var(--green-soft); }
input.warn { border-color: var(--warn); background: var(--warn-soft); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-row label { margin-top: 12px; }
.search { position: relative; }
.search .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 44px; }

/* 선택지 */
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line-2); border-radius: 999px; padding: 10px 16px; font-weight: 600; min-height: 44px; }
.choice[aria-pressed="true"] { background: var(--ink); color: #fff; box-shadow: none; }
.tiles { display: grid; gap: 8px; }
.tiles.two { grid-template-columns: 1fr 1fr; }
.tile { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line-2); border-radius: 14px; padding: 14px 16px; text-align: left; font-weight: 700; min-height: 0; }
.tile small { display: block; color: var(--muted); font-weight: 500; margin-top: 2px; font-size: 13px; }
.tile[aria-pressed="true"] { box-shadow: inset 0 0 0 2.5px var(--ink); background: #fbfcfb; }
.tile[aria-pressed="true"] small { color: var(--ink-2); }
.seg { display: flex; background: #e6e9e6; border-radius: 12px; padding: 3px; gap: 2px; overflow-x: auto; }
.seg button { flex: 1 0 auto; background: transparent; color: var(--ink-2); border-radius: 10px; min-height: 38px; padding: 7px 12px; font-size: 14px; font-weight: 700; }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(17,21,19,.12); }

/* 식단 안 */
.plan-meal { padding: 12px var(--pad); border-top: 1px solid var(--line); }
.plan-meal:first-child { border-top: 0; }
.plan-meal .head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.plan-meal ul { list-style: none; padding: 0; margin: 0 0 8px; }
.plan-meal li { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; font-size: 15px; }
.plan-meal li b { font-weight: 600; color: var(--ink-2); white-space: nowrap; }

/* 사진 넣기 */
.drop { display: grid; place-items: center; gap: 6px; text-align: center; background: var(--surface); border: 2px dashed var(--line-2); border-radius: var(--r); padding: 26px 16px; cursor: pointer; font-weight: 700; color: var(--ink); }
.drop .ic { width: 34px; height: 34px; color: var(--green); }
.drop small { font-weight: 500; }
.drop input { display: none; }
.photo { width: 100%; max-height: 220px; object-fit: cover; border-radius: var(--r); display: block; }
.thumb { width: 52px; height: 52px; border-radius: 12px; object-fit: cover; background: #e6e9e6; flex: none; }
.progress { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 10px; }
.progress i { display: block; height: 100%; width: 0; background: var(--green); transition: width .3s; }
.progress.indet i { width: 40%; animation: indet 1.2s ease-in-out infinite; }
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }

/* 수량 조절 */
.stepper { display: inline-flex; align-items: center; background: #eceeec; border-radius: 12px; }
.stepper button { background: transparent; color: var(--ink); min-height: 40px; width: 40px; padding: 0; display: grid; place-items: center; border-radius: 12px; }
.stepper input { width: 64px; min-height: 40px; border: 0; background: transparent; text-align: center; padding: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.stepper input:focus { box-shadow: none; }

/* 아래 고정 행동 막대 */
.actionbar { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 6; background: rgba(244,245,243,.94); backdrop-filter: blur(8px); border-top: 1px solid var(--line); }
.actionbar .in { max-width: 480px; margin: 0 auto; padding: 10px var(--pad); display: flex; gap: 12px; align-items: center; }
.actionbar .sum { flex: 1; font-size: 13px; color: var(--muted); }
.actionbar .sum b { display: block; font-size: 18px; color: var(--ink); font-variant-numeric: tabular-nums; }
.has-actionbar main { padding-bottom: calc(var(--nav-h) + 120px + env(safe-area-inset-bottom)); }

/* 인터뷰 */
.steps { display: flex; gap: 4px; margin: 2px 0 16px; }
.steps i { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.steps i.on { background: var(--ink); }
.chat { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 16px; }
.bubble { max-width: 86%; padding: 10px 14px; border-radius: 18px 18px 18px 6px; background: var(--surface); font-size: 15px; }
.bubble.me { align-self: flex-end; background: var(--ink); color: #fff; border-radius: 18px 18px 6px 18px; }
.ask-q { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; margin: 4px 0 12px; }

/* 체중 */
.stat { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat div { background: var(--surface); border-radius: var(--r-sm); padding: 12px; }
.stat small { display: block; font-size: 12px; }
.stat b { font-size: 20px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .down { color: var(--green); } .stat .up { color: var(--warn); }
.chart { width: 100%; height: auto; display: block; }
.d-up { color: var(--warn); } .d-down { color: var(--green); }

.basis dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.basis dt { color: var(--muted); } .basis dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
details { background: var(--surface); border-radius: var(--r); padding: 4px var(--pad); margin: 12px 0; }
summary { cursor: pointer; font-weight: 700; padding: 12px 0; list-style: none; display: flex; justify-content: space-between; }
summary::after { content: "+"; color: var(--muted); font-weight: 400; }
details[open] summary::after { content: "−"; }
details[open] { padding-bottom: 14px; }

.disclaimer { font-size: 12px; color: var(--muted); margin-top: 32px; text-align: center; line-height: 1.6; }

/* 아래 탭 + 가운데 카메라 */
nav#tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 7; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
nav#tabs[hidden] { display: none; }
nav#tabs .in { max-width: 480px; margin: 0 auto; height: var(--nav-h); display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; }
nav#tabs a { display: grid; justify-items: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 700; padding: 6px 0; }
nav#tabs a[aria-current="page"] { color: var(--ink); }
nav#tabs a.fab { width: 58px; height: 58px; border-radius: 50%; background: var(--green); color: #fff; place-self: center; align-content: center; margin-top: -26px; box-shadow: 0 6px 16px rgba(23,105,74,.35), 0 0 0 5px var(--bg); }
nav#tabs a.fab .ic { width: 26px; height: 26px; }
nav#tabs a.fab span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 12px; max-width: calc(100% - 32px); z-index: 20; font-size: 15px; font-weight: 600; }
#toast[hidden] { display: none; }

/* 로그인 */
.login { max-width: 380px; margin: 14vh auto 0; }
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.brand-mark { width: 44px; height: 44px; border-radius: 12px; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 13px; line-height: 1; letter-spacing: -0.02em; text-align: center; }
.brand b { font-size: 20px; letter-spacing: -0.02em; }
.login h1 { font-size: 30px; }
.login input { font-size: 20px; letter-spacing: 0.08em; text-align: center; }
.hint { background: #eceeec; border-radius: var(--r-sm); padding: 12px 14px; font-size: 14px; margin-top: 18px; }
.hint code { font-weight: 700; font-size: 15px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* 처음 사용 안내 */
.welcome-hero { background: var(--surface); border: 2px solid var(--ink); border-radius: 6px; padding: 16px; margin: 4px 0 16px; }
.welcome-hero .title { font-weight: 800; border-bottom: 8px solid var(--ink); padding-bottom: 6px; margin-bottom: 10px; display: flex; justify-content: space-between; }
.welcome-hero .title span { color: var(--muted); font-weight: 600; font-size: 13px; }
.flow { list-style: none; padding: 0; margin: 0; counter-reset: f; }
.flow li { counter-increment: f; display: grid; grid-template-columns: 30px 1fr; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.flow li:first-child { border-top: 0; }
.flow li::before { content: counter(f); width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.flow li b { display: block; }
.flow li small { color: var(--muted); }
.tour { background: var(--ink); color: #fff; border-radius: var(--r); padding: 16px; margin: 12px 0; }
.tour h3 { color: #fff; margin-bottom: 8px; }
.tour ul { list-style: none; padding: 0; margin: 0 0 10px; }
.tour li { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; font-size: 15px; }
.tour li .ic { color: #9fd8bd; margin-top: 1px; }
.tour button { background: #fff; color: var(--ink); min-height: 42px; padding: 8px 14px; }

/* iOS 사파리 날짜 칸은 자기 폭을 고집해 카드 밖으로 나간다 */
input { min-width: 0; max-width: 100%; }
input[type="date"] { -webkit-appearance: none; appearance: none; display: block; text-align: left; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; margin: 0; }
