:root {
  color-scheme: light;
  --mint: #9dd8c9;
  --mint-dark: #2eb981;
  --ink: #171b1a;
  --muted: #747a78;
  --line: #e1e4e2;
  --paper: #ffffff;
  --canvas: #f5f7f6;
  --coral: #ee694f;
  --gold: #ecb343;
  --shadow: 0 8px 24px rgba(24, 46, 38, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--canvas); color: var(--ink); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.app-shell { width: min(100%, 480px); min-height: 100vh; margin: auto; padding: 0 16px calc(126px + env(safe-area-inset-bottom)); background: var(--paper); box-shadow: 0 0 40px rgba(0,0,0,.06); }

.status-spacer { height: max(20px, env(safe-area-inset-top)); margin: 0 -16px; background: white; }
.app-header { display: grid; grid-template-columns: 60px 1fr 60px; align-items: center; min-height: 76px; margin: 0 -16px; padding: 7px 12px; background: var(--mint); }
.app-header h1 { margin: 0; text-align: center; font-size: 1.61rem; font-weight: 800; }
.menu-button { width: 52px; height: 52px; padding: 0; border: 0; background: transparent; color: var(--ink); font-size: 2.45rem; font-weight: 800; line-height: 1; text-align: left; transform: scaleX(1.08); }
.header-button { width: 40px; height: 40px; border: 0; background: transparent; color: var(--ink); font-size: 1.2rem; }
.header-spacer { width: 40px; }

.summary { padding: 30px 14px 20px; text-align: center; }
.calorie-ring { position: relative; width: 297px; height: 297px; margin: auto; }
.calorie-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.calorie-ring circle { fill: none; stroke-width: 21.6; }
.ring-track { stroke: #e6e8e7; }
.ring-value { stroke-linecap: butt; transition: stroke-dasharray .3s ease; }
.other-ring { stroke: var(--mint-dark); }
.protein-ring { stroke: var(--coral); }
.ring-copy { position: absolute; inset: 42px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-stat { display: flex; min-width: 0; flex-direction: column; align-items: center; }
.ring-stat span { margin-bottom: 2px; font-size: .92rem; font-weight: 650; line-height: 1; }
.ring-stat strong { font-size: 2.23rem; font-weight: 850; line-height: 1; letter-spacing: -.04em; }
.protein-stat { margin-bottom: 12px; }
.protein-stat span { color: #c84e3a; }
.other-stat span { color: #16825e; }

.quick-section, .log-section { padding: 20px 0 0; border-top: 8px solid var(--canvas); }
.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; }
.section-title h2 { margin: 0 0 2px; font-size: 1.06rem; }
.section-title p { margin: 0; color: var(--muted); font-size: .75rem; }
.small-button { padding: 8px 11px; border: 1px solid #a7d8cb; border-radius: 9px; background: #effaf7; color: #167357; font-size: .76rem; font-weight: 700; }
.meal-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.meal-slot { position: relative; min-height: 92px; padding: 14px 36px 12px 13px; border: 1px solid var(--line); border-radius: 13px; background: white; box-shadow: var(--shadow); text-align: left; }
.meal-slot:active { background: #f2faf7; transform: scale(.985); }
.meal-slot strong { display: block; overflow: hidden; margin-bottom: 8px; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.meal-slot span { display: block; color: var(--muted); font-size: .72rem; line-height: 1.4; }
.edit-meal { position: absolute; top: 7px; right: 7px; display: grid; width: 30px; height: 30px; place-items: center; border: 0; border-radius: 50%; background: #f3f5f4; color: #59615e; font-size: .85rem; }
.clear-button { padding: 7px; border: 0; background: transparent; color: #b24130; font-size: .76rem; font-weight: 700; }

.empty-state { padding: 24px 16px; border: 1px dashed #cbd1ce; border-radius: 12px; color: var(--muted); text-align: center; font-size: .8rem; }
.food-log { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.food-item { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 11px; padding: 11px 8px 11px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.food-item:active { background: #f1f8f5; }
.food-details { min-width: 0; }
.food-details strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .85rem; }
.food-details small, .food-macros small { color: var(--muted); font-size: .69rem; }
.food-macros { text-align: right; }
.food-macros strong { display: block; font-size: .82rem; }
.delete-button { display: grid; width: 32px; height: 32px; place-items: center; border: 0; background: transparent; color: #909794; font-size: 1.2rem; }

dialog { width: min(calc(100% - 28px), 430px); padding: 0; border: 0; border-radius: 18px; background: white; box-shadow: 0 25px 70px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(11,20,17,.55); backdrop-filter: blur(3px); }
dialog form { padding: 20px; }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.dialog-header h2 { margin: 0; font-size: 1.2rem; }
.dialog-kicker { margin: 0 0 3px; color: #287d64; font-size: .64rem; font-weight: 800; letter-spacing: .14em; }
.close-button { display: grid; width: 38px; height: 38px; place-items: center; border: 0; border-radius: 50%; background: #f2f4f3; font-size: 1.4rem; }
label { display: block; margin-top: 14px; color: var(--muted); font-size: .73rem; font-weight: 700; }
input, select { width: 100%; margin-top: 5px; padding: 12px; border: 1px solid #cfd4d1; border-radius: 9px; outline: none; background: white; color: var(--ink); font-size: 1rem; font-weight: 600; }
input:focus { border-color: #44a98a; box-shadow: 0 0 0 3px rgba(68,169,138,.12); }
.check-row { display: flex; align-items: center; gap: 9px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #f7f9f8; color: var(--ink); }
.check-row input { width: 20px; height: 20px; margin: 0; padding: 0; accent-color: #238664; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.primary-button { width: 100%; min-height: 48px; margin-top: 20px; border: 0; border-radius: 10px; background: #238664; color: white; font-weight: 750; }
.dialog-note { margin: 15px 0 0; color: var(--muted); font-size: .73rem; line-height: 1.4; }
.activity-status { margin: 16px 0 0; padding: 11px; border-radius: 9px; background: #f2f5f4; color: var(--muted); font-size: .78rem; text-align: center; }
.remove-button { width: 100%; margin-top: 8px; padding: 10px; border: 0; background: transparent; color: #b24130; font-size: .77rem; font-weight: 700; }
.bottom-nav { position: fixed; z-index: 15; left: 50%; bottom: calc(10px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(5, 1fr); width: min(calc(100% - 20px), 460px); min-height: 86px; padding: 8px 7px; border: 1px solid #d5dad7; border-radius: 19px; background: rgba(255,255,255,.97); box-shadow: 0 10px 32px rgba(20,35,29,.2); transform: translateX(-50%); backdrop-filter: blur(14px); }
.nav-button { position: relative; display: flex; min-width: 0; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; border-radius: 12px; background: transparent; color: #3d4441; }
.nav-button svg { width: 36px; height: 36px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.nav-button span { font-size: .69rem; font-weight: 750; }
.nav-button i { position: absolute; top: 4px; right: calc(50% - 19px); width: 7px; height: 7px; border: 2px solid white; border-radius: 50%; background: var(--mint-dark); opacity: 0; }
.nav-button.active { background: #e8f6f1; color: #0b7453; }
.nav-button.active i { opacity: 1; }
.tall-dialog { max-height: calc(100dvh - 28px); overflow: auto; }
.timer-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.timer-fields input { padding-inline: 7px; text-align: center; }
.saved-timers-heading { display: flex; align-items: flex-end; justify-content: space-between; margin: 24px 0 9px; }
.saved-timers-heading strong { font-size: .9rem; }
.saved-timers-heading small { color: var(--muted); font-size: .68rem; }
.saved-timers { display: grid; gap: 8px; }
.saved-timer { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 6px; padding: 10px 8px 10px 12px; border: 1px solid var(--line); border-radius: 11px; background: #f8faf9; }
.start-timer { min-width: 0; padding: 0; border: 0; background: transparent; color: var(--ink); text-align: left; }
.start-timer strong, .start-timer small { display: block; }
.start-timer small { margin-top: 3px; color: var(--muted); font-size: .68rem; }
.timer-action { width: 34px; height: 34px; border: 0; border-radius: 50%; background: white; color: #656e6a; }
.no-timers { padding: 16px; border: 1px dashed #cbd1ce; border-radius: 10px; color: var(--muted); font-size: .75rem; text-align: center; }
.timer-overlay { position: fixed; z-index: 100; inset: 0; min-height: 100dvh; padding: max(22px, env(safe-area-inset-top)) 20px max(22px, env(safe-area-inset-bottom)); background: #12382d; color: white; text-align: center; }
.timer-overlay.high { background: #c84636; }
.timer-overlay.low { background: #168160; }
.timer-overlay.ready { background: #28322f; }
.timer-overlay.done { background: #18211e; }
.timer-close { position: absolute; top: max(20px, env(safe-area-inset-top)); right: 20px; width: 48px; height: 48px; border: 1px solid rgba(255,255,255,.35); border-radius: 50%; background: rgba(0,0,0,.14); color: white; font-size: 2rem; }
.timer-name { margin: 58px 0 0; font-size: 1rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.timer-phase { margin: 15vh 0 0; font-size: clamp(2rem, 10vw, 4rem); font-weight: 900; letter-spacing: .08em; }
.timer-count { display: block; margin-top: 2vh; font-size: clamp(9rem, 48vw, 18rem); font-weight: 900; line-height: .9; letter-spacing: -.07em; }
.timer-round { margin: 5vh 0 0; font-size: 1.2rem; font-weight: 800; }
.progress-dialog { width: min(calc(100% - 16px), 470px); height: min(calc(100dvh - 16px), 900px); max-height: none; overflow: hidden; border-radius: 22px; }
.progress-panel { height: 100%; overflow-y: auto; padding: 20px 18px 35px; background: var(--canvas); }
.progress-card { margin-top: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: white; box-shadow: var(--shadow); }
.score-hero { display: grid; grid-template-columns: 118px 1fr; align-items: center; gap: 14px; }
.diet-score-ring { display: grid; width: 118px; height: 118px; padding: 12px; place-items: center; border-radius: 50%; background: conic-gradient(var(--score-color, #238664) var(--score, 0deg), #e3e7e5 0); }
.diet-score-ring > div { display: flex; width: 100%; height: 100%; flex-direction: column; align-items: center; justify-content: center; border-radius: 50%; background: white; }
.diet-score-ring strong { color: var(--score-color, #238664); font-size: 2rem; line-height: 1; letter-spacing: -.06em; }
.diet-score-ring span { margin-top: 4px; color: var(--muted); font-size: .58rem; font-weight: 700; text-transform: uppercase; }
.score-copy h3 { margin: 0; font-size: 1.05rem; }
.score-copy p { margin: 3px 0 10px; color: var(--muted); font-size: .68rem; line-height: 1.35; }
.score-legend { display: flex; flex-wrap: wrap; gap: 5px 9px; }
.score-legend span { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: .57rem; font-weight: 700; }
.score-legend i { width: 7px; height: 7px; border-radius: 50%; }
.score-legend .great { background: #2fb985; }.score-legend .good { background: #e7ad3c; }.score-legend .low { background: #e5604c; }
.today-goals { display: grid; gap: 10px; margin: 17px 0 14px; padding: 12px; border-radius: 12px; background: #f5f7f6; }
.goal-row > div:first-child { display: flex; justify-content: space-between; margin-bottom: 5px; }
.goal-row strong, .goal-row span { font-size: .66rem; }
.goal-row span { color: var(--muted); font-weight: 650; }
.goal-track { height: 9px; overflow: hidden; border-radius: 99px; background: #dde2df; }
.goal-track i { display: block; width: 0; height: 100%; border-radius: inherit; transition: width .3s; }
.protein-goal-row .goal-track i { background: var(--coral); }.other-goal-row .goal-track i { background: var(--mint-dark); }
.chart-label { margin: 4px 0 8px; color: #8a918e; font-size: .57rem; font-weight: 850; letter-spacing: .13em; }
.diet-chart { display: grid; grid-template-columns: repeat(7, 1fr); align-items: end; gap: 5px; height: 116px; }
.diet-day { display: flex; height: 100%; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; }
.diet-bar-track { position: relative; width: 100%; max-width: 27px; height: 76px; overflow: hidden; border-radius: 7px; background: #e5e8e7; }
.diet-bar { position: absolute; right: 0; bottom: 0; left: 0; border-radius: 7px; }
.diet-bar.great { background: #2fb985; }.diet-bar.good { background: #e7ad3c; }.diet-bar.low { background: #e5604c; }
.diet-day small { color: var(--muted); font-size: .58rem; }
.diet-day b { font-size: .58rem; }
.progress-card-title { display: flex; align-items: center; justify-content: space-between; }
.progress-card-title > span { font-size: .82rem; font-weight: 850; }
.progress-card-title > div { display: flex; align-items: center; gap: 7px; }
.progress-card-title strong { font-size: .78rem; }
.progress-card-title em { padding: 4px 6px; border-radius: 7px; background: #e9f6f1; color: #177657; font-size: .62rem; font-style: normal; font-weight: 800; }
.progress-card-title em.up { background: #fff0ed; color: #b84d3d; }
.weight-chart { display: block; width: 100%; height: 140px; margin-top: 8px; overflow: visible; }
.weight-empty { fill: #7b8380; font-size: 12px; text-anchor: middle; }
.activity-totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 13px 0 15px; }
.activity-total { display: grid; min-width: 0; padding: 10px 5px; place-items: center; border-radius: 12px; background: #f3f6f4; }
.activity-total svg { width: 27px; height: 27px; fill: none; stroke: #238664; stroke-width: 2.2; stroke-linecap: round; }
.activity-total > strong { margin-top: 4px; font-size: 1.45rem; line-height: 1; }
.activity-total > span:last-child { margin-top: 3px; color: var(--muted); font-size: .57rem; font-weight: 700; }
.flame { display: grid; width: 27px; height: 27px; place-items: center; color: #ef7c40; font-size: 1.4rem; }
.activity-chart { display: grid; gap: 10px; }
.activity-row { display: grid; grid-template-columns: 42px repeat(7, 1fr); align-items: center; gap: 4px; }
.activity-row > strong { font-size: .67rem; }
.activity-day { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); font-size: .55rem; }
.activity-dot { width: 22px; height: 22px; border-radius: 50%; background: #e4e8e6; }
.activity-dot.on { background: #238664; box-shadow: inset 0 0 0 6px #cceade; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 99px; background: #17201d; color: white; box-shadow: var(--shadow); font-size: .78rem; font-weight: 700; opacity: 0; pointer-events: none; transform: translate(-50%, 10px); transition: .2s; }
.bottom-nav ~ .toast, .toast { bottom: calc(112px + env(safe-area-inset-bottom)); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (orientation: landscape) {
  .app-shell { width: min(100%, 390px); }
  .bottom-nav { width: min(calc(100% - 20px), 370px); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
