:root {
  --bg: #f4f5f7;
  --panel: #fff;
  --soft: #f8f9fb;
  --ink: #171a22;
  --muted: #808692;
  --line: #e3e6ec;
  --dark: #252b3a;
  --dark-2: #353b49;
  --green: #109b7b;
  --green-soft: #e2f7ef;
  --mint: #5be790;
  --blue: #8bc8f0;
  --sky: #85c8ef;
  --coral: #ff765f;
  --gold: #f1c453;
  --red: #c9444e;
  --red-soft: #ffecef;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select { font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin: 0; }
.app { width: min(760px, 100%); min-height: 100vh; margin: 0 auto; padding: max(14px, env(safe-area-inset-top)) 12px max(92px, env(safe-area-inset-bottom)); }
.kicker { display: block; margin-bottom: 3px; color: var(--green); font-size: .68rem; font-weight: 900; letter-spacing: 0; text-transform: uppercase; }
h1 { font-size: 1.55rem; line-height: 1.05; }
h2 { font-size: 1.06rem; line-height: 1.18; }
h3 { font-size: 1rem; }
main, .view, .food-log, .menu-list, .component-list { display: grid; gap: 12px; }
.date-row { display: grid; grid-template-columns: 42px 1fr 42px; align-items: center; gap: 8px; padding: 0; }
.topbar { position: sticky; top: max(8px, env(safe-area-inset-top)); z-index: 8; display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 2px; padding: 4px 2px 8px; border-radius: 0; background: rgba(244,245,247,.92); color: var(--ink); backdrop-filter: blur(14px); }
.topbar .kicker { color: var(--green); }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); font-size: 1.25rem; font-weight: 850; line-height: 1; }
.topbar .icon-button { border-color: var(--line); background: #fff; color: var(--ink); }
input, select { min-height: 42px; width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); padding: 0 12px; font-weight: 760; }
.view { display: none; }
.view.active { display: grid; }
.panel, .energy-card { border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.9); box-shadow: 0 10px 24px rgba(28,38,56,.055); padding: 12px; }
.dashboard-hero { display: grid; gap: 14px; padding: 14px; border-radius: 8px; background: var(--dark); color: #fff; box-shadow: 0 18px 34px rgba(37,43,58,.22); }
.dashboard-hero .kicker { color: var(--mint); }
.dashboard-hero .panel, .dashboard-hero .energy-card { box-shadow: none; }
.dashboard-hero .day-panel, .dashboard-hero .macro-panel { padding: 0; border: 0; background: transparent; }
.dashboard-hero .day-panel .section-head { display: none; }
.dashboard-hero .day-grid { margin-top: 0; }
.dashboard-hero .pill { background: rgba(100,214,173,.16); color: var(--mint); }
.dashboard-hero .pill.warn { background: rgba(255,115,92,.16); color: #ffb0a3; }
.section-head, .log-main, .load-row, .meal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
#food-log { margin-top: 14px; }
.pill, .status-chip { display: inline-flex; align-items: center; min-height: 27px; padding: 0 9px; border-radius: 999px; background: var(--green-soft); color: #0f604f; font-size: .76rem; font-weight: 850; white-space: nowrap; }
.pill.warn, .status-chip.missing, .status-chip.partial { background: var(--red-soft); color: var(--red); }
.status-chip.manual { background: #fff3dd; color: #8b5a12; }
.status-chip.fatsecret { background: #e7f0ff; color: #24558f; }
.status-chip.confirmed { background: var(--green-soft); color: #0f604f; }
.day-grid, .metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.day-card, .metric, .meal-card { border: 1px solid var(--line); border-radius: 8px; background: var(--soft); padding: 10px; }
.meal-card { display: grid; gap: 10px; padding: 11px; }
.meal-items { display: grid; gap: 9px; }
.day-panel { background: rgba(255,255,255,.92); }
.day-card { min-height: 82px; display: grid; grid-template-columns: 34px minmax(0, 1fr); align-items: center; gap: 9px; text-align: left; background: #fff; }
.day-card.active { border-color: rgba(16,155,123,.36); background: var(--green-soft); box-shadow: inset 0 0 0 1px rgba(16,155,123,.08); }
.day-icon { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 8px; background: var(--dark); color: #fff; font-size: .78rem; font-weight: 950; }
.day-card.active .day-icon { background: var(--green); }
.day-copy { min-width: 0; display: grid; gap: 4px; }
.day-top { display: flex; justify-content: space-between; gap: 8px; }
.day-top em { flex: none; font-style: normal; color: var(--green); font-size: .72rem; font-weight: 850; }
.dashboard-hero .day-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dashboard-hero .day-card { min-height: 48px; grid-template-columns: 28px minmax(0, 1fr); place-items: center stretch; gap: 8px; padding: 8px 9px; border-color: rgba(255,255,255,.14); background: rgba(255,255,255,.07); color: rgba(255,255,255,.9); }
.dashboard-hero .day-card.active { border-color: transparent; background: var(--mint); color: #10231c; }
.dashboard-hero .day-icon { width: 28px; height: 28px; display: inline-grid; place-items: center; border-radius: 8px; background: rgba(255,255,255,.12); font-size: 1.04rem; }
.dashboard-hero .day-card.active .day-icon { background: rgba(16,35,28,.13); }
.dashboard-hero .day-copy { gap: 0; justify-items: start; text-align: left; }
.dashboard-hero .day-top { display: grid; justify-items: start; gap: 2px; }
.dashboard-hero .day-top strong { font-size: .82rem; }
.dashboard-hero .day-top em { color: inherit; font-size: .68rem; opacity: .72; }
.dashboard-hero .day-top em:empty { display: none; }
.dashboard-hero .small { display: none; }
.small, .muted, .metric-bottom, .meal-head span, .status-line { color: var(--muted); font-size: .8rem; font-weight: 750; line-height: 1.35; }
.energy-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 14px; border-color: transparent; background: var(--dark); color: #fff; box-shadow: 0 18px 34px rgba(32,41,53,.2); }
.energy-card .kicker { color: var(--mint); }
.energy-card .muted { color: rgba(255,255,255,.65); }
.dashboard-hero .energy-card { padding: 13px; background: linear-gradient(135deg, rgba(255,255,255,.12), rgba(255,255,255,.045)); }
.energy-number { text-align: right; }
.energy-number strong { display: block; font-size: 3rem; line-height: .86; letter-spacing: 0; }
.budget-row { grid-column: 1 / -1; display: flex; justify-content: space-between; color: rgba(255,255,255,.68); font-size: .84rem; font-weight: 800; }
.budget-bar, .bar { overflow: hidden; border-radius: 999px; background: #e6eaf0; }
.budget-bar { grid-column: 1 / -1; height: 10px; }
.bar { height: 7px; margin: 9px 0 8px; }
.budget-bar { background: rgba(255,255,255,.16); }
.budget-bar span, .bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--mint), var(--blue)); }
.metric-top, .metric-bottom { display: flex; justify-content: space-between; gap: 8px; }
.metric-top span { color: var(--muted); font-size: .76rem; font-weight: 800; }
.metric-top strong { white-space: nowrap; font-size: .96rem; }
.dashboard-hero .macro-panel .section-head { display: none; }
.dashboard-hero .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 0; }
.dashboard-hero .metric { display: grid; gap: 6px; min-height: 78px; padding: 10px; border-color: transparent; background: rgba(255,255,255,.08); }
.dashboard-hero .metric-top, .dashboard-hero .metric-bottom { display: grid; gap: 3px; }
.dashboard-hero .metric-top span, .dashboard-hero .metric-bottom { color: rgba(255,255,255,.62); }
.dashboard-hero .metric-top strong { color: #fff; font-size: .88rem; }
.dashboard-hero .bar { height: 5px; margin: 0; background: rgba(255,255,255,.16); }
.dashboard-hero .metric.nutrient-sugar { grid-column: 1 / -1; min-height: auto; display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; }
.dashboard-hero .metric.nutrient-sugar .bar { display: none; }
.dashboard-hero .metric.nutrient-sugar .metric-top, .dashboard-hero .metric.nutrient-sugar .metric-bottom { display: flex; align-items: center; gap: 8px; }

.quick-actions { display: grid; grid-template-columns: minmax(0, 1fr) 82px 70px; gap: 8px; }
.quick-action {
  min-height: 54px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  font-weight: 900;
}
.quick-action span {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 1rem;
  font-weight: 950;
}
.quick-action b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .84rem; }
.quick-action.primary { border-color: transparent; background: #fff; color: var(--ink); box-shadow: 0 10px 22px rgba(28,38,56,.06); }
.quick-action.primary span { background: var(--dark); color: #fff; }

.add-button, .delete-button, .compact-button, .primary-small, .secondary-button, .lookup-button { min-height: 36px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); font-weight: 850; }
.add-button, .compact-button, .primary-small { padding: 0 12px; }
.add-button { border-color: var(--green); color: var(--green); }
.meal-card .add-button { width: 34px; min-height: 34px; padding: 0; border-radius: 999px; background: #f0f2f5; color: var(--ink); font-size: 1.15rem; line-height: 1; }
.delete-button { color: var(--red); font-size: .76rem; }
.log-item, .menu-card, .component-row { border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.diary-panel { background: rgba(255,255,255,.92); }
.meal-card { background: #fff; box-shadow: 0 8px 18px rgba(28,38,56,.035); }
.meal-head { align-items: center; }
.meal-head strong { display: inline-flex; align-items: center; gap: 8px; font-size: .98rem; }
.meal-head strong span { color: var(--ink); font-size: .98rem; font-weight: 900; }
.meal-count { margin: -5px 0 0 36px; color: var(--muted); font-size: .76rem; font-weight: 850; }
.meal-icon {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  font-size: 1rem;
  font-style: normal;
  font-weight: 950;
}
.meal-icon.breakfast { background: var(--coral); }
.meal-icon.lunch { background: var(--sky); }
.meal-icon.snack { background: var(--gold); }
.meal-icon.dinner { background: var(--dark-2); }
.log-item { padding: 10px; background: #f7faf9; }
.log-main { align-items: flex-start; }
.log-copy { min-width: 0; display: grid; gap: 4px; }
.log-title-row { min-width: 0; display: flex; align-items: center; gap: 6px; }
.log-title-row strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .94rem; line-height: 1.25; }
.log-main p { margin-top: 0; overflow: hidden; color: var(--muted); font-size: .78rem; line-height: 1.35; white-space: nowrap; text-overflow: ellipsis; }
.log-item .status-chip { min-height: 22px; padding: 0 7px; font-size: .68rem; }
.log-item .delete-button { flex: none; width: 32px; min-height: 32px; padding: 0; border-radius: 999px; color: var(--muted); font-size: 1rem; line-height: 1; }
.chips, .mini-metrics { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips span, .mini-metrics span, .selected-summary span { display: inline-flex; align-items: center; gap: 4px; min-height: 25px; padding: 0 7px; border-radius: 999px; background: #f0f3f7; color: var(--ink); font-size: .73rem; font-weight: 800; }
.chips b, .mini-metrics b { color: var(--muted); }
.meal-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 10px; }
.meal-tab { min-height: 42px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); font-weight: 850; }
.meal-tab.active { border-color: var(--dark); background: var(--dark); color: #fff; }
.filter-row { display: grid; grid-template-columns: minmax(126px, .9fr) minmax(0, 1.1fr); gap: 8px; margin-top: 9px; }
.load-row { align-items: center; margin: 10px 0; }
.primary-small { border-color: var(--green); background: var(--green); color: #fff; box-shadow: 0 8px 18px rgba(16,155,123,.14); }
.status-line { min-width: 0; text-align: right; }
.status-line.error { color: var(--red); }
.menu-card { display: block; width: 100%; padding: 0; overflow: hidden; text-align: left; box-shadow: 0 8px 18px rgba(28,38,56,.035); }
.menu-card-body { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 11px; }
.menu-card.has-image .menu-card-body { grid-template-columns: 74px minmax(0, 1fr) auto; }
.menu-thumb { display: block; width: 74px; aspect-ratio: 1; overflow: hidden; border-radius: 8px; background: #eef1f5; }
.menu-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.menu-copy { min-width: 0; display: grid; gap: 4px; }
.menu-copy strong { font-size: .97rem; line-height: 1.25; }
.menu-copy small { color: var(--blue); font-size: .72rem; font-weight: 850; }
.menu-copy span { overflow: hidden; color: var(--muted); font-size: .78rem; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.menu-copy .menu-hits { display: flex; flex-wrap: wrap; gap: 5px; overflow: visible; -webkit-line-clamp: initial; }
.menu-hits b { display: inline-flex; align-items: center; min-height: 22px; padding: 0 7px; border-radius: 999px; background: var(--green-soft); color: var(--green); font-size: .7rem; font-weight: 900; }
.menu-side { display: grid; justify-items: end; gap: 5px; white-space: nowrap; }
.menu-side b { color: var(--green); font-size: .82rem; }
.menu-side em { color: var(--muted); font-size: .72rem; font-style: normal; font-weight: 800; }
.menu-side em.missing { color: var(--red); }
.menu-side em.pending { color: var(--green); }
.empty { padding: 18px 8px; text-align: center; color: var(--muted); font-weight: 750; }
.lookup { display: grid; gap: 10px; margin-top: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); }
.lookup-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.lookup-button { display: inline-grid; place-items: center; padding: 0 8px; text-align: center; text-decoration: none; font-size: .78rem; }
.lookup-button:first-child { border-color: var(--green); background: var(--green); color: #fff; }
.lookup-button.disabled, .lookup-button:disabled { background: #eef1f5; color: var(--muted); cursor: not-allowed; }
.assistant-results { display: grid; gap: 9px; }
.assistant-box {
  display: grid;
  gap: 9px;
  padding: 11px;
  border: 1px solid rgba(16,155,123,.24);
  border-radius: 8px;
  background: #f2fbf7;
}
.assistant-box.warn { border-color: rgba(201,68,78,.24); background: var(--red-soft); }
.assistant-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.assistant-head strong { font-size: .92rem; }
.assistant-head span { color: var(--muted); font-size: .72rem; font-weight: 850; }
.assistant-box p { color: var(--muted); font-size: .82rem; font-weight: 760; line-height: 1.4; }
.assistant-warning { padding: 8px 9px; border-radius: 8px; background: rgba(255,255,255,.64); color: var(--red); font-size: .76rem; font-weight: 850; line-height: 1.35; }
.assistant-help {
  display: grid;
  gap: 6px;
  padding: 9px;
  border-radius: 8px;
  background: rgba(255,255,255,.72);
  color: var(--ink);
  font-size: .78rem;
  font-weight: 780;
  line-height: 1.38;
}
.assistant-help b { color: var(--ink); font-weight: 950; }
.assistant-help code {
  padding: 1px 5px;
  border-radius: 6px;
  background: #fff;
  color: var(--green);
  font-family: inherit;
  font-weight: 900;
}
.assistant-questions, .assistant-terms { display: flex; flex-wrap: wrap; gap: 6px; }
.assistant-questions span, .assistant-terms button {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: .76rem;
  font-weight: 850;
}
.assistant-terms button { cursor: pointer; }
.assistant-candidates { display: grid; gap: 7px; }
.assistant-candidates > strong { font-size: .82rem; }
.assistant-food, .assistant-menu {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.assistant-food.exact, .assistant-menu.exact { border-color: rgba(16,155,123,.36); box-shadow: inset 0 0 0 1px rgba(16,155,123,.08); }
.assistant-food > div { min-width: 0; }
.assistant-food strong, .assistant-menu span { font-size: .88rem; font-weight: 900; }
.assistant-food p, .assistant-menu small { display: block; margin-top: 3px; color: var(--muted); font-size: .74rem; font-weight: 780; }
.settings-link {
  width: fit-content;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  margin-top: 12px;
  padding: 0 12px;
  border: 1px solid var(--green);
  border-radius: 8px;
  color: var(--green);
  background: #fff;
  text-decoration: none;
  font-weight: 900;
}
.settings-link.inline { margin-top: 0; background: rgba(255,255,255,.75); }
.backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(12,18,29,.44); }
.sheet, .manual-sheet { position: fixed; left: 50%; bottom: 0; z-index: 21; width: min(760px, 100%); max-height: min(90dvh, 760px); transform: translate(-50%, 105%); display: grid; gap: 10px; padding: 10px 12px max(16px, env(safe-area-inset-bottom)); border-radius: 8px 8px 0 0; background: #fff; box-shadow: 0 16px 38px rgba(28,38,56,.12); overflow: hidden; transition: transform .18s ease; }
.sheet { height: min(96dvh, 860px); max-height: none; grid-template-rows: auto auto auto auto auto auto auto 1fr auto; }
.manual-sheet { grid-template-rows: auto auto 1fr; }
.sheet[aria-hidden="false"], .manual-sheet[aria-hidden="false"] { transform: translate(-50%, 0); }
.handle { width: 42px; height: 5px; margin: 0 auto; border-radius: 999px; background: #cbd2df; }
.sheet-head { display: flex; justify-content: space-between; gap: 10px; }
.sheet-image-frame { overflow: hidden; border-radius: 8px; background: #eef1f5; height: clamp(110px, 22dvh, 190px); }
.sheet.compact-image .sheet-image-frame { height: clamp(78px, 13dvh, 120px); }
.sheet.image-collapsed .sheet-image-frame { display: none; }
.sheet-image-frame img { display: block; width: 100%; height: 100%; object-fit: cover; }
.warning { padding: 9px 10px; border: 1px solid rgba(201,68,78,.26); border-radius: 8px; background: var(--red-soft); color: var(--red); font-size: .78rem; font-weight: 800; line-height: 1.35; }
.selected-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--green-soft); }
.selected-summary strong { color: #0f604f; font-size: .85rem; }
.sheet-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.sheet-tools { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.sheet-tools input { min-height: 38px; }
.sheet-tools .secondary-button { min-height: 38px; padding: 0 12px; white-space: nowrap; }
.component-list { overflow: auto; min-height: 0; padding-right: 2px; overscroll-behavior: contain; }
.component-row { display: grid; grid-template-columns: 28px 1fr; gap: 8px; align-items: start; padding: 10px; }
.component-row input { width: 22px; min-height: 22px; margin: 2px 0 0; accent-color: var(--green); }
.component-title { display: flex; align-items: center; gap: 6px; font-weight: 850; }
.component-title b { display: inline-flex; min-height: 22px; align-items: center; padding: 0 7px; border-radius: 999px; background: var(--green-soft); color: var(--green); font-size: .68rem; }
.save-button { min-height: 48px; border: 0; border-radius: 8px; background: var(--ink); color: #fff; font-weight: 900; font-size: .96rem; }
.manual-form { display: grid; gap: 10px; overflow: auto; }
.manual-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.bottom-nav { position: fixed; left: 50%; bottom: 0; z-index: 9; width: min(760px, 100%); transform: translateX(-50%); display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; padding: 7px 8px max(7px, env(safe-area-inset-bottom)); border-top: 1px solid rgba(220,228,230,.78); background: rgba(255,255,255,.94); backdrop-filter: blur(16px); box-shadow: 0 -12px 26px rgba(28,38,56,.07); }
.nav-item { min-height: 42px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: .78rem; font-weight: 850; }
.nav-item.active { background: var(--dark); color: #fff; }
.sheet-open { overflow: hidden; }
@media (max-width: 430px) {
  .quick-actions { grid-template-columns: minmax(0, 1fr) 72px 64px; }
  .quick-action.primary { grid-column: auto; }
  .quick-action { min-height: 50px; }
  .quick-action { padding: 9px; }
  .quick-action b { font-size: .8rem; }
  .menu-card.has-image .menu-card-body { grid-template-columns: 64px minmax(0, 1fr); }
  .menu-thumb { width: 64px; }
  .menu-side { grid-column: 2; grid-template-columns: repeat(2, auto); justify-content: start; justify-items: start; }
  .lookup-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sheet-actions { grid-template-columns: repeat(2, 1fr); }
  .sheet { height: 96dvh; }
}
