/* TrackR — premium mobile app design system */
:root {
  --bg: #EEE8DC;
  --bg-2: #FFFDF8;
  --bg-3: #F8F2E8;
  --forest: #2D4F3E;
  --forest-dk: #1E3A2C;
  --forest-lt: #4F8065;
  --ink: #171511;
  --ink-2: #3F3A32;
  --ink-3: #7A7368;
  --line: rgba(23,21,17,0.08);
  --line-2: rgba(23,21,17,0.14);
  --orange: #D9672E;
  --orange-dk: #B84E1E;
  --orange-soft: rgba(217,103,46,0.10);
  --orange-ring: rgba(217,103,46,0.24);
  --green: var(--forest-lt);
  --green-dk: var(--forest);
  --green-soft: rgba(45,79,62,0.11);
  --green-ring: rgba(45,79,62,0.26);
  --p: #3F7A5B;
  --c: #C89B3C;
  --f: #8F6B3C;
  --p-soft: rgba(63,122,91,0.13);
  --c-soft: rgba(200,155,60,0.14);
  --f-soft: rgba(143,107,60,0.14);
  --err: #B23B2B;
  --err-bg: rgba(178,59,43,0.08);
  --ok-bg: rgba(45,79,62,0.10);
  --focus-ring: rgba(45,79,62,0.22);
  --tier-green: #2F9D63;
  --tier-amber: #D98324;
  --tier-amber-txt: #C2710A;
  --tier-red: #B3362A;
  --shadow-sm: 0 1px 2px rgba(23,21,17,0.05), 0 6px 18px rgba(23,21,17,0.04);
  --shadow-md: 0 12px 32px rgba(23,21,17,0.08);
  --radius: 12px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font-family: "Fraunces", Georgia, serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  min-height: 100vh; min-height: 100dvh; padding-bottom: env(safe-area-inset-bottom);
  letter-spacing: -0.005em;
  overscroll-behavior-x: none;
}
a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--forest-lt); }
button { font-family: inherit; cursor: pointer; }
button, a, input, select, textarea { touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }

/* Sans for UI chrome / numbers — same stack the LeanR website uses for nav */
.brand, .topnav, .navlink, .btn-primary, .btn-ghost, .meal-add, .meal-routine-btn, .badge,
.label, .field input, .field select, .field textarea, .search-input,
.entry-meta, .totals-num, .totals-lbl, .mb-lbl, .mb-num, .meal-sub,
.rr-name, .rr-sub, .prev-kcal, .prev-macros, .preview, .alert,
.history-meta, .empty, .entry-name, .entry-brand, .dn-date, .dn-sub,
.section-h, .totals-target, .auth-h, .auth-foot, .auth-brand, .log-meal, .log-date {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  letter-spacing: -0.005em;
}

/* Top bar */
.topbar { background: rgba(250,250,247,0.94); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50;
  padding-top: env(safe-area-inset-top); }
.topbar-inner { max-width: 760px; margin: 0 auto; padding: 12px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { font-weight: 700; letter-spacing: -0.02em; font-size: 18px; color: var(--ink); }
.brand-accent { color: var(--orange); font-style: italic; font-weight: 600; }
.topnav { display: flex; gap: 18px; align-items: center; }
.navlink { font-size: 14px; color: var(--ink-3); font-weight: 500; }
.navlink:hover { color: var(--ink); }
.navlink.subtle { color: var(--ink-3); }

/* Main */
.main { max-width: 760px; margin: 0 auto; }
.page-pad { padding: 16px 18px 28px; }
.section-h { font-family: "Fraunces", Georgia, serif;
  font-size: 22px; font-weight: 600; margin: 22px 0 10px; letter-spacing: -0.02em; color: var(--ink); }

/* Auth */
.auth-body { background: var(--bg); min-height: 100vh; }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 28px 22px; }
.auth-card { width: 100%; max-width: 380px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 30px 26px; }
.auth-brand { font-size: 17px; font-weight: 600; margin-bottom: 18px; color: var(--ink); }
.auth-h { font-family: "Fraunces", Georgia, serif; font-size: 26px; font-weight: 600;
  margin: 0 0 16px; letter-spacing: -0.02em; }
.auth-foot { margin: 16px 0 0; font-size: 14px; color: var(--ink-3); text-align: center; }
.auth-foot a { color: var(--forest); font-weight: 600; }
.welcome-shell { align-items: center; }
.welcome-card { width: 100%; max-width: 420px; padding: 34px 26px; }
.welcome-h { font-family: "Fraunces", Georgia, serif; font-size: 32px; line-height: 1.02;
  font-weight: 600; margin: 0 0 14px; color: var(--ink); }
.welcome-sub { color: var(--ink-3); font-size: 15px; line-height: 1.48; margin: 0 0 20px; }
.welcome-actions { display: grid; gap: 8px; }

/* Forms */
input, select, textarea { font-size: 16px !important; }
.field { display: block; margin: 12px 0; }
.field .label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-3); margin-bottom: 6px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; background: var(--bg-3); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: 10px; font-size: 16px;
  outline: none; -webkit-appearance: none; appearance: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--forest); box-shadow: 0 0 0 3px var(--focus-ring); }
.field .hint { display: block; font-size: 12px; color: var(--ink-3); margin-top: 5px; }
.btn-primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--forest); color: #fff; border: 0; padding: 13px 18px; border-radius: 10px;
  font-weight: 600; font-size: 15px; width: 100%; margin-top: 10px;
  min-height: 44px; transition: background 120ms ease, transform 120ms ease; }
.btn-primary:hover { background: var(--forest-dk); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink-2); border: 1px solid var(--line-2);
  padding: 11px 14px; border-radius: 10px; font-size: 14px; width: 100%; margin-top: 16px;
  font-weight: 500; transition: background 120ms ease; }
.btn-ghost:hover { background: var(--bg-2); color: var(--ink); }
.alert { padding: 10px 14px; border-radius: 10px; font-size: 13px; margin: 8px 0;
  border: 1px solid transparent; }
.alert.err { background: var(--err-bg); color: var(--err); border-color: rgba(179,48,32,0.20); }
.alert.ok { background: var(--ok-bg); color: var(--green-dk); border-color: var(--green-ring); }
.alert.warn { background: rgba(232,93,31,0.08); color: var(--orange-dk, #C94D15); border-color: rgba(232,93,31,0.25); }

/* Coach-locked pill (TrackR for LeanR members) */
.coach-pill { display: flex; align-items: center; gap: 10px; padding: 12px 14px; margin: 6px 0 14px;
  background: var(--ok-bg, rgba(63,107,84,0.08)); color: var(--green-dk, #2D4F3E);
  border: 1px solid var(--green-ring, rgba(63,107,84,0.25)); border-radius: 12px; font-size: 13px; }
.coach-pill-ico { color: var(--green-dk, #3F6B54); font-size: 16px; line-height: 1; }
.coach-pill-text strong { font-weight: 600; }
.form-locked input[readonly] { background: rgba(15,15,15,0.03); color: var(--ink-2); cursor: not-allowed; }
.form-locked { opacity: 0.96; }

/* Weekly check-in */
.checkin-dashboard-page { padding-bottom: calc(148px + env(safe-area-inset-bottom)); }
.checkin-hero { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 18px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 20px 18px; margin: 4px 0 12px; box-shadow: var(--shadow-sm); }
.checkin-kicker { font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  color: var(--forest); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 700; margin-bottom: 6px; }
.checkin-hero h1 { font-family: "Fraunces", Georgia, serif; font-size: 34px; line-height: 1;
  font-weight: 600; letter-spacing: -0.025em; margin: 0; color: var(--ink); }
.checkin-hero p { font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  color: var(--ink-3); font-size: 13px; line-height: 1.45; margin: 8px 0 0; max-width: 420px; }
.checkin-hero-target { min-width: 94px; min-height: 94px; border: 1px solid var(--green-ring);
  border-radius: 999px; background: var(--green-soft); display: grid; place-items: center;
  align-content: center; color: var(--forest); }
.checkin-hero-target span { font-family: "Fraunces", Georgia, serif; font-size: 30px; line-height: 1;
  font-weight: 600; font-variant-numeric: tabular-nums; }
.checkin-hero-target small { font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  display: block; margin-top: 5px; color: var(--ink-3); font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.06em; font-weight: 700; }
.checkin-readiness { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 10px;
  margin-bottom: 12px; }
.readiness-item { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 10px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg-3); color: var(--ink-3); }
.readiness-item.ready { background: var(--ok-bg); border-color: var(--green-ring); color: var(--forest); }
.readiness-item b { display: block; color: var(--ink); font-size: 14px; line-height: 1.1;
  font-variant-numeric: tabular-nums; }
.readiness-item span { display: block; font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.checkin-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.checkin-section-head > span { font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  color: var(--forest); background: var(--green-soft); border: 1px solid var(--green-ring);
  border-radius: 999px; padding: 5px 9px; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.05em; font-weight: 700; white-space: nowrap; }
.checkin-section-head h3 { margin: 0; font-size: 14px; color: var(--ink); }
.checkin-form-card { margin-bottom: 12px; }
.checkin-form-card .btn-primary { margin-top: 2px; }
.checkin-summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 4px 0 12px; }
.checkin-stat-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 16px; box-shadow: var(--shadow-sm); min-width: 0; }
.checkin-stat-card span { display: block; color: var(--ink-3); font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.06em; font-weight: 800; font-family: -apple-system, BlinkMacSystemFont, "Inter", sans-serif; }
.checkin-stat-card strong { display: block; margin-top: 8px; color: var(--ink); font-size: 30px; line-height: 1;
  font-weight: 800; font-variant-numeric: tabular-nums; font-family: -apple-system, BlinkMacSystemFont, "Inter", sans-serif; }
.checkin-stat-card small { display: block; margin-top: 7px; color: var(--ink-3); font-size: 12px; font-weight: 700;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", sans-serif; }
.checkin-stat-card small.down { color: var(--forest); }
.checkin-stat-card small.up { color: var(--orange-dk); }
.checkin-target-card, .checkin-recommendation-summary { margin-bottom: 12px; }
.target-snapshot { display: grid; gap: 6px; margin-top: 10px; padding: 14px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--bg-3); font-family: -apple-system, BlinkMacSystemFont, "Inter", sans-serif; }
.target-snapshot strong { font-size: 28px; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.target-snapshot span { font-size: 13px; color: var(--ink-2); font-weight: 700; font-variant-numeric: tabular-nums; }
.target-snapshot.recommended { border-color: var(--green-ring); background: var(--green-soft); }
.target-snapshot.recommended strong { color: var(--forest-dk); }
.checkin-submit-launch { position: fixed; left: 50%; bottom: calc(72px + env(safe-area-inset-bottom));
  width: min(calc(100vw - 32px), 724px); min-height: 52px; margin: 0; transform: translateX(-50%);
  z-index: 58; font-size: 16px; box-shadow: 0 10px 28px rgba(30,58,44,0.24); }
.bf-summary { margin-bottom: 12px; }
.bf-current { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 10px; }
.bf-value { font-size: 34px; line-height: 1; font-weight: 800; letter-spacing: -0.02em;
  color: var(--forest-dk); font-variant-numeric: tabular-nums; }
.bf-sub { margin-top: 4px; color: var(--ink-3); font-size: 12px; }
.bf-trend { padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg-3); color: var(--ink-2); font-size: 12px; font-weight: 700;
  font-variant-numeric: tabular-nums; white-space: nowrap; }
.bf-trend.down { background: var(--ok-bg); border-color: var(--green-ring); color: var(--forest); }
.bf-trend.up { background: rgba(232,93,31,0.12); border-color: rgba(232,93,31,0.25); color: var(--orange-dk, #C94D15); }
.bf-history { margin-top: 10px; font-size: 13px; color: var(--ink-2); }
.bf-history summary { cursor: pointer; color: var(--forest); font-weight: 700; }
.bf-history-list { display: grid; gap: 6px; margin-top: 8px; }
.bf-history-list div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0;
  border-bottom: 1px solid var(--line); }
.checkin-photo-fieldset { border: 1px dashed var(--green-ring); }
.checkin-photo-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 12px 0; }
.checkin-photo-tile { display: grid; gap: 7px; cursor: pointer; min-width: 0; }
.checkin-photo-tile input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.photo-multi-trigger { display: flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 52px; border-radius: 12px; border: 1px solid var(--green-ring); background: var(--bg);
  color: var(--forest); font-weight: 800; cursor: pointer; font-family: -apple-system, BlinkMacSystemFont, "Inter", sans-serif; }
.photo-assignment { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.photo-tile { min-width: 0; display: grid; gap: 7px; }
.photo-tile-frame { display: grid; place-items: center; aspect-ratio: 3 / 4; max-height: 116px;
  border: 1px solid var(--green-ring); border-radius: 8px; background: var(--bg); color: var(--forest);
  overflow: hidden; }
.photo-tile-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-tile-caption { font-size: 11px; color: var(--forest); font-weight: 800; text-align: center;
  text-transform: uppercase; letter-spacing: 0.08em; font-family: -apple-system, BlinkMacSystemFont, "Inter", sans-serif; }
.autofill-tag { display: inline-block; margin-top: 5px; color: var(--forest); font-size: 12px; font-weight: 700; }
.photo-upload-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.photo-upload-actions .btn-ghost { display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  margin-top: 0; cursor: pointer; }
.photo-preview { margin-top: 8px; padding: 9px 10px; border: 1px solid var(--green-ring);
  border-radius: 8px; background: var(--bg); color: var(--forest); font-size: 12px; font-weight: 700; }
.rating-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 8px; }
.rating-row input { position: absolute; opacity: 0; pointer-events: none; }
.rating-row span { display: grid; place-items: center; min-height: 38px; border: 1px solid var(--line-2);
  border-radius: 8px; background: var(--bg); color: var(--ink-2); font-weight: 700; }
.rating-row input:checked + span { border-color: var(--forest); background: var(--green-soft); color: var(--forest-dk); }
.rating-labels { display: flex; justify-content: space-between; margin-top: 5px; font-size: 11px; color: var(--ink-3); }
.rating-row-feel { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.rating-row-feel span { min-height: 48px; padding: 7px 4px; gap: 2px; line-height: 1.1; }
.rating-row-feel b { display: block; font-size: 12px; font-weight: 700; }
.rating-row-feel small { display: block; font-size: 10px; color: var(--ink-3); font-weight: 600; }
.rating-row-feel input:checked + span small { color: var(--forest); }
.checkin-confirm { display: flex; align-items: flex-start; gap: 9px; margin: 12px 0;
  color: var(--ink-2); font-size: 13px; line-height: 1.35; }
.checkin-confirm input { margin-top: 2px; }
.bodyfat-ai-panel { margin-top: 14px; padding: 14px; border: 1px dashed var(--green-ring);
  border-radius: 8px; background: var(--green-soft); }
.compact-fields { gap: 8px 12px; }
.compact-fields .field { margin: 8px 0; }
.inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bodyfat-ai-panel .btn-primary { margin-top: 4px; }
.bodyfat-ai-panel .sub-help { margin-top: 8px; }
.kpi { padding: 10px 0; }
.kpi-label { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-val { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; }
.kpi-sub { font-size: 12px; color: var(--ink-3); margin-top: 1px; }
.checkin-reason { font-size: 14px; line-height: 1.55; margin: 4px 0 14px; color: var(--ink-2); }
.recommendation-card { box-shadow: var(--shadow-sm); border-color: var(--green-ring); }
.protein-adjust-note { margin: 10px 0 14px; padding: 12px; border: 1px solid var(--green-ring);
  border-radius: 8px; background: var(--green-soft); }
.protein-adjust-head { display: flex; align-items: center; gap: 8px; color: var(--forest-dk); }
.protein-adjust-note p { margin: 7px 0 9px; font-size: 13px; line-height: 1.45; color: var(--ink-2); }
.protein-adjust-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.protein-adjust-meta span { font-size: 11px; padding: 4px 7px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--line); color: var(--ink-3); }
.protein-adjust-detail { margin-top: 8px; font-size: 12px; line-height: 1.4; color: var(--ink-3); }
.rec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0 16px; }
.rec-cell { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "label label" "now arrow" "new new";
  align-items: center; gap: 4px 8px; padding: 12px; background: var(--bg-3);
  border: 1px solid var(--line); border-radius: 10px; }
.rec-label { grid-area: label; font-size: 13px; color: var(--ink-3); }
.rec-now { grid-area: now; font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.rec-arrow { grid-area: arrow; font-size: 14px; color: var(--ink-3); text-align: center; }
.rec-new { grid-area: new; font-size: 22px; line-height: 1.1; font-weight: 700; color: var(--forest);
  font-variant-numeric: tabular-nums; }
.checkin-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.checkin-actions .btn-primary, .checkin-actions .btn-ghost { margin-top: 0; }
.checkin-modify { margin-top: 12px; padding: 8px 0; border-top: 1px dashed var(--line); }
.checkin-modify summary { font-size: 14px; color: var(--forest); cursor: pointer; font-weight: 500; }
.checkin-skip-form { margin-top: 4px; }
.checkin-history-link { text-align: center; padding: 24px 0 10px; }
.checkin-history-link a { color: var(--ink-3); font-size: 13px; }
.checkin-row { display: block; padding: 12px 0; }
.checkin-row-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.checkin-row-body { font-size: 13px; color: var(--ink-2); }
.checkin-row-reason { font-size: 13px; color: var(--ink-3); margin-top: 4px; font-style: italic; }
.checkin-row-note { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.checkin-pill { font-size: 11px; padding: 2px 8px; border-radius: 10px; text-transform: uppercase;
  letter-spacing: 0.05em; font-weight: 600; }
.checkin-pill-accepted { background: var(--ok-bg); color: var(--green-dk); }
.checkin-pill-modified { background: rgba(232,93,31,0.12); color: var(--orange-dk, #C94D15); }
.checkin-pill-skipped { background: rgba(15,15,15,0.06); color: var(--ink-3); }
.checkin-pill-pending { background: rgba(232,93,31,0.18); color: var(--orange-dk, #C94D15); }
.checkin-history-photos { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; padding-bottom: 2px; }
.checkin-history-photos a { width: 74px; flex: 0 0 74px; text-decoration: none; color: var(--ink-3); font-size: 10px; }
.checkin-history-photos img { width: 74px; height: 92px; object-fit: cover; border-radius: 8px; display: block;
  background: var(--bg-3); border: 1px solid var(--line); }
.checkin-history-photos span { display: block; margin-top: 3px; text-align: center; text-transform: capitalize; }
.compact-history { margin-top: 4px; }
.checkin-modal { position: fixed; inset: 0; z-index: 1000; overflow: hidden; touch-action: none; }
.checkin-modal[hidden] { display: none; }
.checkin-modal-backdrop { position: absolute; inset: 0; border: 0; padding: 0; margin: 0;
  background: rgba(0,0,0,0.52); width: 100%; height: 100%; touch-action: none; }
.checkin-modal-content { position: fixed; left: 50%; right: auto; bottom: 0; width: min(100vw, 590px);
  max-width: 100vw; height: min(88dvh, 760px); max-height: calc(100dvh - env(safe-area-inset-top) - 12px);
  transform: translate3d(-50%, 0, 0); display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg-2); border: 1px solid rgba(255,255,255,0.56); border-bottom: 0;
  border-radius: 22px 22px 0 0; box-shadow: 0 -18px 54px rgba(23,21,17,0.24);
  animation: checkinSlideUp 0.22s ease-out; contain: layout paint; touch-action: pan-y; }
.checkin-modal-handle { flex: 0 0 auto; width: 42px; height: 4px; border-radius: 999px; background: var(--line-2); margin: 16px auto 10px; }
.checkin-modal-head { flex: 0 0 auto; display: flex; align-items: start; justify-content: space-between; gap: 12px;
  padding: 0 18px 12px; border-bottom: 1px solid var(--line); background: var(--bg-2); }
.checkin-modal-title { font-size: 24px; line-height: 1.1; margin: 0; letter-spacing: 0; }
.checkin-modal-subtitle { margin: 5px 0 0; color: var(--ink-3); font-size: 13px;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", sans-serif; }
.checkin-form-condensed { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden;
  padding: 14px 18px calc(20px + env(safe-area-inset-bottom)); overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.checkin-form-condensed fieldset { border: 0; margin: 0 0 14px; padding: 0; }
.checkin-form-condensed legend { color: var(--forest); font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.06em; font-weight: 800; font-family: -apple-system, BlinkMacSystemFont, "Inter", sans-serif; }
.checkin-form-condensed > .field,
.checkin-form-condensed > fieldset,
.checkin-form-condensed > .checkin-feel-field {
  padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg-2);
}
.checkin-form-condensed > .field { margin: 0 0 12px; }
.checkin-photo-fieldset.bodyfat-ai-panel { margin-top: 0; border-style: solid; box-shadow: 0 1px 0 rgba(23,21,17,0.03); }
.checkin-macros-compact { padding-top: 14px !important; border-top: 1px solid var(--line) !important; }
.checkin-modal-actions { position: sticky; bottom: calc(-20px - env(safe-area-inset-bottom)); display: grid;
  grid-template-columns: 0.8fr 1.2fr; gap: 10px; margin: 14px -18px calc(-20px - env(safe-area-inset-bottom));
  padding: 12px 18px calc(20px + env(safe-area-inset-bottom)); background: rgba(255,253,248,0.94);
  backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.checkin-modal-actions .btn-primary, .checkin-modal-actions .btn-ghost { margin-top: 0; }
body.modal-open { overflow: hidden; position: fixed; width: 100%; left: 0; right: 0; touch-action: none; }
@keyframes checkinSlideUp { from { transform: translate3d(-50%, 28px, 0); opacity: 0.88; } to { transform: translate3d(-50%, 0, 0); opacity: 1; } }
.result-card { padding: 22px 18px; }
.result-week { display: block; color: var(--forest); font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.08em; font-weight: 800; font-family: -apple-system, BlinkMacSystemFont, "Inter", sans-serif; }
.result-title { margin: 6px 0 18px; font-size: 34px; line-height: 1; letter-spacing: 0; }
.result-stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin-bottom: 14px; }
.result-stats-grid .stat { padding: 12px 9px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg-3); min-width: 0; }
.stat-label { display: block; color: var(--ink-3); font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.06em; font-weight: 800; font-family: -apple-system, BlinkMacSystemFont, "Inter", sans-serif; }
.stat-value { display: block; margin-top: 5px; font-size: 20px; font-weight: 800; color: var(--ink);
  font-variant-numeric: tabular-nums; font-family: -apple-system, BlinkMacSystemFont, "Inter", sans-serif; }
.stat-value.down { color: var(--forest); }
.result-recommendation { border: 1px solid var(--green-ring); border-radius: 14px; background: var(--green-soft);
  padding: 16px; margin-top: 10px; }
.rec-title { margin: 4px 0 8px; font-size: 28px; line-height: 1; color: var(--forest-dk); letter-spacing: 0; }
.rec-reasoning { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.5; }
.rec-targets-preview { margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--bg-2);
  border: 1px solid var(--green-ring); font-family: -apple-system, BlinkMacSystemFont, "Inter", sans-serif; }
.rec-targets-preview div:first-child { font-size: 26px; font-weight: 800; color: var(--forest-dk); line-height: 1; }
.rec-targets-preview div + div { margin-top: 6px; color: var(--ink-2); font-size: 13px; font-weight: 700; }
.result-actions { display: grid; gap: 10px; margin-top: 14px; }
.result-actions .btn-primary, .result-actions .btn-ghost { margin-top: 0; }
.result-modify summary { list-style: none; text-align: center; cursor: pointer; }
.result-modify summary::-webkit-details-marker { display: none; }
.result-modify .form-card { margin-top: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-3); }
.result-next { margin-top: 14px; text-align: center; color: var(--ink-3); font-size: 13px;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", sans-serif; }

/* "Check-in ready" banner on diary */
.checkin-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--forest); color: #fff; padding: 12px 14px; border-radius: 12px; margin: 10px 0 14px; }
.checkin-banner a { color: #fff; text-decoration: underline; font-weight: 600; }
.trial-ended-banner { align-items: flex-start; }
/* Free-tier house ad card (2026-07-29) */
.free-upsell-card { position: relative; margin-bottom: 14px; padding: 16px; }
.free-upsell-card .free-upsell-body { display: grid; gap: 8px; }
.free-upsell-card .free-upsell-body p { margin: 0; font-size: 14px; line-height: 1.45; color: var(--ink-2, #555); }
.free-upsell-card .btn-primary { justify-self: start; padding: 9px 18px; font-size: 14px; }
.free-upsell-dismiss { position: absolute; top: 8px; right: 10px; border: 0; background: transparent;
  font-size: 20px; line-height: 1; color: var(--ink-3, #999); cursor: pointer; padding: 4px; }
.trial-ended-actions { display: grid; gap: 6px; min-width: 0; }
.trial-ended-actions a:last-child { font-size: 13px; line-height: 1.25; opacity: .94; }

@media (max-width: 430px) {
  .checkin-hero { grid-template-columns: 1fr; align-items: start; }
  .checkin-hero-target { width: 86px; min-width: 86px; min-height: 86px; }
  .checkin-readiness { grid-template-columns: 1fr; }
  .checkin-actions { grid-template-columns: 1fr; }
  .bf-current { align-items: flex-start; flex-direction: column; }
  .photo-upload-actions { grid-template-columns: 1fr; }
  .checkin-summary-grid { grid-template-columns: 1fr 1fr; }
  .checkin-stat-card { padding: 14px 12px; }
  .checkin-stat-card strong { font-size: 25px; }
  .photo-assignment { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  .photo-tile-frame { max-height: 104px; }
  .result-stats-grid { grid-template-columns: 1fr; }
  .checkin-modal-actions { grid-template-columns: 1fr; }
}

/* Date nav */
.date-nav { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 10px; padding: 6px 0 16px; }
.dn-btn { display: grid; place-items: center; height: 38px; border-radius: 10px; background: var(--bg-2);
  border: 1px solid var(--line); color: var(--ink); font-size: 20px; line-height: 1; }
.dn-btn:hover { background: var(--bg-3); }
.dn-center { text-align: center; }
.dn-date { font-size: 17px; font-weight: 600; letter-spacing: -0.015em; }
.dn-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.dn-sub a { color: var(--forest); font-weight: 600; }

/* Totals card */
.totals-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 18px 18px 16px; margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(15,15,15,0.03); }
.totals-row { display: grid; grid-template-columns: minmax(120px, 160px) 1fr; gap: 18px; align-items: center; }
.totals-big { text-align: center; }
.totals-num { font-family: "Fraunces", Georgia, serif; font-size: 44px; font-weight: 600;
  letter-spacing: -0.03em; line-height: 1; color: var(--ink); }
.totals-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); margin-top: 5px; font-weight: 600; }
.totals-target { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.macro-bars { display: flex; flex-direction: column; gap: 9px; }
.macro-bar { background: var(--bg-3); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; }
.mb-head { display: flex; justify-content: space-between; align-items: center; }
.mb-lbl { font-size: 12px; color: var(--ink-3); font-weight: 500; }
.mb-num { font-size: 12px; color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 600; }
.mb-track { height: 5px; background: rgba(15,15,15,0.06); border-radius: 999px; margin-top: 7px; overflow: hidden; }
.mb-fill { height: 100%; border-radius: 999px; transition: width 220ms ease; }
.mb-p .mb-fill { background: var(--p); }
.mb-c .mb-fill { background: var(--c); }
.mb-f .mb-fill { background: var(--f); }

/* Meal cards */
.meal-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-lg);
  margin-bottom: 12px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(15,15,15,0.03); }
.meal-head { display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px; border-bottom: 1px solid var(--line); }
.meal-name { font-family: "Fraunces", Georgia, serif; font-weight: 600; font-size: 17px; letter-spacing: -0.015em; }
.meal-sub { font-size: 12px; color: var(--ink-3); margin-top: 3px; font-variant-numeric: tabular-nums; }
.meal-actions { display: inline-flex; align-items: center; gap: 7px; flex-shrink: 0; }
.meal-routine-btn { background: var(--bg-2); color: var(--forest); padding: 0; border-radius: 999px;
  border: 1px solid var(--green-ring); min-height: 44px; min-width: 44px;
  display: inline-flex; align-items: center; justify-content: center; }
.meal-routine-btn:hover:not(:disabled) { background: var(--green-soft); color: var(--forest-dk); border-color: var(--forest-lt); }
.meal-routine-btn:disabled { color: var(--ink-3); border-color: var(--line); background: var(--bg-3); opacity: 0.55; }
.meal-add { background: transparent; color: var(--forest); padding: 8px 13px; border-radius: 999px;
  font-size: 13px; font-weight: 700; border: 1px solid var(--green-ring); min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center; }
.meal-add:hover { background: var(--green-soft); color: var(--forest-dk); border-color: var(--forest-lt); }

.entry-list { list-style: none; padding: 0; margin: 0; background: var(--bg-3); }
.entry-row { display: flex; align-items: center; gap: 8px; padding: 11px 16px;
  border-bottom: 1px solid var(--line); }
.entry-row:last-child { border-bottom: 0; }
.entry-main { flex: 1; min-width: 0; }
.entry-name { font-size: 14px; line-height: 1.35; color: var(--ink); }
.entry-brand { color: var(--ink-3); font-size: 12px; margin-left: 6px; }
.entry-meta { font-size: 12px; color: var(--ink-3); margin-top: 3px; font-variant-numeric: tabular-nums; }
.entry-del { background: transparent; color: var(--ink-3); border: 0; font-size: 22px;
  line-height: 1; padding: 2px 8px; border-radius: 6px; }
.entry-del:hover { color: var(--err); background: var(--err-bg); }
.entry-empty { padding: 14px 16px; font-size: 13px; color: var(--ink-3); text-align: center; background: var(--bg-3); font-style: italic; }

.copy-form { margin-top: 10px; }
.copy-sheet-inner { max-height: 88vh; overflow: auto; }
.copy-calendar-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 4px 0 8px; }
.copy-calendar-head h3 { margin: 0; font-size: 16px; }
.copy-calendar-head span { color: var(--ink-3); font-size: 11px; line-height: 1.2; text-align: right; }
.copy-calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin: 6px 0 12px; }
.copy-day { aspect-ratio: 1; min-height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-3);
  color: var(--ink-3); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 6px 2px; font-variant-numeric: tabular-nums; cursor: pointer; transition: transform 0.1s ease; }
.copy-day:hover { transform: scale(1.05); }
.copy-day:active { transform: scale(0.95); }
.copy-day.cal-none { background: var(--bg-3); color: var(--ink-3); }
.copy-day.cal-none .copy-day-kcal { display: none; }
.copy-day.cal-low { background: rgba(31, 111, 91, 0.18); color: var(--forest); }
.copy-day.cal-mid { background: rgba(31, 111, 91, 0.55); color: #fff; border-color: rgba(31, 111, 91, 0.58); }
.copy-day.cal-high { background: rgba(31, 111, 91, 0.90); color: #fff; border-color: rgba(31, 111, 91, 0.88); }
.copy-day.selected { box-shadow: inset 0 0 0 3px var(--orange); outline: 0; }
.copy-day:disabled { opacity: 0.55; }
.copy-day-num { font-weight: 700; font-size: 16px; line-height: 1; }
.copy-day-kcal { font-size: 10px; font-weight: 600; opacity: 0.86; line-height: 1; margin-top: 2px; }
.copy-preview { border: 1px solid var(--line); border-radius: 12px; background: var(--bg-3); padding: 12px; margin-bottom: 12px; }
.copy-preview.empty, .copy-loading { text-align: center; color: var(--ink-3); font-size: 13px; font-style: italic; }
.copy-preview-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--ink-2); margin-bottom: 10px; }
.copy-meal-check { display: flex; align-items: flex-start; gap: 9px; padding: 9px 0; border-top: 1px solid var(--line); }
.copy-meal-check:first-of-type { border-top: 0; }
.copy-meal-check input { margin-top: 2px; accent-color: var(--forest); }
.copy-meal-check span { display: flex; flex-direction: column; gap: 2px; }
.copy-meal-check small { color: var(--ink-3); font-size: 12px; }
.copy-food-list { margin: -3px 0 8px 27px; color: var(--ink-3); font-size: 12px; }
.copy-food-list div { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }

/* Log / search page */
.log-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 6px 0 12px; }
.log-meal { font-weight: 600; font-size: 16px; }
.log-date { text-align: right; font-size: 13px; color: var(--ink-3); }
.back-link { font-size: 14px; color: var(--ink-3); }

.search-wrap { position: sticky; top: 60px; background: var(--bg); padding: 6px 0 10px; z-index: 5; }
.search-input { width: 100%; padding: 14px 16px; font-size: 16px; background: var(--bg-2); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: 12px; outline: none; -webkit-appearance: none; }
.search-input:focus { border-color: var(--forest); box-shadow: 0 0 0 3px var(--focus-ring); }
.search-input::placeholder { color: var(--ink-3); }

.search-results { display: flex; flex-direction: column; gap: 8px; padding-top: 8px; }
.result-row { background: var(--bg-2); border: 1px solid var(--line); padding: 12px 14px; border-radius: 12px;
  display: flex; align-items: center; gap: 10px; cursor: pointer; text-align: left; color: var(--ink); width: 100%;
  transition: background 120ms ease, border-color 120ms ease; }
.result-row:hover { background: var(--bg-3); border-color: var(--line-2); }
.rr-main { flex: 1; min-width: 0; }
.rr-name { font-size: 15px; line-height: 1.3; display: flex; align-items: center; gap: 8px; color: var(--ink); }
.rr-sub { font-size: 12px; color: var(--ink-3); margin-top: 3px; font-variant-numeric: tabular-nums; }
.rr-arrow { color: var(--ink-3); font-size: 18px; }
.empty { padding: 32px 14px; text-align: center; color: var(--ink-3); font-size: 14px; font-style: italic; }

.badge { font-size: 10px; padding: 2px 7px; border-radius: 999px; border: 1px solid transparent;
  vertical-align: 1px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.badge.verified { background: var(--green-soft); color: var(--green-dk); border-color: var(--green-ring); }
.badge.recent { background: var(--green-soft); color: var(--forest); border-color: var(--green-ring); }
.badge.fav { background: var(--orange-soft); color: var(--orange-dk); border-color: var(--orange-ring); }
.badge.popular { background: rgba(108,83,45,0.10); color: var(--ink-2); border-color: rgba(108,83,45,0.22); }
.rr-variance { margin-top: 5px; padding: 5px 7px; border-radius: 7px;
  background: var(--orange-soft); color: var(--orange-dk); font-size: 11px; line-height: 1.35; }
.rr-variance b { color: var(--orange-dk); }

/* Slide-up sheet */
.sheet { position: fixed; inset: 0; background: rgba(15,15,15,0.45); display: grid; align-items: end; z-index: 100; }
.sheet.hidden { display: none; }
.sheet-inner { background: var(--bg-2); border-top-left-radius: 18px; border-top-right-radius: 18px;
  padding: 22px 22px calc(22px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line);
  max-width: 760px; margin: 0 auto; width: 100%; box-shadow: 0 -8px 32px rgba(15,15,15,0.15);
  max-height: calc(100dvh - 18px); overflow: hidden; display: flex; flex-direction: column; }
.sheet-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.sheet-title { font-family: "Fraunces", Georgia, serif; font-size: 18px; font-weight: 600; flex: 1; min-width: 0; line-height: 1.3; letter-spacing: -0.015em; }
.sheet-close { background: transparent; border: 0; color: var(--ink-3); font-size: 24px; line-height: 1; padding: 0 6px; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding-bottom: 2px; }
.sheet-help { margin: -2px 0 12px; color: var(--ink-2); font-size: 13px; line-height: 1.45; }
.health-first-run { text-align: center; padding-top: 28px; }
.health-first-run-icon { width: 58px; height: 58px; margin: 0 auto 14px; border-radius: 50%;
  display: grid; place-items: center; color: var(--forest); background: var(--green-soft);
  border: 1px solid var(--green-ring); }
.health-first-run .sheet-title { font-size: 25px; }
.health-first-run-copy { margin: 10px auto 12px; max-width: 480px; color: var(--ink-2);
  font-size: 15px; line-height: 1.5; }
.health-first-run-status { min-height: 20px; margin: 0 0 6px; }
.health-first-run .btn-primary, .health-first-run .btn-ghost { width: 100%; }
.health-first-run .btn-ghost { margin-top: 8px; }
.health-first-run-foot { margin: 14px auto 0; max-width: 480px; color: var(--ink-3);
  font-size: 11px; line-height: 1.45; }
.earn-terms-list { margin: 0 0 8px; padding-left: 18px; display: grid; gap: 10px; color: var(--ink-2); font-size: 13px; line-height: 1.5; }
.preview { display: flex; align-items: center; gap: 16px; padding: 14px 16px; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 12px; margin: 12px 0 16px; }
.prev-kcal { display: flex; align-items: baseline; gap: 5px; font-variant-numeric: tabular-nums; }
.prev-kcal #prevKcal { font-family: "Fraunces", Georgia, serif; font-size: 30px; font-weight: 600; letter-spacing: -0.02em; }
.prev-lbl { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.prev-macros { display: flex; gap: 14px; font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.prev-macros b { color: var(--ink); font-weight: 600; }

/* Targets */
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 16px;
  box-shadow: 0 1px 2px rgba(15,15,15,0.03); }
.form-card { padding: 18px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 380px) { .grid-2 { grid-template-columns: 1fr; } }
.history-list { list-style: none; padding: 0; margin: 14px 0 0; }
.history-row { padding: 11px 0; border-bottom: 1px solid var(--line); }
.history-row:last-child { border-bottom: 0; }
.history-meta { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.history-meta em { color: var(--ink); font-style: normal; font-weight: 500; }


/* ============================================================
   v1 additions: bottom nav, toasts, charts, ingredient rows,
   weight pill, page-h-row, AI sheet, scanner.
   ============================================================ */

/* Spacing so bottom nav doesn't cover content */
.main { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }

/* Top-right settings icon */
.topbar-icon { display: grid; place-items: center; width: 44px; height: 44px;
  border-radius: 8px; color: var(--ink-2); }
.topbar-icon:hover { background: var(--bg-2); color: var(--ink); }

/* Bottom nav */
.bottomnav { position: fixed; left: 0; right: 0; bottom: 0;
  background: rgba(250,250,247,0.96); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: repeat(5, 1fr);
  z-index: 60; max-width: 760px; margin: 0 auto;
}
.bn-item { display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--ink-3); font-size: 10.5px; padding: 4px 2px; text-decoration: none;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  letter-spacing: 0.01em; font-weight: 500;
}
.bn-item svg { stroke: currentColor; }
.bn-item.active { color: var(--forest); }
.bn-item:hover { color: var(--ink); }
.bn-item.active:hover { color: var(--forest-dk); }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translate(-50%, 30px); background: var(--ink); color: var(--bg);
  padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(15,15,15,0.20);
  opacity: 0; transition: transform 220ms ease, opacity 220ms ease;
  z-index: 200; max-width: 80vw; text-align: center;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", sans-serif;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.err { background: var(--err); color: #fff; }

/* Page header with right-side button */
.page-h-row { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 6px; }
.page-h-row .section-h { margin: 14px 0 0; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.btn-primary.inline { display: inline-flex; width: auto; margin: 0; padding: 9px 14px; font-size: 13px; }
.btn-ghost.inline { display: inline-flex; width: auto; margin: 0; padding: 9px 14px; font-size: 13px; }
.btn-primary.inline.tiny { padding: 7px 12px; font-size: 12px; }
.btn-ghost.danger { color: var(--err); border-color: rgba(179,48,32,0.30); }
.btn-ghost.danger:hover { background: var(--err-bg); color: var(--err); }

/* Quick action row on log page */
.quickrow { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; padding: 10px 0 4px; }
.qr-btn { background: var(--bg-2); border: 1px solid var(--line); color: var(--ink);
  padding: 9px 5px; border-radius: 10px; font-size: 11.5px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", sans-serif; text-align: center; }
.qr-btn:hover { background: var(--bg-3); color: var(--ink); }
.qr-btn.active { background: var(--green-soft); border-color: var(--green-ring); color: var(--forest-dk); }

/* Weight pill on diary page */
.weight-pill { display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-2); border: 1px solid var(--line); padding: 10px 14px;
  border-radius: 10px; font-size: 13px; margin: 0 0 12px; color: var(--ink-2);
  font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.weight-pill b { color: var(--ink); font-weight: 600; }
.weight-pill-empty { color: var(--ink-3); justify-content: center; font-style: italic; }
.weight-pill-empty:hover { color: var(--forest); border-color: var(--green-ring); }
.weight-edit { color: var(--ink-3); font-size: 12px; }

/* Big empty state */
.big-empty { text-align: center; padding: 40px 16px; }
.big-empty p { color: var(--ink-3); margin: 6px 0; line-height: 1.5; max-width: 360px; margin-left: auto; margin-right: auto; }
.big-empty p:first-child { color: var(--ink); font-size: 17px; font-weight: 600; margin-bottom: 10px; }
.big-empty .btn-primary { display: inline-flex; width: auto; margin-top: 12px; padding: 11px 22px; }
.sub-help { color: var(--ink-3); font-size: 13px; line-height: 1.5; margin: 6px 0 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", sans-serif; }

/* Flat entry-list (used by my-foods, recipes, history) */
.entry-list.flat { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-lg); }

/* Stat cards (weight page) */
.stat-card { padding: 18px; }
.stat-card.link { display: block; color: var(--ink); }
.stat-card.link:hover { background: var(--bg-3); }
.stat-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.stat-big { text-align: left; }
.stat-num { font-family: "Fraunces", Georgia, serif; font-size: 38px; font-weight: 600; letter-spacing: -0.03em; line-height: 1; }
.stat-lbl { font-size: 12px; color: var(--ink-3); margin-top: 5px; font-weight: 500; }
.stat-trend { text-align: right; }
.trend-num { font-family: "Fraunces", Georgia, serif; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.trend-lbl { font-size: 11px; color: var(--ink-3); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }

/* Charts */
.chart-card { padding: 14px; }
canvas { display: block; }

/* Weekly bars */
.weekbars { height: 168px; padding: 8px 4px 0; }
.weekbars-scaled { display: grid; grid-template-columns: 38px 1fr; gap: 9px; height: 100%; }
.weekbars-yaxis { position: relative; height: 140px; color: var(--ink-3); font-size: 10px; font-variant-numeric: tabular-nums; }
.weekbars-yaxis span { position: absolute; right: 0; transform: translateY(50%); }
.weekbars-bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; height: 100%; align-items: end; }
.weekbar { display: flex; flex-direction: column; height: 100%; align-items: center; justify-content: end; }
.weekbar-track { height: 140px; width: 100%; max-width: 28px; background: rgba(15,15,15,0.04); border-radius: 6px 6px 2px 2px;
  position: relative; overflow: hidden; }
.weekbar-fill { position: absolute; bottom: 0; width: 100%; background: var(--forest-lt);
  border-radius: 6px 6px 2px 2px; transition: height 240ms ease; }
.weekbar-lbl { font-size: 10px; color: var(--ink-3); margin-top: 6px;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif; font-variant-numeric: tabular-nums; }

.streak-celebration { position: fixed; inset: 0; background: rgba(13, 21, 17, 0.72);
  display: flex; align-items: center; justify-content: center; padding: 22px; z-index: 9999; }
#confettiCanvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.streak-celebration-content { position: relative; z-index: 1; max-width: 340px; width: 100%; padding: 28px 22px;
  border-radius: 14px; background: var(--bg); border: 1px solid var(--line); text-align: center;
  box-shadow: 0 24px 70px rgba(0,0,0,0.22); }
.streak-celebration-mark { display: inline-grid; place-items: center; width: 58px; height: 58px;
  margin-bottom: 10px; border-radius: 999px; background: var(--orange); color: #fff;
  font-size: 25px; font-weight: 800; font-variant-numeric: tabular-nums; }
.streak-celebration-content h2 { margin: 0 0 8px; font-size: 28px; }
.streak-celebration-content p { margin: 0 0 18px; color: var(--ink-2); line-height: 1.4; }
.streak-celebration-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Insights */
.insight-list { list-style: none; padding: 0; margin: 0; }
.insight-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0;
  font-size: 14px; color: var(--ink); line-height: 1.5;
  border-bottom: 1px solid var(--line); }
.insight-row:last-child { border-bottom: 0; }
.insight-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--forest); margin-top: 7px; flex-shrink: 0; }

/* Ingredient list (recipes, routines) */
.ing-list { list-style: none; padding: 0; margin: 0 0 8px;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.ing-list:empty { display: none; }
.ing-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.ing-row:last-child { border-bottom: 0; }
.ing-main { flex: 1; min-width: 0; }
.ing-name { font-size: 14px; color: var(--ink); }
.ing-sub { font-size: 13px; color: var(--ink-3); margin-top: 4px; display: flex; align-items: center; gap: 6px;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.ing-qty { width: 60px; padding: 5px 8px; border: 1px solid var(--line-2); border-radius: 6px;
  background: var(--bg-3); font-size: 16px; -webkit-appearance: none; font-variant-numeric: tabular-nums; }
.ing-qty:focus { outline: none; border-color: var(--forest); box-shadow: 0 0 0 3px var(--focus-ring); }

.recipe-preview { background: var(--bg-3); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 14px 0; }
.rp-row { display: flex; justify-content: space-between; align-items: center; font-family: -apple-system, sans-serif; }
.rp-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); font-weight: 600; }
.rp-vals { display: flex; gap: 14px; font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.rp-vals b { color: var(--ink); font-weight: 600; }
.recipe-import-review.hidden { display: none; }
.import-ingredient-list { display: flex; flex-direction: column; gap: 8px; }
.import-ing-row { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 12px; background: var(--bg-3); border: 1px solid var(--line); border-radius: 10px; }
.import-ing-main { flex: 1; min-width: 0; }
.import-ing-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.import-ing-actions .btn-ghost { min-height: 34px; padding: 6px 10px; font-size: 12px; }
.import-qty { width: 72px; padding: 5px 8px; border: 1px solid var(--line-2); border-radius: 6px;
  background: var(--bg-2); font-size: 16px; -webkit-appearance: none; font-variant-numeric: tabular-nums; }

/* AI photo results */
.ai-list { list-style: none; padding: 0; margin: 14px 0; background: var(--bg-3); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.ai-row { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.ai-row:last-child { border-bottom: 0; }
.ai-main { flex: 1; min-width: 0; }
.ai-name { width: 100%; padding: 7px 10px; border: 1px solid var(--line-2); border-radius: 8px;
  background: var(--bg-3); font-size: 14px; font-weight: 600; margin-bottom: 6px; -webkit-appearance: none; }
.ai-name:focus { outline: none; border-color: var(--forest); box-shadow: 0 0 0 3px var(--focus-ring); }
.ai-meta { display: flex; gap: 10px; margin: 4px 0; flex-wrap: wrap;
  font-family: -apple-system, sans-serif; }
.ai-meta label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3);
  display: flex; align-items: center; gap: 6px; font-weight: 600; }
.ai-meta input { width: 70px; padding: 5px 8px; border: 1px solid var(--line-2); border-radius: 6px;
  background: var(--bg-3); font-size: 16px; -webkit-appearance: none; font-variant-numeric: tabular-nums; text-transform: none; }
.ai-meta input:focus { outline: none; border-color: var(--forest); box-shadow: 0 0 0 3px var(--focus-ring); }
.ai-notes { font-size: 12px; color: var(--ink-3); font-style: italic; margin-top: 6px; }

/* Scanner */
.scan-frame { position: absolute; inset: 18%; border: 2px solid #fff;
  border-radius: 10px; opacity: 0.7; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.20) inset; }

/* Settings key-value rows */
.kv-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0;
  border-bottom: 1px solid var(--line); font-family: -apple-system, sans-serif; font-size: 14px; }
.kv-row:last-child { border-bottom: 0; }
.kv-k { color: var(--ink-3); }
.kv-v { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }


/* ============================================================
   v2 additions: streak pill, donut chart, quick widget grid,
   daily note, activity, measurements, progress photos, more page.
   ============================================================ */

/* Streak + date nav inline */
.streak-row { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 12px; padding: 4px 0 12px; }
.streak-pill { display: flex; align-items: center; gap: 6px; background: var(--green-soft);
  border: 1px solid var(--green-ring); color: var(--forest-dk); padding: 7px 12px; border-radius: 999px;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.streak-flame { font-size: 16px; line-height: 1; }
.streak-num { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.streak-unit { font-size: 12px; font-weight: 500; color: var(--forest); }

.date-nav-inline { display: grid; grid-template-columns: 36px 1fr 36px; align-items: center; gap: 8px; }
.date-nav-inline .dn-btn { height: 34px; }
.date-nav-inline .dn-date { font-size: 15px; }
.date-nav-inline .dn-sub { font-size: 11px; }

/* Progress rings: big kcal ring left, three macro rings right */
.totals-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 16px; align-items: center; }
@media (max-width: 420px) { .totals-grid { gap: 10px; } }
.ring-wrap { position: relative; }
.ring { width: 100%; height: auto; aspect-ratio: 1 / 1; }
.ring circle { transition: stroke-dashoffset 480ms ease; }
.ring .ring-track, .mring .ring-track { stroke: var(--line); }
.ring .ring-fill { stroke: var(--orange); stroke-linecap: round;
  transform: rotate(-90deg); transform-origin: center; }
.ring .ring-fill.over { stroke: var(--err); } /* legacy fallback */
/* Calorie tier colors — one truth, both modes. Under is neutral (never a
   warning); green = in the ±150 zone; amber = 151–300 over; red = 300+ over. */
.ring .ring-fill.k-progress { stroke: var(--forest); }
.ring .ring-fill.k-zone { stroke: var(--tier-green); }
.ring .ring-fill.k-drift { stroke: var(--tier-amber); }
.ring .ring-fill.k-off { stroke: var(--tier-red); }
.ring-num { font-family: "Fraunces", Georgia, serif; font-size: 28px; font-weight: 700; fill: var(--ink); text-anchor: middle; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.ring-lbl { font-size: 8px; fill: var(--ink-3); text-anchor: middle; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; }
.ring-meta { display: flex; flex-direction: column; gap: 2px; font-size: 11.5px; margin-top: 8px;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; }
.ring-meta .dt-row { display: flex; justify-content: space-between; gap: 8px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.ring-meta .dt-row b { color: var(--ink); font-weight: 600; }
.ring-meta .dt-rem { border-top: 1px solid var(--line); padding-top: 3px; margin-top: 1px; }
.ring-meta .dt-rem b { color: var(--green-dk); }
.ring-meta .dt-rem.over b { color: var(--err); } /* legacy fallback */
.ring-meta .dt-rem.k-zone span, .ring-meta .dt-rem.k-zone b { color: var(--tier-green); }
.ring-meta .dt-rem.k-drift b { color: var(--tier-amber-txt); }
.ring-meta .dt-rem.k-off b { color: var(--tier-red); }
.ring-meta a { color: var(--forest); font-weight: 700; }

.macro-rings { display: flex; flex-direction: column; gap: 10px; }
.macro-ring { display: grid; grid-template-columns: 56px 1fr; gap: 10px; align-items: center; }
.macro-ring .mring { width: 56px; height: 56px; }
.macro-ring .mring .ring-fill { stroke-linecap: round; transform: rotate(-90deg); transform-origin: center; }
.mring-p .ring-fill { stroke: var(--p); }
.mring-c .ring-fill { stroke: var(--c); }
.mring-f .ring-fill { stroke: var(--f); }
.mring-num { font-family: "Fraunces", Georgia, serif; font-size: 12.5px; font-weight: 700; fill: var(--ink); text-anchor: middle; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.mring-info { font-family: -apple-system, BlinkMacSystemFont, sans-serif; min-width: 0; }
.mring-lbl { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.mring-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.mring-p-dot { background: var(--p); } .mring-c-dot { background: var(--c); } .mring-f-dot { background: var(--f); }
.mring-sub { font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; margin-top: 1px; }
.totals-card { padding-bottom: 16px; }

/* Simple|Full totals mode pill — small, quiet, centered */
.tc-mode { display: flex; justify-content: center; margin: 0 0 14px;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.tc-mode { background: var(--bg-3); border: 1px solid var(--line); border-radius: 999px;
  padding: 2px; width: max-content; margin-left: auto; margin-right: auto; }
.tc-mode-btn { border: 0; background: transparent; color: var(--ink-3);
  font-size: 12px; font-weight: 700; padding: 5px 16px; border-radius: 999px;
  min-height: 30px; font-family: inherit; }
.tc-mode-btn.on { background: var(--bg-2); color: var(--forest-dk);
  box-shadow: 0 1px 2px rgba(23,21,17,0.10); }

/* Simple mode: two bars, one grammar. Protein = a floor (tick), calories = a
   target with a zone (band). Under never wears a warning color. */
.sbars { display: flex; flex-direction: column; gap: 18px; padding: 2px 2px 0;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.sbar-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.sbar-name { font-size: 11.5px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--forest); }
.sbar-val { font-size: 15px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.sbar-val small { font-weight: 600; color: var(--ink-3); font-size: 12px; }
.sbar { position: relative; height: 18px; border-radius: 9px; background: var(--line); }
.sbar-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 9px 4px 4px 9px;
  background: var(--forest); transition: width 480ms ease; }
.sb-hit .sbar-fill { background: var(--tier-green); }
.sbar-fill.k-zone { background: var(--tier-green); }
.sbar-fill.k-drift { background: var(--tier-amber); }
.sbar-fill.k-off { background: var(--tier-red); }
.sbar-zone { position: absolute; top: 0; bottom: 0; background: rgba(46,125,79,0.14);
  border-left: 2px solid rgba(46,125,79,0.45); border-right: 2px solid rgba(46,125,79,0.45); }
.sbar-zone::after { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px;
  width: 0; border-left: 2px solid rgba(45,79,62,0.35); }
.sbar-tick { position: absolute; top: -4px; bottom: -4px; width: 0;
  border-left: 2.5px solid var(--forest-dk); }
.sbar-tick::after { content: "MIN"; position: absolute; top: -13px; left: -11px;
  font-size: 8.5px; font-weight: 800; letter-spacing: 0.06em; color: var(--ink-3); }
.sbar-metric:first-child .sbar { margin-top: 12px; } /* room for the MIN cap */
.sbar-status { font-size: 12.5px; font-weight: 700; margin-top: 7px; color: var(--ink-3);
  font-variant-numeric: tabular-nums; }
.sbar-status.st-good { color: var(--tier-green); }
.sbar-status.st-amber { color: var(--tier-amber-txt); }
.sbar-status.st-red { color: var(--tier-red); }
.sbar-status a { color: var(--forest); font-weight: 700; }
.sbar-sub { font-size: 11px; color: var(--ink-3); margin-top: 3px; }

/* LeanR workout rows on the Activity tab (read-only, badged) */
.leanr-badge { background: var(--green-soft); color: var(--forest); border: 1px solid var(--green-ring);
  border-radius: 999px; padding: 1px 8px; font-size: 10px; font-weight: 700; margin-left: 7px;
  text-transform: uppercase; letter-spacing: 0.05em; }
.leanr-open { display: inline-grid; place-items: center; min-width: 34px; min-height: 34px;
  color: var(--forest); font-size: 20px; font-weight: 600; border-radius: 999px; }
.leanr-open:hover { background: var(--green-soft); }

/* Quick widget grid */
.widget-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.widget { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  color: var(--ink); display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif; text-align: left; cursor: pointer; min-height: 78px; }
.widget:hover { background: var(--bg-3); border-color: var(--line-2); }
.widget-ico { color: var(--forest); display: inline-grid; place-items: center; min-height: 18px; }
.widget-ico.widget-empty { width: 30px; height: 30px; border: 1px solid var(--green-ring); border-radius: 999px; background: var(--green-soft); }
.widget-lbl { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); font-weight: 600; }
.widget-num { font-family: "Fraunces", Georgia, serif; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.widget-num.widget-empty { color: var(--forest); font-weight: 400; }
.widget-unit { font-size: 13px; color: var(--ink-3); font-weight: 500; font-family: -apple-system, sans-serif; }
.widget-sub { font-size: 11px; color: var(--ink-3); }
.widget.my-meds-w .widget-num { color: var(--forest); }

/* My Meds */
.subtle { color: var(--ink-3); font-size: 13px; margin: -4px 0 10px; font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.my-meds-page .hidden, .sheet-body .hidden { display: none !important; }
.btn-small { display: inline-flex; align-items: center; justify-content: center; gap: 5px; border: 1px solid var(--line-2);
  background: var(--bg-2); color: var(--ink); border-radius: 999px; padding: 8px 12px; min-height: 38px;
  font-size: 13px; font-weight: 700; font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.section-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 18px 0 8px; }
.section-row .section-h { margin: 0; }
.my-meds-log-card { padding: 16px; margin: 12px 0 18px; }
.card-kicker { font-family: -apple-system, BlinkMacSystemFont, sans-serif; font-size: 11px; color: var(--ink-3);
  font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 10px; }
.med-log-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.med-log-grid .field, .med-notes-field { margin: 0; }
.suggest-field { position: relative; }
.substance-suggestions { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 12; display: grid; gap: 4px;
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow-sm); padding: 6px; }
.substance-suggestions button { border: 0; background: transparent; color: var(--ink); text-align: left; border-radius: 9px;
  padding: 8px 10px; display: flex; justify-content: space-between; gap: 10px; align-items: center; font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.substance-suggestions button:hover { background: var(--bg-3); }
.substance-suggestions small { color: var(--ink-3); text-transform: capitalize; }
.med-notes-field { margin-top: 10px; }
.med-notes-field textarea { width: 100%; resize: vertical; background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; font-size: 16px; color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.my-meds-roster { display: grid; gap: 8px; margin: 12px 0 18px; }
.due-today-list { margin-top: 8px; }
.med-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: stretch;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.due-row { border-color: var(--green-ring); background: linear-gradient(0deg, rgba(42,94,70,0.04), rgba(42,94,70,0.04)), var(--bg-2); }
.due-row.is-logged { border-color: var(--line); opacity: 0.82; }
.med-main { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px;
  border: 0; background: transparent; color: var(--ink); text-align: left; padding: 4px; min-width: 0; }
.med-ico { width: 32px; height: 32px; border-radius: 10px; background: var(--green-soft); color: var(--forest);
  display: grid; place-items: center; }
.med-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.med-body b { font-size: 15px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.med-body small, .med-dose { color: var(--ink-3); font-size: 12px; }
.med-dose { font-family: -apple-system, BlinkMacSystemFont, sans-serif; font-weight: 700; color: var(--ink-2); }
.med-actions { display: grid; grid-template-columns: 1fr; gap: 6px; min-width: 72px; }
.med-log-btn { border: 0; background: var(--forest); color: white; border-radius: 10px; padding: 0 12px; font-size: 13px;
  font-weight: 700; min-height: 44px; font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.med-edit-btn { border: 1px solid var(--line-2); background: var(--bg-3); color: var(--ink-2); border-radius: 10px;
  padding: 0 12px; font-size: 12px; font-weight: 800; min-height: 34px; font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.compact-empty { padding: 16px; }
.my-meds-intro-icon { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center;
  color: var(--forest); background: var(--green-soft); margin: 0 auto 16px; }
.my-meds-day-card { margin: 14px 0; padding: 0; overflow: hidden; }
.my-meds-day-head { width: 100%; border: 0; background: transparent; color: var(--ink); display: flex; justify-content: space-between;
  align-items: center; padding: 14px 16px; font-size: 15px; font-weight: 700; font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
#myMedsDayBody { padding: 0 16px 14px; }
.my-meds-day-list { display: grid; gap: 8px; margin-bottom: 10px; }
.my-meds-day-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center;
  font-size: 13px; font-family: -apple-system, BlinkMacSystemFont, sans-serif; color: var(--ink-2); }
.my-meds-day-row b { color: var(--ink); }
.my-meds-day-row small { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.my-meds-sheet-list { display: grid; gap: 8px; }
.my-meds-sheet-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center;
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--bg-3);
  font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.my-meds-sheet-row span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.my-meds-sheet-row b { font-size: 14px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.my-meds-sheet-row small { color: var(--ink-3); font-size: 12px; }
.my-meds-sheet-row button { border: 0; border-radius: 9px; background: var(--forest); color: white; padding: 8px 10px;
  font-weight: 700; font-size: 12px; min-height: 38px; }
.my-meds-sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.my-meds-sheet-actions .btn-ghost { margin-top: 0; text-align: center; }
.med-history-list { display: grid; gap: 8px; margin-bottom: 8px; }
.med-history-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.med-history-row span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.med-history-row strong { color: var(--ink); font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.med-history-row small { color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.med-history-row b { color: var(--forest); font-size: 14px; white-space: nowrap; }
.med-reminder-card { padding: 14px 16px; }
.med-schedule-form { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) 120px minmax(90px, .65fr); gap: 8px; align-items: end; margin: 12px 0; }
.med-schedule-form .field { margin: 0; }
.med-schedule-form .btn-primary { min-height: 42px; white-space: nowrap; }
.weekday-picker { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.day-pill { border: 1px solid var(--line-2); background: var(--bg-3); color: var(--ink-3); border-radius: 999px; min-height: 36px;
  font-size: 12px; font-weight: 800; font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.day-pill.selected { background: var(--forest); color: white; border-color: var(--forest); }
.schedule-list { display: grid; gap: 8px; }
.schedule-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--bg-3); padding: 10px 12px; font-family: -apple-system, BlinkMacSystemFont, sans-serif; font-size: 13px; }
.schedule-row.is-off { opacity: 0.72; }
.schedule-row span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.schedule-row b { color: var(--ink); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.schedule-row small { color: var(--ink-3); }
.schedule-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.schedule-row button { border: 1px solid var(--line-2); background: var(--bg-2); color: var(--ink-3); border-radius: 999px;
  padding: 7px 10px; font-size: 12px; font-weight: 800; }
.recon-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; margin-bottom: 10px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg-3); }
.recon-tabs button { border: 0; border-radius: 9px; background: transparent; color: var(--ink-3); min-height: 38px;
  font-size: 13px; font-weight: 800; font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.recon-tabs button.selected { background: var(--bg-2); color: var(--forest); box-shadow: var(--shadow-sm); }
.dose-chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.dose-chip-row button { border: 1px solid var(--line-2); border-radius: 999px; background: var(--bg-2); color: var(--ink-2);
  padding: 8px 11px; min-height: 36px; font-size: 13px; font-weight: 800; font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.dose-chip-row button.selected { background: var(--forest); border-color: var(--forest); color: white; }
.recon-result { display: flex; flex-direction: column; gap: 4px; min-height: 62px; margin: 12px 0; padding: 14px;
  border: 1px solid var(--green-ring); border-radius: 12px; background: var(--green-soft); color: var(--ink-2);
  font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.recon-result b { color: var(--forest); font-size: 24px; line-height: 1.1; }
.recon-result span { font-size: 13px; }
.recon-result.warn { border-color: rgba(177,124,37,0.34); background: #fff7e8; }
.recon-result.warn b { color: #8a5a12; }
.recon-sources { display: grid; gap: 5px; margin: 14px 0 4px; padding: 12px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--bg-3); color: var(--ink-2); font-size: 12px; line-height: 1.4; }
.recon-sources strong { color: var(--ink); font-size: 13px; }
.recon-sources p { margin: 0 0 2px; }
.recon-sources a, .inline-source-link { color: var(--forest); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.recon-mini-chart { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
.recon-mini-chart span { border: 1px solid var(--green-ring); border-radius: 9px; padding: 7px 8px; background: rgba(255,255,255,0.45);
  color: var(--ink); font-size: 12px; font-weight: 800; text-align: center; }
#reconSheet .sheet-inner { max-height: calc(100dvh - 10px); padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
#reconSheet .sheet-head { margin-bottom: 10px; }
#reconSheet .sheet-help { margin-bottom: 8px; }
#reconSheet .field { margin-bottom: 8px; }
#reconSheet .recon-tabs { margin-bottom: 8px; }
#reconSheet .recon-result { margin: 10px 0; padding: 12px; }
#reconSheet .btn-primary { position: sticky; bottom: 0; margin-top: 8px; box-shadow: 0 -10px 18px rgba(255,253,248,0.92); }
.danger-action { background: var(--err) !important; border-color: var(--err) !important; color: white !important; }
.danger-row { width: 100%; border-color: rgba(178,59,43,0.22); color: var(--err); text-align: left; }

@media (max-width: 640px) {
  .med-log-grid { grid-template-columns: 1fr; }
  .section-row { align-items: flex-end; }
  .med-row { grid-template-columns: 1fr; }
  .med-main { grid-template-columns: 34px minmax(0, 1fr) auto; }
  .med-actions { grid-template-columns: 1fr 1fr; min-width: 0; }
  .med-schedule-form { grid-template-columns: 1fr; }
  .weekday-picker { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .schedule-row { grid-template-columns: 1fr; }
  .schedule-actions { justify-content: stretch; }
  .schedule-actions button { flex: 1 1 84px; }
}

.journey-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0 14px; }
.journey-controls select { background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; color: var(--ink); }
.journey-list { display: grid; gap: 12px; }
.journey-entry { background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.journey-date { font-family: -apple-system, BlinkMacSystemFont, sans-serif; color: var(--ink-3); font-weight: 800;
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 10px; }
.journey-photo { width: 100%; max-height: 320px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); margin-bottom: 10px; }
.journey-lines { display: grid; gap: 8px; font-family: -apple-system, BlinkMacSystemFont, sans-serif; font-size: 14px; color: var(--ink-2); }
.journey-lines b { color: var(--ink); }
.journey-lines details { border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; background: var(--bg-3); }
.journey-lines summary { font-weight: 800; color: var(--ink); cursor: pointer; }

/* Daily note */
.daily-note-card { margin: 14px 0; padding: 14px 16px; }
.dn-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.dn-h { font-size: 13px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; font-family: -apple-system, sans-serif; }
.dn-save { background: var(--forest); color: #fff; border: 0; padding: 6px 12px; border-radius: 8px; font-size: 12px; font-weight: 700; min-height: 44px; }
.daily-note-card textarea { width: 100%; min-height: 70px; resize: vertical; padding: 10px 12px;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px; font-size: 16px;
  font-family: "Fraunces", Georgia, serif; color: var(--ink); -webkit-appearance: none; outline: none; line-height: 1.45; }
.daily-note-card textarea:focus { border-color: var(--forest); box-shadow: 0 0 0 3px var(--focus-ring); }

/* Measurements grid */
.meas-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.meas-stat { padding: 10px 0; border-bottom: 1px solid var(--line); }
.meas-stat:nth-last-child(-n+2) { border-bottom: 0; }
.meas-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); font-weight: 600; }
.meas-num { font-family: "Fraunces", Georgia, serif; font-size: 20px; font-weight: 600; letter-spacing: -0.02em; margin-top: 2px; }
.meas-num span { font-size: 12px; color: var(--ink-3); font-family: -apple-system, sans-serif; font-weight: 500; }
.meas-date { font-size: 11px; color: var(--ink-3); margin-top: 12px; text-align: right; font-family: -apple-system, sans-serif; }

/* Progress photos */
.ba-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.ba-cell img { width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); display: block; }
.ba-cap { font-size: 12px; color: var(--ink-3); text-align: center; margin-top: 6px; font-family: -apple-system, sans-serif; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.photo-cell { position: relative; }
.photo-cell img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); display: block; }
.photo-cap { font-size: 11px; color: var(--ink-3); margin-top: 5px; font-family: -apple-system, sans-serif; }
.photo-del { position: absolute; top: 6px; right: 6px; background: rgba(15,15,15,0.6); color: #fff;
  border: 0; width: 28px; height: 28px; border-radius: 999px; font-size: 16px; line-height: 1; }
.photo-del:hover { background: var(--err); }

/* More page */
.more-list { background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; margin-top: 8px; }
.more-row { display: grid; grid-template-columns: 36px 1fr 16px; align-items: center; gap: 12px;
  padding: 14px 16px; color: var(--ink); border-bottom: 1px solid var(--line);
  font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.more-row:last-child { border-bottom: 0; }
.more-row:hover { background: var(--bg-3); }
.more-ico { font-size: 22px; }
.more-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.more-name { font-size: 15px; font-weight: 600; color: var(--ink); }
.more-sub { font-size: 12px; color: var(--ink-3); }
.more-arrow { font-size: 18px; color: var(--ink-3); }


/* ============================================================
   Entry tap-to-edit + drag-and-drop
   ============================================================ */
.entry-row { cursor: pointer; transition: background 100ms ease; user-select: none; -webkit-user-select: none; }
.entry-row:active { background: var(--bg-3); }
.entry-row:hover { background: var(--bg-3); }
.entry-row.dragging { opacity: 0.4; }
.entry-handle { color: var(--ink-3); font-size: 14px; line-height: 1; padding: 2px 6px 2px 0;
  letter-spacing: -2px; font-weight: 700; cursor: grab; align-self: center; }
.entry-handle:active { cursor: grabbing; }
.meal-card.drop-target { outline: 2px dashed var(--forest); outline-offset: -2px; background: var(--green-soft); }
.meal-card.drop-target .meal-head { background: var(--green-soft); }

/* Targets: live macro balance readout */
.macro-balance { margin: 4px 0 12px; padding: 10px 12px; background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 10px; font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.mbal-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px;
  font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.mbal-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.mbal-row span:not(.mbal-dot) { margin-right: 6px; }
.mbal-sum { font-size: 12px; margin-top: 6px; font-weight: 600; }

/* ============================================================
   TrackR theme — premium app polish (Inter UI, Fraunces display,
   warm surfaces, forest chrome, restrained orange)
   ============================================================ */
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
}
.section-h, .auth-h, .meal-name, .dn-date,
.totals-num, .widget-num, .meas-num { font-family: "Fraunces", Georgia, serif; }
/* Ring numbers: Inter, heavy + tabular — Fraunces was hard to read at a glance */
.ring-num, .mring-num {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: 0;
}

/* Wordmark: forest like the LeanR app, orange R */
.brand { color: var(--forest-dk); font-weight: 900; font-size: 21px; letter-spacing: -0.01em; }
.brand-accent { color: var(--orange); font-style: italic; font-weight: 900; }
.topbar { background: rgba(250,250,247,0.88); backdrop-filter: blur(18px); }

/* Cards: white, bigger radius, soft LeanR shadow */
.card, .totals-card, .meal-card, .auth-card {
  border-radius: var(--radius-lg);
  border-color: var(--line);
  box-shadow: var(--shadow-md);
}
.widget, .entry-list.flat, .chart-card, .stat-card, .form-card, .more-list, .photo-item {
  box-shadow: var(--shadow-sm);
}

/* Bottom nav: forest active pill (LeanR app style) */
.bn-item { font-weight: 700; border-radius: 12px; margin: 0 6px; }
.bn-item.active, .bn-item.active:hover {
  color: var(--forest-dk);
  background: rgba(45,79,62,0.10);
}

/* Labels/eyebrows lean forest like the app */
.widget-lbl, .field .label, .dn-h { color: var(--forest); }

/* Search result polish: section headers + macro colors in rows */
.rr-section { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--forest); padding: 14px 2px 6px;
  font-family: "Inter", -apple-system, sans-serif; }
.rr-sub b, .rr-sub span { font-weight: 600; font-variant-numeric: tabular-nums; }
.rr-p { color: var(--p); } .rr-c { color: var(--c); } .rr-f { color: #B8860B; }
.badge.verified { color: var(--green-dk); background: var(--green-soft); }

/* Week chart: goal line + over-goal bars */
.weekbar-track { position: relative; overflow: visible; }
.weekbar-goal { position: absolute; left: -2px; right: -2px; height: 0;
  border-top: 2px dashed rgba(45,79,62,0.55); z-index: 2; }
.weekbar-fill.over { background: var(--err); }
.weekbars-legend { margin-top: 10px; font-size: 11.5px; color: var(--ink-3); text-align: center;
  font-family: "Inter", -apple-system, sans-serif; }
.weekbars-legend .wl-over { color: var(--err); font-weight: 700; }

/* ============ Onboarding wizard ============ */
.ob { max-width: 460px; margin: 0 auto; padding-top: 28px; }
.ob-progress { height: 5px; background: rgba(15,15,15,0.07); border-radius: 999px; margin-bottom: 26px; overflow: hidden; }
.ob-bar { height: 100%; width: 16%; background: var(--forest); border-radius: 999px; transition: width 280ms ease; }
.ob-eyebrow { margin: 0 0 4px; font-size: 11px; font-weight: 800; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--forest); font-family: "Inter", sans-serif; }
.ob-h { font-family: "Fraunces", Georgia, serif; font-size: clamp(26px, 6.4vw, 32px);
  margin: 0 0 8px; letter-spacing: -0.01em; line-height: 1.12; }
.ob-sub { margin: 0 0 18px; color: var(--ink-3); font-size: 14.5px; line-height: 1.45;
  font-family: "Inter", sans-serif; }
.ob-options { display: grid; gap: 11px; }
.ob-options.ob-row2 { grid-template-columns: 1fr 1fr; }
.ob-opt { text-align: left; background: var(--bg-2); border: 1.5px solid var(--line-2);
  border-radius: 16px; padding: 16px 17px; display: grid; gap: 3px;
  font-family: "Inter", sans-serif; transition: border-color 120ms ease, background 120ms ease; }
.ob-opt:hover { border-color: var(--forest); }
.ob-opt.sel { border-color: var(--forest); background: var(--green-soft); }
.ob-opt.sm { text-align: center; }
.ob-opt-title { font-size: 16.5px; font-weight: 800; color: var(--ink); }
.ob-opt-sub { font-size: 12.5px; color: var(--ink-3); }
.ob-rec { background: var(--green-soft); border: 1px solid var(--green-ring); color: var(--forest-dk);
  border-radius: 14px; padding: 13px 15px; font-size: 14px; line-height: 1.5; margin-bottom: 14px;
  font-family: "Inter", sans-serif; }
.ob-goal-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 12px; }
.ob-goal-tabs button { border: 1.5px solid var(--line-2); background: var(--bg-2); border-radius: 999px;
  padding: 9px 4px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); font-family: "Inter", sans-serif; }
.ob-goal-tabs button.sel { border-color: var(--forest); background: rgba(45,79,62,0.10); color: var(--forest-dk); }
.ob-plan { padding: 20px; text-align: center; }
.ob-kcal { font-family: "Inter", sans-serif; }
.ob-kcal span { font-size: 44px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.ob-kcal em { display: block; font-style: normal; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--ink-3); font-weight: 700; margin-top: 2px; }
.ob-macros { display: flex; justify-content: center; gap: 18px; margin: 14px 0 10px;
  font-family: "Inter", sans-serif; font-size: 13.5px; color: var(--ink-2); }
.ob-macros div { display: flex; align-items: center; gap: 6px; }
.ob-macros b { font-variant-numeric: tabular-nums; }
.ob-plan-note { font-size: 12.5px; color: var(--ink-3); line-height: 1.5; font-family: "Inter", sans-serif; }
.ob-foot { text-align: center; font-size: 12.5px; color: var(--ink-3); font-family: "Inter", sans-serif; }
.ob-features { display: grid; gap: 9px; }
.feat-row { display: grid; grid-template-columns: 24px 1fr; align-items: start; gap: 11px;
  background: var(--bg-2); border: 1.5px solid var(--line); border-radius: 12px;
  padding: 12px 13px; cursor: pointer; font-family: "Inter", sans-serif;
  transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease; }
.feat-row:hover { border-color: var(--green-ring); }
.feat-row:has(input:checked) { border-color: var(--forest); background: var(--green-soft);
  box-shadow: 0 1px 0 rgba(15,15,15,0.03); }
.feat-row input[type="checkbox"] { width: 20px; height: 20px; margin: 1px 0 0;
  accent-color: var(--forest); flex: none; }
.feat-body { min-width: 0; display: grid; gap: 3px; }
.feat-title { display: block; color: var(--ink); font-size: 14.5px; line-height: 1.25;
  font-weight: 800; letter-spacing: 0; }
.feat-sub { display: block; color: var(--ink-3); font-size: 12.5px; line-height: 1.35; }
.ob-features .ob-cta { margin-top: 7px; }

.ob-step.hidden, .ob .hidden { display: none; }


/* ============================================================
   Photo AI — capture → analyzing → results UX
   ============================================================ */
.photo-page .photo-state { display: flex; flex-direction: column; gap: 12px; }
.photo-page .photo-state[hidden] { display: none !important; }

/* Capture state */
.photo-capture-card { min-height: min(54vh, 440px); border: 1px dashed var(--green-ring);
  border-radius: 18px; background: var(--bg-2); display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; gap: 10px;
  padding: 28px 22px; box-shadow: var(--shadow-sm); }
.photo-capture-icon { width: 76px; height: 76px; border-radius: 24px; display: grid; place-items: center;
  background: var(--green-soft); color: var(--forest); border: 1px solid var(--green-ring); }
.photo-capture-card h1 { margin: 4px 0 0; font-family: ui-serif, Georgia, serif;
  font-size: 28px; line-height: 1.05; letter-spacing: 0; color: var(--ink); }
.photo-capture-card p { max-width: 310px; margin: 0; color: var(--ink-2);
  font-size: 14px; line-height: 1.45; font-family: "Inter", sans-serif; }
.photo-capture-tip { margin-top: 4px; color: var(--forest-dk); background: var(--bg);
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px;
  font-size: 12.5px; font-weight: 700; font-family: "Inter", sans-serif; }
.photo-cta { font-size: 16px; padding: 16px; min-height: 54px; }
.photo-fallback { display: block; text-align: center; color: var(--ink-3);
  text-decoration: none; font-size: 14px; padding: 6px; margin-top: 0;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.photo-fallback:hover { color: var(--forest); }

/* Analyzing state */
.photo-preview { width: 100%; }
.photo-preview img { width: 100%; aspect-ratio: 1 / 1; max-height: 56vh; object-fit: cover;
  border-radius: 18px; border: 1px solid var(--line); display: block; box-shadow: var(--shadow-sm); }
.analyze-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; display: grid; gap: 5px; box-shadow: 0 1px 0 rgba(15,15,15,0.03); }
.analyze-pulse { display: flex; gap: 7px; justify-content: center; padding: 2px 0 4px; }
.analyze-pulse span { width: 10px; height: 10px; border-radius: 50%;
  background: var(--orange); animation: pulse 1.4s infinite ease-in-out; }
.analyze-pulse span:nth-child(2) { animation-delay: 0.2s; }
.analyze-pulse span:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse {
  0%, 60%, 100% { transform: scale(0.6); opacity: 0.4; }
  30% { transform: scale(1); opacity: 1; }
}
.analyze-step { text-align: center; font-size: 16px; font-weight: 600; color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.analyze-sub { text-align: center; font-size: 12px; color: var(--ink-3);
  font-family: -apple-system, BlinkMacSystemFont, sans-serif; }

/* Results state */
.photo-result-summary { display: grid; grid-template-columns: minmax(118px, 0.72fr) minmax(0, 1fr);
  gap: 10px; align-items: stretch; }
.results-photo { min-width: 0; }
.results-photo img { width: 100%; height: 100%; min-height: 168px; max-height: 228px;
  object-fit: cover; border-radius: 16px; border: 1px solid var(--line); display: block; }
.photo-total-card { min-width: 0; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 16px; padding: 14px; display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: var(--shadow-sm); }
.photo-total-kcal { display: flex; align-items: baseline; gap: 6px; color: var(--ink); }
.photo-total-kcal span { font-size: 38px; line-height: 0.95; font-weight: 900;
  font-variant-numeric: tabular-nums; letter-spacing: 0; }
.photo-total-kcal small { color: var(--ink-3); font-size: 13px; font-weight: 800; }
.photo-total-macros { display: grid; gap: 7px; margin-top: 12px; }
.photo-total-macros span { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; color: var(--ink-3); font-size: 12.5px; font-weight: 700; }
.photo-total-macros b { color: var(--ink); font-size: 13px; font-variant-numeric: tabular-nums; }
.confidence-row { display: flex; justify-content: space-between; align-items: center;
  gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line);
  font-size: 12px; font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
#confLabel { color: var(--green-dk); font-weight: 600; }
.conf-help { color: var(--ink-3); text-align: right; }

.photo-section-h { font-family: ui-serif, Georgia, serif; font-size: 18px;
  font-weight: 600; margin: 8px 0 2px; letter-spacing: 0;
  display: flex; align-items: center; gap: 8px; }
.photo-section-count { background: var(--bg-3); color: var(--ink-3);
  font-family: -apple-system, BlinkMacSystemFont, sans-serif; font-size: 12px;
  padding: 2px 8px; border-radius: 999px; font-weight: 600; }

/* Items list */
.photo-items { list-style: none; padding: 0; margin: 0; display: flex;
  flex-direction: column; gap: 8px; }
.photo-item { background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.photo-item-head { display: flex; align-items: center; gap: 8px; }
.photo-item-name { flex: 1; }
.photo-item-name input { width: 100%; padding: 6px 8px; border: 1px solid transparent;
  border-radius: 6px; background: transparent; color: var(--ink);
  font-size: 16px; font-weight: 600; -webkit-appearance: none; outline: none;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.photo-item-name input:focus { border-color: var(--forest); background: var(--bg); box-shadow: 0 0 0 3px var(--focus-ring); }
.photo-item-del { background: transparent; color: var(--ink-3); border: 0;
  font-size: 22px; line-height: 1; padding: 4px 10px; border-radius: 6px; }
.photo-item-del:hover { color: var(--err); background: var(--err-bg); }

.photo-item-swap { background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 9px; margin: 4px 0;
  display: flex; align-items: center; gap: 6px; width: 100%; cursor: pointer;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif; font-size: 13px; color: var(--ink-2); }
.photo-item-swap:hover { background: var(--bg-3); }
.photo-item-swap .match-tick { color: var(--green-dk); font-weight: 700; flex-shrink: 0; }
.photo-item-swap .match-name { flex: 1; text-align: left; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-weight: 500; }
.photo-item-swap .match-name em { color: var(--ink-3); font-style: normal; font-weight: 400; }
.photo-item-swap .match-edit { font-size: 11px; color: var(--forest); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em; }
.photo-item-swap-empty .match-tick { color: var(--err); }
.photo-item-swap-empty { border-color: rgba(179,48,32,0.30); background: var(--err-bg); }

.photo-item-row { display: flex; align-items: center; justify-content: space-between;
  margin-top: 6px; gap: 8px; font-size: 13px; }
.photo-item-portion { background: var(--bg); border: 1px solid var(--line);
  color: var(--ink); font-size: 13px; padding: 6px 12px; border-radius: 999px;
  font-weight: 600; font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-variant-numeric: tabular-nums; }
.photo-item-portion:hover { border-color: var(--forest); color: var(--forest-dk); }
.photo-item-portion .muted { color: var(--ink-3); font-weight: 400; }
.photo-item-macros { color: var(--ink-3); font-variant-numeric: tabular-nums; font-size: 12px; text-align: right; }
.photo-item-macros b { color: var(--ink); font-weight: 600; }
.photo-item-note { font-size: 12px; color: var(--ink-3); font-style: italic;
  margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.photo-item-warn { font-size: 12px; color: var(--err); margin-top: 6px; font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif; }

.photo-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px;
  position: sticky; bottom: calc(86px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  padding-top: 16px; padding-bottom: 4px; z-index: 4; }

/* SVG icon buttons (replaced emojis) */
.ic { vertical-align: -3px; flex: none; }
.qr-btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.qr-btn .ic { color: var(--forest); }
.qr-btn .ic-sparkle { color: var(--orange); }
.qr-btn .ic-bolt { color: var(--f); }
.streak-flame .ic { color: var(--forest); display: block; }
.photo-cta { gap: 9px; }
.photo-cta .ic { color: #fff; }
.tip-icon .ic, .photo-capture-icon .ic { color: var(--forest); }
.more-ico { display: grid; place-items: center; color: var(--forest); }

/* One-tap quick log button on search rows */
.result-row { cursor: pointer; }
.rr-quick { flex: none; width: 38px; height: 38px; margin-left: 8px; border-radius: 12px;
  border: 1.5px solid var(--green-ring); background: var(--green-soft); color: var(--forest);
  font-size: 22px; font-weight: 700; line-height: 1; display: grid; place-items: center;
  font-family: "Inter", sans-serif; transition: background 120ms ease; }
.rr-quick:hover { background: var(--forest); color: #fff; }
.rr-quick.done { background: var(--green-soft); border-color: var(--green-ring); color: var(--green-dk); }

/* Micros line in the serving sheet */
.prev-micros { width: 100%; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--ink-3); font-family: "Inter", sans-serif;
  font-variant-numeric: tabular-nums; text-align: center; }
.prev-micros:empty { display: none; }

/* Metabolism (adherence TDEE) card */
.metab-card { font-family: "Inter", -apple-system, sans-serif; }
.metab-grid { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; }
.metab-num { font-size: 38px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: var(--forest-dk); }
.metab-lbl { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); font-weight: 700; margin-top: 2px; }
.metab-stats { display: grid; gap: 5px; }
.metab-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.metab-row b { color: var(--ink); font-weight: 600; }
.metab-note { margin-top: 12px; padding: 11px 13px; background: var(--green-soft); border: 1px solid var(--green-ring);
  border-radius: 12px; font-size: 13px; line-height: 1.5; color: var(--forest-dk); }
.metab-locked { font-size: 13.5px; color: var(--ink-2); line-height: 1.5; }
.metab-locked-h { font-weight: 700; font-size: 15px; color: var(--ink); margin-bottom: 6px; }
.metab-locked p { margin: 0 0 10px; }
.metab-progress { display: flex; gap: 8px; flex-wrap: wrap; }
.metab-progress span { background: var(--bg-3); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 11px; font-size: 12px; font-weight: 600; color: var(--ink-2); }

/* Onboarding: photo BF option + status + rec reasoning */
.ob-photo-opt { border-style: dashed; }
.ob-photo-opt .ob-opt-title { display: inline-flex; align-items: center; gap: 8px; color: var(--forest-dk); }
.ob-photo-opt .ic { color: var(--forest); }
.ob-photo-status { margin-top: 10px; padding: 11px 13px; background: var(--green-soft);
  border: 1px solid var(--green-ring); border-radius: 12px; font-size: 13px; color: var(--ink-2);
  font-family: "Inter", sans-serif; line-height: 1.45; }
.ob-rec-sub { margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--green-ring);
  font-size: 12.5px; color: var(--forest); }

/* 4-goal tabs + recommended chip + bulk warning */
.ob-goal-tabs-4 { grid-template-columns: repeat(2, 1fr); }
.ob-goal-tabs-4 button { position: relative; padding: 12px 4px 11px; font-size: 13px; }
.rec-chip { position: absolute; top: -8px; left: 50%; transform: translateX(-50%);
  background: var(--forest); color: #fff; font-size: 9px; font-weight: 800;
  letter-spacing: 0.06em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px;
  white-space: nowrap; }
.rec-chip.hidden { display: none; }
.ob-plan-warn { margin-top: 10px; padding: 10px 13px; background: var(--orange-soft);
  border: 1px solid var(--orange-ring); border-radius: 12px; font-size: 12.5px;
  color: var(--orange-dk); line-height: 1.5; font-family: "Inter", sans-serif; }
.ob-plan-warn.hidden { display: none; }

/* Legal pages */
.legal-card { font-family: "Inter", sans-serif; font-size: 14px; line-height: 1.6; color: var(--ink-2); }
.legal-card h3 { font-family: "Fraunces", Georgia, serif; font-size: 17px; margin: 18px 0 6px; color: var(--ink); }
.legal-card p { margin: 0 0 10px; }
.legal-card a { color: var(--forest); font-weight: 600; }
.source-list { display: grid; gap: 8px; padding-left: 20px; }

/* Premium finishing pass */
.ring-num, .ring-lbl, .mring-num, .mring-sub,
.totals-num, .totals-target, .meal-sub, .entry-meta,
.widget-num, .widget-unit, .stat-num, .trend-num, .meas-num,
.prev-kcal, .prev-macros, .rr-sub, .mb-num, .kv-v,
.weekbar-lbl, .ob-kcal span, .ob-macros b, .metab-num, .metab-row {
  font-variant-numeric: tabular-nums;
}

.btn-ghost, .dn-btn, .topbar-icon, .qr-btn, .rr-quick, .entry-del,
.photo-item-del, .photo-item-swap, .photo-item-portion {
  min-height: 44px;
}

.entry-del, .photo-item-del, .topbar-icon {
  min-width: 44px;
}

.topbar, .bottomnav {
  border-color: var(--line);
}

.ring-wrap {
  max-width: 280px;
  margin: 0 auto;
}

.macro-ring .mring .ring-track {
  stroke: var(--line-2);
}

.widget-lbl {
  color: var(--ink-3);
}

.widget-ico + .widget-lbl {
  margin-top: 2px;
}

.widget-num {
  letter-spacing: 0;
}

.meal-head {
  background: rgba(255,255,255,0.18);
}

.entry-list {
  background: color-mix(in srgb, var(--bg-3) 82%, var(--bg-2));
}

html.theme-dark {
  --bg: #171A17;
  --bg-2: #20241F;
  --bg-3: #282D27;
  --forest: #8FBF9C;
  --forest-dk: #C7E2CF;
  --forest-lt: #A9D2B2;
  --ink: #F4EFE6;
  --ink-2: #D3CABD;
  --ink-3: #A59C90;
  --line: rgba(244,239,230,0.10);
  --line-2: rgba(244,239,230,0.16);
  --orange: #E48A52;
  --orange-dk: #F0A372;
  --orange-soft: rgba(228,138,82,0.13);
  --orange-ring: rgba(228,138,82,0.25);
  --green: var(--forest-lt);
  --green-dk: var(--forest-dk);
  --green-soft: rgba(143,191,156,0.13);
  --green-ring: rgba(143,191,156,0.28);
  --p: #87C49C;
  --c: #D8B66B;
  --f: #C09B65;
  --p-soft: rgba(135,196,156,0.15);
  --c-soft: rgba(216,182,107,0.15);
  --f-soft: rgba(192,155,101,0.15);
  --err: #F07A68;
  --err-bg: rgba(240,122,104,0.12);
  --ok-bg: rgba(143,191,156,0.12);
  --focus-ring: rgba(143,191,156,0.24);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.22), 0 8px 20px rgba(0,0,0,0.16);
  --shadow-md: 0 16px 34px rgba(0,0,0,0.28);
}

html.theme-dark .topbar {
  background: rgba(23,26,23,0.88);
}

html.theme-dark .bottomnav {
  background: rgba(23,26,23,0.94);
}

html.theme-dark .sheet {
  background: rgba(0,0,0,0.58);
}

html.theme-dark .meal-head {
  background: rgba(244,239,230,0.02);
}

html.theme-dark .photo-actions {
  background: linear-gradient(to top, var(--bg) 60%, transparent);
}

html.theme-dark .toast {
  background: var(--ink);
  color: var(--bg);
}


/* Apple-required subscription disclosure block - required on any subscription paywall */
.upgrade-disclosure {
  margin-top: 14px;
  padding: 10px 12px;
  background: rgba(30,30,30,0.04);
  border-radius: 10px;
  font-size: 11px;
  line-height: 1.45;
  color: rgba(30,30,30,0.62);
}
.upgrade-legal-links {
  margin-top: 10px;
  font-size: 12px;
  color: rgba(30,30,30,0.62);
  text-align: center;
}
.upgrade-legal-links a,
.upgrade-legal-links .link-button {
  color: #2d4f3e;
  text-decoration: underline;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  cursor: pointer;
}


/* ---- Week chart v2: stacked macro bars + zone-tier day values ---- */
/* Day values are plain data — the diary rings carry the zone verdict. */
.weekbar-val { font-size: 10px; font-weight: 700; margin-bottom: 4px; min-height: 13px;
  font-variant-numeric: tabular-nums; color: var(--ink-2, var(--ink-3)); }
.weekbar-stack { position: absolute; bottom: 0; width: 100%;
  display: flex; flex-direction: column; gap: 2px;
  border-radius: 6px 6px 2px 2px; overflow: hidden;
  transition: height 240ms ease; }
.weekbar-stack span { display: block; width: 100%; min-height: 0; }
.weekbar-stack .ws-p { background: var(--p); }
.weekbar-stack .ws-c { background: var(--c); }
.weekbar-stack .ws-f { background: var(--f); }
.weekbars-legend { display: flex; align-items: center; flex-wrap: wrap; gap: 5px;
  font-size: 11px; color: var(--ink-3); }
.wl-swatch { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-left: 4px; }
.wl-swatch:first-child { margin-left: 0; }
.wl-p { background: var(--p); } .wl-c { background: var(--c); } .wl-f { background: var(--f); }
.wl-sep { margin: 0 2px; }

/* week chart v2 layout: room for the value labels above each bar */
.weekbars { height: 188px; }
.weekbars-yaxis { margin-top: 17px; }
.weekbar-track { flex-shrink: 0; }
