:root {
  /* Apple Health-style system colors. Dark is the default (see index.html). */
  --bg: #f2f2f7;
  --card: #ffffff;
  --card-2: #e9e9eb;
  --text: #000000;
  --muted: #6d6d72;
  --line: #d1d1d6;
  --accent: #007aff;
  --accent-soft: rgba(0, 122, 255, 0.12);
  --danger: #ff3b30;
  --user-bubble: #e9e9eb;
  --seg-bg: rgba(118, 118, 128, 0.12);
  --seg-on: #ffffff;
  --tabbar: rgba(249, 249, 249, 0.82);
  --imsg-in: #e9e9eb;
  --imsg-out: #007aff;
  --radius: 18px;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", 'Inter', system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", 'Inter', system-ui, sans-serif;
  --font-serif: 'Source Serif 4', 'Iowan Old Style', Georgia, serif;
  /* charts: validated categorical slots */
  --series-1: #007aff;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --grid: #e5e5ea;
  --axis: #c7c7cc;
  --band: rgba(0, 122, 255, 0.08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --card: #1c1c1e; --card-2: #2c2c2e; --text: #ffffff; --muted: #98989f; --line: #38383a;
    --accent: #0a84ff; --accent-soft: rgba(10, 132, 255, 0.16); --danger: #ff453a; --user-bubble: #2c2c2e;
    --seg-bg: rgba(118, 118, 128, 0.24); --seg-on: #636366; --tabbar: rgba(30, 30, 32, 0.78);
    --imsg-in: #262628; --imsg-out: #0a84ff;
    --series-1: #0a84ff; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --grid: #2c2c2e; --axis: #48484a; --band: rgba(10, 132, 255, 0.14);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --card: #1c1c1e; --card-2: #2c2c2e; --text: #ffffff; --muted: #98989f; --line: #38383a;
    --accent: #0a84ff; --accent-soft: rgba(10, 132, 255, 0.16); --danger: #ff453a; --user-bubble: #2c2c2e;
    --seg-bg: rgba(118, 118, 128, 0.24); --seg-on: #636366; --tabbar: rgba(30, 30, 32, 0.78);
    --imsg-in: #262628; --imsg-out: #0a84ff;
    --series-1: #0a84ff; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --grid: #2c2c2e; --axis: #48484a; --band: rgba(10, 132, 255, 0.14);
    color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
h1 { font: 700 34px/1.15 var(--font-display); margin: 10px 0 14px; letter-spacing: 0.01em; }
h2 { font: 700 22px/1.25 var(--font-display); }
h2 { font-size: 20px; margin: 18px 0 10px; }
h3 { font: 700 20px/1.3 var(--font-display); margin: 24px 0 10px; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.block { display: block; }

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 100px);
}
body.public .page { padding-bottom: 40px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.warn { border-color: var(--danger); }
.pill {
  display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 2px 8px; vertical-align: middle;
}

/* ---------- Tabs ---------- */
/* Apple Health-style bottom bar: a glass capsule of tabs + a separate round button */
.tabbar {
  position: fixed; z-index: 10;
  left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 4px);
  max-width: 560px; margin: 0 auto;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  pointer-events: none;
}
.tabbar[hidden] { display: none; }
.tab-pill, .tab-round {
  pointer-events: auto;
  background: var(--tabbar);
  backdrop-filter: saturate(180%) blur(22px); -webkit-backdrop-filter: saturate(180%) blur(22px);
  box-shadow: inset 0 0 0 0.5px color-mix(in srgb, var(--text) 16%, transparent), 0 8px 28px rgb(0 0 0 / 0.35);
}
.tab-pill { display: flex; flex: 1; min-width: 0; max-width: 420px; padding: 4px; border-radius: 999px; }
.tab-pill a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; min-width: 0; height: 54px; padding: 0 4px; border-radius: 999px; white-space: nowrap;
  color: var(--text); text-decoration: none; font-size: 11px; font-weight: 600; letter-spacing: 0.01em;
  transition: transform 0.18s cubic-bezier(.3,.7,.4,1.4), background-color 0.2s;
}
.tab-pill a.active { color: var(--accent); background: color-mix(in srgb, var(--text) 11%, transparent); }
.tab-round {
  display: grid; place-items: center; flex: none;
  width: 62px; height: 62px; border-radius: 50%;
  color: var(--text); text-decoration: none;
  transition: transform 0.18s cubic-bezier(.3,.7,.4,1.4);
}
.tab-round.active { color: var(--accent); }
.tab-round .tab-icon { width: 27px; height: 27px; margin: 0; }
.tab-pill a:active, .tab-round:active { transform: scale(0.92); }
.tab-icon { display: block; width: 26px; height: 26px; margin: 0 auto 2px; }
@media (prefers-reduced-motion: reduce) { .tab-pill a, .tab-round { transition: none; } }
body.typing .tabbar { display: none; }

/* ---------- Buttons & forms ---------- */
.btn {
  display: block; width: 100%; text-align: center; text-decoration: none;
  border: 0; border-radius: 999px; padding: 14px; font: inherit; font-size: 17px; font-weight: 600;
  background: var(--accent); color: #fff; margin-top: 12px;
}
.btn.secondary { background: var(--card-2); color: var(--accent); }
.btn.danger { background: var(--card); color: var(--danger); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: var(--card-2); color: var(--accent); font-size: 20px; font-weight: 600; text-decoration: none;
}
.icon-btn.disabled { opacity: 0.3; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 15px; }
label.check input { width: auto; }
input, textarea, select {
  width: 100%; font: inherit; font-size: 17px; color: var(--text);
  background: var(--card-2); border: 0; border-radius: 10px; padding: 11px 12px;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.row > * { min-width: 0; }
input[type="time"], input[type="date"] { min-width: 0; max-width: 100%; }
.row label { margin-top: 8px; }
.code {
  font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; user-select: all;
}
code { font: 13px ui-monospace, Menlo, monospace; }
.segmented { display: flex; background: var(--seg-bg); border-radius: 10px; padding: 2px; gap: 2px; margin: 4px 0 10px; }
.segmented button {
  flex: 1; border: 0; background: transparent; color: var(--text); border-radius: 8px; padding: 7px 0;
  font: inherit; font-size: 14px; font-weight: 600;
}
.segmented button.on { background: var(--seg-on); box-shadow: 0 2px 6px rgb(0 0 0 / 0.18); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { border: 0; background: var(--card-2); color: var(--accent); font-weight: 600; border-radius: 999px; padding: 7px 12px; font: inherit; font-size: 14px; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 84px);
  background: var(--card-2); color: var(--text); padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 20; box-shadow: 0 6px 24px rgb(0 0 0 / 0.3);
  max-width: calc(100% - 32px);
}
.subnav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; min-height: 36px; }
.back { text-decoration: none; font-size: 16px; }
.subnav-arrows { display: flex; gap: 8px; }
.login { max-width: 360px; margin: 18vh auto 0; }

/* ---------- Chat (Claude-style) ---------- */
body[data-screen="chat"] .page { padding-bottom: calc(env(safe-area-inset-bottom) + 200px); }
body[data-screen="chat"].typing .page { padding-bottom: 140px; }
.chat-log { display: flex; flex-direction: column; gap: 14px; }
.chat-empty { text-align: center; margin-top: 26vh; }
.chat-empty h1 { font: 400 30px/1.2 var(--font-serif); }
.chat-date { align-self: center; font-size: 12px; color: var(--muted); margin: 10px 0 2px; }
.msg { max-width: 100%; }
.msg.user { align-self: flex-end; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; max-width: 85%; }
.msg-bubble { background: var(--user-bubble); border-radius: 18px; padding: 9px 14px; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 100%; }
.msg-photos { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.msg-photos img { width: 120px; height: 120px; object-fit: cover; border-radius: 14px; display: block; }
.msg.assistant { align-self: stretch; font: 17px/1.55 var(--font-serif); }
.msg.assistant .msg-head { font-weight: 600; }
.msg.assistant p { margin: 0 0 6px; }
.msg.assistant ul { margin: 0 0 8px; padding-left: 20px; }
.msg.assistant li { margin: 2px 0; }
.msg-head { font-weight: 600; }
.msg-total { color: var(--muted); font: 14px/1.45 var(--font-sans); font-variant-numeric: tabular-nums; }
.msg-warn { color: var(--danger); }
.msg.error { color: var(--danger); font-family: var(--font-sans); font-size: 15px; }
.msg { overflow-wrap: anywhere; }
.msg-report { white-space: pre-wrap; font: 14px/1.5 ui-monospace, Menlo, monospace; background: var(--card); border-radius: 12px; padding: 12px; margin: 0 0 8px; }
.msg-link { display: inline-block; font-weight: 600; text-decoration: none; margin-top: 2px; }
.typing-dots { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite ease-in-out; }
.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .typing-dots i { animation: none; opacity: 0.6; } }

.chat-dock {
  position: fixed; left: 0; right: 0; z-index: 9;
  bottom: calc(env(safe-area-inset-bottom) + 72px);
  padding: 8px 12px 10px;
  background: linear-gradient(to bottom, transparent, var(--bg) 18px);
}
body.typing .chat-dock { bottom: 0; padding-bottom: 10px; }
.chat-dock > * { max-width: 640px; margin-left: auto; margin-right: auto; }
.composer {
  background: var(--card); border: 1px solid color-mix(in srgb, var(--text) 8%, transparent); border-radius: 24px;
  padding: 12px 10px 8px 16px; box-shadow: 0 4px 20px rgb(0 0 0 / 0.25);
}
.composer textarea {
  border: 0; padding: 2px 0; background: transparent; font-size: 17px; resize: none; min-height: 24px; max-height: 160px; line-height: 1.4;
}
.composer textarea:focus { outline: none; }
.composer-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.attach {
  display: grid; place-items: center; width: 34px; height: 34px; margin: 0; border-radius: 50%;
  background: var(--card-2); color: var(--text); cursor: pointer;
}
.send {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; border: 0;
  background: var(--accent); color: #fff;
}
.send:disabled { background: var(--card-2); color: var(--muted); }
.photo-previews { display: flex; gap: 8px; }
.photo-previews:not(:empty) { margin-bottom: 8px; }
.thumb { position: relative; padding: 0; border: 0; background: none; }
.thumb img { width: 60px; height: 60px; object-fit: cover; border-radius: 10px; display: block; }
.thumb span {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--card-2); color: var(--text); font-size: 14px; line-height: 20px;
}

/* ---------- History ---------- */
.calendar { padding: 12px; }
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal-dow { font-size: 11px; color: var(--muted); padding: 4px 0; }
.cal-cell {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  min-height: 48px; padding-top: 4px; border-radius: 10px; text-decoration: none; color: var(--text);
}
.cal-cell.future { color: var(--muted); opacity: 0.45; }
.cal-num { width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-size: 15px; font-variant-numeric: tabular-nums; }
.cal-cell.today .cal-num { color: var(--accent); font-weight: 700; }
.cal-cell.selected .cal-num { background: var(--accent); color: #fff; font-weight: 700; }
.cal-head strong { font: 700 17px var(--font-display); }
.cal-kcal { font-size: 10px; color: var(--muted); line-height: 1.2; font-variant-numeric: tabular-nums; }
.cal-lock { position: absolute; top: 2px; right: 4px; font-size: 9px; color: var(--accent); }
.day-detail h2 { margin-top: 20px; }
.kv-list { padding: 4px 14px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-top: 0.5px solid var(--line); font-variant-numeric: tabular-nums; }
.kv:first-child { border-top: 0; }
.kv > span { color: var(--muted); }
.diary { padding: 6px 14px 10px; }
.diary-meal { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 8px 0 2px; font-weight: 600; }
.diary-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 0.5px solid var(--line); }
.diary-meal + .diary-row { border-top: 0; }
.diary-row .muted { white-space: nowrap; font-variant-numeric: tabular-nums; }
.diary-time { flex: 0 0 5.6em; color: var(--muted); font-size: 0.85em; padding-top: 0.15em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.diary-name { flex: 1; min-width: 0; }

/* ---------- Report ---------- */
.rr-title { font: 600 19px/1.3 var(--font-serif); letter-spacing: 0.01em; margin: 8px 0 12px; }
.rr-card { background: var(--card); border-radius: var(--radius); padding: 4px 14px 10px; margin-bottom: 10px; }
.rr-card h3 { margin: 12px 0 6px; }
.rr-row { display: flex; gap: 6px; align-items: baseline; padding: 5px 0; font-variant-numeric: tabular-nums; }
.rr-row span:first-child { flex: 0 0 90px; color: var(--muted); }
.rr-diary { margin: 0; padding-left: 20px; }
.rr-diary li { padding: 3px 0; }
details summary { cursor: pointer; font-weight: 600; }
.report-text { white-space: pre-wrap; font: 13px/1.45 ui-monospace, Menlo, monospace; margin: 10px 0 0; }
.day-row { display: block; text-decoration: none; color: inherit; background: var(--card); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; }

/* ---------- Settings menus ---------- */
.menu { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.menu-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 16px; border-top: 0.5px solid var(--line); color: var(--text); text-decoration: none; font-size: 17px;
}
.menu-row:first-child { border-top: 0; }
.menu-row > .muted { white-space: nowrap; font-size: 14px; }
.menu + .center { margin-top: 14px; }

/* ---------- Stats ---------- */
.stat-card { display: block; text-decoration: none; color: inherit; }
.stat-card-head { display: flex; justify-content: space-between; font-size: 15px; font-weight: 600; color: var(--accent); }
.stat-card-head .chev { color: var(--muted); }
.chev { font-size: 18px; line-height: 1; }
.stat-card-hero { font: 700 30px/1.2 var(--font-display); margin-top: 6px; }
.stat-card-hero .muted { font-size: 14px; font-weight: 500; letter-spacing: 0; }
.stat-card-chart { margin-top: 10px; }
.chart-card { padding: 12px 12px 14px; }
.chart-title { font-weight: 600; font-size: 14px; margin-bottom: 8px; }

/* Chart primitives (charts.js) */
.viz { position: relative; }
.viz svg { display: block; overflow: visible; }
.viz-grid { stroke: var(--grid); stroke-width: 1; }
.viz-axis { stroke: var(--axis); stroke-width: 1; }
.viz-tick { fill: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.viz-target { stroke: var(--text); stroke-width: 1; opacity: 0.55; }
.viz-target-label { fill: var(--muted); font-size: 10.5px; }
.viz-band { fill: var(--band); }
.viz-cross { stroke: var(--muted); stroke-width: 1; }
.viz-bar, .viz circle { transition: opacity 0.12s; }
.viz .dim { opacity: 0.4; }
.viz rect[tabindex]:focus, .viz circle[tabindex]:focus { outline: none; }
.viz-tip {
  position: absolute; top: -8px; transform: translateY(-100%); z-index: 5; pointer-events: none;
  background: var(--card-2); border: 0; border-radius: 10px; padding: 7px 10px;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.12); font-size: 13px; white-space: nowrap;
}
.viz-tip-title { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.viz-tip-row { display: flex; align-items: center; gap: 6px; }
.viz-tip-label { color: var(--muted); }
.viz-key-line { width: 10px; height: 2px; border-radius: 1px; }
.donut-wrap { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.donut-wrap > .viz-legend { flex: 1 1 170px; min-width: 0; }
.donut-wrap > svg { flex: none; }
.donut-value { fill: var(--text); font-size: 20px; font-weight: 700; }
.viz-legend { list-style: none; margin: 0; padding: 0; flex: 1; font-size: 14px; }
.viz-legend li { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.viz-legend-name { flex: 1; }
.viz-legend-val { font-variant-numeric: tabular-nums; white-space: nowrap; }
.viz-legend-name { min-width: 0; }
.viz-legend-pct { color: var(--muted); min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.viz-legend.inline { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.viz-legend.inline li { padding: 0; }
.viz-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.rank-row { padding: 6px 0; }
.rank-head { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.rank-head span { overflow-wrap: anywhere; }
.rank-head strong { white-space: nowrap; font-variant-numeric: tabular-nums; }
.rank-track { height: 6px; border-radius: 3px; background: var(--grid); margin-top: 4px; }
.rank-bar { height: 100%; border-radius: 3px; }
.rank-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.viz-table { margin: 4px 0 16px; font-size: 13px; }
.viz-table summary { color: var(--accent); font-weight: 600; padding: 6px 0; }
.viz-table table { width: 100%; border-collapse: collapse; margin-top: 6px; font-variant-numeric: tabular-nums; }
.viz-table th, .viz-table td { text-align: right; padding: 5px 4px; border-bottom: 1px solid var(--line); }
.viz-table th:first-child, .viz-table td:first-child { text-align: left; }
.viz-table th { color: var(--muted); font-weight: 600; }

button.menu-row { width: 100%; background: none; border: 0; border-top: 0.5px solid var(--line); font: inherit; font-size: 17px; text-align: left; }
button.menu-row:first-child { border-top: 0; }
.menu-row .check { color: var(--accent); font-weight: 700; }

/* Pinned Rachel Report button at the top of the chat */
.chat-top {
  position: sticky; top: 0; z-index: 8; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; pointer-events: none;
  margin: calc(-1 * env(safe-area-inset-top) - 12px) -16px 6px; padding: calc(env(safe-area-inset-top) + 8px) 16px 14px;
  background: linear-gradient(var(--bg) 85%, transparent);
}
.report-pill {
  pointer-events: auto; display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 999px; text-decoration: none; font-weight: 600; font-size: 15px;
  color: var(--accent); background: var(--tabbar);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: inset 0 0 0 0.5px color-mix(in srgb, var(--text) 16%, transparent), 0 4px 16px rgb(0 0 0 / 0.3);
  transition: transform 0.18s cubic-bezier(.3,.7,.4,1.4);
}
.report-pill:active { transform: scale(0.94); }

/* Messages from Rachel: iMessage-style bubbles */
.imsg { display: flex; flex-direction: column; max-width: 80%; }
.imsg.in { align-self: flex-start; }
.imsg.out { align-self: flex-end; align-items: flex-end; }
.imsg-meta { font: 500 12px var(--font-sans); color: var(--muted); margin: 0 12px 3px; }
.imsg.in .imsg-meta { margin-left: 54px; }
.imsg-row { display: flex; align-items: flex-end; gap: 12px; }
.imsg-avatar {
  flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(180deg, #a5a5ab, #85858b); color: #fff; font: 600 14px var(--font-sans);
}
.imsg-bubble {
  position: relative; padding: 8px 13px; border-radius: 19px; font: 17px/1.3 var(--font-sans);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.imsg.in .imsg-bubble { background: var(--imsg-in); color: var(--text); }
.imsg.out .imsg-bubble { background: var(--imsg-out); color: #fff; }
/* the little tail */
.imsg-bubble::before, .imsg-bubble::after { content: ''; position: absolute; bottom: 0; height: 20px; }
.imsg.in .imsg-bubble::before { left: -7px; width: 20px; background: var(--imsg-in); border-bottom-right-radius: 16px 14px; }
.imsg.in .imsg-bubble::after { left: -10px; width: 10px; background: var(--bg); border-bottom-right-radius: 10px; }
.imsg.out .imsg-bubble::before { right: -7px; width: 20px; background: var(--imsg-out); border-bottom-left-radius: 16px 14px; }
.imsg.out .imsg-bubble::after { right: -10px; width: 10px; background: var(--bg); border-bottom-left-radius: 10px; }
.imsg-link { display: block; margin-top: 4px; font-size: 15px; font-weight: 600; text-decoration: none; color: var(--accent); }

.login-icon { display: block; width: 84px; height: 84px; border-radius: 20px; margin: 0 auto 8px; }
.login h1 { text-align: center; }
.login .segmented button { font-size: 14px; }

.rank-head { align-items: baseline; }
.rank-head span { flex: 1; }
.rank-action { border: 0; background: var(--card-2); color: var(--accent); font: inherit; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 3px 10px; }
.link-btn { background: none; border: 0; color: var(--accent); font: inherit; font-weight: 600; padding: 0; }

/* Accounts */
.err { color: var(--danger); }
.login { max-width: 400px; margin: 10vh auto 0; }
.login p { margin-top: 10px; }
.login .legacy { margin-top: 24px; }
.login .legacy summary { font-weight: 600; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form .btn { margin: 0; width: auto; padding: 11px 16px; white-space: nowrap; }
.prewrap { white-space: pre-wrap; margin: 0; }

/* Nutritionist: client roster */
.client-card { display: block; width: 100%; text-align: left; border: 0; color: inherit; font: inherit; cursor: pointer; }
.client-card:active { transform: scale(0.99); }
.client-top { display: flex; align-items: center; gap: 12px; }
.client-name { flex: 1; display: flex; flex-direction: column; }
.client-name strong { font-size: 18px; }
.client-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0 10px; }
.client-stats > div { display: flex; flex-direction: column; min-width: 0; }
.client-stats strong { font-size: 19px; font-variant-numeric: tabular-nums; }
.client-card .bar { height: 5px; border-radius: 3px; background: var(--card-2); overflow: hidden; }
.client-card .bar span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.client-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px 5px 5px; margin-bottom: 4px;
  border-radius: 999px; background: var(--card); color: var(--text); text-decoration: none; font-weight: 600; font-size: 15px;
}
.imsg-avatar.small { width: 26px; height: 26px; font-size: 12px; }
select { appearance: none; -webkit-appearance: none; }

/* "Add to Home Screen" tip (iPhone browser only) */
.a2hs {
  position: fixed; z-index: 30; left: 12px; right: 12px; top: calc(env(safe-area-inset-top) + 10px);
  max-width: 520px; margin: 0 auto; display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 14px 14px 14px; border-radius: 20px; background: var(--card-2);
  box-shadow: 0 10px 40px rgb(0 0 0 / 0.45); font-size: 14px; line-height: 1.35;
}
.a2hs[hidden] { display: none; }
.a2hs-icon { width: 52px; height: 52px; border-radius: 12px; flex: none; }
.a2hs-text { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.a2hs-text strong { font-size: 15px; }
.a2hs-steps { margin: 6px 0 0; padding-left: 18px; }
.a2hs-steps li { margin: 3px 0; }
.a2hs-glyph { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; background: var(--card); color: var(--accent); vertical-align: middle; }
.a2hs-close { flex: none; border: 0; background: var(--card); color: var(--muted); width: 28px; height: 28px; border-radius: 50%; font-size: 13px; }

/* Small phones: client stats as 2×2, report rows keep numbers together */
@media (max-width: 380px) {
  .client-stats { grid-template-columns: 1fr 1fr; row-gap: 12px; }
}
.rr-row strong, .rr-row .muted { white-space: nowrap; }
.rr-row { flex-wrap: wrap; }

/* Apple Health setup steps */
.hs-steps { list-style: none; margin: 0; padding: 0; }
.hs-step { display: flex; gap: 12px; padding: 10px 0; border-bottom: 0.5px solid var(--line); line-height: 1.4; }
.hs-step:last-child { border-bottom: 0; }
.hs-num { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; font-size: 14px; display: grid; place-items: center; }

/* Today at a glance, above the chat */
.glance {
  pointer-events: auto; flex: 1 0 100%; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px;
  padding: 10px 14px; border-radius: 16px; text-decoration: none; color: var(--text);
  background: var(--tabbar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: inset 0 0 0 0.5px color-mix(in srgb, var(--text) 16%, transparent);
}
.glance-cell { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.glance-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.glance-val { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.glance-val strong { font-size: 16px; }
.glance-bar { height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--text) 12%, transparent); overflow: hidden; }
.glance-bar i { display: block; height: 100%; border-radius: 2px; background: var(--accent); }
.glance-cell.over .glance-bar i { background: var(--series-2); }
.streak {
  pointer-events: auto; padding: 8px 12px; border-radius: 999px; font-size: 14px; font-weight: 600; color: var(--text);
  background: var(--tabbar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: inset 0 0 0 0.5px color-mix(in srgb, var(--text) 16%, transparent);
}

/* Undo on the newest change */
.undo-btn { margin-top: 6px; padding: 5px 12px; border-radius: 999px; border: 0; background: var(--card-2, var(--card)); color: var(--accent); font: 600 14px var(--font-sans); }
.undo-btn:disabled { opacity: 0.5; }
.msg.is-undone > :not(.undone) { opacity: 0.45; text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--text) 40%, transparent); }
.undone { display: block; margin-top: 4px; }

/* Replying to your nutritionist */
.imsg-reply { align-self: flex-start; margin: 4px 0 0 54px; padding: 0; border: 0; background: none; color: var(--accent); font: 600 14px var(--font-sans); }
.reply-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px;
  padding: 8px 12px; border-radius: 12px; background: var(--accent-soft); color: var(--text); font-size: 14px;
}
.reply-bar button { border: 0; background: none; color: var(--muted); font-size: 16px; padding: 2px 6px; }
.proposal .imsg-bubble { white-space: normal; }
.proposal .imsg-bubble p { margin: 0 0 8px; }
.proposal .kv-list { margin: 0 0 10px; }
.imsg.proposal { max-width: 92%; }
.proposal .kv { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 15px; }
.proposal .kv span { white-space: nowrap; }
.proposal .kv strong { text-align: right; }
.proposal .btn { margin: 0; padding: 9px 12px; font-size: 15px; white-space: nowrap; }

/* Unread counts */
.tab-pill a, .tab-round { position: relative; }
.badge {
  position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font: 700 11px/18px var(--font-sans); text-align: center;
}
.count-badge { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--danger); color: #fff; font: 700 13px/22px var(--font-sans); text-align: center; }
.client-card.inactive { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--series-2) 55%, transparent); }
.warn-text { color: var(--series-2); }

/* First-run welcome */
.welcome-dots { display: flex; justify-content: center; gap: 6px; margin: 8px 0 18px; }
.welcome-dots i { width: 7px; height: 7px; border-radius: 50%; background: color-mix(in srgb, var(--text) 22%, transparent); }
.welcome-dots i.on { background: var(--accent); }
.welcome-icon { display: block; width: 76px; height: 76px; border-radius: 18px; margin: 0 auto 10px; }
body[data-screen="welcome"] h1 { text-align: center; }
body[data-screen="welcome"] h1 + .muted { text-align: center; }
.center-block { display: block; margin: 14px auto 0; }

/* Stats → D: ‹ Today › */
.day-nav { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 12px; }
.day-nav strong { font-size: 17px; }
.day-nav-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--card); color: var(--accent); font-size: 24px; line-height: 1; }
.day-nav-btn:disabled { color: var(--muted); opacity: 0.4; }

.hs-more summary { cursor: pointer; padding: 2px 0; }
.hs-more[open] summary { margin-bottom: 6px; }

/* Small iPhones: keep the whole "1,310 / 1,700" visible */
@media (max-width: 380px) {
  .glance { gap: 8px; padding: 9px 12px; }
  .glance-val { font-size: 11.5px; }
  .glance-val strong { font-size: 14px; }
}

/* Chat top: today at a glance + round Report button, one row */
.chat-top { flex-wrap: nowrap; align-items: stretch; }
.chat-top .glance { flex: 1 1 auto; position: relative; }
.glance-spacer { flex: 1; }
.report-round {
  pointer-events: auto; flex: none; width: 62px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border-radius: 16px; text-decoration: none; color: var(--accent); font-size: 11px; font-weight: 700;
  background: var(--tabbar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: inset 0 0 0 0.5px color-mix(in srgb, var(--text) 16%, transparent);
  transition: transform 0.18s cubic-bezier(.3,.7,.4,1.4);
}
.report-round:active { transform: scale(0.94); }
.glance .streak {
  position: absolute; top: -8px; right: 10px; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: var(--card-2, var(--card)); color: var(--text); box-shadow: 0 0 0 1px var(--line); backdrop-filter: none; -webkit-backdrop-filter: none;
}
@media (max-width: 380px) { .report-round { width: 54px; } }

/* Usual foods for this time of day */
.chips.suggest .chip { display: inline-flex; align-items: baseline; gap: 6px; }
.chip-kcal { color: var(--muted); font-weight: 500; font-size: 12px; }
.chips.suggest { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: -4px; padding-left: 4px; }
.chips.suggest::-webkit-scrollbar { display: none; }
.chips.suggest .chip { flex: none; }

/* Coaching tip under a logged message */
.msg-tip {
  margin: 8px 0 0; padding: 8px 12px; border-radius: 12px; background: var(--accent-soft);
  font: 15px/1.4 var(--font-sans); color: var(--text);
}

/* Waiting for signal */
.outbox-note { align-self: flex-end; margin: -2px 4px 6px; font-size: 12px; color: var(--muted); }

/* History calendar: green at/under calorie goal, orange over */
.cal-cell.under .cal-kcal { color: var(--series-3); font-weight: 600; }
.cal-cell.over .cal-kcal { color: var(--series-2); font-weight: 600; }
.cal-legend { display: flex; gap: 14px; justify-content: center; margin-top: 8px; font-size: 12px; color: var(--muted); }
.cal-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }

/* Show password */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 44px; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border: 0; background: none; color: var(--muted); display: grid; place-items: center; }

.chat-top .glance { gap: 10px; padding: 10px 12px; }
.chat-top .glance-val { font-size: 12px; overflow: visible; text-overflow: clip; }
.chat-top .glance-val strong { font-size: 16px; margin-right: 1px; }
@media (max-width: 380px) {
  .chat-top .glance { gap: 7px; padding: 9px 10px; }
  .chat-top .glance-val { font-size: 11px; }
  .chat-top .glance-val strong { font-size: 14px; }
}
@media (max-width: 380px) {
  .chat-top .glance-val { display: flex; flex-direction: column; line-height: 1.15; }
  .chat-top .glance-val .muted { font-size: 11px; }
}

/* Import */
.file-pick { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; cursor: pointer; }
.file-pick .btn { width: auto; margin: 0; padding: 10px 16px; }
.imp-item p { margin: 4px 0; }
.imp-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; margin-bottom: 4px; }
.imp-status { display: inline-block; font-size: 13px; font-weight: 700; margin: 2px 0 6px; }
.imp-status.working { color: var(--accent); }
.imp-status.done { color: var(--series-3); }
.imp-status.failed { color: var(--series-2); }
.imp-item .glance-bar { display: block; margin-bottom: 6px; }
.cal-import { display: block; text-align: center; margin-top: 10px; text-decoration: none; color: var(--accent); font-weight: 600; }

/* + menu in the chat: photo or import */
.attach-wrap { position: relative; }
.attach { border: 0; }
.attach-menu {
  position: absolute; bottom: 44px; left: 0; z-index: 20; min-width: 250px; padding: 6px; border-radius: 14px;
  background: var(--card); box-shadow: 0 0 0 0.5px var(--line), 0 12px 32px rgb(0 0 0 / 0.35);
}
.attach-menu[hidden] { display: none; }
.attach-item { display: block; padding: 11px 12px; border-radius: 10px; color: var(--text); text-decoration: none; font-size: 16px; cursor: pointer; }
.attach-item:active { background: var(--card-2, var(--line)); }
.imp-help summary { cursor: pointer; }
.imp-help .hs-steps { margin-top: 8px; }

/* Calorie balance */
.bal.def { color: var(--series-3); }
.bal.sur { color: var(--series-2); }

/* Top bar cells: calories/protein link to today; water is a one-tap button */
.glance { color: var(--text); }
a.glance-cell { text-decoration: none; color: inherit; }
button.glance-cell { border: 0; background: none; padding: 0; margin: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.water-plus {
  display: inline-grid; place-items: center; width: 15px; height: 15px; margin-left: 4px; vertical-align: 1px;
  border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; font-weight: 800; line-height: 1;
}
.water-tap:active { transform: scale(0.95); }
.water-tap.pop .glance-bar i { animation: water-pop 0.5s ease; }
@keyframes water-pop { 0% { filter: brightness(1.8); } 100% { filter: none; } }
@media (prefers-reduced-motion: reduce) { .water-tap.pop .glance-bar i { animation: none; } }
.toast { display: flex; align-items: center; gap: 14px; }
.toast[hidden] { display: none; }
.toast-action { border: 0; background: none; color: var(--accent); font: inherit; font-weight: 700; padding: 0; }

/* Meal photos */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.photo-tile { position: relative; aspect-ratio: 1; padding: 0; border: 0; border-radius: 12px; overflow: hidden; background: var(--card-2, var(--line)); cursor: zoom-in; }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-time { position: absolute; left: 6px; bottom: 6px; padding: 1px 6px; border-radius: 999px; background: rgb(0 0 0 / 0.55); color: #fff; font-size: 11px; font-weight: 600; }
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgb(0 0 0 / 0.97); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: calc(env(safe-area-inset-top) + 48px) 16px calc(env(safe-area-inset-bottom) + 16px); overflow-y: auto; }
.lightbox img { max-width: 100%; max-height: 62vh; border-radius: 12px; }
.lightbox-info { width: 100%; max-width: 520px; margin-top: 12px; color: #fff; }
.lightbox-info p { margin: 6px 0; }
.lightbox-info ul { margin: 6px 0 0; padding-left: 18px; }
.lightbox-info .muted { color: rgb(255 255 255 / 0.65); }
.lightbox-close { position: absolute; top: calc(env(safe-area-inset-top) + 10px); right: 12px; width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgb(255 255 255 / 0.15); color: #fff; font-size: 18px; }

/* 🛑 STOP */
.stop-btn {
  display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; margin-right: auto; padding: 4px 12px 4px 4px;
  border: 0; border-radius: 999px; background: rgb(224 36 42 / 0.14); color: #ff453a; font: 700 13px var(--font-sans); cursor: pointer;
}
.stop-btn .stop-sign { width: 28px; height: 28px; flex: none; }
.stop-btn:active { transform: scale(0.95); }
@media (max-width: 380px) { .stop-btn span { display: none; } .stop-btn { padding: 4px; } }
.stop-sign { display: block; }
.stop-screen {
  position: fixed; inset: 0; z-index: 120; overflow-y: auto; background: #120304; color: #fff;
  padding: calc(env(safe-area-inset-top) + 20px) 20px calc(env(safe-area-inset-bottom) + 24px);
}
.stop-screen h1 { text-align: center; margin: 10px 0 6px; font-size: 34px; }
.stop-big { display: grid; place-items: center; }
.stop-big .stop-sign { width: 132px; height: 132px; animation: stop-in 0.35s cubic-bezier(.3,.7,.4,1.4); }
@keyframes stop-in { from { transform: scale(0.6); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .stop-big .stop-sign { animation: none; } }
.stop-lead { text-align: center; color: rgb(255 255 255 / 0.8); margin: 0 auto 14px; max-width: 420px; }
.stop-steps { max-width: 460px; margin: 0 auto 16px; padding-left: 0; list-style: none; counter-reset: s; }
.stop-steps li { counter-increment: s; position: relative; padding: 12px 12px 12px 44px; margin-bottom: 8px; border-radius: 14px; background: rgb(255 255 255 / 0.07); line-height: 1.35; }
.stop-steps li::before { content: counter(s); position: absolute; left: 12px; top: 12px; width: 22px; height: 22px; border-radius: 50%; background: #e0242a; display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.stop-steps label { display: flex; gap: 10px; align-items: flex-start; }
.stop-steps input[type=checkbox] { margin-top: 3px; width: 18px; height: 18px; accent-color: #34c759; flex: none; }
.stop-feelings { margin: 8px 0 0; }
.stop-feelings .chip { background: rgb(255 255 255 / 0.12); color: #fff; }
.stop-feelings .chip.on { background: #fff; color: #120304; }
.stop-screen .btn { max-width: 460px; margin-left: auto; margin-right: auto; display: block; width: 100%; }
.stop-screen .btn.secondary { background: rgb(255 255 255 / 0.12); color: #fff; }
.stop-done { background: #34c759; color: #04210c; }
.stop-actions { display: grid; gap: 10px; margin-top: 16px; }
.stop-close { position: absolute; top: calc(env(safe-area-inset-top) + 12px); right: 14px; width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgb(255 255 255 / 0.14); color: #fff; font-size: 18px; }
body.no-scroll { overflow: hidden; }
.urge-card { margin-top: 10px; padding: 12px; border-radius: 14px; background: rgb(224 36 42 / 0.12); box-shadow: inset 0 0 0 1px rgb(224 36 42 / 0.45); font: 15px/1.4 var(--font-sans); }
.urge-head { display: flex; align-items: center; gap: 8px; font-weight: 800; color: #ff453a; }
.urge-head .stop-sign { width: 26px; height: 26px; }
.urge-card p { margin: 6px 0 10px; }
.urge-card .btn { margin: 0; padding: 9px 12px; font-size: 15px; }
.btn.stop-now { background: #e0242a; color: #fff; }
.urge-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 0.5px solid var(--line); }
.urge-row:first-of-type { border-top: 0; }
.urge-icon .stop-sign { width: 22px; height: 22px; margin-top: 2px; }

/* ---------- Groceries ---------- */
.groc-intro { margin: 0 0 10px; }
.groc-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 0.5px solid var(--line); }
.diary-meal + .groc-item { border-top: 0; }
.groc-check input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--accent); }
.groc-body { flex: 1; min-width: 0; }
.groc-name { font-weight: 600; }
.groc-item.done .groc-name { text-decoration: line-through; color: var(--muted); }
.groc-swap { color: var(--accent); margin-top: 2px; }
.groc-rate { display: flex; gap: 2px; flex: none; }
.groc-thumb { background: none; border: 0; font-size: 18px; padding: 4px; border-radius: 10px; opacity: 0.45; filter: grayscale(1); }
.groc-thumb.on { opacity: 1; filter: none; background: var(--accent-soft); }
.groc-count { margin: 10px 0 0; }
.groc-working { display: flex; gap: 12px; align-items: center; }
.spinner { width: 22px; height: 22px; flex: none; border-radius: 50%; border: 3px solid var(--card-2); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.groc-trip summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.groc-note { border-radius: 12px; padding: 10px 12px; margin: 10px 0; background: var(--card-2); }
.groc-note p { margin: 4px 0 0; }
.groc-note.good strong { color: #30d158; }
.groc-note.warn strong { color: #ff9f0a; }
.groc-meal { padding: 10px 0; border-top: 0.5px solid var(--line); }
.diary-meal + .groc-meal { border-top: 0; }
.groc-meal p { margin: 4px 0 0; }
.groc-bought { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; }
.verdict { flex: none; width: 4.2em; text-align: center; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 2px 0; margin-top: 1px; }
.verdict.great { background: rgba(48, 209, 88, 0.18); color: #30d158; }
.verdict.ok { background: var(--card-2); color: var(--muted); }
.verdict.limit { background: rgba(255, 159, 10, 0.18); color: #ff9f0a; }
.groc-pref { display: inline-flex; align-items: center; gap: 4px; color: var(--text); font-weight: 500; }
.groc-pref button { background: none; border: 0; color: var(--muted); font-size: 16px; padding: 0 0 0 2px; line-height: 1; }
.groc-pref.like { background: rgba(48, 209, 88, 0.14); }
.groc-pref.dislike { background: var(--card-2); color: var(--muted); }
.groc-pref.trigger { background: rgba(255, 159, 10, 0.14); }
.groc-trip .link-btn { margin-top: 10px; }
/* Four tabs on a small phone (iPhone SE): tighter labels so "Groceries" fits. */
@media (max-width: 380px) {
  .tab-pill a { flex: 1 1 auto; padding: 0 2px; font-size: 10px; letter-spacing: 0; }
  .tab-round { width: 56px; height: 56px; }
  .tab-pill a { height: 48px; }
}

/* ---------- Nutritionist: week overview ---------- */
.ov-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; padding: 14px 12px 10px; }
.ov-day { display: flex; flex-direction: column; align-items: center; gap: 4px; text-decoration: none; color: inherit; }
.ov-kcal { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 11px; }
.ov-bar-wrap { position: relative; width: 100%; max-width: 30px; height: 90px; display: flex; align-items: flex-end; }
.ov-bar { width: 100%; border-radius: 6px 6px 3px 3px; background: var(--accent); }
.ov-bar.under { background: #30d158; }
.ov-bar.over { background: #ff9f0a; }
.ov-goal { position: absolute; left: -3px; right: -3px; border-top: 1.5px dashed var(--muted); opacity: 0.7; }
.ov-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.ov-tile { background: var(--card); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ov-tile strong { font-size: 22px; font-variant-numeric: tabular-nums; }
.ov-tile strong .muted { font-size: 15px; font-weight: 600; }
.ov-flags { padding: 4px 16px; }
.ov-flag { display: flex; gap: 10px; align-items: baseline; padding: 11px 0; border-top: 0.5px solid var(--line); color: inherit; text-decoration: none; }
.ov-flag:first-child { border-top: 0; }
.ov-flag > span:nth-child(2) { flex: 1; }
.ov-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: #ff9f0a; transform: translateY(-1px); }
.ov-flag.good .ov-dot { background: #30d158; }
a.urge-row { color: inherit; text-decoration: none; }
a.diary-row { color: inherit; text-decoration: none; }
.menu-card { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.menu-card > div:first-child { flex: 1; }
.stop-note { display: block; color: #ff6961; }
.groc-from { color: #bf5af2; font-weight: 600; margin-top: 2px; }
.groc-state { width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--line); display: grid; place-items: center; color: #30d158; font-weight: 700; margin-top: 2px; }

/* Four gauges across the top: stack "value" over "/goal" so each fits. */
.chat-top .glance-val { display: flex; flex-direction: column; line-height: 1.15; }
.chat-top .glance-val .muted { font-size: 11px; }
.glance-cell.behind .glance-bar i { background: #ff9f0a; }
.glance-cell.behind .glance-label { color: #ff9f0a; }
.glance-label { white-space: nowrap; overflow: hidden; text-overflow: clip; }
.water-tap { position: relative; }
.water-tap .water-plus { position: absolute; top: 0; right: 0; margin: 0; }
.lbl-short { display: none; }
/* Five gauges on a phone: short labels, slightly smaller numbers. */
@media (max-width: 440px) {
  .lbl-long { display: none; }
  .lbl-short { display: inline; }
  .chat-top .glance { gap: 7px; padding: 10px 10px; }
  .chat-top .glance-label { font-size: 11px; letter-spacing: -0.01em; }
  .chat-top .glance-val strong { font-size: 15px; }
  .chat-top .glance-val .muted { font-size: 10.5px; }
  .water-tap .water-plus { width: 16px; height: 16px; font-size: 12px; top: 20px; right: 0; }
}
@media (max-width: 380px) {
  .chat-top .glance-label { font-size: 11px; letter-spacing: -0.01em; }
  .water-tap .water-plus { width: 16px; height: 16px; font-size: 12px; top: 20px; right: 0; }
}
@media (max-width: 380px) {
  .chat-top { gap: 6px; }
  .chat-top .glance { gap: 5px; padding: 9px 8px; }
  .chat-top .glance-label { font-size: 10px; letter-spacing: -0.02em; }
  .chat-top .glance-val strong { font-size: 13px; letter-spacing: -0.02em; }
  .chat-top .glance-val .muted { font-size: 10px; }
  .report-round { width: 48px; font-size: 10px; }
  .water-tap .water-plus { width: 14px; height: 14px; font-size: 11px; top: 18px; }
}
