/* ================================================================
   THRIVE — Design System
   Palette: Vibrant green & lime (wellness/health) + warm off-white
   Font: General Sans (body) + Cabinet Grotesk (headings)
   ================================================================ */

/* --- Font Loading --- */
@import url('https://api.fontshare.com/v2/css?f[]=general-sans@300,400,500,600,700&f[]=cabinet-grotesk@400,500,700,800&display=swap');

/* --- Design Tokens --- */
:root,
[data-theme='light'] {
  /* Surfaces — soft warm cream */
  --color-bg: #f5f7f5;
  --color-surface: #ffffff;
  --color-surface-2: #f0f4f1;
  --color-surface-offset: #e8ede9;
  --color-divider: #d8dfd9;
  --color-border: #ccd4cc;

  /* Text */
  --color-text: #1a2b1c;
  --color-text-muted: #5a6e5c;
  --color-text-faint: #9aaa9b;
  --color-text-inverse: #f5f7f5;

  /* Primary — deep green */
  --color-primary: #2d7a2f;
  --color-primary-hover: #165e46;
  --color-primary-active: #0e4330;
  --color-primary-light: #e0f0ea;

  /* Protein — warm coral/amber */
  --color-protein: #d4542a;
  --color-protein-light: #fceae3;

  /* Fruit/Veg — vivid green */
  --color-fruitveg: #4a9e47;
  --color-fruitveg-light: #e5f5e4;

  /* Grains — golden amber */
  --color-grains: #c48b1a;
  --color-grains-light: #fdf3dc;

  /* UI states */
  --color-success: #2e7d32;
  --color-success-light: #e8f5e9;
  --color-warning: #c47c1a;
  --color-warning-light: #fef3e0;
  --color-error: #c0392b;
  --color-error-light: #fdecea;
  --color-info: #1565c0;
  --color-info-light: #e3f2fd;

  /* Water */
  --color-water: #1976d2;
  --color-water-light: #e3f2fd;

  /* Typography */
  --font-display: 'Cabinet Grotesk', 'Helvetica Neue', sans-serif;
  --font-body: 'General Sans', 'Inter', sans-serif;

  /* Type Scale */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);

  /* Spacing (4px base) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.625rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(30, 50, 30, 0.08);
  --shadow-md: 0 4px 16px rgba(30, 50, 30, 0.10);
  --shadow-lg: 0 12px 40px rgba(30, 50, 30, 0.14);

  /* Transitions */
  --transition: 180ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 320ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Nav height */
  --nav-height: 64px;
}

[data-theme='dark'] {
  --color-bg: #111a12;
  --color-surface: #182019;
  --color-surface-2: #1d261e;
  --color-surface-offset: #1a221b;
  --color-divider: #253027;
  --color-border: #2f3d31;
  --color-text: #d2e0d3;
  --color-text-muted: #7a9a7c;
  --color-text-faint: #4a6a4c;
  --color-text-inverse: #111a12;

  --color-primary: #4db845;
  --color-primary-hover: #3da035;
  --color-primary-active: #2d8a20;
  --color-primary-light: #1a3328;

  --color-protein: #e87a55;
  --color-protein-light: #3d1f14;

  --color-fruitveg: #6cc068;
  --color-fruitveg-light: #1b2e1a;

  --color-grains: #e0a830;
  --color-grains-light: #2e2210;

  --color-success: #4caf50;
  --color-success-light: #1b3120;
  --color-warning: #ffa726;
  --color-warning-light: #2e2010;
  --color-error: #ef5350;
  --color-error-light: #2e1010;
  --color-info: #42a5f5;
  --color-info-light: #0d2244;

  --color-water: #42a5f5;
  --color-water-light: #0d2040;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg: #111a12;
    --color-surface: #182019;
    --color-surface-2: #1d261e;
    --color-surface-offset: #1a221b;
    --color-divider: #253027;
    --color-border: #2f3d31;
    --color-text: #d2e0d3;
    --color-text-muted: #7a9a7c;
    --color-text-faint: #4a6a4c;
    --color-text-inverse: #111a12;
    --color-primary: #4db845;
    --color-primary-hover: #3da035;
    --color-primary-active: #2d8a20;
    --color-primary-light: #1a3328;
    --color-protein: #e87a55;
    --color-protein-light: #3d1f14;
    --color-fruitveg: #6cc068;
    --color-fruitveg-light: #1b2e1a;
    --color-grains: #e0a830;
    --color-grains-light: #2e2210;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
  }
}

/* ================================================================
   BASE RESET
   ================================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}
body {
  min-height: 100dvh;
  line-height: 1.6;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  transition: background-color var(--transition-slow), color var(--transition-slow);
}
img, picture, video, canvas, svg { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  text-wrap: balance;
  line-height: 1.2;
}
button { cursor: pointer; background: none; border: none; }
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ================================================================
   LAYOUT
   ================================================================ */
.app-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

/* ================================================================
   HEADER
   ================================================================ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(135deg, #2d7a2f 0%, #4ea832 60%, #6abf3a 100%);
  border-bottom: none;
  box-shadow: var(--shadow-md);
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  gap: var(--space-3);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.header-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: rgba(255,255,255,0.95);
}
.logo-mark {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}
.logo-text {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
}
.logo-text span {
  display: block;
  font-weight: 400;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.header-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  transition: background var(--transition), color var(--transition);
  font-size: var(--text-sm);
  font-weight: 600;
}
.icon-btn:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}
.lang-btn {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 10px;
  height: 32px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.lang-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-light);
}

/* ================================================================
   GLOBAL CONTROL BAR — language + region always visible
   ================================================================ */
.global-control-bar {
  position: sticky;
  top: var(--nav-height, 60px);
  z-index: 90;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px var(--space-3);
  padding: 7px var(--space-3);
  scrollbar-width: none;
}
.global-control-bar::-webkit-scrollbar { display: none; }
.gcb-section {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  flex-shrink: 0;
}
.gcb-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.gcb-btns {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  justify-content: center;
}
.gcb-btn {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--color-border);
  background: var(--color-surface-2);
  color: #111;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  line-height: 1;
}
.gcb-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 8%, transparent);
}
.gcb-btn.active {
  border-color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 14%, transparent);
  color: var(--color-primary);
  font-weight: 800;
}
.gcb-divider {
  width: 1px;
  height: 22px;
  background: var(--color-border);
  flex-shrink: 0;
}

/* ================================================================
   BOTTOM NAV
   ================================================================ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-around;
  padding: var(--space-2) 0;
  padding-bottom: calc(var(--space-2) + env(safe-area-inset-bottom, 0));
  z-index: 90;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  transition: color var(--transition), background var(--transition);
  cursor: pointer;
  min-width: 56px;
}
.nav-item svg {
  width: 22px;
  height: 22px;
  transition: transform var(--transition);
}
.nav-item span {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.nav-item.active {
  color: var(--color-primary);
}
.nav-item.active svg {
  transform: translateY(-1px);
}
.nav-item:hover {
  color: var(--color-primary);
  background: var(--color-primary-light);
}

/* ================================================================
   MAIN CONTENT
   ================================================================ */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  padding-bottom: calc(80px + env(safe-area-inset-bottom, 0) + var(--space-4));
}

/* ================================================================
   VIEWS (TAB PANELS)
   ================================================================ */
.view {
  display: none;
  animation: viewIn 280ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
.view.active { display: block; }

@keyframes viewIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ================================================================
   DASHBOARD — Summary KPI Cards
   ================================================================ */
.date-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}
.date-nav {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.date-label {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
  min-width: 140px;
  text-align: center;
}
.date-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  transition: all var(--transition);
}
.date-btn:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
/* When calories are on, revert to 2×2 layout */
.kpi-grid.calories-on {
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}
.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  transition: box-shadow var(--transition), transform var(--transition);
  animation: cardIn 360ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
/* Restore full padding in 2×2 mode */
.kpi-grid.calories-on .kpi-card {
  padding: var(--space-4);
  gap: var(--space-2);
}
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.kpi-card:nth-child(1) { animation-delay: 0ms; }
.kpi-card:nth-child(2) { animation-delay: 60ms; }
.kpi-card:nth-child(3) { animation-delay: 120ms; }
.kpi-card:nth-child(4) { animation-delay: 180ms; }

.kpi-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Restore full icon in 2×2 mode */
.kpi-grid.calories-on .kpi-icon {
  width: 36px;
  height: 36px;
}
.kpi-icon.protein { background: var(--color-protein-light); color: var(--color-protein); }
.kpi-icon.water { background: var(--color-water-light); color: var(--color-water); }
.kpi-icon.meals { background: var(--color-primary-light); color: var(--color-primary); }
.kpi-icon.calories { background: var(--color-grains-light); color: var(--color-grains); }

.kpi-value {
  font-family: var(--font-display);
  font-size: var(--text-md, 1rem);
  font-weight: 800;
  color: var(--color-text);
  line-height: 1;
}
/* Restore larger value in 2×2 mode */
.kpi-grid.calories-on .kpi-value {
  font-size: var(--text-lg);
}
.kpi-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 500;
}
.kpi-progress {
  height: 4px;
  background: var(--color-surface-offset);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: var(--space-1);
}
.kpi-progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 600ms cubic-bezier(0.16, 1, 0.3, 1);
}
.kpi-progress-bar.protein { background: var(--color-protein); }
.kpi-progress-bar.water { background: var(--color-water); }
.kpi-progress-bar.meals { background: var(--color-primary); }
.kpi-progress-bar.calories { background: var(--color-grains); }

/* ================================================================
   PLATE DONUT
   ================================================================ */
.plate-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-sm);
}
.plate-section-title {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.plate-visual {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}
.plate-donut {
  flex-shrink: 0;
  position: relative;
  width: 100px;
  height: 100px;
}
.plate-donut svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.plate-donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
}
.plate-legend {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}
.legend-label {
  flex: 1;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.legend-pct {
  font-size: var(--text-xs);
  font-weight: 700;
  font-family: var(--font-display);
}

/* ================================================================
   MEAL CARDS (Journal)
   ================================================================ */
.section-title {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.meal-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.meal-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  animation: cardIn 360ms cubic-bezier(0.16, 1, 0.3, 1) both;
  transition: box-shadow var(--transition), transform var(--transition);
}
.meal-card:hover { box-shadow: var(--shadow-md); }
.meal-card.new-entry {
  animation: newCard 500ms cubic-bezier(0.16, 1, 0.3, 1) both;
  border-color: var(--color-primary);
}
@keyframes newCard {
  0% { opacity: 0; transform: scale(0.92) translateY(-10px); }
  60% { transform: scale(1.02) translateY(2px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
.meal-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.meal-name {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
  flex: 1;
}
.meal-type-badge {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--color-primary-light);
  color: var(--color-primary);
  white-space: nowrap;
}
.meal-macros {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.macro-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.macro-chip strong {
  color: var(--color-text);
  font-weight: 600;
}
.macro-dot { width: 6px; height: 6px; border-radius: 50%; }
.cnf-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--color-primary);
  background: var(--color-primary-light);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  margin-top: var(--space-1);
  letter-spacing: 0.04em;
}
.meal-actions {
  display: flex;
  gap: var(--space-1);
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-divider);
}
.meal-action-btn {
  padding: 4px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 4px;
}
.meal-action-btn:hover { background: var(--color-surface-2); color: var(--color-text); }
.meal-action-btn.delete:hover { background: var(--color-error-light); color: var(--color-error); }

/* ── Meal card photo ── */
.meal-card-photo-wrap {
  margin-top: var(--space-2);
  border-radius: var(--radius-md);
  overflow: hidden;
  max-height: 200px;
}
.meal-card-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: var(--radius-md);
  animation: fadeIn 0.3s ease;
}

/* ── Photo capture UI ── */
.photo-btn-row {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.photo-btn {
  flex: 1;
  min-width: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
}
.photo-preview-wrap {
  position: relative;
  margin-bottom: var(--space-2);
  border-radius: var(--radius-md);
  overflow: hidden;
  max-height: 220px;
  background: var(--color-surface-2);
}
.photo-preview-img {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  display: block;
  border-radius: var(--radius-md);
  animation: fadeIn 0.3s ease;
}
.photo-remove-btn {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  transition: background var(--transition);
}
.photo-remove-btn:hover { background: rgba(0,0,0,0.8); }

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-4);
  text-align: center;
  gap: var(--space-3);
}
.empty-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-xl);
  background: var(--color-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
}
.empty-title {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
}
.empty-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  max-width: 240px;
}

/* ================================================================
   WATER TRACKER
   ================================================================ */
.water-tracker {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-sm);
}
.water-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}
.water-title {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.water-display {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--color-water);
  line-height: 1;
}
.water-cups {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
}
.water-cup {
  width: 32px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--color-water);
  background: transparent;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.water-cup.filled {
  background: var(--color-water);
}
.water-cup:hover {
  transform: scale(1.1);
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.2);
}
.water-cup-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--color-water);
  opacity: 0.3;
  transition: height 300ms ease;
}

/* ================================================================
   ADD MEAL FORM
   ================================================================ */
.form-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  box-shadow: var(--shadow-sm);
}

/* About section — database link cards */
.about-db-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  color: var(--color-text);
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease;
  font-size: var(--text-xs);
  line-height: 1.4;
}
.about-db-link:hover {
  border-color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 6%, transparent);
  color: var(--color-primary);
}
.about-db-link strong {
  display: block;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
}
.about-db-link:hover strong {
  color: var(--color-primary);
}
.about-db-flag {
  font-size: 18px;
  flex-shrink: 0;
  line-height: 1;
}
.about-db-desc {
  color: var(--color-text-muted);
  font-size: 11px;
}
.about-db-arrow {
  margin-left: auto;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  flex-shrink: 0;
}
.form-section-title {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.form-group {
  margin-bottom: var(--space-3);
}
.form-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-1);
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: var(--space-3) var(--space-3);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  color: var(--color-text);
  font-size: var(--text-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(30, 122, 92, 0.15);
}
.form-input::placeholder { color: var(--color-text-faint); }
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235a6e5c' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}
.macro-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}
.macro-input-wrap {
  position: relative;
}
.macro-input-wrap .unit {
  position: absolute;
  right: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  pointer-events: none;
}

/* CNF autofill badge in form */
.autofill-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--color-primary);
  background: var(--color-primary-light);
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-full);
  padding: 2px 10px;
  margin-top: var(--space-2);
  animation: badgeIn 300ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes badgeIn {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

/* ================================================================
   BUTTONS
   ================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  transition: all var(--transition);
  cursor: pointer;
  border: none;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--color-primary);
  color: white;
  box-shadow: 0 2px 8px rgba(30, 122, 92, 0.25);
}
.btn-primary:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(30, 122, 92, 0.3);
}
.btn-primary:active { transform: translateY(0); }
.btn-secondary {
  background: var(--color-surface-2);
  color: var(--color-text);
  border: 1.5px solid var(--color-border);
}
.btn-secondary:hover {
  background: var(--color-surface-offset);
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
}
.btn-ghost:hover { background: var(--color-surface-2); color: var(--color-text); }
.btn-danger {
  background: var(--color-error-light);
  color: var(--color-error);
}
.btn-danger:hover { background: var(--color-error); color: white; }
.btn-full { width: 100%; }
.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
}
.btn svg { flex-shrink: 0; }

/* Loading spinner in button */
.btn.loading .btn-text { opacity: 0.4; }
.btn.loading::after {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 600ms linear infinite;
  position: absolute;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ================================================================
   CNF SEARCH PANEL
   ================================================================ */
.cnf-search-wrap {
  position: relative;
  margin-bottom: var(--space-3);
}
.cnf-search-input {
  width: 100%;
  padding: var(--space-3) var(--space-3) var(--space-3) 40px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  color: var(--color-text);
  font-size: var(--text-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.cnf-search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(30, 122, 92, 0.15);
}
.cnf-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-faint);
  pointer-events: none;
}
.cnf-search-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
}

.cnf-results {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: 280px;
  overflow-y: auto;
  margin-bottom: var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}
.cnf-result-item {
  padding: var(--space-3);
  cursor: pointer;
  border-bottom: 1px solid var(--color-divider);
  transition: background var(--transition);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
}
.cnf-result-item:last-child { border-bottom: none; }
.cnf-result-item:hover { background: var(--color-primary-light); }
.cnf-result-name {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.4;
}
.cnf-result-code {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  font-family: monospace;
  white-space: nowrap;
}
.cnf-loading {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}
.cnf-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
  flex-shrink: 0;
}

/* Nutrient mapping reference */
.nutrient-map-table {
  width: 100%;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-2);
  border-collapse: collapse;
}
.nutrient-map-table td { padding: 4px var(--space-2); vertical-align: top; }
.nutrient-map-table td:first-child { color: var(--color-text); font-weight: 600; white-space: nowrap; }
.nutrient-map-table thead tr { border-bottom: 1px solid var(--color-border); }
.nutrient-map-table tbody tr:nth-child(even) { background: var(--color-surface-offset); }
.nutrient-map-table thead td { color: var(--color-text-muted); font-weight: 700; font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.03em; padding-bottom: var(--space-1); }

/* ================================================================
   BARCODE SCANNER
   ================================================================ */
.scanner-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--space-3);
  box-shadow: var(--shadow-sm);
}
.scanner-header {
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-divider);
}
.scanner-viewport {
  position: relative;
  background: #000;
  aspect-ratio: 4/3;
  overflow: hidden;
  max-height: 240px;
}
#scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.scanner-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.scanner-frame {
  width: 220px;
  height: 120px;
  border: 2px solid rgba(77, 184, 144, 0.8);
  border-radius: var(--radius-md);
  position: relative;
  box-shadow: 0 0 0 1000px rgba(0,0,0,0.5);
}
.scanner-frame::before, .scanner-frame::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-color: var(--color-primary);
  border-style: solid;
}
.scanner-frame::before {
  top: -2px;
  left: -2px;
  border-width: 3px 0 0 3px;
  border-radius: var(--radius-sm) 0 0 0;
}
.scanner-frame::after {
  top: -2px;
  right: -2px;
  border-width: 3px 3px 0 0;
  border-radius: 0 var(--radius-sm) 0 0;
}
.scanner-laser {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--color-primary), transparent);
  animation: laserScan 1.8s ease-in-out infinite;
  top: 50%;
}
@keyframes laserScan {
  0% { top: 10%; opacity: 0.7; }
  50% { top: 90%; opacity: 1; }
  100% { top: 10%; opacity: 0.7; }
}
.scanner-status {
  position: absolute;
  bottom: var(--space-2);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  color: white;
  font-size: var(--text-xs);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  backdrop-filter: blur(4px);
}
.scanner-footer {
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.scan-result-display {
  background: var(--color-primary-light);
  border: 1.5px solid var(--color-primary);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-primary);
  font-weight: 600;
  text-align: center;
  animation: badgeIn 300ms ease both;
}

/* ================================================================
   GOALS / SETTINGS
   ================================================================ */
.goals-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  box-shadow: var(--shadow-sm);
}
.goals-title {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.goals-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}
.goal-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.goal-item label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.goal-item-full {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  gap: var(--space-3);
}
.toggle-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-transform: none !important;
  letter-spacing: 0 !important;
  font-size: var(--text-sm) !important;
  font-weight: 600 !important;
  color: var(--color-text) !important;
}
.toggle-hint {
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--color-text-muted);
  text-transform: none;
  letter-spacing: 0;
}
/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  text-transform: none;
  letter-spacing: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--color-border);
  border-radius: 24px;
  cursor: pointer;
  transition: background 0.25s;
}
.toggle-slider:before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.25s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider { background: var(--color-primary); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(20px); }

/* ================================================================
   DAILY SUMMARY TABLE
   ================================================================ */
.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-xs);
}
.summary-table th {
  padding: var(--space-2) var(--space-2);
  text-align: left;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--color-surface-2);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.summary-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-divider);
  color: var(--color-text);
  vertical-align: middle;
}
.summary-table tr:last-child td { border-bottom: none; }
.summary-table tr:hover td { background: var(--color-surface-2); }
.summary-goal-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.mini-bar {
  flex: 1;
  height: 6px;
  background: var(--color-surface-offset);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.mini-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 600ms ease;
}

/* ================================================================
   EXPORT
   ================================================================ */
.export-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

/* ── Export Cards ─────────────────────────────────────────────── */
.export-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-3);
}
.export-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.export-card:hover {
  border-color: var(--color-primary);
  box-shadow: 0 2px 8px rgba(30,122,92,0.10);
}
.export-card:active { opacity: 0.85; }
.export-card-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.export-card-icon--green {
  background: var(--color-protein-light, #e8f5ee);
  color: var(--color-primary);
}
.export-card-icon--blue {
  background: #e8f0fe;
  color: #1a73e8;
}
.export-card-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.export-card-label {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
}
.export-card-sub {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  line-height: 1.4;
}
.export-card-chevron {
  color: var(--color-text-faint);
  flex-shrink: 0;
}

/* ── Danger Zone ──────────────────────────────────────────────── */
.export-danger-zone {
  margin-top: var(--space-4);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  border: 1.5px dashed var(--color-error, #e53935);
  background: rgba(229,57,53,0.04);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.export-danger-label {
  flex: 1;
  font-size: 0.65rem;
  color: var(--color-text-muted);
  line-height: 1.4;
  min-width: 120px;
}
.export-danger-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--color-error, #e53935);
  background: transparent;
  color: var(--color-error, #e53935);
  font-size: var(--text-xs);
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  flex-shrink: 0;
}
.export-danger-btn:hover {
  background: rgba(229,57,53,0.08);
}

/* ================================================================
   TOAST NOTIFICATIONS
   ================================================================ */
.toast-container {
  position: fixed;
  top: calc(var(--nav-height) + var(--space-3));
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
  max-width: 360px;
  width: calc(100% - var(--space-8));
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: toastIn 320ms cubic-bezier(0.16, 1, 0.3, 1) both;
  font-size: var(--text-sm);
  font-weight: 500;
  pointer-events: all;
}
.toast.success { border-left: 4px solid var(--color-success); }
.toast.error { border-left: 4px solid var(--color-error); }
.toast.info { border-left: 4px solid var(--color-primary); }
.toast.exit { animation: toastOut 280ms ease both; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-16px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(-8px) scale(0.95); }
}

/* ================================================================
   MODAL / DIALOG
   ================================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: env(safe-area-inset-bottom, 0);
  animation: overlayIn 200ms ease both;
}
.modal-overlay.hidden { display: none; }
@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal-sheet {
  background: var(--color-surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-4);
  width: 100%;
  max-width: 480px;
  max-height: 85dvh;
  overflow-y: auto;
  animation: sheetUp 320ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes sheetUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  margin: 0 auto var(--space-4);
}
.modal-title {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  margin-bottom: var(--space-4);
}

/* ================================================================
   TABS inside view
   ================================================================ */
.tab-bar {
  display: flex;
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 3px;
  margin-bottom: var(--space-4);
}
.tab-btn {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  border-radius: calc(var(--radius-md) - 2px);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  transition: all var(--transition);
  text-align: center;
  cursor: pointer;
}
.tab-btn.active {
  background: var(--color-surface);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

/* ================================================================
   UTILITY / HELPER CLASSES
   ================================================================ */
.text-primary { color: var(--color-primary); }
.text-muted { color: var(--color-text-muted); }
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.font-bold { font-weight: 700; }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, var(--color-surface-2) 25%, var(--color-surface-offset) 50%, var(--color-surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-md);
}
@keyframes shimmer {
  to { background-position: -200% 0; }
}

/* Disclaimer */
/* ================================================================
   AD SLOTS
   ================================================================ */
.ad-slot {
  margin: var(--space-3) 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  min-height: 80px;
}
.ad-slot--scan {
  margin: var(--space-3) var(--space-2) 0;
}
.ad-slot-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  padding: 4px var(--space-2) 0;
  opacity: 0.6;
}

.disclaimer {
  background: var(--color-warning-light);
  border: 1px solid var(--color-warning);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.5;
  margin-bottom: var(--space-3);
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: var(--radius-full); }

/* Mobile safe area support */
@supports (padding: env(safe-area-inset-bottom)) {
  .app-wrapper { padding-bottom: 0; }
}

/* ================================================================
   MEAL REPLACEMENT SHAKE PANEL
   ================================================================ */
.shake-panel {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  margin: var(--space-3) var(--space-3) 0;
}

.shake-panel-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

/* Collapsible toggle button */
.shake-panel-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
  margin-bottom: var(--space-3);
  gap: var(--space-2);
}
.shake-panel-toggle:hover .shake-panel-title {
  color: var(--color-primary);
}
.shake-chevron {
  flex-shrink: 0;
  color: var(--color-text-muted);
  transition: transform 0.22s ease;
}
.shake-panel-toggle[aria-expanded="false"] .shake-chevron {
  transform: rotate(-90deg);
}
.shake-panel-toggle[aria-expanded="false"] {
  margin-bottom: 0;
}

/* Collapsed grid — defined AFTER .shake-grid to win specificity */

.shake-panel-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
}

.shake-panel-subtitle {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}

.shake-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
}

@media (min-width: 420px) {
  .shake-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Must come AFTER .shake-grid rules so display:none wins */
.shake-grid-collapsed {
  display: none !important;
}

.shake-card {
  --shake-color: var(--color-primary);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  background: var(--color-surface);
  border: 2px solid transparent;
  border-left: 4px solid var(--shake-color);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-2);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  width: 100%;
}

.shake-card:hover,
.shake-card:focus {
  border-color: var(--shake-color);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  transform: translateY(-1px);
  outline: none;
}

.shake-card:active {
  transform: translateY(0);
  box-shadow: none;
}

.shake-brand {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--shake-color);
}

.shake-name {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
}

.shake-macros {
  font-size: 10px;
  font-weight: 600;
  color: var(--color-primary);
  margin-top: 2px;
}

.shake-serving {
  font-size: 10px;
  color: var(--color-text-muted);
}

/* ================================================================
   WELCOME / PROFILE SCREEN
   ================================================================ */

.welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--color-bg);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: var(--space-4) var(--space-4) 40px;
}

.welcome-overlay.hidden {
  display: none;
}

.welcome-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  padding: var(--space-6) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* Logo row */
.welcome-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-1);
}

.welcome-logo svg {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.welcome-logo-text {
  display: flex;
  flex-direction: column;
}

.welcome-app-name {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

.welcome-app-sub {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* Titles */
.welcome-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.2;
}

.welcome-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: calc(var(--space-1) * -1) 0 0;
}

/* Sections */
.welcome-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
}

.welcome-section-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-primary);
}

/* Sex toggle */
.sex-toggle-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.sex-btn {
  padding: var(--space-3) var(--space-2);
  border-radius: var(--radius-lg);
  border: 2px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.sex-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.sex-btn.active {
  border-color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 12%, transparent);
  color: var(--color-primary);
}

/* Fields */
.welcome-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.welcome-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.welcome-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
}

.welcome-input {
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: var(--text-base);
  font-family: inherit;
  transition: border-color 0.15s;
  width: 100%;
  box-sizing: border-box;
}

.welcome-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 15%, transparent);
}

/* BMI Card */
.bmi-card {
  background: color-mix(in srgb, var(--color-primary) 8%, var(--color-bg));
  border: 1.5px solid color-mix(in srgb, var(--color-primary) 25%, transparent);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.bmi-value-row {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

.bmi-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
}

.bmi-value {
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--color-primary);
  letter-spacing: -0.03em;
}

.bmi-category {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  margin-left: auto;
  padding: 2px 10px;
  border-radius: 20px;
  background: var(--color-surface);
}

/* BMI bar */
.bmi-bar-track {
  height: 8px;
  border-radius: 99px;
  background: linear-gradient(to right, #3b82f6 0%, #22c55e 20%, #f59e0b 45%, #ef4444 70%, #7c3aed 100%);
  position: relative;
  overflow: visible;
}

.bmi-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: transparent;
}

.bmi-bar-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  background: white;
  border: 3px solid var(--color-primary);
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  transition: left 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.bmi-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--color-text-muted);
  font-weight: 600;
}

/* Save button */
.welcome-save-btn {
  width: 100%;
  padding: var(--space-4);
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius-xl);
  font-size: var(--text-base);
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: opacity 0.15s, transform 0.1s;
  box-shadow: 0 4px 16px color-mix(in srgb, var(--color-primary) 35%, transparent);
}

.welcome-save-btn:hover {
  opacity: 0.92;
}

.welcome-save-btn:active {
  transform: scale(0.98);
}

/* ---- Welcome overlay close button ---- */
.welcome-close-btn {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--color-surface-alt, #f0f0f0);
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  z-index: 10;
}
.welcome-close-btn:hover {
  background: var(--color-border);
  color: var(--color-text);
}
.welcome-close-btn.hidden {
  display: none;
}

/* ---- Profile summary card in Goals tab ---- */
.profile-summary-card {
  background: var(--color-surface-alt, #f8f9fa);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  margin-bottom: var(--space-2);
}
.profile-summary-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.profile-summary-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--color-primary) 18%, transparent);
  color: var(--color-primary);
  font-size: var(--text-lg);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.profile-summary-info {
  flex: 1;
  min-width: 0;
}
.profile-summary-name {
  font-weight: 700;
  font-size: var(--text-base);
  color: var(--color-text);
}
.profile-summary-sex {
  font-size: var(--text-sm);
}
.profile-summary-meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}
.profile-summary-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}
.profile-summary-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-1);
  gap: 2px;
}
.profile-stat-label {
  font-size: 10px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.profile-stat-value {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
}
.profile-summary-empty {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: center;
  padding: var(--space-2) 0;
  margin: 0;
}

/* Profile chip in header (shown after setup) */
.profile-chip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 99px;
  padding: 4px 12px 4px 6px;
  cursor: pointer;
  transition: border-color 0.15s;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text);
}

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

.profile-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--color-primary) 20%, transparent);
  color: var(--color-primary);
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Days since surgery badge */
.days-since-badge {
  font-size: 10px;
  color: var(--color-text-muted);
  margin-left: 2px;
}

/* Unit system toggle (metric / imperial) */
.unit-toggle-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.unit-btn {
  padding: var(--space-2) var(--space-2);
  border-radius: var(--radius-lg);
  border: 2px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
}

.unit-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.unit-btn.active {
  border-color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 12%, transparent);
  color: var(--color-primary);
}

/* Imperial 3-col layout */
.imperial-height-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-3);
}

/* ================================================================
   FOOD DATABASE REGION SELECTOR
   ================================================================ */

.db-region-row {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}

.db-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.db-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 6%, transparent);
}

.db-btn.active {
  border-color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 12%, transparent);
  color: var(--color-primary);
}

.db-flag {
  font-size: 14px;
  line-height: 1;
}

.db-source-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: var(--space-1);
  background: color-mix(in srgb, var(--color-primary) 12%, transparent);
  color: var(--color-primary);
  vertical-align: middle;
}
.code-db-badge-row {
  margin-bottom: var(--space-3);
  min-height: 20px;
}
.code-db-badge-row .db-source-badge {
  margin-left: 0;
  font-size: 11px;
  padding: 3px 8px;
}

/* ================================================================
   MENU GENERATOR
   ================================================================ */

/* Header */
.menu-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4) var(--space-2);
  flex-wrap: wrap;
}
.menu-header-actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}
.menu-title {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--color-text);
}
.menu-subtitle {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* Day tabs */
.menu-day-tabs {
  display: flex;
  gap: var(--space-1);
  padding: 0 var(--space-4) var(--space-3);
  overflow-x: auto;
  scrollbar-width: none;
}
.menu-day-tabs::-webkit-scrollbar { display: none; }
.menu-day-tab {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.menu-day-tab.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}
.menu-day-tab:hover:not(.active) {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* Meal cards */
.menu-day-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: 0 var(--space-4) calc(var(--space-4) + 60px);
}
.menu-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  transition: box-shadow 0.15s;
}
.menu-card:hover { box-shadow: 0 3px 12px rgba(0,0,0,0.10); }
.menu-card-photo {
  width: 100%;
  height: 160px;
  background-size: cover;
  background-position: center;
  position: relative;
}
.menu-card-meal-type {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  letter-spacing: 0.03em;
  backdrop-filter: blur(4px);
}
.menu-card-body {
  padding: var(--space-3);
}
.menu-card-name {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-2);
  line-height: 1.3;
}
.menu-card-macros {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
  margin-bottom: var(--space-2);
}
.menu-macro-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
}
.menu-macro-p {
  background: var(--color-protein-light, #fce7e7);
  color: var(--color-protein, #c0392b);
}
.menu-macro-c {
  background: var(--color-grains-light, #fef9e7);
  color: var(--color-grains, #b7950b);
}
.menu-card-time {
  display: flex;
  gap: var(--space-3);
  font-size: 0.65rem;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}
.menu-card-actions {
  display: flex;
  gap: var(--space-2);
}
.menu-card-actions .btn { flex: 1; font-size: 0.7rem; padding: 7px 10px; }

/* ── Recipe Modal ───────────────────────────────────────────── */
.recipe-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 300;
  display: flex;
  align-items: flex-end;
}
.recipe-modal-overlay.hidden { display: none; }
.recipe-modal-scroll {
  width: 100%;
  max-height: 92vh;
  background: var(--color-bg);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  overflow-y: auto;
  scrollbar-width: thin;
}
.recipe-modal-photo {
  width: 100%;
  height: 220px;
  background-size: cover;
  background-position: center;
  position: relative;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  overflow: hidden;
  flex-shrink: 0;
}
.recipe-modal-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  border: none;
  font-size: 14px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.recipe-modal-meal-type {
  position: absolute;
  bottom: 12px; left: 12px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
}
.recipe-modal-body {
  padding: var(--space-4);
  padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
}
.recipe-modal-title {
  font-size: var(--text-md);
  font-weight: 800;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}
.recipe-modal-meta {
  display: flex;
  gap: var(--space-3);
  font-size: 0.65rem;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}
.recipe-nutrition-strip {
  display: flex;
  gap: var(--space-2);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-4);
  overflow-x: auto;
  scrollbar-width: none;
}
.recipe-nutrition-strip::-webkit-scrollbar { display: none; }
.recipe-nut-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 48px;
  gap: 2px;
}
.recipe-nut-val {
  font-size: var(--text-sm);
  font-weight: 800;
  color: var(--color-text);
}
.recipe-nut-label {
  font-size: 0.6rem;
  color: var(--color-text-muted);
  text-align: center;
}
.recipe-section-title {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: var(--space-4) 0 var(--space-2);
}
.recipe-ingredients-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.recipe-ingredients-list li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border);
}
.recipe-ingredients-list li::before {
  content: '•';
  color: var(--color-primary);
  font-weight: 700;
  flex-shrink: 0;
}
.recipe-instructions-list {
  padding-left: var(--space-4);
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.recipe-instructions-list li {
  font-size: var(--text-xs);
  color: var(--color-text);
  line-height: 1.6;
}

/* ── Grocery Modal ──────────────────────────────────────────── */
.grocery-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 300;
  display: flex;
  align-items: flex-end;
}
.grocery-modal-overlay.hidden { display: none; }
.grocery-modal-box {
  width: 100%;
  max-height: 85vh;
  background: var(--color-bg);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  overflow-y: auto;
  scrollbar-width: thin;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.grocery-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-4) var(--space-2);
  position: sticky;
  top: 0;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  z-index: 2;
}
.grocery-modal-title {
  font-size: var(--text-sm);
  font-weight: 800;
  color: var(--color-text);
}
.grocery-modal-body {
  padding: var(--space-3) var(--space-4) var(--space-6);
}
.grocery-section { margin-bottom: var(--space-4); }
.grocery-section-title {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-2);
  padding-bottom: 4px;
  border-bottom: 2px solid var(--color-primary);
  display: inline-block;
}
.grocery-list-items {
  list-style: none;
  padding: 0;
  margin: 0;
}
.grocery-list-items li {
  border-bottom: 1px solid var(--color-border);
}
.grocery-check-label {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  cursor: pointer;
  font-size: var(--text-xs);
  color: var(--color-text);
  transition: color 0.15s;
  width: 100%;
}
.grocery-check-label.checked { color: var(--color-text-muted); text-decoration: line-through; }
.grocery-checkbox {
  width: 18px; height: 18px;
  accent-color: var(--color-primary);
  flex-shrink: 0;
  cursor: pointer;
}

/* ================================================================
   INTERNET RECIPE SEARCH PANEL
   ================================================================ */
.recipe-search-section {
  margin: var(--space-4) var(--space-4) calc(var(--space-4) + 80px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}
.recipe-search-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}
.recipe-search-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin: 0 0 var(--space-3);
}
.recipe-search-bar {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.recipe-search-bar .form-input {
  flex: 1;
}
.recipe-search-bar .btn {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}
/* Quick tag pills */
.recipe-search-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: var(--space-3);
}
.recipe-tag {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.recipe-tag:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 8%, transparent);
}
/* No results message */
.recipe-no-results {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  padding: var(--space-3) 0;
  text-align: center;
}
/* Internet recipe card */
.inet-recipe-card {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
}
.inet-recipe-card:last-child { border-bottom: none; }
.inet-recipe-photo {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-md);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  background-color: var(--color-surface-2);
}
.inet-recipe-body {
  flex: 1;
  min-width: 0;
}
.inet-recipe-name {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 2px;
  line-height: 1.3;
}
.inet-recipe-tag {
  font-size: 10px;
  color: var(--color-primary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-2);
}
.inet-recipe-ingredients {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: var(--space-2);
}
.inet-ing-chip {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  white-space: nowrap;
}
.inet-ing-more {
  font-size: 10px;
  color: var(--color-text-muted);
  align-self: center;
  padding-left: 2px;
}
.inet-recipe-note {
  font-size: 10px;
  color: var(--color-text-muted);
  font-style: italic;
  margin: 0 0 var(--space-2);
}
.inet-recipe-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.inet-recipe-actions .btn { font-size: 0.68rem; padding: 5px 9px; }
.inet-source-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--color-primary) 10%, transparent);
  color: var(--color-primary);
  margin-top: var(--space-1);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
/* Web fallback */
.recipe-web-fallback {
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
}
.recipe-web-fallback p {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin: 0 0 var(--space-2);
}
.recipe-web-btns {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* ================================================================
   SUPPLEMENT TRACKER — Today tab widget
   ================================================================ */
.supp-tracker {
  margin: 0 var(--space-4) var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-sm);
}
.supp-tracker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}
.supp-tracker-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
}
.supp-count {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 10%, transparent);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}
/* Dashboard pill grid */
.supp-pill-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.supp-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px 5px 7px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-display);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  line-height: 1;
}
.supp-pill:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 8%, transparent);
}
.supp-pill.taken {
  border-color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 14%, transparent);
  color: var(--color-primary);
}
.supp-pill-icon { font-size: 13px; line-height: 1; }
.supp-pill-label { font-size: 11px; }
.supp-check {
  font-size: 10px;
  font-weight: 900;
  color: var(--color-primary);
  margin-left: 2px;
}

/* Add tab supplement grid */
.supp-add-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--space-3);
}
.supp-add-pill {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 1.5px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: var(--font-display);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  width: 100%;
}
.supp-add-pill:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 6%, transparent);
}
.supp-add-pill.taken {
  border-color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 12%, transparent);
  color: var(--color-primary);
}
.supp-taken-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--color-primary) 18%, transparent);
  color: var(--color-primary);
  flex-shrink: 0;
}
.supp-custom-row {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-1);
}
.supp-custom-row .form-input { flex: 1; }
.supp-custom-row .btn { flex-shrink: 0; display: flex; align-items: center; gap: 5px; }

/* ================================================================
   LIQUID DIET TAB
   ================================================================ */
/* Header */
.liquid-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4) var(--space-2);
}
.liquid-header-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #4fc3f7 0%, #0288d1 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.liquid-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--color-text);
  line-height: 1.2;
}
.liquid-subtitle {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* Cards */
.liquid-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin: 0 var(--space-4) var(--space-3);
  padding: var(--space-4);
  box-shadow: 0 1px 6px rgba(0,0,0,0.04);
}
.liquid-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-3);
}
.liquid-card-header svg { color: var(--color-primary); flex-shrink: 0; }

/* Edit button */
.liquid-rx-edit {
  margin-left: auto;
  font-size: 0.7rem;
  padding: 3px 10px;
  gap: 4px;
}
.btn-xs { font-size: 0.7rem; padding: 3px 10px; }

/* Prescription summary (read-only) */
.liquid-rx-summary {
  font-size: 0.83rem;
  color: var(--color-text-muted);
  line-height: 1.6;
}
.liquid-rx-summary .rx-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-1) 0;
  border-bottom: 1px solid var(--color-border);
}
.liquid-rx-summary .rx-row:last-child { border-bottom: none; }
.liquid-rx-summary .rx-label {
  font-weight: 600;
  color: var(--color-text);
  min-width: 90px;
  font-size: 0.78rem;
}
.liquid-rx-summary .rx-val {
  color: var(--color-text-muted);
  font-size: 0.83rem;
}
.liquid-rx-progress {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.liquid-rx-progress-bar-wrap {
  flex: 1;
  height: 8px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.liquid-rx-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #4fc3f7, #0288d1);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}
.liquid-rx-progress-pct {
  font-size: 0.75rem;
  font-weight: 700;
  color: #0288d1;
  min-width: 36px;
  text-align: right;
}

/* Edit form */
.liquid-rx-form { margin-top: var(--space-2); }

/* Duration pills */
.liquid-duration-pills {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.liquid-pill {
  flex: 1;
  min-width: 80px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
  border: 2px solid var(--color-border);
  background: transparent;
  color: var(--color-text);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}
.liquid-pill.active,
.liquid-pill:hover {
  border-color: #0288d1;
  background: #e1f5fe;
  color: #0288d1;
}

/* Shakes-per-day stepper */
.liquid-shakes-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.liquid-qty-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: 2px solid var(--color-border);
  background: transparent;
  color: var(--color-text);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.liquid-qty-btn:hover {
  border-color: #0288d1;
  color: #0288d1;
  background: #e1f5fe;
}
.liquid-qty-display {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--color-text);
  min-width: 32px;
  text-align: center;
}
.liquid-qty-unit {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* Form actions */
.liquid-form-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

/* Allowance rows */
.liquid-allowance-row {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
}
.liquid-allowance-row:last-child { border-bottom: none; }
.liquid-allowance-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
}
.liquid-allowance-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text);
}
.liquid-allowance-limit {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}
.liquid-veg-used {
  font-weight: 700;
  color: #0288d1;
}
.liquid-cup-stepper {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.liquid-limit-warn {
  font-size: 0.75rem;
  color: #ef5350;
  font-weight: 600;
  margin-top: var(--space-1);
  background: #ffebee;
  border-radius: var(--radius-sm);
  padding: 4px 10px;
}

/* Veg grid */
.liquid-veg-section { padding-top: var(--space-3); }
.liquid-veg-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.liquid-veg-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: var(--space-2) var(--space-1);
  border-radius: var(--radius-md);
  border: 2px solid var(--color-border);
  background: transparent;
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-text-muted);
}
.liquid-veg-chip .veg-emoji { font-size: 1.4rem; line-height: 1; }
.liquid-veg-chip.selected {
  border-color: #43a047;
  background: #e8f5e9;
  color: #2e7d32;
}
.liquid-veg-chip .veg-cups {
  font-size: 0.65rem;
  font-weight: 700;
  color: #43a047;
  display: none;
}
.liquid-veg-chip.selected .veg-cups { display: block; }

/* Hydration card */
.liquid-hydration-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  background: linear-gradient(135deg, #e1f5fe 0%, #f0f9ff 100%);
  border-color: #b3e5fc;
}
.liquid-hydration-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #4fc3f7, #0288d1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.liquid-hydration-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #01579b;
  margin-bottom: 4px;
}
.liquid-hydration-text {
  font-size: 0.78rem;
  color: #0277bd;
  line-height: 1.55;
}

/* Shake summary grid */
.liquid-shake-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}
.liquid-shake-kpi {
  background: var(--color-bg);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  text-align: center;
}
.liquid-shake-kpi-val {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--color-text);
}
.liquid-shake-kpi-label {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

/* Nav — 7 items: scrollable on very small screens, centered on larger */
.bottom-nav {
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  justify-content: center;
}
.bottom-nav::-webkit-scrollbar { display: none; }
.nav-item {
  flex-shrink: 0;
  min-width: 46px;
  padding: var(--space-1) var(--space-2);
}

/* ── AdSense suppression for Pro users ───────────────────── */
html.no-ads .ad-slot,
html.no-ads .adsbygoogle,
html.no-ads ins.adsbygoogle {
  display: none !important;
  height: 0 !important;
  overflow: hidden !important;
}

/* ── Body Measurements section ───────────────────────────── */
.meas-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px 0 6px;
  gap: 8px;
  color: inherit;
}
.meas-section-toggle:hover .welcome-section-label { color: var(--color-primary); }

.meas-chevron {
  flex-shrink: 0;
  color: var(--color-text-muted);
  transition: transform 0.25s ease;
}
.meas-section-toggle[aria-expanded="true"] .meas-chevron {
  transform: rotate(180deg);
}

.meas-fields-collapsed {
  display: none !important;
}

.meas-hint {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin: 0 0 10px;
  line-height: 1.4;
}

/* Profile summary measurements */
.profile-meas-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin: 12px 0 6px;
}
.profile-summary-stats-wrap {
  flex-wrap: wrap;
  gap: 8px;
}

/* ── Fitness Tab ─────────────────────────────────────────── */
.fitness-rings-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.fitness-ring-card {
  background: var(--color-surface);
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
  border: 1px solid var(--color-border);
}
.fitness-ring-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}
.fitness-ring-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: #2d7a2f;
  line-height: 1.1;
}
.fitness-ring-goal {
  font-size: 0.68rem;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}
.fitness-progress-bar {
  height: 5px;
  background: var(--color-border);
  border-radius: 3px;
  overflow: hidden;
}
.fitness-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2d7a2f, #6abf3a);
  border-radius: 3px;
  transition: width 0.4s ease;
}
/* Workout list */
.workout-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}
.workout-item:last-child { border-bottom: none; }
.workout-icon { font-size: 1.4rem; flex-shrink: 0; line-height: 1; }
.workout-info { flex: 1; min-width: 0; }
.workout-name { font-weight: 700; font-size: 0.9rem; }
.workout-meta { font-size: 0.78rem; color: var(--color-text-muted); margin-top: 2px; }
.workout-notes { font-size: 0.75rem; color: var(--color-text-muted); font-style: italic; margin-top: 2px; }
.workout-delete {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.workout-delete:hover { color: #ef4444; background: #fee2e2; }
/* Health sync */
.health-sync-buttons { display: flex; gap: 10px; margin: 10px 0 6px; flex-wrap: wrap; }
.health-sync-note { font-size: 0.78rem; color: var(--color-text-muted); }
/* Macro model */
.macro-model-buttons { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.macro-model-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 12px 14px;
  border: 2px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s, background 0.2s;
}
.macro-model-btn.active {
  border-color: #2d7a2f;
  background: #f0fdf4;
}
.macro-model-btn:hover { border-color: #6abf3a; }
.macro-model-name { font-weight: 700; font-size: 0.9rem; color: var(--color-text); }
.macro-model-desc { font-size: 0.75rem; color: var(--color-text-muted); margin-top: 2px; }
.macro-model-btn.active .macro-model-name { color: #2d7a2f; }
/* Logo subtitle 2 */
.logo-subtitle2 {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.75);
  font-weight: 500;
  letter-spacing: 0.04em;
  display: block;
}
/* Section card (used in fitness tab) */
.section-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
}
.section-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--color-text);
  margin-bottom: var(--space-4);
}
.section-subtitle {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-3);
}
.section-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
  line-height: 1.5;
}
.empty-state-text {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: center;
  padding: var(--space-4);
}
/* Modal card style (for workout modal) */
.modal-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: 0;
  width: min(480px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  background: var(--color-surface);
  z-index: 1;
}
.modal-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--color-text);
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  line-height: 1;
}
.modal-close:hover { background: var(--color-surface-2); }
.modal-body {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
/* Header logo text updates for white on gradient */
#logoTitle {
  color: rgba(255,255,255,0.97);
}
#logoSubtitle {
  color: rgba(255,255,255,0.82);
}
/* Nav item and header icon adjustments for gradient header */
.icon-btn, .lang-btn {
  color: #111;
}
.icon-btn:hover, .lang-btn:hover {
  background: rgba(255,255,255,0.25);
  color: #000;
}
#langLabel {
  color: #111;
}

/* Workout modal centering override */
#workoutModal {
  align-items: center;
}
#workoutModal .modal-card {
  margin: auto;
}

/* ── Supplement Log — collapsible ────────────────────────── */
.supp-log-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0 8px;
  gap: 8px;
  color: inherit;
  text-align: left;
}
.supp-log-toggle-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.supp-log-chevron {
  color: var(--color-text-muted);
  transition: transform 0.25s ease;
  flex-shrink: 0;
}
.supp-log-toggle[aria-expanded="true"] .supp-log-chevron {
  transform: rotate(180deg);
}
.supp-log-fields-collapsed {
  display: none !important;
}
/* Today-tab toggle inside header */
.supp-tracker-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: default;
}
.supp-tracker-toggle-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-text-muted);
  white-space: nowrap;
}
/* Toggle switch */
.supp-toggle-switch {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 20px;
  cursor: pointer;
}
.supp-toggle-switch input { opacity: 0; width: 0; height: 0; }
.supp-toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--color-border);
  border-radius: 20px;
  transition: background 0.2s;
}
.supp-toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}
.supp-toggle-switch input:checked + .supp-toggle-slider {
  background: #2d7a2f;
}
.supp-toggle-switch input:checked + .supp-toggle-slider::before {
  transform: translateX(14px);
}

/* ── Oura Ring Connect Panel ─────────────────────────────── */
.oura-sync-btn.sync-connected {
  border-color: #2d7a2f;
  color: #2d7a2f;
  background: rgba(45,122,47,0.06);
}
.oura-connect-panel {
  margin-top: 10px;
  border: 1.5px solid #d1e8d1;
  border-radius: 14px;
  overflow: hidden;
  background: var(--card-bg, #fff);
  transition: all 0.3s ease;
}
.oura-connect-panel.hidden {
  display: none;
}
.oura-panel-inner {
  padding: 16px;
}
.oura-panel-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text, #1a1a1a);
}
.oura-panel-desc {
  font-size: 0.875rem;
  color: var(--text-muted, #666);
  margin: 0 0 6px 0;
  line-height: 1.5;
}
.oura-panel-hint {
  font-size: 0.8rem;
  color: var(--text-muted, #888);
  margin: 0 0 12px 0;
  line-height: 1.4;
}
.oura-token-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.oura-token-row .welcome-input {
  flex: 1;
  font-size: 0.85rem;
  padding: 8px 12px;
}
.oura-connect-status {
  font-size: 0.82rem;
  min-height: 18px;
  margin-bottom: 4px;
  color: var(--text-muted, #666);
}
.oura-connect-status.success {
  color: #2d7a2f;
  font-weight: 600;
}
.oura-connect-status.error {
  color: #c0392b;
}
.oura-data-preview {
  margin-top: 12px;
  padding: 12px;
  background: rgba(45,122,47,0.05);
  border-radius: 10px;
  border: 1px solid #c8e6c9;
}
.oura-data-preview.hidden {
  display: none;
}
.oura-preview-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 8px;
}
@media (max-width: 400px) {
  .oura-preview-grid { grid-template-columns: repeat(2, 1fr); }
}
.oura-preview-item {
  text-align: center;
  padding: 8px 4px;
  background: var(--card-bg, #fff);
  border-radius: 8px;
}
.oura-preview-val {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  color: #2d7a2f;
}
.oura-preview-lbl {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted, #888);
  margin-top: 2px;
}

/* ── Activity Rings (Closing Rings) ─────────────────────────────── */
.activity-rings-section {
  background: var(--card-bg, #fff);
  border-radius: 18px;
  padding: 16px;
  margin: 0 0 14px 0;
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}
.activity-rings-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text, #1a1a1a);
  margin-bottom: 14px;
  letter-spacing: 0.01em;
}
.activity-rings-body {
  display: flex;
  align-items: center;
  gap: 20px;
}
.activity-rings-svg-wrap {
  flex-shrink: 0;
  width: 120px;
  height: 120px;
}
.activity-rings-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Track (background) circles */
.ar-track { stroke: rgba(0,0,0,0.08); }
@media (prefers-color-scheme: dark) {
  .ar-track { stroke: rgba(255,255,255,0.1); }
}

/* Ring colours */
.ar-move    { stroke: #ff375f; }   /* Red — Move / calories */
.ar-exercise{ stroke: #92e82a; }   /* Lime — Exercise / active min */
.ar-stand   { stroke: #1fe0ff; }   /* Cyan — Stand / steps */

/* Ring animation */
.ar-ring {
  transition: stroke-dasharray 1s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Legend */
.activity-rings-legend {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ar-legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ar-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ar-move-color     { background: #ff375f; color: #ff375f; }
.ar-exercise-color { background: #92e82a; color: #92e82a; }
.ar-stand-color    { background: #1fe0ff; color: #1fe0ff; }
.ar-legend-text {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.ar-legend-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-text, #1a1a1a);
  line-height: 1.2;
}
.ar-legend-val {
  font-size: 0.7rem;
  color: var(--color-text-muted, #888);
  line-height: 1.3;
}
.ar-legend-pct {
  font-size: 0.78rem;
  font-weight: 800;
  min-width: 36px;
  text-align: right;
}


/* ================================================================
   FEATURE 1: STREAK TRACKING
   ================================================================ */
.streak-banner {
  display: flex; align-items: center; gap: 10px;
  background: var(--card-bg, #fff); border-radius: 14px;
  padding: 10px 16px; margin: 0 0 10px 0;
  border: 1.5px solid #e8e8e8;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.streak-banner.streak-active { border-color: #ff8c00; background: #fff8f0; }
.streak-flame { font-size: 1.5rem; line-height: 1; }
.streak-text { font-size: 1.1rem; font-weight: 800; color: var(--color-text,#1a1a1a); }
.streak-sub { font-size: 0.8rem; color: var(--color-text-muted,#888); margin-left: auto; }

/* ================================================================
   FEATURE 2: PROGRESS PHOTOS
   ================================================================ */
.progress-photos-section { margin: 14px 0; }
.progress-photo-gallery { display: flex; gap: 10px; overflow-x: auto; padding: 8px 0; }
.progress-photo-item { flex-shrink: 0; text-align: center; }
.progress-photo-img { width: 80px; height: 80px; object-fit: cover; border-radius: 10px; cursor: pointer; border: 2px solid var(--color-border,#e0e0e0); }
.progress-photo-date { font-size: 0.65rem; color: var(--color-text-muted,#888); margin-top: 4px; }
.photo-fullscreen-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 9999; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.no-photos-hint { font-size: 0.85rem; color: var(--color-text-muted,#888); padding: 12px 0; }

/* ================================================================
   FEATURE 3: WEIGHT TRACKING CHART
   ================================================================ */
.weight-chart-section { background: var(--card-bg,#fff); border-radius: 14px; padding: 14px 16px; margin: 0 0 14px 0; box-shadow: 0 1px 4px rgba(0,0,0,0.05); }
.weight-chart-canvas { width: 100%; display: block; border-radius: 8px; }
.weight-chart-stats { display: flex; gap: 14px; margin-top: 8px; flex-wrap: wrap; }
.wc-stat { font-size: 0.82rem; color: var(--color-text-muted,#666); }
.wc-stat b { color: var(--color-text,#1a1a1a); }
.wc-loss { color: #2d7a2f; font-weight: 700; }
.wc-gain { color: #c0392b; font-weight: 700; }

/* ================================================================
   FEATURE 4: NOTIFICATION SETTINGS
   ================================================================ */
.notif-settings-section { background: var(--card-bg,#fff); border-radius: 14px; padding: 14px 16px; margin: 0 0 14px 0; box-shadow: 0 1px 4px rgba(0,0,0,0.05); }
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--color-border,#eee); }
.settings-row:last-child { border-bottom: none; }
.settings-row-info { display: flex; flex-direction: column; gap: 2px; }
.settings-row-sub { font-size: 0.75rem; color: var(--color-text-muted,#888); }

/* Shared: section-title with inline button */
.section-title { display: flex; align-items: center; justify-content: space-between; font-size: 0.9rem; font-weight: 700; color: var(--color-text,#1a1a1a); margin-bottom: 8px; }
