/* ---------- Colours ---------- */
:root {
  --plum: #6b3f69;
  --plum-hover: #5a3458;
  --on-plum: #ffffff;
  --rose: #d98a9b; /* bars, charts, dots. Never small text. */
  --rose-soft: #f3dde3;
  --bg: #faf6f8;
  --card: #ffffff;
  --card-tint: #f5edf2;
  --text: #2f2a2e;
  --text-soft: #5b525a;
  --border: #e4d8df;
  --focus: #6b3f69;
  --good: #2f6b4f;
  --note-bg: #f3ebf2;
  --shadow: 0 1px 2px rgba(60, 30, 60, 0.06), 0 2px 8px rgba(60, 30, 60, 0.05);
  --chart-1: #7b3a78;
  --chart-2: #d9758d;
  --hero: linear-gradient(135deg, #6b3f69 0%, #8a4a7c 55%, #c9798f 100%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --plum: #8e5a8b;
    --plum-hover: #a06c9d;
    --on-plum: #ffffff;
    --rose: #e29aaa;
    --rose-soft: #4a2e44;
    --bg: #1a1019;
    --card: #261a25;
    --card-tint: #2f2130;
    --text: #f4edf2;
    --text-soft: #cdbfca;
    --border: #44334a;
    --focus: #e29aaa;
    --good: #8fd1ae;
    --note-bg: #321f31;
    --shadow: none;
    --chart-1: #94519a;
    --chart-2: #d66c86;
    --hero: linear-gradient(135deg, #3d2240 0%, #56305a 55%, #8a4a68 100%);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --plum: #8e5a8b;
  --plum-hover: #a06c9d;
  --on-plum: #ffffff;
  --rose: #e29aaa;
  --rose-soft: #4a2e44;
  --bg: #1a1019;
  --card: #261a25;
  --card-tint: #2f2130;
  --text: #f4edf2;
  --text-soft: #cdbfca;
  --border: #44334a;
  --focus: #e29aaa;
  --good: #8fd1ae;
  --note-bg: #321f31;
  --shadow: none;
  --chart-1: #94519a;
  --chart-2: #d66c86;
  --hero: linear-gradient(135deg, #3d2240 0%, #56305a 55%, #8a4a68 100%);
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { font-size: 18px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', system-ui, sans-serif;
  line-height: 1.5;
}
h1, h2, h3 {
  font-family: 'Plus Jakarta Sans', 'DM Sans', system-ui, sans-serif;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin: 0;
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0; }
a { color: var(--plum); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  background: var(--card-tint);
  padding: 0.1em 0.35em;
  border-radius: 6px;
  font-size: 0.9em;
  overflow-wrap: anywhere;
}

/* ---------- Layout ---------- */
.shell { min-height: 100vh; display: flex; }
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 24px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 30; /* so the feedback box opened from here covers the page */
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--plum);
  padding: 0 10px 20px;
}
:root[data-theme='dark'] .brand { color: var(--text); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .brand { color: var(--text); } }
.brand img { width: 32px; height: 32px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 0 14px;
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}
.nav-link:hover { background: var(--card-tint); }
.nav-link.active { background: var(--plum); color: var(--on-plum); }
.nav-link svg { width: 24px; height: 24px; flex-shrink: 0; }
.nav-spacer { flex: 1; }

.main { flex: 1; min-width: 0; }
.topbar { display: none; }
.content { max-width: 960px; margin: 0 auto; padding: 32px 28px 64px; }
.page-head { margin-bottom: 24px; }
.page-head p { color: var(--text-soft); margin-top: 6px; }

.bottom-nav { display: none; }

@media (max-width: 820px) {
  .sidebar { display: none; }
  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 30; /* above the bottom menu, so the feedback box opened from here covers it */
  }
  .topbar .brand { padding: 0; font-size: 1.15rem; }
  .icon-btn {
    width: 48px; height: 48px;
    display: grid; place-items: center;
    border-radius: 12px;
    color: var(--text);
  }
  .icon-btn.active { background: var(--plum); color: var(--on-plum); }
  .icon-btn svg { width: 26px; height: 26px; }
  .content { padding: 20px 16px 120px; }
  h1 { font-size: 1.5rem; }
  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: var(--card);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    z-index: 10;
  }
  .bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 58px;
    border-radius: 12px;
    color: var(--text-soft);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
  }
  .bottom-nav a svg { width: 26px; height: 26px; }
  .bottom-nav a.active { color: var(--on-plum); background: var(--plum); }
}

/* ---------- Cards ---------- */
.stack { display: flex; flex-direction: column; gap: 20px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.card.tint { background: var(--card-tint); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.card-sub { color: var(--text-soft); margin-bottom: 18px; }
@media (max-width: 820px) { .card { padding: 18px 16px; } }

.note {
  background: var(--note-bg);
  border-left: 4px solid var(--rose);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
}
.soft { color: var(--text-soft); }
.small { font-size: 0.9rem; }

/* ---------- Forms ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 620px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-weight: 500; }
.field .hint { color: var(--text-soft); font-size: 0.9rem; }
input[type='text'], input[type='number'], input[type='time'], input[type='date'], input[type='password'], input[type='email'], select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 12px;
  min-height: 52px;
  padding: 10px 14px;
  width: 100%;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--plum); outline: none; }
.with-unit { display: flex; align-items: center; gap: 8px; }
.with-unit input { flex: 1; min-width: 0; }
.with-unit span { color: var(--text-soft); white-space: nowrap; }

.btn {
  font: inherit;
  font-weight: 600;
  min-height: 52px;
  padding: 0 24px;
  border-radius: 14px;
  border: 2px solid var(--plum);
  background: var(--plum);
  color: var(--on-plum);
  cursor: pointer;
}
.btn:hover { background: var(--plum-hover); border-color: var(--plum-hover); }
.btn.secondary { background: transparent; color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--card-tint); }
.btn:disabled { opacity: 0.55; cursor: default; }
.actions { display: flex; align-items: center; gap: 14px; margin-top: 20px; flex-wrap: wrap; }
.saved { color: var(--good); font-weight: 600; }
.error { color: #b3261e; font-weight: 600; }
:root[data-theme='dark'] .error { color: #ffb4ab; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .error { color: #ffb4ab; } }

/* Day and option chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: inherit;
  font-weight: 500;
  min-height: 48px;
  min-width: 56px;
  padding: 0 14px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}
.chip[aria-pressed='true'] { background: var(--plum); border-color: var(--plum); color: var(--on-plum); }

/* On/off switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; min-height: 48px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
  width: 56px; height: 32px;
  border-radius: 999px;
  background: var(--border);
  position: relative;
  transition: background 0.15s;
  flex-shrink: 0;
}
.switch .track::after {
  content: '';
  position: absolute;
  top: 4px; left: 4px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
}
.switch input:checked + .track { background: var(--plum); }
.switch input:checked + .track::after { transform: translateX(24px); }
.switch input:focus-visible + .track { outline: 3px solid var(--focus); outline-offset: 2px; }

.reminder {
  border-top: 1px solid var(--border);
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.reminder:first-of-type { border-top: 0; padding-top: 4px; }
.reminder-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.reminder-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.reminder-row input[type='time'] { width: 160px; }

/* Placeholder screens */
.coming {
  text-align: center;
  padding: 48px 24px;
}
.coming .dot {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--rose-soft);
  display: grid; place-items: center;
  margin: 0 auto 16px;
  color: var(--plum);
}
:root[data-theme='dark'] .coming .dot { color: var(--rose); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .coming .dot { color: var(--rose); } }
.coming .dot svg { width: 30px; height: 30px; }

.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--card-tint);
}
.status-pill::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--rose); }
.status-pill.on::before { background: var(--good); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- Dashboard ---------- */
.welcome {
  background: var(--plum);
  color: var(--on-plum);
  border-radius: 22px;
  padding: 28px 28px 30px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}
.welcome::after {
  content: '';
  position: absolute;
  right: -60px; top: -60px;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: var(--rose);
  opacity: 0.35;
}
.welcome > * { position: relative; z-index: 1; }
.welcome h1 { color: var(--on-plum); margin: 4px 0 6px; }
.welcome p { color: var(--on-plum); opacity: 0.92; }
.welcome-date { font-weight: 500; }
:root[data-theme='dark'] .welcome { background: #4a2b48; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .welcome { background: #4a2b48; } }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 900px) { .stats { grid-template-columns: repeat(2, 1fr); gap: 12px; } }
.stat { padding: 18px; }
.stat-label { color: var(--text-soft); font-weight: 500; font-size: 0.9rem; }
.stat-value { font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 700; font-size: 1.7rem; margin-top: 4px; }
.stat-unit { font-size: 0.95rem; font-weight: 600; color: var(--text-soft); }
.stat-note { color: var(--text-soft); font-size: 0.85rem; margin-top: 4px; }

.bar { height: 14px; border-radius: 999px; background: var(--rose-soft); overflow: hidden; margin-top: 8px; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--rose); transition: width 0.4s; }
.goal { margin-top: 14px; }
.goal-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.big-line { display: flex; align-items: baseline; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.big-num { font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 700; font-size: 2.2rem; line-height: 1; }
.dots { display: flex; gap: 10px; margin-top: 14px; }
.dot { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--rose); }
.dot.on { background: var(--rose); }

.cal-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; margin-top: 4px; }
.cal-num { font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 700; font-size: 1.6rem; }

.link-btn { display: inline-flex; align-items: center; text-decoration: none; margin-top: 18px; }
.dash-grid { align-items: start; }
.dash-grid > * { min-width: 0; }

.reminders { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.reminder-card {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--card); border: 1px solid var(--border);
  border-left: 5px solid var(--rose);
  border-radius: 16px; padding: 14px 16px;
  color: var(--text); text-decoration: none;
  min-height: 64px;
}
.reminder-card:hover { background: var(--card-tint); }
.reminder-icon { color: var(--plum); flex-shrink: 0; margin-top: 2px; }
:root[data-theme='dark'] .reminder-icon { color: var(--rose); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .reminder-icon { color: var(--rose); } }
.reminder-icon svg { width: 24px; height: 24px; }

/* ---------- Nutrition ---------- */
.date-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.date-bar strong { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 1.15rem; text-align: center; }
.date-bar .btn { min-width: 56px; padding: 0 14px; font-size: 1.3rem; }
.toast { margin-bottom: 14px; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.badge { display: inline-block; font-size: 0.8rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; }
.badge.est { background: var(--card-tint); color: var(--text); border: 1px solid var(--border); }
.badge.missing { background: var(--note-bg); color: var(--text); border: 1px dashed var(--rose); }

.saved-meal { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 10px; }
.saved-meal:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }

.meal-protein { color: var(--text-soft); white-space: nowrap; }
.log-list { list-style: none; margin: 8px 0 0; padding: 0; }
.log-group { font-weight: 700; color: var(--text-soft); font-size: 0.9rem; padding: 10px 0 2px; text-transform: uppercase; letter-spacing: 0.04em; }
.log-row {
  display: grid; grid-template-columns: 1fr auto 48px; gap: 12px; align-items: center;
  border-top: 1px solid var(--border); padding: 10px 0;
}
.log-values { display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.icon-del {
  width: 48px; height: 48px; border-radius: 12px; border: 1px solid var(--border);
  background: transparent; color: var(--text-soft); font-size: 1rem; cursor: pointer;
}
.icon-del:hover { background: var(--card-tint); color: var(--text); }

.modal-back {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(20, 8, 20, 0.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 32px 16px; overflow-y: auto;
}
.modal {
  background: var(--card); color: var(--text);
  border-radius: 20px; padding: 24px; width: 100%; max-width: 720px;
  border: 1px solid var(--border);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.close-btn { min-width: 52px; padding: 0; }
@media (max-width: 620px) {
  .modal-back { padding: 0; }
  .modal { border-radius: 0; min-height: 100%; padding: 18px 16px 40px; }
}

.ingredients { margin-top: 14px; }
.ingredient {
  display: grid; grid-template-columns: 1fr 110px 130px; gap: 12px; align-items: center;
  border-top: 1px solid var(--border); padding: 12px 0;
}
.ingredient-amount { display: flex; flex-direction: column; gap: 4px; }
.ingredient-values { display: flex; flex-direction: column; text-align: right; }
@media (max-width: 620px) {
  .ingredient { grid-template-columns: 1fr 1fr; }
  .ingredient-name { grid-column: 1 / -1; }
  .ingredient-values { justify-content: center; }
}
.totals-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 10px; }
@media (max-width: 420px) { .totals-grid { grid-template-columns: repeat(2, 1fr); } }

.food-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.food-pick {
  font: inherit; color: var(--text); text-align: left;
  display: flex; flex-direction: column; gap: 2px;
  background: var(--card); border: 2px solid var(--border); border-radius: 14px;
  padding: 12px 14px; min-height: 56px; cursor: pointer;
}
.food-pick:hover { border-color: var(--plum); }

.week-bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin-top: 18px; }
.week-col { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.week-track { width: 100%; max-width: 40px; height: 110px; background: var(--rose-soft); border-radius: 10px; display: flex; align-items: flex-end; overflow: hidden; }
.week-fill { width: 100%; background: var(--rose); border-radius: 10px 10px 0 0; }

.tips { margin: 10px 0 0; padding-left: 1.2em; }
.tips li { margin-bottom: 8px; }
.cal-num { overflow-wrap: anywhere; }

/* ---------- Label scan ---------- */
.file-btn { display: inline-flex; align-items: center; justify-content: center; position: relative; overflow: hidden; align-self: flex-start; cursor: pointer; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-btn.disabled { opacity: 0.6; cursor: default; }
.file-btn:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.reading { display: flex; gap: 14px; align-items: center; }
.reading img, .scan-check img { width: 120px; max-height: 160px; object-fit: contain; border-radius: 10px; border: 1px solid var(--border); background: #fff; }
.scan-check { display: flex; gap: 14px; align-items: flex-start; }
@media (max-width: 620px) { .scan-check { flex-direction: column; } .scan-check img { width: 100%; max-height: 320px; } }
.spinner {
  display: inline-block; width: 18px; height: 18px; vertical-align: -3px; margin-right: 6px;
  border: 3px solid var(--rose-soft); border-top-color: var(--plum); border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.field.check label::after {
  content: 'check'; margin-left: 8px; font-size: 0.75rem; font-weight: 700;
  padding: 1px 8px; border-radius: 999px; border: 1px dashed var(--rose); color: var(--text);
}
.field.check input { border-color: var(--rose); border-style: dashed; }
.welcome .tagline { font-weight: 500; letter-spacing: 0.01em; }
.sidebar .brand { font-size: 1.1rem; gap: 8px; padding-right: 0; overflow-wrap: anywhere; }
.sidebar .brand img { width: 28px; height: 28px; flex-shrink: 0; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 420px; text-align: center; padding: 32px 24px; }
.login-card h1 { margin-top: 12px; }
.login-card .field { text-align: left; width: 100%; }
.login-card .btn { width: 100%; }

/* ---------- Motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.stack > *, .stats > *, .rise { animation: rise 0.45s ease both; }
.stack > *:nth-child(2), .stats > *:nth-child(2) { animation-delay: 0.05s; }
.stack > *:nth-child(3), .stats > *:nth-child(3) { animation-delay: 0.1s; }
.stack > *:nth-child(4), .stats > *:nth-child(4) { animation-delay: 0.15s; }
.stack > *:nth-child(n+5) { animation-delay: 0.2s; }
.bar-fill { transition: width 0.9s cubic-bezier(0.22, 1, 0.36, 1); }
.card { transition: box-shadow 0.2s, transform 0.2s; }
a.card:hover, .card.lift:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(60, 30, 60, 0.12); }
@media (prefers-reduced-motion: reduce) {
  .stack > *, .stats > *, .rise { animation: none; }
  .bar-fill, .card { transition: none; }
}

/* ---------- Toggle ---------- */
.toggle { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 999px; background: var(--card-tint); border: 1px solid var(--border); }
.toggle button {
  font: inherit; font-weight: 600; font-size: 0.95rem; color: var(--text);
  min-height: 44px; padding: 0 16px; border-radius: 999px; border: 0; background: transparent; cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.toggle button.on { background: var(--plum); color: var(--on-plum); }

/* ---------- Charts ---------- */
.chart { margin: 14px 0 0; }
.chart-box { position: relative; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; }
.chart-table { margin-top: 10px; }
.chart-table summary { cursor: pointer; color: var(--text-soft); font-weight: 500; min-height: 44px; display: flex; align-items: center; }
.chart-table table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.chart-table th, .chart-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.card-head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- Richer cards ---------- */
.welcome { background: var(--hero) !important; }
.welcome::after { opacity: 0.22 !important; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.hero-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 18px;
  border-radius: 14px; font-weight: 600; text-decoration: none; border: 2px solid rgba(255,255,255,0.6);
  color: #fff; background: rgba(255,255,255,0.12);
}
.hero-btn.solid { background: #fff; color: #6b3f69; border-color: #fff; }
.hero-btn svg { width: 20px; height: 20px; }
.hero-btn:hover { background: rgba(255,255,255,0.22); }
.hero-btn.solid:hover { background: #f6eef4; }

.stat-top { display: flex; align-items: center; gap: 10px; }
.stat-icon {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: var(--rose-soft); color: var(--plum); flex-shrink: 0;
}
:root[data-theme='dark'] .stat-icon { color: var(--rose); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .stat-icon { color: var(--rose); } }
.stat-icon svg { width: 20px; height: 20px; }

.segment { margin-top: 14px; }
.segment .goal-row span:last-child { font-variant-numeric: tabular-nums; }
.bar.strong .bar-fill { background: var(--chart-1); }
.segment-note { margin-top: 12px; }

.week-bars-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.week-pill { height: 12px; border-radius: 999px; background: var(--rose-soft); overflow: hidden; }
.week-pill > div { height: 100%; width: 0; background: var(--rose); border-radius: 999px; transition: width 0.8s ease; }
.week-pill.done > div { width: 100%; }
.today-session {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--card-tint); border-radius: 14px; padding: 14px 16px; margin-top: 16px;
}
.btn.small { min-height: 44px; padding: 0 16px; font-size: 0.95rem; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.btn svg { width: 18px; height: 18px; }

/* ---------- Progress ---------- */
.tab-scroll { overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.tab-scroll .toggle { flex-wrap: nowrap; white-space: nowrap; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.compare figure, .photo-grid figure { margin: 0; }
.compare img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 14px; background: var(--card-tint); }
.compare figcaption, .photo-grid figcaption { margin-top: 6px; color: var(--text-soft); font-size: 0.9rem; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-top: 14px; }
.photo-grid img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 12px; background: var(--card-tint); }
.table-wrap { overflow-x: auto; margin-top: 14px; }
.compare-table { width: 100%; border-collapse: collapse; }
.compare-table th, .compare-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
.compare-table thead th { color: var(--text-soft); font-weight: 600; font-size: 0.9rem; }
.compare-table tbody th { font-weight: 500; }
.rich p { margin: 0 0 10px; }
.rich h3 { margin: 14px 0 6px; font-size: 1.05rem; }
.rich ul { margin: 0 0 10px; padding-left: 1.2em; }
.rich li { margin-bottom: 4px; }

/* ---------- Plan ---------- */
.session-card.today { border: 2px solid var(--plum); }
.today-tag { display: inline-block; background: var(--plum); color: var(--on-plum); font-weight: 600; font-size: 0.8rem; border-radius: 999px; padding: 2px 10px; margin-bottom: 6px; }
.session-body { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.ex-item { border-top: 1px solid var(--border); padding: 14px 0; }
.ex-item:first-of-type { border-top: 0; }
.run-ex-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.run-links { display: flex; gap: 8px; flex-wrap: wrap; }
.suggest { display: flex; gap: 6px; align-items: flex-start; margin-top: 8px; padding: 8px 12px; border-radius: 10px; background: var(--note-bg); }
.suggest svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 2px; color: var(--good); }
.last-time { margin-top: 8px; color: var(--text-soft); }
.run-ex { border-top: 1px solid var(--border); padding: 18px 0; }
.runner-top { display: flex; gap: 16px; align-items: flex-end; }
.rest-pick { display: flex; flex-direction: column; gap: 4px; font-weight: 500; font-size: 0.9rem; }
.rest-pick select { min-height: 44px; padding: 4px 10px; width: auto; }
.set-rows { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.set-row { display: grid; grid-template-columns: 60px 1fr 1fr 52px; gap: 10px; align-items: center; padding: 6px 8px; border-radius: 12px; }
.set-row:not(:has(.with-unit + .with-unit)) { grid-template-columns: 60px 1fr 52px; }
.set-row.done { background: var(--card-tint); }
.set-n { font-weight: 600; color: var(--text-soft); }
.set-check {
  width: 52px; height: 52px; border-radius: 14px; border: 2px solid var(--border); background: var(--card);
  color: var(--text-soft); display: grid; place-items: center; cursor: pointer;
}
.set-check svg { width: 24px; height: 24px; }
.set-check.on { background: var(--plum); border-color: var(--plum); color: var(--on-plum); }
.warm summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 6px; }
.rest-dock {
  position: sticky; bottom: 0; margin: 16px -24px -24px; padding: 14px 24px;
  background: var(--card); border-top: 2px solid var(--rose); box-shadow: 0 -6px 16px rgba(0,0,0,0.08);
}
.rest-timer { display: flex; gap: 16px; align-items: center; }
.rest-ring {
  --p: 0; width: 76px; height: 76px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  background: conic-gradient(var(--plum) calc(var(--p) * 1%), var(--rose-soft) 0);
}
.rest-ring span { width: 60px; height: 60px; border-radius: 50%; background: var(--card); display: grid; place-items: center; font-weight: 700; font-size: 1.1rem; }
.pain-field { margin-top: 14px; }
.pain-field input[type='range'] { width: 100%; min-height: 44px; accent-color: var(--plum); }
.activity-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 16px; }
.balance-list { margin: 12px 0 0; padding-left: 1.3em; }
.balance-list li { margin-bottom: 8px; }
.link-like { font: inherit; color: var(--plum); text-decoration: underline; background: none; border: 0; cursor: pointer; padding: 0; }
:root[data-theme='dark'] .link-like { color: var(--rose); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .link-like { color: var(--rose); } }
@media (max-width: 620px) {
  .set-row { grid-template-columns: 1fr 1fr 52px; }
  .set-row .set-n { grid-column: 1 / -1; }
  .set-row:not(:has(.with-unit + .with-unit)) { grid-template-columns: 1fr 52px; }
  .rest-dock { margin: 16px -16px -40px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
}

/* ---------- Coach ---------- */
.chat { display: flex; flex-direction: column; }
.chat-log { display: flex; flex-direction: column; gap: 14px; max-height: 60vh; min-height: 200px; overflow-y: auto; padding: 4px 2px 8px; }
.chat-msg { display: flex; gap: 10px; align-items: flex-start; }
.chat-msg.user { justify-content: flex-end; }
.chat-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--rose-soft); color: var(--plum); display: grid; place-items: center; flex-shrink: 0; }
:root[data-theme='dark'] .chat-avatar { color: var(--rose); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .chat-avatar { color: var(--rose); } }
.chat-avatar svg { width: 20px; height: 20px; }
.bubble { max-width: min(640px, 85%); padding: 12px 16px; border-radius: 18px; background: var(--card-tint); white-space: pre-wrap; }
.bubble .rich { white-space: normal; }
.bubble .rich p:last-child, .bubble .rich ul:last-child { margin-bottom: 0; }
.chat-msg.user .bubble { background: var(--plum); color: var(--on-plum); border-bottom-right-radius: 6px; }
.chat-msg.assistant .bubble { border-bottom-left-radius: 6px; }
.thinking { display: flex; align-items: center; gap: 10px; color: var(--text-soft); }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--rose); animation: bounce 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: 0.5; } 40% { transform: translateY(-5px); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .dots i { animation: none; } }
.starters { margin-top: 14px; }
.starter-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip.starter { text-align: left; border-radius: 14px; padding: 8px 14px; }
.chat-input { display: flex; gap: 10px; align-items: flex-end; margin-top: 16px; }
.chat-input textarea { min-height: 56px; flex: 1; }
.send-btn { width: 56px; padding: 0; display: grid; place-items: center; }
.send-btn svg { width: 22px; height: 22px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.today-session .btn { white-space: nowrap; flex-shrink: 0; }

/* ---------- Appearance choice ---------- */
.theme-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.theme-opt {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  padding: 12px; min-height: 44px; border-radius: 14px; cursor: pointer; text-align: left;
  background: var(--card); color: var(--text); border: 2px solid var(--border); font: inherit;
}
.theme-opt:hover { border-color: var(--text-soft); }
.theme-opt.on { border: 3px solid var(--plum); padding: 11px; }
.theme-opt:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.theme-name { font-weight: 700; font-size: 1.05rem; display: inline-flex; align-items: center; gap: 4px; }
.theme-name svg { width: 18px; height: 18px; color: var(--plum); }
.theme-hint { font-size: 0.9rem; color: var(--text-soft); }
/* Little pictures of each look. Their colours are fixed, so they never flip with the theme. */
.theme-preview {
  position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: 8px;
  overflow: hidden; border: 1px solid #d9ccd5; background: #faf6f8;
}
.theme-preview i { position: absolute; left: 8%; top: 14%; width: 34%; height: 14%; border-radius: 4px; background: #6b3f69; }
.theme-preview b { position: absolute; left: 8%; width: 84%; height: 18%; border-radius: 4px; background: #ffffff; border: 1px solid #e4d8df; }
.theme-preview b:nth-of-type(1) { top: 40%; }
.theme-preview b:nth-of-type(2) { top: 66%; }
.theme-preview.dark { background: #1a1019; border-color: #44334a; }
.theme-preview.dark i { background: #e29aaa; }
.theme-preview.dark b { background: #261a25; border-color: #44334a; }
.theme-preview.auto { background: linear-gradient(90deg, #faf6f8 50%, #1a1019 50%); }
.theme-preview.auto b { background: linear-gradient(90deg, #ffffff 50%, #261a25 50%); }
@media (max-width: 480px) { .theme-options { grid-template-columns: 1fr; } .theme-preview { aspect-ratio: 4 / 1; } }

/* ---------- Coach: saved conversations ---------- */
.coach-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.past-chats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; }
.past-chats li { display: flex; gap: 8px; align-items: stretch; }
.past-open {
  flex: 1; min-width: 0; min-height: 56px; padding: 8px 14px; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
  font: inherit; color: var(--text); background: var(--card); border: 2px solid var(--border); border-radius: 12px;
}
.past-open:hover { border-color: var(--text-soft); }
.past-chats li.on .past-open { border-color: var(--plum); border-width: 3px; padding: 7px 13px; }
.past-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.past-when { font-size: 0.9rem; color: var(--text-soft); }
.past-ask { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px; background: var(--card-tint); }
.past-ask span { flex: 1 1 100%; font-weight: 600; }
.btn.danger { background: #a33a3a; border-color: #a33a3a; color: #fff; }
.btn.danger:hover { background: #8a2f2f; }
[hidden] { display: none !important; }

/* ---------- Lists with a delete button on each item ---------- */
.item-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.item-list li { display: flex; gap: 8px; align-items: center; padding: 8px 8px 8px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
.item-list .item-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.item-list .item-edit { flex: 1; }
.item-add { display: flex; gap: 8px; }
.item-add input { flex: 1; min-width: 0; }

/* ---------- Invite code ---------- */
.invite-box { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 8px 0; }
.invite-code { font-family: ui-monospace, Menlo, monospace; font-size: 1.6rem; font-weight: 700; letter-spacing: 0.12em; padding: 8px 16px; border-radius: 12px; background: var(--card-tint); border: 2px dashed var(--border); user-select: all; }
.del-ask { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 12px; background: var(--card-tint); }
.del-ask > span { font-weight: 600; }
.food-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.food-row .food-pick { flex: 1; min-width: 0; }
button.nav-link { width: 100%; font: inherit; background: none; border: 0; cursor: pointer; text-align: left; }
button.icon-btn { background: none; border: 0; cursor: pointer; }
.food-row .del-ask, .item-list li .del-ask { flex-basis: 100%; order: 2; }
.add-scan { text-decoration: none; color: inherit; display: block; }

/* ---------- Resources ---------- */
.section-title { font-size: 1.25rem; margin: 10px 0 0; }
.guide-head { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px; background: none; border: 0; padding: 0; cursor: pointer; color: inherit; font: inherit; text-align: left; min-height: 44px; }
.guide-head span { font-size: 1.6rem; color: var(--plum); }
.guide-body p { margin-top: 10px; }
.resource { text-decoration: none; color: inherit; display: block; }
.resource h3 { margin-bottom: 6px; }
.resource .ext { color: var(--plum); }
.resource-site { margin-top: 10px; color: var(--text-soft); font-weight: 600; }
:root[data-theme='dark'] .resource .ext, :root[data-theme='dark'] .guide-head span { color: var(--rose); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .resource .ext, :root:not([data-theme='light']) .guide-head span { color: var(--rose); } }
.list-head { margin: 16px 0 8px; font-size: 1rem; }
.star-btn { width: 48px; height: 48px; border-radius: 12px; border: 1px solid var(--border); background: transparent; color: var(--text-soft); font-size: 1.4rem; cursor: pointer; flex-shrink: 0; }
.star-btn.on { color: var(--plum); border-color: var(--plum); }
:root[data-theme='dark'] .star-btn.on { color: var(--rose); border-color: var(--rose); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .star-btn.on { color: var(--rose); border-color: var(--rose); } }
.meal-item { padding: 14px; }
.meal-nums { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) auto; gap: 8px; align-items: end; margin-top: 10px; }
.meal-nums .field label { font-size: 0.85rem; }
@media (max-width: 620px) { .meal-nums { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* Your plans */
.plan-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.plan-list li { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; }
.plan-list li.on { border: 3px solid var(--plum); padding: 10px 12px; }
.plan-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 240px; }
.plan-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.following { display: inline-flex; gap: 6px; align-items: center; font-weight: 600; color: var(--plum); }
.following svg { width: 18px; height: 18px; }

/* Show/hide password */
.pw-wrap { position: relative; }
.pw-wrap input { width: 100%; padding-right: 52px; }
.pw-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; color: var(--text-soft); cursor: pointer; border-radius: 10px; }
.pw-eye:hover { color: var(--text); }
button.icon-btn { border: 0; background: none; cursor: pointer; font: inherit; }
