:root {
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1b1c19;
  background: #edf1e8;
  font-synthesis: none;
  --primary: #386a20;
  --primary-hover: #2d5719;
  --on-primary: #ffffff;
  --primary-container: #b8f397;
  --on-primary-container: #0b2004;
  --secondary-container: #d5e8c9;
  --tertiary: #386666;
  --surface: #fcfdf7;
  --surface-2: #f2f5ed;
  --surface-3: #e8ede3;
  --outline: #73796e;
  --outline-soft: #d9ded4;
  --muted: #5b6157;
  --error: #ba1a1a;
  --error-soft: #ffdad6;
  --shadow: 0 24px 70px rgba(42, 58, 35, .13);
  --radius-card: 22px;
  --radius-control: 14px;
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; background: #edf1e8; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid rgba(56, 102, 102, .35); outline-offset: 2px; }
button:disabled { cursor: wait; opacity: .68; }
.icon { width: 22px; height: 22px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding: 28px 18px;
  background:
    radial-gradient(circle at 12% 0%, rgba(184, 243, 151, .42), transparent 30rem),
    radial-gradient(circle at 88% 90%, rgba(56, 102, 102, .12), transparent 26rem),
    #edf1e8;
}

.phone-surface {
  width: min(100%, 720px);
  min-height: calc(100vh - 56px);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid rgba(74, 82, 70, .14);
  border-radius: 30px;
  box-shadow: var(--shadow);
}

.screen { min-height: calc(100vh - 58px); }
.onboarding { display: flex; flex-direction: column; padding: clamp(26px, 6vw, 48px); }
.brand-mark { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 18px; color: var(--primary); background: var(--primary-container); }
.brand-mark .icon { width: 30px; height: 30px; stroke-width: 2.2; }
.eyebrow { margin: 0 0 5px; color: var(--primary); font-size: .72rem; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: clamp(2rem, 7vw, 2.65rem); line-height: 1.08; letter-spacing: -.04em; }
h2 { margin: 0; font-size: 1.28rem; line-height: 1.2; letter-spacing: -.02em; }
h2 small { color: var(--muted); font-weight: 500; }
h3 { margin: 0; }
.onboarding > .eyebrow { margin-top: 28px; }
.lede { max-width: 540px; color: var(--muted); margin: 14px 0 28px; line-height: 1.55; }
.lede.compact { margin: 0 0 24px; }
.helper { color: var(--muted); margin: 7px 0 0; font-size: .9rem; line-height: 1.5; }
.privacy-note { margin: auto 0 0; padding-top: 28px; color: var(--muted); text-align: center; font-size: .78rem; line-height: 1.45; }
.divider { height: 1px; margin: 3px 0; background: var(--outline-soft); }

.form-stack { display: grid; gap: 18px; }
.form-stack.compact-stack { gap: 13px; margin-top: 18px; }
.field { display: grid; min-width: 0; gap: 8px; color: #32372f; font-size: .84rem; font-weight: 760; }
.field > span:first-child em { color: var(--muted); font-weight: 500; font-style: normal; }
.input-wrap { display: flex; align-items: center; min-width: 0; min-height: 56px; padding: 0 16px; border: 1px solid var(--outline); border-radius: var(--radius-control); background: #fff; transition: border-color .16s, box-shadow .16s; }
.input-wrap:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(56, 106, 32, .14); }
.input-wrap input { min-width: 0; width: 100%; border: 0; outline: 0; color: #1b1c19; background: transparent; }
.input-wrap b { color: var(--muted); font-size: .84rem; font-weight: 650; }
.time-input { gap: 8px; }
.time-input .icon { width: 18px; color: var(--primary); }
.textarea-field textarea { width: 100%; resize: vertical; min-height: 118px; padding: 15px 16px; border: 1px solid var(--outline); border-radius: var(--radius-control); color: #1b1c19; line-height: 1.45; background: #fff; }
.textarea-field textarea:focus { border-color: var(--primary); outline: 0; box-shadow: 0 0 0 3px rgba(56, 106, 32, .14); }
.split-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checkbox-field { display: grid; grid-template-columns: 24px 1fr; gap: 11px; align-items: start; padding: 14px; border-radius: 16px; background: var(--surface-2); cursor: pointer; }
.checkbox-field input { position: absolute; opacity: 0; pointer-events: none; }
.checkbox-box { width: 23px; height: 23px; display: grid; place-items: center; border: 2px solid var(--outline); border-radius: 6px; color: transparent; background: #fff; }
.checkbox-box .icon { width: 16px; height: 16px; stroke-width: 3; }
.checkbox-field input:checked + .checkbox-box { color: #fff; border-color: var(--primary); background: var(--primary); }
.checkbox-field strong, .checkbox-field small { display: block; }
.checkbox-field strong { font-size: .92rem; }
.checkbox-field small { margin-top: 3px; color: var(--muted); line-height: 1.4; }
.checkbox-field:has(input:focus-visible) { outline: 3px solid rgba(56, 102, 102, .35); outline-offset: 2px; }
.form-error { margin: -4px 0 0; color: var(--error); font-size: .88rem; line-height: 1.4; }
.form-error[hidden] { display: none; }

.button { min-height: 50px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 999px; padding: 0 22px; font-weight: 780; transition: transform .12s, background .16s, border-color .16s; }
.button:active { transform: scale(.99); }
.button.primary { color: var(--on-primary); background: var(--primary); }
.button.primary:hover { background: var(--primary-hover); }
.button.outline { color: var(--primary); border: 1px solid var(--outline); background: transparent; }
.button.outline:hover { background: rgba(56, 106, 32, .06); border-color: var(--primary); }
.button.text { color: var(--primary); background: transparent; }
.button.text:hover { background: rgba(56, 106, 32, .07); }
.button.danger { margin-top: 10px; color: var(--error); }
.button.wide { width: 100%; }

.top-bar { min-height: 74px; display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--outline-soft); background: rgba(252, 253, 247, .93); }
.top-bar h1 { text-align: center; font-size: 1.25rem; letter-spacing: -.02em; }
.top-bar-spacer { width: 48px; }
.icon-button { width: 46px; height: 46px; display: grid; place-items: center; padding: 0; color: #30362d; border: 0; border-radius: 50%; background: transparent; }
.icon-button:hover { background: var(--surface-3); }
.icon-button.small { width: 40px; height: 40px; }
.screen-content { padding: 28px clamp(22px, 6vw, 42px) 42px; }

.today-screen { padding: clamp(24px, 5vw, 38px); }
.today-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.today-header h1 { font-size: clamp(2.35rem, 8vw, 3.15rem); }
.today-header .icon-button { margin-top: 2px; background: var(--surface-2); }
.date-line { margin: 7px 0 0; color: var(--muted); font-size: .93rem; }
.progress-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.progress-card { min-width: 0; padding: 20px; border: 1px solid var(--outline-soft); border-radius: var(--radius-card); background: #fff; box-shadow: 0 7px 24px rgba(44, 58, 39, .055); }
.progress-title { display: grid; gap: 6px; }
.progress-title > span { color: var(--muted); font-size: .82rem; font-weight: 760; }
.progress-title strong { font-size: clamp(1.4rem, 5vw, 1.9rem); letter-spacing: -.035em; }
.progress-title strong span { color: var(--muted); font-size: .84rem; font-weight: 650; letter-spacing: 0; }
.progress-wrap { position: relative; height: 22px; margin-top: 16px; }
.progress-track { position: absolute; left: 0; right: 0; bottom: 1px; height: 11px; overflow: hidden; border-radius: 999px; background: #e1e8dc; }
.progress-fill { display: block; height: 100%; border-radius: inherit; background: var(--primary); transition: width .35s ease; }
.over-limit .progress-fill { background: var(--error); }
.time-marker { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--tertiary); }
.time-marker i { position: absolute; top: 0; left: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--tertiary); }
.progress-meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 7px; color: var(--muted); font-size: .72rem; font-weight: 670; }
.progress-meta b { color: var(--error); }
.eating-text { display: flex; align-items: flex-start; gap: 6px; margin: 11px 0 0; color: var(--muted); font-size: .72rem; line-height: 1.35; }
.eating-text .icon { width: 15px; height: 15px; }
.streak-card { display: flex; align-items: center; gap: 13px; margin-top: 12px; padding: 15px 17px; border-radius: 18px; color: #4c3d08; background: #fbefbf; }
.streak-card > .icon { width: 25px; height: 25px; color: #9b6b00; }
.streak-card strong, .streak-card span { display: block; }
.streak-card strong { font-size: .92rem; }
.streak-card span { margin-top: 2px; font-size: .76rem; opacity: .78; }
.section-block { margin-top: 30px; }
.section-heading { min-height: 42px; display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 13px; }
.section-heading h2 { font-size: 1.4rem; }
.count-badge { min-width: 30px; height: 30px; display: grid; place-items: center; border-radius: 999px; color: var(--primary); font-size: .8rem; font-weight: 800; background: var(--secondary-container); }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.action-card { min-width: 0; min-height: 82px; display: flex; align-items: center; gap: 12px; padding: 14px 15px; text-align: left; border: 0; border-radius: 19px; }
.action-card > .icon { width: 25px; height: 25px; }
.action-card strong, .action-card small { display: block; }
.action-card strong { font-size: .92rem; }
.action-card small { margin-top: 3px; opacity: .74; }
.primary-action { color: var(--on-primary); background: var(--primary); }
.primary-action:hover { background: var(--primary-hover); }
.tonal-action { color: var(--on-primary-container); background: var(--primary-container); }
.tonal-action:hover { background: #a6e184; }
.section-block > .button.outline { margin-top: 10px; }

.meal-list, .saved-list { display: grid; gap: 10px; }
.meal-card { display: grid; grid-template-columns: 44px 1fr; gap: 13px; align-items: center; padding: 15px; border: 1px solid var(--outline-soft); border-radius: 18px; background: #fff; }
.meal-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; color: var(--primary); background: var(--surface-3); }
.meal-icon .icon { width: 21px; height: 21px; }
.meal-copy h3 { font-size: .95rem; }
.meal-copy p { margin: 4px 0; font-size: .82rem; }
.meal-copy p span, .meal-copy small span { margin: 0 4px; color: #a2a79d; }
.meal-copy small { color: var(--muted); font-size: .74rem; }
.saved-card { width: 100%; display: grid; grid-template-columns: 44px 1fr 24px; gap: 13px; align-items: center; padding: 14px; text-align: left; color: #1b1c19; border: 1px solid var(--outline-soft); border-radius: 18px; background: #fff; }
.saved-card:hover { border-color: #a7b29f; background: #f8faf5; }
.saved-card strong, .saved-card small { display: block; }
.saved-card small { margin-top: 5px; color: var(--muted); }
.saved-card > .icon { color: var(--muted); }
.empty-state { display: grid; justify-items: center; padding: 34px 18px; text-align: center; border: 1px dashed #c6cdc0; border-radius: var(--radius-card); background: var(--surface-2); }
.empty-state h3 { margin-top: 13px; font-size: 1.02rem; }
.empty-state p { max-width: 380px; margin: 7px 0 0; color: var(--muted); font-size: .86rem; line-height: 1.45; }
.empty-icon { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 17px; color: var(--primary); background: var(--secondary-container); }
.empty-icon.spark { background: var(--primary-container); }
.centered-empty { min-height: 470px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.centered-empty h2 { margin-top: 19px; }
.centered-empty p { max-width: 430px; margin: 10px 0 22px; color: var(--muted); line-height: 1.5; }

.settings-content { display: grid; gap: 18px; }
.settings-section { padding: 20px; border: 1px solid var(--outline-soft); border-radius: var(--radius-card); background: #fff; }
.settings-section .eyebrow { margin-bottom: 7px; }
.key-status { display: flex; align-items: center; gap: 8px; margin: 14px 0 0; padding: 11px 12px; border-radius: 12px; color: var(--muted); font-size: .83rem; background: var(--surface-2); }
.key-status.saved { color: var(--primary); background: #e4f2dc; }
.key-status .icon { width: 17px; height: 17px; }
.security-note { margin: 13px 2px 0; color: var(--muted); font-size: .75rem; line-height: 1.45; }
.photo-actions .button { min-width: 0; padding: 0 12px; font-size: .84rem; }
.camera-dialog { width: min(94vw, 560px); max-height: 92dvh; overflow: auto; padding: 22px; border: 0; border-radius: 24px; color: #1b1c19; background: var(--surface); }
.camera-dialog::backdrop { background: rgba(24, 29, 23, .7); }
.camera-dialog video { display: block; width: 100%; max-height: 58dvh; margin-top: 16px; border-radius: 16px; background: #111; object-fit: contain; }
.camera-dialog video[hidden] { display: none; }
.camera-status { color: var(--muted); font-size: .9rem; line-height: 1.5; }
.camera-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.photo-chip { display: grid; grid-template-columns: 52px 1fr 40px; align-items: center; gap: 11px; padding: 9px; border: 1px solid var(--outline-soft); border-radius: 16px; background: var(--surface-2); }
.photo-thumb { width: 52px; height: 52px; overflow: hidden; border-radius: 12px; background: var(--surface-3); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-chip strong, .photo-chip small { display: block; }
.photo-chip strong { font-size: .86rem; }
.photo-chip small { max-width: 280px; overflow: hidden; margin-top: 3px; color: var(--muted); font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
.estimate-note, .estimate-banner { display: flex; align-items: flex-start; gap: 9px; padding: 12px 14px; border-radius: 15px; color: var(--muted); font-size: .8rem; line-height: 1.45; background: var(--surface-2); }
.estimate-note .icon, .estimate-banner .icon { width: 18px; height: 18px; margin-top: 1px; color: var(--tertiary); }
.estimate-banner { margin-bottom: 20px; color: #314e4e; background: #dceceb; }
.estimate-banner p { margin: 0; }

.dialog-backdrop { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 22px; }
.dialog-scrim { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: rgba(24, 29, 23, .55); cursor: default; }
.dialog { position: relative; width: min(100%, 460px); padding: 25px; border-radius: 24px; background: var(--surface); box-shadow: 0 24px 80px rgba(0, 0, 0, .28); }
.dialog p { margin: 12px 0 0; color: var(--muted); line-height: 1.5; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.dialog-actions .button { min-height: 46px; padding: 0 17px; }
.snackbar { position: fixed; z-index: 30; left: 50%; bottom: 24px; max-width: min(calc(100% - 32px), 520px); transform: translateX(-50%); padding: 13px 18px; border-radius: 13px; color: #fff; font-size: .88rem; font-weight: 630; text-align: center; background: #2d332a; box-shadow: 0 10px 35px rgba(0, 0, 0, .25); }
.spinner { width: 19px; height: 19px; border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; overflow: hidden !important; clip: rect(0 0 0 0) !important; white-space: nowrap !important; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 620px) {
  .app-shell { padding: 0; background: var(--surface); }
  .phone-surface { min-height: 100vh; border: 0; border-radius: 0; box-shadow: none; }
  .screen { min-height: 100vh; }
  .today-screen { padding: 24px 20px 36px; }
  .progress-grid { grid-template-columns: 1fr; }
  .progress-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
  .progress-title strong { text-align: right; }
  .progress-card { padding: 17px; }
  .eating-text { font-size: .7rem; }
  .screen-content { padding: 24px 20px 38px; }
}

@media (max-width: 410px) {
  .split-fields, .photo-actions { grid-template-columns: 1fr; }
  .action-card { min-height: 76px; padding: 12px; }
  .action-card small { font-size: .68rem; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
