:root {
  color-scheme: light dark;
  --system-background: #ffffff;
  --grouped-background: #f2f2f7;
  --secondary-grouped-background: #ffffff;
  --tertiary-fill: rgba(118, 118, 128, 0.12);
  --quaternary-fill: rgba(116, 116, 128, 0.08);
  --label: #000000;
  --secondary-label: rgba(60, 60, 67, 0.6);
  --tertiary-label: rgba(60, 60, 67, 0.3);
  --separator: rgba(60, 60, 67, 0.29);
  --bar-bg: rgba(249, 249, 249, 0.78);
  --segment-selected: #ffffff;
  --blue: #007aff;
  --green: #34c759;
  --orange: #ff9500;
  --pink: #ff2d55;
  --teal: #30b0c7;
  --red: #ff3b30;
  --purple: #af52de;
  --indigo: #5856d6;
  --ring-track-opacity: 0.18;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.02);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, sans-serif;
  --radius: 14px;
  --spring: cubic-bezier(0.34, 1.36, 0.64, 1);
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --tabbar-h: 50px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --system-background: #000000;
    --grouped-background: #000000;
    --secondary-grouped-background: #1c1c1e;
    --tertiary-fill: rgba(118, 118, 128, 0.24);
    --quaternary-fill: rgba(118, 118, 128, 0.18);
    --label: #ffffff;
    --secondary-label: rgba(235, 235, 245, 0.6);
    --tertiary-label: rgba(235, 235, 245, 0.3);
    --separator: rgba(84, 84, 88, 0.65);
    --bar-bg: rgba(22, 22, 24, 0.72);
    --segment-selected: #636366;
    --blue: #0a84ff;
    --green: #30d158;
    --orange: #ff9f0a;
    --pink: #ff375f;
    --teal: #40c8e0;
    --red: #ff453a;
    --ring-track-opacity: 0.24;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.29;
  letter-spacing: -0.41px;
  color: var(--label);
  background: var(--grouped-background);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  min-height: 100vh;
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; cursor: pointer; }
[hidden] { display: none !important; }
.sprite { position: absolute; }

/* ---------- type scale ---------- */
.large-title { font-size: 34px; line-height: 41px; font-weight: 700; letter-spacing: 0.37px; margin: 0; }
.title1 { font-size: 28px; line-height: 34px; font-weight: 700; letter-spacing: 0.36px; margin: 0; }
.title3 { font-size: 20px; line-height: 25px; font-weight: 600; letter-spacing: 0.38px; margin: 0; }
.headline { font-size: 17px; font-weight: 600; }
.subhead { font-size: 15px; line-height: 20px; letter-spacing: -0.24px; color: var(--secondary-label); margin: 0; }
.footnote { font-size: 13px; line-height: 18px; letter-spacing: -0.08px; color: var(--secondary-label); margin: 0; }
.caption { font-size: 12px; line-height: 16px; color: var(--secondary-label); }
.pad { padding: 6px 16px 0; }
.center { text-align: center; }
.error-text { color: var(--red); font-size: 13px; margin: 8px 0 0; }

/* ---------- icons ---------- */
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.xl { width: 44px; height: 44px; stroke-width: 1.4; }
.tint-blue { color: var(--blue); }
.tint-teal { color: var(--teal); }
.tint-orange { color: var(--orange); }

/* ---------- layout ---------- */
#app { height: 100vh; height: 100dvh; }
.view { position: fixed; inset: 0; display: flex; flex-direction: column; }
.scroller {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: calc(var(--safe-top) + 44px) calc(16px + var(--safe-right)) calc(var(--tabbar-h) + var(--safe-bottom) + 28px) calc(16px + var(--safe-left));
}
.scroller > * { max-width: 640px; margin-left: auto; margin-right: auto; }

/* Navbar: transparent until the large title scrolls away, then frosted with an inline title. */
.navbar {
  position: absolute; z-index: 10; top: 0; left: 0; right: 0;
  height: calc(44px + var(--safe-top));
  padding: var(--safe-top) calc(8px + var(--safe-right)) 0 calc(8px + var(--safe-left));
  display: flex; align-items: center; justify-content: center;
  border-bottom: 0.5px solid transparent;
  transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.navbar-title { font-size: 17px; font-weight: 600; opacity: 0; transform: translateY(4px); transition: opacity 0.2s var(--ease), transform 0.2s var(--ease); }
.navbar.collapsed { background: var(--bar-bg); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%); border-bottom-color: var(--separator); }
.navbar.collapsed .navbar-title { opacity: 1; transform: none; }
.nav-btn { position: absolute; right: calc(8px + var(--safe-right)); bottom: 0; width: 44px; height: 44px; border: 0; background: none; color: var(--blue); display: grid; place-items: center; }
.nav-btn .icon { width: 24px; height: 24px; stroke-width: 2; }

.large-title-row { padding: 4px 4px 12px; }
.large-title-row .subhead { margin-top: 2px; }

.section-header { font-size: 13px; font-weight: 400; text-transform: uppercase; letter-spacing: -0.08px; color: var(--secondary-label); margin: 26px 16px 7px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }

/* ---------- cards & grouped lists ---------- */
.card { background: var(--secondary-grouped-background); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 12px; }
.list { overflow: hidden; }
.row {
  position: relative; display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 11px 16px; width: 100%;
  background: none; border: 0; text-align: left;
}
.row + .row::before { content: ''; position: absolute; top: 0; left: 16px; right: 0; border-top: 0.5px solid var(--separator); }
.row.column { flex-direction: column; align-items: stretch; gap: 10px; }
.row-label { flex: 1; min-width: 0; }
.row-value { color: var(--secondary-label); }
.row.action { color: var(--blue); }
.row.action .row-label { color: var(--label); }
.row.action.destructive .row-label { color: var(--red); text-align: center; }
.row.action:active { background: var(--tertiary-fill); }
.chevron { width: 16px; height: 16px; color: var(--tertiary-label); stroke-width: 2.4; }

.row.field input:not([type=checkbox]) {
  flex: 1; min-width: 0; text-align: right; border: 0; outline: none; background: none; padding: 0;
  font-size: 17px; color: var(--secondary-label); min-height: 22px;
}
.row.field input:focus { color: var(--label); }
.row.field input::placeholder { color: var(--tertiary-label); }
.row.field input[type=time], .row.field input[type=date] { flex: none; -webkit-appearance: none; appearance: none; background: var(--tertiary-fill); color: var(--label); border-radius: 8px; padding: 6px 10px; min-width: 92px; text-align: center; }
.row.field.invalid input { color: var(--red); }
.row .unit { color: var(--secondary-label); font-size: 15px; min-width: 32px; }
.row.field .field-error { position: absolute; right: 16px; bottom: 1px; font-size: 11px; color: var(--red); }
.target-row input { max-width: 90px; }

/* ---------- buttons ---------- */
.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px; border-radius: 999px; border: 0;
  font-size: 17px; font-weight: 600; background: none; color: var(--blue);
  transition: transform 0.25s var(--spring), opacity 0.2s;
}
.pill .icon { width: 20px; height: 20px; }
.pill.filled { background: var(--blue); color: #fff; }
.pill.tinted { background: color-mix(in srgb, var(--blue) 15%, transparent); color: var(--blue); }
.pill.tinted.teal { background: color-mix(in srgb, var(--teal) 16%, transparent); color: var(--teal); }
.pill.tinted.orange { background: color-mix(in srgb, var(--orange) 16%, transparent); color: var(--orange); }
.pill.plain.small { min-height: 44px; font-size: 15px; font-weight: 400; padding: 0 8px; color: var(--secondary-label); }
.pill.wide { display: flex; width: 100%; margin-top: 16px; }
.pill:disabled { opacity: 0.4; }
.pill:active, .card.quick button:active, .photo-pick:active, .tabbar button:active, .icon-btn:active, .nav-btn:active { transform: scale(0.97); }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; background: none; border: 0; color: var(--secondary-label); flex: none; }

.pill-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pill-row.three { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.pill-row .pill { padding: 0 4px; font-size: 15px; }

/* ---------- segmented control ---------- */
.segmented { display: flex; background: var(--tertiary-fill); border-radius: 9px; padding: 2px; gap: 2px; position: relative; }
.segmented button {
  flex: 1; min-height: 32px; border: 0; border-radius: 7px; background: none; font-size: 13px; font-weight: 500; white-space: nowrap; padding: 0 6px;
  transition: background-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.segmented button.on { background: var(--segment-selected); font-weight: 600; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 3px 1px rgba(0, 0, 0, 0.04); }
.segmented.compact { flex: none; min-width: 210px; }
/* Taller hit area while keeping the visual compact */
.segmented button { position: relative; }
.segmented button::after { content: ''; position: absolute; inset: -6px 0; }

/* ---------- switch ---------- */
.switch {
  -webkit-appearance: none; appearance: none; flex: none; position: relative;
  width: 51px; height: 31px; border-radius: 31px; margin: 0; background: var(--tertiary-fill); cursor: pointer;
  transition: background-color 0.25s var(--ease);
}
.switch::before {
  content: ''; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; 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 0.3s var(--spring);
}
.switch:checked { background: var(--green); }
.switch:checked::before { transform: translateX(20px); }

/* ---------- today ---------- */
.banner { display: flex; gap: 12px; align-items: center; padding: 12px 4px 12px 16px; margin-bottom: 12px; border-radius: var(--radius); background: color-mix(in srgb, var(--blue) 12%, var(--secondary-grouped-background)); }
.banner p { margin: 0; font-size: 15px; line-height: 20px; flex: 1; }
.banner > .icon { color: var(--blue); }
.motivation { display: flex; gap: 12px; padding: 16px; align-items: flex-start; }
.motivation .icon { color: var(--orange); margin-top: 1px; }
.motivation p { margin: 0; font-size: 17px; line-height: 23px; }

.rings-card { display: flex; align-items: center; gap: 16px; padding: 16px; margin-top: 12px; }
.rings { width: 46%; max-width: 190px; flex: none; transform: rotate(-90deg); }
.rings .track { opacity: var(--ring-track-opacity); }
.rings .fill { transition: stroke-dashoffset 1.1s var(--spring); }
.ring-legend { list-style: none; margin: 0; padding: 0; flex: 1; display: grid; gap: 10px; min-width: 0; }
.ring-legend li { display: grid; gap: 0; }
.ring-legend .lbl { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0; }
.ring-legend .val { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: 0.2px; }
.ring-legend .val small { font-size: 13px; font-weight: 500; color: var(--secondary-label); }

.card.quick { padding: 14px 12px 6px; display: flex; flex-direction: column; gap: 8px; margin: 0; }
.quick-head { display: flex; align-items: center; gap: 6px; padding-left: 2px; }
.big-num { margin: 0; padding-left: 2px; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.big-num small { font-size: 13px; font-weight: 500; color: var(--secondary-label); }

.bar-row { display: grid; grid-template-columns: 1fr auto; row-gap: 6px; }
.bar-row .row-value { font-size: 15px; font-variant-numeric: tabular-nums; }
.bar { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: var(--tertiary-fill); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 4px; width: 0; transition: width 0.9s var(--spring); }

.suggestion { padding: 14px 16px; }
.suggestion + .suggestion { margin-top: 12px; }
.suggestion h3 { font-size: 17px; font-weight: 600; margin: 0 0 4px; display: flex; gap: 8px; align-items: center; }
.suggestion p { margin: 0; color: var(--secondary-label); font-size: 15px; line-height: 20px; }
.suggestion ul { list-style: none; margin: 10px 0 0; padding: 0; }
.suggestion li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 0.5px solid var(--separator); font-size: 15px; }
.suggestion li .amt { color: var(--secondary-label); font-size: 13px; display: block; }
.suggestion li .det { color: var(--green); font-weight: 600; white-space: nowrap; font-size: 15px; }
.suggestion.warn h3 { color: var(--orange); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }

/* ---------- food ---------- */
.photo-pick { display: block; position: relative; overflow: hidden; min-height: 200px; cursor: pointer; transition: transform 0.25s var(--spring); }
.photo-pick input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.photo-pick img { display: block; width: 100%; max-height: 360px; object-fit: cover; }
.photo-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 200px; padding: 20px; text-align: center; color: var(--blue); }
.photo-empty .headline { color: var(--label); }
#photo-clear { display: flex; margin: 4px auto 8px; }
#meal-type-seg { margin: 0 0 4px; }

/* ---------- log ---------- */
.meal-row { align-items: flex-start; }
.meal-row .meta { flex: 1; min-width: 0; }
.meal-row .title { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.meal-row .sub { font-size: 13px; color: var(--secondary-label); margin-top: 2px; }
.meal-row .kcal { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; padding-top: 1px; }
.meal-row .icon-btn { margin: -10px -12px -10px 0; color: var(--red); }
.empty { padding: 20px 16px; color: var(--secondary-label); text-align: center; font-size: 15px; }
.hist-row { display: grid; grid-template-columns: 86px repeat(4, 1fr); gap: 8px; align-items: center; }
.hist-row .d { font-weight: 600; font-size: 15px; }
.hist-row .d small { display: block; font-weight: 400; font-size: 12px; color: var(--secondary-label); }
.hist-cell { display: grid; gap: 4px; font-size: 13px; font-variant-numeric: tabular-nums; }
.hist-cell .mini { height: 4px; border-radius: 2px; background: var(--tertiary-fill); overflow: hidden; }
.hist-cell .mini span { display: block; height: 100%; }
.hist-head { font-size: 12px; color: var(--secondary-label); text-transform: uppercase; min-height: 32px; padding-top: 8px; padding-bottom: 4px; }
.hist-head + .row::before { display: none; }

/* ---------- settings ---------- */
.walk-time-row input[type=time] { margin-left: auto; }
.walk-time-row .icon-btn { margin-right: -12px; color: var(--red); }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 0;
  display: flex; padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
  background: var(--bar-bg); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
  border-top: 0.5px solid var(--separator);
}
.tabbar button {
  flex: 1; height: var(--tabbar-h); border: 0; background: none; color: rgba(153, 153, 153, 1);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 10px; font-weight: 500; letter-spacing: 0.1px; transition: transform 0.25s var(--spring);
}
.tabbar button .icon { width: 26px; height: 26px; stroke-width: 1.7; }
.tabbar button.active { color: var(--blue); }
.tabbar button.active .icon { stroke-width: 2.1; }

/* ---------- login ---------- */
.login { min-height: 100vh; min-height: 100dvh; max-width: 440px; margin: 0 auto; display: flex; flex-direction: column; justify-content: center; padding: calc(var(--safe-top) + 24px) 16px calc(var(--safe-bottom) + 24px); text-align: center; }
.login-icon { border-radius: 20px; margin: 0 auto 16px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12); }
.login .subhead { margin: 6px 0 24px; }
.login .row-label { text-align: left; flex: 0 0 64px; }
.login .row.field input { text-align: left; color: var(--label); }

/* ---------- bottom sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.4); opacity: 0; transition: opacity 0.3s var(--ease); }
.sheet-backdrop.open { opacity: 1; }
.sheet {
  position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; max-width: 640px; margin: 0 auto;
  max-height: calc(100dvh - var(--safe-top) - 24px); display: flex; flex-direction: column;
  background: var(--grouped-background); border-radius: 12px 12px 0 0;
  transform: translateY(100%); transition: transform 0.42s var(--spring);
  box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.15);
}
.sheet.open { transform: none; }
.grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--tertiary-label); margin: 6px auto 4px; flex: none; touch-action: none; }
.grabber::after { content: ''; display: block; height: 30px; margin-top: -12px; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 4px 16px calc(var(--safe-bottom) + 20px); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 4px; }
.sheet-head .pill { padding: 0 8px; }

.item-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 8px; align-items: center; }
.item-row .name-input { font-weight: 600; border: 0; background: none; outline: none; padding: 0; min-width: 0; font-size: 17px; }
.item-row .qty-input { border: 0; background: none; outline: none; padding: 0; min-width: 0; font-size: 15px; color: var(--secondary-label); grid-column: 1 / 2; }
.item-row .icon-btn { grid-row: 1 / 3; grid-column: 2; margin-right: -12px; color: var(--red); }
.macro-inputs { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.macro-inputs label { display: grid; gap: 2px; text-align: center; font-size: 11px; color: var(--secondary-label); text-transform: uppercase; }
.macro-inputs input { color: var(--label); width: 100%; text-align: center; border: 0; border-radius: 8px; background: var(--tertiary-fill); padding: 8px 2px; font-size: 16px; font-variant-numeric: tabular-nums; outline: none; }
.macro-inputs input:focus { box-shadow: 0 0 0 2px var(--blue) inset; }
.macro-inputs input.invalid { box-shadow: 0 0 0 2px var(--red) inset; }
.totals-strip { display: grid; grid-template-columns: repeat(5, 1fr); text-align: center; padding: 12px 8px; }
.totals-strip b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.totals-strip span { font-size: 11px; text-transform: uppercase; color: var(--secondary-label); }
.confidence { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--tertiary-fill); color: var(--secondary-label); text-transform: capitalize; }

/* Skeleton while analysing */
.skeleton { display: grid; gap: 12px; padding: 8px 0 20px; }
.skeleton .sk { height: 16px; border-radius: 6px; background: linear-gradient(90deg, var(--tertiary-fill) 25%, var(--quaternary-fill) 50%, var(--tertiary-fill) 75%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
.skeleton .sk.lg { height: 64px; border-radius: var(--radius); }
.skeleton .sk.w60 { width: 60%; }
.analyzing { display: flex; align-items: center; gap: 10px; color: var(--secondary-label); font-size: 15px; padding: 8px 0 4px; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--tertiary-fill); border-top-color: var(--blue); animation: spin 0.8s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- toast ---------- */
.toast {
  position: fixed; z-index: 60; left: 0; right: 0; top: calc(var(--safe-top) + 10px); transform: translateY(-20px); opacity: 0;
  width: max-content; max-width: calc(100% - 32px); margin: 0 auto; padding: 12px 18px; border-radius: 999px; font-size: 15px; font-weight: 500;
  background: var(--bar-bg); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18); transition: transform 0.4s var(--spring), opacity 0.25s var(--ease);
  text-align: center;
}
.toast.show { transform: none; opacity: 1; }
.toast.error { color: var(--red); }

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

/* Spacing for cards that follow a footnote or hidden helper button */
.pad + .card { margin-top: 20px; }
#photo-clear + .card { margin-top: 12px; }

/* ---------- admin viewing another person ---------- */
.person-seg { margin: 0 0 12px; }
body.viewing-other .own-only { display: none !important; }

/* ---------- weight card ---------- */
.weight-card {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; width: 100%; margin-top: 12px; padding: 12px 16px;
  min-height: 52px; border: 0; text-align: left; color: var(--label); transition: transform 0.25s var(--spring);
}
.weight-card:active:not(:disabled) { transform: scale(0.98); }
.weight-card .w-main { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; flex-wrap: wrap; }
.weight-card .w-main .icon { color: var(--purple); }
.weight-card b { font-size: 20px; font-variant-numeric: tabular-nums; }
.weight-card .w-sub { font-size: 13px; color: var(--secondary-label); }
.weight-card .w-good { font-size: 13px; font-weight: 600; color: var(--green); }
.w-diff { font-size: 13px; color: var(--secondary-label); min-width: 40px; text-align: right; font-variant-numeric: tabular-nums; }
.w-diff.down { color: var(--green); }
.w-diff.up { color: var(--orange); }

/* ---------- settings additions ---------- */
.notes-card { margin-top: 12px; }
.notes-card textarea {
  width: 100%; border: 0; outline: none; resize: vertical; background: var(--tertiary-fill); border-radius: 10px;
  padding: 10px 12px; font-size: 16px; line-height: 1.35; color: var(--label); min-height: 96px;
}

/* ---------- tab badge ---------- */
.tabbar button { position: relative; }
.badge {
  position: absolute; top: 3px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--red); color: #fff; font-size: 12px; font-weight: 600; line-height: 18px; text-align: center;
}

/* ---------- chat ---------- */
.chat-view .navbar { background: var(--bar-bg); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%); border-bottom-color: var(--separator); }
.chat-view .navbar-title { opacity: 1; transform: none; text-align: center; line-height: 1.15; }
.chat-title { display: flex; flex-direction: column; align-items: center; }
.chat-title .caption { font-weight: 400; }
.chat-view { background: var(--system-background); }
.chat-scroller { padding-top: calc(var(--safe-top) + 56px); padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 72px); }
body.kb-open .chat-scroller { padding-bottom: 72px; }
.chat-list { display: flex; flex-direction: column; gap: 2px; }
#chat-older { display: flex; margin: 0 auto 8px; color: var(--blue); }
.chat-time { text-align: center; font-size: 12px; color: var(--secondary-label); margin: 14px 0 6px; font-weight: 500; }
.chat-empty { text-align: center; color: var(--secondary-label); padding: 40px 20px; }
.chat-empty span { font-size: 44px; }
.chat-empty p { font-size: 15px; line-height: 21px; }

.bubble-row { display: flex; align-items: flex-end; gap: 6px; max-width: 100%; }
.bubble-row.mine { justify-content: flex-end; }
.bubble-row.tail { margin-bottom: 6px; }
.bubble-col { display: flex; flex-direction: column; gap: 4px; max-width: 78%; min-width: 0; }
.bubble-row.mine .bubble-col { align-items: flex-end; }
.sender { font-size: 12px; color: var(--secondary-label); margin: 6px 0 0 12px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--tertiary-fill); font-size: 14px; font-weight: 600; color: var(--secondary-label);
}
.avatar.spacer { visibility: hidden; }
.bubble-row.coach .avatar { background: color-mix(in srgb, var(--green) 20%, transparent); }
.bubble {
  padding: 8px 13px; border-radius: 18px; font-size: 17px; line-height: 22px; letter-spacing: -0.4px;
  background: var(--tertiary-fill); color: var(--label); overflow-wrap: anywhere; white-space: normal;
}
.bubble-row.mine .bubble { background: var(--blue); color: #fff; }
.bubble-row.coach .bubble { background: color-mix(in srgb, var(--green) 16%, var(--secondary-grouped-background)); }
.bubble-row.mine.tail .bubble { border-bottom-right-radius: 6px; }
.bubble-row.theirs.tail .bubble, .bubble-row.coach.tail .bubble { border-bottom-left-radius: 6px; }
.receipt { text-align: right; font-size: 11px; color: var(--secondary-label); margin: -2px 4px 4px; min-height: 13px; }

.poke {
  display: grid; justify-items: center; gap: 2px; padding: 12px 18px; border-radius: 20px;
  background: color-mix(in srgb, var(--orange) 14%, var(--secondary-grouped-background)); min-width: 150px; text-align: center;
}
.bubble-row.mine .poke { background: color-mix(in srgb, var(--blue) 16%, var(--secondary-grouped-background)); }
.poke-emoji { font-size: 40px; line-height: 1.1; animation: poke-pop 0.6s var(--spring); }
.poke-text { font-weight: 600; font-size: 16px; }
.poke-to { font-size: 12px; color: var(--secondary-label); }
@keyframes poke-pop { 0% { transform: scale(0.3) rotate(-20deg); } 70% { transform: scale(1.15) rotate(8deg); } 100% { transform: none; } }

.meme {
  position: relative; width: 240px; max-width: 100%; border-radius: 16px; overflow: hidden; background: #000;
  display: grid; place-items: center; min-height: 180px;
}
.meme img { display: block; width: 100%; height: auto; max-height: 340px; object-fit: cover; }
.meme-emoji { font-size: 84px; line-height: 1; padding: 44px 0; }
.meme-text {
  position: absolute; left: 8px; right: 8px; text-align: center; color: #fff; text-transform: uppercase;
  font-family: Impact, "Anton", "Arial Black", var(--font); font-weight: 900; font-size: 22px; line-height: 1.05; letter-spacing: 0.5px;
  -webkit-text-stroke: 1.5px #000; paint-order: stroke fill;
  text-shadow: 0 2px 0 #000, 0 -2px 0 #000, 2px 0 0 #000, -2px 0 0 #000; overflow-wrap: anywhere;
}
.meme-text.top { top: 8px; }
.meme-text.bottom { bottom: 8px; }
.meme-bg-0 { background: linear-gradient(135deg, #ff9a8b, #ff6a88); }
.meme-bg-1 { background: linear-gradient(135deg, #30b0c7, #34c759); }
.meme-bg-2 { background: linear-gradient(135deg, #5856d6, #af52de); }
.meme-bg-3 { background: linear-gradient(135deg, #ff9500, #ffcc00); }
.meme-bg-4 { background: linear-gradient(135deg, #007aff, #30b0c7); }
.meme-bg-5 { background: linear-gradient(135deg, #1c1c1e, #48484a); }
#meme-preview { display: grid; place-items: center; margin-top: 8px; }
#meme-preview .meme { width: 100%; max-width: 320px; }

.bubble-row.coach.typing .bubble { display: flex; gap: 4px; padding: 12px 14px; }
.typing .bubble span { width: 8px; height: 8px; border-radius: 50%; background: var(--secondary-label); animation: typing 1.2s infinite ease-in-out; }
.typing .bubble span:nth-child(2) { animation-delay: 0.15s; }
.typing .bubble span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing { 0%, 60%, 100% { opacity: 0.3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }

.composer {
  position: fixed; z-index: 15; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  display: flex; align-items: center; gap: 6px; padding: 6px calc(10px + var(--safe-right)) 6px calc(6px + var(--safe-left));
  background: var(--bar-bg); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
  border-top: 0.5px solid var(--separator);
}
body.kb-open .composer { bottom: var(--kb, 0px); }
body.kb-open .tabbar { display: none; }
.composer input {
  flex: 1; min-width: 0; height: 36px; border-radius: 18px; border: 0.5px solid var(--separator); background: var(--system-background);
  padding: 0 14px; font-size: 16px; outline: none;
}
.composer-btn { width: 40px; height: 44px; border: 0; background: none; color: var(--blue); display: grid; place-items: center; flex: none; }
.composer-btn .icon { width: 26px; height: 26px; }
.send-btn { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--blue); color: #fff; display: grid; place-items: center; flex: none; transition: transform 0.2s var(--spring), opacity 0.2s; }
.send-btn .icon { width: 20px; height: 20px; stroke-width: 2.6; }
.send-btn:disabled { opacity: 0.35; }
.composer-btn:active, .send-btn:active:not(:disabled) { transform: scale(0.92); }

.poke-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.poke-choice {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 8px; min-height: 88px; border: 0; border-radius: 16px;
  background: var(--secondary-grouped-background); font-size: 15px; font-weight: 500; transition: transform 0.25s var(--spring);
}
.poke-choice span { font-size: 34px; }
.poke-choice:active { transform: scale(0.95); }
.emoji-row { display: flex; flex-wrap: wrap; gap: 8px; }
.emoji-choice, .swatch { width: 44px; height: 44px; border-radius: 12px; border: 2px solid transparent; font-size: 24px; display: grid; place-items: center; }
.emoji-choice { background: var(--secondary-grouped-background); }
.emoji-choice.on, .swatch.on { border-color: var(--blue); }

/* ---------- poke card on Today ---------- */
.poke-card { padding: 10px 12px 12px 16px; margin-top: 12px; }
.poke-head { display: flex; align-items: center; justify-content: space-between; }
.poke-head .pill.plain.small { color: var(--blue); }
.poke-chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 4px; }
.poke-chip {
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 64px; padding: 8px 4px; border: 0; border-radius: 14px;
  background: color-mix(in srgb, var(--pink) 10%, var(--tertiary-fill)); font-size: 13px; font-weight: 600; color: var(--label);
  transition: transform 0.25s var(--spring), opacity 0.2s;
}
.poke-chip span { font-size: 26px; line-height: 1.1; }
.poke-chip:active { transform: scale(0.92); }
.poke-chip:disabled { opacity: 0.5; }

/* ---------- energy / BMR ---------- */
.weight-card .w-energy { flex-basis: 100%; font-size: 13px; color: var(--secondary-label); padding-left: 30px; }
.row.auto-locked input { color: var(--green) !important; }
.row.auto-locked .unit::after { content: ' · auto'; color: var(--green); }
#energy-card .row-value b { color: var(--label); }
