/* NutriTrack app styles. Tokens live in tokens.css. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 1rem/1.5 var(--font); font-feature-settings: "tnum", "cv11";
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; overflow-x: hidden;
}
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; font-feature-settings: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { display: block; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hide { display: none !important; }

/* ---------- shell ---------- */
.app { min-height: 100dvh; }
.sidebar { display: none; }
.main { min-width: 0; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 28px); }
.page { padding: 0 var(--gutter); max-width: 1240px; margin: 0 auto; padding-left: max(var(--gutter), env(safe-area-inset-left)); padding-right: max(var(--gutter), env(safe-area-inset-right)); }
.page-head { display: flex; align-items: center; gap: 12px; padding: calc(env(safe-area-inset-top) + 18px) 0 12px; min-height: 64px; }
.page-head h1 { font-size: 1.75rem; line-height: 1.15; font-weight: 700; letter-spacing: -.02em; flex: 1; min-width: 0; }
.page-head .sub { display: block; font-size: .875rem; font-weight: 500; color: var(--text-2); letter-spacing: 0; margin-top: 2px; }
.page-head .actions { display: flex; gap: 8px; align-items: center; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--border);
  display: flex; padding: 0 max(4px, env(safe-area-inset-left)) env(safe-area-inset-bottom) max(4px, env(safe-area-inset-right));
}
.bottomnav a {
  flex: 1; height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: .75rem; font-weight: 500; color: var(--text-3); text-decoration: none; position: relative; min-width: 0;
}
.bottomnav .pill { width: 56px; height: 30px; border-radius: 999px; display: grid; place-items: center; transition: background .2s; position: relative; }
.bottomnav a[aria-current="page"] { color: var(--primary-text); font-weight: 600; }
.bottomnav a[aria-current="page"] .pill { background: var(--primary-tint); }
.bottomnav a[aria-current="page"] svg { stroke-width: 2.3; }
.dotbadge { position: absolute; top: 2px; right: 12px; width: 9px; height: 9px; border-radius: 50%; background: var(--warn); border: 2px solid var(--surface); box-sizing: content-box; }

@media (min-width: 640px) { .page-head h1 { font-size: 2rem; } }
@media (min-width: 1024px) {
  .app { display: grid; grid-template-columns: 240px 1fr; }
  .app.rail { grid-template-columns: 72px 1fr; }
  .bottomnav { display: none; }
  .main { padding-bottom: 48px; }
  .page-head { padding-top: 28px; }
  .sidebar {
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh;
    background: var(--surface); border-right: 1px solid var(--border); padding: 20px 12px 16px;
  }
  .sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; font-weight: 700; font-size: 1.125rem; letter-spacing: -.01em; }
  .sidebar .brand img { width: 32px; height: 32px; border-radius: 9px; flex: none; }
  .sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
  .sidebar a, .sidebar .collapse {
    display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 12px; border-radius: 10px; position: relative;
    color: var(--text-2); font-weight: 500; text-decoration: none; font-size: .9375rem;
  }
  .sidebar a:hover, .sidebar .collapse:hover { background: var(--surface-2); text-decoration: none; }
  .sidebar a[aria-current="page"] { background: var(--primary-tint); color: var(--primary-text); font-weight: 600; }
  .sidebar a[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); }
  .sidebar .spacer { flex: 1; }
  .sidebar .count { margin-left: auto; font-size: .75rem; font-weight: 600; background: var(--warn-bg); color: var(--warn); border-radius: 999px; padding: 1px 8px; }
  .app.rail .sidebar .label, .app.rail .sidebar .count, .app.rail .sidebar .brand .brand-text { display: none; }
  .app.rail .sidebar a, .app.rail .sidebar .collapse { justify-content: center; padding: 0; }
  .app.rail .sidebar .brand { justify-content: center; padding-inline: 0; }
  .app.rail .sidebar a[aria-current="page"]::before { left: -12px; }
}

/* ---------- grid / cards ---------- */
.grid { display: grid; gap: var(--gap); align-items: start; }
.grid > * { min-width: 0; }
@media (min-width: 640px) { .grid.two { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1024px) {
  .grid.cols-12-8 { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
  .grid.cols-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
  .grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card);
  box-shadow: var(--shadow-1); padding: var(--card-pad); min-width: 0;
}
.card.flush { padding: 0; overflow: hidden; }
.card h2, .h2 { font-size: 1.125rem; line-height: 1.3; font-weight: 600; }
.micro { font-size: .75rem; line-height: 1.3; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); }
.small { font-size: .875rem; line-height: 1.4; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 8px 2px 8px; }
.section-title h2 { font-size: 1.125rem; font-weight: 600; }
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 48px; padding: 0 20px;
  border-radius: var(--r-ctl); font-weight: 600; font-size: 1rem; border: 1px solid transparent;
  background: var(--primary); color: var(--on-primary); transition: background .15s, transform .1s; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--primary-hover); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn.secondary { background: transparent; color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.ghost { background: transparent; color: var(--primary-text); padding: 0 12px; }
.btn.ghost:hover { background: var(--primary-tint); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--border); }
.btn.sm { height: 36px; padding: 0 14px; font-size: .875rem; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.iconbtn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--text-2); flex: none; }
.iconbtn:hover { background: var(--surface-2); color: var(--text); }
.iconbtn.sm { width: 36px; height: 36px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2); font-size: .8125rem; font-weight: 500; border: 1px solid transparent; white-space: nowrap;
}
button.chip:hover { background: var(--border); }
.chip.on, .chip[aria-pressed="true"] { background: var(--primary-tint); color: var(--primary-text); font-weight: 600; }
.chip.tint { background: var(--primary-tint); color: var(--primary-text); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; max-width: 100%; }
.seg button { height: 34px; padding: 0 14px; border-radius: 9px; font-size: .875rem; font-weight: 500; color: var(--text-2); white-space: nowrap; flex: 1; }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-1); }
:root[data-theme="dark"] .seg button[aria-pressed="true"], :root[data-theme="dark"] .seg button[aria-selected="true"] { background: var(--border); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .seg button[aria-pressed="true"], :root:not([data-theme="light"]) .seg button[aria-selected="true"] { background: var(--border); } }

.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.ok { background: var(--success-bg); color: var(--success); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .field > label { font-size: .8125rem; font-weight: 500; color: var(--text-2); }
.input, select.input, textarea.input {
  width: 100%; height: 48px; padding: 0 14px; border-radius: var(--r-ctl); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 1rem; /* 16px: no zoom on focus */
  appearance: none; -webkit-appearance: none;
}
select.input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238EA199' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.input::placeholder { color: var(--text-3); opacity: 1; }
.input:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
.input.err { border-color: var(--danger); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.hint { font-size: .8125rem; color: var(--text-3); }
.errtext { font-size: .8125rem; color: var(--danger); }

.check {
  width: 48px; height: 48px; flex: none; display: grid; place-items: center; margin: -10px -8px -10px 0; border-radius: 50%;
}
.check .box {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--dot); display: grid; place-items: center; color: transparent;
  transition: background .15s, border-color .15s, transform .15s;
}
.check:hover .box { border-color: var(--primary); }
.check[aria-checked="true"] .box { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.check.pop .box { animation: pop .18s ease-out; }
@keyframes pop { 0% { transform: scale(1.18); } 100% { transform: scale(1); } }
.check.sq .box { border-radius: 8px; }

/* ---------- today ---------- */
.daystrip { display: flex; gap: 6px; margin: 0 -4px 12px; }
.daystrip button {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px;
  border-radius: 14px; color: var(--text-2); font-size: .6875rem; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; position: relative;
}
.daystrip button b { font-size: 1rem; font-weight: 600; color: var(--text); letter-spacing: 0; text-transform: none; }
.daystrip button:hover { background: var(--surface-2); }
.daystrip button[aria-current="date"] { background: var(--primary); color: var(--on-primary); }
.daystrip button[aria-current="date"] b { color: var(--on-primary); }
.daystrip button.future { opacity: .55; }
.daystrip button.today::after { content: ""; position: absolute; bottom: 3px; width: 4px; height: 4px; border-radius: 50%; background: var(--primary); }
.daystrip button[aria-current="date"].today::after { background: var(--on-primary); }
.daynav { display: flex; align-items: center; gap: 4px; }
.jump { position: fixed; z-index: 20; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); box-shadow: var(--shadow-3); }
@media (min-width: 1024px) { .jump { bottom: 28px; } }

.hero { display: flex; flex-direction: column; gap: 18px; }
.hero-top { display: flex; align-items: center; gap: 20px; }
.ring { position: relative; width: 148px; height: 148px; flex: none; cursor: pointer; border-radius: 50%; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring .rtrack { stroke: var(--surface-2); }
.ring .arc { stroke: var(--kcal); transition: stroke-dashoffset .6s ease-out; }
.ring .arc.over { stroke: var(--warn); }
.ring .center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ring .big { font-size: 2.25rem; line-height: 1.1; font-weight: 700; letter-spacing: -.03em; }
.ring .big.over { color: var(--warn); font-size: 1.75rem; }
.ring .lbl { font-size: .75rem; color: var(--text-2); font-weight: 500; margin-top: 2px; }
.hero-stats { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.stat-line { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: .875rem; color: var(--text-2); }
.stat-line b { color: var(--text); font-weight: 600; }
.bars { display: flex; flex-direction: column; gap: 12px; }
.mbar .top { display: flex; align-items: center; gap: 8px; font-size: .875rem; margin-bottom: 6px; }
.mbar .top .nm { font-weight: 500; flex: 1; display: flex; align-items: center; gap: 8px; }
.mbar .top .val { color: var(--text-2); }
.mbar .top .val b { color: var(--text); font-weight: 600; }
.dotl { width: 20px; height: 20px; border-radius: 6px; display: inline-grid; place-items: center; font-size: .6875rem; font-weight: 700; flex: none; }
.dotl.p { background: var(--protein-bg); color: var(--protein); }
.dotl.c { background: var(--carbs-bg); color: var(--carbs); }
.dotl.f { background: var(--fat-bg); color: var(--fat); }
.dotl.k { background: var(--kcal-bg); color: var(--kcal); }
.track { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; position: relative; }
.track i { display: block; height: 100%; border-radius: 999px; width: 0; transition: width .5s ease-out; }
.track i.p { background: var(--protein); } .track i.c { background: var(--carbs); } .track i.f { background: var(--fat); } .track i.k { background: var(--kcal); }
.track i.over { background-image: repeating-linear-gradient(135deg, transparent 0 5px, rgba(255,255,255,.28) 5px 8px); }
.pc { color: var(--protein); font-weight: 600; } .cc { color: var(--carbs); font-weight: 600; } .fc { color: var(--fat); font-weight: 600; }

.note-card { display: flex; gap: 12px; background: var(--primary-tint); border-color: transparent; box-shadow: none; }
.note-card .ic { width: 32px; height: 32px; border-radius: 10px; background: var(--surface); color: var(--primary-text); display: grid; place-items: center; flex: none; }
.note-card p { font-size: .9375rem; }
.note-card .by { font-size: .75rem; color: var(--text-2); margin-top: 4px; }

.slots { display: flex; flex-direction: column; gap: 10px; }
.meal {
  display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 12px; min-height: 76px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-1); position: relative;
  transition: opacity .2s, border-color .2s;
}
.meal .thumb { width: 52px; height: 52px; border-radius: 14px; flex: none; display: grid; place-items: center; color: var(--primary-text); background: var(--primary-tint); }
.meal .body { flex: 1; min-width: 0; text-align: left; display: block; }
.meal .slotname { font-size: .6875rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); display: flex; gap: 8px; }
.meal .title { font-weight: 600; line-height: 1.3; margin: 1px 0 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meal .meta { font-size: .8125rem; color: var(--text-2); display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: center; }
.meal .meta .m { white-space: nowrap; }
.meal .acts { display: flex; align-items: center; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.meal.done .title, .meal.swapped .title { opacity: .72; }
.meal.skipped { border-style: dashed; background: transparent; box-shadow: none; }
.meal.skipped .title, .meal.skipped .thumb { opacity: .55; }
.meal.flash { animation: flash 1s ease-out; }
@keyframes flash { 0% { background: var(--primary-tint); } 100% { background: var(--surface); } }
.lnk { color: var(--primary-text); font-weight: 600; font-size: .8125rem; display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 10px; border-radius: 999px; }
.lnk:hover { background: var(--primary-tint); text-decoration: none; }
.lnk.muted { color: var(--text-2); }
.lnk.muted:hover { background: var(--surface-2); }

.intake { display: flex; align-items: center; gap: 12px; padding: 12px 8px 12px 14px; border-bottom: 1px solid var(--border); }
.intake:last-child { border-bottom: 0; }
.intake img.ph { width: 44px; height: 44px; border-radius: 12px; object-fit: cover; flex: none; background: var(--surface-2); }
.intake .t { font-weight: 500; }
.approx { color: var(--warn); font-weight: 700; }

.empty { text-align: center; padding: 36px 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty svg.art { width: 120px; height: 84px; margin-bottom: 4px; }
.empty h3 { font-size: 1.0625rem; font-weight: 600; }
.empty p { color: var(--text-2); font-size: .9375rem; max-width: 34ch; }
.empty .btn { margin-top: 8px; }

/* weight stepper */
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper .iconbtn { border: 1px solid var(--border); width: 48px; height: 48px; background: var(--surface); color: var(--text); }
.stepper .iconbtn:active { background: var(--primary-tint); }
.stepper .val { flex: 1; text-align: center; font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; }
.stepper .val input { width: 100%; text-align: center; border: 0; background: transparent; font-size: 1.75rem; font-weight: 700; height: 48px; letter-spacing: -.02em; border-radius: 12px; }
.stepper .val input:focus { outline: 2px solid var(--focus); }
.stepper .val small { font-size: 1rem; color: var(--text-2); font-weight: 500; letter-spacing: 0; margin-left: 2px; }

/* ---------- sheets / toasts ---------- */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 100; opacity: 0; transition: opacity .2s; }
.scrim.in { opacity: 1; }
.sheet {
  position: fixed; z-index: 101; left: 0; right: 0; bottom: 0; max-height: 88dvh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--r-sheet) var(--r-sheet) 0 0; box-shadow: var(--shadow-3);
  transform: translateY(100%); transition: transform .26s cubic-bezier(.2,.8,.2,1);
  padding-bottom: env(safe-area-inset-bottom); overscroll-behavior: contain;
}
:root[data-theme="dark"] .sheet { border: 1px solid var(--border); border-bottom: 0; }
.sheet.in { transform: none; }
.sheet .handle { width: 36px; height: 4px; border-radius: 4px; background: var(--border); margin: 10px auto 2px; flex: none; }
.sheet .sh-head { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 20px; flex: none; }
.sheet .sh-head h2 { flex: 1; font-size: 1.125rem; font-weight: 600; }
.sheet .sh-body { overflow-y: auto; padding: 8px 20px 20px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sheet .sh-foot { padding: 12px 20px 16px; border-top: 1px solid var(--border); display: flex; gap: 10px; flex: none; }
.sheet .sh-foot .btn { flex: 1; }
@media (min-width: 640px) {
  .sheet { left: 50%; right: auto; width: 480px; bottom: auto; top: 50%; border-radius: 20px; transform: translate(-50%, -46%); opacity: 0; transition: transform .22s ease-out, opacity .2s; max-height: min(88dvh, 760px); padding-bottom: 0; }
  .sheet.in { transform: translate(-50%, -50%); opacity: 1; }
  .sheet .handle { display: none; }
  .sheet .sh-head { padding-top: 14px; }
}
.opt { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); margin-bottom: 8px; min-height: 64px; }
.opt:hover { border-color: var(--primary); }
.opt[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-tint); }
.opt .radio { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--dot); flex: none; display: grid; place-items: center; }
.opt[aria-pressed="true"] .radio { border-color: var(--primary); background: var(--primary); color: var(--on-primary); }
.deltas { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.delta { font-size: .75rem; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.delta.flash { animation: dflash .9s ease-out 1; }
@keyframes dflash { 0% { background: var(--primary-tint); color: var(--primary-text); } 100% { } }

.toasts { position: fixed; z-index: 200; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px); display: flex; justify-content: center; pointer-events: none; padding: 0 16px; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; max-width: 460px; width: max-content;
  background: var(--toast-bg); color: var(--toast-text); border-radius: 12px; padding: 12px 12px 12px 16px; font-size: .9375rem; font-weight: 500;
  box-shadow: var(--shadow-3); animation: toastin .22s ease-out;
}
.toast button { color: inherit; font-weight: 700; padding: 6px 10px; border-radius: 8px; text-decoration: underline; text-underline-offset: 3px; }
.toast.err { background: var(--danger); color: #fff; }
:root[data-theme="dark"] .toast.err { color: #1f0b09; }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } }
@media (min-width: 1024px) { .toasts { bottom: 24px; left: 240px; justify-content: flex-start; padding-left: 24px; } .app.rail ~ .toasts { left: 72px; } }

.skel { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; border-radius: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- plan ---------- */
.daytabs { display: flex; gap: 6px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 calc(var(--gutter) * -1) 12px; padding: 2px var(--gutter); scrollbar-width: none; }
.daytabs::-webkit-scrollbar { display: none; }
.daytabs button { scroll-snap-align: center; flex: 1 0 auto; min-width: 48px; padding: 8px 10px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: .6875rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); font-weight: 500; }
.daytabs button b { font-size: 1rem; color: var(--text); text-transform: none; letter-spacing: 0; }
.daytabs button[aria-selected="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.daytabs button[aria-selected="true"] b { color: var(--on-primary); }
.totals-chip { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: .875rem; color: var(--text-2); margin-bottom: 12px; }
.totals-chip b { color: var(--text); font-weight: 700; font-size: 1rem; }
.pmeal { display: block; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 14px; box-shadow: var(--shadow-1); text-decoration: none; color: inherit; }
.pmeal:hover { border-color: var(--primary); text-decoration: none; }
.pmeal.sel { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-tint); }
.pmeal .title { font-weight: 600; line-height: 1.3; margin: 2px 0 4px; }
.pmeal .meta { font-size: .8125rem; color: var(--text-2); }

.weekgrid { display: grid; grid-template-columns: 84px repeat(7, minmax(0, 1fr)); gap: 6px; align-items: stretch; min-width: 0; }
.weekgrid .colhead { text-align: center; padding: 8px 4px; border-radius: 12px; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); font-weight: 500; }
.weekgrid .colhead b { display: block; font-size: 1.125rem; color: var(--text); text-transform: none; letter-spacing: 0; }
.weekgrid .colhead.today { background: var(--primary); color: var(--on-primary); }
.weekgrid .colhead.today b { color: var(--on-primary); }
.weekgrid .rowhead { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); padding-top: 12px; }
.weekgrid .rowhead small { display: block; font-weight: 500; letter-spacing: 0; text-transform: none; font-size: .75rem; }
.weekgrid .cell { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px; text-align: left; font-size: .8125rem; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.weekgrid button.cell:hover { border-color: var(--primary); }
.weekgrid .cell.sel { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-tint); }
.weekgrid .cell .t { font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.weekgrid .cell .k { color: var(--text-2); font-size: .75rem; }
.weekgrid .sumrow { font-size: .75rem; text-align: center; color: var(--text-2); padding: 4px 0; }
.plan-layout { display: grid; gap: var(--gap); }
@media (min-width: 1024px) { .plan-layout.has-panel { grid-template-columns: minmax(0, 1fr) 400px; } .panel { position: sticky; top: 16px; max-height: calc(100dvh - 32px); overflow-y: auto; } }

.rhero { border-radius: var(--r-card); padding: 20px; color: #fff; position: relative; overflow: hidden; min-height: 132px; display: flex; flex-direction: column; justify-content: flex-end; gap: 10px; }
.rhero svg.pat { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .16; }
.rhero h1, .rhero h2 { position: relative; font-size: 1.375rem; line-height: 1.25; font-weight: 700; letter-spacing: -.01em; text-wrap: balance; }
.rhero .tags { position: relative; display: flex; gap: 6px; flex-wrap: wrap; }
.rhero .tags span { background: rgba(255,255,255,.2); border-radius: 999px; padding: 2px 10px; font-size: .75rem; font-weight: 600; }
.mchips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mchip { border-radius: 12px; padding: 8px 6px; text-align: center; }
.mchip b { display: block; font-size: 1.0625rem; font-weight: 700; }
.mchip span { font-size: .6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.mchip.k { background: var(--kcal-bg); color: var(--kcal); } .mchip.p { background: var(--protein-bg); color: var(--protein); }
.mchip.c { background: var(--carbs-bg); color: var(--carbs); } .mchip.f { background: var(--fat-bg); color: var(--fat); }
.ing { display: flex; align-items: baseline; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.ing:last-child { border-bottom: 0; }
.ing .g { width: 64px; text-align: right; font-weight: 600; flex: none; }
.ing .k { font-size: .8125rem; color: var(--text-3); }
ol.steps { margin: 0; padding: 0; list-style: none; counter-reset: s; display: flex; flex-direction: column; gap: 14px; }
ol.steps li { counter-increment: s; display: flex; gap: 12px; }
ol.steps li::before { content: counter(s); flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--primary-tint); color: var(--primary-text); font-weight: 700; font-size: .8125rem; display: grid; place-items: center; margin-top: 1px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 4px 0 8px; }
.tabs button { padding: 10px 14px; font-weight: 500; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--primary-text); border-color: var(--primary); font-weight: 600; }

/* ---------- progress ---------- */
.chart-wrap { position: relative; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart-wrap svg { width: 100%; height: auto; overflow: visible; cursor: crosshair; }
.chart text { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.chart .grid-l { stroke: var(--grid); stroke-width: 1; }
.chart .dot { fill: var(--dot); }
.chart .trend { fill: none; stroke: var(--trend); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .goal { stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 5 5; }
.chart text.goal-t { fill: var(--warn); font-weight: 600; }
.chart .off { display: none; }
.chart .dot.scrub { fill: var(--text-2); }
.chart .cross { stroke: var(--text-3); stroke-width: 1; }
.chart .hot { fill: var(--surface); stroke: var(--trend); stroke-width: 2.5; }
.chart .area { fill: var(--trend); opacity: .08; }
.readout { display: flex; flex-wrap: wrap; gap: 4px 16px; min-height: 40px; align-items: baseline; margin-bottom: 8px; font-size: .875rem; color: var(--text-2); }
.readout b { color: var(--text); font-weight: 700; font-size: 1.0625rem; }
.bigweight { font-size: 2.5rem; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; }
.bigweight small { font-size: 1.125rem; font-weight: 500; color: var(--text-2); letter-spacing: 0; margin-left: 4px; }
.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi .v { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.kpi .v small { font-size: .9375rem; font-weight: 500; color: var(--text-2); letter-spacing: 0; }
.msm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.msm { background: var(--surface-2); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.msm .v { font-size: 1.25rem; font-weight: 700; }
.msm .v small { font-size: .8125rem; color: var(--text-2); font-weight: 500; }
.msm svg { width: 100%; height: 36px; margin-top: 6px; overflow: visible; }
.msm path { fill: none; stroke: var(--primary-text); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.msm circle { fill: var(--primary-text); }
.heat-scroll { overflow-x: auto; padding: 3px 4px 4px 0; scrollbar-width: thin; }
.heat { display: inline-grid; grid-auto-flow: column; grid-template-rows: repeat(7, var(--cell)); grid-auto-columns: var(--cell); gap: 3px; --cell: 14px; }
.heat-wrap { display: flex; gap: 6px; }
.heat-days { display: grid; grid-template-rows: repeat(7, var(--cell, 14px)); gap: 3px; font-size: 10px; color: var(--text-3); font-weight: 500; align-items: center; margin-top: 18px; --cell: 14px; flex: none; width: 14px; }
@media (min-width: 1024px) { .heat, .heat-days { --cell: 18px; } .heat-days { font-size: 11px; } }
.heat button, .heat i { border-radius: 4px; background: var(--h0); display: block; width: var(--cell); height: var(--cell); }
.heat i.none { background: transparent; }
.heat .l1 { background: var(--h1); } .heat .l2 { background: var(--h2); } .heat .l3 { background: var(--h3); } .heat .l4 { background: var(--h4); }
.heat button.today { outline: 2px solid var(--primary-text); outline-offset: 1px; }
.heat button.sel { outline: 2px solid var(--text); outline-offset: 1px; }
.heat-months { display: grid; grid-auto-flow: column; grid-auto-columns: var(--cell, 14px); gap: 3px; font-size: 10px; color: var(--text-3); font-weight: 500; height: 16px; margin-bottom: 2px; --cell: 14px; }
.heat-months span { white-space: nowrap; overflow: visible; }
@media (min-width: 1024px) { .heat-months { --cell: 18px; font-size: 11px; } }
.legend { display: flex; align-items: center; gap: 4px; font-size: .75rem; color: var(--text-3); }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: block; }

/* ---------- shopping ---------- */
.aisle { margin-bottom: var(--gap); break-inside: avoid; }
.aisle-head { display: flex; align-items: center; gap: 10px; width: 100%; padding: 14px var(--card-pad); text-align: left; font-weight: 600; position: sticky; top: 0; background: var(--surface); z-index: 2; }
.aisle-head .cnt { font-weight: 500; color: var(--text-2); font-size: .8125rem; margin-left: auto; }
.aisle-head svg.chev { transition: transform .2s; color: var(--text-3); flex: none; }
.aisle.closed .aisle-head svg.chev { transform: rotate(-90deg); }
.aisle.closed .aisle-rows { display: none; }
.srow { display: flex; align-items: center; gap: 12px; padding: 10px var(--card-pad); min-height: 60px; border-top: 1px solid var(--border); }
.srow .nm { font-weight: 500; line-height: 1.3; }
.srow .sub { font-size: .8125rem; color: var(--text-2); }
.srow.bought .nm { text-decoration: line-through; color: var(--text-3); }
.srow .expand { text-align: left; flex: 1; min-width: 0; display: block; }
.srow .why { font-size: .8125rem; color: var(--text-2); margin-top: 6px; }
.masonry { column-gap: var(--gap); }
@media (min-width: 640px) { .masonry { columns: 2; } }
@media (min-width: 1024px) { .masonry { columns: 3; } }
.stickybar { position: fixed; z-index: 25; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 10px); display: flex; justify-content: center; padding: 0 16px; pointer-events: none; }
.stickybar .btn { pointer-events: auto; box-shadow: var(--shadow-3); min-width: 220px; }
@media (min-width: 1024px) { .stickybar { bottom: 24px; left: 240px; } }

/* ---------- coach ---------- */
.feed { display: flex; flex-direction: column; gap: 10px; }
.day-h { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); margin: 14px 2px 2px; }
.change { display: flex; gap: 12px; }
.change .ic { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--primary-tint); color: var(--primary-text); }
.change .ic.app { background: var(--info-bg); color: var(--info); }
.change .ic.system { background: var(--surface-2); color: var(--text-2); }
.change .tt { font-weight: 600; line-height: 1.35; }
.change .why { font-size: .875rem; color: var(--text-2); margin-top: 3px; }
.change .why b { color: var(--text); font-weight: 600; }
.change .meta { font-size: .75rem; color: var(--text-3); margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.diff { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.diff span { background: var(--surface-2); border-radius: 8px; font-size: .75rem; padding: 3px 8px; color: var(--text-2); }
.diff span b { color: var(--text); font-weight: 600; }
.diff .arrow { color: var(--text-3); padding: 0 3px; }
.change.reverted .tt { text-decoration: line-through; text-decoration-color: var(--text-3); color: var(--text-2); }
.narrow { max-width: 720px; }
.coach-layout { display: grid; gap: var(--gap); }
@media (min-width: 1024px) { .coach-layout { grid-template-columns: minmax(0, 720px) 320px; justify-content: center; } }

/* ---------- settings ---------- */
.set-layout { display: grid; gap: var(--gap); }
.subnav { display: none; }
@media (min-width: 1024px) {
  .set-layout { grid-template-columns: 220px minmax(0, 640px); }
  .subnav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 16px; align-self: start; }
  .subnav a { padding: 10px 12px; border-radius: 10px; color: var(--text-2); font-weight: 500; font-size: .9375rem; }
  .subnav a:hover { background: var(--surface-2); text-decoration: none; }
}
.set-sec { scroll-margin-top: 16px; }
.set-sec > h2 { margin: 6px 2px 10px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: .9375rem; }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--text-2); }
.suggest { background: var(--primary-tint); border-radius: 14px; padding: 14px; margin-top: 12px; }

/* ---------- more (phone) ---------- */
.menu a { display: flex; align-items: center; gap: 14px; padding: 16px var(--card-pad); color: var(--text); font-weight: 600; text-decoration: none; border-bottom: 1px solid var(--border); }
.menu a:last-child { border-bottom: 0; }
.menu a .ic { width: 40px; height: 40px; border-radius: 12px; background: var(--primary-tint); color: var(--primary-text); display: grid; place-items: center; }
.menu a small { display: block; font-weight: 400; color: var(--text-2); font-size: .875rem; }

/* ---------- splash / setup / error ---------- */
.fullscreen { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: calc(env(safe-area-inset-top) + 24px) 24px calc(env(safe-area-inset-bottom) + 24px); gap: 14px; background: var(--bg); }
.fullscreen .logo { width: 84px; height: 84px; border-radius: 24px; box-shadow: var(--shadow-2); }
.fullscreen h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; }
.fullscreen p { color: var(--text-2); max-width: 36ch; }
.fullscreen .card { width: 100%; max-width: 420px; text-align: left; display: flex; flex-direction: column; gap: 14px; }
.splash .logo { animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(.94); opacity: .85; } }
.splash .ts { font-size: .9375rem; color: var(--text-3); opacity: 0; transition: opacity .6s, transform .5s; margin-top: 10px; display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 999px; }
.splash .ts.show { opacity: 1; color: var(--warn); background: var(--warn-bg); font-weight: 600; }
.errstate .art { width: 96px; height: 96px; border-radius: 50%; background: var(--warn-bg); color: var(--warn); display: grid; place-items: center; }
.errstate h1 { font-size: 1.5rem; max-width: 24ch; text-wrap: balance; }
.errstate .steps { display: flex; flex-direction: column; gap: 6px; text-align: left; font-size: .9375rem; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; max-width: 360px; }
.inline-error { padding: 48px 16px; }

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

/* today layout: phone = one column in the order note, hero, meals, intake, weight; desktop = 2 columns */
.tg { display: flex; flex-direction: column; gap: var(--gap); }
.tg .L, .tg .R { display: contents; }
.tg .o1 { order: 1; } .tg .o2 { order: 2; } .tg .o3 { order: 3; } .tg .o4 { order: 4; } .tg .o5 { order: 5; }
.tg .b-note { order: 0; } .tg .b-hero { order: 1; } .tg .b-meals { order: 2; } .tg .b-intake { order: 3; } .tg .b-weight { order: 4; }
@media (min-width: 1024px) {
  .tg { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; gap: var(--gap); }
  .tg .L, .tg .R { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
  .tg.pg { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
  .tg .section-title:first-child { margin-top: 0; }
  .hero-top { gap: 28px; }
  .ring .big { font-size: 2.75rem; }
}
.rail-card { align-self: start; }
@media (max-width: 1023px) { .rail-card { display: none; } }
.meta { font-size: .8125rem; color: var(--text-2); display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: center; }
.meta .m { white-space: nowrap; }
.note-card .iconbtn { background: transparent; }
@media (min-width: 1024px) { .daystrip { max-width: 640px; } }
.srow .check { margin-right: -4px; }

.ico { flex: none; }
.nojs { padding: 24px; font-family: sans-serif; }
.acct { display: block; font-size: .75rem; font-weight: 500; color: var(--text-3); margin-top: 2px; }
