:root {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--page-bg);
  font-synthesis: none;
  color-scheme: light dark;
  --accent: #a85e0a;
  --accent-strong: #884900;
  --surface: #ffffff;
  --grouped: #f3f3f5;
  --ink: #191714;
  --muted: #625f5a;
  --separator: #dedddd;
  --page-bg: #ececec;
  --header-bg: #ffffff;
  --tab-bg: #f9f9f9;
  --selected-surface: #ffffff;
  --progress-track: #dddddf;
  --control-border: #8b8781;
  --placeholder: #6b6761;
  --icon-surface: #f4e7d6;
  --info-surface: #edf4fb;
  --info-ink: #263a4c;
  --chart-axis: #777777;
  --chart-baseline: #a9a9a9;
  --scanner-surface: #121212;
  --toast-surface: #242321;
  --backdrop: rgba(0,0,0,.38);
  --protein: #5551c8;
  --carbs: #087b76;
  --fat: #c85d13;
  --danger: #b42318;
  --tab-inactive: #696663;
  --accent-ink: #ffffff;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --z-header: 3;
  --z-navigation: 4;
  --z-toast: 20;
  --tab-height: 70px;
  --header-height: calc(76px + env(safe-area-inset-top));
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--page-bg); }
body { margin: 0; min-height: 100vh; min-height: 100dvh; }
button, input, select, textarea { font: inherit; }
input, select, textarea { font-size: 1rem; }
button, select { cursor: pointer; }
button { color: inherit; }
input::placeholder, textarea::placeholder { color: var(--placeholder); opacity: 1; }
select option { background: var(--surface); color: var(--ink); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; }
button:active { filter: brightness(.94); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.app-shell {
  width: min(430px, 100vw);
  height: min(900px, 100dvh);
  min-height: 620px;
  margin: max(0px, calc((100dvh - 900px) / 2)) auto 0;
  background: var(--surface);
  position: relative;
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(0,0,0,.14);
}

.app-header {
  height: var(--header-height);
  padding: env(safe-area-inset-top) var(--space-4) var(--space-2);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  background: var(--header-bg);
  border-bottom: 1px solid transparent;
  position: relative;
  z-index: var(--z-header);
}
.date-label { margin: 0 0 3px; color: var(--muted); font-size: .78rem; font-weight: 600; }
.app-header h1 { margin: 0; font-size: 2rem; line-height: 1; letter-spacing: -.03em; }
.profile-picker { display: flex; min-height: 44px; align-items: center; gap: var(--space-2); border: 0; border-radius: 999px; background: var(--grouped); padding: var(--space-1) var(--space-2) var(--space-1) var(--space-1); }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: white; font-weight: 750; }
.profile-picker select { max-width: 102px; border: 0; background: transparent; color: var(--ink); font-size: 1rem; font-weight: 600; outline: 0; }

main { position: absolute; inset: var(--header-height) 0 calc(var(--tab-height) + env(safe-area-inset-bottom)); }
.view { display: none; height: 100%; position: relative; }
.view.active { display: block; }
.today-scroll, .content-scroll { height: 100%; overflow-y: auto; overscroll-behavior-y: contain; scrollbar-width: none; padding: var(--space-2) var(--space-4) 96px; }
.content-scroll { padding-top: var(--space-4); }
.today-scroll::-webkit-scrollbar, .content-scroll::-webkit-scrollbar { display: none; }

.calorie-summary { display: flex; align-items: center; gap: 16px; padding: 16px; background: var(--grouped); border-radius: 14px; }
.calorie-ring { width: 108px; height: 108px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: conic-gradient(var(--accent) var(--progress, 0%), var(--progress-track) 0); position: relative; }
.calorie-ring::before { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: var(--grouped); }
.calorie-ring > div { position: relative; display: grid; text-align: center; }
.calorie-ring strong { font-family: ui-rounded, -apple-system, sans-serif; font-size: 1.6rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.calorie-ring span { color: var(--muted); font-size: .72rem; }
.calorie-detail { min-width: 0; flex: 1; }
.calorie-detail h2 { margin: 0 0 var(--space-4); font-family: ui-rounded, -apple-system, sans-serif; font-size: 1rem; font-variant-numeric: tabular-nums; }
.calorie-detail dl { display: grid; gap: var(--space-2); margin: 0; }
.calorie-detail dl div { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: .78rem; }
.calorie-detail dd { margin: 0; font-variant-numeric: tabular-nums; }

.activity-row { margin: var(--space-3) 0 0; padding: var(--space-3) var(--space-1); display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); border-bottom: 1px solid var(--separator); }
.activity-row h2 { margin: 0 0 var(--space-1); font-size: 1rem; }
.activity-row p { margin: 0; max-width: 32ch; color: var(--muted); font-size: .875rem; line-height: 1.4; }
.activity-row label { display: flex; align-items: center; background: var(--grouped); border-radius: 9px; padding: 0 8px; color: var(--muted); font-size: .72rem; }
.activity-row input { width: 58px; min-height: 42px; padding: 0 4px; border: 0; outline: 0; background: transparent; text-align: right; font-weight: 700; color: var(--ink); }

.section-block { margin-top: var(--space-8); }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); }
.section-heading h2, .content-scroll > section > h2, .settings-screen section > h2 { margin: 0 0 var(--space-3); font-size: 1.25rem; letter-spacing: -.015em; }
.section-heading > span { color: var(--muted); font-size: .75rem; text-align: right; }
.macro-row { margin-bottom: 16px; }
.macro-row > div { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: var(--space-2); font-size: .875rem; }
.macro-row strong { font-weight: 600; }
.macro-row span, .macro-row small { color: var(--muted); font-variant-numeric: tabular-nums; }
.macro-row small { display: block; margin-top: var(--space-1); text-align: right; font-size: .75rem; }
progress { display: block; width: 100%; height: 7px; border: 0; appearance: none; }
progress::-webkit-progress-bar { background: var(--progress-track); border-radius: 9px; }
progress::-webkit-progress-value { border-radius: 9px; background: var(--bar, var(--protein)); }
progress::-moz-progress-bar { border-radius: 9px; background: var(--bar, var(--protein)); }
.macro-row.carbs { --bar: var(--carbs); }
.macro-row.fat { --bar: var(--fat); }

.meal-list { border-top: 1px solid var(--separator); }
.empty-state { padding: var(--space-8) var(--space-6); text-align: center; color: var(--muted); }
.empty-state strong { display: block; margin-bottom: var(--space-1); color: var(--ink); font-size: 1rem; }
.empty-state p { margin: 0 0 var(--space-4); font-size: .875rem; line-height: 1.4; }
.inline-add { min-height: 44px; padding: 0 var(--space-4); border: 0; border-radius: 10px; background: var(--grouped); color: var(--accent-strong); font-weight: 700; }
.meal-group h3 { display: flex; justify-content: space-between; margin: var(--space-4) 0 var(--space-1); font-size: 1rem; }
.meal-group h3 span { color: var(--muted); font-size: .75rem; font-weight: 500; }
.food-row { width: 100%; min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-2) var(--space-1); border: 0; border-bottom: 1px solid var(--separator); background: transparent; text-align: left; }
.food-row > span:first-child { display: grid; gap: var(--space-1); }
.food-row strong { font-size: 1rem; }
.food-row small { color: var(--muted); font-size: .75rem; }
.food-row .row-calories { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.floating-action { position: absolute; right: var(--space-4); bottom: var(--space-4); min-height: 48px; padding: 0 var(--space-4); border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 8px rgba(74,40,0,.25); font-weight: 700; }
.floating-action span { font-size: 1.25rem; vertical-align: -1px; }

.log-options section + section, .settings-screen section + section { margin-top: var(--space-8); }
.chat-log-section { padding: var(--space-4); border-radius: 14px; background: var(--grouped); }
.chat-log-section h2 { margin-bottom: var(--space-2) !important; }
.chat-composer { display: grid; grid-template-columns: minmax(0, 1fr) 48px; align-items: end; gap: var(--space-2); padding: var(--space-2); border: 1px solid var(--control-border); border-radius: 12px; background: var(--surface); }
.chat-composer textarea { min-width: 0; min-height: 52px; max-height: 132px; padding: var(--space-2); resize: vertical; border: 0; outline: 0; background: transparent; color: var(--ink); line-height: 1.4; }
.chat-composer button { width: 48px; height: 48px; border: 0; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 1.4rem; font-weight: 750; }
.chat-composer button:disabled { opacity: .55; cursor: wait; }
.chat-log-status { min-height: 38px; margin: var(--space-2) var(--space-1) 0; color: var(--muted); font-size: .875rem; line-height: 1.45; }
.chat-log-status.error { color: var(--danger); }
.chat-manual-fallback { display: block; width: auto; margin: 0 var(--space-1); padding: 0; text-align: left; }
.feature-action, .action-list button, .recent-list button { width: 100%; min-height: 60px; border: 0; background: var(--surface); display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-1); text-align: left; }
.feature-action { min-height: 76px; padding: 12px; border-radius: 12px; background: var(--grouped); }
.action-icon { width: 38px; height: 38px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 10px; background: var(--icon-surface); color: var(--accent-strong); font-size: 1.3rem; font-weight: 500; }
.feature-action > span:nth-child(2), .action-list button > span:nth-child(2), .recent-list button > span:first-child { min-width: 0; flex: 1; display: grid; gap: var(--space-1); }
.feature-action strong, .action-list strong, .recent-list strong { font-size: 1rem; font-weight: 600; }
.feature-action small, .action-list small, .recent-list small { color: var(--muted); font-size: .875rem; line-height: 1.4; }
.privacy-note, .supporting-copy { max-width: 65ch; color: var(--muted); font-size: .875rem; line-height: 1.45; }
.privacy-note { margin: 8px 12px 0; }
.action-list, .settings-group { border-top: 1px solid var(--separator); border-bottom: 1px solid var(--separator); }
.action-list button + button, .settings-group > * + * { border-top: 1px solid var(--separator); }
.recent-list .empty-state { padding-top: var(--space-4); }
.recent-list button { border-bottom: 1px solid var(--separator); }

.period-control { display: grid; grid-template-columns: repeat(3,1fr); padding: 2px; border-radius: 9px; background: var(--grouped); }
.period-control button { min-height: 34px; border: 0; border-radius: 7px; background: transparent; font-size: .78rem; font-weight: 650; }
.period-control button.selected { background: var(--selected-surface); box-shadow: 0 1px 3px rgba(0,0,0,.16); }
.trend-overview { display: grid; grid-template-columns: repeat(3,1fr); margin-top: 19px; padding: 15px 2px; border-radius: 12px; background: var(--grouped); }
.trend-overview > div { display: grid; text-align: center; padding: 0 4px; border-right: 1px solid var(--separator); }
.trend-overview > div:last-child { border: 0; }
.trend-overview strong { font-family: ui-rounded, -apple-system, sans-serif; font-size: 1.125rem; font-variant-numeric: tabular-nums; }
.trend-overview span { margin-top: var(--space-1); color: var(--muted); font-size: .75rem; line-height: 1.3; }
.chart { height: 210px; display: flex; align-items: flex-end; gap: 4px; padding-top: 14px; border-bottom: 1px solid var(--chart-baseline); position: relative; }
.chart::before { content: "Goal"; position: absolute; left: 0; right: 0; bottom: 60%; border-top: 1px dashed var(--chart-axis); color: var(--muted); font-size: .75rem; }
.chart-bar { flex: 1 1 0; min-width: 3px; max-width: 18px; height: var(--height); background: var(--accent); border-radius: 3px 3px 0 0; opacity: .88; position: relative; }
.chart.empty { display: grid; place-items: center; border: 0; color: var(--muted); font-size: .8rem; text-align: center; }
.chart.empty::before { display: none; }

.text-button { min-height: 44px; border: 0; background: transparent; color: var(--accent-strong); font-weight: 700; font-size: .82rem; }
.settings-group > button, .settings-group > label, .settings-group > a { width: 100%; min-height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 8px 2px; border: 0; background: transparent; color: var(--ink); text-align: left; text-decoration: none; font-size: .86rem; }
.profile-setting { gap: 10px; }
.profile-setting .avatar { width: 32px; height: 32px; font-size: .78rem; }
.profile-setting strong { flex: 1; }
.profile-setting small { color: var(--muted); }
.goal-grid { display: grid; gap: var(--space-2); }
.goal-grid label, .sheet-body > label, .advanced-settings label { min-height: 52px; display: grid; grid-template-columns: 1fr minmax(90px, 120px) auto; align-items: center; gap: var(--space-2); padding: 0 var(--space-3); background: var(--grouped); border-radius: 9px; font-size: .875rem; font-weight: 600; }
.goal-grid input, .sheet-body input, .sheet-body select, .advanced-settings input { width: 100%; min-height: 44px; border: 0; outline: 0; background: transparent; text-align: right; color: var(--ink); }
.goal-grid label > span { color: var(--muted); font-size: .72rem; }
.goal-grid.two-column { grid-template-columns: 1fr 1fr; }
.goal-grid.two-column label { grid-template-columns: 1fr; padding: 8px 10px; }
.goal-grid.two-column input { text-align: left; min-height: 44px; }
.goal-grid.two-column .primary-button { grid-column: 1/-1; }
.primary-button, .secondary-button { width: 100%; min-height: 48px; border-radius: 10px; font-weight: 700; }
.primary-button { border: 0; background: var(--accent); color: var(--accent-ink); }
.primary-button:disabled { opacity: .55; cursor: wait; }
.secondary-button { border: 1px solid var(--control-border); background: var(--surface); color: var(--ink); }
.watch-note { margin-top: 14px; padding: 13px; border-radius: 10px; background: var(--info-surface); color: var(--info-ink); }
.watch-note strong { font-size: .82rem; }
.watch-note p { margin: 4px 0 0; font-size: .74rem; line-height: 1.4; }
.file-button { cursor: pointer; }
.advanced-settings { margin-top: 28px; padding: 12px 0; border-top: 1px solid var(--separator); border-bottom: 1px solid var(--separator); }
.advanced-settings summary { min-height: 44px; display: flex; align-items: center; font-weight: 700; font-size: .9rem; cursor: pointer; }
.advanced-settings form { display: grid; gap: 10px; padding-top: 8px; }
.advanced-settings label { grid-template-columns: 1fr; padding: 8px 10px; }
.advanced-settings input { text-align: left; }
.danger-button { width: 100%; min-height: 46px; margin-top: 24px; border: 0; background: transparent; color: var(--danger); font-weight: 700; }

.tabbar { position: absolute; z-index: var(--z-navigation); left: 0; right: 0; bottom: 0; height: calc(var(--tab-height) + env(safe-area-inset-bottom)); padding: var(--space-1) var(--space-2) max(var(--space-2), env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(4,1fr); background: var(--tab-bg); border-top: 1px solid var(--separator); }
.tabbar button { min-height: 48px; border: 0; background: transparent; color: var(--tab-inactive); display: grid; place-items: center; align-content: center; gap: 2px; font-size: .7rem; }
.tabbar button span { font-size: 1.25rem; line-height: 1; }
.tabbar button.active { color: var(--accent-strong); font-weight: 750; }

dialog { width: min(430px, 100vw); max-height: min(840px, 94dvh); margin: auto auto 0; padding: 0; border: 0; border-radius: 16px 16px 0 0; background: var(--surface); color: var(--ink); box-shadow: 0 -4px 12px rgba(0,0,0,.16); }
dialog::backdrop { background: var(--backdrop); }
.compact-dialog { margin: auto; border-radius: 14px; width: min(390px, calc(100vw - 28px)); }
.sheet-header { min-height: 55px; display: grid; grid-template-columns: 70px 1fr 70px; align-items: center; border-bottom: 1px solid var(--separator); padding: 0 9px; }
.sheet-header h2 { margin: 0; text-align: center; font-size: 1.125rem; }
.sheet-header button { min-height: 44px; border: 0; background: transparent; color: var(--accent-strong); text-align: left; }
.sheet-body { display: grid; gap: var(--space-3); overflow-y: auto; max-height: calc(92dvh - 55px); padding: var(--space-4) var(--space-4) max(var(--space-6), env(safe-area-inset-bottom)); }
.sheet-body > label { grid-template-columns: 1fr; padding: var(--space-2) var(--space-3); }
.sheet-body > label input, .sheet-body > label select { min-height: 44px; text-align: left; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.form-row label, .macro-inputs label { display: grid; gap: var(--space-1); padding: var(--space-2) var(--space-3); border-radius: 9px; background: var(--grouped); font-size: .875rem; font-weight: 600; }
.form-row input, .form-row select, .macro-inputs input { min-width: 0; width: 100%; min-height: 44px; padding: 0; border: 0; outline: 0; background: transparent; color: var(--ink); }
.macro-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.macro-inputs label { position: relative; }
.macro-inputs input { padding-right: 44px; font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.macro-inputs label span { position: absolute; right: 10px; bottom: 16px; color: var(--muted); font-size: .7rem; }
.form-help { margin: 0 var(--space-1); max-width: 65ch; color: var(--muted); font-size: .875rem; line-height: 1.45; }
.photo-preview-wrap { display: grid; grid-template-columns: 76px 1fr; align-items: center; gap: 12px; padding-bottom: 5px; }
.photo-preview-wrap img { width: 76px; height: 76px; object-fit: cover; border-radius: 10px; }
.photo-preview-wrap p { margin: 0; color: var(--muted); font-size: .875rem; line-height: 1.4; }
.entry-review-note { margin: 0; padding: var(--space-3); border-radius: 10px; background: var(--info-surface); color: var(--info-ink); font-size: .875rem; line-height: 1.45; }
.lookup-form { display: flex; gap: 8px; padding: 14px 14px 10px; }
.lookup-form input { min-width: 0; flex: 1; min-height: 46px; padding: 0 12px; border: 0; border-radius: 9px; background: var(--grouped); outline: 0; }
.lookup-form .primary-button { width: auto; padding: 0 16px; }
.lookup-results { max-height: 55dvh; overflow-y: auto; padding: 0 14px 18px; }
.lookup-results button { width: 100%; min-height: 58px; display: grid; gap: 3px; padding: 8px 2px; border: 0; border-bottom: 1px solid var(--separator); background: transparent; text-align: left; }
.lookup-results small { color: var(--muted); }
.scanner-body { display: grid; gap: 14px; overflow-y: auto; padding: 16px 16px max(22px, env(safe-area-inset-bottom)); }
.scanner-preview { position: relative; overflow: hidden; width: 100%; aspect-ratio: 4 / 3; max-height: 43dvh; border-radius: 12px; background: var(--scanner-surface); }
.scanner-preview video { width: 100%; height: 100%; object-fit: cover; }
.scanner-guide { position: absolute; inset: 50% 9% auto; height: 38%; transform: translateY(-50%); border: 2px solid rgba(255,255,255,.92); border-radius: 10px; box-shadow: 0 0 0 999px rgba(0,0,0,.3); }
.scanner-guide span { position: absolute; left: 8%; right: 8%; top: 50%; height: 2px; background: var(--accent); box-shadow: 0 0 5px rgba(255,255,255,.65); }
.scanner-status { min-height: 20px; margin: 0; color: var(--muted); text-align: center; font-size: .82rem; line-height: 1.4; }
.scanner-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .75rem; }
.scanner-divider::before, .scanner-divider::after { content: ""; height: 1px; flex: 1; background: var(--separator); }
.barcode-manual-form { display: flex; gap: 8px; }
.barcode-manual-form input { min-width: 0; flex: 1; min-height: 48px; padding: 0 12px; border: 0; border-radius: 9px; outline: 0; background: var(--grouped); color: var(--ink); font-size: 1rem; }
.barcode-manual-form .primary-button { width: auto; padding: 0 16px; }
.scanner-help { margin: 0 var(--space-1); color: var(--muted); text-align: center; font-size: .875rem; line-height: 1.4; }
.message-dialog { width: min(350px, calc(100vw - 36px)); margin: auto; border-radius: 14px; text-align: center; }
.message-dialog > div { padding: 22px; }
.message-dialog h2 { margin: 0 0 8px; font-size: 1.15rem; }
.message-dialog p { margin: 0 0 18px; color: var(--muted); line-height: 1.45; font-size: .84rem; }
.toast { position: fixed; z-index: var(--z-toast); left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); max-width: calc(100vw - 32px); padding: var(--space-3) var(--space-4); border-radius: 9px; background: var(--toast-surface); color: white; font-size: .875rem; opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.library-control { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-1); padding: var(--space-1); border-radius: 10px; background: var(--grouped); }
.library-control button { min-height: 44px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: .875rem; font-weight: 600; }
.library-control button.selected { background: var(--selected-surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.saved-meal-list, .recent-list { margin-top: var(--space-2); border-top: 1px solid var(--separator); }
.saved-meal-row { display: flex; align-items: stretch; border-bottom: 1px solid var(--separator); }
.saved-meal-details { min-width: 0; min-height: 60px; flex: 1; display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-1); border: 0; background: transparent; text-align: left; }
.saved-meal-details > span:first-child { min-width: 0; flex: 1; display: grid; gap: var(--space-1); }
.saved-meal-details strong { overflow-wrap: anywhere; font-size: 1rem; font-weight: 600; }
.saved-meal-details small { color: var(--muted); font-size: .875rem; line-height: 1.4; font-variant-numeric: tabular-nums; }
.saved-meal-add { width: 48px; min-height: 48px; align-self: center; border: 0; border-radius: 10px; background: var(--grouped); color: var(--accent-strong); font-size: 1.25rem; font-weight: 600; }

.goal-summary { display: grid; gap: var(--space-2); margin-bottom: var(--space-3); padding: var(--space-4); border-radius: 12px; background: var(--grouped); }
.goal-summary > div { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); }
.goal-summary span, .goal-summary small { color: var(--muted); font-size: .875rem; line-height: 1.4; }
.goal-summary strong, .goal-summary p { font-family: ui-rounded, -apple-system, sans-serif; font-variant-numeric: tabular-nums; }
.goal-summary strong { font-size: 1.125rem; }
.goal-summary p { margin: 0; font-size: .875rem; }
.manual-goals { margin-top: var(--space-3); border-top: 1px solid var(--separator); border-bottom: 1px solid var(--separator); }
.manual-goals summary { min-height: 48px; display: flex; align-items: center; color: var(--accent-strong); font-size: .875rem; font-weight: 600; cursor: pointer; }
.manual-goals .goal-grid { padding: var(--space-2) 0 var(--space-3); }

.meal-builder-dialog { max-height: calc(100dvh - env(safe-area-inset-top)); }
.meal-builder-body { align-content: start; }
.meal-total { display: grid; gap: var(--space-1); padding: var(--space-4); border-radius: 12px; background: var(--grouped); }
.meal-total > div { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); }
.meal-total span { color: var(--muted); font-size: .875rem; }
.meal-total strong { font-family: ui-rounded, -apple-system, sans-serif; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.meal-total p { margin: 0; color: var(--muted); font-family: ui-rounded, -apple-system, sans-serif; font-size: .875rem; font-variant-numeric: tabular-nums; }
.builder-heading { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-2); }
.builder-heading h3 { margin: 0; font-size: 1rem; }
.builder-heading span { color: var(--muted); font-size: .75rem; }
.meal-builder-items { border-top: 1px solid var(--separator); }
.meal-builder-items > button { width: 100%; min-height: 60px; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) var(--space-1); border: 0; border-bottom: 1px solid var(--separator); background: transparent; text-align: left; }
.meal-builder-items > button > span:first-child { min-width: 0; display: grid; gap: var(--space-1); }
.meal-builder-items strong { overflow-wrap: anywhere; font-size: 1rem; font-weight: 600; }
.meal-builder-items small { color: var(--muted); font-size: .875rem; line-height: 1.4; font-variant-numeric: tabular-nums; }
.row-calories { flex: 0 0 auto; color: var(--muted); font-family: ui-rounded, -apple-system, sans-serif; font-size: .875rem; font-variant-numeric: tabular-nums; }
.ingredient-actions { border-top: 1px solid var(--separator); border-bottom: 1px solid var(--separator); }
.ingredient-actions button { width: 100%; min-height: 52px; display: flex; align-items: center; justify-content: space-between; padding: var(--space-2) var(--space-1); border: 0; background: transparent; text-align: left; }
.ingredient-actions button + button { border-top: 1px solid var(--separator); }
.ingredient-actions strong { font-size: 1rem; font-weight: 600; }
.ingredient-actions span { color: var(--accent-strong); font-size: 1.125rem; }
.builder-footer { position: sticky; bottom: calc(-1 * max(var(--space-6), env(safe-area-inset-bottom))); display: grid; grid-template-columns: 1fr 1.25fr; gap: var(--space-2); margin: var(--space-2) calc(-1 * var(--space-4)) 0; padding: var(--space-3) var(--space-4) max(var(--space-6), env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--separator); }

.goal-wizard-dialog { max-height: calc(100dvh - env(safe-area-inset-top)); }
.goal-wizard-body { max-height: calc(100dvh - var(--header-height)); overflow-y: auto; }
.wizard-progress { display: grid; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--separator); }
.wizard-progress span { color: var(--muted); font-size: .75rem; font-weight: 600; }
.wizard-progress progress { height: 5px; }
.wizard-step { display: grid; gap: var(--space-3); padding: var(--space-6) var(--space-4) var(--space-8); }
.wizard-step h3 { margin: 0; font-size: 1.25rem; line-height: 1.2; }
.wizard-step > p { margin: 0 0 var(--space-2); max-width: 65ch; color: var(--muted); font-size: 1rem; line-height: 1.5; }
.wizard-step > label { min-height: 60px; display: grid; grid-template-columns: 1fr; gap: var(--space-1); padding: var(--space-2) var(--space-3); border-radius: 9px; background: var(--grouped); font-size: .875rem; font-weight: 600; }
.wizard-step > label input, .wizard-step > label select { min-height: 44px; border: 0; outline: 0; background: transparent; color: var(--ink); text-align: left; }
.wizard-step .form-row label { position: relative; }
.wizard-step .form-row label span { position: absolute; right: var(--space-3); bottom: 17px; color: var(--muted); font-size: .75rem; }
.wizard-step .form-row label input { padding-right: var(--space-6); font-size: 1rem; }
.calculation-note { padding: var(--space-3); border-radius: 10px; background: var(--info-surface); color: var(--info-ink); }
.calculation-note strong { font-size: .875rem; }
.calculation-note p { margin: var(--space-1) 0 0; font-size: .875rem; line-height: 1.45; }
.wizard-footer { position: sticky; bottom: 0; display: grid; grid-template-columns: 1fr 1.5fr; gap: var(--space-2); padding: var(--space-3) var(--space-4) max(var(--space-3), env(safe-area-inset-bottom)); border-top: 1px solid var(--separator); background: var(--surface); }
.wizard-footer .primary-button:only-child { grid-column: 1 / -1; }

@media (max-width: 430px) {
  html { background: white; }
  .app-shell { width: 100vw; height: 100dvh; min-height: 0; margin: 0; box-shadow: none; }
  .app-header h1 { font-size: 1.85rem; }
  .profile-picker select { max-width: 88px; }
  .today-scroll, .content-scroll { padding-inline: var(--space-3); }
  dialog { width: 100vw; max-width: none; max-height: calc(100dvh - env(safe-area-inset-top)); }
  .sheet-body { padding-inline: var(--space-3); }
  .builder-footer { margin-inline: calc(-1 * var(--space-3)); padding-inline: var(--space-3); }
}
@media (max-width: 360px) {
  .calorie-summary { gap: var(--space-3); padding: var(--space-3); }
  .calorie-ring { width: 100px; height: 100px; }
  .goal-grid.two-column, .macro-inputs, .form-row { grid-template-columns: 1fr; }
  .goal-grid label { grid-template-columns: 1fr auto; padding-block: var(--space-2); }
  .goal-grid label input { grid-column: 1 / -1; grid-row: 2; text-align: left; }
  .goal-grid label > span { grid-column: 2; grid-row: 1; }
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page-bg: #070809;
    --surface: #111417;
    --grouped: #23282e;
    --selected-surface: #343b43;
    --ink: #f8fafb;
    --muted: #c4cbd2;
    --separator: #66717c;
    --header-bg: #111417;
    --tab-bg: #111417;
    --tab-inactive: #c4cbd2;
    --progress-track: #454d56;
    --control-border: #89939e;
    --placeholder: #aeb7c0;
    --accent: #f2b15f;
    --accent-strong: #ffcb87;
    --accent-ink: #211306;
    --danger: #ff938a;
    --protein: #aaa7ff;
    --carbs: #68e0d8;
    --fat: #ffb184;
    --icon-surface: #3b2b1b;
    --info-surface: #172b36;
    --info-ink: #e1f4ff;
    --chart-axis: #aab2bb;
    --chart-baseline: #6b747e;
    --scanner-surface: #000000;
    --toast-surface: #2a2f35;
    --backdrop: rgba(0,0,0,.72);
  }
  .app-shell, dialog { box-shadow: none; }
  .period-control button.selected, .library-control button.selected { box-shadow: none; }
  input, select { caret-color: var(--accent-strong); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
