/* ================================================================
   BARIATRIC JOURNAL — Design System
   Palette: Soft teal-green (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 teal-green */
  --color-primary: #1e7a5c;
  --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: #4db890;
  --color-primary-hover: #3da07c;
  --color-primary-active: #2d8a68;
  --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: #4db890;
    --color-primary-hover: #3da07c;
    --color-primary-active: #2d8a68;
    --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: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  min-height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: env(safe-area-inset-top, 0px) var(--space-4) 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: var(--color-text);
}
.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 (toggle via globe button)
   ================================================================ */
.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;
  /* Hidden by default — toggled by globe button */
  max-height: 0;
  overflow: hidden;
  padding-top: 0;
  padding-bottom: 0;
  border-bottom-width: 0;
  transition: max-height 0.25s ease, padding 0.2s ease, border-bottom-width 0.2s ease;
}
.global-control-bar.gcb-open {
  max-height: 80px;
  padding: 7px var(--space-3);
  border-bottom-width: 1px;
}
.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: var(--color-text-muted);
  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-teal); }

.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 — Bariatric Health v1.8.25
   ================================================================ */
/* Fitness tab */
.fitness-rings-row { display: flex; gap: 10px; margin: 12px 0; }
.fitness-ring-card { flex: 1; background: var(--card-bg,#fff); border-radius: 12px; padding: 12px 8px; text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.fitness-ring-label { font-size: 0.72rem; font-weight: 700; color: var(--color-text-muted,#666); text-transform: uppercase; letter-spacing: 0.04em; }
.fitness-ring-value { font-size: 1.4rem; font-weight: 800; color: var(--color-text,#1a1a1a); margin: 4px 0 2px; }
.fitness-ring-goal { font-size: 0.72rem; color: var(--color-text-muted,#888); margin-bottom: 6px; }
.fitness-progress-bar { height: 4px; background: var(--color-surface-2,#f0f0f0); border-radius: 2px; overflow: hidden; }
.fitness-progress-fill { height: 100%; background: var(--color-primary,#2e86c1); border-radius: 2px; transition: width 0.6s ease; }
.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,#888); margin: 4px 0 12px; }
.health-native-notice { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 12px; }
.health-native-card { display: flex; align-items: flex-start; gap: 8px; padding: 9px 12px; border-radius: 10px; background: var(--color-surface-2, #f4f9f6); border: 1px solid var(--color-border, #e0e0e0); font-size: 0.82rem; color: var(--color-text-muted, #666); line-height: 1.45; }
.health-native-card svg { flex-shrink: 0; margin-top: 2px; opacity: 0.5; }
.workout-entry { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: var(--card-bg,#fff); border-radius: 10px; margin-bottom: 6px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.workout-entry-type { font-weight: 700; font-size: 0.9rem; text-transform: capitalize; color: var(--color-text,#1a1a1a); }
.workout-entry-detail { font-size: 0.78rem; color: var(--color-text-muted,#888); margin-top: 2px; }
.workout-entry-info { display: flex; flex-direction: column; }
/* Activity rings */
.activity-rings-section { background: var(--card-bg,#fff); border-radius: 18px; padding: 16px; margin: 0 0 14px; 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; }
.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; }
.ar-track { stroke: rgba(0,0,0,0.08); }
.ar-move { stroke: #ff375f; }
.ar-exercise { stroke: #92e82a; }
.ar-stand { stroke: #1fe0ff; }
.ar-ring { transition: stroke-dasharray 1s cubic-bezier(0.16,1,0.3,1); }
.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); }
.ar-legend-val { font-size: 0.7rem; color: var(--color-text-muted,#888); }
.ar-legend-pct { font-size: 0.78rem; font-weight: 800; min-width: 36px; text-align: right; }
/* Oura panel */
.oura-connect-panel { margin-top: 10px; border: 1.5px solid #d1e0f0; border-radius: 14px; overflow: hidden; background: var(--card-bg,#fff); }
.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; }
.oura-panel-desc, .oura-panel-hint { font-size: 0.875rem; color: var(--color-text-muted,#666); margin: 0 0 8px; line-height: 1.5; }
.oura-token-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.oura-token-row .welcome-input { flex: 1; font-size: 0.85rem; }
.oura-connect-status { font-size: 0.82rem; min-height: 18px; margin-bottom: 4px; color: var(--color-text-muted,#666); }
.oura-connect-status.success { color: #2e86c1; font-weight: 600; }
.oura-connect-status.error { color: #c0392b; }
.oura-data-preview { margin-top: 12px; padding: 12px; background: rgba(46,134,193,0.05); border-radius: 10px; border: 1px solid #c8dff0; }
.oura-data-preview.hidden { display: none; }
.oura-preview-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; }
.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: #2e86c1; }
.oura-preview-lbl { display: block; font-size: 0.7rem; color: var(--color-text-muted,#888); margin-top: 2px; }
.sync-connected { border-color: #2e86c1 !important; color: #2e86c1 !important; background: rgba(46,134,193,0.06) !important; }

/* ================================================================
   POST-OP STAGE PROFILES — Bariatric Health v1.8.25
   ================================================================ */
.stage-btn-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.stage-btn { padding: 6px 12px; border-radius: 20px; border: 1.5px solid var(--color-border,#ddd); background: var(--color-surface-2,#f5f5f5); color: var(--color-text,#333); font-size: 0.82rem; font-weight: 600; cursor: pointer; transition: all 0.15s; }
.stage-btn.active { border-color: var(--color-primary,#2e86c1); background: var(--color-primary,#2e86c1); color: white; }
.stage-hint { font-size: 0.78rem; color: var(--color-text-muted,#888); margin-top: 6px; line-height: 1.4; }

/* ══════════════════════════════════════════════════════════════
   SURGERY TYPE SELECTOR
   ══════════════════════════════════════════════════════════════ */
#surgeryTypeGroup {
  margin-top: 12px;
}
#surgeryTypeHint {
  font-size: var(--text-xs, 0.78rem);
  color: var(--color-text-muted);
  line-height: 1.4;
  min-height: 1.2em;
}

/* ══════════════════════════════════════════════════════════════
   LOG TAB — Sub-tab bar (Add Meal / Scan / Meal Plan)
   ══════════════════════════════════════════════════════════════ */
.log-subtab-bar {
  display: flex;
  gap: 0;
  background: var(--color-surface-2, #f0f0f0);
  border-radius: 12px;
  padding: 4px;
  margin: 0 0 14px;
}
.log-subtab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--color-text-muted, #666);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
  white-space: nowrap;
}
.log-subtab.active {
  background: var(--card-bg, #fff);
  color: var(--color-primary, #1a5c3a);
  box-shadow: 0 1px 4px rgba(0,0,0,0.10);
}
.log-subtab svg {
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════════
   ME TAB — Sub-tab bar (Profile / Goals / Summary)
   ══════════════════════════════════════════════════════════════ */
.me-subtab-bar {
  display: flex;
  gap: 0;
  background: var(--color-surface-2, #f0f0f0);
  border-radius: 12px;
  padding: 4px;
  margin: 0 0 16px;
}
.me-subtab {
  flex: 1;
  padding: 8px 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--color-text-muted, #666);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
  text-align: center;
}
.me-subtab.active {
  background: var(--card-bg, #fff);
  color: var(--color-primary, #1a5c3a);
  box-shadow: 0 1px 4px rgba(0,0,0,0.10);
}

/* ══════════════════════════════════════════════════════════════
   CARE TEAM TAB
   ══════════════════════════════════════════════════════════════ */
.ct-header {
  padding: 20px 0 8px;
  text-align: center;
}
.ct-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--color-text, #1a1a1a);
  margin: 0 0 4px;
}
.ct-subtitle {
  font-size: 0.84rem;
  color: var(--color-text-muted, #666);
  margin: 0;
}
.ct-section {
  background: var(--card-bg, #fff);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 5px rgba(0,0,0,0.06);
}
.ct-section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-text-muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}
/* Contacts */
.ct-contacts {
  margin-bottom: 10px;
}
.ct-contact-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--color-border, #eee);
}
.ct-contact-row:last-child {
  border-bottom: none;
}
.ct-contact-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-text-muted, #888);
  min-width: 140px;
  flex-shrink: 0;
}
.ct-contact-value {
  font-size: 0.88rem;
  color: var(--color-text, #1a1a1a);
  word-break: break-all;
}
.ct-empty {
  font-size: 0.84rem;
  color: var(--color-text-muted, #999);
  font-style: italic;
  margin: 4px 0 10px;
  text-align: center;
}
/* Edit button */
.ct-edit-btn {
  margin-top: 4px;
}
/* Edit form */
.ct-edit-form {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--color-border, #eee);
}
.ct-edit-form.hidden {
  display: none;
}
.ct-field {
  margin-bottom: 10px;
}
.ct-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
/* Row buttons (liquid diet, forms, sharing) */
.ct-row-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--color-surface-2, #f7f7f7);
  border: 1.5px solid var(--color-border, #e8e8e8);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-align: left;
}
.ct-row-btn:last-child {
  margin-bottom: 0;
}
.ct-row-btn:hover,
.ct-row-btn:focus {
  background: var(--color-surface-3, #f0f6f2);
  border-color: var(--color-primary, #1a5c3a);
  outline: none;
}
.ct-row-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ct-row-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-text, #1a1a1a);
}
.ct-row-sub {
  font-size: 0.76rem;
  color: var(--color-text-muted, #888);
}
/* Share section */
.ct-share-hint {
  font-size: 0.8rem;
  color: var(--color-text-muted, #888);
  margin-bottom: 12px;
  padding: 8px 10px;
  background: var(--color-surface-2, #f5f8f5);
  border-radius: 8px;
  border-left: 3px solid var(--color-primary, #1a5c3a);
}
/* Journal export date range */
.ct-journal-export {
  background: var(--color-surface-2, #f7f7f7);
  border: 1.5px solid var(--color-border, #e8e8e8);
  border-radius: 12px;
  margin-bottom: 8px;
  overflow: hidden;
}
.ct-date-range {
  display: flex;
  gap: 10px;
  padding: 8px 14px 4px;
}
.ct-date-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ct-date-field label {
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--color-text-muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ct-date-field input[type="date"] {
  font-size: 0.84rem;
  padding: 6px 8px;
  border: 1.5px solid var(--color-border, #ddd);
  border-radius: 8px;
  background: var(--card-bg, #fff);
  color: var(--color-text, #1a1a1a);
  width: 100%;
  box-sizing: border-box;
}
.ct-export-actions {
  display: flex;
  gap: 8px;
  padding: 10px 14px 12px;
}
.ct-export-actions .btn {
  flex: 1;
  font-size: 0.8rem;
}
/* Share history */
.ct-share-history {
  margin-top: 12px;
}
.ct-history-label {
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--color-text-muted, #999);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.ct-history-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid var(--color-border, #f0f0f0);
  gap: 8px;
}
.ct-history-row:last-child {
  border-bottom: none;
}
.ct-history-type {
  font-size: 0.81rem;
  font-weight: 600;
  color: var(--color-text, #1a1a1a);
}
.ct-history-meta {
  font-size: 0.74rem;
  color: var(--color-text-muted, #aaa);
  text-align: right;
}

/* ══════════════════════════════════════════════════════════════
   LEARN TAB — Phase 4 placeholder
   ══════════════════════════════════════════════════════════════ */
.learn-coming-soon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 32px;
  min-height: 60vh;
  gap: 14px;
}
.learn-cs-icon {
  width: 80px;
  height: 80px;
  background: var(--color-surface-2, #f0f5f0);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}
.learn-cs-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--color-text, #1a1a1a);
  margin: 0;
}
.learn-cs-body {
  font-size: 0.9rem;
  color: var(--color-text-muted, #666);
  max-width: 280px;
  line-height: 1.6;
  margin: 0;
}
.learn-cs-badge {
  display: inline-block;
  padding: 6px 18px;
  background: var(--color-primary, #1a5c3a);
  color: #fff;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-top: 6px;
}

/* ══════════════════════════════════════════════════════════════
   FORM MODALS — PHQ-9, GAD-7, Participation Agreement
   ══════════════════════════════════════════════════════════════ */
.form-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  backdrop-filter: blur(2px);
}
.form-modal-overlay.hidden {
  display: none;
}
.form-modal-card {
  background: var(--card-bg, #fff);
  border-radius: 22px 22px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -4px 30px rgba(0,0,0,0.18);
  animation: slideUpModal 0.28s cubic-bezier(0.16,1,0.3,1);
}
@keyframes slideUpModal {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.form-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--color-border, #eee);
  flex-shrink: 0;
}
.form-modal-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--color-text, #1a1a1a);
  margin: 0;
  line-height: 1.3;
  max-width: calc(100% - 36px);
}
.form-modal-close {
  background: var(--color-surface-2, #f0f0f0);
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  color: var(--color-text-muted, #666);
  transition: background 0.15s;
}
.form-modal-close:hover {
  background: var(--color-border, #e0e0e0);
}
.form-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  -webkit-overflow-scrolling: touch;
}
.form-modal-footer {
  display: flex;
  gap: 8px;
  padding: 14px 20px 20px;
  border-top: 1px solid var(--color-border, #eee);
  flex-shrink: 0;
}
.form-modal-footer .btn {
  flex: 1;
}
/* Form intro */
.form-intro {
  font-size: 0.88rem;
  color: var(--color-text-muted, #666);
  margin: 0 0 12px;
  line-height: 1.5;
}
.form-scale-legend {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--color-text-muted, #888);
  background: var(--color-surface-2, #f5f5f5);
  border-radius: 8px;
  padding: 6px 10px;
  margin-bottom: 14px;
  gap: 4px;
}
.form-question {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--color-border, #f0f0f0);
}
.form-question:last-child {
  border-bottom: none;
}
.form-q-text {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-text, #1a1a1a);
  margin-bottom: 10px;
  line-height: 1.45;
}
.form-q-options {
  display: flex;
  gap: 8px;
}
.form-q-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.form-q-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.form-q-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 2px solid var(--color-border, #ddd);
  background: var(--color-surface-2, #f5f5f5);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-text-muted, #888);
  transition: all 0.15s;
}
.form-q-option input[type="radio"]:checked + span {
  border-color: var(--color-primary, #1a5c3a);
  background: var(--color-primary, #1a5c3a);
  color: #fff;
}
/* Signed badge */
.form-signed-badge {
  display: inline-block;
  margin-top: 12px;
  padding: 6px 14px;
  background: rgba(26,92,58,0.10);
  color: var(--color-primary, #1a5c3a);
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
}
/* Participation agreement text */
.participation-text {
  font-size: 0.86rem;
  color: var(--color-text, #333);
  line-height: 1.65;
  background: var(--color-surface-2, #f7f9f7);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 10px 0;
  border-left: 3px solid var(--color-primary, #1a5c3a);
}
.participation-text ul {
  margin: 8px 0 8px 16px;
  padding: 0;
}
.participation-text li {
  margin-bottom: 6px;
}

/* ══════════════════════════════════════════════════════════════
   LOG PANEL SECTIONS (scanner, menu — inside Log tab panels)
   ══════════════════════════════════════════════════════════════ */
.log-panel-section {
  display: block;
}

/* ================================================================
   ACTIVITY 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;
}
.ar-track { stroke: rgba(0,0,0,0.08); }
@media (prefers-color-scheme: dark) {
  .ar-track { stroke: rgba(255,255,255,0.1); }
}
.ar-move    { stroke: #ff375f; }
.ar-exercise{ stroke: #92e82a; }
.ar-stand   { stroke: #1fe0ff; }
.ar-ring {
  transition: stroke-dasharray 1s cubic-bezier(0.16, 1, 0.3, 1);
}
.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;
}

/* Home link (back to purebariatric.com) */
.app-header .home-link {
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: 999px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.app-header .home-link:hover {
  background: var(--color-primary-light, #e8f1ed);
  border-color: var(--color-primary, #1a6b52);
  color: var(--color-primary, #1a6b52);
}
@media (max-width: 480px) {
  .app-header .home-link .home-link-text { display: none; }
  .app-header .home-link { padding: 8px !important; }
}

/* ================================================================
   v1.9.13 — SAFETY TAB
   Emergency Contacts, Medical ID, Red-Tier Escalation, SBAR
   ================================================================ */

/* Safety nav button — subtle red accent so it reads "urgent help here" */
.nav-item-safety svg { stroke: #c83232; }
.nav-item-safety.active svg { stroke: #a01818; }
.nav-item-safety.active { color: #a01818; }

/* Safety tab outer container */
#view-safety { padding: var(--space-3, 12px); padding-bottom: 100px; }
.safety-section {
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #e5e0d6);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.safety-section h2 {
  font-size: 1.05rem;
  margin: 0 0 4px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-text, #2a2a2a);
}
.safety-section h3 {
  font-size: 0.95rem;
  margin: 0 0 10px 0;
  color: var(--color-text, #2a2a2a);
}
.safety-section-sub {
  font-size: 0.85rem;
  color: var(--color-text-muted, #777);
  margin: 0 0 12px 0;
  line-height: 1.45;
}

/* Hero banner — quick access actions at top of Safety tab */
.safety-hero {
  background: linear-gradient(135deg, #fff5f5 0%, #ffeaea 100%);
  border: 1px solid #f1c8c8;
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
}
.safety-hero-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 4px 0;
  color: #8a1818;
}
.safety-hero-sub {
  font-size: 0.85rem;
  color: #6a3a3a;
  margin: 0 0 12px 0;
  line-height: 1.4;
}
.safety-hero-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* CTA buttons */
.safety-cta-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 8px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  min-height: 64px;
  transition: transform 0.05s ease, box-shadow 0.15s ease;
}
.safety-cta-btn:active { transform: scale(0.97); }
.safety-cta-911 {
  background: #c41e1e;
  color: #fff;
  border-color: #a01818;
  box-shadow: 0 2px 6px rgba(196,30,30,0.25);
}
.safety-cta-988 {
  background: #fff;
  color: #8a1818;
  border-color: #d9a0a0;
}
.safety-cta-er {
  background: #d97a1c;
  color: #fff;
  border-color: #b66318;
}
.safety-cta-symptom {
  background: var(--color-primary, #0a6e6b);
  color: #fff;
  border-color: var(--color-primary, #0a6e6b);
}
.safety-cta-symptom:hover, .safety-cta-911:hover, .safety-cta-988:hover, .safety-cta-er:hover {
  filter: brightness(1.05);
}
.safety-cta-btn-large {
  display: block;
  width: 100%;
  padding: 14px;
  margin-top: 10px;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 12px;
  border: none;
  background: var(--color-primary, #0a6e6b);
  color: #fff;
  cursor: pointer;
}
.safety-cta-btn-large:active { transform: scale(0.98); }

/* Emergency contact card list */
.safety-contact-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.safety-contact-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #fafaf6;
  border: 1px solid var(--color-border, #e5e0d6);
  border-radius: 10px;
}
.safety-contact-priority {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-primary, #0a6e6b);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}
.safety-contact-main { flex: 1; min-width: 0; }
.safety-contact-name { font-weight: 600; color: var(--color-text, #2a2a2a); font-size: 0.95rem; }
.safety-contact-rel { font-size: 0.8rem; color: var(--color-text-muted, #777); }
.safety-contact-phone { font-size: 0.85rem; color: var(--color-text-muted, #555); margin-top: 2px; }
.safety-contact-actions { display: flex; gap: 6px; flex-shrink: 0; }
.safety-call-btn {
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.safety-call-btn:active { transform: scale(0.97); }
.safety-edit-btn {
  background: transparent;
  color: var(--color-text-muted, #555);
  border: 1px solid var(--color-border, #d4cfc4);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.8rem;
  cursor: pointer;
}

/* Empty state */
.safety-empty-state {
  text-align: center;
  padding: 18px 10px;
  color: var(--color-text-muted, #888);
  font-size: 0.9rem;
}

/* Medical ID card */
.safety-medid-summary {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  font-size: 0.88rem;
  margin-bottom: 10px;
}
.safety-medid-summary dt { font-weight: 600; color: var(--color-text-muted, #555); }
.safety-medid-summary dd { margin: 0; color: var(--color-text, #2a2a2a); }
.safety-medid-fullscreen {
  position: fixed;
  inset: 0;
  background: #c41e1e;
  color: #fff;
  z-index: 9999;
  overflow-y: auto;
  padding: 24px 20px;
}
.safety-medid-fullscreen-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.safety-medid-fullscreen-header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}
.safety-medid-close {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.5);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
}
.safety-medid-fullscreen-card {
  background: #fff;
  color: #2a2a2a;
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 16px;
}
.safety-medid-fullscreen-card h2 {
  font-size: 1rem;
  margin: 0 0 10px 0;
  color: #8a1818;
  border-bottom: 1px solid #f1c8c8;
  padding-bottom: 6px;
}
.safety-medid-fullscreen .safety-medid-summary { font-size: 1rem; }

/* Modal overlays — shared by edit modal, redtier modal, SBAR modal, MedID fullscreen */
.safety-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 9998;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.safety-modal-overlay.hidden { display: none; }
.safety-modal-box {
  width: 100%;
  max-width: 480px;
  background: var(--color-surface, #fff);
  border-radius: 18px 18px 0 0;
  padding: 20px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 -10px 40px rgba(0,0,0,0.2);
}
@media (min-width: 600px) {
  .safety-modal-overlay { align-items: center; }
  .safety-modal-box { border-radius: 16px; max-height: 86vh; }
}
.safety-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.safety-modal-header h2 { margin: 0; font-size: 1.1rem; }
.safety-modal-close {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  color: var(--color-text-muted, #777);
  cursor: pointer;
  padding: 4px 8px;
}
.safety-form-field {
  margin-bottom: 12px;
}
.safety-form-field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text, #2a2a2a);
  margin-bottom: 4px;
}
.safety-form-field input,
.safety-form-field textarea,
.safety-form-field select {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--color-border, #d4cfc4);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
  color: var(--color-text, #2a2a2a);
  box-sizing: border-box;
}
.safety-form-field input:focus,
.safety-form-field textarea:focus,
.safety-form-field select:focus {
  outline: 2px solid var(--color-primary, #0a6e6b);
  outline-offset: -1px;
}
.safety-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.safety-form-actions button { flex: 1; padding: 12px; border-radius: 10px; font-weight: 600; cursor: pointer; font-size: 0.95rem; border: 1px solid transparent; }
.safety-btn-primary { background: var(--color-primary, #0a6e6b); color: #fff; border-color: var(--color-primary, #0a6e6b); }
.safety-btn-danger { background: #c41e1e; color: #fff; border-color: #a01818; }
.safety-btn-ghost { background: #fff; color: var(--color-text, #2a2a2a); border-color: var(--color-border, #d4cfc4); }

/* Red-tier escalation modal — full-screen, alarm-styled */
.safety-redtier-overlay {
  position: fixed;
  inset: 0;
  background: #c41e1e;
  z-index: 9999;
  overflow-y: auto;
  padding: 28px 20px;
  color: #fff;
}
.safety-redtier-overlay.hidden { display: none; }
.safety-redtier-header { text-align: center; margin-bottom: 18px; }
.safety-redtier-header h1 { font-size: 1.5rem; margin: 0 0 4px 0; font-weight: 800; }
.safety-redtier-header p { margin: 0; font-size: 0.95rem; opacity: 0.92; }
.safety-redtier-symptoms {
  background: rgba(255,255,255,0.13);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 16px;
}
.safety-redtier-symptoms h3 { margin: 0 0 6px 0; font-size: 0.95rem; }
.safety-redtier-symptoms ul { margin: 0; padding-left: 20px; font-size: 0.9rem; line-height: 1.5; }
.safety-redtier-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.safety-redtier-action-btn {
  display: block;
  width: 100%;
  padding: 16px;
  background: #fff;
  color: #c41e1e;
  border: 2px solid #fff;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.safety-redtier-action-btn:active { transform: scale(0.98); }
.safety-redtier-action-btn-988 {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border-color: rgba(255,255,255,0.7);
}
.safety-redtier-action-btn-secondary {
  background: transparent;
  color: #fff;
  border-color: rgba(255,255,255,0.7);
  font-weight: 600;
}
.safety-redtier-sbar-summary {
  background: rgba(255,255,255,0.13);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 16px;
  font-size: 0.85rem;
  line-height: 1.5;
}
.safety-redtier-sbar-summary h3 { margin: 0 0 8px 0; font-size: 0.95rem; }
.safety-redtier-sbar-summary p { margin: 4px 0; }
.safety-redtier-dismiss {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.5);
  color: rgba(255,255,255,0.85);
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  display: block;
  margin: 14px auto 0;
  font-size: 0.85rem;
}

/* SBAR viewer */
.safety-sbar-voice-toggle {
  display: flex;
  background: #f3f1ea;
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 12px;
  border: 1px solid var(--color-border, #d4cfc4);
}
.safety-sbar-voice-toggle button {
  flex: 1;
  padding: 8px;
  background: transparent;
  border: none;
  border-radius: 7px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--color-text-muted, #555);
}
.safety-sbar-voice-toggle button.active {
  background: #fff;
  color: var(--color-text, #2a2a2a);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.safety-sbar-text {
  background: #fafaf6;
  border: 1px solid var(--color-border, #e5e0d6);
  border-radius: 10px;
  padding: 14px;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--color-text, #2a2a2a);
  white-space: pre-wrap;
  font-family: inherit;
  margin-bottom: 10px;
}
.safety-sbar-section { margin-bottom: 8px; }
.safety-sbar-section strong { display: block; color: #8a1818; margin-bottom: 2px; }

/* Disclaimer block */
.safety-disclaimer {
  font-size: 0.75rem;
  color: var(--color-text-muted, #777);
  line-height: 1.4;
  padding: 10px;
  background: #fafaf6;
  border-left: 3px solid var(--color-primary, #0a6e6b);
  border-radius: 6px;
  margin-top: 12px;
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
  .safety-hero { background: linear-gradient(135deg, #2a1818 0%, #3a1c1c 100%); border-color: #4a2828; }
  .safety-hero-title { color: #ffb8b8; }
  .safety-hero-sub { color: #d4a4a4; }
  .safety-contact-card { background: #2a2a2a; border-color: #3a3a3a; }
  .safety-sbar-text, .safety-disclaimer { background: #2a2a2a; }
  .safety-sbar-voice-toggle { background: #2a2a2a; }
  .safety-sbar-voice-toggle button.active { background: #3a3a3a; color: #f0e8d8; }
}

/* Symptom Log specific styles (v1.9.13 \u2014 BRSS-driven) */
.symptom-list { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.symptom-group {
  background: #fafaf6;
  border: 1px solid var(--color-border, #e5e0d6);
  border-radius: 10px;
  padding: 12px;
}
.symptom-group-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted, #777);
  margin-bottom: 8px;
}
.symptom-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 6px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.92rem;
  line-height: 1.4;
  color: var(--color-text, #2a2a2a);
}
.symptom-option:hover { background: rgba(0,0,0,0.03); }
.symptom-option input[type="checkbox"] {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  accent-color: var(--color-primary, #0a6e6b);
  cursor: pointer;
}
.symptom-alert {
  border-radius: 10px;
  padding: 12px;
  margin: 4px 0 12px 0;
  font-size: 0.9rem;
  line-height: 1.45;
}
.symptom-alert-urgent {
  background: #fff5f5;
  border: 1px solid #f1a8a8;
  color: #8a1818;
}
.symptom-alert-soon {
  background: #fff8eb;
  border: 1px solid #e0c280;
  color: #6b4a10;
}
.symptom-alert-checkin {
  background: #eff7f6;
  border: 1px solid #b8d8d4;
  color: #0a6e6b;
}

@media (prefers-color-scheme: dark) {
  .symptom-group { background: #2a2a2a; border-color: #3a3a3a; }
  .symptom-alert-urgent { background: #3a1818; border-color: #6a2828; color: #ffb8b8; }
  .symptom-alert-soon   { background: #3a2c10; border-color: #6a5018; color: #f8d488; }
  .symptom-alert-checkin{ background: #182a28; border-color: #2a4a48; color: #88d4cc; }
}

/* Symptom Check CTA button on Safety tab \u2014 layout fixes (v1.9.13) */
.safety-section-primary .safety-cta-btn {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--color-primary, #0a6e6b);
  background: linear-gradient(135deg, rgba(10,110,107,0.07) 0%, rgba(10,110,107,0.02) 100%);
  color: var(--color-text, #2a2a2a);
  text-align: left;
  min-height: 0;
}
.safety-section-primary .safety-cta-btn:active { transform: scale(0.99); }
.safety-cta-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.safety-cta-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-primary, #0a6e6b);
  line-height: 1.2;
}
.safety-cta-sub {
  font-size: 0.83rem;
  font-weight: 400;
  color: var(--color-text-muted, #555);
  line-height: 1.35;
}
.safety-section-primary .safety-cta-btn svg {
  flex-shrink: 0;
  color: var(--color-primary, #0a6e6b);
  margin-left: 10px;
}

/* Section labels with inline icon */
.safety-section-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text, #2a2a2a);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px 0;
}
.safety-section-note {
  font-size: 0.8rem;
  color: var(--color-text-muted, #777);
  margin: 0 0 12px 0;
  line-height: 1.4;
}
.safety-subtitle {
  font-size: 0.88rem;
  color: var(--color-text-muted, #777);
  margin: 4px 0 16px 0;
  line-height: 1.4;
}
.safety-empty-hint {
  font-size: 0.82rem;
  color: var(--color-text-muted, #888);
  margin-top: 4px;
}
.safety-medid-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}
.safety-medid-actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.safety-medid-actions .btn,
.safety-medid-actions .safety-edit-btn {
  flex: 1 1 auto;
  white-space: nowrap;
}

/* ============================================================
   v1.9.13 Stage A — Polish pass 3
   Maps CSS to actual class names rendered in safety.js
   ============================================================ */

/* Red-tier overlay: top-of-screen visibility, safe area handling */
.safety-redtier-overlay {
  padding: max(env(safe-area-inset-top, 0px), 20px) 16px max(env(safe-area-inset-bottom, 0px), 20px) 16px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  -webkit-overflow-scrolling: touch;
}
.safety-redtier-box {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}

/* Red-tier header (uses .safety-redtier-title / -subtitle classes) */
.safety-redtier-title {
  font-size: 1.45rem;
  margin: 0 0 6px 0;
  font-weight: 800;
  text-align: center;
  line-height: 1.2;
}
.safety-redtier-subtitle {
  margin: 0 0 18px 0;
  font-size: 1rem;
  text-align: center;
  opacity: 0.95;
  font-weight: 600;
}

/* Red-tier flags panel (new class name: .safety-redtier-flags) */
.safety-redtier-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.safety-redtier-flags {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 12px;
  padding: 12px 14px;
}
.safety-redtier-flags-label {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  opacity: 0.9;
}
.safety-redtier-flags-list {
  margin: 0;
  padding-left: 20px;
  font-size: 0.95rem;
  line-height: 1.55;
}
.safety-redtier-flags-list li {
  margin-bottom: 2px;
}

/* Red-tier action buttons (new class name: .safety-redtier-btn) */
.safety-redtier-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.safety-redtier-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  background: #ffffff;
  color: #c41e1e;
  border: 2px solid #ffffff;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 700;
  box-sizing: border-box;
  min-height: 64px;
  transition: transform 0.08s ease;
}
.safety-redtier-btn:active { transform: scale(0.98); }
.safety-redtier-btn-icon {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}
.safety-redtier-btn-icon svg {
  width: 28px;
  height: 28px;
}
.safety-redtier-btn-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  text-align: left;
  min-width: 0;
}
.safety-redtier-btn-label {
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.2;
  word-break: break-word;
}
.safety-redtier-btn-sub {
  font-size: 0.85rem;
  font-weight: 500;
  margin-top: 2px;
  opacity: 0.85;
  word-break: break-word;
}
.safety-redtier-btn-988 {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.7);
}
.safety-redtier-btn-988 .safety-redtier-btn-sub { opacity: 0.95; }
.safety-redtier-btn-contact,
.safety-redtier-btn-careteam {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.55);
}

/* Red-tier SBAR details block */
.safety-redtier-sbar {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  padding: 12px 14px;
}
.safety-redtier-sbar > summary.safety-redtier-sbar-summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 0.95rem;
  list-style: none;
  padding: 0;
  background: transparent;
  border: none;
  color: #ffffff;
  margin-bottom: 10px;
}
.safety-redtier-sbar > summary.safety-redtier-sbar-summary::-webkit-details-marker { display: none; }
.safety-redtier-sbar[open] > summary.safety-redtier-sbar-summary {
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.25);
  padding-bottom: 8px;
}
.safety-redtier-sbar .safety-sbar-text {
  background: #ffffff;
  color: #2a2a2a;
  border: none;
  font-size: 0.88rem;
}

/* SBAR voice toggle (radio + label layout — fixes overflow on narrow screens) */
.safety-sbar-voice-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 10px;
  padding: 6px;
  margin-bottom: 12px;
  border: 1px solid rgba(255, 255, 255, 0.4);
}
.safety-sbar-voice-toggle label {
  flex: 1 1 140px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: transparent;
  border-radius: 7px;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  color: #2a2a2a;
  line-height: 1.25;
  word-break: break-word;
  min-height: 36px;
}
.safety-sbar-voice-toggle label:has(input:checked) {
  background: #c41e1e;
  color: #ffffff;
}
.safety-sbar-voice-toggle input[type="radio"] {
  flex: 0 0 auto;
  margin: 0;
  accent-color: #c41e1e;
}

/* Red-tier disclaimer + footer */
.safety-redtier-disclaimer {
  font-size: 0.82rem;
  line-height: 1.5;
  opacity: 0.92;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 4px;
}
.safety-redtier-footer {
  margin-top: 18px;
  display: flex;
  justify-content: center;
  padding-bottom: 8px;
}
.safety-redtier-dismiss-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.55);
  color: rgba(255, 255, 255, 0.92);
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
}
.safety-redtier-dismiss-btn:active { transform: scale(0.98); }

/* Dark mode adjustments for new polish */
@media (prefers-color-scheme: dark) {
  .safety-sbar-voice-toggle { background: rgba(40, 40, 40, 0.95); border-color: rgba(255,255,255,0.2); }
  .safety-sbar-voice-toggle label { color: #f0e8d8; }
  .safety-redtier-sbar .safety-sbar-text { background: #f5f1e8; color: #2a2a2a; }
}

/* ============================================================
   v1.9.13 Stage B — Daily Habits & Streaks card
   ============================================================ */
.daily-habits-section {
  margin: 16px 0 8px 0;
}
.daily-habits-card {
  background: var(--color-surface, #ffffff);
  border: 1px solid var(--color-border, #e5e0d6);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.daily-habits-card:empty {
  display: none;
}
.streak-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border-light, #f0ebe0);
}
.streak-counter-block {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.streak-counter {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--color-text, #2a2a2a);
  letter-spacing: -0.02em;
}
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: linear-gradient(135deg, #fff4d1 0%, #ffe4a1 100%);
  border: 1px solid #e6c878;
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #6b4d1a;
}
.streak-nudge {
  font-size: 0.82rem;
  color: var(--color-text-muted, #6b6b6b);
  line-height: 1.4;
}
.streak-checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.streak-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #fafaf6;
  border: 1px solid var(--color-border-light, #f0ebe0);
  border-radius: 10px;
  font-size: 0.92rem;
  color: var(--color-text, #2a2a2a);
  transition: all 0.15s ease;
}
.streak-item.done {
  background: #ecf6ee;
  border-color: #c8e6c9;
  color: #1b5e20;
}
.streak-check {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text-muted, #9b9b9b);
}
.streak-item.done .streak-check {
  color: #2e7d32;
}
.streak-complete-banner {
  margin-top: 12px;
  padding: 10px 12px;
  background: linear-gradient(135deg, #e8f5e9 0%, #d6efd9 100%);
  border: 1px solid #a5d6a7;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #1b5e20;
  text-align: center;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  .daily-habits-card { background: #1f1f1f; border-color: #2f2f2f; }
  .streak-counter { color: #f0e8d8; }
  .streak-nudge { color: #b8b8b8; }
  .streak-item { background: #2a2a2a; border-color: #3a3a3a; color: #f0e8d8; }
  .streak-item.done { background: rgba(46, 125, 50, 0.2); border-color: #2e7d32; color: #a5d6a7; }
  .streak-item.done .streak-check { color: #81c784; }
  .streak-complete-banner { background: rgba(46, 125, 50, 0.18); border-color: #2e7d32; color: #a5d6a7; }
  .streak-badge { background: linear-gradient(135deg, #4a3e1a 0%, #6b551e 100%); border-color: #8b6f2a; color: #ffd97a; }
}

/* ============================================================
   v1.9.13.2 — Daily Habits streak opt-in toggle
   Default: collapsed. User opts in via the toggle.
   ============================================================ */
.streak-toggle-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin: -4px 0 0 0;
}
.streak-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  padding: 6px 4px;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--color-text, #2a2a2a);
  border-radius: 6px;
  -webkit-tap-highlight-color: rgba(0,0,0,0.04);
}
.streak-toggle-btn:hover {
  background: rgba(0, 0, 0, 0.03);
}
.streak-toggle-btn:focus-visible {
  outline: 2px solid var(--color-accent, #1e7a5c);
  outline-offset: 2px;
}
.streak-toggle-chevron {
  display: inline-block;
  font-size: 0.75rem;
  line-height: 1;
  transition: transform 0.18s ease;
  width: 12px;
  color: var(--color-text-muted, #6b6b6b);
}
.streak-toggle-chevron.open {
  transform: rotate(90deg);
}
.streak-toggle-label {
  letter-spacing: -0.01em;
}
.streak-optin-note {
  margin-top: 6px;
  padding: 10px 12px;
  background: #f7f4ec;
  border: 1px solid var(--color-border-light, #f0ebe0);
  border-radius: 10px;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--color-text-muted, #5b5b5b);
}
.streak-body {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border-light, #f0ebe0);
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  .streak-toggle-btn { color: #f0e8d8; }
  .streak-toggle-btn:hover { background: rgba(255, 255, 255, 0.04); }
  .streak-toggle-chevron { color: #b8b8b8; }
  .streak-optin-note { background: #262626; border-color: #3a3a3a; color: #b8b8b8; }
  .streak-body { border-top-color: #2f2f2f; }
}

/* ================================================================
   v1.9.13.3 — MILESTONES (Me tab subview)
   ================================================================ */
.milestones-content {
  padding: 16px 16px 24px;
}
.milestone-section-title {
  font-size: var(--text-base, 16px);
  font-weight: 600;
  color: var(--color-text, #1f2937);
  margin: 20px 0 12px;
}
.milestone-section-title:first-child {
  margin-top: 4px;
}
.milestone-card-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: 12px;
  background: var(--color-surface, #fff);
}
.milestone-card-preview.earned {
  border-color: var(--color-primary, #1a6b52);
  box-shadow: 0 1px 3px rgba(26, 107, 82, 0.08);
}
.milestone-card-preview.pending {
  opacity: 0.62;
  filter: grayscale(0.4);
}
.milestone-card-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1 1 auto;
  min-width: 0;
}
.milestone-icon {
  font-size: 32px;
  line-height: 1;
  flex: 0 0 auto;
}
.milestone-label {
  font-size: var(--text-sm, 14px);
  font-weight: 600;
  color: var(--color-text, #1f2937);
}
.milestone-sub {
  font-size: var(--text-xs, 12px);
  color: var(--color-text-muted, #6b7280);
  margin-top: 2px;
}
.milestone-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}
.milestone-actions .btn-sm {
  padding: 6px 12px;
  font-size: var(--text-xs, 12px);
  min-width: auto;
}
.milestones-empty {
  font-size: var(--text-sm, 14px);
}

/* Stack actions below the card body on phones so the label has full width */
@media (max-width: 480px) {
  .milestone-card-preview.earned {
    flex-direction: column;
    align-items: stretch;
  }
  .milestone-card-preview.earned .milestone-card-inner {
    width: 100%;
  }
  .milestone-actions {
    justify-content: flex-end;
    margin-top: 8px;
  }
}

/* Share consent modal */
.ms-consent-modal {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.ms-consent-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}
.ms-consent-card {
  position: relative;
  max-width: 420px;
  width: 100%;
  background: var(--color-surface, #fff);
  border-radius: 14px;
  padding: 22px 22px 18px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}
.ms-consent-title {
  font-size: var(--text-lg, 18px);
  font-weight: 700;
  color: var(--color-text, #1f2937);
  margin: 0 0 10px;
}
.ms-consent-body {
  font-size: var(--text-sm, 14px);
  line-height: 1.5;
  color: var(--color-text, #374151);
  margin: 0 0 18px;
}
.ms-consent-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ================================================================
   PROVIDER SHARE (v1.9.13.5) — Modal wizard for PDF report export
   ================================================================ */

.ps-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.ps-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 26, 22, 0.65);
  backdrop-filter: blur(2px);
}

.ps-modal-card {
  position: relative;
  z-index: 1;
  background: var(--color-surface, #fff);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  max-width: 560px;
  width: 100%;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ps-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border, #e5e7e3);
  background: var(--color-bg-soft, #f6f9f7);
}

.ps-modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-text, #1a2e25);
  flex: 1;
}

.ps-close {
  background: transparent;
  border: 0;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--color-text-muted, #5a6e64);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
}

.ps-close:hover { background: rgba(0,0,0,0.05); color: var(--color-text, #1a2e25); }

.ps-modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.ps-modal-body p { margin: 0 0 12px; color: var(--color-text, #1a2e25); line-height: 1.5; }

.ps-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--color-border, #e5e7e3);
  background: var(--color-bg-soft, #f6f9f7);
  flex-wrap: wrap;
}

.ps-modal-actions .btn { min-width: 100px; }

/* Step 1 — range radios */
.ps-range-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.ps-radio {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--color-border, #e5e7e3);
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--color-text, #1a2e25);
  background: #fff;
  transition: border-color 0.15s, background 0.15s;
}

.ps-radio:hover { border-color: var(--color-primary, #1a6b52); }
.ps-radio input[type="radio"] { accent-color: var(--color-primary, #1a6b52); }

/* Step 2 — section toggles */
.ps-toggles {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ps-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--color-text, #1a2e25);
  transition: background 0.15s;
}

.ps-toggle:hover { background: var(--color-bg-soft, #f6f9f7); }
.ps-toggle input[type="checkbox"] { accent-color: var(--color-primary, #1a6b52); width: 18px; height: 18px; }

/* Step 3 — privacy ack */
.ps-privacy-body {
  background: var(--color-bg-soft, #f6f9f7);
  border-left: 3px solid var(--color-primary, #1a6b52);
  padding: 12px 14px;
  border-radius: 0 8px 8px 0;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--color-text, #1a2e25);
}

.ps-toggle-ack {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--color-border, #e5e7e3);
  border-radius: 10px;
  background: #fff;
}

/* Step 4 — preview */
.ps-preview-body { padding: 0; display: flex; }

.ps-preview-frame {
  width: 100%;
  height: 60vh;
  min-height: 360px;
  border: 0;
  background: #f2f2f2;
}

/* Mobile tweaks */
@media (max-width: 480px) {
  .ps-modal { padding: 0; }
  .ps-modal-card {
    border-radius: 0;
    max-height: 100vh;
    height: 100vh;
  }
  .ps-modal-actions { flex-direction: column-reverse; }
  .ps-modal-actions .btn { width: 100%; }
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
  .ps-modal-card { background: #1a2422; }
  .ps-modal-header, .ps-modal-actions { background: #14201d; border-color: #2a3633; }
  .ps-radio, .ps-toggle-ack { background: #14201d; border-color: #2a3633; color: #e5ece8; }
  .ps-privacy-body { background: #14201d; color: #e5ece8; }
  .ps-modal-header h3, .ps-toggle, .ps-modal-body p { color: #e5ece8; }
}

/* ===========================================================
   LEARN TAB — Education Library (v1.9.13.6)
   =========================================================== */
.learn-page {
  max-width: 760px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-4) calc(var(--space-8) + 80px);
  color: var(--color-text);
}
.learn-header { margin-bottom: var(--space-4); }
.learn-h1 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-primary);
  margin: 0 0 var(--space-2);
  letter-spacing: -0.01em;
}
.learn-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 0;
}
.learn-disclaimer {
  background: var(--color-warning-light);
  border-left: 4px solid var(--color-warning);
  padding: var(--space-3) var(--space-4);
  border-radius: 8px;
  font-size: var(--text-sm);
  line-height: 1.45;
  color: var(--color-text);
  margin: var(--space-4) 0;
}
.learn-disclaimer strong { color: var(--color-warning); }

/* Section nav chips */
.learn-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-4) 0 var(--space-6);
}
.learn-chip {
  display: inline-block;
  padding: 6px 12px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}
.learn-chip:hover, .learn-chip:focus {
  background: var(--color-primary);
  color: #fff;
  outline: none;
}

/* Sections */
.learn-section {
  margin: var(--space-6) 0;
  scroll-margin-top: 80px;
}
.learn-h2 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 2px solid var(--color-primary-light);
}
.learn-h3 {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  margin: 0 0 var(--space-2);
}
.learn-h4 {
  font-size: var(--text-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin: var(--space-3) 0 var(--space-1);
}
.learn-h4-pros { color: var(--color-success); }
.learn-h4-cons { color: var(--color-error); }

.learn-list {
  margin: var(--space-1) 0 var(--space-3);
  padding-left: 1.25rem;
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--color-text);
}
.learn-list li { margin-bottom: 4px; }
.learn-pros li::marker { color: var(--color-success); }
.learn-cons li::marker { color: var(--color-error); }

/* Red card (When to call 911) */
.learn-red-card {
  background: var(--color-error-light);
  border: 2px solid var(--color-error);
  border-radius: 12px;
  padding: var(--space-4);
  margin: var(--space-2) 0 var(--space-4);
}
.learn-red-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.learn-red-icon {
  font-size: 1.4rem;
  color: var(--color-error);
  flex: 0 0 auto;
}
.learn-red-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-error);
  margin: 0;
  line-height: 1.25;
}
.learn-red-list {
  margin: var(--space-2) 0 var(--space-3);
  padding-left: 1.25rem;
  color: var(--color-text);
  font-size: var(--text-sm);
  line-height: 1.55;
}
.learn-red-list li { margin-bottom: 4px; }
.learn-red-note {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin: var(--space-2) 0 var(--space-3);
  font-style: italic;
}
.learn-red-btn {
  background: var(--color-error);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
  min-height: 44px;
}
.learn-red-btn:hover, .learn-red-btn:focus {
  background: #a52f25;
  outline: none;
}

/* Cards (procedures, stages, supplements) */
.learn-card {
  background: var(--color-bg-elev, #fff);
  border: 1px solid var(--color-border, #e0e7e2);
  border-radius: 10px;
  margin-bottom: var(--space-2);
  overflow: hidden;
  transition: border-color 0.15s;
}
.learn-card[open] { border-color: var(--color-primary); }
.learn-card-summary {
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  color: var(--color-text);
  min-height: 44px;
  user-select: none;
}
.learn-card-summary::-webkit-details-marker { display: none; }
.learn-card-summary::after {
  content: '+';
  margin-left: auto;
  font-size: 1.3rem;
  color: var(--color-primary);
  font-weight: 300;
  line-height: 1;
}
.learn-card[open] .learn-card-summary::after { content: '−'; }
.learn-card-summary:hover { background: var(--color-primary-light); }

.learn-card-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--color-primary);
  color: #fff;
  border-radius: 50%;
  font-size: var(--text-sm);
  font-weight: 700;
  flex: 0 0 auto;
}
.learn-card-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  flex: 1 1 auto;
  line-height: 1.3;
}
.learn-card-aka {
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--color-text-muted);
  font-style: italic;
}

.learn-card-body {
  padding: 0 var(--space-4) var(--space-4);
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--color-text);
  border-top: 1px solid var(--color-border, #e0e7e2);
  padding-top: var(--space-3);
}
.learn-card-body p { margin: 0 0 var(--space-2); }
.learn-card-status {
  display: inline-block;
  font-size: var(--text-xs);
  background: var(--color-primary-light);
  color: var(--color-primary);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.learn-meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 12px;
  margin: var(--space-3) 0;
  font-size: var(--text-sm);
}
.learn-meta dt { font-weight: 600; color: var(--color-text-muted); }
.learn-meta dd { margin: 0; color: var(--color-text); }

.learn-extlink { margin-top: var(--space-3); font-size: var(--text-sm); }
.learn-extlink a {
  color: var(--color-primary);
  font-weight: 600;
  text-decoration: none;
}
.learn-extlink a:hover { text-decoration: underline; }

/* Supplements intro */
.learn-supp-intro {
  background: var(--color-primary-light);
  border-radius: 10px;
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}
.learn-supp-intro p { font-size: var(--text-sm); line-height: 1.55; margin: var(--space-2) 0; }
.learn-supp-floor {
  background: rgba(255,255,255,0.5);
  padding: var(--space-3);
  border-radius: 8px;
  margin: var(--space-3) 0;
  font-size: var(--text-sm);
}
.learn-supp-footer {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-style: italic;
  margin-top: var(--space-2);
}

/* Mechanics grid */
.learn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-3);
}
.learn-tip-card {
  background: var(--color-bg-elev, #fff);
  border: 1px solid var(--color-border, #e0e7e2);
  border-radius: 10px;
  padding: var(--space-4);
}
.learn-tip-card .learn-h3 {
  color: var(--color-primary);
  margin-bottom: var(--space-2);
}
.learn-tip-card p {
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--color-text);
  margin: 0;
}

/* Timeline */
.learn-timeline {
  list-style: none;
  padding: 0;
  margin: 0;
  position: relative;
}
.learn-timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--color-primary-light);
}
.learn-tl-item {
  position: relative;
  padding-left: 32px;
  padding-bottom: var(--space-4);
}
.learn-tl-item::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 2px solid var(--color-bg);
}
.learn-tl-when {
  font-weight: 700;
  color: var(--color-primary);
  font-size: var(--text-sm);
  margin-bottom: 2px;
}
.learn-tl-what {
  font-size: var(--text-sm);
  color: var(--color-text);
  line-height: 1.5;
}

/* Visits + resources lists */
.learn-visits, .learn-resources {
  list-style: none;
  padding: 0;
  margin: 0;
}
.learn-visits li {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border, #e0e7e2);
  font-size: var(--text-sm);
  line-height: 1.55;
}
.learn-visits li:last-child { border-bottom: none; }
.learn-visits strong { color: var(--color-primary); }

.learn-resources li {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border, #e0e7e2);
}
.learn-resources li:last-child { border-bottom: none; }
.learn-resources a {
  color: var(--color-primary);
  font-weight: 600;
  text-decoration: none;
  font-size: var(--text-sm);
}
.learn-resources a:hover { text-decoration: underline; }
.learn-res-desc {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* Sources footer */
.learn-sources {
  margin-top: var(--space-8);
  padding-top: var(--space-4);
  border-top: 2px solid var(--color-primary-light);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.55;
}
.learn-sources .learn-h2 {
  font-size: var(--text-base);
  margin-bottom: var(--space-2);
}
.learn-disclaimer-footer {
  margin-top: var(--space-2);
  font-style: italic;
}
.learn-toplink {
  display: inline-block;
  margin-top: var(--space-3);
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
  font-size: var(--text-sm);
}
.learn-toplink:hover { text-decoration: underline; }

.learn-empty {
  padding: var(--space-8);
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* Mobile refinements */
@media (max-width: 480px) {
  .learn-page { padding: var(--space-3) var(--space-3) calc(var(--space-8) + 80px); }
  .learn-grid { grid-template-columns: 1fr; }
  .learn-meta { grid-template-columns: 1fr; gap: 2px; }
  .learn-meta dt { margin-top: var(--space-2); }
  .learn-card-summary { padding: var(--space-3); }
  .learn-card-body { padding: var(--space-3); padding-top: var(--space-3); }
}

/* Dark-mode adjustments */
@media (prefers-color-scheme: dark) {
  .learn-card,
  .learn-tip-card {
    background: rgba(255,255,255,0.03);
    border-color: rgba(255,255,255,0.08);
  }
  .learn-card-body {
    border-top-color: rgba(255,255,255,0.08);
  }
  .learn-disclaimer {
    background: rgba(196, 124, 26, 0.15);
  }
  .learn-red-card {
    background: rgba(192, 57, 43, 0.15);
  }
  .learn-supp-intro {
    background: rgba(77, 184, 144, 0.1);
  }
  .learn-supp-floor {
    background: rgba(0,0,0,0.25);
  }
  .learn-visits li,
  .learn-resources li {
    border-bottom-color: rgba(255,255,255,0.08);
  }
}
.dark-mode .learn-card,
.dark-mode .learn-tip-card {
  background: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.08);
}
.dark-mode .learn-card-body { border-top-color: rgba(255,255,255,0.08); }
.dark-mode .learn-disclaimer { background: rgba(196,124,26,0.15); }
.dark-mode .learn-red-card { background: rgba(192,57,43,0.15); }
.dark-mode .learn-supp-intro { background: rgba(77,184,144,0.1); }
.dark-mode .learn-supp-floor { background: rgba(0,0,0,0.25); }
.dark-mode .learn-visits li,
.dark-mode .learn-resources li { border-bottom-color: rgba(255,255,255,0.08); }

/* ===========================================================
   STAGE TRACKER CARD (v1.9.13.7)
   =========================================================== */
.stage-card {
  background: var(--color-bg-elev, #fff);
  border: 1px solid var(--color-border, #e0e7e2);
  border-left: 4px solid var(--color-primary);
  border-radius: 12px;
  padding: var(--space-4);
  margin: var(--space-3) 0 var(--space-4);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.stage-card-empty {
  border-left-color: var(--color-accent, #d4a847);
}
.stage-card-head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.stage-card-icon {
  font-size: 1.5rem;
  line-height: 1;
  flex: 0 0 auto;
}
.stage-card-titles { flex: 1 1 auto; min-width: 0; }
.stage-card-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 2px;
  line-height: 1.25;
}
.stage-card-subtitle {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.4;
}
.stage-card-meta {
  font-size: var(--text-xs);
  color: var(--color-primary);
  margin: 0;
  font-weight: 600;
}
.stage-card-chip-btn {
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid var(--color-border, #e0e7e2);
  color: var(--color-primary);
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font-family: inherit;
  min-height: 32px;
  transition: background 0.15s, border-color 0.15s;
}
.stage-card-chip-btn:hover, .stage-card-chip-btn:focus {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  outline: none;
}

.stage-card-active {
  background: var(--color-primary-light);
  border-radius: 8px;
  padding: var(--space-3);
  margin-bottom: var(--space-3);
}
.stage-card-active-name {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.25;
  margin-bottom: 4px;
}
.stage-card-active-dur {
  font-size: var(--text-xs);
  color: var(--color-text);
  line-height: 1.4;
}
.stage-card-active-dur strong { color: var(--color-text-muted); font-weight: 600; }

.stage-card-goals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.stage-card-goal {
  background: var(--color-bg, #f7f9f8);
  border-radius: 8px;
  padding: var(--space-2) var(--space-3);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.stage-card-goal-num {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1;
}
.stage-card-goal-lab {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  margin-top: 4px;
}

.stage-card-empty-msg {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 0 0 var(--space-3);
}
.stage-card-suggest {
  background: var(--color-primary-light);
  border-radius: 8px;
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stage-card-suggest-tag {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-primary);
}
.stage-card-suggest-name {
  font-size: var(--text-sm);
  color: var(--color-text);
  font-weight: 600;
}

.stage-card-btn {
  display: block;
  width: 100%;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  border: none;
  min-height: 44px;
  margin-bottom: var(--space-3);
  transition: background 0.15s;
}
.stage-card-btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.stage-card-btn-primary:hover, .stage-card-btn-primary:focus {
  background: var(--color-primary-dark, #155f48);
  outline: none;
}

.stage-card-note {
  font-size: var(--text-xs);
  line-height: 1.5;
  border-radius: 6px;
  padding: var(--space-2) var(--space-3);
  margin: var(--space-2) 0;
}
.stage-card-note-info {
  background: var(--color-primary-light);
  color: var(--color-text);
}
.stage-card-note-warn {
  background: var(--color-warning-light);
  color: var(--color-text);
  border-left: 3px solid var(--color-warning);
}
.stage-card-note-icon { font-weight: 700; }

.stage-card-disclaimer {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-style: italic;
  margin: var(--space-2) 0 0;
  line-height: 1.5;
}
.stage-card-link {
  display: inline-block;
  margin-top: var(--space-2);
  color: var(--color-primary);
  font-weight: 600;
  font-size: var(--text-sm);
  text-decoration: none;
}
.stage-card-link:hover { text-decoration: underline; }

/* Stage picker modal */
.stage-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
  animation: stageFadeIn 0.15s ease;
}
.stage-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  pointer-events: none;
}
.stage-modal-card {
  background: var(--color-bg-elev, #fff);
  border-radius: 12px;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: var(--space-5);
  pointer-events: auto;
  position: relative;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  animation: stageSlideUp 0.2s ease;
}
@keyframes stageFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes stageSlideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.stage-modal-close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--color-text-muted);
  cursor: pointer;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-family: inherit;
}
.stage-modal-close:hover { background: var(--color-bg, #f7f9f8); }

.stage-modal-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  margin: 0 var(--space-5) var(--space-2) 0;
  line-height: 1.25;
}
.stage-modal-help {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 0 0 var(--space-4);
  line-height: 1.5;
}

.stage-modal-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.stage-modal-opt {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 2px solid var(--color-border, #e0e7e2);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.stage-modal-opt:hover { background: var(--color-bg, #f7f9f8); }
.stage-modal-opt.is-selected {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}
.stage-modal-opt input[type="radio"] {
  margin-top: 4px;
  accent-color: var(--color-primary);
  flex: 0 0 auto;
}
.stage-modal-opt-icon {
  font-size: 1.4rem;
  line-height: 1;
  flex: 0 0 auto;
}
.stage-modal-opt-body { flex: 1 1 auto; min-width: 0; }
.stage-modal-opt-name {
  display: block;
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--color-text);
  line-height: 1.3;
  margin-bottom: 2px;
}
.stage-modal-opt-tag {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-primary);
  background: rgba(255,255,255,0.7);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 4px;
  vertical-align: middle;
}
.stage-modal-opt-dur {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.4;
}

.stage-modal-disclaimer {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-style: italic;
  background: var(--color-warning-light);
  border-left: 3px solid var(--color-warning);
  padding: var(--space-2) var(--space-3);
  border-radius: 6px;
  margin: var(--space-3) 0;
  line-height: 1.5;
}

.stage-modal-actions {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
}
.stage-modal-btn {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  border: none;
  min-height: 44px;
  transition: background 0.15s;
}
.stage-modal-btn-secondary {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border, #e0e7e2);
}
.stage-modal-btn-secondary:hover { background: var(--color-bg, #f7f9f8); }
.stage-modal-btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.stage-modal-btn-primary:hover, .stage-modal-btn-primary:focus {
  background: var(--color-primary-dark, #155f48);
  outline: none;
}

/* Mobile refinements */
@media (max-width: 480px) {
  .stage-card { padding: var(--space-3); }
  .stage-card-goals { grid-template-columns: 1fr 1fr; }
  .stage-modal-card { padding: var(--space-4); }
  .stage-modal-actions { flex-direction: column-reverse; }
  .stage-modal-actions .stage-modal-btn { width: 100%; }
}

/* Dark-mode adaptations */
@media (prefers-color-scheme: dark) {
  .stage-card {
    background: rgba(255,255,255,0.03);
    border-color: rgba(255,255,255,0.08);
  }
  .stage-card-active { background: rgba(77, 184, 144, 0.12); }
  .stage-card-goal { background: rgba(0,0,0,0.25); }
  .stage-card-suggest { background: rgba(77, 184, 144, 0.12); }
  .stage-card-note-info { background: rgba(77, 184, 144, 0.12); }
  .stage-card-note-warn { background: rgba(196, 124, 26, 0.15); }
  .stage-modal-card {
    background: var(--color-bg-dark, #1a2820);
  }
  .stage-modal-opt {
    border-color: rgba(255,255,255,0.1);
  }
  .stage-modal-opt:hover { background: rgba(255,255,255,0.03); }
  .stage-modal-opt.is-selected {
    background: rgba(77,184,144,0.12);
  }
  .stage-modal-disclaimer { background: rgba(196,124,26,0.15); }
}
.dark-mode .stage-card { background: rgba(255,255,255,0.03); border-color: rgba(255,255,255,0.08); }
.dark-mode .stage-card-active { background: rgba(77,184,144,0.12); }
.dark-mode .stage-card-goal { background: rgba(0,0,0,0.25); }
.dark-mode .stage-card-suggest { background: rgba(77,184,144,0.12); }
.dark-mode .stage-card-note-info { background: rgba(77,184,144,0.12); }
.dark-mode .stage-card-note-warn { background: rgba(196,124,26,0.15); }
.dark-mode .stage-modal-card { background: #1a2820; }
.dark-mode .stage-modal-opt { border-color: rgba(255,255,255,0.1); }
.dark-mode .stage-modal-opt:hover { background: rgba(255,255,255,0.03); }
.dark-mode .stage-modal-opt.is-selected { background: rgba(77,184,144,0.12); }
.dark-mode .stage-modal-disclaimer { background: rgba(196,124,26,0.15); }

/* ============================================================
   v1.9.13.8 REVIEW GATE — Stage card + Learn tab placeholder UI
   ============================================================ */

/* Stage card — review notice (empty state) */
.stage-card-review-notice {
  margin: 8px 0 0;
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.4;
  color: #6b7280;
  background: #f9fafb;
  border-left: 3px solid #d4a843;
  border-radius: 4px;
}

/* Stage card — review notice (active state, short form) */
.stage-card-active-review {
  margin: 4px 0 0;
  font-size: 12px;
  color: #6b7280;
  font-style: italic;
}

/* Learn tab — top gate banner */
.learn-gate-banner {
  margin: 12px 0 16px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #fff7e0 0%, #fef3d3 100%);
  border: 1px solid #e5d094;
  border-radius: 8px;
  color: #1f2937;
}
.learn-gate-banner .learn-gate-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.learn-gate-banner .learn-gate-icon {
  font-size: 18px;
  line-height: 1;
}
.learn-gate-banner .learn-gate-title {
  font-size: 14px;
  font-weight: 700;
  color: #1f2937;
}
.learn-gate-banner .learn-gate-body {
  margin: 4px 0 8px;
  font-size: 13px;
  line-height: 1.5;
  color: #374151;
}
.learn-gate-banner .learn-gate-links {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
}
.learn-gate-banner .learn-gate-links li {
  margin: 4px 0;
}
.learn-gate-banner .learn-gate-links a {
  color: #1a6b52;
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
}
.learn-gate-banner .learn-gate-links a:hover {
  text-decoration: underline;
}

/* Learn tab — per-section placeholder card */
.learn-gate-card {
  margin: 8px 0 16px;
  padding: 14px 16px;
  background: #f9fafb;
  border: 1px dashed #d1d5db;
  border-radius: 8px;
  color: #6b7280;
}
.learn-gate-card .learn-gate-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.learn-gate-card .learn-gate-icon {
  font-size: 16px;
  line-height: 1;
}
.learn-gate-card .learn-gate-title {
  font-size: 13px;
  font-weight: 700;
  color: #4b5563;
}
.learn-gate-card .learn-gate-body {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: #6b7280;
}

/* Learn red-flag source footnote */
.learn-red-source {
  margin: 8px 0 0;
  font-size: 11px;
  font-style: italic;
  color: rgba(255,255,255,0.85);
  border-top: 1px solid rgba(255,255,255,0.18);
  padding-top: 6px;
}

/* ── Dark mode ───────────────────────────────────────────── */
.dark-mode .stage-card-review-notice {
  background: rgba(255,255,255,0.04);
  color: #b8c5bd;
  border-left-color: #d4a843;
}
.dark-mode .stage-card-active-review {
  color: #8aa098;
}
.dark-mode .learn-gate-banner {
  background: linear-gradient(135deg, rgba(212,168,67,0.12) 0%, rgba(212,168,67,0.06) 100%);
  border-color: rgba(212,168,67,0.35);
  color: #e6ede9;
}
.dark-mode .learn-gate-banner .learn-gate-title {
  color: #f0f5f2;
}
.dark-mode .learn-gate-banner .learn-gate-body {
  color: #cbd6cf;
}
.dark-mode .learn-gate-banner .learn-gate-links a {
  color: #6dcfa3;
}
.dark-mode .learn-gate-card {
  background: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.12);
  color: #9aa8a0;
}
.dark-mode .learn-gate-card .learn-gate-title {
  color: #cbd6cf;
}
.dark-mode .learn-gate-card .learn-gate-body {
  color: #9aa8a0;
}
.dark-mode .learn-red-source {
  color: rgba(255,255,255,0.75);
  border-top-color: rgba(255,255,255,0.15);
}

/* ─────────────────────────────────────────────────────────────────────────
   v1.9.13.9 — Sources expander UI
   Per-section <details> on Learn pages + stage-card sources button.
   Default-collapsed, always-on. Backs every clinical claim.
   ───────────────────────────────────────────────────────────────────────── */
.learn-sources-expander {
  margin: 16px 0 4px;
  padding: 10px 14px;
  background: rgba(26, 107, 82, 0.04);
  border: 1px solid rgba(26, 107, 82, 0.18);
  border-radius: 8px;
}
.learn-sources-expander[open] {
  background: rgba(26, 107, 82, 0.06);
}
.learn-sources-summary {
  font-size: 13px;
  font-weight: 600;
  color: #1a6b52;
  cursor: pointer;
  list-style: none;
  padding: 2px 0;
  user-select: none;
}
.learn-sources-summary::-webkit-details-marker { display: none; }
.learn-sources-summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  font-size: 11px;
  transition: transform 0.15s ease;
}
.learn-sources-expander[open] .learn-sources-summary::before {
  transform: rotate(90deg);
}
.learn-sources-list {
  margin: 10px 0 0;
  padding-left: 22px;
  font-size: 12.5px;
  line-height: 1.5;
  color: #374151;
}
.learn-sources-item { margin: 8px 0; }
.learn-sources-item a {
  color: #1a6b52;
  text-decoration: underline;
  font-weight: 500;
}
.learn-sources-item a:hover { color: #145740; }
.learn-sources-item .claim-ref {
  display: block;
  font-size: 11px;
  color: #6b7280;
  font-style: italic;
  margin-top: 2px;
}
.learn-sources-item blockquote {
  margin: 6px 0 0 0;
  padding: 4px 0 4px 10px;
  border-left: 3px solid #d1d5db;
  font-size: 11.5px;
  color: #4b5563;
  font-style: italic;
}

/* Stage card sources button + panel */
.stage-sources-btn {
  display: block;
  margin-top: 12px;
  padding: 6px 0;
  background: none;
  border: none;
  color: #1a6b52;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.stage-sources-btn:hover { color: #145740; text-decoration: underline; }
.stage-sources-btn[aria-expanded="true"] { font-weight: 600; }
.stage-sources-panel {
  margin-top: 8px;
  padding: 12px 14px;
  background: rgba(26, 107, 82, 0.04);
  border: 1px solid rgba(26, 107, 82, 0.18);
  border-radius: 8px;
}
.stage-sources-title {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: #1a6b52;
}
.stage-sources-list {
  margin: 0;
  padding-left: 22px;
  font-size: 12.5px;
  line-height: 1.5;
  color: #374151;
}
.stage-sources-item { margin: 8px 0; }
.stage-sources-item a {
  color: #1a6b52;
  text-decoration: underline;
  font-weight: 500;
}
.stage-sources-item a:hover { color: #145740; }
.stage-sources-item .stage-sources-refs {
  display: block;
  font-size: 11px;
  color: #6b7280;
  font-style: italic;
  margin-top: 2px;
}
.stage-sources-item blockquote {
  margin: 6px 0 0 0;
  padding: 4px 0 4px 10px;
  border-left: 3px solid #d1d5db;
  font-size: 11.5px;
  color: #4b5563;
  font-style: italic;
}

/* Dark mode */
.dark-mode .learn-sources-expander,
.dark-mode .stage-sources-panel {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
}
.dark-mode .learn-sources-expander[open] {
  background: rgba(255, 255, 255, 0.06);
}
.dark-mode .learn-sources-summary,
.dark-mode .stage-sources-btn,
.dark-mode .stage-sources-title {
  color: #6dd4b0;
}
.dark-mode .learn-sources-item,
.dark-mode .stage-sources-item {
  color: rgba(255, 255, 255, 0.85);
}
.dark-mode .learn-sources-item a,
.dark-mode .stage-sources-item a {
  color: #6dd4b0;
}
.dark-mode .learn-sources-item .claim-ref,
.dark-mode .stage-sources-item .stage-sources-refs {
  color: rgba(255, 255, 255, 0.55);
}
.dark-mode .learn-sources-item blockquote,
.dark-mode .stage-sources-item blockquote {
  border-left-color: rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.7);
}

/* ============================================================
 * v1.9.14 — AI Coach (Hybrid RAG, Stripe-gated)
 * ============================================================ */

/* "Ask about this section" button under each Learn section h2 */
.coach-ask-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0 14px 0;
  padding: 7px 12px;
  background: #1a6b52;
  color: #fff;
  border: none;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.coach-ask-btn:hover,
.coach-ask-btn:focus { background: #145740; outline: none; }
.coach-ask-btn:focus-visible { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #1a6b52; }
.coach-ask-btn svg { flex: 0 0 14px; }

/* Backdrop overlay for both paywall sheet and chat sheet */
.coach-sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9990;
  display: flex; align-items: flex-end; justify-content: center;
  animation: coach-fade-in 0.18s ease;
}
@keyframes coach-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* The chat sheet itself — bottom sheet on mobile, centered card on desktop */
.coach-sheet {
  background: #fff;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  border-radius: 16px 16px 0 0;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.18);
  animation: coach-slide-up 0.22s ease;
}
@keyframes coach-slide-up { from { transform: translateY(20px); } to { transform: translateY(0); } }
@media (min-width: 720px) {
  .coach-sheet-backdrop { align-items: center; }
  .coach-sheet { border-radius: 16px; max-height: 80vh; }
}

.coach-sheet-header {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  display: flex; align-items: center; justify-content: space-between;
  background: #f7faf9;
}
.coach-sheet-title {
  font-size: 16px; font-weight: 700; color: #1a6b52; margin: 0;
  display: flex; align-items: center; gap: 8px;
}
.coach-scope-pill {
  display: inline-block;
  font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 999px;
  background: rgba(26, 107, 82, 0.12); color: #145740;
  text-transform: capitalize;
}
.coach-close-btn {
  background: transparent; border: none;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; cursor: pointer; color: #555;
  font-size: 22px; line-height: 1;
}
.coach-close-btn:hover { background: rgba(0,0,0,0.06); }

/* Thread */
.coach-thread {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 12px;
  background: #fafbfa;
  -webkit-overflow-scrolling: touch;
}
.coach-msg {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 14.5px; line-height: 1.5;
  word-wrap: break-word;
}
.coach-msg-user {
  align-self: flex-end;
  background: #1a6b52; color: #fff;
  border-bottom-right-radius: 4px;
}
.coach-msg-bot {
  align-self: flex-start;
  background: #fff; color: #222;
  border: 1px solid rgba(0,0,0,0.08);
  border-bottom-left-radius: 4px;
}
.coach-msg-bot strong { color: #145740; }
.coach-msg-thinking {
  align-self: flex-start;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.08);
  padding: 12px 16px;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  color: #888; font-size: 13px;
  display: flex; align-items: center; gap: 6px;
}
.coach-msg-thinking .dot {
  width: 6px; height: 6px; background: #1a6b52;
  border-radius: 50%; animation: coach-pulse 1.4s ease infinite;
}
.coach-msg-thinking .dot:nth-child(2) { animation-delay: 0.2s; }
.coach-msg-thinking .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes coach-pulse {
  0%, 60%, 100% { opacity: 0.3; }
  30% { opacity: 1; }
}

/* Inline [Source N] reference — clickable */
.coach-src-ref {
  display: inline-block;
  padding: 1px 6px;
  margin: 0 2px;
  background: rgba(26, 107, 82, 0.12);
  color: #145740;
  font-size: 12px; font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  border: none;
  vertical-align: baseline;
}
.coach-src-ref:hover { background: rgba(26, 107, 82, 0.22); }

/* Sources expander at bottom of each bot message */
.coach-sources {
  margin-top: 10px;
  border-top: 1px dashed rgba(0,0,0,0.12);
  padding-top: 8px;
}
.coach-sources summary {
  cursor: pointer;
  font-size: 12.5px; font-weight: 600;
  color: #145740;
  list-style: none;
  padding: 4px 0;
}
.coach-sources summary::-webkit-details-marker { display: none; }
.coach-sources summary::before {
  content: '▸ '; font-size: 10px; transition: transform 0.15s;
  display: inline-block;
}
.coach-sources[open] summary::before { transform: rotate(90deg); }
.coach-sources-list { margin: 6px 0 0 0; padding: 0; list-style: none; font-size: 12.5px; }
.coach-sources-list li { margin-bottom: 8px; padding-left: 4px; }
.coach-sources-list a { color: #1a6b52; text-decoration: underline; }
.coach-src-quote {
  margin: 4px 0 0 0; padding: 4px 8px;
  border-left: 2px solid rgba(26,107,82,0.4);
  color: #555; font-style: italic; font-size: 12px;
}

/* Red-flag panel (urgent symptoms) */
.coach-rf-title {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; color: #dc2626; font-size: 14px; margin-bottom: 6px;
}
.coach-rf-symptom {
  font-weight: 600; color: #222; margin: 4px 0;
}
.coach-rf-actions {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px;
}
.coach-rf-btn {
  flex: 1 1 auto;
  padding: 10px 14px;
  font-size: 14px; font-weight: 700;
  border-radius: 8px; border: none;
  cursor: pointer; text-align: center;
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.coach-rf-btn-911 { background: #dc2626; color: #fff; }
.coach-rf-btn-911:hover { background: #b91c1c; }
.coach-rf-btn-988 { background: #2563eb; color: #fff; }
.coach-rf-btn-988:hover { background: #1d4ed8; }
.coach-rf-btn-safety {
  background: #fff; color: #dc2626;
  border: 2px solid #dc2626; padding: 8px 14px;
}
.coach-rf-btn-safety:hover { background: #fef2f2; }

/* Mini inline red-flag warning when symptom phrase detected mid-conversation */
.coach-rf-inline {
  background: #fef2f2;
  border-left: 3px solid #dc2626;
  padding: 10px 12px; border-radius: 6px;
  font-size: 13px; color: #7f1d1d;
}
.coach-rf-mini-btn {
  display: inline-block;
  background: #dc2626; color: #fff;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  text-decoration: none; margin-top: 4px;
}

/* Disclaimer footer on every bot answer */
.coach-disclaimer {
  margin-top: 8px; padding-top: 6px;
  border-top: 1px dashed rgba(0,0,0,0.12);
  font-size: 11.5px; color: #888; font-style: italic; line-height: 1.4;
}

/* Input row at bottom */
.coach-input-row {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid rgba(0,0,0,0.08);
  background: #fff;
}
.coach-input {
  flex: 1; resize: none;
  border: 1px solid rgba(0,0,0,0.18);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14.5px; font-family: inherit;
  line-height: 1.4;
  max-height: 100px;
  background: #fafbfa;
  color: #222;
}
.coach-input:focus { outline: none; border-color: #1a6b52; background: #fff; }
.coach-send-btn {
  flex: 0 0 auto;
  background: #1a6b52; color: #fff;
  border: none; border-radius: 12px;
  padding: 10px 16px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.coach-send-btn:hover { background: #145740; }
.coach-send-btn:disabled { background: #9bb6ad; cursor: not-allowed; }

.coach-rate-warn {
  text-align: center; font-size: 11.5px; color: #888;
  padding: 4px 0;
}

/* Paywall sheet */
.coach-paywall { padding: 22px 20px 14px; }
.coach-pw-icon {
  width: 54px; height: 54px; border-radius: 50%;
  background: rgba(26,107,82,0.12); color: #1a6b52;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; margin: 0 auto 14px;
}
.coach-pw-title {
  font-size: 20px; font-weight: 700; color: #1a6b52;
  text-align: center; margin: 0 0 6px 0;
}
.coach-pw-sub {
  text-align: center; font-size: 14px; color: #555;
  margin: 0 0 18px 0; line-height: 1.5;
}
.coach-pw-features { list-style: none; padding: 0; margin: 0 0 20px 0; }
.coach-pw-features li {
  padding: 6px 0 6px 24px;
  position: relative;
  font-size: 13.5px; color: #333; line-height: 1.5;
}
.coach-pw-features li::before {
  content: '✓';
  position: absolute; left: 4px; top: 6px;
  color: #1a6b52; font-weight: 700; font-size: 14px;
}
.coach-pw-plans {
  display: flex; gap: 10px; margin-bottom: 14px;
}
.coach-pw-plan {
  flex: 1;
  padding: 14px 12px;
  border: 2px solid rgba(0,0,0,0.12);
  border-radius: 12px;
  cursor: pointer; text-align: center;
  transition: border-color 0.15s, background 0.15s;
  background: #fff;
}
.coach-pw-plan.is-selected,
.coach-pw-plan.coach-pw-plan-active {
  border-color: #1a6b52;
  background: rgba(26,107,82,0.06);
}
.coach-pw-plan-name { font-weight: 700; font-size: 13.5px; color: #145740; margin: 0; }
.coach-pw-plan-price { font-size: 22px; font-weight: 700; color: #1a6b52; margin: 4px 0 0; }
.coach-pw-plan-period { font-size: 11.5px; color: #888; }
.coach-pw-plan-save {
  display: inline-block; margin-top: 4px;
  padding: 2px 8px; background: #fde68a;
  border-radius: 999px; font-size: 10.5px;
  color: #78350f; font-weight: 600;
}
.coach-pw-email-row { margin-bottom: 14px; }
.coach-pw-email-label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: #555; margin-bottom: 4px;
}
.coach-pw-email {
  width: 100%; padding: 10px 12px;
  border: 1px solid rgba(0,0,0,0.18);
  border-radius: 10px; font-size: 14.5px;
  background: #fafbfa; color: #222;
  box-sizing: border-box;
}
.coach-pw-email:focus { outline: none; border-color: #1a6b52; background: #fff; }
.coach-pw-checkout-btn {
  display: block; width: 100%;
  background: #1a6b52; color: #fff;
  border: none; padding: 13px;
  border-radius: 12px;
  font-size: 15px; font-weight: 700;
  cursor: pointer;
}
.coach-pw-checkout-btn:hover { background: #145740; }
.coach-pw-checkout-btn:disabled { background: #9bb6ad; cursor: not-allowed; }
.coach-pw-fine {
  margin-top: 12px;
  font-size: 11px; color: #888; text-align: center; line-height: 1.5;
}
.coach-pw-error {
  margin: 8px 0;
  padding: 8px 10px;
  background: #fef2f2; border-left: 3px solid #dc2626;
  font-size: 12.5px; color: #7f1d1d; border-radius: 4px;
}

/* Dark mode overrides */
.dark-mode .coach-sheet,
.dark-mode .coach-sheet-header { background: #1a2926; color: #e5f0ec; }
.dark-mode .coach-sheet-header { background: #15201d; border-bottom-color: rgba(255,255,255,0.08); }
.dark-mode .coach-sheet-title { color: #6dd4b0; }
.dark-mode .coach-scope-pill { background: rgba(109,212,176,0.16); color: #8fe3c0; }
.dark-mode .coach-close-btn { color: #c8d6d2; }
.dark-mode .coach-close-btn:hover { background: rgba(255,255,255,0.08); }
.dark-mode .coach-thread { background: #131c1a; }
.dark-mode .coach-msg-bot {
  background: #1f2c29; color: #e5f0ec;
  border-color: rgba(255,255,255,0.08);
}
.dark-mode .coach-msg-bot strong { color: #6dd4b0; }
.dark-mode .coach-msg-thinking {
  background: #1f2c29; color: rgba(255,255,255,0.55);
  border-color: rgba(255,255,255,0.08);
}
.dark-mode .coach-msg-thinking .dot { background: #6dd4b0; }
.dark-mode .coach-src-ref {
  background: rgba(109,212,176,0.16); color: #8fe3c0;
}
.dark-mode .coach-src-ref:hover { background: rgba(109,212,176,0.28); }
.dark-mode .coach-sources { border-top-color: rgba(255,255,255,0.12); }
.dark-mode .coach-sources summary { color: #6dd4b0; }
.dark-mode .coach-sources-list { color: rgba(255,255,255,0.85); }
.dark-mode .coach-sources-list a { color: #6dd4b0; }
.dark-mode .coach-src-quote {
  border-left-color: rgba(109,212,176,0.4);
  color: rgba(255,255,255,0.55);
}
.dark-mode .coach-rf-title { color: #fca5a5; }
.dark-mode .coach-rf-symptom { color: #e5f0ec; }
.dark-mode .coach-rf-inline {
  background: rgba(220,38,38,0.16); color: #fecaca;
  border-left-color: #dc2626;
}
.dark-mode .coach-disclaimer {
  color: rgba(255,255,255,0.45);
  border-top-color: rgba(255,255,255,0.12);
}
.dark-mode .coach-input-row {
  background: #15201d;
  border-top-color: rgba(255,255,255,0.08);
}
.dark-mode .coach-input {
  background: #1f2c29; color: #e5f0ec;
  border-color: rgba(255,255,255,0.18);
}
.dark-mode .coach-input:focus { background: #243431; border-color: #6dd4b0; }
.dark-mode .coach-paywall { background: #1a2926; color: #e5f0ec; }
.dark-mode .coach-pw-icon { background: rgba(109,212,176,0.16); color: #6dd4b0; }
.dark-mode .coach-pw-title { color: #6dd4b0; }
.dark-mode .coach-pw-sub { color: rgba(255,255,255,0.65); }
.dark-mode .coach-pw-features li { color: rgba(255,255,255,0.85); }
.dark-mode .coach-pw-features li::before { color: #6dd4b0; }
.dark-mode .coach-pw-plan {
  background: #1f2c29; border-color: rgba(255,255,255,0.12);
}
.dark-mode .coach-pw-plan.is-selected,
.dark-mode .coach-pw-plan.coach-pw-plan-active {
  background: rgba(109,212,176,0.08); border-color: #6dd4b0;
}
.dark-mode .coach-pw-plan-name { color: #6dd4b0; }
.dark-mode .coach-pw-plan-price { color: #6dd4b0; }
.dark-mode .coach-pw-plan-period { color: rgba(255,255,255,0.55); }
.dark-mode .coach-pw-email-label { color: rgba(255,255,255,0.75); }
.dark-mode .coach-pw-email {
  background: #1f2c29; color: #e5f0ec;
  border-color: rgba(255,255,255,0.18);
}
.dark-mode .coach-pw-email:focus { background: #243431; border-color: #6dd4b0; }
.dark-mode .coach-pw-fine { color: rgba(255,255,255,0.45); }
.dark-mode .coach-rate-warn { color: rgba(255,255,255,0.55); }

/* Additional coach class additions to match coach.js (v1.9.14) */
.coach-text { font-size: 14.5px; line-height: 1.55; color: #222; }
.dark-mode .coach-text { color: #e5f0ec; }

.coach-pw-body { padding: 0 4px; }
.coach-pw-email-help {
  font-size: 11.5px; color: #888; margin: -8px 0 12px;
}
.dark-mode .coach-pw-email-help { color: rgba(255,255,255,0.55); }

.coach-pw-status {
  min-height: 18px;
  font-size: 12.5px; color: #7f1d1d;
  text-align: center; margin: 6px 0;
}
.coach-pw-status:empty { display: none; }
.dark-mode .coach-pw-status { color: #fca5a5; }

.coach-pw-checkout {
  display: block; width: 100%;
  background: #1a6b52; color: #fff;
  border: none; padding: 13px;
  border-radius: 12px;
  font-size: 15px; font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
}
.coach-pw-checkout:hover { background: #145740; }
.coach-pw-checkout:disabled { background: #9bb6ad; cursor: not-allowed; }

.coach-pw-restore {
  display: block; width: 100%;
  background: transparent;
  color: #1a6b52;
  border: 1px solid rgba(26,107,82,0.3);
  padding: 9px;
  border-radius: 10px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}
.coach-pw-restore:hover { background: rgba(26,107,82,0.06); }
.dark-mode .coach-pw-restore { color: #6dd4b0; border-color: rgba(109,212,176,0.4); }
.dark-mode .coach-pw-restore:hover { background: rgba(109,212,176,0.08); }

/* ============================================================================
 * INSIGHTS TAB (v1.9.15)
 * Deterministic on-device aggregator UI. No LLM, sourced cards only.
 * ========================================================================== */
.insights-screen {
  padding: 16px 16px 80px;
  max-width: 720px;
  margin: 0 auto;
}
.insights-header { margin-bottom: 16px; }
.insights-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px 0;
  color: #1a4d3e;
}
.dark-mode .insights-title { color: #6dd4b0; }
.insights-subtitle {
  font-size: 13px;
  color: #5a6b6a;
  margin: 0;
  line-height: 1.4;
}
.dark-mode .insights-subtitle { color: #9ab2af; }

.insights-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.insights-card {
  background: #fff;
  border: 1px solid rgba(26,77,62,0.12);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.dark-mode .insights-card {
  background: #1c2826;
  border-color: rgba(109,212,176,0.18);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.insights-card-empty {
  background: #f7f9f8;
  border-style: dashed;
}
.dark-mode .insights-card-empty {
  background: #161f1e;
}

.insights-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 12px;
}
.insights-card-title {
  font-size: 14px;
  font-weight: 600;
  color: #2d4f47;
  flex: 1;
}
.dark-mode .insights-card-title { color: #c3e2d8; }

.insights-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  white-space: nowrap;
}
.insights-badge-green {
  background: rgba(46,160,67,0.12);
  color: #1f7a36;
}
.dark-mode .insights-badge-green {
  background: rgba(109,212,176,0.18);
  color: #6dd4b0;
}
.insights-badge-amber {
  background: rgba(217,144,33,0.14);
  color: #a35d00;
}
.dark-mode .insights-badge-amber {
  background: rgba(255,180,84,0.18);
  color: #ffb454;
}
.insights-badge-red {
  background: rgba(196,46,46,0.12);
  color: #a01818;
}
.dark-mode .insights-badge-red {
  background: rgba(255,107,107,0.18);
  color: #ff8a8a;
}

.insights-card-body {
  font-size: 14px;
  color: #2d4f47;
}
.dark-mode .insights-card-body { color: #c3e2d8; }

.insights-metric {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-bottom: 4px;
}
.insights-metric-value {
  font-size: 26px;
  font-weight: 700;
  color: #1a4d3e;
  line-height: 1.1;
}
.dark-mode .insights-metric-value { color: #6dd4b0; }
.insights-metric-unit {
  font-size: 13px;
  color: #5a6b6a;
}
.dark-mode .insights-metric-unit { color: #9ab2af; }

.insights-target {
  font-size: 12px;
  color: #5a6b6a;
  margin-top: 4px;
}
.dark-mode .insights-target { color: #9ab2af; }

.insights-stage-suggest {
  font-size: 12px;
  color: #a35d00;
  margin-top: 6px;
  padding: 6px 8px;
  background: rgba(217,144,33,0.08);
  border-left: 3px solid #d99021;
  border-radius: 0 4px 4px 0;
}
.dark-mode .insights-stage-suggest {
  color: #ffb454;
  background: rgba(255,180,84,0.08);
  border-left-color: #ffb454;
}

.insights-source {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(26,77,62,0.08);
  font-size: 11px;
  color: #6e7f7d;
  line-height: 1.4;
}
.dark-mode .insights-source {
  border-top-color: rgba(109,212,176,0.12);
  color: #8ba39f;
}
.insights-source-label {
  font-weight: 600;
}

.insights-empty-msg {
  font-size: 13px;
  color: #6e7f7d;
  font-style: italic;
}
.dark-mode .insights-empty-msg { color: #8ba39f; }

.insights-redflag {
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(196,46,46,0.08);
  border: 1px solid rgba(196,46,46,0.3);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dark-mode .insights-redflag {
  background: rgba(255,107,107,0.1);
  border-color: rgba(255,107,107,0.35);
}
.insights-redflag-text {
  font-size: 13px;
  font-weight: 600;
  color: #a01818;
}
.dark-mode .insights-redflag-text { color: #ff8a8a; }
.insights-redflag-btn {
  background: #c42e2e;
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  align-self: flex-start;
}
.insights-redflag-btn:hover { background: #a01818; }
.dark-mode .insights-redflag-btn { background: #d63a3a; }
.dark-mode .insights-redflag-btn:hover { background: #b53030; }

.insights-disclaimer {
  margin-top: 20px;
  padding: 12px;
  font-size: 11px;
  color: #6e7f7d;
  line-height: 1.5;
  background: rgba(26,77,62,0.04);
  border-radius: 8px;
  text-align: center;
}
.dark-mode .insights-disclaimer {
  background: rgba(109,212,176,0.06);
  color: #8ba39f;
}

@media (max-width: 360px) {
  .insights-metric-value { font-size: 22px; }
  .insights-card-title { font-size: 13px; }
}

/* v1.9.15: Paywall safety note */
.coach-pw-safety-note {
  padding: 10px 12px;
  margin: 12px 0;
  background: rgba(196,46,46,0.06);
  border: 1px solid rgba(196,46,46,0.2);
  border-radius: 8px;
  font-size: 13px;
  color: #2d4f47;
  line-height: 1.4;
}
.dark-mode .coach-pw-safety-note {
  background: rgba(255,107,107,0.08);
  border-color: rgba(255,107,107,0.25);
  color: #c3e2d8;
}
.coach-pw-safety-link {
  background: none;
  border: none;
  padding: 0;
  color: #c42e2e;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  font-size: 13px;
}
.coach-pw-safety-link:hover { color: #a01818; }
.dark-mode .coach-pw-safety-link { color: #ff8a8a; }
.dark-mode .coach-pw-safety-link:hover { color: #ffb0b0; }
