:root {
  --bg: #F6F6F7; --card: #FFFFFF; --ink: #111111; --muted: #6B6B70; --line: #E7E7EA;
  --pos: #2563EB; --pos-soft: #E8EFFE; --neg: #C2410C; --neg-soft: #FDEEE6;
  --ok-soft: #F1F1F3; --radius: 20px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: 'Noto Sans KR', -apple-system, 'Apple SD Gothic Neo', sans-serif; font-size: 15px; line-height: 1.5; letter-spacing: -0.2px; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
a { color: inherit; text-decoration: none; }
svg { display: block; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

#app { max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; }
#app.has-nav { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.screen { padding: calc(12px + env(safe-area-inset-top)) 16px 24px; display: flex; flex-direction: column; gap: 14px; }

.top { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.logo { font-weight: 800; font-size: 22px; letter-spacing: -0.6px; }
.title { font-size: 22px; font-weight: 800; margin: 0; letter-spacing: -0.6px; }
h1 { margin: 0; }
h2 { font-size: 17px; font-weight: 700; margin: 8px 0 -4px; }
.h3 { font-size: 18px; }
.muted { color: var(--muted); }
.small, .tiny { font-size: 13px; }
.tiny { font-size: 12px; color: var(--muted); }
.note { font-size: 12px; color: var(--muted); margin: 4px 2px; }
.pos { color: var(--pos); } .neg { color: var(--neg); } .zero { color: var(--muted); }
.row { display: flex; align-items: center; } .between { justify-content: space-between; }
.gap6 { gap: 6px; } .gap12 { gap: 12px; } .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.card.center { align-items: center; text-align: center; }
.card.empty { color: var(--muted); text-align: center; padding: 24px 16px; }
.card.warn { background: #FFF8E6; }
.card.warn p { margin: 0; font-size: 14px; }
.icon-btn { width: 44px; height: 44px; border-radius: 999px; display: grid; place-items: center; }
.icon-btn:hover { background: #ECECEF; }
.icon-btn.sm { width: 32px; height: 32px; color: var(--muted); }
.label { font-size: 13px; font-weight: 700; color: var(--muted); }
.link { color: var(--pos); font-weight: 600; font-size: 14px; text-align: left; }

.btn-primary { background: var(--ink); color: #fff; border-radius: 16px; min-height: 52px; font-weight: 700; display: flex; gap: 6px; align-items: center; justify-content: center; padding: 0 14px; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary.sticky { position: sticky; bottom: calc(92px + env(safe-area-inset-bottom)); box-shadow: 0 8px 24px rgba(0,0,0,0.15); z-index: 2; }
.btn-ghost { background: var(--card); border: 1px solid var(--line); border-radius: 16px; min-height: 52px; font-weight: 600; display: flex; gap: 6px; align-items: center; justify-content: center; padding: 0 12px; }
.btn-ghost.sm { min-height: 36px; font-size: 13px; border-radius: 12px; }
.btn-ghost.wide, .btn-danger.wide { width: 100%; }
.btn-danger { color: #B42318; border: 1px solid #F3C7C2; border-radius: 16px; min-height: 48px; font-weight: 600; margin-top: 4px; }
.filebtn { position: relative; overflow: hidden; cursor: pointer; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* 주간 띠 */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.day { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 0; border-radius: 14px; font-size: 12px; color: var(--muted); }
.day b { width: 34px; height: 34px; border-radius: 999px; display: grid; place-items: center; font-size: 14px; color: var(--ink); border: 2px dashed #D4D4D8; }
.day b.pos { border: 2px solid var(--pos); } .day b.neg { border: 2px solid var(--neg); } .day b.zero { border: 2px solid #A1A1A6; }
.day.on { background: var(--card); color: var(--ink); font-weight: 700; }

/* 홈 */
.hero { flex-direction: row; align-items: center; justify-content: space-between; padding: 18px 12px 18px 18px; }
.hero-l { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.big { font-size: 40px; font-weight: 800; letter-spacing: -1.4px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.badge { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--ok-soft); color: #44444A; }
.badge.good { background: var(--pos-soft); color: var(--pos); }
.badge.sick { background: var(--neg-soft); color: var(--neg); }
.mini { gap: 2px; }
.mini b { font-size: 20px; font-weight: 800; letter-spacing: -0.5px; }
.bar { display: block; height: 6px; border-radius: 99px; background: #EFEFF2; overflow: hidden; margin-top: 6px; }
.fill { display: block; height: 100%; border-radius: 99px; }
.fill.pos { background: var(--pos); } .fill.neg { background: var(--neg); } .fill.zero { background: #C4C4C8; }
.quick { background: var(--card); border-radius: 16px; min-height: 76px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 8px 4px; text-align: center; }
.quick:active, .fcard:active, .chip-food:active { transform: scale(0.97); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip-food { flex: none; display: flex; align-items: center; gap: 6px; background: var(--card); border-radius: 999px; padding: 4px 14px 4px 4px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.list { background: var(--card); border-radius: var(--radius); padding: 4px 8px 4px 12px; }
.item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #F0F0F2; }
.item:last-child { border-bottom: 0; }
.item b { font-weight: 700; font-size: 15px; }
.item .grow b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb { width: 40px; height: 40px; flex: none; display: grid; place-items: center; }
.thumb.habit { background: #F2F2F4; border-radius: 12px; }

/* 음식 사전 */
.search { display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 16px; padding: 0 14px; min-height: 50px; color: var(--muted); }
.search input { flex: 1; border: 0; outline: 0; font: inherit; background: none; color: var(--ink); min-width: 0; font-size: 16px; }
.cats { display: flex; flex-wrap: wrap; gap: 6px; }
.cats::-webkit-scrollbar { display: none; }
.cat { flex: none; padding: 8px 14px; border-radius: 999px; background: var(--card); font-size: 14px; font-weight: 600; color: #44444A; }
.cat.on { background: var(--ink); color: #fff; }
.foodgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fcard { background: var(--card); border-radius: 18px; padding: 10px 6px 12px; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.fname { font-size: 13px; font-weight: 600; text-align: center; line-height: 1.3; min-height: 34px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: keep-all; }
.fcard b { font-size: 14px; font-weight: 800; }

/* 음식 상세 */
.fname-big { font-size: 22px; font-weight: 800; letter-spacing: -0.6px; }
.summary { margin: 2px 0 0; color: #44444A; font-size: 14px; word-break: keep-all; }
.seg { background: #F2F2F4; border-radius: 14px; min-height: 48px; font-weight: 600; font-size: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 6px 4px; line-height: 1.3; }
.seg small { font-size: 12px; font-weight: 700; opacity: 0.75; }
.seg.on { background: var(--ink); color: #fff; }
.toggle { flex-direction: row; align-items: center; justify-content: space-between; text-align: left; }
.parts { gap: 12px; }
.part .bar { margin-top: 4px; }
.src { border-top: 1px solid #F0F0F2; padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }

/* 온보딩 */
.ob-head { display: flex; flex-direction: column; gap: 6px; padding-top: 8px; }
.ob-head h1 { font-size: 28px; font-weight: 800; line-height: 1.25; letter-spacing: -0.8px; }
.ob-head p { margin: 0; }
.ob-char { align-items: center; padding: 18px 12px 14px; }
.ob-char .row { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); }
.ob-char .seg { min-height: 38px; font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.look { background: var(--card); border-radius: 16px; padding: 8px 0; display: grid; place-items: center; border: 2px solid transparent; }
.look.on { border-color: var(--ink); }
.field .seg { background: var(--card); }
.field .seg.on { background: var(--ink); }
.stepper { background: var(--card); border-radius: 16px; display: flex; align-items: center; justify-content: space-between; padding: 6px; text-align: center; }
.stepper button { width: 44px; height: 44px; border-radius: 12px; background: #F2F2F4; font-size: 20px; font-weight: 700; }
.stepper b { font-size: 17px; }

/* 리포트 */
.chart { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 10px; }
.col { display: flex; flex-direction: column; align-items: center; font-size: 12px; color: var(--muted); }
.col .up { height: 70px; display: flex; align-items: flex-end; } .col .dn { height: 50px; }
.col i { display: block; width: 18px; border-radius: 6px; }
.col i.pos { background: var(--pos); } .col i.neg { background: var(--neg); }
.col .axis { width: 100%; height: 1px; background: var(--line); }
.col span { margin-top: 4px; }

/* 근거 */
.rules { margin: 0; padding-left: 18px; font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
.card p { margin: 0; }
.srcrow { display: flex; flex-direction: column; text-align: left; padding: 10px 0; border-bottom: 1px solid #F0F0F2; width: 100%; }
.srcrow:last-child { border-bottom: 0; }

/* 하단 탭 */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,0.94); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, 1fr); padding: 6px max(8px, calc(50% - 232px)) calc(6px + env(safe-area-inset-bottom)); z-index: 5; }
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 600; color: #9A9AA0; min-height: 52px; justify-content: center; }
.tab.on { color: var(--ink); }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(100px + env(safe-area-inset-bottom)); background: rgba(17,17,17,0.92); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 14px; font-weight: 600; z-index: 10; max-width: calc(100% - 32px); text-align: center; animation: pop 0.2s ease-out; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
:focus-visible { outline: 3px solid var(--pos); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.card.row { flex-direction: row; align-items: center; }
.hero .big { font-size: 34px; white-space: nowrap; }
.toast { width: max-content; }
.habitcard .hic { width: 76px; height: 76px; display: grid; place-items: center; background: #F2F2F4; border-radius: 20px; }
