/* LIUsog design system.
   Semantic colours, type and spacing follow the iOS system so the app feels native on a phone:
   grouped backgrounds, inset lists, translucent bars, sheets, system font. Sizes are in rem so
   the layout grows with the user's text-size setting. */

:root {
  color-scheme: light dark;

  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-2: #f2f2f7;
  --label: #000000;
  --label-2: rgba(60, 60, 67, 0.72);
  --label-3: rgba(60, 60, 67, 0.4);
  --separator: rgba(60, 60, 67, 0.2);
  --fill: rgba(120, 120, 128, 0.2);
  --fill-2: rgba(120, 120, 128, 0.12);
  --material: rgba(249, 249, 249, 0.78);
  --scrim: rgba(0, 0, 0, 0.32);

  --tint: #007aff;
  --red: #ff3b30;
  --green: #248a3d;

  --energy: #ff9500;
  --energy-2: #ffcc00;
  --energy-text: #b25000;
  --protein: #ff2d55;
  --carb: #30b0c7;
  --fat: #5856d6;
  --body: #af52de;
  --move: #34c759;
  --move-text: #248a3d;

  --blue: #007aff; --pink: #ff2d55; --orange: #ff9500; --purple: #af52de; --teal: #30b0c7;
  --indigo: #5856d6; --mint: #00c7be; --yellow: #d4a400;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, Roboto, sans-serif;
  --font-rounded: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;

  --radius-card: 1rem;
  --radius-control: 0.75rem;
  --gutter: 1rem;
  --tabbar-h: 3.125rem;
  --navbar-h: 2.75rem;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* Non-gesture transitions. Gesture-driven motion (sheets) uses springs in app.js. */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --label: #ffffff;
    --label-2: rgba(235, 235, 245, 0.68);
    --label-3: rgba(235, 235, 245, 0.34);
    --separator: rgba(84, 84, 88, 0.6);
    --fill: rgba(120, 120, 128, 0.36);
    --fill-2: rgba(120, 120, 128, 0.24);
    --material: rgba(29, 29, 31, 0.78);
    --scrim: rgba(0, 0, 0, 0.5);

    --tint: #0a84ff;
    --red: #ff453a;
    --green: #30d158;
    --energy: #ff9f0a;
    --energy-2: #ffd60a;
    --energy-text: #ff9f0a;
    --protein: #ff375f;
    --carb: #40c8e0;
    --fat: #7d7aff;
    --body: #bf5af2;
    --move: #30d158;
    --move-text: #30d158;

    --blue: #0a84ff; --pink: #ff375f; --orange: #ff9f0a; --purple: #bf5af2; --teal: #40c8e0;
    --indigo: #5e5ce6; --mint: #63e6e2; --yellow: #ffd60a;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html {
  font: 100%/1.3 var(--font);
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  color: var(--label);
  background: var(--bg);
  font-size: 1.0625rem;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

h1, h2, h3, p { margin: 0; }
a { color: var(--tint); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
svg { display: block; }
[hidden] { display: none !important; }

.icon { width: 1.5rem; height: 1.5rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.sm { width: 1.125rem; height: 1.125rem; stroke-width: 2; }
.icon.fill { fill: currentColor; stroke: none; }
.num { font-family: var(--font-rounded); font-variant-numeric: tabular-nums; }
.secondary { color: var(--label-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ------------------------------------------------------------------ app frame */
.app {
  max-width: 30rem;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--bg);
  transform-origin: 50% 0;
  will-change: transform;
}

.navbar {
  position: sticky; top: 0; z-index: 20;
  height: calc(var(--navbar-h) + var(--safe-top));
  padding: var(--safe-top) 0.5rem 0;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
}
/* The material sits on a pseudo-element so it can fade in once content scrolls under the bar,
   instead of a hard divider that is always there. */
.navbar::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: var(--material);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--separator);
  opacity: 0; transition: opacity 180ms ease;
}
.navbar.is-stuck::before { opacity: 1; }
.navbar-title {
  font-size: 1.0625rem; font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; transition: opacity 180ms ease;
}
.navbar.is-stuck .navbar-title, .navbar.is-plain .navbar-title { opacity: 1; }
.navbar-start { display: flex; justify-content: flex-start; }
.navbar-end { display: flex; justify-content: flex-end; gap: 0.25rem; }
.nav-btn {
  min-width: 2.75rem; min-height: 2.75rem; padding: 0 0.5rem;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.125rem;
  color: var(--tint); font-size: 1.0625rem; border-radius: 0.75rem;
}
.nav-btn.strong { font-weight: 600; }
.nav-btn:active { opacity: 0.45; }
.nav-btn .icon { width: 1.375rem; height: 1.375rem; stroke-width: 2.2; }

.screen {
  padding: 0 var(--gutter) calc(var(--tabbar-h) + var(--safe-bottom) + 2rem);
}
.screen.no-tabbar { padding-bottom: calc(var(--safe-bottom) + 2rem); }

.eyebrow {
  font-size: 0.8125rem; font-weight: 600; color: var(--label-2); text-transform: uppercase; letter-spacing: 0.02em;
}
.large-title {
  font-size: 2.125rem; line-height: 1.2; font-weight: 700; letter-spacing: -0.022em;
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.section-title { font-size: 1.375rem; font-weight: 700; letter-spacing: -0.012em; margin: 1.75rem 0 0.625rem; display: flex; align-items: baseline; justify-content: space-between; }
.section-title a { font-size: 1.0625rem; font-weight: 400; letter-spacing: 0; }
.group-header { font-size: 0.8125rem; color: var(--label-2); text-transform: uppercase; letter-spacing: 0.02em; margin: 1.5rem 1rem 0.4375rem; }
.group-footer { font-size: 0.8125rem; color: var(--label-2); margin: 0.4375rem 1rem 0; line-height: 1.38; }

/* ------------------------------------------------------------------ tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--material);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--separator);
  padding-bottom: var(--safe-bottom);
}
.tabbar-inner { max-width: 30rem; margin: 0 auto; height: var(--tabbar-h); display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.125rem;
  color: var(--label-2); font-size: 0.625rem; font-weight: 500; letter-spacing: 0.01em;
}
.tab .icon { width: 1.625rem; height: 1.625rem; }
.tab[aria-current="page"] { color: var(--tint); }
.tab[aria-current="page"] .icon { fill: currentColor; fill-opacity: 0.16; }
.tab:active { opacity: 0.55; }

/* ------------------------------------------------------------------ cards and lists */
.card {
  background: var(--surface); border-radius: var(--radius-card); padding: 1rem;
  display: block; color: inherit;
}
.card + .card { margin-top: 0.75rem; }
a.card:active, button.card:active { background: var(--surface-2); }
.card-head {
  display: flex; align-items: center; gap: 0.375rem;
  font-size: 0.9375rem; font-weight: 600; margin-bottom: 0.75rem;
}
.card-head .chev { margin-left: auto; color: var(--label-3); display: flex; align-items: center; gap: 0.25rem; font-weight: 400; font-size: 0.875rem; }
.t-energy { color: var(--energy-text); }
.t-body { color: var(--body); }
.t-tint { color: var(--tint); }
.t-green { color: var(--green); }

.metric { font-family: var(--font-rounded); font-weight: 700; font-size: 2.125rem; line-height: 1.05; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; }
.metric small { font-family: var(--font); font-size: 1rem; font-weight: 600; color: var(--label-2); letter-spacing: 0; margin-left: 0.125rem; }
.metric.md { font-size: 1.75rem; }

.group { background: var(--surface); border-radius: var(--radius-card); overflow: hidden; }
.group + .group { margin-top: 1.25rem; }
.row {
  display: flex; align-items: center; gap: 0.75rem; width: 100%;
  min-height: 2.75rem; padding: 0.6875rem 1rem; position: relative;
  color: inherit; text-align: left; background: var(--surface);
}
.row + .row::before, .row + form > .row::before, form + .row::before {
  content: ""; position: absolute; top: 0; right: 0; left: 1rem; height: 0.5px; background: var(--separator);
}
.row.inset-sep + .row::before { left: 3.75rem; }
a.row:active, button.row:active { background: var(--fill-2); }
.row-main { flex: 1; min-width: 0; }
.row-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { display: block; font-size: 0.8125rem; color: var(--label-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 0.0625rem; }
.row-value { color: var(--label-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-chev { color: var(--label-3); margin-right: -0.25rem; }
.row .tint { color: var(--tint); }
.row.destructive { color: var(--red); justify-content: center; }
.row.center { justify-content: center; color: var(--tint); }

/* Form rows: label on the left, control on the right, like Settings. */
.field { display: flex; align-items: center; gap: 0.75rem; min-height: 2.75rem; padding: 0 1rem; position: relative; background: var(--surface); }
.field + .field::before { content: ""; position: absolute; top: 0; right: 0; left: 1rem; height: 0.5px; background: var(--separator); }
.field > label, .field > .field-label { flex: none; min-width: 6.5rem; }
.field input, .field select {
  flex: 1; min-width: 0; height: 2.75rem; border: 0; background: transparent; outline: none;
  text-align: right; color: var(--label); -webkit-appearance: none; appearance: none; border-radius: 0;
}
.field input::placeholder { color: var(--label-3); }
.field select { color: var(--tint); text-align-last: right; padding-right: 0; }
.field input[type="date"] { color: var(--tint); min-width: 8rem; }
.field .unit { color: var(--label-2); flex: none; }
.field.left input { text-align: left; }
.field-error { color: var(--red); font-size: 0.8125rem; margin: 0.4375rem 1rem 0; }
.field:focus-within > label { color: var(--tint); }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem; width: 100%;
  min-height: 3.125rem; padding: 0 1.25rem; border-radius: 0.875rem;
  background: var(--tint); color: #fff; font-weight: 600; font-size: 1.0625rem;
  transition: transform 120ms var(--ease-out), opacity 120ms ease;
}
.btn:active { transform: scale(0.97); opacity: 0.85; transition-duration: 0ms; }
.btn.tinted { background: color-mix(in srgb, var(--tint) 14%, transparent); color: var(--tint); }
.btn.gray { background: var(--fill-2); color: var(--tint); }
.btn.sm { min-height: 2.125rem; width: auto; padding: 0 0.875rem; border-radius: 1.0625rem; font-size: 0.9375rem; }
.btn.destructive { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.btn-plain { color: var(--tint); font-size: 1.0625rem; min-height: 2.75rem; padding: 0 0.5rem; }
.btn-plain.strong { font-weight: 600; }
.btn-plain:active { opacity: 0.45; }
.icon-btn {
  width: 1.875rem; height: 1.875rem; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--fill-2); color: var(--tint);
  transition: transform 120ms var(--ease-out);
}
.icon-btn:active { transform: scale(0.9); transition-duration: 0ms; background: var(--fill); }
.icon-btn .icon { width: 1.0625rem; height: 1.0625rem; stroke-width: 2.6; }
/* A 30px visual with a 44px touch target. */
.icon-btn { position: relative; }
.icon-btn::after { content: ""; position: absolute; inset: -0.4375rem; }

.avatar {
  --c: var(--blue);
  width: 2.25rem; height: 2.25rem; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, color-mix(in srgb, var(--c) 78%, #fff), var(--c));
  color: #fff; font-weight: 600; font-size: 0.875rem; letter-spacing: 0.01em;
}
.avatar.lg { width: 3.5rem; height: 3.5rem; font-size: 1.25rem; }
.avatar.xl { width: 5.5rem; height: 5.5rem; font-size: 2rem; }
.c-blue { --c: var(--blue); } .c-pink { --c: var(--pink); } .c-green { --c: #34c759; } .c-orange { --c: var(--orange); }
.c-purple { --c: var(--purple); } .c-teal { --c: var(--teal); } .c-indigo { --c: var(--indigo); } .c-red { --c: var(--red); }
.c-mint { --c: var(--mint); } .c-yellow { --c: var(--yellow); }

/* ------------------------------------------------------------------ rings and bars */
.ring { display: block; flex: none; }
.ring-track { stroke: var(--ring-color); opacity: 0.2; }
.ring-value {
  stroke: var(--ring-color);
  transform: rotate(-90deg); transform-origin: 50% 50%;
  animation: ring-fill 900ms var(--ease-out) both;
}
.ring.energy { --ring-color: var(--energy); }
.ring.body { --ring-color: var(--body); }
.ring.tint { --ring-color: var(--tint); }
@keyframes ring-fill { from { stroke-dashoffset: var(--ring-c); } }

.ring-wrap { position: relative; flex: none; }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }

.hero { display: flex; align-items: center; gap: 1.25rem; }
.hero-stats { flex: 1; min-width: 0; }
.hero-stats .caption { font-size: 0.8125rem; color: var(--label-2); margin-top: 0.375rem; line-height: 1.4; }

.macros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.875rem; margin-top: 1.125rem; }
.macro-label { font-size: 0.75rem; font-weight: 600; color: var(--label-2); }
.macro-value { font-family: var(--font-rounded); font-weight: 600; font-size: 0.9375rem; white-space: nowrap; font-variant-numeric: tabular-nums; margin: 0.125rem 0 0.375rem; }
.macro-value span { color: var(--label-2); font-weight: 500; }
.bar { height: 0.375rem; border-radius: 0.1875rem; background: color-mix(in srgb, var(--bar) 20%, transparent); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--bar); transform-origin: 0 50%; animation: bar-fill 700ms var(--ease-out) both; }
.bar.tint { --bar: var(--tint); } .bar.done { --bar: var(--move); }
.bar.protein { --bar: var(--protein); } .bar.carb { --bar: var(--carb); } .bar.fat { --bar: var(--fat); }
@keyframes bar-fill { from { transform: scaleX(0); } }

/* Week strip: one small ring per day, like the Fitness app's week header. */
.week { display: grid; grid-template-columns: repeat(7, 1fr); margin: 0 -0.25rem 1rem; }
.week-day { display: flex; flex-direction: column; align-items: center; gap: 0.375rem; padding: 0.25rem 0; color: var(--label); border-radius: 0.75rem; }
.week-day .letter {
  width: 1.5rem; height: 1.5rem; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 0.6875rem; font-weight: 600; color: var(--label-2);
}
.week-day.is-today .letter { color: var(--tint); }
.week-day.selected .letter { background: var(--label); color: var(--bg); }
.week-day.selected.is-today .letter { background: var(--tint); color: #fff; }
.week-day.future { opacity: 0.35; pointer-events: none; }
.week-day:active { opacity: 0.55; }

.spark { stroke: var(--body); stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }

.chart { width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--separator); stroke-width: 0.5; }
.chart .axis { fill: var(--label-2); font-size: 10px; font-family: var(--font); }
.chart .area { fill: var(--body); opacity: 0.12; }
.chart .trend { stroke: var(--body); stroke-width: 2.5; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.chart .dot { fill: var(--body); opacity: 0.35; }
.chart .last { fill: var(--surface); stroke: var(--body); stroke-width: 2.5; }

/* ------------------------------------------------------------------ controls */
.search {
  display: flex; align-items: center; gap: 0.375rem; height: 2.25rem; padding: 0 0.5rem;
  background: var(--fill-2); border-radius: 0.625rem; color: var(--label-2);
}
.search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; height: 100%; color: var(--label); -webkit-appearance: none; appearance: none; }
.search input::placeholder { color: var(--label-2); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search-row { display: flex; align-items: center; gap: 0.5rem; position: sticky; top: calc(var(--navbar-h) + var(--safe-top)); z-index: 10; background: var(--bg); padding: 0.25rem 0 0.625rem; }
.search-row .search { flex: 1; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--fill-2); border-radius: 0.5625rem; padding: 0.125rem; position: relative; margin-bottom: 1rem; }
.segmented button { position: relative; z-index: 1; height: 1.875rem; font-size: 0.8125rem; font-weight: 500; border-radius: 0.4375rem; }
.segmented button[aria-selected="true"] { font-weight: 600; }
.segmented .thumb {
  position: absolute; top: 0.125rem; bottom: 0.125rem; left: 0.125rem; width: calc((100% - 0.25rem) / var(--n));
  background: var(--surface); border-radius: 0.4375rem;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 3px 1px rgba(0, 0, 0, 0.04);
  transform: translateX(calc(var(--i) * 100%)); transition: transform 260ms var(--ease-out);
}
@media (prefers-color-scheme: dark) { .segmented .thumb { background: #636366; } }

.stepper { display: inline-flex; align-items: center; background: var(--fill-2); border-radius: 0.5rem; flex: none; }
.stepper button { width: 2.9375rem; height: 2rem; display: flex; align-items: center; justify-content: center; }
.stepper button:active { background: var(--fill); }
.stepper button:first-child { border-radius: 0.5rem 0 0 0.5rem; }
.stepper button:last-child { border-radius: 0 0.5rem 0.5rem 0; }
.stepper i { width: 1px; height: 1.125rem; background: var(--separator); }
.stepper .icon { width: 1.125rem; height: 1.125rem; stroke-width: 2.4; }

.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.625rem; margin-bottom: 1.25rem; }
.action {
  background: var(--surface); border-radius: 0.875rem; padding: 0.75rem 0.5rem; min-height: 4.25rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.3125rem;
  color: var(--tint); font-size: 0.8125rem; font-weight: 500; text-align: center; cursor: pointer;
  transition: transform 120ms var(--ease-out);
}
.action:active { transform: scale(0.96); background: var(--fill-2); transition-duration: 0ms; }

.empty { text-align: center; padding: 2.5rem 1.5rem; color: var(--label-2); }
.empty h3 { color: var(--label); font-size: 1.25rem; font-weight: 700; margin-bottom: 0.375rem; }
.empty p { font-size: 0.9375rem; line-height: 1.4; }
.empty .btn { margin-top: 1.25rem; }

.family-strip { display: flex; gap: 1rem; overflow-x: auto; margin: 0 calc(var(--gutter) * -1); padding: 0.125rem var(--gutter); scrollbar-width: none; }
.family-strip::-webkit-scrollbar { display: none; }
.member { display: flex; flex-direction: column; align-items: center; gap: 0.375rem; color: var(--label); font-size: 0.75rem; flex: none; width: 3.75rem; }
.member:active { opacity: 0.55; }
.member-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.banner { display: flex; align-items: center; gap: 0.625rem; padding: 0.625rem 0.875rem; background: color-mix(in srgb, var(--tint) 12%, var(--surface)); border-radius: 0.875rem; font-size: 0.9375rem; margin-bottom: 0.75rem; }

/* ------------------------------------------------------------------ sheets */
#sheet-root { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
#sheet-root.open { pointer-events: auto; }
.scrim { position: absolute; inset: 0; background: var(--scrim); opacity: 0; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 30rem;
  max-height: calc(100dvh - var(--safe-top) - 2.5rem);
  background: var(--bg); border-radius: 0.875rem 0.875rem 0 0;
  display: flex; flex-direction: column;
  transform: translateY(100%); will-change: transform;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.18);
  /* Extends below the screen so a springy overshoot never shows a gap under the sheet. */
  padding-bottom: 0;
}
.sheet::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 50vh; background: var(--bg); }
.sheet-handle { touch-action: none; cursor: grab; flex: none; }
.sheet-grabber { width: 2.25rem; height: 0.3125rem; border-radius: 0.1875rem; background: var(--label-3); margin: 0.3125rem auto 0; }
.sheet-header { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0.125rem 0.5rem 0.25rem; min-height: 2.75rem; }
.sheet-header h2 { font-size: 1.0625rem; font-weight: 600; text-align: center; }
.sheet-header > :first-child { justify-self: start; }
.sheet-header > :last-child { justify-self: end; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 0.5rem var(--gutter) calc(var(--safe-bottom) + 1.25rem); }
html.sheet-open, html.sheet-open body { background: #000; }
html.sheet-open .app { border-radius: 0.75rem; overflow: hidden; }

.portion-hero { text-align: center; padding: 0.5rem 0 1.25rem; }
.portion-hero .food-name { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; }
.portion-hero .food-brand { color: var(--label-2); font-size: 0.9375rem; margin-top: 0.125rem; }
.portion-hero .metric { font-size: 3rem; margin-top: 0.875rem; color: var(--energy-text); }
.portion-macros { display: flex; justify-content: center; gap: 1.5rem; margin-top: 0.625rem; font-size: 0.8125rem; color: var(--label-2); }
.portion-macros b { font-family: var(--font-rounded); color: var(--label); font-weight: 600; font-size: 1.0625rem; display: block; font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 0.5rem; height: 0.5rem; border-radius: 50%; margin-right: 0.25rem; }
.dot.protein { background: var(--protein); } .dot.carb { background: var(--carb); } .dot.fat { background: var(--fat); }
.qty { display: flex; align-items: center; gap: 0.75rem; flex: 1; justify-content: flex-end; }
.qty input { width: 4.5rem; flex: none; font-family: var(--font-rounded); font-weight: 600; font-variant-numeric: tabular-nums; }
.source-note { font-size: 0.75rem; color: var(--label-2); text-align: center; margin-top: 1rem; }
.fav { color: var(--label-3); min-width: 2.75rem; min-height: 2.75rem; display: inline-flex; align-items: center; justify-content: center; }
.fav.on { color: var(--energy); }
.fav.on .icon { fill: currentColor; }

/* ------------------------------------------------------------------ training */
.ring.move { --ring-color: var(--move); }
.t-move { color: var(--move-text); }
.switch { position: relative; flex: none; width: 3.1875rem; height: 1.9375rem; }
.switch input {
  -webkit-appearance: none; appearance: none; width: 100%; height: 100%; margin: 0; border-radius: 1rem; cursor: pointer;
  background: var(--fill); transition: background 200ms ease; flex: none;
}
.switch input::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 1.6875rem; height: 1.6875rem; border-radius: 50%; background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 3px 1px rgba(0, 0, 0, 0.06); transition: transform 220ms var(--ease-out);
}
.switch input:checked { background: #34c759; }
.switch input:checked::after { transform: translateX(1.25rem); }
.row.question { align-items: center; padding-block: 0.75rem; }
.row.question .row-main { white-space: normal; line-height: 1.3; }

.chips { display: flex; gap: 0.5rem; overflow-x: auto; margin: 0 calc(var(--gutter) * -1) 0.875rem; padding: 0 var(--gutter); scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 2rem; padding: 0 0.875rem; border-radius: 1rem; display: inline-flex; align-items: center;
  background: var(--surface); color: var(--label); font-size: 0.9375rem; font-weight: 500; text-transform: capitalize;
}
.chip[aria-current="true"] { background: var(--label); color: var(--bg); }
.chip:active { opacity: 0.6; }
.tag { display: inline-flex; align-items: center; height: 1.5rem; padding: 0 0.5rem; border-radius: 0.375rem; background: var(--fill-2); font-size: 0.75rem; font-weight: 600; color: var(--label-2); text-transform: capitalize; }
.tags { display: flex; flex-wrap: wrap; gap: 0.375rem; }

.thumb { width: 3.25rem; height: 3.25rem; border-radius: 0.625rem; object-fit: cover; background: var(--fill-2); flex: none; }
.xcard { padding: 0.875rem 1rem 1rem; }
.xcard + .xcard { margin-top: 0.75rem; }
.xcard-head { display: flex; align-items: center; gap: 0.75rem; width: 100%; text-align: left; }
.xcard-head .row-title { font-weight: 600; white-space: normal; line-height: 1.2; }
.xcard.complete .xcard-check { color: #34c759; }
.xcard-check { color: var(--label-3); flex: none; }
.xcard-check .icon { width: 1.625rem; height: 1.625rem; }
.aim { margin-top: 0.75rem; padding: 0.625rem 0.75rem; border-radius: 0.75rem; background: color-mix(in srgb, var(--tint) 10%, transparent); font-size: 0.9375rem; line-height: 1.35; }
.aim b { font-family: var(--font-rounded); font-weight: 700; color: var(--tint); }
.aim .secondary { display: block; font-size: 0.8125rem; margin-top: 0.125rem; }
.last-time { font-size: 0.8125rem; color: var(--label-2); margin-top: 0.5rem; }
.sets { margin-top: 0.625rem; }
.set-row { display: flex; align-items: center; gap: 0.75rem; min-height: 2.5rem; border-top: 0.5px solid var(--separator); font-variant-numeric: tabular-nums; }
.set-no { width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--fill-2); display: inline-flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 700; color: var(--label-2); flex: none; }
.set-row .value { flex: 1; font-family: var(--font-rounded); font-weight: 600; }
.set-form { display: flex; align-items: flex-end; gap: 0.5rem; margin-top: 0.75rem; }
.set-form label { flex: 1; min-width: 0; font-size: 0.6875rem; font-weight: 600; color: var(--label-2); text-transform: uppercase; letter-spacing: 0.03em; }
.set-form input {
  display: block; width: 100%; height: 2.75rem; margin-top: 0.25rem; border: 0; border-radius: 0.625rem; background: var(--fill-2); outline: none;
  text-align: center; font-family: var(--font-rounded); font-weight: 600; font-size: 1.1875rem; color: var(--label); -webkit-appearance: none; appearance: none;
}
.set-form input:focus { box-shadow: 0 0 0 2px var(--tint); }
.set-form .btn { flex: 1.2; min-height: 2.75rem; border-radius: 0.625rem; }
.plain-list { margin: 0; padding: 0; list-style: none; }
.plain-list li { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; padding: 0.5rem 0; border-top: 0.5px solid var(--separator); }
.plain-list li:first-child { border-top: 0; }
.plain-list .detail { color: var(--label-2); font-size: 0.8125rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.plain-list li.stack { display: block; }
.plain-list li.stack .detail { white-space: normal; display: block; margin-top: 0.125rem; line-height: 1.35; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.625rem; margin-top: 0.875rem; }
.btn-row:has(> [hidden]) { grid-template-columns: 1fr; }
.btn-row .btn { font-size: 0.9375rem; padding: 0 0.5rem; white-space: nowrap; }
.steps { margin: 0; padding-left: 1.25rem; line-height: 1.45; }
.steps li { margin-bottom: 0.625rem; }
.demo { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-bottom: 1rem; }
.demo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 0.75rem; background: var(--fill-2); }
.mini { width: 3.25rem; flex: none; }
.mini input { width: 100%; height: 2.25rem; border: 0; border-radius: 0.5rem; background: var(--fill-2); text-align: center; font-family: var(--font-rounded); font-weight: 600; color: var(--label); outline: none; -webkit-appearance: none; appearance: none; }
.mini span { display: block; text-align: center; font-size: 0.6875rem; color: var(--label-2); margin-top: 0.125rem; }

.rank { width: 1.5rem; text-align: center; font-family: var(--font-rounded); font-weight: 700; color: var(--label-2); flex: none; }
.rank.r1 { color: #d4a400; } .rank.r2 { color: #8e8e93; } .rank.r3 { color: #b0683a; }

/* ------------------------------------------------------------------ blood work */
.flag { flex: none; height: 1.375rem; padding: 0 0.5rem; border-radius: 0.6875rem; display: inline-flex; align-items: center; font-size: 0.75rem; font-weight: 600; }
.flag.out { background: color-mix(in srgb, var(--energy) 18%, transparent); color: var(--energy-text); }
.flag.ok { background: color-mix(in srgb, var(--move) 16%, transparent); color: var(--move-text); }
.lab-row { padding: 0.75rem 1rem; position: relative; }
.lab-row + .lab-row::before { content: ""; position: absolute; top: 0; right: 0; left: 1rem; height: 0.5px; background: var(--separator); }
.lab-row > label { display: block; font-weight: 500; margin-bottom: 0.5rem; }
.lab-inputs { display: flex; align-items: center; gap: 0.5rem; }
.lab-inputs + .lab-inputs { margin-top: 0.5rem; }
.lab-inputs input, .lab-inputs select {
  flex: 1; min-width: 0; height: 2.375rem; border: 0; border-radius: 0.5rem; background: var(--fill-2); padding: 0 0.625rem; outline: none;
  color: var(--label); -webkit-appearance: none; appearance: none; font-variant-numeric: tabular-nums;
}
.lab-inputs select { flex: none; width: 6.5rem; color: var(--tint); }
.lab-inputs input:focus { box-shadow: 0 0 0 2px var(--tint); }
.lab-inputs .lab-unit { flex: none; width: 6.5rem; color: var(--label-2); font-size: 0.9375rem; }
.lab-inputs.range { font-size: 0.8125rem; color: var(--label-2); }
.lab-inputs.range input { height: 2rem; font-size: 0.9375rem; }
.chart.lab .band { fill: var(--move); opacity: 0.14; }
.chart.lab .trend { stroke: var(--pink); }
.chart.lab .pt { fill: var(--pink); stroke: var(--surface); stroke-width: 2; }
.chart.lab .pt.out { fill: var(--energy); }

.radio { width: 1.375rem; height: 1.375rem; flex: none; accent-color: var(--tint); margin: 0; }
.notes { display: block; width: 100%; border: 0; background: transparent; padding: 0.75rem 1rem; outline: none; resize: vertical; color: var(--label); line-height: 1.4; -webkit-appearance: none; appearance: none; }
.notes::placeholder { color: var(--label-3); }
.spinner { width: 2rem; height: 2rem; margin: 0 auto; border-radius: 50%; border: 3px solid var(--fill); border-top-color: var(--tint); animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.actions.four { grid-template-columns: repeat(4, 1fr); gap: 0.5rem; }
.actions.four .action { font-size: 0.75rem; padding-inline: 0.25rem; }
.copybox { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8125rem; background: var(--fill-2); border-radius: 0.5rem; padding: 0.625rem 0.75rem; word-break: break-all; user-select: all; -webkit-user-select: all; }

/* ------------------------------------------------------------------ barcode scanner */
.scanner { position: fixed; inset: 0; z-index: 70; background: #000; color: #fff; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* A dimmed frame with a clear window: the cut-out is one big box-shadow around the reticle. */
.scanner-reticle {
  position: absolute; left: 50%; top: 42%; width: min(78vw, 20rem); height: 9.5rem; transform: translate(-50%, -50%);
  border-radius: 1rem; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.55); outline: 2px solid rgba(255, 255, 255, 0.9); outline-offset: -1px;
}
.scanner-top { position: absolute; top: calc(var(--safe-top) + 0.5rem); left: 0.75rem; right: 0.75rem; display: flex; }
.scanner-bottom { position: absolute; left: 1rem; right: 1rem; bottom: calc(var(--safe-bottom) + 1.5rem); display: flex; flex-direction: column; align-items: center; gap: 1rem; text-align: center; }
.scanner-bottom p { font-size: 1.0625rem; font-weight: 500; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }
.scanner-btn {
  display: inline-flex; align-items: center; gap: 0.375rem; min-height: 2.75rem; padding: 0 1rem; border-radius: 1.375rem;
  color: #fff; font-size: 1.0625rem; background: rgba(60, 60, 67, 0.6);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.scanner-btn:active { opacity: 0.6; }
html.scanning, html.scanning body { overflow: hidden; }

/* ------------------------------------------------------------------ toasts */
.toasts { position: fixed; top: calc(var(--safe-top) + 0.5rem); left: 0; right: 0; z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; pointer-events: none; padding: 0 1rem; }
.toast {
  max-width: 26rem; padding: 0.6875rem 1rem; border-radius: 1.375rem;
  background: var(--material); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.16), 0 0 0 0.5px var(--separator);
  font-size: 0.9375rem; font-weight: 500; line-height: 1.3; text-align: center;
  animation: toast-in 420ms var(--ease-out) both; transition: opacity 240ms ease, transform 240ms ease;
}
.toast.leaving { opacity: 0; transform: translateY(-0.75rem); }
.toast.error { color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-1rem) scale(0.96); } }

/* ------------------------------------------------------------------ auth */
.auth { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 2rem 1.5rem calc(var(--safe-bottom) + 2rem); max-width: 26rem; margin: 0 auto; }
.auth-mark { width: 5.5rem; height: 5.5rem; border-radius: 1.375rem; margin: 0 auto 1.5rem; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.14); }
.auth h1 { font-size: 2.125rem; font-weight: 700; letter-spacing: -0.022em; text-align: center; }
.auth .lede { text-align: center; color: var(--label-2); margin: 0.375rem 0 2rem; }
.auth .btn { margin-top: 1.25rem; }
.profile-head { display: flex; flex-direction: column; align-items: center; gap: 0.625rem; padding: 0.5rem 0 0.5rem; }
.profile-head h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.015em; }
.target-grid { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; gap: 0.5rem; }
.target-grid .metric { font-size: 1.375rem; }
.target-grid span { display: block; font-size: 0.75rem; color: var(--label-2); margin-top: 0.125rem; }

/* ------------------------------------------------------------------ page transitions */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 180ms; }
.tabbar { view-transition-name: tabbar; }

/* ------------------------------------------------------------------ accessibility */
:focus-visible { outline: 2px solid var(--tint); outline-offset: 2px; border-radius: 0.375rem; }
.field input:focus-visible, .search input:focus-visible { outline: none; }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .ring-value, .bar > i, .toast { animation: none; }
  .spinner { animation-duration: 2.4s; }
  .segmented .thumb, .btn, .icon-btn, .action { transition: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .navbar::before, .tabbar, .toast { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  :root { --separator: var(--label-2); --label-2: var(--label); }
  .navbar::before, .tabbar, .toast { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .card, .group, .action { outline: 1px solid var(--label-2); }
}

/* On a wide screen the app stays a phone-width column. */
@media (min-width: 40rem) {
  body { background: var(--bg); }
  .app { border-inline: 0.5px solid var(--separator); }
}
