/* ==========================================================
   Marcelo Fit styles, shared by the landing page and the tracker.

   Style: a modern consumer-app look. White sticky nav bar,
   soft rounded cards, a bright green brand color and the
   Inter font, similar to popular fitness/health apps.
   ========================================================== */

/* --- Color palette & reusable values (light mode) ---
   CSS variables: define once here, reuse everywhere with var(--name).
   Dark mode (further down) simply swaps these values. */
:root {
  color-scheme: light;
  --bg: #f7f9fb;           /* page background */
  --surface: #ffffff;      /* cards */
  --surface-2: #f1f5f9;    /* insets inside cards */
  --text: #0f172a;         /* main text */
  --muted: #64748b;        /* secondary text */
  --line: #e2e8f0;         /* borders */
  --line-soft: #f1f5f9;
  --track: #eef2f6;        /* empty part of rings and bars */
  --nav-bg: rgba(255, 255, 255, 0.88);
  --grouped: #f0f3f7;      /* behind grouped lists (Settings) */
  --switch-off: #d9e0e8;   /* an "off" toggle switch */

  --primary: #0fa968;      /* brand green */
  --primary-dark: #0b8a55;
  --primary-soft: #e7f8f0;
  --primary-text: #0b8a55; /* green text on light backgrounds */
  --warn: #ef4444;         /* red, e.g. over the calorie goal */
  --warn-soft: #fee2e2;

  /* Colors for each thing we track */
  --exercise: #6366f1;
  --protein: #e11d48;
  --carbs: #f59e0b;
  --fat: #8b5cf6;
  --water: #0ea5e9;
  --steps: #6366f1;
  --km: #0fa968;
  --sleep: #6d5dfc;
  --heart: #e5484d;
  --bp: #d6336c;           /* blood pressure */

  /* Activity rings, like Apple Fitness */
  --ring-move: #fa114f;
  --ring-exercise: #4fb81e;
  --ring-stand: #00aed6;

  /* One color per meal, used for the little dots */
  --breakfast: #f59e0b;
  --lunch: #10b981;
  --dinner: #3b82f6;
  --snack: #ec4899;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05), 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 6px rgba(15, 23, 42, 0.04), 0 12px 32px rgba(15, 23, 42, 0.08);
}

/* --- Dark mode ---
   Used when you pick dark with the moon button, or when your computer
   is set to dark and you haven't picked either one. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1220;
  --surface: #131c2e;
  --surface-2: #1b2538;
  --text: #e5eaf2;
  --muted: #94a3b8;
  --line: #243047;
  --line-soft: #1b2538;
  --track: #243047;
  --nav-bg: rgba(19, 28, 46, 0.88);
  --grouped: #0b1220;
  --switch-off: #334155;
  --primary-soft: rgba(15, 169, 104, 0.16);
  --primary-text: #34d399;
  --warn-soft: rgba(239, 68, 68, 0.16);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  --ring-exercise: #92e82a;
  --ring-stand: #1eeaef;
  --sleep: #9d8cff;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b1220;
    --surface: #131c2e;
    --surface-2: #1b2538;
    --text: #e5eaf2;
    --muted: #94a3b8;
    --line: #243047;
    --line-soft: #1b2538;
    --track: #243047;
    --nav-bg: rgba(19, 28, 46, 0.88);
    --grouped: #0b1220;
    --switch-off: #334155;
    --primary-soft: rgba(15, 169, 104, 0.16);
    --primary-text: #34d399;
    --warn-soft: rgba(239, 68, 68, 0.16);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
    --ring-exercise: #92e82a;
    --ring-stand: #1eeaef;
    --sleep: #9d8cff;
  }
}

/* --- Basic reset --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Anything with the "hidden" attribute is really hidden,
   even if a class below gives it a display value. */
[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;   /* menu links glide down the page */
}

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

/* Hides text visually but keeps it for screen readers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Visible outline when moving around with the Tab key */
:focus-visible {
  outline: 3px solid rgba(15, 169, 104, 0.5);
  outline-offset: 2px;
}

/* Keeps content centered with a max width, and 16px from phone edges */
.container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 16px;
}

@media (min-width: 768px) {
  .container {
    padding: 0 24px;
  }
}

.muted {
  color: var(--muted);
}

/* --- Logo --- */
.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.logo-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #34d399, var(--primary));
  display: grid;
  place-items: center;
  color: #fff;
  flex: none;
}

.logo-mark svg {
  width: 20px;
  height: 20px;
}

/* Line icons */
.i {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.8rem 1.4rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 6px 16px rgba(15, 169, 104, 0.28);
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--line);
}

.btn-secondary:hover {
  background: var(--surface-2);
}

.btn-light {
  background: #fff;
  color: var(--primary-dark);
}

.btn-light:hover {
  background: #f0fdf7;
  transform: translateY(-1px);
}

.btn-water {
  background: var(--water);
  color: #fff;
}

.btn-water:hover {
  filter: brightness(0.93);
}

.btn-danger {
  background: var(--warn-soft);
  color: var(--warn);
}

.btn-danger:hover {
  background: var(--warn);
  color: #fff;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

.btn-lg {
  padding: 1rem 1.75rem;
  font-size: 1.05rem;
}

.btn-sm {
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
}

.btn-block {
  width: 100%;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: none;
}

.icon-btn:hover {
  background: var(--surface-2);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-btn.small {
  width: 30px;
  height: 30px;
}

.icon-btn.small svg {
  width: 16px;
  height: 16px;
}

.icon-btn:disabled {
  opacity: 0.35;
  background: transparent;
  cursor: default;
}

.link-btn {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary-text);
  text-decoration: none;
  background: none;
  border: 0;
  cursor: pointer;
}

.link-btn:hover {
  text-decoration: underline;
}

/* --- Top navigation bar (both pages) --- */
.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 64px;
}

.nav-links {
  display: flex;
  gap: 1.75rem;
  list-style: none;
}

.nav-links a {
  text-decoration: none;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.95rem;
}

.nav-links a:hover {
  color: var(--text);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

@media (max-width: 820px) {
  .nav-links {
    display: none;
  }
}

/* ==========================================================
   Landing page
   ========================================================== */

.section {
  padding: 88px 0;
}

.section-white {
  background: var(--surface);
}

.section-head {
  text-align: center;
  max-width: 640px;
  margin: 0 auto 48px;
}

.eyebrow {
  display: inline-block;
  background: var(--primary-soft);
  color: var(--primary-text);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  margin-bottom: 0.9rem;
}

.section-head h2 {
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.section-head p {
  color: var(--muted);
  font-size: 1.1rem;
  margin-top: 0.8rem;
}

/* --- Hero --- */
.hero {
  overflow: hidden;
  padding: 72px 0 96px;
  background:
    radial-gradient(55% 60% at 85% 25%, rgba(52, 211, 153, 0.2), transparent 70%),
    radial-gradient(45% 50% at 0% 100%, rgba(99, 102, 241, 0.1), transparent 70%);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 48px;
  align-items: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.3rem 0.9rem 0.3rem 0.35rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  box-shadow: var(--shadow-sm);
}

.pill-tag {
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 700;
}

.hero h1 {
  font-size: clamp(2.6rem, 6vw, 4.2rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.035em;
  margin: 1.25rem 0;
}

.gradient-text {
  background: linear-gradient(90deg, var(--primary), #34d399);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  font-size: 1.2rem;
  color: var(--muted);
  max-width: 34rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 2rem 0;
}

/* True facts under the hero buttons (no account, no ads, offline) */
.hero-facts {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.4rem;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 500;
}

.hero-facts li {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.hero-facts .i {
  width: 18px;
  height: 18px;
  color: var(--primary);
  stroke-width: 2.5;
}

/* --- Phone mockup in the hero --- */
.hero-visual {
  position: relative;
}

.phone {
  width: 290px;
  max-width: 100%;
  margin: 0 auto;
  background: #0f172a;
  border-radius: 44px;
  padding: 11px;
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.25);
}

.phone-screen {
  background: var(--bg);
  border-radius: 34px;
  overflow: hidden;
  padding: 0 14px 18px;
}

.phone-notch {
  width: 90px;
  height: 22px;
  background: #0f172a;
  border-radius: 0 0 14px 14px;
  margin: 0 auto 14px;
}

.phone-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.phone-top strong {
  font-size: 1.05rem;
}

.phone-top span {
  font-size: 0.75rem;
  color: var(--muted);
}

.mini-card {
  background: var(--surface);
  border-radius: 18px;
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 10px;
}

.mini-meal {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  font-size: 0.85rem;
}

.mini-meal + .mini-meal {
  border-top: 1px solid var(--line);
}

.mini-meal .kcal {
  margin-left: auto;
  font-weight: 600;
}

/* Activity rings inside the phone */
.mini-rings {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mini-rings .rings-svg {
  width: 92px;
  height: 92px;
  flex: none;
}

.mini-rings .rings-svg circle {
  fill: none;
  stroke-width: 12;
}

.mini-rings ul {
  list-style: none;
  display: grid;
  gap: 4px;
  font-size: 0.72rem;
  line-height: 1.2;
}

.mini-rings span {
  display: block;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.62rem;
}

.mini-rings .rl-move     { color: color-mix(in srgb, var(--ring-move) 80%, var(--text)); }
.mini-rings .rl-exercise { color: color-mix(in srgb, var(--ring-exercise) 65%, var(--text)); }
.mini-rings .rl-stand    { color: color-mix(in srgb, var(--ring-stand) 65%, var(--text)); }

.mini-rings strong {
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.mini-left {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.85rem;
  color: var(--muted);
}

.mini-left strong {
  font-size: 1.15rem;
  color: var(--primary-text);
}

/* Little pop-up cards floating next to the phone */
.float {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border-radius: 14px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  font-size: 0.85rem;
  line-height: 1.3;
}

.float strong {
  display: block;
}

.float span {
  color: var(--muted);
}

.float-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: none;
  background: color-mix(in srgb, currentColor 14%, transparent);
}

.float-icon svg {
  width: 18px;
  height: 18px;
}

.float-1 {
  top: 47%;
  left: 0;
}

.float-2 {
  bottom: 12%;
  right: 0;
}

/* --- Stats strip --- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 32px;
  box-shadow: var(--shadow-sm);
  margin-top: -48px;
  position: relative;
  text-align: center;
}

.stat strong {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.stat span {
  color: var(--muted);
  font-size: 0.95rem;
}

/* --- Feature cards --- */
.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.feature {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  transition: box-shadow 0.2s, transform 0.2s;
}

.feature:hover {
  box-shadow: var(--shadow);
  transform: translateY(-3px);
}

/* Icon squares: the background is a pale version of the icon color */
.icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  background: color-mix(in srgb, currentColor 14%, transparent);
}

.icon svg {
  width: 24px;
  height: 24px;
}

.icon-green  { color: var(--primary); }
.icon-indigo { color: #6366f1; }
.icon-amber  { color: #d97706; }
.icon-pink   { color: #db2777; }
.icon-blue   { color: #3b82f6; }
.icon-teal   { color: #0d9488; }

.feature h3 {
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  margin-bottom: 0.4rem;
}

.feature p {
  color: var(--muted);
}

/* --- How it works --- */
.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
  list-style: none;
}

.step {
  text-align: center;
  padding: 0 12px;
}

.step-num {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  font-size: 1.3rem;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  box-shadow: 0 8px 20px rgba(15, 169, 104, 0.3);
}

.step h3 {
  font-size: 1.15rem;
  margin-bottom: 0.4rem;
}

.step p {
  color: var(--muted);
}

/* --- FAQ --- */
.faq {
  max-width: 760px;
  margin: 0 auto;
  display: grid;
  gap: 12px;
}

.faq details {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0 22px;
}

.section-white .faq details {
  background: var(--bg);
}

.faq summary {
  list-style: none;
  cursor: pointer;
  padding: 18px 0;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary::after {
  content: "+";
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1;
  color: var(--muted);
  transition: transform 0.2s;
}

.faq details[open] summary::after {
  transform: rotate(45deg);
}

.faq details p {
  color: var(--muted);
  padding-bottom: 18px;
}

/* --- Final call to action --- */
.cta {
  background: linear-gradient(135deg, var(--primary) 0%, #10b981 55%, #34d399 100%);
  border-radius: 28px;
  padding: 64px 32px;
  text-align: center;
  color: #fff;
}

.cta h2 {
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.cta p {
  opacity: 0.92;
  font-size: 1.1rem;
  max-width: 32rem;
  margin: 0.8rem auto 1.8rem;
}

/* --- Footer --- */
.footer {
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 40px 0;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.footer-lang {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1.25rem;
  color: var(--muted);
}

.footer-lang .i {
  width: 18px;
  height: 18px;
}

.footer-lang select {
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  list-style: none;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
}

.footer-links a:hover {
  color: var(--text);
}

.footer-note {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 1.25rem;
}

@media (max-width: 900px) {
  .hero {
    padding: 48px 0 88px;
  }
  .hero-grid {
    grid-template-columns: 1fr;
  }
  .features {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 700px) {
  .section {
    padding: 64px 0;
  }
  .stats {
    grid-template-columns: repeat(2, 1fr);
    padding: 24px;
  }
  .steps {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .features {
    grid-template-columns: 1fr;
  }
  .float-1 {
    left: -6px;
  }
  .float-2 {
    right: -6px;
  }
  .cta {
    padding: 48px 20px;
  }
}

/* ==========================================================
   Tracker: shared pieces
   ========================================================== */

.day-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}

.day-nav h1 {
  font-size: 0.95rem;
  font-weight: 600;
  min-width: 8rem;
  text-align: center;
  white-space: nowrap;
}

.day-nav .icon-btn {
  width: 32px;
  height: 32px;
  border: 0;
  box-shadow: var(--shadow-sm);
}

/* --- Tab bar: under the top bar on computers, at the bottom on phones --- */
.tabbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 64px;
  z-index: 15;
}

.tabs {
  display: flex;
  gap: 0.25rem;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}

.tab svg {
  width: 18px;
  height: 18px;
}

.tab:hover {
  color: var(--text);
}

.tab[aria-selected="true"] {
  color: var(--primary-text);
  border-bottom-color: var(--primary);
}

.tab-panel {
  padding: 28px 0 64px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1rem;
}

.card-head h2 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* Small heading inside a card */
.sub-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 1.5rem 0 0.75rem;
}

.small-text {
  font-size: 0.85rem;
  margin-top: 0.6rem;
}

.card-head .muted {
  font-size: 0.85rem;
}

.col {
  display: grid;
  gap: 24px;
  align-content: start;
  min-width: 0;
}

/* Progress bars ("meters") */
.meter {
  height: 10px;
  background: var(--track);
  border-radius: 999px;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.5s ease;
}

.fill-protein { background: var(--protein); }
.fill-carbs   { background: var(--carbs); }
.fill-fat     { background: var(--fat); }
.fill-km      { background: var(--km); }
.fill-water   { background: var(--water); }
.fill-steps   { background: var(--steps); }
.fill-sleep   { background: var(--sleep); }

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
  display: inline-block;
}

.dot-breakfast { background: var(--breakfast); }
.dot-lunch     { background: var(--lunch); }
.dot-dinner    { background: var(--dinner); }
.dot-snack     { background: var(--snack); }
.dot-exercise  { background: var(--exercise); }
.dot-protein   { background: var(--protein); }
.dot-carbs     { background: var(--carbs); }
.dot-fat       { background: var(--fat); }
.dot-move      { background: var(--ring-move); }
.dot-exring    { background: var(--ring-exercise); }
.dot-stand     { background: var(--ring-stand); }
.dot-sleep     { background: var(--sleep); }
.dot-water     { background: var(--water); }
.dot-heart     { background: var(--heart); }

.status {
  font-size: 0.85rem;
  color: var(--primary-text);
  font-weight: 600;
  min-height: 1.3em;
  margin-top: 0.5rem;
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.6rem 0 1rem;
}

/* --- Rings (calories and steps) --- */
.ring-wrap {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0.5rem auto 1.25rem;
}

.ring-wrap.mini {
  width: 150px;
  height: 150px;
  margin: 4px auto 10px;
}

.ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);   /* start filling from the top */
}

.ring circle {
  fill: none;
  stroke-width: 12;
}

.ring-track {
  stroke: var(--track);
}

/* pathLength="100" in the HTML means the circle is 100 units long,
   so a dash offset of 35 leaves 65% of the ring filled. */
.ring-fill {
  stroke: var(--primary);
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset 0.6s ease, stroke 0.3s;
}

.ring-fill.steps {
  stroke: var(--steps);
}

.ring-fill.over {
  stroke: var(--warn);
}

.ring-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}

.ring-center strong {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.ring-wrap.mini .ring-center strong {
  font-size: 1.7rem;
}

.ring-center span {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.3rem;
}

.ring-center.over strong {
  color: var(--warn);
}

/* --- Form pieces --- */

/* The radio circles are hidden; the <span> next to each is styled instead */
.segmented input,
.chips input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.segmented {
  border: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 1.1rem;
}

.segmented span {
  display: block;
  text-align: center;
  padding: 0.55rem;
  border-radius: 9px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.segmented input:checked + span {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.segmented input:focus-visible + span,
.chips input:focus-visible + span {
  outline: 3px solid rgba(15, 169, 104, 0.5);
  outline-offset: 2px;
}

.fields {
  display: grid;
  grid-template-columns: 1fr 9rem;
  gap: 0.75rem;
}

.fields.two {
  grid-template-columns: 1fr 1fr;
}

.fields + .fields {
  margin-top: 0.75rem;
}

.fields.three {
  grid-template-columns: repeat(3, 1fr);
  margin-top: 0.75rem;
}

.field span,
.chips legend,
.form-label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
}

.field input,
.field select,
.inline input {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-size: 1rem;      /* 16px stops phones from zooming in on tap */
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field select:focus,
.inline input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(15, 169, 104, 0.15);
}

.inline {
  display: flex;
  gap: 0.5rem;
}

.inline input {
  flex: 1;
  min-width: 0;
}

.chips {
  border: 0;
  margin-top: 1rem;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chips span {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
}

/* An icon or word inside a chip (Walk / Run / Hike) is part of the pill, not a pill of its own */
.chips span span {
  display: inline;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  font: inherit;
  color: inherit;
}

.chips input:checked + span {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-text);
  font-weight: 600;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  font-size: 0.95rem;
  cursor: pointer;
}

.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.form-actions {
  margin-top: 1.25rem;
}

/* ==========================================================
   Today tab
   ========================================================== */

/* "Time for a backup" card at the top of Today (backup.js) */
.nudge {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.nudge .tile {
  width: 40px;
  height: 40px;
  border-radius: 11px;
}

.nudge-text {
  flex: 1 1 260px;
  display: grid;
  gap: 2px;
}

.nudge-text span {
  color: var(--muted);
  font-size: 0.92rem;
}

.nudge-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

@media (max-width: 560px) {
  .nudge-actions {
    width: 100%;
  }
  .nudge-actions .btn {
    flex: 1;
  }
}

.tracker {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  gap: 24px;
  align-items: start;
}

/* Goal − Food + Exercise */
.equation {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-2);
  border-radius: 14px;
  padding: 12px 16px;
  text-align: center;
}

.equation strong {
  display: block;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

.equation span {
  font-size: 0.75rem;
  color: var(--muted);
}

.equation .op {
  font-size: 1rem;
  font-weight: 600;
}

.progress-text {
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.75rem 0 1rem;
}

.progress-text strong {
  color: var(--text);
}

/* Per-meal breakdown */
.breakdown {
  list-style: none;
  border-top: 1px solid var(--line);
  padding-top: 0.5rem;
}

.breakdown li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.4rem 0;
  font-size: 0.95rem;
}

.breakdown .kcal {
  margin-left: auto;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.breakdown .pct {
  width: 2.75rem;
  text-align: right;
  font-size: 0.85rem;
  color: var(--muted);
}

.breakdown .out .kcal {
  color: var(--exercise);
}

/* Macros (protein, carbs, fat) */
.macro + .macro {
  margin-top: 1rem;
}

.macro-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.4rem;
  font-size: 0.95rem;
}

.macro-top > span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.macro-top .muted {
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

/* Water cups */
.cups {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 1rem;
}

.cup {
  width: 34px;
  height: 42px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--line);
}

.cup svg {
  width: 100%;
  height: 100%;
}

.cup path {
  fill: transparent;
  stroke: currentColor;
  stroke-width: 1.6;
  transition: fill 0.2s;
}

.cup.full {
  color: var(--water);
}

.cup.full path {
  fill: currentColor;
}

.water-actions {
  display: flex;
  gap: 0.5rem;
}

/* Favorites */
.favorites {
  margin-bottom: 1.1rem;
}

.fav-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.fav {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  overflow: hidden;
}

.fav-add {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 0;
  background: none;
  padding: 0.4rem 0.4rem 0.4rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}

.fav-add .muted {
  font-size: 0.8rem;
}

.fav-add:hover {
  color: var(--primary-text);
}

.fav-remove {
  border: 0;
  background: none;
  color: var(--muted);
  width: 30px;
  height: 30px;
  font-size: 1.05rem;
  cursor: pointer;
  border-radius: 50%;
}

.fav-remove:hover {
  color: var(--warn);
}

.empty-small {
  font-size: 0.85rem;
  color: var(--muted);
}

/* Log list */
.group + .group {
  margin-top: 1.25rem;
}

.group h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}

.group h3 .num {
  margin-left: auto;
  color: var(--muted);
  font-weight: 600;
}

.group ul {
  list-style: none;
}

.entry {
  display: grid;
  grid-template-columns: 1fr auto 2rem 2rem;
  gap: 0.75rem;
  align-items: center;
  padding: 0.6rem 0 0.6rem 20px;
  border-bottom: 1px solid var(--line-soft);
}

.entry-name {
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.entry-macros {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.group.out .num {
  color: var(--exercise);
}

.edit {
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.edit svg {
  width: 16px;
  height: 16px;
}

.edit:hover {
  background: var(--primary-soft);
  color: var(--primary-text);
}

.delete {
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.delete:hover {
  background: var(--warn-soft);
  color: var(--warn);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem 1rem;
}

/* --- Copying food (copy.js) --- */
.head-links {
  display: inline-flex;
  gap: 1rem;
  flex: none;
  white-space: nowrap;
}

/* "Copy to today" in a meal's heading on past days */
.group-copy {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 0;
  background: var(--primary-soft);
  color: var(--primary-text);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.group-copy .i {
  width: 14px;
  height: 14px;
}

.group-copy:hover {
  background: var(--primary);
  color: #fff;
}

/* "Breakfast like yesterday" buttons under the log */
.copy-suggest {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--line);
}

.empty + .copy-suggest {
  margin-top: 0;
}

.copy-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.copy-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 0.4rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}

.copy-chip .i {
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.copy-chip .muted {
  font-size: 0.8rem;
}

.copy-chip:hover {
  border-color: var(--primary);
  color: var(--primary-text);
}

/* The Copy food window */
.copy-dates {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 0.5rem;
}

.copy-arrow {
  width: 20px;
  height: 20px;
  margin-bottom: 0.85rem;
  color: var(--muted);
}

.copy-dates .field {
  min-width: 0;
}

/* Phones: "From" above "To", so the dates have room */
@media (max-width: 480px) {
  .copy-dates {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .copy-arrow {
    display: none;
  }
}

.copy-choices {
  border: 0;
  margin-top: 1.25rem;
}

.copy-choices .check {
  margin: 0;
  align-items: flex-start;
}

.copy-choices .check strong {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.copy-choices .check input:disabled + span {
  opacity: 0.5;
}

.copy-choices .check:has(input:disabled) {
  cursor: default;
}

#copy-note:empty {
  display: none;
}

/* --- My foods & recipes window (my-foods.js) --- */
.myfoods-view {
  display: flex;
  flex-direction: column;
  max-height: inherit;
  min-height: 0;
}

.myfoods-view[hidden],
.mf-fieldset[hidden],
.myfoods-dialog .field[hidden] {
  display: none;
}

.myfoods-dialog #myfood-form .dialog-head {
  justify-content: flex-start;
}

.myfoods-dialog #myfood-form .dialog-head h2 {
  flex: 1;
}

.myfoods-dialog .dialog-body > .hint:first-child {
  margin-top: 1rem;
}

.myfoods-dialog .dialog-body > .fields:first-child {
  margin-top: 1.25rem;
}

.myfoods-dialog .fields {
  grid-template-columns: 1fr 8rem;
}

.mf-fieldset {
  border: 0;
  min-width: 0;
}

#mf-recipe-fields {
  margin-top: 1.1rem;
}

.mf-fieldset .goal-grid {
  margin: 0.75rem 0 0.5rem;
}

.myfoods-list {
  list-style: none;
}

.myfood {
  display: grid;
  grid-template-columns: 1fr 2rem;
  gap: 0.5rem;
  align-items: center;
  border-bottom: 1px solid var(--line-soft);
}

.myfood-pick {
  border: 0;
  background: none;
  text-align: left;
  padding: 0.7rem 0.5rem;
  margin-left: -0.5rem;
  border-radius: 10px;
  cursor: pointer;
  min-width: 0;
}

.myfood-pick:hover {
  background: var(--surface-2);
}

.myfood-pick strong {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.myfood-pick small {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.recipe-tag {
  background: var(--primary-soft);
  color: var(--primary-text);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Ingredient search: the results sit in the window instead of floating */
.ing-search .search-results {
  position: static;
  margin-top: 6px;
  max-height: 260px;
  box-shadow: none;
}

.ing-list {
  list-style: none;
  margin-top: 0.5rem;
}

.ing {
  display: grid;
  grid-template-columns: 1fr 4.5rem 3.5rem 2rem;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line-soft);
}

.amount-input {
  width: 100%;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 1rem;
  text-align: center;
}

.amount-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(15, 169, 104, 0.15);
}

.recipe-total {
  margin-top: 0.9rem;
  background: var(--primary-soft);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 0.9rem;
  display: grid;
  gap: 0.2rem;
}

.recipe-total.muted {
  background: var(--surface-2);
}

.myfoods-dialog .dialog-actions .btn-danger {
  margin-right: auto;
}

/* ==========================================================
   Activity tab
   ========================================================== */

.activity-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
  align-items: start;
}

.km-block {
  margin: 0.25rem 0 1.25rem;
}

.km-big {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.streak-hero {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.streak-flame {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: rgba(249, 115, 22, 0.14);
  display: grid;
  place-items: center;
  font-size: 2.2rem;
  flex: none;
}

.streak-hero strong {
  display: block;
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.15;
}

.streak-hero span {
  color: var(--muted);
  font-size: 0.9rem;
}

.week-dots {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 1.25rem;
}

.week-dots li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.day-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--track);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
}

.week-dots .hit .day-circle {
  background: var(--primary);
}

.week-dots .current .day-circle {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary);
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 12px;
}

.mini-stats div {
  background: var(--surface-2);
  border-radius: 14px;
  padding: 12px;
  text-align: center;
}

.mini-stats strong {
  display: block;
  font-size: 1.3rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.mini-stats span {
  font-size: 0.8rem;
  color: var(--muted);
}

.next-awards {
  list-style: none;
  display: grid;
  gap: 16px;
}

.next-awards li {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: center;
}

.next-awards strong {
  display: block;
  font-size: 0.95rem;
}

.next-awards small {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.3rem;
}

/* ==========================================================
   Awards tab
   ========================================================== */

.awards-summary {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.awards-summary h2 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.meter.big {
  height: 14px;
}

.award-group + .award-group {
  margin-top: 2rem;
}

.award-group h3 {
  font-size: 1.05rem;
  margin-bottom: 0.9rem;
}

.badges {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.badge {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.badge-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 2rem;
  background: var(--surface-2);
  margin-bottom: 0.4rem;
}

.badge-icon.small {
  width: 44px;
  height: 44px;
  font-size: 1.35rem;
  margin: 0;
}

.badge.earned .badge-icon {
  background: linear-gradient(135deg, #fde68a, #f59e0b);
  box-shadow: 0 6px 16px rgba(245, 158, 11, 0.35);
}

.badge.locked .badge-icon {
  filter: grayscale(1);
  opacity: 0.5;
}

.badge strong {
  font-size: 1rem;
  line-height: 1.3;
}

.badge p {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.4;
}

.badge .meter {
  width: 100%;
  height: 8px;
  margin-top: auto;
}

.badge small {
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.badge-foot {
  width: 100%;
  margin-top: auto;
  padding-top: 0.6rem;
}

.earned-tag {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary-text);
  background: var(--primary-soft);
  padding: 0.15rem 0.7rem;
  border-radius: 999px;
}

/* ==========================================================
   Trends tab (charts) and the weight chart on the Health tab
   ========================================================== */

.metric-switch {
  margin: 0;
}

/* Bar chart */
.chart-bars {
  position: relative;
  height: 200px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

.bar-col {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  min-width: 0;
}

.bar-value {
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-bottom: 4px;
  white-space: nowrap;
}

.bar {
  width: 100%;
  max-width: 44px;
  min-height: 3px;
  border-radius: 8px 8px 3px 3px;
  transition: height 0.5s ease;
}

.bar-col.current .bar-value {
  color: var(--text);
  font-weight: 700;
}

.goal-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 2px dashed var(--muted);
  opacity: 0.6;
  pointer-events: none;
}

.goal-line span {
  position: absolute;
  right: 0;
  top: -1.4rem;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--surface);
  padding: 0 4px;
}

.chart-days {
  display: flex;
  gap: 10px;
  margin: 0.4rem 0 1.25rem;
}

.chart-days span {
  flex: 1;
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
}

.chart-days span.current {
  color: var(--text);
  font-weight: 700;
}

/* Weight chart */
.weight-chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.wc-grid {
  stroke: var(--line);
  stroke-width: 1;
}

.wc-area {
  fill: var(--primary);
  opacity: 0.1;
}

.wc-line {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.wc-dot {
  fill: var(--surface);
  stroke: var(--primary);
  stroke-width: 2;
}

.wc-label {
  fill: var(--muted);
  font-size: 11px;
  font-family: inherit;
}

.chart-empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 2.5rem 1rem;
  background: var(--surface-2);
  border-radius: 14px;
}

.weight-form {
  margin: 1.25rem 0 0.5rem;
}

.weight-form .inline input[type="date"] {
  flex: 1.2;
}

.weight-list {
  list-style: none;
  margin-top: 0.5rem;
}

.wc-goal {
  stroke: var(--muted);
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
  opacity: 0.7;
}

.weight-list li {
  display: grid;
  grid-template-columns: 1fr auto 2rem;
  gap: 0.75rem;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line-soft);
}

/* ==========================================================
   Food search, portions and editing (Today tab)
   ========================================================== */

.food-search {
  position: relative;
  margin-bottom: 1.1rem;
}

.search-row {
  display: flex;
  gap: 0.5rem;
}

.search-box {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.search-box:focus-within {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 4px rgba(15, 169, 104, 0.15);
}

.search-box svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
  flex: none;
}

.search-box input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  padding: 0.7rem 0;
  font-size: 1rem;
  outline: none;
}

.scan-btn {
  padding: 0.6rem 1rem;
}

.scan-btn svg {
  width: 18px;
  height: 18px;
}

/* Voice logging (voice.js) */
@media (max-width: 560px) {
  .voice-btn span {
    display: none;    /* just the microphone on phones, to leave room for the search box */
  }
}

/* Insights (insights.js) */
.insights {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.insights:empty {
  display: none;
}

.insight {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface-2);
}

.insight-icon {
  font-size: 1.4rem;
  line-height: 1.2;
  flex: none;
}

/* Walk tracker (walk.js) */
.walk-types {
  margin: 0 0 1rem;
}

.walk-stats {
  grid-template-columns: repeat(2, 1fr);
}

.walk-stats strong {
  font-size: 1.6rem;
}

.walk-card.is-tracking .walk-stats div {
  background: var(--primary-soft);
}

.walk-state {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary-text);
}

.walk-card.is-tracking .walk-state::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--primary);
  animation: walk-blink 1.2s ease-in-out infinite;
}

@keyframes walk-blink {
  50% { opacity: 0.2; }
}

@media (prefers-reduced-motion: reduce) {
  .walk-card.is-tracking .walk-state::before { animation: none; }
}

.walk-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1rem;
}

.walk-actions .btn {
  flex: 1;
}

.walk-actions .link-btn {
  flex-basis: 100%;
  text-align: center;
}

/* Walk maps (route-map.js, Leaflet + OpenStreetMap) */
.route-map {
  height: 240px;
  margin-top: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--line-soft);
  isolation: isolate;   /* Leaflet's layers stay under the tab bar and dialogs */
}

.route-map-big {
  height: min(45vh, 400px);
}

.route-map .leaflet-control-attribution {
  font-size: 0.7rem;
}

[data-theme="dark"] .route-tiles {
  filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .route-tiles {
    filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9);
  }
}

#route-replay {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

#route-replay[hidden] {
  display: none;
}

#route-replay svg {
  width: 18px;
  height: 18px;
}

#route-replay.is-playing svg {
  display: none;
}

.route-replay-badge {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.82);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

/* "What can I cook?" (recipe.js) */
.recipe-open {
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.recipe-open input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.recipe-open:focus-within {
  outline: 3px solid rgba(15, 169, 104, 0.5);
  outline-offset: 2px;
}

#recipe-preview {
  width: 100%;
  max-height: 170px;
  object-fit: cover;
  border-radius: 14px;
  background: var(--surface-2);
}

.recipe-seen {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.8rem;
}

.recipe-seen:empty {
  display: none;
}

.recipe-seen-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  margin-right: 0.15rem;
}

.recipe-chip {
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.85rem;
}

.recipe-list {
  list-style: none;
  margin: 0.8rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.7rem;
}

.recipe-card {
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  display: grid;
  gap: 0.5rem;
}

.recipe-card h3 {
  margin: 0;
  font-size: 1.05rem;
}

.recipe-facts {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.recipe-more summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--primary-text);
  font-size: 0.92rem;
}

.recipe-ingredients,
.recipe-steps {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
  display: grid;
  gap: 0.3rem;
  font-size: 0.95rem;
}

.recipe-more .recipe-steps {
  margin-top: 0.7rem;
}

.recipe-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Walk weather (weather.js) */
.weather-card {
  --weather-tint: var(--surface-2);
}

.weather-card[data-level="great"] { --weather-tint: color-mix(in srgb, #10b981 16%, var(--surface)); }
.weather-card[data-level="good"]  { --weather-tint: color-mix(in srgb, #38bdf8 16%, var(--surface)); }
.weather-card[data-level="ok"]    { --weather-tint: color-mix(in srgb, #f59e0b 16%, var(--surface)); }
.weather-card[data-level="poor"]  { --weather-tint: color-mix(in srgb, #64748b 18%, var(--surface)); }

#weather-start {
  margin-top: 0.8rem;
}

#weather-start[hidden],
.weather-status[hidden] {
  display: none;
}

.weather-status.is-error {
  color: #b45309;
}

#weather-updated {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.weather-main {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  background: var(--weather-tint);
}

.weather-main p {
  margin: 0;
}

.weather-icon {
  font-size: 2.8rem;
  line-height: 1;
}

.weather-verdict {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.weather-best {
  font-size: 1.25rem;
  font-weight: 800;
}

.weather-detail {
  color: var(--muted);
  font-size: 0.92rem;
}

.weather-warnings {
  list-style: none;
  margin: 0.7rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}

.weather-warnings:empty {
  display: none;
}

.weather-warnings li {
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  border: 1px solid #f59e0b;
  font-size: 0.9rem;
}

.weather-scroll {
  margin-top: 0.8rem;
  overflow-x: auto;
  scrollbar-width: thin;
}

.weather-hours {
  list-style: none;
  margin: 0;
  padding: 0 0 0.3rem;
  display: flex;
  gap: 0.4rem;
}

.weather-hour {
  flex: none;
  min-width: 3.6rem;
  display: grid;
  justify-items: center;
  gap: 0.1rem;
  padding: 0.5rem 0.35rem;
  border-radius: 12px;
  background: var(--surface-2);
  font-variant-numeric: tabular-nums;
}

.weather-hour.is-best {
  background: var(--primary);
  color: #fff;
}

.weather-hour-time {
  font-size: 0.75rem;
  font-weight: 600;
  opacity: 0.8;
}

.weather-hour-icon {
  font-size: 1.3rem;
  line-height: 1.2;
}

.weather-hour small {
  font-size: 0.72rem;
  opacity: 0.75;
}

.weather-credit {
  margin: 0.5rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.weather-credit a {
  color: inherit;
}

/* The AI coach (coach.js) */
.coach-dialog[open] {
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  height: min(680px, calc(100% - 32px));
}

.coach-log {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  overflow-y: auto;
  min-height: 0;
}

.coach-msg {
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
  max-width: 88%;
}

.coach-user {
  align-self: flex-end;
}

.coach-bubble {
  margin: 0;
  padding: 0.7rem 0.9rem;
  border-radius: 18px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.coach-coach .coach-bubble {
  background: var(--surface-2);
  color: var(--text);
  border-bottom-left-radius: 6px;
}

.coach-user .coach-bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 6px;
}

.coach-error .coach-bubble {
  background: var(--surface-2);
  border: 1px solid #f59e0b;
}

.coach-typing .coach-bubble {
  animation: coach-pulse 1.1s ease-in-out infinite;
  font-weight: 800;
  letter-spacing: 0.15em;
}

@keyframes coach-pulse {
  50% { opacity: 0.35; }
}

.coach-speak {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.coach-speak .i {
  width: 17px;
  height: 17px;
}

.coach-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding-top: 0.6rem;
}

.coach-chips[hidden] {
  display: none;
}

.coach-chip {
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--primary-text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.coach-form {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.coach-form input {
  flex: 1;
  min-width: 0;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.coach-form input:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 1px;
}

.coach-send {
  width: 46px;
  height: 46px;
  padding: 0;
  display: grid;
  place-items: center;
  flex: none;
}

.coach-send .i,
.coach-mic .i {
  width: 20px;
  height: 20px;
}

.coach-mic.is-listening {
  color: #fff;
  background: #ef4444;
}

.coach-privacy {
  margin: 0.6rem 0 0;
  font-size: 0.78rem;
}

@media (max-width: 560px) {
  .coach-dialog[open] {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    padding: calc(env(safe-area-inset-top, 0px) + 16px) 16px calc(env(safe-area-inset-bottom, 0px) + 12px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .coach-typing .coach-bubble { animation: none; }
}

/* "Your month, wrapped" (wrapped.js) */
.wrapped-banner {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  width: 100%;
  padding: 1rem 1.1rem;
  border: 0;
  border-radius: 20px;
  background: linear-gradient(120deg, #10b981, #6366f1 60%, #ec4899);
  color: #fff;
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 10px 24px -12px rgba(99, 102, 241, 0.7);
}

.wrapped-banner[hidden] {
  display: none;
}

.wrapped-banner:focus-visible {
  outline: 3px solid var(--text);
  outline-offset: 3px;
}

.wrapped-banner-emoji {
  font-size: 2rem;
  line-height: 1;
}

.wrapped-banner-text {
  flex: 1;
  min-width: 0;
  display: grid;
}

.wrapped-banner-text strong {
  font-size: 1.1rem;
}

.wrapped-banner-text span {
  font-size: 0.88rem;
  opacity: 0.9;
}

.wrapped-banner-go {
  padding: 0.45rem 1rem;
  border-radius: 999px;
  background: #fff;
  color: #4f46e5;
  font-weight: 800;
  white-space: nowrap;
}

.wrapped-dialog {
  --wrap-a: #10b981;
  --wrap-b: #0e7490;
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  color: #fff;
  background: radial-gradient(120% 90% at 20% 10%, var(--wrap-a), var(--wrap-b));
  overflow: hidden;
  transition: background 0.5s ease;
}

.wrapped-dialog::backdrop {
  background: #0b1220;
}

.wrapped-dialog[data-look="indigo"] { --wrap-a: #6366f1; --wrap-b: #312e81; }
.wrapped-dialog[data-look="sky"]    { --wrap-a: #38bdf8; --wrap-b: #1e40af; }
.wrapped-dialog[data-look="amber"]  { --wrap-a: #f59e0b; --wrap-b: #b45309; }
.wrapped-dialog[data-look="pink"]   { --wrap-a: #ec4899; --wrap-b: #7c2d92; }
.wrapped-dialog[data-look="orange"] { --wrap-a: #fb923c; --wrap-b: #be123c; }
.wrapped-dialog[data-look="violet"] { --wrap-a: #a78bfa; --wrap-b: #4c1d95; }
.wrapped-dialog[data-look="red"]    { --wrap-a: #f43f5e; --wrap-b: #7f1d1d; }

.wrapped-bars {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  left: 16px;
  right: 16px;
  display: flex;
  gap: 4px;
  z-index: 3;
}

.wrapped-bar {
  flex: 1;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.35);
  overflow: hidden;
}

.wrapped-bar i {
  display: block;
  width: 0;
  height: 100%;
  background: #fff;
}

.wrapped-close {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 26px);
  right: 12px;
  z-index: 4;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.18);
  color: #fff;
  cursor: pointer;
}

.wrapped-close .i,
.wrapped-nav .i {
  width: 22px;
  height: 22px;
}

.wrapped-stage {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  padding: 90px 28px calc(env(safe-area-inset-bottom, 0px) + 90px);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.wrapped-slide {
  width: min(460px, 100%);
  display: grid;
  gap: 0.6rem;
  text-align: center;
  animation: wrapped-in 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes wrapped-in {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.wrapped-emoji {
  font-size: 4rem;
  line-height: 1.1;
}

.wrapped-kicker {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.85;
}

.wrapped-title {
  margin: 0;
  font-size: clamp(2rem, 9vw, 3rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.wrapped-number {
  margin: 0;
  display: grid;
  line-height: 1;
}

.wrapped-number span {
  font-size: clamp(4.5rem, 24vw, 7.5rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.wrapped-number small {
  margin-top: 0.4rem;
  font-size: 1.3rem;
  font-weight: 700;
}

.wrapped-caption {
  margin: 0.4rem auto 0;
  max-width: 32ch;
  font-size: 1.1rem;
  line-height: 1.45;
  opacity: 0.95;
  text-wrap: balance;
}

.wrapped-lines {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}

.wrapped-lines li {
  padding: 0.8rem 1rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 1.05rem;
  font-weight: 600;
}

.wrapped-actions {
  margin-top: 1.2rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.7rem;
}

.wrapped-share {
  background: #fff;
  color: #065f46;
}

.wrapped-done {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.wrapped-confetti {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

.wrapped-nav {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
  z-index: 3;
  display: flex;
  justify-content: center;
  gap: 1.2rem;
}

.wrapped-nav button {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  cursor: pointer;
}

.wrapped-nav button:disabled {
  opacity: 0.35;
  cursor: default;
}

.wrapped-close:focus-visible,
.wrapped-nav button:focus-visible,
.wrapped-actions .btn:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .wrapped-slide { animation: none; }
  .wrapped-dialog { transition: none; }
}

/* Virtual journey (journeys.js) */
.journey-summary {
  font-weight: 800;
  color: var(--exercise);
  font-variant-numeric: tabular-nums;
}

.journey-choices {
  list-style: none;
  margin: 0.9rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}

.journey-choice {
  width: 100%;
  display: grid;
  grid-template-columns: 2.4rem 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.journey-choice:hover {
  border-color: var(--exercise);
}

.journey-choice:focus-visible {
  outline: 3px solid var(--exercise);
  outline-offset: 2px;
}

.journey-choice-icon {
  font-size: 1.6rem;
  line-height: 1;
  text-align: center;
}

.journey-choice-text {
  min-width: 0;
  display: grid;
}

.journey-choice-text small {
  color: var(--muted);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.journey-choice-km {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.journey-name {
  margin: 0;
  font-weight: 700;
}

.journey-map {
  height: 220px;
}

.journey-track {
  height: 10px;
  margin-top: 0.9rem;
  border-radius: 999px;
  background: var(--line-soft);
  overflow: hidden;
}

.journey-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #10b981, var(--exercise));
  transition: width 0.6s ease;
}

.journey-progress {
  margin: 0.5rem 0 0.15rem;
  font-variant-numeric: tabular-nums;
}

.journey-postcards-title {
  margin: 1rem 0 0.5rem;
  font-size: 0.95rem;
}

.journey-postcards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.journey-postcard {
  display: grid;
  gap: 0.1rem;
  padding: 0.65rem 0.8rem;
  border-radius: 12px;
  background: var(--surface-2);
  border-left: 4px solid var(--exercise);
}

.journey-postcard span {
  color: var(--muted);
  font-size: 0.88rem;
}

.journey-change {
  margin-top: 0.8rem;
}

.journey-card.is-finished .journey-summary::before {
  content: "🎉 ";
}

.route-when {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.route-stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 0.9rem;
}

.route-stats div {
  padding: 8px;
}

.route-stats strong {
  font-size: 1.15rem;
}

.workout-map-btn {
  display: flex;
  width: fit-content;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.2rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.workout-map-btn .i {
  width: 16px;
  height: 16px;
}

/* "How am I doing?" (voice.js) */
.talk-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin: -0.25rem auto 1rem;
}

.talk-btn {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

/* Phones: the three buttons become a row of tiles (icon above the words) */
@media (max-width: 560px) {
  .talk-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .talk-row .talk-btn {
    flex-direction: column;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.65rem 0.4rem;
    border-radius: 16px;
    font-size: 0.82rem;
    line-height: 1.2;
    text-align: center;
    white-space: normal;
  }

  .talk-row .talk-btn svg {
    width: 22px;
    height: 22px;
  }
}

.talk-btn svg,
#talk-again svg {
  width: 18px;
  height: 18px;
}

#talk-again {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.talk-text {
  font-size: 1.1rem;
  line-height: 1.6;
  margin-bottom: 1.25rem;
}

.voice-dialog .dialog-actions {
  margin-top: 1.25rem;
}

.voice-top {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 1rem;
}

.voice-mic {
  width: 64px;
  height: 64px;
  flex: none;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #34d399, var(--primary));
  box-shadow: 0 6px 18px rgba(15, 169, 104, 0.35);
  cursor: pointer;
}

.voice-mic svg {
  width: 28px;
  height: 28px;
}

.voice-mic.is-listening {
  background: linear-gradient(145deg, #ff6b8b, #e5484d);
  box-shadow: 0 0 0 0 rgba(229, 72, 77, 0.5);
  animation: voice-pulse 1.4s ease-out infinite;
}

@keyframes voice-pulse {
  to { box-shadow: 0 0 0 18px rgba(229, 72, 77, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .voice-mic.is-listening { animation: none; }
}

.voice-mic:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

.voice-status {
  color: var(--muted);
  font-size: 0.95rem;
}

.voice-said textarea {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  resize: vertical;
}

.voice-said textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(15, 169, 104, 0.15);
}

.voice-list {
  list-style: none;
  display: grid;
  gap: 8px;
  margin-top: 0.75rem;
}

.voice-list:empty {
  display: none;
}

.voice-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: var(--surface-2);
}

.voice-row.off {
  opacity: 0.55;
}

.voice-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: var(--primary);
  flex: none;
}

.voice-main {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 6px;
}

.voice-main small {
  color: var(--muted);
}

.voice-pick {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
}

.voice-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.voice-amount {
  width: 4.5rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}

/* The drop-down list of results */
.search-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 10;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  max-height: 380px;
  overflow-y: auto;
  padding: 6px;
}

.result-group h4 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 0.5rem 0.6rem 0.25rem;
}

.result {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-align: left;
  border: 0;
  background: none;
  padding: 0.55rem 0.6rem;
  border-radius: 10px;
  cursor: pointer;
}

.result:hover,
.result:focus-visible {
  background: var(--surface-2);
  outline: none;
}

.result-text {
  flex: 1;
  min-width: 0;
  line-height: 1.35;
}

.result-text strong {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-text small {
  color: var(--muted);
  font-size: 0.8rem;
}

.result-kcal {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.online-btn {
  color: var(--primary-text);
  font-weight: 600;
  font-size: 0.9rem;
}

.online-btn svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.results-note {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0.5rem 0.6rem;
}

/* The chosen food with its amount */
.portion {
  display: grid;
  grid-template-columns: 1fr auto 2rem;
  gap: 0.75rem;
  align-items: center;
  background: var(--primary-soft);
  border-radius: 14px;
  padding: 0.7rem 0.6rem 0.7rem 0.9rem;
  margin-bottom: 1rem;
}

.portion-info {
  min-width: 0;
  line-height: 1.35;
}

.portion-info strong {
  display: block;
  overflow-wrap: anywhere;
}

.portion-info span {
  font-size: 0.8rem;
}

/* − 1 + buttons */
.stepper {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 3px;
}

.portion .stepper {
  background: var(--surface);
}

.step-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 0;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}

.portion .step-btn {
  background: var(--surface-2);
  box-shadow: none;
}

.step-btn:hover {
  color: var(--primary-text);
}

.step-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.stepper input {
  width: 3.75rem;
  text-align: center;
  border: 0;
  background: transparent;
  font-weight: 700;
  font-size: 1rem;
  -moz-appearance: textfield;
}

.stepper input::-webkit-inner-spin-button,
.stepper input::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

.stepper.small .step-btn {
  width: 28px;
  height: 28px;
}

/* While editing an entry or workout */
.card.is-editing {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.entry.editing,
.workout.editing {
  background: var(--primary-soft);
  border-radius: 10px;
}

.button-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.button-row .btn-primary {
  flex: 1;
  min-width: 0;
  white-space: normal;   /* long labels wrap instead of sticking out */
  text-align: center;
}

#calc-goals {
  margin-top: 0.75rem;
}

/* ==========================================================
   Activity tab: rings and workouts
   ========================================================== */

.rings-hero {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 28px;
  align-items: center;
  margin-bottom: 0.5rem;
}

.rings-big {
  width: 190px;
  height: 190px;
}

.rings-svg {
  display: block;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);   /* start filling from the top */
}

.rings-svg circle {
  fill: none;
  stroke-width: 12;
}

.rf {
  stroke-linecap: round;
  stroke-dasharray: 100;
  transition: stroke-dashoffset 0.6s ease;
}

/* The empty part of each ring is a faint version of its color */
.rt-move     { stroke: color-mix(in srgb, var(--ring-move) 18%, transparent); }
.rt-exercise { stroke: color-mix(in srgb, var(--ring-exercise) 20%, transparent); }
.rt-stand    { stroke: color-mix(in srgb, var(--ring-stand) 20%, transparent); }
.rf-move     { stroke: var(--ring-move); }
.rf-exercise { stroke: var(--ring-exercise); }
.rf-stand    { stroke: var(--ring-stand); }

.ring-legend {
  list-style: none;
  display: grid;
  gap: 14px;
}

.ring-legend li {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 8px;
}

.rl-name {
  grid-column: 1 / -1;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Ring colors mixed with the text color, so the words are easy to read */
.rl-move .rl-name     { color: color-mix(in srgb, var(--ring-move) 80%, var(--text)); }
.rl-exercise .rl-name { color: color-mix(in srgb, var(--ring-exercise) 65%, var(--text)); }
.rl-stand .rl-name    { color: color-mix(in srgb, var(--ring-stand) 65%, var(--text)); }

.ring-legend strong {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.ring-legend small {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0;
}

.week-rings {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.day-rings {
  width: 100%;
  border: 0;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 2px;
  border-radius: 12px;
  font-size: 0.75rem;
  color: var(--muted);
  cursor: pointer;
}

.day-rings svg {
  width: 100%;
  max-width: 46px;
  height: auto;
}

.day-rings:hover {
  background: var(--surface-2);
}

.day-rings.current {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
}

.workout-list {
  list-style: none;
}

.workout {
  display: grid;
  grid-template-columns: 44px 1fr auto 2rem 2rem;
  gap: 0.75rem;
  align-items: center;
  padding: 0.55rem 0.25rem;
  border-bottom: 1px solid var(--line-soft);
}

.workout-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--ring-exercise) 16%, transparent);
  display: grid;
  place-items: center;
  font-size: 1.35rem;
}

.workout-info {
  min-width: 0;
  line-height: 1.35;
}

.workout-info strong {
  display: block;
  overflow-wrap: anywhere;
}

.workout-info small {
  color: var(--muted);
  font-size: 0.8rem;
}

.workout-kcal {
  font-weight: 600;
  font-size: 0.95rem;
}

.workout-form {
  border-top: 1px solid var(--line);
  margin-top: 1rem;
}

.type-chips {
  margin: 0 0 1rem;
}

.type-chips span {
  padding: 0.4rem 0.8rem;
  font-size: 0.9rem;
}

.chip-icon {
  font-size: 1rem;
  line-height: 1;
}

.stat-bars {
  display: grid;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.big-num {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.big-num small {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0;
}

/* ==========================================================
   Health tab
   ========================================================== */

.health-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

.stack-form {
  margin-top: 1.25rem;
}

/* Small 7-day bar charts (sleep, heart rate) */
.mini-bars {
  position: relative;
  display: flex;
  gap: 8px;
}

.mini-bars.heart {
  margin: 1.25rem 0 1rem;
}

.mini-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.mini-val {
  font-size: 0.7rem;
  color: var(--muted);
  height: 1.1rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.mini-track {
  width: 100%;
  height: 80px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.mini-bar {
  width: 100%;
  max-width: 28px;
  min-height: 3px;
  border-radius: 6px 6px 2px 2px;
  background: var(--sleep);
  transition: height 0.5s ease;
}

.mini-bars.heart .mini-bar {
  background: var(--heart);
}

/* Blood pressure (Health tab). One color per American Heart Association category;
   --level is used by the status line and by the bars in the 7-day chart. */
.dot-bp { background: var(--bp); }
.bp-normal   { --level: var(--primary); }
.bp-elevated { --level: #e0a100; }
.bp-high1    { --level: #f97316; }
.bp-high2    { --level: #e5484d; }
.bp-crisis   { --level: #b4133a; }

.bp-status {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.45;
  background: color-mix(in srgb, var(--level) 14%, transparent);
}

.bp-status strong {
  color: color-mix(in srgb, var(--level) 70%, var(--text));
}

.mini-bars.bp {
  margin: 1.25rem 0 1rem;
}

.bp-track {
  position: relative;
}

.bp-range {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 28px;
  border-radius: 6px;
  background: var(--level);
}

.bp-form {
  display: grid;
  gap: 12px;
}

.bp-fields {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.bp-fields label {
  display: grid;
  gap: 4px;
  font-size: 0.85rem;
  font-weight: 600;
}

.bp-fields small {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 400;
}

.bp-fields input {
  width: 100%;
  min-width: 0;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1rem;      /* 16px stops phones from zooming in on tap */
}

.bp-fields input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(15, 169, 104, 0.15);
}

.mini-bar.empty {
  background: var(--track);
}

.mini-day {
  font-size: 0.75rem;
  color: var(--muted);
  height: 1.35rem;
  line-height: 1.35rem;
}

.mini-col.current .mini-day,
.mini-col.current .mini-val {
  color: var(--text);
  font-weight: 700;
}

.mini-goal {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 2px dashed var(--muted);
  opacity: 0.45;
  pointer-events: none;
}

/* Mood faces */
.moods {
  border: 0;
}

.mood-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.mood-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.6rem 0.2rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.mood-btn:hover {
  background: var(--surface-2);
  transform: translateY(-1px);
}

.mood-face {
  font-size: 1.7rem;
  line-height: 1.15;
}

.mood-btn[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-text);
}

.mood-note {
  margin-top: 1rem;
}

.mood-week {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.mood-week li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.mood-week .mood-face {
  font-size: 1.4rem;
}

.mood-week .mood-face.none {
  color: var(--line);
}

.mood-week .current span:last-child {
  color: var(--text);
  font-weight: 700;
}

/* Breathe: a circle that grows as you breathe in */
.breathe {
  position: relative;
  height: 210px;
  display: grid;
  place-items: center;
  margin-bottom: 1rem;
}

.breathe-circle {
  position: absolute;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: radial-gradient(circle,
    color-mix(in srgb, var(--ring-stand) 45%, transparent) 0%,
    color-mix(in srgb, var(--primary) 25%, transparent) 70%);
  transform: scale(0.6);
}

.breathe.running .breathe-circle {
  animation: breathe 10s ease-in-out infinite;
}

@keyframes breathe {
  0%   { transform: scale(0.6); }
  40%  { transform: scale(1); }    /* 4 seconds in */
  100% { transform: scale(0.6); }  /* 6 seconds out */
}

.breathe-text {
  position: relative;
  text-align: center;
}

.breathe-text strong {
  display: block;
  font-size: 1.3rem;
  font-weight: 800;
}

.breathe-text span {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.center-chips {
  margin: 0 0 1rem;
}

.center-chips .chip-row {
  justify-content: center;
}

.heart-form {
  margin-top: 0.5rem;
}

.weight-list + .hint {
  margin-bottom: 0;
}

#weight-stats {
  margin-bottom: 1.25rem;
}

/* ==========================================================
   Trends tab
   ========================================================== */

.trends-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 24px;
  align-items: start;
}

.span-2 {
  grid-column: 1 / -1;
}

.compare {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

@media (max-width: 760px) {
  .compare {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
}

.compare li {
  background: var(--surface-2);
  border-radius: 14px;
  padding: 12px 14px;
  display: grid;
  gap: 0.15rem;
}

.compare-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.compare strong {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.compare strong small {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0;
}

.change {
  font-size: 0.8rem;
  font-weight: 700;
}

.change.good    { color: var(--primary-text); }
.change.bad     { color: var(--warn); }
.change.neutral,
.change.none    { color: var(--muted); font-weight: 600; }

.chart-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
}

.range-switch {
  width: 200px;
  margin: 0;
  flex: none;
}

.chart-bars.dense,
.chart-days.dense {
  gap: 3px;
}

.chart-bars.dense .bar {
  border-radius: 4px 4px 2px 2px;
}

.chart-days.dense span {
  font-size: 0.7rem;
}

/* Ring calendar */
.month-nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.month-nav span {
  min-width: 8.5rem;
  text-align: center;
}

.calendar-head,
.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-head span {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  padding-bottom: 4px;
}

.cal-day {
  border: 0;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 0;
  border-radius: 10px;
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.cal-day svg {
  width: 100%;
  max-width: 38px;
  height: auto;
}

.cal-day:hover:not(:disabled) {
  background: var(--surface-2);
}

.cal-day.current {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
}

.cal-day:disabled {
  opacity: 0.35;
  cursor: default;
}

/* Personal records */
.records {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.records li {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-2);
  border-radius: 14px;
  padding: 12px 14px;
}

.records div {
  min-width: 0;
  line-height: 1.35;
}

.record-icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  flex: none;
  background: linear-gradient(135deg, #fde68a, #f59e0b);
}

.empty-record .record-icon {
  background: var(--track);
  filter: grayscale(1);
  opacity: 0.5;
}

.record-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.records strong {
  display: block;
  font-size: 1.15rem;
  font-weight: 800;
}

.records small {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================
   Awards tab: monthly challenge
   ========================================================== */

.awards-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 2rem;
}

.awards-top .awards-summary {
  margin-bottom: 0;
}

.challenge {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(135deg, color-mix(in srgb, var(--ring-move) 9%, var(--surface)), var(--surface) 70%);
}

.challenge-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 2rem;
  flex: none;
  background: color-mix(in srgb, var(--ring-move) 14%, transparent);
}

.challenge-text {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 0.35rem;
}

.challenge-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: color-mix(in srgb, var(--ring-move) 80%, var(--text));
}

.challenge strong {
  font-size: 1.05rem;
  line-height: 1.3;
}

.challenge small {
  font-size: 0.8rem;
  color: var(--muted);
}

.challenge .meter-fill {
  background: var(--ring-move);
}

.challenge.done .meter-fill {
  background: var(--primary);
}

/* ==========================================================
   Pop-up windows (Settings, barcode scanner) and messages
   ========================================================== */

.dialog {
  border: 0;
  border-radius: 20px;
  padding: 24px;
  margin: auto;
  width: min(520px, calc(100% - 32px));
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgba(15, 23, 42, 0.5);
}

.dialog h2 {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.goal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 1.25rem 0 1.5rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

/* Settings: a fixed header and footer with a scrolling middle */
.settings-dialog {
  padding: 0;
  width: min(600px, calc(100% - 32px));
  max-height: min(780px, calc(100vh - 32px));
  overflow: hidden;
}

.settings-dialog form {
  display: flex;
  flex-direction: column;
  max-height: inherit;
}

.settings-dialog .dialog-head {
  padding: 20px 24px 0;
}

.dialog-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 24px 20px;
}

.settings-dialog .dialog-actions {
  padding: 16px 24px;
  border-top: 1px solid var(--line);
}

.settings-dialog .goal-grid {
  margin: 0 0 0.5rem;
}

/* Height in feet and inches: two small boxes side by side */
.ft-in {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.field[hidden] {
  display: none;
}

.calc-result {
  margin-top: 1rem;
  background: var(--primary-soft);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 0.9rem;
  display: grid;
  gap: 0.4rem;
}

.notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--surface-2);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 0.9rem;
  margin: 1.25rem 0 0.5rem;
}

.reminder-list {
  list-style: none;
}

.reminder-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line-soft);
}

.reminder-list .check input {
  margin-top: 3px;
  flex: none;
}

.reminder-list strong {
  display: block;
  font-size: 0.95rem;
}

.reminder-list small {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

/* A real file picker hidden on top of a nice-looking button */
.file-btn {
  position: relative;
  overflow: hidden;
}

.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-btn:focus-within {
  outline: 3px solid rgba(15, 169, 104, 0.5);
  outline-offset: 2px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 50;
  width: max-content;
  max-width: calc(100% - 32px);
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--text);
  color: var(--surface);
  padding: 0.8rem 1.25rem;
  border-radius: 999px;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  box-shadow: var(--shadow);
  animation: toast-in 0.3s ease;
}

.toast-action {
  border: 0;
  background: none;
  color: #34d399;
  font-weight: 700;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  margin: -0.2rem -0.4rem -0.2rem 0;
  border-radius: 8px;
}

.toast-action:hover {
  text-decoration: underline;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 12px);
  }
}

/* --- Settings (settings.js) ---
   Like the Settings screen of most phone apps: rounded white groups of
   rows on a soft grey background, a colored icon tile on each row, and
   each row opens its own page that slides in from the right. */
.dialog.prefs {
  width: min(560px, calc(100% - 32px));
  height: min(780px, calc(100dvh - 32px));
  max-height: none;
  background: var(--grouped);
}

.prefs form {
  height: 100%;
  max-height: none;
}

.prefs-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.5rem;
  padding: 12px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.prefs-head h2 {
  grid-column: 2;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-align: center;
  white-space: nowrap;
}

.prefs-head .icon-btn {
  grid-column: 3;
  justify-self: end;
  border: 0;
  background: var(--surface-2);
}

.prefs-back {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 1px;
  max-width: 100%;
  min-width: 0;
  padding: 6px 8px 6px 2px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--primary-text);
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
}

.prefs-back svg {
  width: 22px;
  height: 22px;
  flex: none;
  stroke-width: 2.4;
}

.prefs-back span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prefs-back:hover {
  background: var(--primary-soft);
}

.prefs .prefs-body {
  padding: 4px 16px 28px;
  overscroll-behavior: contain;
}

.prefs-page.slide-forward {
  animation: prefs-forward 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.prefs-page.slide-back {
  animation: prefs-back 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes prefs-forward {
  from { opacity: 0; transform: translateX(28px); }
}

@keyframes prefs-back {
  from { opacity: 0; transform: translateX(-28px); }
}

/* The calorie goal card at the top of the list */
.prefs-hero {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  margin-top: 16px;
  padding: 16px;
  border: 0;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.prefs-hero:hover {
  background: var(--surface-2);
}

.prefs-hero-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #34d399, #0b8a55);
  box-shadow: 0 6px 14px rgba(15, 169, 104, 0.3);
}

.prefs-hero-icon svg {
  width: 26px;
  height: 26px;
}

.prefs-hero-text {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.prefs-hero-text small {
  color: var(--muted);
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prefs-hero-text strong {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.prefs-group-title {
  margin: 24px 14px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.prefs-group {
  background: var(--surface);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.prefs-page > .prefs-group:first-child,
.prefs-page > .notice:first-child,
.prefs-page > .theme-picker:first-child,
.prefs-page > .install-hero:first-child {
  margin-top: 16px;
}

.prefs-group + .prefs-group,
.prefs-note + .prefs-group {
  margin-top: 16px;
}

/* One row: [tile] text / box [chevron] */
/* Language page: a list with a tick next to the chosen language */
.lang-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.lang-check {
  width: 20px;
  height: 20px;
  margin-left: auto;
  flex: none;
  color: var(--primary);
  stroke-width: 2.6;
  visibility: hidden;
}

.lang-option input:checked ~ .lang-check {
  visibility: visible;
}

.lang-option:has(input:focus-visible) {
  outline: 3px solid var(--primary);
  outline-offset: -3px;
  border-radius: 12px;
}

.prefs-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 54px;
  padding: 10px 14px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
}

/* The thin line between rows starts where the text starts, like on a phone */
.prefs-row + .prefs-row::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 14px;
  border-top: 1px solid var(--line);
}

.prefs-row:has(> .tile)::before {
  left: 58px;
}

button.prefs-row,
.prefs-toggle,
.prefs-action {
  cursor: pointer;
  transition: background 0.12s;
}

button.prefs-row:hover,
.prefs-toggle:hover,
.prefs-action:hover {
  background: var(--surface-2);
}

.prefs-row:focus-visible,
.prefs-hero:focus-visible,
.prefs-action:focus-within {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  border-radius: 16px;
}

.prefs-row:disabled {
  cursor: default;
  opacity: 0.45;
  background: none;
}

/* Colored icon squares */
.tile {
  width: 32px;
  height: 32px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: #fff;
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.06);
}

.tile svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.tile-green  { background: linear-gradient(145deg, #34d399, #0fa968); }
.tile-red    { background: linear-gradient(145deg, #ff6b8b, #fa114f); }
.tile-violet { background: linear-gradient(145deg, #b197fc, #7c3aed); }
.tile-blue   { background: linear-gradient(145deg, #60a5fa, #2563eb); }
.tile-teal   { background: linear-gradient(145deg, #2dd4bf, #0d9488); }
.tile-orange { background: linear-gradient(145deg, #fdba4d, #f97316); }
.tile-indigo { background: linear-gradient(145deg, #8b93ff, #4f46e5); }
.tile-slate  { background: linear-gradient(145deg, #7b8aa3, #334155); }
.tile-sky    { background: linear-gradient(145deg, #56ccf2, #0284c7); }
.tile-pink   { background: linear-gradient(145deg, #f78fc4, #db2777); }

.prefs-text {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}

.prefs-text strong {
  font-size: 0.98rem;
  font-weight: 600;
}

.prefs-text small {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

/* On the list, the summary under each row stays on one line */
.prefs-page[data-page="home"] .prefs-text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prefs-chev {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--muted);
  opacity: 0.6;
}

.prefs-danger strong {
  color: var(--warn);
}

/* Rows with a box to type in: label on the left, number on the right */
.prefs-label {
  flex: 1;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.98rem;
  font-weight: 500;
}

.prefs-field input:not([type="checkbox"]),
.prefs-field select {
  width: 6.5rem;
  flex: none;
  padding: 0.5rem 0.7rem;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;      /* 16px stops phones from zooming in on tap */
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.prefs-field input::placeholder {
  color: var(--muted);
  font-weight: 500;
  opacity: 0.7;
}

.prefs-field input[type="time"] {
  width: auto;
}

.prefs-field select {
  width: auto;
  max-width: 55%;
  padding-right: 2rem;
  text-align: left;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.55rem center;
  background-size: 16px;
  cursor: pointer;
}

.prefs-field input:not([type="checkbox"]):focus,
.prefs-field select:focus {
  outline: none;
  border-color: var(--primary);
  background-color: var(--surface);
  box-shadow: 0 0 0 4px rgba(15, 169, 104, 0.15);
}

.prefs-field input:user-invalid {
  border-color: var(--warn);
}

.prefs-unit {
  flex: none;
  width: 3.4rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.prefs-row .ft-in {
  display: flex;
  align-items: center;
  gap: 6px;
}

.prefs-row .ft-in input:not([type="checkbox"]) {
  width: 3.4rem;
}

.prefs-row .ft-in .prefs-unit {
  width: auto;
}

.prefs-row[hidden] {
  display: none;
}

/* An on/off switch (a checkbox that looks like a phone toggle) */
.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 50px;
  height: 30px;
  margin: 0;
  border-radius: 999px;
  background: var(--switch-off);
  cursor: pointer;
  transition: background 0.2s;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(15, 23, 42, 0.25);
  transition: transform 0.2s cubic-bezier(0.3, 0.7, 0.4, 1.2);
}

.switch:checked {
  background: var(--primary);
}

.switch:checked::after {
  transform: translateX(20px);
}

.switch:focus-visible {
  outline: 3px solid rgba(15, 169, 104, 0.45);
  outline-offset: 2px;
}

.prefs-note {
  margin: 8px 14px 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.prefs-note-top {
  margin: 16px 4px 12px;
  font-size: 0.88rem;
}

.prefs-foot {
  margin: 32px 0 4px;
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.prefs .notice {
  margin: 16px 0;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.prefs #calc-goals {
  margin-top: 20px;
}

.prefs .calc-result {
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--primary);
}

/* Appearance: three little screen pictures to pick from */
.theme-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 18px 16px 16px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
}

.theme-option {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.theme-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-preview {
  width: 100%;
  max-width: 104px;
  aspect-ratio: 3 / 4;
  display: grid;
  align-content: start;
  gap: 7px;
  padding: 12px 10px;
  border: 2px solid var(--line);
  border-radius: 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.theme-preview i {
  display: block;
  height: 12px;
  border-radius: 6px;
}

.theme-preview i:first-child {
  width: 55%;
  background: #0fa968;
}

.theme-preview-light,
.theme-preview-auto {
  background: #f0f3f7;
}

.theme-preview-light i:not(:first-child),
.theme-preview-auto i:not(:first-child) {
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.theme-preview-dark {
  background: #0b1220;
}

.theme-preview-dark i:not(:first-child) {
  background: #1b2538;
}

/* Automatic: half light, half dark */
.theme-preview-auto {
  background: linear-gradient(135deg, #f0f3f7 50%, #0b1220 50%);
}

.theme-option input:checked + .theme-preview {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(15, 169, 104, 0.18);
}

.theme-option input:focus-visible + .theme-preview {
  outline: 3px solid rgba(15, 169, 104, 0.45);
  outline-offset: 3px;
}

.theme-option input:checked ~ span:last-child {
  color: var(--primary-text);
}

/* Install page */
.install-hero {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 28px 22px 24px;
  text-align: center;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
}

.install-hero img {
  border-radius: 16px;
  box-shadow: 0 8px 20px rgba(15, 169, 104, 0.25);
}

.install-hero strong {
  font-size: 1.1rem;
}

.install-hero p {
  color: var(--muted);
  font-size: 0.92rem;
  max-width: 34ch;
}

.prefs .prefs-actions {
  padding: 12px 16px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

/* Phones: Settings fills the screen and slides up, like a native screen */
@media (max-width: 560px) {
  .dialog.prefs {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    margin: 0;
    border-radius: 0;
  }
  .prefs[open] {
    animation: prefs-up 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  .prefs-head {
    padding-top: max(12px, env(safe-area-inset-top));
  }
  .prefs .prefs-actions {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .prefs .prefs-actions .btn {
    flex: 1;
  }
}

@keyframes prefs-up {
  from { transform: translateY(40px); opacity: 0; }
}

/* --- Barcode scanner (scanner.js) --- */
.scan-dialog {
  width: min(480px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.scanner {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 18px;
  overflow: hidden;
  background: #000;
}

.scanner video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* The frame: dark outside, four white corners, a moving green line */
.scan-frame {
  position: absolute;
  inset: 24% 9%;
  border-radius: 14px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.42);
  background:
    linear-gradient(#fff, #fff) top left / 30px 4px,
    linear-gradient(#fff, #fff) top left / 4px 30px,
    linear-gradient(#fff, #fff) top right / 30px 4px,
    linear-gradient(#fff, #fff) top right / 4px 30px,
    linear-gradient(#fff, #fff) bottom left / 30px 4px,
    linear-gradient(#fff, #fff) bottom left / 4px 30px,
    linear-gradient(#fff, #fff) bottom right / 30px 4px,
    linear-gradient(#fff, #fff) bottom right / 4px 30px;
  background-repeat: no-repeat;
}

.scan-line {
  position: absolute;
  left: 6%;
  right: 6%;
  top: 12%;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, #34d399 20%, #34d399 80%, transparent);
  box-shadow: 0 0 12px 2px rgba(52, 211, 153, 0.7);
  animation: scan-sweep 1.6s ease-in-out infinite alternate;
}

@keyframes scan-sweep {
  to { top: 86%; }
}

.scan-torch {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px 8px 10px;
  border: 0;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.scan-torch svg {
  width: 18px;
  height: 18px;
}

.scan-torch[aria-pressed="true"] {
  background: #fff;
  color: #0f172a;
}

.scan-torch[aria-pressed="true"] svg {
  fill: #facc15;
}

.scan-status {
  margin: 12px 2px 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.scan-status:empty {
  display: none;
}

/* A small spinning circle while it's busy */
.scan-status.is-busy::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  vertical-align: -2px;
  border: 2px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.scan-tools {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.scan-photo-btn svg {
  width: 20px;
  height: 20px;
}

.scan-history .form-label {
  margin: 6px 2px 8px;
}

.scan-history-list {
  list-style: none;
  display: grid;
  gap: 2px;
  padding: 4px;
  border-radius: 16px;
  background: var(--surface-2);
}

.scan-history-item {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.scan-history-item:hover {
  background: var(--surface);
}

.scan-history-text {
  display: grid;
  min-width: 0;
}

.scan-history-text strong,
.scan-history-text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scan-history-text strong {
  font-size: 0.92rem;
}

.scan-history-text small,
.scan-history-when {
  color: var(--muted);
  font-size: 0.78rem;
}

/* Product picture (or its first letter) */
.product-pic {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary-text);
  font-weight: 800;
}

.product-pic img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.scan-hint {
  font-size: 0.78rem;
  line-height: 1.5;
}

/* What was found */
.scan-product,
.scan-missing {
  animation: scan-pop 0.25s ease;
}

@keyframes scan-pop {
  from { opacity: 0; transform: translateY(8px); }
}

.scan-product-top {
  display: grid;
  grid-template-columns: 80px 1fr;
  align-items: center;
  gap: 16px;
}

.scan-product-img .product-pic {
  width: 80px;
  height: 80px;
  border-radius: 18px;
  border: 1px solid var(--line);
  font-size: 2rem;
}

.scan-product-name {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.scan-product-name strong {
  font-size: 1.12rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.scan-product-name small {
  color: var(--muted);
  font-size: 0.88rem;
}

.scan-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.scan-badges:empty {
  display: none;
}

.scan-badge {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.scan-badge-mine {
  background: var(--primary-soft);
  color: var(--primary-text);
}

/* Nutri-Score colors (A = healthiest, E = least healthy) */
.ns   { color: #fff; }
.ns-a { background: #038141; }
.ns-b { background: #85bb2f; }
.ns-c { background: #fecb02; color: #3b2f00; }
.ns-d { background: #ee8100; }
.ns-e { background: #e63e11; }

.scan-per {
  margin: 20px 2px 8px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.scan-facts {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr 1fr;
  gap: 8px;
}

.scan-fact {
  display: grid;
  gap: 2px;
  padding: 12px 6px;
  border-radius: 14px;
  background: var(--surface-2);
  text-align: center;
}

.scan-fact strong {
  font-size: 1.1rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.scan-fact span {
  color: var(--muted);
  font-size: 0.75rem;
}

.scan-fact-kcal {
  background: var(--primary-soft);
}

.scan-fact-kcal strong {
  color: var(--primary-text);
  font-size: 1.3rem;
}

.scan-serving {
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.scan-product-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);   /* minmax: long words can't push it off a phone screen */
  gap: 10px;
  margin-top: 20px;
}

/* Not found */
.scan-missing {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 8px 4px 0;
  text-align: center;
}

.scan-missing-icon {
  width: 60px;
  height: 60px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
}

.scan-missing-icon svg {
  width: 28px;
  height: 28px;
}

.scan-missing strong {
  font-size: 1.08rem;
  overflow-wrap: anywhere;
}

.scan-missing p {
  max-width: 40ch;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.scan-missing .scan-product-actions {
  width: 100%;
}

.mf-barcode {
  display: block;
  margin-top: 0.25rem;
}

.mf-barcode small {
  font-weight: 500;
}

/* Phones: the scanner fills the screen, like a camera app */
@media (max-width: 560px) {
  .dialog.scan-dialog {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    margin: 0;
    border-radius: 0;
    padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  }
  .scanner {
    aspect-ratio: 3 / 4;
    max-height: 58vh;
    width: 100%;
  }
  .scan-frame {
    inset: 32% 8%;
  }
}

/* ==========================================================
   Tracker on smaller screens
   ========================================================== */

@media (max-width: 860px) {
  .tracker,
  .activity-grid,
  .health-grid,
  .trends-grid {
    grid-template-columns: 1fr;
  }
  .span-2 {
    grid-column: auto;
  }
  .awards-top {
    grid-template-columns: 1fr;
  }
}

/* Phones: the tab bar moves to the bottom, like most fitness apps */
@media (max-width: 760px) {
  .app-body {
    padding-bottom: 76px;
  }
  .tabbar {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    border-bottom: 0;
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabs {
    padding: 0;
    gap: 0;
  }
  .tab {
    flex: 1;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.55rem 0.25rem;
    font-size: 0.72rem;
    border-bottom: 0;
    border-top: 2px solid transparent;
  }
  .tab svg {
    width: 22px;
    height: 22px;
  }
  .tab {
    font-size: 0.68rem;
  }
  .tab[aria-selected="true"] {
    border-top-color: var(--primary);
  }
  .tab-panel {
    padding: 20px 0 32px;
  }
  .toast {
    bottom: 90px;
  }
  .awards-summary {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
}

@media (max-width: 480px) {
  .app-nav .nav-inner {
    gap: 0.5rem;
  }
  .app-nav .logo-text {
    display: none;    /* make room for the day switcher on phones */
  }
  .day-nav h1 {
    min-width: 6.25rem;
    font-size: 0.9rem;
  }
  .fields {
    grid-template-columns: 1fr 7rem;
  }
  .goal-grid {
    grid-template-columns: 1fr;
  }
  .badges {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .card {
    padding: 20px;
  }
  .rings-hero {
    grid-template-columns: 130px 1fr;
    gap: 18px;
  }
  .rings-big {
    width: 130px;
    height: 130px;
  }
  .ring-legend {
    gap: 10px;
  }
  .ring-legend strong {
    font-size: 1.3rem;
  }
  .scan-btn span {
    display: none;   /* just the icon on small phones */
  }
  .scan-btn {
    padding: 0.6rem 0.8rem;
  }
  .workout {
    grid-template-columns: 38px 1fr auto 2rem 2rem;
    gap: 0.5rem;
  }
  .workout-icon {
    width: 38px;
    height: 38px;
  }
  .settings-dialog .dialog-head,
  .dialog-body,
  .settings-dialog .dialog-actions {
    padding-left: 18px;
    padding-right: 18px;
  }
  .range-switch {
    width: 100%;
  }
  .mood-btn span:last-child {
    font-size: 0.7rem;
  }
}

/* Respect people who turn off animations in their system settings */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* ==========================================================
   Unit words ("km" / "mi", "kg" / "lb") inside labels.
   Some labels style every <span> inside them as a block;
   these small ones must stay on the same line as the text.
   ========================================================== */
.field span .js-dist-unit,
.field span .js-weight-unit,
.mini-stats span .js-dist-unit {
  display: inline;
  margin: 0;
  font: inherit;
  color: inherit;
}


/* ==========================================================
   Easy mode (Settings -> Appearance; theme.js adds class="easy"
   to <html>): everything about 15% larger, bigger tap targets,
   and the detailed numbers (protein, carbs, fat, percentages)
   hidden. They're still counted, just not shown.
   ========================================================== */
html.easy {
  font-size: 115%;
}

html.easy .easy-hide,
html.easy .breakdown .pct {
  display: none;
}

html.easy .btn {
  min-height: 52px;
}

html.easy .icon-btn {
  width: 44px;
  height: 44px;
}

html.easy .icon-btn svg {
  width: 22px;
  height: 22px;
}

html.easy .prefs-row {
  min-height: 60px;
}

/* On phones the top bar is full at the bigger size: the light/dark button moves to
   Settings -> Appearance only */
@media (max-width: 560px) {
  html.easy .app-nav #theme-toggle {
    display: none;
  }
}


/* ==========================================================
   Report for the doctor (report.js): a window with the report
   as a "sheet of paper", and print styles that print only
   that sheet (a copy of it in #print-root).
   ========================================================== */
.report-nudge {
  margin-bottom: 24px;
}

/* Keeps the icon beside the text on phones (the button goes underneath) */
.report-nudge .nudge-text {
  flex-basis: 180px;
}

.dialog.report-dialog {
  padding: 0;
  width: min(760px, calc(100% - 32px));
  height: min(900px, calc(100dvh - 32px));
  max-height: none;
  overflow: hidden;
  background: var(--grouped);
}

.report-dialog[open] {
  display: flex;
  flex-direction: column;
}

.report-head {
  margin: 0;
  padding: 16px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.report-scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 20px 24px;
}

.report-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 4px 20px;
  margin-bottom: 16px;
}

.report-controls .field {
  flex: 1 1 220px;
}

.report-controls .chips {
  margin: 0;
}

.report-actions {
  padding: 14px 20px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.report-actions .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.report-actions .btn svg {
  width: 18px;
  height: 18px;
}

/* The sheet */
.report-sheet {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.rp-head {
  display: grid;
  gap: 4px;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--primary);
}

.rp-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.85rem;
}

.rp-brand .logo-mark {
  width: 22px;
  height: 22px;
  border-radius: 7px;
}

.rp-brand .logo-mark svg {
  width: 14px;
  height: 14px;
}

.rp-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 14px;
  margin-top: 6px;
}

.rp-title h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.rp-name {
  font-size: 1.15rem;
  font-weight: 600;
}

.rp-meta {
  color: var(--muted);
  font-size: 0.92rem;
}

.rp-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.rp-wide {
  grid-column: 1 / -1;
}

.rp-section {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  min-width: 0;
}

.rp-section h2 {
  font-size: 1.02rem;
  font-weight: 800;
  margin-bottom: 10px;
}

.rp-section h2 small {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
}

.rp-empty h2 {
  margin-bottom: 4px;
}

.rp-none {
  color: var(--muted);
  font-size: 0.9rem;
}

.rp-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 8px;
}

.rp-stat {
  display: grid;
  align-content: start;
  gap: 1px;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 0;
}

.rp-stat span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.rp-stat strong {
  font-size: 1.12rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.rp-stat small {
  color: var(--muted);
  font-size: 0.78rem;
}

/* The average blood pressure: a colored edge and category (--level from .bp-*) */
.rp-stat[class*="bp-"] {
  box-shadow: inset 4px 0 0 var(--level);
  padding-left: 14px;
}

.rp-stat[class*="bp-"] small {
  color: color-mix(in srgb, var(--level) 75%, var(--text));
  font-weight: 700;
}

.rp-line {
  margin-top: 10px;
  font-size: 0.88rem;
  color: var(--muted);
}

.rp-figure {
  margin: 12px 0 0;
}

.rp-chart {
  display: block;
  width: 100%;
  height: auto;
  max-height: 220px;
}

.rp-guide {
  stroke: var(--line);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.rp-axis {
  fill: var(--muted);
  font-size: 11px;
  font-family: inherit;
}

.rp-path {
  fill: none;
  stroke: var(--line-color);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.rp-line-sys    { --line-color: var(--bp); }
.rp-line-dia    { --line-color: var(--exercise); }
.rp-line-weight { --line-color: var(--primary); }

.rp-dot {
  fill: var(--line-color);
}

.rp-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--muted);
}

.rp-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.rp-legend i {
  width: 14px;
  height: 3px;
  border-radius: 2px;
  background: var(--line-color);
}

.rp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

.rp-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  padding: 0 6px 6px;
  border-bottom: 1px solid var(--line);
}

.rp-table td {
  padding: 6px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}

.rp-table td:nth-child(3) {
  font-weight: 700;
  white-space: nowrap;
}

/* A colored dot before the category */
.rp-table td:last-child::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--level, transparent);
}

.rp-lists .rp-section {
  margin-top: 14px;
}

.rp-foot {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
  display: grid;
  gap: 4px;
}

/* Phones: the report fills the screen */
@media (max-width: 560px) {
  .dialog.report-dialog {
    width: 100%;
    max-width: 100%;
    height: 100%;
    margin: 0;
    border-radius: 0;
  }
  .report-head {
    padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  }
  .report-scroll {
    padding: 12px 12px 20px;
  }
  .report-sheet {
    padding: 14px;
    border-radius: 14px;
  }
  .rp-section {
    padding: 12px;
  }
  .rp-stats {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  }
  .report-actions {
    padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  }
  .report-actions {
    flex-wrap: wrap;
  }
  .report-actions .btn {
    flex: 1 1 auto;
    padding-left: 10px;
    padding-right: 10px;
  }
  .rp-table {
    font-size: 0.8rem;
  }
  .rp-table th,
  .rp-table td {
    padding-left: 3px;
    padding-right: 3px;
  }
  .rp-table td:last-child::before {
    margin-right: 4px;
  }
  /* Axis labels stay readable when the chart is shrunk to phone width */
  .rp-axis {
    font-size: 15px;
  }
}

/* Very long words (big text in easy mode): the list scrolls sideways inside its box */
.rp-table-box {
  overflow-x: auto;
}

/* Printing: only the copy of the sheet, always light, on white paper */
.print-root {
  display: none;
}

@media print {
  @page {
    margin: 12mm;
  }
  /* Smaller than on screen (sizes are in rem), and never dark */
  html.printing-report {
    font-size: 10.5px !important;
    background: #fff !important;
    color-scheme: light !important;
  }
  html.printing-report body {
    background: #fff !important;
    margin: 0;
    padding: 0;
  }
  html.printing-report body > :not(.print-root) {
    display: none !important;
  }
  html.printing-report .print-root {
    display: block;
    color-scheme: light;
    --text: #0f172a;
    --muted: #475569;
    --line: #cbd5e1;
    --line-soft: #e2e8f0;
    --surface: #fff;
    --surface-2: #f1f5f9;
    --primary: #0fa968;
    --bp: #d6336c;
    --exercise: #6366f1;
    color: var(--text);
    font-size: 1rem;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .print-root .report-sheet {
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    background: #fff;
  }
  .print-root .bp-normal   { --level: #0fa968; }
  .print-root .rp-sections {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .print-root .rp-section {
    border-radius: 8px;
    padding: 8px 10px;
    break-inside: avoid;
  }
  .print-root .rp-table-box {
    break-inside: auto;
    break-before: page;
    margin-top: 0;
  }
  .print-root .rp-table tr {
    break-inside: avoid;
  }
  .print-root .rp-stats {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 5px;
  }
  .print-root .rp-stat {
    padding: 5px 7px;
    border-radius: 6px;
  }
  .print-root .rp-stat[class*="bp-"] {
    padding-left: 11px;
  }
  /* Wide sections: the numbers on the left, the chart on the right */
  .print-root .rp-wide:has(.rp-figure) {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 14px;
    align-items: start;
  }
  .print-root .rp-wide:has(.rp-figure) > :not(.rp-stats, .rp-figure) {
    grid-column: 1 / -1;
  }
  .print-root .rp-figure {
    margin: 0;
  }
  .print-root .rp-chart {
    max-height: none;
  }
  .print-root .rp-foot {
    break-inside: avoid;
  }
  .print-root .rp-head {
    padding-bottom: 8px;
    margin-bottom: 10px;
  }
  .print-root .rp-title h1 {
    font-size: 18pt;
  }
}


/* ==========================================================
   Read the label (label.js): a button in the New food form that
   reads the numbers from a photo, with a status line underneath
   and a choice of column (per 100 g / per serving).
   ========================================================== */
.label-read {
  display: grid;
  gap: 8px;
  margin: 1rem 0 0.25rem;
  padding: 14px;
  border-radius: 16px;
  background: var(--primary-soft);
}

.label-btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}

.label-btn svg {
  width: 20px;
  height: 20px;
}

.label-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.label-btn:focus-within {
  outline: 3px solid rgba(15, 169, 104, 0.5);
  outline-offset: 2px;
}

/* While reading: the button waits and gently pulses */
.label-btn.is-busy {
  pointer-events: none;
  animation: label-pulse 1.2s ease-in-out infinite;
}

@keyframes label-pulse {
  50% { opacity: 0.55; }
}

.label-status {
  margin: 0;
}

.label-status.good { color: var(--primary-text); font-weight: 600; }
.label-status.warn { color: color-mix(in srgb, #e0a100 70%, var(--text)); font-weight: 600; }
.label-status.bad  { color: var(--warn); font-weight: 600; }

.label-columns {
  margin: 0;
}

.scan-read-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 14px auto 0;
}

.scan-read-label svg {
  width: 18px;
  height: 18px;
}

/* Scanner cards on narrow phones with long words (Polish, easy mode): stay inside the
   screen, button text may take two lines */
.scan-missing {
  grid-template-columns: minmax(0, 1fr);
}

.scan-product-actions .btn {
  white-space: normal;
  line-height: 1.2;
}


/* ==========================================================
   Meal photo (meal-photo.js): the Photo button next to Scan and
   Speak, and the window with the photo and the list to check.
   The list reuses the voice list styles (.voice-row…).
   ========================================================== */
.photo-btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.photo-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.photo-btn:focus-within {
  outline: 3px solid rgba(15, 169, 104, 0.5);
  outline-offset: 2px;
}

@media (max-width: 560px) {
  .photo-btn span {
    display: none;    /* just the camera on phones, like the microphone */
  }
}

.meal-top {
  display: grid;
  gap: 10px;
}

#meal-preview {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: 14px;
  background: var(--surface-2);
}

.meal-status.busy {
  animation: label-pulse 1.2s ease-in-out infinite;
}

.meal-status.good { color: var(--primary-text); }
.meal-status.bad  { color: var(--warn); }

.meal-note {
  margin: 0.5rem 0 0;
  font-style: italic;
}

.meal-name {
  font-weight: 600;
}

.meal-privacy {
  margin-top: 0.75rem;
  font-size: 0.8rem;
}

.meal-again {
  margin-right: auto;
}

/* Phones: the search box gets its own line, and Scan / Speak / Photo share the line
   below with their words showing (bigger targets, and the search box isn't squeezed) */
@media (max-width: 480px) {
  .search-row {
    flex-wrap: wrap;
  }
  .search-row .search-box {
    flex: 1 1 100%;
  }
  .search-row .scan-btn {
    flex: 1 1 0;
    justify-content: center;
    min-width: 0;
  }
  .search-row .scan-btn span {
    display: inline;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .search-row .scan-btn svg {
    flex: none;
  }
}

/* =========================================================
   Plant buddy (buddy.js): card at the top of Today + outfits window
   ========================================================= */
.buddy-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  background: linear-gradient(135deg, var(--primary-soft), var(--surface) 70%);
}
.buddy-tap {
  flex: none;
  width: 112px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 16px;
  -webkit-tap-highlight-color: transparent;
}
.buddy-tap:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.buddy-svg, .buddy-preview { display: block; width: 100%; height: auto; overflow: visible; }
.buddy-shadow { fill: rgba(15, 23, 42, 0.12); }
:root[data-theme="dark"] .buddy-shadow { fill: rgba(0, 0, 0, 0.35); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .buddy-shadow { fill: rgba(0, 0, 0, 0.35); } }

.buddy-info { flex: 1; min-width: 0; }
.buddy-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.buddy-top h2 { margin: 0; font-size: 1.15rem; overflow-wrap: anywhere; }
.buddy-level {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary-text);
  background: var(--primary-soft);
  padding: 2px 8px;
  border-radius: 999px;
}
.buddy-edit { margin-left: auto; }
.buddy-says { margin: 6px 0 10px; font-size: 0.92rem; line-height: 1.35; }
.buddy-xp { height: 6px; border-radius: 999px; background: var(--track); overflow: hidden; }
.buddy-xp span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #34d399, #0fa968);
  transition: width 0.6s ease;
}
.buddy-xp-text { margin: 4px 0 8px; font-size: 0.75rem; color: var(--muted); }
.buddy-goals {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 10px;
  font-size: 0.82rem;
  color: var(--muted);
}
.buddy-goal { display: flex; align-items: center; gap: 6px; min-width: 0; }
.buddy-check {
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--line);
}
.buddy-goal.done { color: var(--text); font-weight: 600; }
.buddy-goal.done .buddy-check {
  border-color: var(--primary);
  background: var(--primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat;
}

/* Animations: gentle sway, blinking, a hop when tapped or blooming, twinkles, floating z's */
.buddy-plant { transform-box: view-box; transform-origin: 60px 72px; animation: buddy-sway 4s ease-in-out infinite; }
.buddy-card[data-mood="droop"] .buddy-plant,
.buddy-card[data-mood="asleep"] .buddy-plant { animation-duration: 7s; }
.buddy-eyes { transform-box: fill-box; transform-origin: center; animation: buddy-blink 5s infinite; }
.buddy-card[data-mood="bloom"] .buddy-svg { animation: buddy-bounce 2.4s ease-in-out infinite; }
.buddy-card.buddy-hop .buddy-svg { animation: buddy-jump 0.65s ease; }
.buddy-flower { animation: buddy-pop 0.6s ease both; transform-box: fill-box; transform-origin: center; }
.buddy-spark { transform-box: fill-box; transform-origin: center; animation: buddy-twinkle 1.6s ease-in-out infinite; }
.buddy-zzz { animation: buddy-float 2.6s ease-in-out infinite; }

@keyframes buddy-sway { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
@keyframes buddy-blink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(0.1); } }
@keyframes buddy-bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes buddy-jump {
  0% { transform: translateY(0) scale(1, 1); }
  25% { transform: translateY(2px) scale(1.06, 0.92); }
  55% { transform: translateY(-12px) scale(0.96, 1.05); }
  100% { transform: translateY(0) scale(1, 1); }
}
@keyframes buddy-pop { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes buddy-twinkle { 0%, 100% { opacity: 0.2; transform: scale(0.6); } 50% { opacity: 1; transform: scale(1.1); } }
@keyframes buddy-float { 0% { opacity: 0; transform: translateY(4px); } 40% { opacity: 1; } 100% { opacity: 0; transform: translateY(-8px); } }

@media (prefers-reduced-motion: reduce) {
  .buddy-plant, .buddy-eyes, .buddy-card .buddy-svg, .buddy-flower, .buddy-spark, .buddy-zzz { animation: none !important; }
}

/* Outfits window */
.buddy-preview { width: 150px; margin: 4px auto 12px; }
.buddy-section { margin: 16px 0 8px; font-size: 0.95rem; }
.buddy-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.buddy-choice {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  text-align: left;
  cursor: pointer;
}
.buddy-choice.selected { border-color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.buddy-choice:disabled { cursor: default; color: var(--muted); background: var(--surface-2); }
.buddy-choice-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.buddy-choice-name { overflow-wrap: break-word; }
.buddy-lock { font-size: 0.72rem; white-space: nowrap; }
.buddy-swatch { flex: none; width: 18px; height: 18px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }
.buddy-note { margin: 14px 0 0; font-size: 0.82rem; color: var(--muted); }

@media (max-width: 420px) {
  .buddy-card { gap: 12px; padding: 16px; }
  .buddy-tap { width: 100px; }
}

/* =========================================================
   All my walks (walks-map.js): night map with glowing lines
   ========================================================= */
.walks-open {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 12px;
}
.walks-open svg { flex: none; width: 18px; height: 18px; }
.walks-range { margin-top: 4px; }
.walks-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
/* Always a dark map here (in light mode too), so the glow stands out */
.walks-night { background: #0b1220; }
.walks-night .route-tiles,
[data-theme="dark"] .walks-night .route-tiles {
  filter: invert(1) hue-rotate(180deg) brightness(0.62) contrast(1.05) saturate(0.5);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .walks-night .route-tiles {
    filter: invert(1) hue-rotate(180deg) brightness(0.62) contrast(1.05) saturate(0.5);
  }
}
.walks-night.leaflet-container .leaflet-control-attribution { background: rgba(11, 18, 32, 0.75); color: #cbd5e1; }
.walks-night.leaflet-container .leaflet-control-attribution a { color: #93c5fd; }

/* =========================================================
   Ghost race (ghost.js)
   ========================================================= */
.ghost-box { margin-top: 12px; }
.ghost-pick { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; }
.ghost-chosen {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 12px;
  border-radius: 14px;
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.3);
  font-size: 0.88rem;
}
.ghost-chosen-icon { font-size: 1.3rem; }
.ghost-chosen-text { flex: 1; min-width: 0; }
.ghost-remove { flex: none; }
.ghost-status {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  font-weight: 700;
  text-align: center;
  transition: background 0.3s, color 0.3s;
}
.ghost-box.is-ahead .ghost-status { background: var(--primary-soft); color: var(--primary-text); }
.ghost-box.is-behind .ghost-status { background: rgba(139, 92, 246, 0.14); color: #7c3aed; }
:root[data-theme="dark"] .ghost-box.is-behind .ghost-status { color: #c4b5fd; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ghost-box.is-behind .ghost-status { color: #c4b5fd; } }

.ghost-marker { background: none; border: 0; }
.ghost-marker span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  font-size: 22px;
  line-height: 1;
  opacity: 0.85;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
  animation: ghost-float 1.8s ease-in-out infinite;
}
@keyframes ghost-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) { .ghost-marker span { animation: none; } }

.ghost-list { display: grid; gap: 8px; margin-top: 12px; }
.ghost-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.ghost-row:hover { border-color: #a78bfa; }
.ghost-row-icon { font-size: 1.4rem; }
.ghost-row-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.ghost-row-text span { color: var(--muted); font-size: 0.85rem; }
.ghost-fastest {
  flex: none;
  font-size: 0.72rem;
  font-weight: 700;
  color: #b45309;
  background: #fef3c7;
  padding: 3px 8px;
  border-radius: 999px;
}
:root[data-theme="dark"] .ghost-fastest { color: #fcd34d; background: rgba(245, 158, 11, 0.16); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ghost-fastest { color: #fcd34d; background: rgba(245, 158, 11, 0.16); } }

/* =========================================================
   Cooking mode (cook.js): one big step at a time
   ========================================================= */
.cook-dialog {
  width: min(680px, calc(100% - 32px));
  height: min(760px, calc(100dvh - 48px));
  max-height: none;
  padding: 20px 24px;
}
.cook-dialog[open] { display: flex; flex-direction: column; gap: 12px; }
.cook-head { display: flex; align-items: flex-start; gap: 12px; }
.cook-head-text { flex: 1; min-width: 0; }
.cook-count {
  margin: 0 0 2px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary-text);
}
.cook-head h2 { margin: 0; font-size: 1.15rem; overflow-wrap: anywhere; }
.cook-dots { display: flex; gap: 6px; }
.cook-dots span { flex: 1; height: 5px; border-radius: 999px; background: var(--track); transition: background 0.3s; }
.cook-dots span.done { background: #86efac; }
.cook-dots span.on { background: var(--primary); }
:root[data-theme="dark"] .cook-dots span.done { background: rgba(52, 211, 153, 0.45); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cook-dots span.done { background: rgba(52, 211, 153, 0.45); } }

.cook-timers { display: flex; flex-wrap: wrap; gap: 8px; }
.cook-timer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 4px 12px;
  border-radius: 999px;
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
}
.cook-timer-time { font-size: 1.1rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.cook-timer-label { font-size: 0.8rem; opacity: 0.8; }
.cook-timer .icon-btn { width: 32px; height: 32px; }
.cook-timer.is-done { background: #ef4444; border-color: #ef4444; color: #fff; animation: cook-pulse 0.9s ease-in-out infinite; }
.cook-timer.is-done .icon-btn { color: #fff; }
:root[data-theme="dark"] .cook-timer:not(.is-done) { background: rgba(249, 115, 22, 0.14); border-color: rgba(249, 115, 22, 0.35); color: #fdba74; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cook-timer:not(.is-done) { background: rgba(249, 115, 22, 0.14); border-color: rgba(249, 115, 22, 0.35); color: #fdba74; }
}
@keyframes cook-pulse { 50% { transform: scale(1.05); } }

.cook-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
  padding: 8px 2px;
}
.cook-body.is-list { justify-content: flex-start; }
.cook-step-text { margin: 0; font-size: clamp(1.45rem, 4.8vw, 2rem); line-height: 1.4; font-weight: 600; }
.cook-timer-buttons { display: flex; flex-wrap: wrap; gap: 10px; }
.cook-timer-start { display: inline-flex; align-items: center; gap: 8px; font-size: 1.05rem; }
.cook-ingredients { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.cook-ingredients label {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 1.2rem;
  cursor: pointer;
}
.cook-ingredients input { flex: none; width: 24px; height: 24px; accent-color: var(--primary); }
.cook-ingredients input:checked + span { color: var(--muted); text-decoration: line-through; }

.cook-tools { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.cook-tool { display: inline-flex; align-items: center; gap: 6px; }
.cook-tool svg { flex: none; width: 18px; height: 18px; }
.cook-tool.is-off { opacity: 0.55; text-decoration: line-through; }
.cook-tool.is-listening { border-color: #ef4444; color: #ef4444; }
.cook-tool.is-listening svg { animation: cook-pulse 1.2s ease-in-out infinite; }
.cook-nav { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; }
.cook-nav-btn { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 60px; font-size: 1.15rem; }
.cook-nav-btn svg { flex: none; width: 22px; height: 22px; }
.recipe-cook { display: inline-flex; align-items: center; gap: 6px; }

@media (prefers-reduced-motion: reduce) {
  .cook-timer.is-done, .cook-tool.is-listening svg { animation: none; }
}
@media (max-width: 560px) {
  .cook-dialog {
    width: 100%;
    height: 100dvh;
    max-width: none;
    margin: 0;
    border-radius: 0;
    padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  }
}

/* =========================================================
   Meal photo diary (photo-diary.js)
   ========================================================= */
.meal-keep { margin: 12px 0 0; font-size: 0.9rem; }
.log-head { flex-wrap: wrap; row-gap: 6px; column-gap: 12px; }
.log-head .head-links { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.diary-dialog { width: min(640px, calc(100% - 32px)); }
.diary-dialog .dialog-head { gap: 8px; }
.diary-dialog .dialog-head h2 { flex: 1; }
.diary-body { max-height: min(62vh, 620px); overflow-y: auto; margin-top: 12px; padding-right: 4px; scrollbar-gutter: stable; }
.diary-month { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.diary-month h3 { margin: 0; font-size: 1.05rem; text-transform: capitalize; }
.diary-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.diary-weekday { text-align: center; font-size: 0.75rem; font-weight: 700; color: var(--muted); padding: 4px 0; text-transform: uppercase; }
.diary-day, .diary-blank { position: relative; aspect-ratio: 1; border-radius: 10px; }
.diary-day {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 4px 6px;
  border: 0;
  background: var(--surface-2) center / cover no-repeat;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
}
.diary-day.is-today { box-shadow: inset 0 0 0 2px var(--primary); color: var(--primary-text); font-weight: 700; }
.diary-day.has-photo { cursor: pointer; color: #fff; }
.diary-day.has-photo .diary-num { text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8); font-weight: 700; }
.diary-count {
  position: absolute;
  right: 4px;
  bottom: 4px;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.diary-empty { margin-top: 16px; text-align: center; }
.diary-all-month { margin: 16px 0 8px; font-size: 1rem; text-transform: capitalize; }
.diary-all-month:first-child { margin-top: 0; }
.diary-all-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.diary-tile {
  position: relative;
  aspect-ratio: 1;
  border: 0;
  border-radius: 12px;
  background: var(--surface-2) center / cover no-repeat;
  cursor: pointer;
}
.diary-tile-meal {
  position: absolute;
  left: 6px;
  bottom: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px #fff;
}
.diary-tile-meal.dot-breakfast { background: var(--breakfast); }
.diary-tile-meal.dot-lunch { background: var(--lunch); }
.diary-tile-meal.dot-dinner { background: var(--dinner); }
.diary-tile-meal.dot-snack { background: var(--snack); }
.diary-day-title { margin: 0 0 12px; font-size: 1.05rem; text-transform: capitalize; }
.diary-photo { margin: 0 0 18px; }
.diary-photo img { display: block; width: 100%; max-height: 420px; object-fit: cover; border-radius: 14px; background: var(--surface-2); }
.diary-photo figcaption { padding: 8px 2px 0; }
.diary-photo-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.diary-meal { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.diary-time { color: var(--muted); font-weight: 500; }
.diary-delete { color: var(--warn); }
.diary-foods { margin: 4px 0 0; font-size: 0.92rem; }
.diary-kcal { margin: 2px 0 0; font-size: 0.85rem; color: var(--muted); }
.diary-summary { margin: 10px 0 0; font-size: 0.8rem; }
@media (max-width: 560px) {
  .diary-dialog { width: 100%; max-width: none; height: 100dvh; max-height: none; margin: 0; border-radius: 0; }
  .diary-dialog[open] { display: flex; flex-direction: column; }
  .diary-body { flex: 1; max-height: none; }
}

/* =========================================================
   Healthier swap on the scanner's product card (swap.js)
   ========================================================= */
.swap-box { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.swap-find { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; }
.swap-status { margin: 8px 0 0; font-size: 0.9rem; color: var(--muted); }
.swap-status:empty { display: none; }
.swap-status.good { color: var(--text); font-weight: 600; }
.swap-status.bad { color: var(--warn); }
.swap-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.swap-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.swap-row:hover { border-color: var(--primary); }
.swap-img {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: #fff;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.swap-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.swap-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.swap-text strong { font-size: 0.92rem; overflow-wrap: anywhere; }
.swap-text small { color: var(--muted); font-size: 0.8rem; }
.swap-compare { font-size: 0.8rem; color: var(--primary-text); font-weight: 600; }
.swap-worse { color: var(--muted); font-weight: 500; }
.swap-row .scan-badge { flex: none; }
.swap-coach { display: block; margin: 10px auto 0; }

/* =========================================================
   Streak flame + fireworks (celebrate.js)
   ========================================================= */
.log-flame {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 24px;
  padding: 0 9px 0 6px;
  border: 0;
  border-radius: 999px;
  background: rgba(249, 115, 22, 0.14);
  color: #c2410c;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
}
:root[data-theme="dark"] .log-flame { color: #fdba74; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .log-flame { color: #fdba74; } }
.log-flame-fire { display: inline-block; font-size: 0.95rem; line-height: 1; transform-origin: 50% 90%; animation: log-flame-flicker 1.4s ease-in-out infinite; }
.log-flame[data-size="big"] .log-flame-fire,
.log-flame[data-size="blue"] .log-flame-fire { --flame: 1.2; margin-right: 2px; }
.log-flame[data-size="blue"] { background: rgba(59, 130, 246, 0.15); color: #1d4ed8; }
.log-flame[data-size="blue"] .log-flame-fire { filter: hue-rotate(190deg) saturate(1.4) brightness(1.1); }
:root[data-theme="dark"] .log-flame[data-size="blue"] { color: #93c5fd; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .log-flame[data-size="blue"] { color: #93c5fd; } }
.log-flame.is-waiting { background: var(--surface-2); color: var(--muted); }
.log-flame.is-waiting .log-flame-fire { filter: grayscale(1); opacity: 0.6; animation: none; }
@keyframes log-flame-flicker {
  0%, 100% { transform: scale(var(--flame, 1)) rotate(-2deg); }
  30% { transform: scale(calc(var(--flame, 1) * 1.08), calc(var(--flame, 1) * 0.94)) rotate(2deg); }
  60% { transform: scale(calc(var(--flame, 1) * 0.95), calc(var(--flame, 1) * 1.07)) rotate(-1deg); }
}
.fireworks { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 9990; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .log-flame-fire { animation: none; transform: scale(var(--flame, 1)); } }
