:root {
  --bg: #F6F1E9;
  --bg-deep: #EFE8DC;
  --surface: #FFFDF9;
  --surface-2: #FAF6EF;
  --ink: #1E2A23;
  --ink-2: #4B564F;
  --muted: #7C857D;
  --line: #E6DED1;
  --line-2: #D9CFBF;

  --green: #24503D;
  --green-2: #2F6A50;
  --green-soft: #E3ECE5;
  --green-tint: #F0F5F1;
  --terra: #C4643A;
  --terra-2: #D97A4E;
  --terra-soft: #F7E6DC;
  --ochre: #C9962E;
  --ochre-soft: #F5EBD4;
  --water: #3F7E93;
  --water-soft: #DDEBEF;

  --protein: var(--green-2);
  --carbs: var(--ochre);
  --fat: var(--terra-2);

  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 1px 2px rgba(48, 38, 22, .05), 0 6px 20px -8px rgba(48, 38, 22, .12);
  --shadow-lg: 0 2px 6px rgba(48, 38, 22, .06), 0 24px 48px -16px rgba(48, 38, 22, .25);
  --ease: cubic-bezier(.22, .8, .26, 1);
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sans: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --tabbar-h: 72px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg-deep);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
:focus-visible { outline: 2px solid var(--terra); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }

.i {
  width: 22px; height: 22px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.i-sm { width: 16px; height: 16px; }
.i-lg { width: 28px; height: 28px; }

h1, h2, h3 { font-family: var(--serif); font-weight: 500; letter-spacing: -.01em; margin: 0; font-variation-settings: 'opsz' 72; }
p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- App shell ---------- */
.app {
  position: relative;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
}
@media (min-width: 520px) {
  .app { box-shadow: 0 0 0 1px var(--line), 0 30px 80px -40px rgba(48, 38, 22, .35); }
}

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 20px 12px;
  background: rgba(246, 241, 233, .88);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 11px;
  display: grid; place-items: center;
  background: var(--green); color: #F6F1E9;
}
.brand-mark .i { width: 22px; height: 22px; }
.brand-name { font-family: var(--serif); font-size: 21px; font-weight: 600; letter-spacing: -.02em; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; color: var(--ink-2);
  transition: background .2s var(--ease), transform .15s var(--ease);
}
.icon-btn:hover { background: var(--bg-deep); }
.icon-btn:active { transform: scale(.94); }
.streak-pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 34px; padding: 0 12px 0 9px; border-radius: 999px;
  background: var(--terra-soft); color: var(--terra);
  font-weight: 700; font-size: 14px;
  transition: transform .15s var(--ease);
}
.streak-pill .i { width: 18px; height: 18px; }
.streak-pill:active { transform: scale(.95); }
.streak-pill.is-zero { background: var(--bg-deep); color: var(--muted); }
.streak-pill.bump { animation: bump .5s var(--ease); }
@keyframes bump { 40% { transform: scale(1.15); } }

/* ---------- Views ---------- */
.views { padding: 4px 16px 0; }
.view { display: none; }
.view.is-active { display: block; animation: viewIn .35s var(--ease); }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } }

.page-head { padding: 6px 4px 16px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.page-title { font-size: 30px; line-height: 1.12; margin-top: 4px; }
.page-title em { font-style: italic; color: var(--green); }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title { font-size: 19px; }
.card-sub { color: var(--muted); font-size: 13px; }
.section-label { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 22px 4px 10px; display: flex; justify-content: space-between; align-items: baseline; }
.section-label span + span { text-transform: none; letter-spacing: 0; font-weight: 500; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 20px; border-radius: 14px;
  font-weight: 600; font-size: 15px;
  transition: transform .15s var(--ease), background .2s var(--ease), box-shadow .2s var(--ease), opacity .2s;
  user-select: none;
}
.btn:active { transform: scale(.97); }
.btn .i { width: 20px; height: 20px; }
.btn-primary { background: var(--green); color: #FBF8F2; box-shadow: 0 6px 16px -8px rgba(36, 80, 61, .7); }
.btn-primary:hover { background: var(--green-2); }
.btn-accent { background: var(--terra); color: #FFF8F2; box-shadow: 0 6px 16px -8px rgba(196, 100, 58, .8); }
.btn-accent:hover { background: var(--terra-2); }
.btn-ghost { background: var(--bg-deep); color: var(--ink); }
.btn-ghost:hover { background: var(--line); }
.btn-outline { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line-2); }
.btn-danger { background: transparent; color: #A6402A; box-shadow: inset 0 0 0 1.5px #E9C5B8; }
.btn-danger.is-armed { background: #A6402A; color: #fff; box-shadow: none; }
.btn-block { width: 100%; }
.btn-sm { height: 38px; padding: 0 14px; font-size: 14px; border-radius: 11px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1; }
.link-btn { color: var(--green); font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 4px; }
.link-btn .i { width: 16px; height: 16px; }

/* ---------- Plan hero ---------- */
.plan-hero {
  position: relative; overflow: hidden;
  background: var(--green); color: #F3EEE4;
  border-radius: 24px; padding: 22px 20px 20px;
  margin-bottom: 18px;
  box-shadow: 0 16px 32px -18px rgba(36, 80, 61, .8);
}
.plan-hero::after {
  content: ''; position: absolute; right: -60px; top: -60px;
  width: 200px; height: 200px; border-radius: 50%;
  border: 28px solid rgba(255, 255, 255, .05);
}
.plan-hero .eyebrow { color: rgba(243, 238, 228, .65); }
.plan-hero h2 { font-size: 26px; margin: 6px 0 6px; line-height: 1.15; }
.plan-hero h2 em { color: #F2B28F; }
.plan-hero p { color: rgba(243, 238, 228, .8); font-size: 14px; max-width: 30ch; margin-bottom: 16px; }
.plan-hero .btn { position: relative; z-index: 1; }
.hero-meta { display: flex; gap: 14px; margin-top: 14px; font-size: 12.5px; color: rgba(243, 238, 228, .7); }
.hero-meta span { display: inline-flex; align-items: center; gap: 5px; }
.hero-meta .i { width: 15px; height: 15px; }

/* ---------- Search & filters ---------- */
.search {
  position: relative; display: flex; align-items: center;
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.search .i { position: absolute; left: 14px; color: var(--muted); }
.search input {
  width: 100%; height: 50px; border: 0; background: transparent;
  padding: 0 44px 0 44px; font-size: 16px; outline: none; border-radius: 14px;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { box-shadow: inset 0 0 0 1.5px var(--green); }
.search .clear-btn { position: absolute; right: 8px; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: var(--muted); }
.search .clear-btn .i { position: static; width: 18px; height: 18px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 4px; margin: 0 -2px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 36px; padding: 0 14px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); color: var(--ink-2); font-weight: 600; font-size: 13.5px;
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background .2s var(--ease), color .2s var(--ease), box-shadow .2s;
}
.chip .i { width: 17px; height: 17px; }
.chip.is-on { background: var(--ink); color: var(--bg); box-shadow: none; }
.filter-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 4px 12px; font-size: 13px; color: var(--muted); }

.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 36px; height: 22px; border-radius: 999px; background: var(--line-2); position: relative; transition: background .2s var(--ease); }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .25s var(--ease); }
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { outline: 2px solid var(--terra); outline-offset: 2px; }

/* ---------- Dish rows ---------- */
.dish-list { display: flex; flex-direction: column; gap: 10px; }
.dish {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--surface); border-radius: 18px; padding: 14px;
  box-shadow: var(--shadow);
  transition: transform .18s var(--ease), box-shadow .2s var(--ease);
  animation: rise .4s var(--ease) both;
}
.dish:hover { box-shadow: var(--shadow-lg); }
.dish:active { transform: scale(.985); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.meal-tile {
  width: 46px; height: 46px; border-radius: 14px; flex: none;
  display: grid; place-items: center;
}
.meal-tile.breakfast { background: var(--ochre-soft); color: #9A7015; }
.meal-tile.lunch { background: var(--green-soft); color: var(--green); }
.meal-tile.dinner { background: #E5E3EE; color: #4A4870; }
.meal-tile.snack { background: var(--terra-soft); color: var(--terra); }
.dish-main { flex: 1; min-width: 0; }
.dish-name { font-weight: 600; font-size: 15px; line-height: 1.25; }
.dish-desc { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.macro-mini { display: flex; gap: 10px; margin-top: 6px; font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.macro-mini span { display: inline-flex; align-items: center; gap: 4px; }
.macro-mini span::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.macro-mini .p::before { background: var(--protein); }
.macro-mini .c::before { background: var(--carbs); }
.macro-mini .f::before { background: var(--fat); }
.dish-kcal { text-align: right; flex: none; }
.dish-kcal strong { display: block; font-family: var(--serif); font-size: 21px; font-weight: 500; line-height: 1; }
.dish-kcal small { color: var(--muted); font-size: 12px; }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--bg-deep); color: var(--ink-2); }
.tag .i { width: 13px; height: 13px; }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.terra { background: var(--terra-soft); color: var(--terra); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }

.empty {
  text-align: center; padding: 34px 20px; color: var(--muted);
  background: var(--surface-2); border-radius: var(--radius); border: 1.5px dashed var(--line-2);
}
.empty .i { width: 30px; height: 30px; color: var(--line-2); margin-bottom: 6px; }
.empty strong { display: block; color: var(--ink); font-family: var(--serif); font-weight: 500; font-size: 18px; margin-bottom: 4px; }

/* ---------- Today ---------- */
.ring-card { display: flex; flex-direction: column; align-items: center; padding: 22px 18px 18px; }
.ring-wrap { position: relative; width: 220px; height: 220px; }
.ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { stroke: var(--bg-deep); }
.ring-bar { stroke: var(--green); transition: stroke-dashoffset 1s var(--ease), stroke .3s; }
.ring-bar.over { stroke: var(--terra); }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ring-center .big { font-family: var(--serif); font-size: 46px; font-weight: 500; line-height: 1; letter-spacing: -.02em; }
.ring-center .lbl { font-size: 13px; color: var(--muted); margin-top: 6px; font-weight: 500; }
.ring-stats { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.ring-stats div { text-align: center; }
.ring-stats div + div { border-left: 1px solid var(--line); }
.ring-stats strong { display: block; font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ring-stats span { font-size: 12px; color: var(--muted); }

.macro-row + .macro-row { margin-top: 16px; }
.macro-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; }
.macro-name { font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.macro-name::before { content: ''; width: 9px; height: 9px; border-radius: 3px; background: var(--dot); }
.macro-val { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.macro-val b { color: var(--ink); font-weight: 700; font-size: 14px; }
.bar { height: 10px; border-radius: 999px; background: var(--bg-deep); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--dot); transition: width .9s var(--ease); }
.bar.over > i { background: repeating-linear-gradient(45deg, var(--dot), var(--dot) 5px, color-mix(in srgb, var(--dot) 70%, #fff) 5px, color-mix(in srgb, var(--dot) 70%, #fff) 10px); }

.water-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.water-count { font-family: var(--serif); font-size: 24px; }
.water-count small { font-family: var(--sans); font-size: 13px; color: var(--muted); }
.glasses { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.glass {
  height: 52px; border-radius: 12px; display: grid; place-items: center;
  color: var(--line-2); --glass-fill: transparent;
  transition: transform .2s var(--ease), color .2s, background .2s;
}
.glass .i { width: 26px; height: 26px; }
.glass:hover { background: var(--water-soft); }
.glass:active { transform: scale(.9); }
.glass.is-full { color: var(--water); --glass-fill: rgba(63, 126, 147, .45); }
.glass.pop { animation: pop .45s var(--ease); }
@keyframes pop { 40% { transform: scale(1.18) translateY(-3px); } }
.water-actions { display: flex; gap: 6px; }
.water-actions .icon-btn { width: 34px; height: 34px; background: var(--water-soft); color: var(--water); border-radius: 10px; }
.water-actions .icon-btn .i { width: 18px; height: 18px; }
.water-note { font-size: 12.5px; color: var(--muted); margin-top: 10px; }

.meal-group + .meal-group { margin-top: 6px; }
.meal-group-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 2px; font-size: 13px; color: var(--muted); }
.meal-group-head b { color: var(--ink); font-size: 14px; display: inline-flex; align-items: center; gap: 8px; }
.meal-group-head .i { width: 18px; height: 18px; }
.entry {
  display: flex; align-items: center; gap: 12px; padding: 12px 4px 12px 0;
  border-top: 1px solid var(--line);
  transition: opacity .3s var(--ease), transform .3s var(--ease), max-height .3s var(--ease);
  max-height: 120px;
}
.entry.leaving { opacity: 0; transform: translateX(30px); max-height: 0; padding-top: 0; padding-bottom: 0; overflow: hidden; }
.entry-main { flex: 1; min-width: 0; }
.entry-name { font-weight: 600; font-size: 14.5px; }
.entry-meta { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.entry-kcal { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14.5px; }
.entry .icon-btn { width: 36px; height: 36px; color: var(--muted); }
.entry .icon-btn:hover { color: #A6402A; background: #F6E3DB; }

/* ---------- Insights ---------- */
.suggest-card { background: linear-gradient(160deg, #FFFDF9 0%, #FBF1E8 100%); box-shadow: var(--shadow), inset 0 0 0 1px #F0DFD1; }
.suggest-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.suggest-top .meal-tile { width: 40px; height: 40px; border-radius: 12px; }
.suggest-name { font-size: 22px; line-height: 1.2; margin-bottom: 6px; }
.suggest-why { color: var(--ink-2); font-size: 14px; margin-bottom: 14px; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.stat { background: var(--surface); border-radius: 12px; padding: 9px 6px; text-align: center; box-shadow: inset 0 0 0 1px var(--line); }
.stat b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11.5px; color: var(--muted); }

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .bar-rect { fill: var(--green-2); transition: opacity .2s; }
.chart .bar-rect.is-today { fill: var(--green); }
.chart .bar-rect.is-over { fill: var(--terra-2); }
.chart .bar-rect.is-empty { fill: var(--line); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .goal-line { stroke: var(--ink); stroke-width: 1.25; stroke-dasharray: 4 4; opacity: .55; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart text { font-family: var(--sans); font-size: 11px; fill: var(--muted); }
.chart text.goal-label { fill: var(--ink-2); font-weight: 600; }
.chart text.is-today { fill: var(--ink); font-weight: 700; }
.chart.has-focus .bar-rect:not(.is-focus) { opacity: .4; }
.chart-tip {
  position: absolute; pointer-events: none; transform: translate(-50%, -100%);
  background: var(--ink); color: var(--bg); padding: 7px 10px; border-radius: 10px;
  font-size: 12.5px; white-space: nowrap; box-shadow: var(--shadow-lg);
  opacity: 0; transition: opacity .15s;
}
.chart-tip.show { opacity: 1; }
.chart-tip b { font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 10px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend i.line { height: 0; border-top: 1.5px dashed var(--ink); border-radius: 0; width: 14px; opacity: .6; }

.obs { display: flex; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.obs:first-child { border-top: 0; padding-top: 2px; }
.obs-icon { width: 38px; height: 38px; border-radius: 12px; flex: none; display: grid; place-items: center; background: var(--green-tint); color: var(--green); }
.obs-icon.terra { background: var(--terra-soft); color: var(--terra); }
.obs-icon.water { background: var(--water-soft); color: var(--water); }
.obs-icon.ochre { background: var(--ochre-soft); color: #9A7015; }
.obs-icon .i { width: 20px; height: 20px; }
.obs h4 { margin: 0 0 2px; font-size: 14.5px; font-weight: 700; }
.obs p { color: var(--ink-2); font-size: 13.5px; }

.export-card { display: flex; align-items: center; gap: 14px; }
.export-card .obs-icon { width: 44px; height: 44px; }
.export-card div { flex: 1; }
.privacy-note { display: flex; gap: 8px; align-items: center; justify-content: center; font-size: 12px; color: var(--muted); margin: 18px 0 4px; }
.privacy-note .i { width: 15px; height: 15px; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; z-index: 30; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  display: grid; grid-template-columns: repeat(3, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: 8px 16px env(safe-area-inset-bottom);
  background: rgba(255, 253, 249, .92);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--line);
}
.tab {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 12px; font-weight: 600; border-radius: 14px;
  transition: color .2s var(--ease);
}
.tab .i { transition: transform .3s var(--ease); }
.tab::before {
  content: ''; position: absolute; top: 4px; width: 56px; height: 32px; border-radius: 999px;
  background: var(--green-soft); transform: scale(.6); opacity: 0; z-index: -1;
  transition: transform .3s var(--ease), opacity .2s;
}
.tab.is-active { color: var(--green); }
.tab.is-active::before { transform: scale(1); opacity: 1; }
.tab.is-active .i { transform: translateY(-1px); }

/* ---------- Sheet ---------- */
.sheet-root { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.backdrop { position: absolute; inset: 0; background: rgba(30, 42, 35, .38); opacity: 0; transition: opacity .3s var(--ease); }
.sheet {
  position: relative; width: 100%; max-width: 480px; max-height: 92vh; max-height: 92dvh;
  background: var(--bg); border-radius: 26px 26px 0 0;
  box-shadow: var(--shadow-lg);
  transform: translateY(100%); transition: transform .38s var(--ease);
  display: flex; flex-direction: column;
}
.sheet-root.is-open .backdrop { opacity: 1; }
.sheet-root.is-open .sheet { transform: translateY(0); }
.sheet-handle { width: 40px; height: 5px; border-radius: 999px; background: var(--line-2); margin: 10px auto 0; flex: none; }
.sheet-body { overflow-y: auto; padding: 14px 20px calc(22px + env(safe-area-inset-bottom)); overscroll-behavior: contain; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sheet-head h2 { font-size: 25px; line-height: 1.15; }
.sheet-head p { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.sheet-head .icon-btn { background: var(--bg-deep); flex: none; }

.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px;
  background: var(--bg-deep); padding: 4px; border-radius: 14px;
}
.segmented button {
  height: 40px; border-radius: 11px; font-weight: 600; font-size: 13.5px; color: var(--ink-2);
  transition: background .2s var(--ease), color .2s, box-shadow .2s;
}
.segmented button.is-on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(48, 38, 22, .12); }
.field-label { font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; display: block; }

.portion-stats { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr; gap: 8px; margin-top: 16px; }
.portion-stats .stat { background: var(--surface); box-shadow: var(--shadow); padding: 12px 6px; }
.portion-stats .stat b { font-size: 19px; transition: color .2s; }
.portion-stats .stat:first-child b { font-family: var(--serif); font-weight: 500; font-size: 24px; }
.portion-stats .stat.flash b { animation: flash .4s var(--ease); }
@keyframes flash { 50% { color: var(--terra); } }
.fit-note { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--ink-2); background: var(--green-tint); border-radius: 12px; padding: 10px 12px; margin-top: 14px; }
.fit-note .i { width: 18px; height: 18px; color: var(--green); margin-top: 1px; }
.fit-note.warn { background: var(--terra-soft); }
.fit-note.warn .i { color: var(--terra); }
.sheet-actions { margin-top: 20px; }

/* Plan sheet */
.plan-summary { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); padding: 16px; }
.plan-total { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.plan-total strong { font-family: var(--serif); font-size: 32px; font-weight: 500; letter-spacing: -.02em; }
.plan-total span { color: var(--muted); font-size: 13.5px; }
.delta { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12.5px; font-weight: 700; background: var(--green-soft); color: var(--green); font-variant-numeric: tabular-nums; }
.delta.off { background: var(--terra-soft); color: var(--terra); }
.plan-macros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 14px; }
.plan-macro .macro-top { margin-bottom: 5px; }
.plan-macro .macro-name { font-size: 12.5px; }
.plan-macro .macro-val { font-size: 12px; }
.plan-macro .bar { height: 7px; }
.plan-list { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.plan-item {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 16px;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line);
  animation: rise .4s var(--ease) both;
}
.plan-item .meal-tile { width: 42px; height: 42px; border-radius: 12px; }
.plan-slot { font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.plan-dish { font-weight: 600; font-size: 14.5px; line-height: 1.25; }
.plan-item .portion-badge { font-size: 11.5px; font-weight: 700; background: var(--ochre-soft); color: #8A6312; padding: 2px 7px; border-radius: 999px; margin-left: 6px; white-space: nowrap; }
.plan-kcal { text-align: right; flex: none; font-variant-numeric: tabular-nums; }
.plan-kcal b { display: block; font-size: 15px; }
.plan-kcal span { font-size: 12px; color: var(--muted); }
.plan-foot { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); margin-top: 12px; }
.plan-foot .i { width: 15px; height: 15px; }
.plan-list.shuffling .plan-item { animation: none; opacity: .3; transform: scale(.98); transition: opacity .15s, transform .15s; }
.spin .i { animation: spin .5s var(--ease); }
@keyframes spin { to { transform: rotate(180deg); } }

/* Settings */
.input {
  width: 100%; height: 48px; border-radius: 13px; border: 0; padding: 0 14px; font-size: 16px;
  background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line); outline: none;
  transition: box-shadow .2s;
}
.input:focus { box-shadow: inset 0 0 0 1.5px var(--green); }
.input-row { display: flex; gap: 10px; align-items: center; }
.input-row .input { flex: 1; }
.target-preview { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.target-preview .stat { background: var(--surface); }
.danger-zone { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }

/* Feedback */
.settings-link {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  margin-top: 22px; padding: 12px 14px; border-radius: 16px;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line);
  transition: background .2s var(--ease), transform .15s var(--ease);
}
.settings-link:hover { background: var(--surface-2); }
.settings-link:active { transform: scale(.985); }
.settings-link > span:nth-child(2) { flex: 1; }
.settings-link b { display: block; font-size: 15px; }
.settings-link small { color: var(--muted); font-size: 13px; }
.settings-link > .i { color: var(--muted); width: 18px; height: 18px; }
.fb-rating-label, .optional { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--ink-2); }
.optional { color: var(--muted); }
.stars { display: flex; gap: 6px; }
.star-btn {
  width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); color: var(--line-2);
  transition: color .2s, background .2s, transform .15s var(--ease);
}
.star-btn .i { width: 26px; height: 26px; }
.star-btn:hover { color: var(--ochre); }
.star-btn:active { transform: scale(.9); }
.star-btn.is-on { color: var(--ochre); --star-fill: rgba(201, 150, 46, .35); background: var(--ochre-soft); box-shadow: none; }
.star-btn.pop { animation: pop .45s var(--ease); }
.textarea { height: auto; min-height: 120px; padding: 12px 14px; resize: vertical; line-height: 1.45; font-size: 15px; }
.fb-count { text-align: right; font-size: 12px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.fb-privacy { display: flex; gap: 6px; align-items: center; font-size: 12.5px; color: var(--muted); margin-top: 14px; }
#fbError { margin-top: 14px; }
.fb-done { text-align: center; padding: 18px 6px 4px; animation: viewIn .4s var(--ease); }
.fb-done-mark { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 14px; background: var(--green); color: #fff; box-shadow: 0 12px 26px -12px rgba(36, 80, 61, .9); }
.fb-done-mark .i { width: 32px; height: 32px; stroke-width: 2.2; }
.fb-done h2 { font-size: 28px; margin-bottom: 6px; }
.fb-done p { color: var(--ink-2); margin-bottom: 22px; }

/* ---------- Onboarding ---------- */
.onboarding {
  position: fixed; inset: 0; z-index: 60; background: var(--bg); overflow-y: auto;
  display: flex; justify-content: center;
}
.ob-inner { width: 100%; max-width: 480px; min-height: 100%; display: flex; flex-direction: column; padding: calc(22px + env(safe-area-inset-top)) 22px calc(22px + env(safe-area-inset-bottom)); }
.ob-top { display: flex; align-items: center; justify-content: space-between; min-height: 40px; }
.ob-progress { display: flex; gap: 6px; }
.ob-progress i { width: 22px; height: 5px; border-radius: 999px; background: var(--line); transition: background .3s, width .3s var(--ease); }
.ob-progress i.on { background: var(--green); width: 34px; }
.ob-step { flex: 1; display: flex; flex-direction: column; animation: viewIn .45s var(--ease); }
.ob-step h1 { font-size: 34px; line-height: 1.1; margin: 26px 0 10px; }
.ob-step h1 em { color: var(--terra); }
.ob-step .lead { color: var(--ink-2); font-size: 15.5px; margin-bottom: 22px; }
.ob-options { display: flex; flex-direction: column; gap: 10px; }
.ob-option {
  display: flex; align-items: center; gap: 14px; text-align: left; width: 100%;
  padding: 16px; border-radius: 18px; background: var(--surface);
  box-shadow: var(--shadow), inset 0 0 0 1.5px transparent;
  transition: box-shadow .2s var(--ease), transform .15s var(--ease);
}
.ob-option:active { transform: scale(.985); }
.ob-option .obs-icon { width: 46px; height: 46px; border-radius: 14px; }
.ob-option .obs-icon .i { width: 24px; height: 24px; }
.ob-option b { display: block; font-size: 16px; }
.ob-option span { color: var(--muted); font-size: 13.5px; }
.ob-option .tick { margin-left: auto; width: 24px; height: 24px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--line-2); display: grid; place-items: center; color: transparent; flex: none; transition: background .2s, color .2s, box-shadow .2s; }
.ob-option .tick .i { width: 15px; height: 15px; stroke-width: 2.4; }
.ob-option.is-on { box-shadow: var(--shadow), inset 0 0 0 1.5px var(--green); }
.ob-option.is-on .tick { background: var(--green); color: #fff; box-shadow: none; }
.ob-foot { margin-top: auto; padding-top: 24px; }
.ob-hero-mark { width: 64px; height: 64px; border-radius: 20px; background: var(--green); color: #F6F1E9; display: grid; place-items: center; margin-top: 24px; box-shadow: 0 16px 30px -14px rgba(36, 80, 61, .9); }
.ob-hero-mark .i { width: 38px; height: 38px; stroke-width: 1.5; }
.ob-features { display: flex; flex-direction: column; gap: 14px; margin: 6px 0 10px; }
.ob-features div { display: flex; gap: 12px; align-items: flex-start; font-size: 14.5px; color: var(--ink-2); }
.ob-features b { color: var(--ink); }
.cal-editor { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 8px 0 4px; }
.cal-editor .icon-btn { width: 48px; height: 48px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow); color: var(--ink); }
.cal-editor input {
  width: 170px; text-align: center; border: 0; background: transparent; outline: none;
  font-family: var(--serif); font-size: 56px; font-weight: 500; letter-spacing: -.03em; color: var(--ink);
  border-bottom: 2px solid var(--line); padding-bottom: 2px; -moz-appearance: textfield;
}
.cal-editor input:focus { border-bottom-color: var(--green); }
.cal-editor input::-webkit-outer-spin-button, .cal-editor input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cal-unit { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.split-bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; gap: 2px; margin: 14px 0 10px; }
.split-bar i { display: block; height: 100%; }
.how { font-size: 13px; color: var(--muted); margin-top: 16px; display: flex; gap: 8px; }
.how .i { width: 17px; height: 17px; margin-top: 1px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; z-index: 70; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  width: calc(100% - 32px); max-width: 448px;
  display: flex; align-items: center; gap: 10px;
  background: var(--ink); color: #F6F1E9; border-radius: 16px; padding: 12px 12px 12px 16px;
  box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 500;
  transition: opacity .25s var(--ease), transform .35s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast .i { width: 20px; height: 20px; color: #9FCDB4; }
.toast span { flex: 1; }
.toast button { color: #F2B28F; font-weight: 700; padding: 6px 10px; border-radius: 10px; }
.toast button:hover { background: rgba(255,255,255,.08); }

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