/* Health app — calm, neat, mobile-first design */
:root {
  --bg: #f6f8fb;
  --card: #ffffff;
  --ink: #1d2632;
  --muted: #6b7686;
  --faint: #9aa4b2;
  --line: #e8ecef;
  --primary: #c2410c;
  --primary-dark: #9a3412;
  --primary-soft: #fbede3;
  --accent: #3f8fae;
  --accent-soft: #e8f3f8;
  --warn: #b7791f;
  --warn-soft: #faf3e3;
  --danger: #c0492f;
  --danger-soft: #fae9e4;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(20, 40, 70, 0.06), 0 4px 16px rgba(20, 40, 70, 0.05);
  --tabbar-h: 64px;
  --topbar-h: 56px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* ---------- shell ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  height: var(--topbar-h);
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 720px; margin: 0 auto; height: 100%;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
}
.brand { font-weight: 700; font-size: 20px; color: var(--primary); text-decoration: none; letter-spacing: -0.3px; }
.topbar-actions { display: flex; gap: 4px; }
.icon-btn {
  border: 0; background: none; color: var(--muted); font-size: 14px; font-weight: 600;
  padding: 8px 10px; border-radius: 10px; cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--primary-soft); color: var(--primary-dark); }

#view {
  max-width: 720px; margin: 0 auto;
  padding: calc(var(--topbar-h) + 16px) 16px calc(var(--tabbar-h) + 24px);
  min-height: 100vh;
}
#view.no-chrome { padding: 24px 16px 40px; }

#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  display: flex; align-items: stretch; justify-content: space-around;
  max-width: 720px; margin: 0 auto;
}
#tabbar a, #tabbar button {
  flex: 1; border: 0; background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: var(--muted); text-decoration: none;
  font-family: inherit;
}
#tabbar a.active, #tabbar button.active { color: var(--primary); }
#tabbar .tab-primary {
  color: var(--primary-dark); position: relative;
}
#tabbar .tab-primary::after {
  content: "+"; position: absolute; top: 2px; right: calc(50% - 26px);
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 12px; line-height: 16px; text-align: center;
}

/* ---------- floating coach (Intercom-style) ---------- */
#coach-fab {
  position: fixed; z-index: 60;
  right: 16px;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  width: 58px; height: 58px; border: 0; border-radius: 50%;
  background: #c2410c; color: #fff; font-size: 26px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(194, 65, 12, 0.45);
  cursor: pointer;
}
#coach-fab:active { transform: scale(0.94); }
#coach-panel {
  position: fixed; z-index: 61;
  right: 16px;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 86px);
  width: min(380px, calc(100vw - 32px));
  height: min(520px, calc(100dvh - var(--tabbar-h) - 190px));
  min-height: 320px;
  background: var(--card); border-radius: 18px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.22);
  border: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden;
}
.coach-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 12px 12px 10px 16px;
  border-bottom: 1px solid var(--line);
}
.coach-panel-title { display: flex; flex-direction: column; gap: 2px; }
.coach-panel-title b { font-size: 15px; }
#coach-panel-body {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column;
  padding: 12px 12px 10px;
}
#coach-panel-body .chat-list { flex: 1; max-height: none; margin-bottom: 8px; }
#coach-panel-body .upgrade-prompt { margin: 4px 0; }

/* ---------- typography & cards ---------- */
h1 { font-size: 26px; margin: 4px 0 4px; letter-spacing: -0.4px; }
h2 { font-size: 19px; margin: 0 0 8px; letter-spacing: -0.2px; }
h3 { font-size: 16px; margin: 0 0 6px; }
.sub { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin: 0 0 14px;
}
.card.tight { padding: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }

.big-number { font-size: 34px; font-weight: 700; letter-spacing: -0.8px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 12px; }
.stat { background: var(--bg); border-radius: 12px; padding: 10px 8px; text-align: center; }
.stat .v { font-weight: 700; font-size: 16px; }
.stat .l { font-size: 12px; color: var(--muted); }
.stat .v .tgoal { font-size: 11px; font-weight: 600; color: var(--muted); }
.limit-notes { margin-top: 10px; display: grid; gap: 6px; }
.limit-note { background: var(--primary-soft); border-radius: 12px; padding: 8px 12px; font-size: 13px; line-height: 1.35; }

.pill {
  display: inline-block; font-size: 12px; font-weight: 600; padding: 4px 10px;
  border-radius: 999px; background: var(--primary-soft); color: var(--primary-dark);
}
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.info { background: var(--accent-soft); color: var(--accent); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }

.banner {
  border-radius: var(--radius); padding: 14px 16px; margin: 0 0 14px; font-size: 14px;
  background: var(--primary-soft); color: var(--primary-dark); border: 1px solid #d3e6da;
}
.banner.warn { background: var(--warn-soft); color: #7a5410; border-color: #ecdcb8; }
.banner.info { background: var(--accent-soft); color: #2c6478; border-color: #cfe5ef; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 12px; padding: 13px 20px;
  font-size: 15px; font-weight: 700; font-family: inherit; cursor: pointer;
  background: var(--primary); color: #fff; text-decoration: none;
  transition: background 0.15s ease;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.block { display: flex; width: 100%; }
.btn.secondary { background: var(--bg); color: var(--ink); border: 1px solid var(--line); }
.btn.secondary:hover { background: #eef1f3; }
.btn.ghost { background: none; color: var(--primary); padding: 10px 12px; }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 8px 14px; font-size: 13px; border-radius: 10px; }
.link { color: var(--primary); font-weight: 600; text-decoration: none; }
.link:hover { text-decoration: underline; }

.field { margin: 0 0 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: 16px; font-family: inherit; background: #fff; color: var(--ink);
}
.input:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
textarea.input { resize: vertical; min-height: 90px; }

/* show/hide password toggle, sits inside the right edge of the field */
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 68px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: none; color: var(--primary); font-weight: 600;
  font-size: 14px; font-family: inherit; cursor: pointer;
  padding: 10px 8px; border-radius: 8px;
}
.pw-toggle:hover { color: var(--primary-dark); }
.pw-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.hint { font-size: 12px; color: var(--faint); margin-top: 4px; }
.error-text { font-size: 13px; color: var(--danger); margin-top: 6px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; color: var(--ink);
}
.chip.sel { background: var(--primary); border-color: var(--primary); color: #fff; }

/* segmented unit toggle */
.seg { display: inline-flex; background: var(--bg); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button {
  border: 0; background: none; border-radius: 9px; padding: 8px 18px;
  font-size: 14px; font-weight: 700; cursor: pointer; color: var(--muted); font-family: inherit;
}
.seg button.sel { background: #fff; color: var(--primary-dark); box-shadow: 0 1px 4px rgba(0,0,0,0.1); }

/* toggle switch */
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; position: absolute; z-index: 1; }
.switch .track {
  position: absolute; inset: 0; border-radius: 999px; background: #d4dade; transition: background 0.2s;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: left 0.2s;
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { left: 23px; }

/* ---------- wheel picker ---------- */
.wheel {
  height: 220px; overflow: hidden; position: relative; border-radius: 12px;
  background: var(--bg);
  -webkit-mask-image: linear-gradient(to bottom, transparent, black 28%, black 72%, transparent);
  mask-image: linear-gradient(to bottom, transparent, black 28%, black 72%, transparent);
}
.wheel-track { height: 100%; overflow-y: scroll; scrollbar-width: none; scroll-snap-type: y proximity; }
.wheel-track::-webkit-scrollbar { display: none; }
.wheel-item {
  height: 44px; display: flex; align-items: center; justify-content: center;
  font-size: 17px; color: var(--faint); scroll-snap-align: center; user-select: none;
}
.wheel-item.sel { color: var(--ink); font-weight: 700; font-size: 20px; }
.wheel-row { display: flex; gap: 8px; }
.wheel-row .wheel { flex: 1; }
.wheel-label { text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 6px; }
.wheel-value-line { text-align: center; margin-top: 10px; font-size: 15px; font-weight: 600; }

/* ---------- progress ring ---------- */
.ring-wrap { display: flex; align-items: center; gap: 18px; }
.ring { transform: rotate(-90deg); }
.ring .bg { stroke: var(--line); }
.ring .fg { stroke: var(--primary); stroke-linecap: round; transition: stroke-dashoffset 0.5s ease; }
.ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
}
.ring-box { position: relative; width: 132px; height: 132px; flex: none; }

/* ---------- diary ---------- */
.sticky-search {
  position: sticky; top: var(--topbar-h); z-index: 30;
  padding: 10px 0; background: var(--bg);
}
.meal-head {
  width: 100%; border: 0; background: none; cursor: pointer; text-align: left;
  display: flex; align-items: center; gap: 10px; padding: 14px 2px; font-family: inherit;
}
.meal-head .name { font-weight: 700; font-size: 16px; flex: 1; }
.meal-head .cal { font-size: 14px; color: var(--muted); font-weight: 600; }
.meal-budget { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.mini-ring { display: inline-flex; line-height: 0; }
.meal-head .chev { color: var(--faint); font-size: 18px; transition: transform 0.2s; }
.meal-sec.open .meal-head .chev { transform: rotate(90deg); }
.meal-body { display: none; }
.meal-sec.open .meal-body { display: block; }

.entry { position: relative; overflow: hidden; border-radius: 12px; margin-bottom: 8px; background: #fff; box-shadow: var(--shadow); }
.entry-inner {
  display: flex; align-items: center; gap: 8px; padding: 12px 14px;
  background: #fff; position: relative; z-index: 1;
  transition: transform 0.18s ease; touch-action: pan-y;
}
.entry.open .entry-inner { transform: translateX(-84px); }
.entry .food-name { font-weight: 600; font-size: 15px; }
.entry-inner > div:first-child { flex: 1; min-width: 0; }
.entry .food-name, .entry .food-meta {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.entry .food-meta { font-size: 12px; color: var(--muted); }
.entry .cal { margin-left: auto; font-weight: 700; font-size: 15px; white-space: nowrap; }
.entry-actions { display: flex; gap: 4px; flex-shrink: 0; }
.mini-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 9px;
  font-size: 12px; font-weight: 700; padding: 10px 12px; cursor: pointer; color: var(--primary-dark); font-family: inherit;
}
.mini-btn.danger { color: var(--danger); }
.entry-swipe {
  position: absolute; top: 0; right: 0; bottom: 0; width: 84px; z-index: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--danger); color: #fff; font-weight: 700; font-size: 14px; border: 0; cursor: pointer;
}

.food-row {
  display: flex; align-items: center; gap: 12px; padding: 13px 4px;
  border-bottom: 1px solid var(--line); cursor: pointer; width: 100%;
  border-left: 0; border-right: 0; border-top: 0; background: none; text-align: left; font-family: inherit;
}
.food-row:last-child { border-bottom: 0; }
.food-row .n { font-weight: 600; font-size: 15px; }
.food-row .d { font-size: 12px; color: var(--muted); }
.food-row .c { margin-left: auto; font-size: 13px; font-weight: 700; color: var(--primary-dark); white-space: nowrap; }
.food-pick { flex: 1; min-width: 0; background: none; border: 0; padding: 0; text-align: left; font: inherit; cursor: pointer; color: inherit; }
.food-pick .n { font-weight: 600; font-size: 15px; display: block; }
.food-pick .d { font-size: 12px; color: var(--muted); display: block; }
.food-own { display: flex; gap: 0; align-items: center; }
.food-own .icon-btn { padding: 8px 7px; font-size: 15px; }
.food-own .icon-btn.danger { color: var(--danger); }
.food-own .icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

.day-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.day-nav .date { font-weight: 700; font-size: 17px; }

/* ---------- timers ---------- */
.timer-display {
  font-size: 56px; font-weight: 700; letter-spacing: -1.5px; text-align: center;
  font-variant-numeric: tabular-nums; margin: 8px 0 4px;
}
.timer-sub { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.timer-controls { display: flex; gap: 10px; justify-content: center; margin-top: 8px; }
.hiit-phase { text-align: center; font-size: 15px; font-weight: 700; color: var(--primary-dark); }

/* ---------- reminders ---------- */
.reminder-row {
  display: flex; align-items: center; gap: 12px; padding: 14px 2px;
  border-bottom: 1px solid var(--line);
}
.reminder-row:last-child { border-bottom: 0; }
.reminder-row .lbl { flex: 1; font-weight: 600; font-size: 15px; }
.reminder-row input[type="time"] {
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
  font-size: 15px; font-family: inherit; background: #fff;
}
.reminder-row input[type="time"]:disabled { opacity: 0.4; }

/* ---------- coach / upgrade ---------- */
.tip-card { border-left: 4px solid var(--primary); }
.upgrade-prompt { text-align: center; padding: 26px 18px; }
.upgrade-prompt .lock { font-size: 13px; font-weight: 700; color: var(--warn); text-transform: uppercase; letter-spacing: 1px; }
.feature-list { list-style: none; padding: 0; margin: 0 0 16px; }
.feature-list li { padding: 10px 0 10px 28px; position: relative; border-bottom: 1px solid var(--line); font-size: 15px; }
.feature-list li:last-child { border-bottom: 0; }
.feature-list li::before {
  content: ""; position: absolute; left: 2px; top: 15px; width: 14px; height: 8px;
  border-left: 3px solid var(--primary); border-bottom: 3px solid var(--primary);
  transform: rotate(-45deg);
}
.dev-note {
  margin-top: 14px; padding: 12px 14px; border-radius: 12px; font-size: 13px;
  background: var(--warn-soft); color: #7a5410; border: 1px dashed #d9bd7f;
}

/* ---------- onboarding ---------- */
.progress { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 8px 0 20px; }
.progress > div { height: 100%; background: var(--primary); border-radius: 999px; transition: width 0.3s ease; }
.step-count { font-size: 13px; color: var(--muted); font-weight: 600; }
.ob-card { max-width: 480px; margin: 0 auto; }
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.result-cell { background: var(--bg); border-radius: 12px; padding: 12px; }
.result-cell .v { font-size: 19px; font-weight: 700; }
.result-cell .l { font-size: 12px; color: var(--muted); }

/* ---------- modal / sheet / toast ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 60; background: rgba(20, 30, 25, 0.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: #fff; border-radius: 20px 20px 0 0; width: 100%; max-width: 720px;
  max-height: 88vh; overflow-y: auto; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  animation: slideup 0.22s ease;
}
@keyframes slideup { from { transform: translateY(30px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.sheet h2 { margin-bottom: 4px; }

#toast-root { position: fixed; bottom: calc(var(--tabbar-h) + 16px); left: 0; right: 0; z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: #22303f; color: #fff; font-size: 14px; font-weight: 600;
  padding: 12px 20px; border-radius: 999px; box-shadow: 0 4px 18px rgba(0,0,0,0.25);
  animation: toastin 0.25s ease; max-width: 90vw;
}
@keyframes toastin { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- misc ---------- */
.loading { text-align: center; padding: 48px 16px; color: var(--muted); }
.spinner {
  width: 34px; height: 34px; border-radius: 50%; margin: 0 auto 12px;
  border: 3px solid var(--line); border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 36px 18px; color: var(--muted); }
.empty .t { font-weight: 700; color: var(--ink); font-size: 16px; margin-bottom: 6px; }
.skel { background: linear-gradient(90deg, #eef1f3, #e2e7ea, #eef1f3); border-radius: 12px; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: 0.6; } }

.weight-chart { width: 100%; height: auto; display: block; }
.hist-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 2px; border-bottom: 1px solid var(--line); font-size: 14px; }
.hist-row:last-child { border-bottom: 0; }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; }
.tab {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; white-space: nowrap;
  padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; color: var(--muted);
}
.tab.sel { background: var(--ink); border-color: var(--ink); color: #fff; }

.calc-result {
  margin-top: 14px; background: var(--primary-soft); border-radius: 12px; padding: 16px;
  text-align: center;
}
.calc-result .v { font-size: 28px; font-weight: 700; color: var(--primary-dark); }
.calc-result .l { font-size: 13px; color: var(--muted); }

.auth-wrap { max-width: 420px; margin: 8vh auto 0; }
.auth-wrap .logo { font-size: 34px; font-weight: 800; color: var(--primary); letter-spacing: -0.8px; margin-bottom: 4px; }

.back-link { display: inline-block; margin-bottom: 12px; font-size: 14px; }

/* voice food logging: pulsing mic while listening */
.mic-pulse {
  font-size: 34px; display: inline-block; margin-bottom: 8px;
  animation: micpulse 1.2s ease-in-out infinite;
}
@keyframes micpulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.18); opacity: 0.75; }
}

.list-card { padding: 6px 14px; }
.sheet-list button {
  display: block; width: 100%; text-align: left; border: 0; background: none; cursor: pointer;
  padding: 15px 4px; font-size: 16px; font-weight: 600; border-bottom: 1px solid var(--line); font-family: inherit; color: var(--ink);
}
.sheet-list button:last-child { border-bottom: 0; }
.sheet-list button.danger { color: var(--danger); }

@media (min-width: 560px) {
  .overlay { align-items: center; padding: 24px; }
  .sheet { border-radius: 20px; }
}

/* ── Aara conversational chat ── */
.chat-list {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 340px; overflow-y: auto; padding: 4px 2px; margin-bottom: 10px;
}
.chat-msg {
  max-width: 88%; padding: 9px 13px; border-radius: 15px;
  font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
}
.chat-aara {
  align-self: flex-start; background: var(--primary-soft); color: var(--ink);
  border-bottom-left-radius: 5px;
}
.chat-user {
  align-self: flex-end; background: var(--primary); color: #fff;
  border-bottom-right-radius: 5px;
}
.chat-thinking { opacity: 0.55; }
.chat-sugg { max-width: 100%; width: 100%; }
/* Chef talk-to-log confirmation card */
.chef-card { max-width: 100%; width: 100%; display: flex; flex-direction: column; gap: 8px; }
.chef-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chef-card-title { font-weight: 700; }
.chef-meal { width: auto; padding: 6px 8px; font-size: 14px; }
.chef-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.chef-item.dim { opacity: 0.45; }
.chef-item-main { flex: 1; min-width: 0; }
.chef-item-name { font-weight: 600; }
.chef-qty { display: flex; align-items: center; gap: 6px; }
.chef-qv { min-width: 28px; text-align: center; font-weight: 600; }
.chef-toggle { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: 15px; cursor: pointer; flex-shrink: 0; }
.chef-toggle.sel { background: var(--primary); border-color: var(--primary); color: #fff; }
.chef-card-foot { display: flex; justify-content: flex-end; }
.chat-chips { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 10px; padding-bottom: 2px; }
.chat-chips .chip { white-space: nowrap; flex-shrink: 0; font-weight: 500; }
.chat-input-row { display: flex; gap: 6px; align-items: center; }
.chat-input-row .input { flex: 1; min-width: 0; }
.chat-input-row .icon-btn { font-size: 20px; padding: 8px; flex-shrink: 0; }
#chat-mic.listening {
  background: var(--accent-soft, #fdf3e3); border-radius: 50%;
  animation: micpulse 1.2s ease-in-out infinite;
}

/* Plan picker on the upgrade screen */
.plan-toggle { display: flex; gap: 10px; margin: 12px 0 14px; }
.plan-opt {
  flex: 1; padding: 12px 8px; border-radius: 12px; cursor: pointer;
  background: var(--bg); color: var(--ink); border: 1px solid var(--line);
  font-size: 14px; line-height: 1.5;
}
.plan-opt b { font-size: 16px; }
.plan-opt.selected { border-color: var(--primary); background: var(--primary-soft); font-weight: 600; }

/* ---------- Premium icons: clean line-icon system ---------- */
.ico { width: 20px; height: 20px; flex: none; vertical-align: -4px; }
/* nutrient icon chip: tinted rounded square with a line icon */
.nic { width: 36px; height: 36px; border-radius: 12px; display: inline-flex; align-items: center;
  justify-content: center; flex: none; }
.nic .ico { width: 20px; height: 20px; }
.nic-calories { background: #ffedd5; color: #ea580c; }
.nic-protein  { background: #fbe9dd; color: #9a3412; }
.nic-carbs    { background: #fef3c7; color: #b45309; }
.nic-fat      { background: #f3e8ff; color: #9333ea; }
.nic-fibre    { background: #dcfce7; color: #16a34a; }
.nic-water    { background: #fbe9dd; color: #9a3412; }
.nic-steps    { background: #ede9fe; color: #7c3aed; }
.nic-micro    { background: #f1f5f9; color: #475569; }
.nic-vitc      { background: #ffedd5; color: #ea580c; }
.nic-iron      { background: #fee2e2; color: #b91c1c; }
.nic-calcium   { background: #e0f2fe; color: #0284c7; }
.nic-potassium { background: #fef9c3; color: #a16207; }
.nic-vita      { background: #fce7f3; color: #db2777; }
.nic-vitd      { background: #fff7ed; color: #c2410c; }
.nic-magnesium { background: #ccfbf1; color: #0d9488; }
.nic-zinc      { background: #e0e7ff; color: #4f46e5; }
.nic-b12       { background: #f3e8ff; color: #9333ea; }
.nic-folate    { background: #dcfce7; color: #15803d; }
/* card headings that lead with an icon */
.card h2 .nic, .sound-row .ico, .chef-card-title .ico { vertical-align: -7px; margin-right: 2px; }
/* macro cells: icon + label/value + progress bar */
.macro-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; margin-top: 14px; }
.macro-cell { display: flex; align-items: flex-start; gap: 10px; }
.macro-info { flex: 1; min-width: 0; }
.macro-top { display: flex; align-items: baseline; justify-content: space-between; font-size: 14px;
  color: #475569; margin-bottom: 6px; gap: 6px; }
.macro-top b { color: #0f172a; font-size: 13.5px; white-space: nowrap; }
.macro-bar { height: 6px; border-radius: 99px; background: #e2e8f0; overflow: hidden; }
.macro-bar > div { height: 100%; border-radius: 99px; background: linear-gradient(90deg,#fb923c,#c2410c); transition: width .5s ease; }
/* tappable calorie ring -> opens the full-page nutrition breakdown */
.ring-btn { background: none; border: 0; padding: 0; cursor: pointer; display: inline-block;
  -webkit-tap-highlight-color: transparent; text-decoration: none; }
.ring-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 4px; border-radius: 12px; }
/* generic expandable panel (water / steps cards) */
.x-head { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: 0;
  padding: 0; margin: 0 0 4px; cursor: pointer; text-align: left; -webkit-tap-highlight-color: transparent; }
.x-head h2 { margin: 0; display: flex; align-items: center; gap: 8px; }
.x-head .x-chev { margin-left: auto; color: var(--faint); display: inline-flex;
  transition: transform .3s ease; }
.x-head[aria-expanded="true"] .x-chev { transform: rotate(180deg); }
.xpanel { display: grid; grid-template-rows: 0fr; opacity: 0;
  transition: grid-template-rows .38s ease, opacity .3s ease, margin-top .3s ease; margin-top: 0; }
.xpanel.open { grid-template-rows: 1fr; opacity: 1; margin-top: 12px; }
.xclip { overflow: hidden; min-height: 0; }
.x-title { margin: 0 0 8px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: #a8a29e; }
/* 7-day mini bar chart */
.wbars { display: flex; gap: 6px; }
.wbar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.wv { font-size: 10px; color: #a8a29e; white-space: nowrap; }
.wtrack { height: 64px; width: 100%; max-width: 34px; border-radius: 8px; background: #f5efe4;
  display: flex; align-items: flex-end; overflow: hidden; }
.wfill { width: 100%; border-radius: 8px; background: linear-gradient(180deg,#fb923c,#c2410c); }
.wfill.hit { background: linear-gradient(180deg,#4ade80,#16a34a); }
.wd { font-size: 11px; color: #a8a29e; font-weight: 600; }
.np-card { background: var(--card); border: 1px solid #f3ece1; border-radius: 16px; padding: 16px; }
.nb-title { margin: 0; font-size: 17px; }
/* Tab bar: "All Meals" + one tab per meal, sticky under the topbar. */
.nb-tabs { display: flex; gap: 2px; overflow-x: auto; margin: 0 -16px 4px; padding: 0 16px;
  position: sticky; top: var(--topbar-h); background: var(--card); z-index: 6;
  scrollbar-width: none; }
.nb-tabs::-webkit-scrollbar { display: none; }
.nb-tab { flex: none; border: 0; background: none; padding: 12px 14px; font-size: 14px; font-weight: 600;
  color: #a8a29e; cursor: pointer; border-bottom: 2.5px solid transparent; -webkit-tap-highlight-color: transparent; }
.nb-tab.sel { color: #c2410c; border-bottom-color: #c2410c; }
.nb-sec { margin-top: 16px; }
.nb-sec h4 { margin: 0 0 6px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: #a8a29e; }
.nb-calrow { display: flex; gap: 14px; align-items: center; }
.nb-bigpct { font-size: 42px; font-weight: 800; line-height: 1; }
.nb-bigpct.good { color: #16a34a; }
.nb-bigpct.low { color: #b45309; }
.nb-bigpct.over { color: #dc2626; }
.nb-calnum { font-size: 15px; }
.nb-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid #faf6ef; }
.nb-row:last-child { border-bottom: 0; }
.nb-info { flex: 1; min-width: 0; }
.nb-top { display: flex; align-items: baseline; justify-content: space-between; font-size: 14px;
  color: #57534e; margin-bottom: 6px; gap: 8px; }
.nb-top b { color: #1c1917; white-space: nowrap; font-size: 13.5px; }
.nb-bar { height: 6px; border-radius: 99px; background: #f1ebe0; overflow: hidden; }
.nb-bar > div { height: 100%; border-radius: 99px; background: linear-gradient(90deg,#fb923c,#c2410c); transition: width .5s ease; }
.nb-bar > div.over { background: #dc2626; }
.nb-pct { font-size: 14px; min-width: 46px; text-align: right; }
.nb-pct.good { color: #16a34a; }
.nb-pct.low { color: #b45309; }
.nb-pct.over { color: #dc2626; }
.nb-micro .nb-top { margin-bottom: 0; }
.nb-micro { padding: 7px 0; }
.nb-meal { border-top: 1px solid #f5f0e8; padding: 10px 0 2px; }
.nb-mealhead { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 2px; }
.nb-mealhead > b { font-size: 15px; }
.nb-microgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; margin: 8px 0 6px; }
.nb-mrow { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #57534e;
  padding: 6px 0; border-bottom: 1px solid #faf6ef; }
.nb-mrow b { margin-left: auto; color: #1c1917; font-weight: 600; white-space: nowrap; }
/* coach gap rows: same visual language as the Today macro cells */
.gap-row { margin-bottom: 14px; }
.macro-head { display: flex; align-items: center; gap: 10px; font-size: 14px; color: #475569; margin-bottom: 6px; }
.macro-head b { color: #0f172a; }
/* streak + trophy */
.streak-ico { display: inline-flex; color: #ea580c; }
.streak-ico .ico { width: 22px; height: 22px; }
.perfect-chip .ico, .perfect-banner .trophy .ico { vertical-align: -4px; }
.perfect-banner .trophy { display: inline-flex; color: #b45309; }
.perfect-banner .trophy .ico { width: 44px; height: 44px; }
/* icon buttons + toggles that now hold SVGs */
.chef-toggle { display: inline-flex; align-items: center; justify-content: center; }
.chef-toggle .ico { width: 16px; height: 16px; vertical-align: 0; }
.ob-done .ico { width: 26px; height: 26px; vertical-align: 0; }
.mic-pulse .ico { width: 40px; height: 40px; color: var(--primary); }
.food-row .icon-btn .ico { width: 18px; height: 18px; vertical-align: 0; }
.tab .ico { width: 17px; height: 17px; vertical-align: -3px; margin-right: 2px; }
.chip .ico { width: 16px; height: 16px; vertical-align: -3px; margin-right: 2px; }
.btn .ico { width: 17px; height: 17px; vertical-align: -3px; margin-right: 4px; }
.card h2 .ico { vertical-align: -4px; margin-right: 4px; }


/* ---------- Perfect Day reward ---------- */
.perfect-banner { border-radius: 16px; padding: 16px; margin-bottom: 14px; text-align: center;
  background: linear-gradient(135deg, #fffbeb, #fef3c7); border: 2px solid #f59e0b;
  box-shadow: 0 4px 20px rgba(245,158,11,.25); animation: perfect-glow 2.2s ease-in-out infinite; }
.perfect-banner .trophy { display: inline-flex; color: #b45309; margin-bottom: 4px; }
.perfect-banner h2 { margin: 6px 0 4px; font-size: 20px; }
.perfect-banner p { margin: 0; font-size: 13.5px; color: var(--muted); }
@keyframes perfect-glow { 0%,100% { box-shadow: 0 4px 20px rgba(245,158,11,.25); } 50% { box-shadow: 0 4px 32px rgba(245,158,11,.55); } }
.perfect-chip { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px;
  background: #fffbeb; border: 1px solid #f59e0b; border-radius: 999px;
  padding: 6px 12px; font-size: 13px; font-weight: 600; color: #92400e; }
.confetti-piece { position: fixed; top: -16px; z-index: 9999; pointer-events: none; border-radius: 2px;
  animation-name: confetti-fall; animation-timing-function: linear; animation-fill-mode: forwards; }
@keyframes confetti-fall { to { transform: translateY(108vh) rotate(720deg); opacity: .85; } }

@media (prefers-reduced-motion: reduce) {
  .perfect-banner, .mic-pulse { animation: none !important; }
}

.coach-hero { display: flex; align-items: center; gap: 14px; }
.coach-mascot { width: 88px; height: 88px; object-fit: contain; flex: none; }

/* timer sound toggle row */
.sound-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.sound-row > span:first-child { font-weight: 600; }

/* onboarding result screens */
.ob-done { width: 52px; height: 52px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 700; margin: 8px auto 4px; }
.rec-cal { text-align: center; }
.rec-step { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.step-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg); font-size: 22px; line-height: 1; color: var(--primary-dark); cursor: pointer; }
.step-btn:active { transform: scale(0.94); }
.rec-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin: 12px 0 16px; }
.rec-cell { text-align: center; padding: 12px 6px; }
.rec-cell .v { font-size: 20px; font-weight: 800; }
.rec-cell .l { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- Diary redesign: Cal AI-style log ---------- */
.diary-head { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 2px 0 14px; }
.dh-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); background: var(--card); color: var(--text); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; text-decoration: none; }
.dh-btn.sm { width: 34px; height: 34px; }
.dh-btn .ico { width: 20px; height: 20px; }
.dh-sp { visibility: hidden; }
.dh-date { background: none; border: none; font-size: 20px; font-weight: 800; color: var(--text); display: inline-flex; align-items: center; gap: 4px; cursor: pointer; padding: 6px 10px; }
.dh-date .ico { width: 18px; height: 18px; color: var(--muted); }

.diary-cal { margin-bottom: 14px; padding: 14px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); padding: 4px 0; }
.cal-day { aspect-ratio: 1; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 14px; text-decoration: none; color: var(--text); position: relative; border: 1.5px solid transparent; }
.cal-day.today .cal-n { font-weight: 800; color: var(--primary-dark); }
.cal-day.sel { border-color: var(--primary); background: var(--primary-soft); font-weight: 800; }
.cal-day.fut { color: var(--muted); opacity: 0.45; }
.cal-day:active { background: var(--primary-soft); }
.cal-n { line-height: 1; }
.cal-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--primary); margin-top: 3px; }
.cal-pad { visibility: hidden; }

.diary-sum { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.ds-ring { flex: none; }
.ds-num { font-size: 21px; font-weight: 800; }
.ds-num .muted { font-size: 15px; font-weight: 600; }
.ds-trend { margin-left: auto; width: 44px; height: 44px; border-radius: 14px; border: 1px solid var(--border); background: var(--primary-soft); color: var(--primary-dark); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.ds-trend .ico { width: 22px; height: 22px; }

.diary-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.d-tile { background: #2b1d16; color: #fff; border: none; border-radius: 16px; padding: 12px; display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 14px; cursor: pointer; text-decoration: none; }
.d-tile-ic { width: 38px; height: 38px; border-radius: 12px; background: rgba(255,255,255,0.14); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.d-tile-ic .ico { width: 20px; height: 20px; }

.meal-sec { margin-bottom: 20px; }
.meal-sec-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.meal-name { font-weight: 800; font-size: 16px; }
.meal-budget { margin-left: auto; color: var(--muted); font-size: 13.5px; font-weight: 600; }
.meal-add { width: 30px; height: 30px; border-radius: 50%; background: #f97316; color: #fff; display: inline-flex; align-items: center; justify-content: center; flex: none; text-decoration: none; box-shadow: 0 2px 8px rgba(249,115,22,0.4); }
.meal-add .ico { width: 16px; height: 16px; }
.meal-add:active { transform: scale(0.92); }
.meal-empty { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 24px 16px; text-align: center; color: var(--muted); font-size: 14px; }

/* calorie trends */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { border: none; background: none; padding: 6px 12px; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button.sel { background: var(--primary); color: #fff; }
.trend-chart { margin-top: 14px; }
.trend-bars { display: flex; align-items: flex-end; gap: 5px; height: 132px; position: relative; }
.trend-col { flex: 1; display: flex; justify-content: center; align-items: flex-end; height: 100%; min-width: 0; border-radius: 8px; }
.trend-col.hl { background: var(--primary-soft); }
.trend-bar { width: 100%; max-width: 24px; border-radius: 6px 6px 3px 3px; background: #93c5fd; min-height: 3px; }
.trend-bar.over { background: #fb923c; }
.trend-days { display: flex; gap: 5px; margin-top: 5px; }
.trend-days span { flex: 1; text-align: center; font-size: 10px; color: var(--muted); font-weight: 700; }
.trend-goal { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--primary); opacity: 0.75; pointer-events: none; }
.trend-goal span { position: absolute; right: 0; top: -18px; font-size: 10px; font-weight: 800; color: var(--primary-dark); background: var(--card); padding: 0 3px; }
.trend-stats { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.trend-legend { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.lg-bar { width: 14px; height: 8px; border-radius: 3px; background: #93c5fd; display: inline-block; }
.lg-bar.over { background: #fb923c; }
