:root {
  --green-900: #1B4332;
  --green-700: #2D6A4F;
  --green-50: #EAF3EE;
  --bg: #F9F6EF;
  --card: #ffffff;
  --teal: #00BFA5;
  --teal-600: #00A693;
  --red: #E53E3E;
  --amber: #D97706;
  --text: #14241D;
  --muted: #5B6B64;
  --border: #E3DED1;
  --radius: 16px;
  --shadow: 0 4px 18px rgba(27, 67, 50, 0.08);
  --shadow-lg: 0 12px 32px rgba(27, 67, 50, 0.12);
}

:root.dark {
  --bg: #0D1F1A;
  --card: #142A23;
  --text: #EAF3EE;
  --muted: #9CB3AA;
  --border: #1F3B32;
  --green-50: #18302A;
  --shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.mono, .num { font-family: 'JetBrains Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }

a { color: var(--green-900); text-decoration: none; }
a:hover { color: var(--teal-600); }

h1, h2, h3, h4 { color: var(--text); font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.125rem; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea {
  font-family: inherit; font-size: 1rem;
  width: 100%; padding: 0.75rem 1rem;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--card); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  padding: 0;
  accent-color: var(--teal);
  cursor: pointer;
  border-radius: 4px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0, 191, 165, 0.18);
}
label { display: block; font-size: 0.875rem; color: var(--muted); margin-bottom: 0.375rem; font-weight: 500; }


/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.75rem 1.25rem; border-radius: 12px; font-weight: 600;
  transition: transform .1s, box-shadow .15s, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.65; cursor: not-allowed; pointer-events: none; }

.btn-primary { background: var(--green-900); color: #fff; }
.btn-primary:hover { background: var(--green-700); }
.btn-accent { background: var(--teal); color: #04261F; }
.btn-accent:hover { background: var(--teal-600); color: #fff; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--green-50); }
.btn-block { width: 100%; }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
  box-shadow: var(--shadow);
}
.card-tinted { background: var(--green-50); }
.card-title { font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 0.5rem; font-weight: 600; }

/* Layout */
.container { max-width: 1200px; margin: 0 auto; padding: 1.25rem; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }
.grid-4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 768px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

.row { display: flex; gap: 1rem; align-items: center; }
.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* Prevent grid cells from overflowing their column (e.g. Chart.js canvas) */
.grid > * { min-width: 0; }

/* App shell */
.app { min-height: 100vh; padding-bottom: 80px; }
.app-header {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in oklab, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.app-header .container { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; }
.brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; font-size: 1.375rem; color: var(--green-900); }
.brand-dot { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--green-900), var(--teal)); display: grid; place-items: center; color: #fff; font-weight: 800; }
.brand-logo { height: 64px; width: auto; max-width: 200px; border-radius: 6px; object-fit: contain; flex-shrink: 0; }
.auth-card .brand-logo { height: 48px; max-width: 160px; }
:root.dark .brand { color: var(--teal); }

/* Bottom nav (mobile) */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: var(--card); border-top: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 0.5rem 0.25rem; padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
}
.bottom-nav a, .bottom-nav .mobile-menu-trigger {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 0.6875rem; color: var(--muted); padding: 0.375rem; border-radius: 10px; border: none; background: none; cursor: pointer;
  text-decoration: none;
}
.bottom-nav a.active { color: var(--green-900); background: var(--green-50); }
:root.dark .bottom-nav a.active { color: var(--teal); }
.bottom-nav svg, .bottom-nav i { width: 22px; height: 22px; }

/* Mobile Navigation Drawer Overlay */
.mobile-drawer-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px); z-index: 999;
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
}
.mobile-drawer-overlay.open { opacity: 1; pointer-events: auto; }
.mobile-drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 85%; max-width: 320px;
  background: var(--card); border-left: 1px solid var(--border);
  z-index: 1000; display: flex; flex-direction: column;
  padding: 1.25rem; transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-lg);
}
.mobile-drawer-overlay.open .mobile-drawer { transform: translateX(0); }
.mobile-drawer-links a {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 0.875rem; border-radius: 12px;
  color: var(--text); font-weight: 500; font-size: 0.9375rem;
  text-decoration: none; transition: background 0.15s;
}
.mobile-drawer-links a:hover, .mobile-drawer-links a.active {
  background: var(--green-50); color: var(--green-900);
}
:root.dark .mobile-drawer-links a:hover, :root.dark .mobile-drawer-links a.active {
  background: var(--green-50); color: var(--teal);
}
.mobile-drawer-close {
  padding: 0.4rem; border-radius: 8px;
}

/* Sidebar (desktop) */
.side-nav { display: none; }
@media (min-width: 1024px) {
  .has-side { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 0; min-height: 100vh; }
  .has-side > div { min-width: 0; max-width: 100%; }
  .side-nav {
    display: flex; flex-direction: column; gap: 0.25rem;
    padding: 1.5rem 1rem; border-right: 1px solid var(--border);
    height: 100vh; position: sticky; top: 0;
    align-self: start; overflow-y: auto;
  }
  .side-nav a {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.625rem 0.875rem; border-radius: 10px; color: var(--muted); font-weight: 500;
  }
  .side-nav a:hover { background: var(--green-50); color: var(--green-900); }
  .side-nav a.active { background: var(--green-900); color: #fff; }
  :root.dark .side-nav a.active { background: var(--teal); color: #04261F; }
  .side-nav svg { width: 18px; height: 18px; }
  .bottom-nav { display: none; }
  .app { padding-bottom: 0; }
}


/* Vitals tile */
.vital {
  position: relative; padding: 1rem; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.vital-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.vital-value { font-size: 2rem; font-weight: 600; margin-top: 0.25rem; }
.vital-unit { font-size: 0.875rem; color: var(--muted); margin-left: 0.25rem; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot-green { background: #16a34a; box-shadow: 0 0 0 4px rgba(22,163,74,0.15); }
.dot-amber { background: var(--amber); box-shadow: 0 0 0 4px rgba(217,119,6,0.15); }
.dot-red   { background: var(--red); box-shadow: 0 0 0 4px rgba(229,62,62,0.15); }

/* Heart pulse animation */
.heart-pulse { display: inline-block; color: var(--red); animation: pulse 1.1s ease-in-out infinite; transform-origin: center; }
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  20% { transform: scale(1.18); opacity: .92; }
  40% { transform: scale(1); opacity: 1; }
  60% { transform: scale(1.1); opacity: .95; }
}

/* Recommendation hero card */
.rec-card {
  background: linear-gradient(135deg, var(--green-900), #2D6A4F 60%, var(--teal));
  color: #fff; border-radius: 20px; padding: 1.5rem; box-shadow: var(--shadow-lg);
  position: relative; overflow: hidden;
}
.rec-card::after {
  content: ''; position: absolute; right: -40px; top: -40px;
  width: 180px; height: 180px; border-radius: 50%;
  background: rgba(255,255,255,0.08);
}
.rec-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.18); padding: 4px 10px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
}

/* Badge */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge-info { background: rgba(0,191,165,0.12); color: var(--teal-600); }
.badge-warning { background: rgba(217,119,6,0.12); color: var(--amber); }
.badge-critical { background: rgba(229,62,62,0.12); color: var(--red); }
.badge-success { background: rgba(22,163,74,0.12); color: #15803d; }

/* Progress ring */
.ring { transform: rotate(-90deg); }
.ring-bg { stroke: var(--border); }
.ring-fg { stroke: var(--green-900); stroke-linecap: round; transition: stroke-dashoffset 1s ease; }
:root.dark .ring-fg { stroke: var(--teal); }

/* Meal upload */
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 2.5rem 1.5rem; text-align: center; background: var(--card);
  transition: border-color .15s, background .15s; cursor: pointer;
}
.dropzone.dragover { border-color: var(--teal); background: var(--green-50); }
.dropzone svg { width: 40px; height: 40px; color: var(--teal-600); margin: 0 auto 0.5rem; }

.meal-thumb { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; background: var(--green-50); }
.meal-item { display: flex; gap: 0.875rem; padding: 0.75rem; border-radius: 12px; align-items: center; }
.meal-item:hover { background: var(--green-50); }

/* Analyzing overlay */
.overlay {
  position: fixed; inset: 0; background: rgba(13, 31, 26, 0.55);
  backdrop-filter: blur(6px);
  display: grid; place-items: center; z-index: 100;
}
.overlay-card {
  background: var(--card); padding: 2rem; border-radius: 20px;
  text-align: center; max-width: 320px;
}
.spinner {
  width: 48px; height: 48px; border: 4px solid var(--border);
  border-top-color: var(--teal); border-radius: 50%;
  animation: spin 0.8s linear infinite; margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast-wrap { position: fixed; top: 1rem; right: 1rem; z-index: 200; display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
  background: var(--card); border: 1px solid var(--border); padding: 0.875rem 1rem;
  border-radius: 12px; box-shadow: var(--shadow-lg); min-width: 240px;
  animation: slideIn .2s ease;
}
.toast-success { border-left: 4px solid #16a34a; }
.toast-error { border-left: 4px solid var(--red); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Auth pages */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: radial-gradient(circle at 20% 0%, var(--green-50), var(--bg) 60%); }
.auth-card { width: 100%; max-width: 420px; }

/* Landing */
.hero { padding: 4rem 0 3rem; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.5rem); line-height: 1.1; margin-bottom: 1rem; }
.hero .lead { font-size: 1.125rem; color: var(--muted); max-width: 560px; margin-bottom: 1.75rem; }
.hero-cta { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.feature-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 768px) { .feature-grid { grid-template-columns: repeat(3, 1fr); } }
.feature .icon { width: 44px; height: 44px; border-radius: 12px; background: var(--green-50); color: var(--green-900); display: grid; place-items: center; margin-bottom: 0.875rem; }
:root.dark .feature .icon { background: var(--green-700); color: var(--teal); }

/* Lists */
.list { display: flex; flex-direction: column; gap: 0.5rem; }
.list-item {
  display: flex; gap: 0.875rem; padding: 0.875rem; border-radius: 12px;
  background: var(--card); border: 1px solid var(--border);
}

/* Skeleton */
.skel { background: linear-gradient(90deg, var(--border), color-mix(in oklab, var(--border) 50%, transparent), var(--border)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Responsive header with controls (vitals, insights) */
.header-with-controls .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 0.5rem;
}
.header-with-controls h2 {
  font-size: 1.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-controls {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
}
.header-controls select {
  width: auto;
  max-width: 145px;
  padding: 0.4rem 0.6rem;
  font-size: 0.8125rem;
}


/* Responsive chart canvas container */
.chart-card {
  position: relative;
  min-width: 0;
  max-width: 100%;
}
.chart-canvas {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 180px;
}
.chart-canvas canvas {
  width: 100% !important;
  max-width: 100% !important;
}
@media (min-width: 768px) { .chart-canvas { height: 240px; } }

/* Chart card header with title + fullscreen button */
.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.chart-card-header .card-title { margin-bottom: 0; }
.btn-chart-fullscreen {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.25rem 0.4rem;
  cursor: pointer;
  color: var(--muted);
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.btn-chart-fullscreen:hover { color: var(--teal); border-color: var(--teal); }
.btn-chart-fullscreen svg { width: 15px; height: 15px; }

/* When a chart card enters native fullscreen mode */
.chart-card:fullscreen,
.chart-card:-webkit-full-screen {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  padding: 1.25rem;
  border-radius: 0;
  width: 100vw !important;
  height: 100vh !important;
  box-sizing: border-box;
  overflow: hidden;
}
.chart-card:fullscreen .chart-canvas,
.chart-card:-webkit-full-screen .chart-canvas {
  height: calc(100vh - 70px) !important;
  width: 100% !important;
  max-width: 100% !important;
  flex: 1;
}

/* Pseudo-fullscreen fallback (if Fullscreen API unavailable) */
.chart-pseudo-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9999 !important;
  border-radius: 0 !important;
  display: flex;
  flex-direction: column;
  background: var(--bg) !important;
  padding: 1.25rem !important;
  width: 100vw !important;
  height: 100vh !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
}
.chart-pseudo-fullscreen .chart-canvas { height: calc(100vh - 70px) !important; flex: 1; width: 100% !important; }

/* Mobile Fullscreen Landscape Mode (rotates seamlessly if locked in portrait) */
@media (max-width: 768px) and (orientation: portrait) {
  .chart-card:fullscreen,
  .chart-card:-webkit-full-screen,
  .chart-pseudo-fullscreen {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    width: 100vh !important;
    height: 100vw !important;
    transform: translate(-50%, -50%) rotate(90deg) !important;
    transform-origin: center center !important;
    box-sizing: border-box !important;
    z-index: 99999 !important;
  }
  .chart-card:fullscreen .chart-canvas,
  .chart-card:-webkit-full-screen .chart-canvas,
  .chart-pseudo-fullscreen .chart-canvas {
    height: calc(100vw - 70px) !important;
    width: 100% !important;
  }
}


/* Food log date filter */
.filter-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; justify-content: flex-end; }
.filter-row input[type="date"], .filter-row input[type="text"] {
  width: auto; min-width: 130px; padding: 0.4rem 0.75rem; font-size: 0.875rem;
}

/* Make the entire date input open the picker; hide the visible calendar icon */
.filter-row input[type="date"] {
  position: relative;
  cursor: pointer;
}
.filter-row input[type="date"]::-webkit-calendar-picker-indicator {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* Profile / Goals read-only mode */
.profile-readonly input:disabled,
.profile-readonly select:disabled,
#profile-form #email:disabled {
  background: transparent;
  border: 1px dashed var(--border);
  box-shadow: none;
  cursor: default;
  opacity: 1;
  color: var(--text);
  -webkit-text-fill-color: var(--text);
}

/* Hide dropdown arrow on disabled selects (only show when editing) */
#profile-form select:disabled,
#goals-page-form select:disabled {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* Never show number spinners in profile or goals form */
#profile-form input[type="number"]::-webkit-inner-spin-button,
#profile-form input[type="number"]::-webkit-outer-spin-button,
#goals-page-form input[type="number"]::-webkit-inner-spin-button,
#goals-page-form input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
#profile-form input[type="number"],
#goals-page-form input[type="number"] {
  -moz-appearance: textfield;
}

/* Nutrition card */
.nutrition-row { display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.nutrition-ring { position: relative; width: 140px; height: 140px; flex-shrink: 0; }
.nutrition-chart { width: 100%; min-width: 0; }
.nutrition-chart-canvas { height: 160px; width: 100%; overflow: hidden; position: relative; }
@media (min-width: 1024px) {
  .nutrition-row { flex-direction: row; justify-content: space-between; align-items: flex-start; }
  .nutrition-chart { flex: 1; padding-left: 1rem; }
  .nutrition-chart-canvas { height: 200px; }
}

/* Utility */
.hidden { display: none !important; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.gap-sm { gap: 0.5rem; }
.flex-wrap { flex-wrap: wrap; }

/* Responsive connected devices/services list items at phone level */
@media (max-width: 640px) {
  #devices-list .list-item,
  #google-health-row.list-item {
    flex-wrap: wrap;
    gap: 0.5rem 0.875rem;
  }
  #devices-list .list-item > div:last-child,
  #google-health-row.list-item > div:last-child {
    flex-basis: 100%;
    width: 100%;
    justify-content: flex-start !important;
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
    margin-top: 0.25rem;
  }
  .app-header .container {
    padding: 0.625rem 0.875rem;
  }
  .brand {
    font-size: 1.125rem;
    gap: 0.375rem;
  }
  .brand-logo {
    height: 36px;
    max-width: 130px;
  }
  .auth-card .brand-logo {
    height: 36px;
    max-width: 140px;
  }
  .app-header .btn {
    padding: 0.45rem 0.75rem;
    font-size: 0.875rem;
  }
  .hero {
    padding: 2.5rem 0 2rem;
  }
}

/* Animations */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.spin {
  animation: spin 1s linear infinite !important;
  display: inline-block;
}

/* Responsive & layout utilities */
.account-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Smart Target Card in Goals */
.smart-target-card {
  background: var(--green-50);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-top: 0.75rem;
}
.smart-target-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Interactive Per-Field Recommendation Chips in Goals */
.field-rec-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.35rem;
  font-size: 0.775rem;
  line-height: 1.35;
  padding: 0.25rem 0.6rem;
  border-radius: 8px;
  background: rgba(0, 191, 165, 0.08);
  border: 1px dashed rgba(0, 191, 165, 0.35);
  color: var(--green-900);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}
:root.dark .field-rec-chip {
  background: rgba(0, 191, 165, 0.12);
  border-color: rgba(0, 191, 165, 0.4);
  color: #5eead4;
}
.field-rec-chip:hover {
  background: rgba(0, 191, 165, 0.18);
  border-color: var(--teal);
  border-style: solid;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 191, 165, 0.15);
}
.field-rec-chip i {
  color: var(--teal);
  flex-shrink: 0;
}
.field-rec-chip .chip-action {
  font-weight: 700;
  text-decoration: underline;
  margin-left: 0.25rem;
}
.profile-readonly .field-rec-chip {
  display: none !important;
}
.field-highlight {
  animation: fieldFlash 0.8s ease;
}
@keyframes fieldFlash {
  0% { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0, 191, 165, 0.35); }
  100% { border-color: var(--border); box-shadow: none; }
}

@media (max-width: 640px) {
  .hide-mobile {
    display: none !important;
  }
  .account-actions {
    flex-direction: column;
    width: 100%;
  }
  .account-actions .btn {
    width: 100%;
    justify-content: center;
  }
  .smart-target-header {
    flex-direction: column;
    align-items: stretch !important;
    gap: 0.625rem;
  }
  #apply-rec-btn {
    width: 100% !important;
    justify-content: center !important;
    padding: 0.5rem 0.75rem !important;
    text-align: center;
  }
  .goals-actions-bar {
    flex-direction: column;
    width: 100%;
  }
  .goals-actions-bar .btn {
    width: 100%;
    justify-content: center;
  }
  
  /* Mobile Insights card spacing */
  .rec-footer {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.875rem !important;
    margin-top: 1.25rem !important;
  }
  .rec-date {
    display: block;
    margin-bottom: 0.625rem;
    font-size: 0.8125rem;
  }
  .rec-actions {
    width: 100%;
    justify-content: flex-start;
    gap: 0.625rem;
  }
}

/* ── Smart Scale Live View Styles ────────────────────────── */

.scale-link {
  color: var(--teal-600);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  transition: color 0.15s, opacity 0.15s;
}
.scale-link:hover {
  color: var(--green-900);
  text-decoration-thickness: 2px;
}
:root.dark .scale-link {
  color: var(--teal);
}
:root.dark .scale-link:hover {
  color: #fff;
}

.scale-hero-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 2.5rem 1.5rem;
  text-align: center;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.scale-hero-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  background: linear-gradient(90deg, var(--green-900), var(--teal), var(--green-900));
}

.scale-gauge-ring {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  border: 3px dashed var(--border);
  margin: 1rem auto 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  background: radial-gradient(circle, color-mix(in oklab, var(--teal) 8%, transparent) 0%, transparent 70%);
}
.scale-gauge-ring.active-reading {
  border-style: solid;
  border-color: var(--teal);
  box-shadow: 0 0 24px rgba(0, 191, 165, 0.25);
}

.scale-digital-val {
  font-size: 3.5rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  font-family: 'JetBrains Mono', monospace;
}
.scale-digital-unit {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--muted);
  margin-top: 0.25rem;
}

.scale-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  background: var(--green-50);
  color: var(--green-900);
}
:root.dark .scale-live-badge {
  color: var(--teal);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #16a34a;
  animation: livePing 1.6s cubic-bezier(0, 0, 0.2, 1) infinite;
}
.pulse-dot.dot-idle {
  background: var(--muted);
  animation: none;
}
@keyframes livePing {
  0% { transform: scale(0.9); opacity: 1; box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.7); }
  70% { transform: scale(1.1); opacity: 0.8; box-shadow: 0 0 0 8px rgba(22, 163, 74, 0); }
  100% { transform: scale(0.9); opacity: 1; box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

.reading-stream-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  transition: transform 0.15s, border-color 0.15s;
}
.reading-stream-item:hover {
  border-color: var(--teal);
  transform: translateX(2px);
}





