/* ==========================================
   CSS Variables & Design Tokens
   ========================================== */
:root {
  /* Fonts */
  --font-display: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;

  /* Default Vibrant Light Theme Colors */
  --bg-app: radial-gradient(circle at top left, #faf8f5 0%, #edf1f5 100%);
  --bg-sidebar: #ffffff;
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(0, 0, 0, 0.06);
  --glass-border-focus: rgba(0, 0, 0, 0.15);
  --glass-glow: 0 8px 32px 0 rgba(148, 163, 184, 0.07);
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --accent-orange: #ea580c;
  --accent-green: #059669;
  --accent-violet: #7c3aed;
  --accent-yellow: #d97706;
  --accent-pink: #c026d3;
  --accent-blue: #2563eb;
  
  --input-bg: rgba(0, 0, 0, 0.03);
  --border-radius-lg: 20px;
  --border-radius-md: 12px;
  --border-radius-sm: 8px;
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Dark Theme Overrides */
body.dark-theme {
  --bg-app: radial-gradient(circle at top left, #0a0d16 0%, #06080e 100%);
  --bg-sidebar: #0b0e17;
  --glass-bg: rgba(17, 24, 39, 0.60);
  --glass-border: rgba(255, 255, 255, 0.06);
  --glass-border-focus: rgba(255, 255, 255, 0.15);
  --glass-glow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #4b5563;
  
  --accent-orange: #ff7a45;
  --accent-green: #10b981;
  --accent-violet: #8b5cf6;
  --accent-yellow: #fbbf24;
  --accent-pink: #d946ef;
  --accent-blue: #3b82f6;
  
  --input-bg: rgba(0, 0, 0, 0.3);
}

/* ==========================================
   Base Styles & Resets
   ========================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background var(--transition-smooth), color var(--transition-smooth);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
}

button, input, textarea, select {
  font-family: inherit;
  color: inherit;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(156, 163, 175, 0.2);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(156, 163, 175, 0.4);
}

/* ==========================================
   Layout Architecture
   ========================================== */
.app-container {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* Sidebar Layout */
.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--glass-border);
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 10;
  transition: var(--transition-smooth);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 48px;
}

.logo-icon {
  font-size: 28px;
  filter: drop-shadow(0 2px 8px rgba(255,122,69,0.3));
}

.logo-text {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--text-primary) 30%, var(--accent-orange) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-text span {
  font-weight: 400;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border-radius: var(--border-radius-md);
  text-decoration: none;
  font-weight: 500;
  font-size: 15px;
  color: var(--text-secondary);
  border: 1px solid transparent;
  background: transparent;
  position: relative;
  will-change: background-color, color, box-shadow;
  transition:
    background-color 0.22s ease,
    color 0.22s ease,
    border-color 0.22s ease,
    box-shadow 0.28s ease;
}

.nav-item i {
  font-size: 18px;
  transition: color 0.22s ease, text-shadow 0.28s ease;
}

.nav-item:hover {
  color: var(--text-primary);
  background: linear-gradient(135deg,
    rgba(255, 122, 69, 0.08) 0%,
    rgba(255, 122, 69, 0.03) 100%);
  border-color: rgba(255, 122, 69, 0.18);
  box-shadow:
    0 0 0 1px rgba(255, 122, 69, 0.08),
    0 6px 18px -8px rgba(255, 122, 69, 0.45),
    inset 0 0 12px rgba(255, 122, 69, 0.06);
}

.nav-item:hover i {
  color: var(--accent-orange);
  text-shadow: 0 0 8px rgba(255, 122, 69, 0.35);
}

.nav-item.active {
  color: var(--text-primary);
  background: linear-gradient(135deg,
    rgba(255, 122, 69, 0.14) 0%,
    rgba(255, 122, 69, 0.06) 100%);
  border-color: rgba(255, 122, 69, 0.25);
  box-shadow:
    0 0 0 1px rgba(255, 122, 69, 0.12),
    0 8px 22px -10px rgba(255, 122, 69, 0.55);
}

.nav-item.active i {
  color: var(--accent-orange);
  text-shadow: 0 0 12px rgba(255, 122, 69, 0.5);
}

body.dark-theme .nav-item:hover,
body.dark-theme .nav-item.active {
  background: linear-gradient(135deg,
    rgba(255, 122, 69, 0.18) 0%,
    rgba(255, 122, 69, 0.05) 100%);
  border-color: rgba(255, 122, 69, 0.3);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--glass-border);
  font-size: 12px;
  color: var(--text-muted);
}

.network-hint i {
  margin-right: 6px;
}

/* Main Content Area */
.main-content {
  flex-grow: 1;
  padding: 40px;
  max-width: 1400px;
  margin: 0 auto;
  width: calc(100% - 260px);
  padding-bottom: 60px;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 40px;
}

#pageTitle {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 4px;
}

.text-secondary {
  color: var(--text-secondary);
}

.text-secondary.small {
  font-size: 13px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.fast-badge {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  padding: 8px 16px;
  border-radius: 50px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--accent-green);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse 1.8s infinite;
}

.theme-toggle {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  font-size: 16px;
  transition: var(--transition-bounce);
}

.theme-toggle:hover {
  transform: rotate(30deg) scale(1.1);
  border-color: var(--glass-border-focus);
}

/* Glass Card Definition */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--glass-glow);
  transition: border-color var(--transition-smooth), background-color var(--transition-smooth);
}

/* ==========================================
   Milestone Progress Card
   ========================================== */
.milestone-card {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 30px;
  border: 1px solid rgba(217, 119, 6, 0.15);
  background: linear-gradient(135deg, rgba(217, 119, 6, 0.04) 0%, var(--glass-bg) 100%);
}

.milestone-badge {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(217, 119, 6, 0.08);
  color: var(--accent-yellow);
  border: 1px solid rgba(217, 119, 6, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  box-shadow: 0 0 20px rgba(217, 119, 6, 0.1);
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-4px); }
  100% { transform: translateY(0px); }
}

.milestone-info {
  flex-grow: 1;
}

.milestone-header-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.milestone-header-row h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.milestone-ratio {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-yellow);
}

.progress-bar-container {
  height: 8px;
  width: 100%;
  background-color: var(--input-bg);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 8px;
  border: 1px solid var(--glass-border);
}

.progress-bar-fill {
  height: 100%;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--accent-yellow) 0%, var(--accent-orange) 100%);
  box-shadow: 0 0 10px rgba(217, 119, 6, 0.2);
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.milestone-hint {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ==========================================
   KPI Cards Grid
   ========================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.kpi-card {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition-bounce);
}

.kpi-card:hover {
  transform: translateY(-5px);
  border-color: var(--glass-border-focus);
}

.kpi-icon {
  width: 50px;
  height: 50px;
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.kpi-icon.orange {
  background: rgba(234, 88, 12, 0.08);
  color: var(--accent-orange);
  border: 1px solid rgba(234, 88, 12, 0.15);
}
.kpi-icon.green {
  background: rgba(5, 150, 105, 0.08);
  color: var(--accent-green);
  border: 1px solid rgba(5, 150, 105, 0.15);
}
.kpi-icon.blue {
  background: rgba(37, 99, 230, 0.08);
  color: var(--accent-blue);
  border: 1px solid rgba(37, 99, 230, 0.15);
}
.kpi-icon.violet {
  background: rgba(124, 58, 237, 0.08);
  color: var(--accent-violet);
  border: 1px solid rgba(124, 58, 237, 0.15);
}
.kpi-icon.yellow {
  background: rgba(217, 119, 6, 0.08);
  color: var(--accent-yellow);
  border: 1px solid rgba(217, 119, 6, 0.15);
}
.kpi-icon.red {
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.15);
}

.kpi-info h3 {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 24px;
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}

.kpi-value small {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
}

.kpi-value .slash {
  color: var(--text-muted);
  margin: 0 2px;
}

.kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
  white-space: normal;
  word-wrap: break-word;
  line-height: 1.4;
}

.kpi-sub.up {
  color: var(--accent-green);
}

.kpi-sub.down {
  color: var(--accent-orange);
}

/* ==========================================
   Quick-Log Panel (Dashboard)
   ========================================== */
.quick-log-panel {
  padding: 24px 28px;
  margin-bottom: 28px;
}

.quick-log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.quick-log-header h3 {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.quick-log-header h3 i {
  color: var(--accent-yellow);
}

.quick-log-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.quick-log-presets .btn-preset {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--border-radius-md);
  border: 1.5px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-primary);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition-bounce);
  position: relative;
  overflow: hidden;
}

.quick-log-presets .btn-preset::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--juice-color);
  opacity: 0.06;
  transition: opacity 0.3s ease;
}

.quick-log-presets .btn-preset:hover {
  transform: translateY(-3px);
  border-color: var(--juice-color);
  box-shadow: 0 4px 18px rgba(0,0,0,0.08);
}

.quick-log-presets .btn-preset:hover::before {
  opacity: 0.14;
}

.quick-log-presets .btn-preset:active {
  transform: scale(0.96);
}

.quick-log-presets .btn-preset .preset-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.quick-log-presets .btn-preset .preset-qty {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 2px;
}

.quick-log-presets .btn-preset.logging {
  pointer-events: none;
  opacity: 0.7;
}

.quick-log-presets .btn-preset.logged {
  border-color: var(--accent-green) !important;
  animation: quickLogFlash 0.6s ease;
}

@keyframes quickLogFlash {
  0% { background: var(--glass-bg); }
  40% { background: rgba(16, 185, 129, 0.18); }
  100% { background: var(--glass-bg); }
}

/* ==========================================
   Quick-Exercise Panel (Dashboard)
   ========================================== */
.quick-exercise-panel .quick-log-header h3 i {
  color: var(--accent-green);
}

.quick-exercise-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.quick-exercise-presets .exercise-preset-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--border-radius-md);
  border: 1.5px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-primary);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition-bounce);
}

.quick-exercise-presets .exercise-preset-btn:hover {
  transform: translateY(-3px);
  border-color: var(--accent-green);
  box-shadow: 0 4px 18px rgba(16, 185, 129, 0.12);
}

.quick-exercise-presets .exercise-preset-btn:active {
  transform: scale(0.96);
}

.quick-exercise-presets .exercise-preset-btn.selected {
  border-color: var(--accent-green);
  background: rgba(16, 185, 129, 0.08);
}

.quick-exercise-presets .exercise-preset-btn .exercise-preset-emoji {
  font-size: 18px;
  line-height: 1;
}

.quick-exercise-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--border-radius-md);
  background: var(--input-bg);
  border: 1px solid var(--glass-border);
  animation: slideDown 0.25s ease;
}

.quick-exercise-input-row.hidden {
  display: none;
}

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

.quick-exercise-selected {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  flex-shrink: 0;
}

.quick-exercise-emoji {
  font-size: 18px;
}

.quick-exercise-input-row .form-control {
  flex: 1;
  padding: 8px 12px;
  font-size: 13px;
  min-width: 0;
}

.quick-exercise-input-row .btn-sm {
  padding: 8px 14px;
  font-size: 13px;
  border-radius: var(--border-radius-sm);
  flex-shrink: 0;
}

.quick-exercise-input-row .btn-icon {
  flex-shrink: 0;
  color: var(--text-muted);
}

.quick-exercise-input-row .btn-icon:hover {
  color: var(--accent-orange);
}

/* ==========================================
   Charts Layout
   ========================================== */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.chart-card {
  padding: 28px;
  display: flex;
  flex-direction: column;
}

.chart-card.lg-col {
  grid-column: span 2;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.chart-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.chart-legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-secondary);
}

.chart-legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot.weight { background-color: var(--accent-orange); }
.dot.energy { background-color: var(--accent-violet); }
.dot.mood { background-color: var(--accent-pink); }
.dot.if-fasting { background-color: var(--accent-blue); }
.dot.if-eating { background-color: var(--accent-yellow); }
.dot.stage-deep { background-color: #1e3a8a; }
.dot.stage-rem { background-color: #7c3aed; }
.dot.stage-light { background-color: #60a5fa; }
.dot.stage-awake { background-color: #f87171; }
.dot.overlay-sleep { background-color: rgba(59, 130, 246, 0.55); }
.dot.overlay-hrv { background-color: rgba(16, 185, 129, 0.55); }
.dot.watch-steps { background-color: #ea580c; }
.dot.oura-steps { background-color: #10b981; }
.dot.hr-min { background-color: #60a5fa; }
.dot.hr-avg { background-color: #c026d3; }
.dot.hr-max { background-color: #ef4444; }
.dot.glucose-line { background-color: #ef4444; }
.dot.juice-marker { background-color: #ea580c; }
.dot.range-band { background-color: rgba(16, 185, 129, 0.2); border: 1px solid #10b981; }

/* Glucose KPI arrow */
.glucose-arrow {
  font-size: 0.65em;
  margin-left: 6px;
  opacity: 0.85;
  font-weight: 700;
}
.glucose-arrow.rising { color: #ef4444; }
.glucose-arrow.falling { color: #3b82f6; }
.glucose-arrow.flat { color: #10b981; }

/* Glucose-at-log chip shown next to juice entries in history */
.juice-glucose-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.1);
  color: #b91c1c;
  font-size: 11px;
  font-weight: 600;
  margin-left: 6px;
}
body.dark-theme .juice-glucose-chip {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

/* Quick Log Bolus stepper */
.quick-bolus-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin: 8px 0 14px;
  border-radius: 14px;
  background: rgba(59, 130, 246, 0.06);
  border: 1px solid rgba(59, 130, 246, 0.12);
}
.quick-bolus-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-blue);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.quick-bolus-stepper {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.quick-bolus-input {
  width: 70px !important;
  text-align: center;
  padding: 6px 8px !important;
  font-size: 14px !important;
  font-weight: 600;
}
.bolus-step {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.1);
  background: rgba(255,255,255,0.6);
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
body.dark-theme .bolus-step {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.1);
  color: var(--text-primary);
}
.quick-bolus-units {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
}
.quick-bolus-presets {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.bolus-preset-chip {
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid rgba(59, 130, 246, 0.25);
  background: rgba(255, 255, 255, 0.7);
  color: var(--accent-blue);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition:
    background-color 0.18s ease,
    color 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.22s ease,
    transform 0.12s ease;
}
.bolus-preset-chip:hover {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.4);
  box-shadow: 0 4px 12px -6px rgba(59, 130, 246, 0.55);
}
.bolus-preset-chip:active { transform: scale(0.95); }
.bolus-preset-chip.active {
  background: var(--accent-blue);
  color: #fff;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18), 0 6px 14px -6px rgba(59, 130, 246, 0.6);
}
body.dark-theme .bolus-preset-chip {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(59, 130, 246, 0.3);
}
body.dark-theme .bolus-preset-chip:hover {
  background: rgba(59, 130, 246, 0.18);
}

/* Pulse highlight when a juice is logged */
.quick-bolus-row.flash {
  animation: bolus-flash 1.2s ease-out;
}
@keyframes bolus-flash {
  0%   { background: rgba(16, 185, 129, 0.3); }
  100% { background: rgba(59, 130, 246, 0.06); }
}

/* Basal AM / PM section in drawer */
.insulin-basal-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.insulin-basal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-sublabel {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Insulin chip on juice in history + bolus inline edit */
.juice-insulin-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.12);
  color: #2563eb;
  font-size: 11px;
  font-weight: 600;
  margin-left: 6px;
  cursor: pointer;
}
body.dark-theme .juice-insulin-chip {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}
.juice-insulin-chip.empty {
  opacity: 0.5;
}

/* Insulin chart legend dots */
.dot.insulin-basal { background-color: #3b82f6; }
.dot.insulin-basal-pm { background-color: #6366f1; }
.dot.insulin-bolus { background-color: #ea580c; }

/* Basal pills in history bio row */
.bio-pill.basal {
  background: rgba(59, 130, 246, 0.08);
  color: #2563eb;
}
body.dark-theme .bio-pill.basal {
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
}

/* Bolus input inline in drawer's consumed juice list */
.logged-juice-item .juice-bolus-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  font-size: 12px;
}
.juice-bolus-inline input {
  width: 50px;
  padding: 3px 6px !important;
  font-size: 12px !important;
  text-align: center;
}

/* Workouts list */
.workouts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 4px 4px;
}
.workout-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(0,0,0,0.03);
  border: 1px solid rgba(0,0,0,0.05);
}
body.dark-theme .workout-item {
  background: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.06);
}
.workout-emoji { font-size: 22px; }
.workout-main { flex: 1; display: flex; flex-direction: column; }
.workout-type { font-weight: 600; }
.workout-meta { font-size: 12px; color: var(--text-secondary); }
.workout-date { font-size: 12px; color: var(--text-secondary); }

/* Biometrics tab header (source chips + refresh button) */
.biometrics-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.bio-source-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--glass-bg, rgba(255,255,255,0.6));
  border: 1px solid var(--border-color, rgba(0,0,0,0.08));
  font-size: 13px;
  font-weight: 500;
}
.bio-source-chip.muted { opacity: 0.55; }
.bio-source-chip i { color: var(--accent-blue); }
.bio-source-hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-secondary);
  font-style: italic;
}
.bio-sync-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #cbd5e1;
}
.bio-sync-dot.ok { background-color: #10b981; }
.bio-sync-dot.syncing {
  background-color: #f59e0b;
  animation: bio-pulse 1.2s ease-in-out infinite;
}
.bio-sync-dot.error { background-color: #ef4444; }
.bio-sync-dot.pending { background-color: #cbd5e1; }
@keyframes bio-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}
.btn-sm { padding: 6px 14px; font-size: 13px; margin-left: auto; }

.chart-wrapper {
  position: relative;
  width: 100%;
  height: 280px;
}

/* ==========================================
   Exercise Grid (GitHub style)
   ========================================== */
.exercise-grid-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.exercise-grid {
  display: flex;
  gap: 4px;
}

.exercise-day-cell {
  width: 34px;
  height: 34px;
  background-color: var(--input-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  transition: var(--transition-bounce);
}

.exercise-day-cell:hover {
  transform: scale(1.15);
  z-index: 2;
  border-color: var(--text-secondary);
}

.exercise-day-cell.active {
  background: linear-gradient(135deg, rgba(5, 150, 105, 0.25) 0%, rgba(5, 150, 105, 0.7) 100%);
  border-color: var(--accent-green);
  color: white;
  box-shadow: 0 0 10px rgba(5, 150, 105, 0.15);
}

body.dark-theme .exercise-day-cell.active {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.4) 0%, rgba(5, 150, 105, 0.8) 100%);
}

/* Tooltip on hover */
.exercise-day-cell .tooltip {
  visibility: hidden;
  width: 160px;
  background-color: #0f172a;
  color: #fff;
  text-align: center;
  border-radius: var(--border-radius-sm);
  padding: 8px 12px;
  position: absolute;
  z-index: 10;
  bottom: 130%;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  font-size: 11px;
  line-height: 1.4;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.15);
  pointer-events: none;
  border: 1px solid rgba(255,255,255,0.1);
}

.exercise-day-cell:hover .tooltip {
  visibility: visible;
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

.exercise-grid-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  font-size: 11px;
  color: var(--text-secondary);
}

.exercise-grid-legend .cell {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background-color: var(--input-bg);
  border: 1px solid var(--glass-border);
}

.exercise-grid-legend .cell.active {
  background-color: var(--accent-green);
}

/* ==========================================
   Tab Panel Switcher
   ========================================== */
.tab-pane {
  display: none;
  animation: fadeIn 0.4s ease;
}

.tab-pane.active {
  display: block;
}

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

/* ==========================================
   History (Timeline) View
   ========================================== */
.history-controls {
  margin-bottom: 30px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  max-width: 500px;
  border-radius: 50px;
}

.search-box i {
  color: var(--text-secondary);
  font-size: 18px;
}

.search-box input {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 15px;
  width: 100%;
}

.search-box input:focus {
  outline: none;
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: relative;
  padding-left: 20px;
}

.timeline::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  background: var(--glass-border);
}

.no-logs {
  padding: 80px 20px;
  text-align: center;
  color: var(--text-secondary);
}

.no-logs i {
  font-size: 48px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.timeline-card {
  padding: 24px;
  position: relative;
}

.timeline-card::before {
  content: '';
  position: absolute;
  top: 30px;
  left: -26px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-orange);
  border: 3px solid var(--bg-sidebar);
  box-shadow: 0 0 0 4px rgba(234, 88, 12, 0.15);
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.timeline-date h4 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 2px;
}

.timeline-weight {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  background: rgba(234, 88, 12, 0.08);
  color: var(--accent-orange);
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid rgba(234, 88, 12, 0.15);
}

.timeline-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.timeline-juices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.juice-bubble {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 50px;
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  gap: 6px;
}

body.dark-theme .juice-bubble {
  background: rgba(255, 255, 255, 0.05);
}

.juice-color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.timeline-biometrics {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
}

.bio-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
}

.bio-pill i {
  color: var(--accent-violet);
}

.bio-pill.fasting i {
  color: var(--accent-blue);
}

.timeline-symptoms {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.symptom-tag {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.06);
  color: #ea580c;
  border: 1px solid rgba(239, 68, 68, 0.12);
}

.symptom-tag.positive {
  background: rgba(5, 150, 105, 0.06);
  color: var(--accent-green);
  border: 1px solid rgba(5, 150, 105, 0.12);
}

.timeline-exercise {
  font-size: 13px;
  background: rgba(5, 150, 105, 0.03);
  border-left: 3px solid var(--accent-green);
  padding: 8px 12px;
  border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
}

.timeline-observations {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  border-top: 1px solid var(--glass-border);
  padding-top: 12px;
}

.card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-bounce);
}

.btn-icon:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-primary);
}

body.dark-theme .btn-icon:hover {
  background: rgba(255, 255, 255, 0.05);
}

.btn-icon.danger:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
}

/* ==========================================
   Recipe Library View
   ========================================== */
.recipes-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.recipes-header h2 {
  font-size: 26px;
}

.recipes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.recipe-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.recipe-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--recipe-color, var(--accent-orange));
}

.recipe-card h4 {
  font-size: 18px;
  margin-bottom: 8px;
}

.recipe-ingredients {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
  flex-grow: 1;
}

.recipe-card .btn-quick-log {
  margin-top: auto;
}

/* ==========================================
   Buttons Setup
   ========================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  padding: 12px 24px;
  border-radius: var(--border-radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition-bounce);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-orange) 0%, #ff8e53 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(234, 88, 12, 0.2);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(234, 88, 12, 0.35);
}

.btn-secondary {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: rgba(0, 0, 0, 0.02);
  border-color: var(--glass-border-focus);
}

body.dark-theme .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.05);
}

.btn-text {
  background: none;
  border: none;
  color: var(--accent-orange);
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

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

.btn-full {
  width: 100%;
}

.btn-log-trigger {
  margin-top: 16px;
  padding: 14px 20px;
}

/* ==========================================
   Logging Drawer (Forms & Inputs)
   ========================================== */
.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

body.dark-theme .drawer-overlay {
  background: rgba(0, 0, 0, 0.6);
}

.drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.logger-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 480px;
  height: 100%;
  border-radius: 0;
  border-left: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  box-shadow: -10px 0 40px rgba(15, 23, 42, 0.08);
}

body.dark-theme .logger-drawer {
  background: linear-gradient(180deg,
    rgba(30, 41, 59, 0.96) 0%,
    rgba(17, 24, 39, 0.96) 100%);
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: -16px 0 50px rgba(0, 0, 0, 0.65);
  /* Tell browser to render native UI (date/time pickers, scrollbars) in dark mode */
  color-scheme: dark;
}
body.dark-theme .drawer-overlay {
  background: rgba(0, 0, 0, 0.7);
}

/* Ensure all native date/time/number inputs across the app pick the dark scheme */
body.dark-theme input[type="date"],
body.dark-theme input[type="time"],
body.dark-theme input[type="number"] {
  color-scheme: dark;
}

/* Fix the inline juice-bolus number input visibility in dark mode (had no form-control class earlier) */
.juice-bolus-inline input.juice-bolus-input {
  background: var(--input-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  border-radius: 6px;
}
.juice-bolus-inline input.juice-bolus-input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.18);
}

.drawer-overlay.open .logger-drawer {
  transform: translateX(0);
}

.drawer-header {
  padding: 30px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-header h2 {
  font-size: 22px;
  margin-bottom: 4px;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-bounce);
}

.close-btn:hover {
  background: rgba(0, 0, 0, 0.03);
  color: var(--text-primary);
}

body.dark-theme .close-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

.drawer-form {
  flex-grow: 1;
  overflow-y: auto;
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.form-label.secondary {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 6px;
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.metric-value-display {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--accent-orange);
}

.form-control {
  background: var(--input-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  padding: 14px 16px;
  color: var(--text-primary);
  font-size: 15px;
  transition: var(--transition-smooth);
  width: 100%;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-orange);
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.12);
}

/* Custom Styled Input Range Sliders */
.slider-field {
  margin-bottom: 20px;
}

.slider-value {
  font-size: 13px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.02);
  padding: 2px 10px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
}

body.dark-theme .slider-value {
  background: rgba(255, 255, 255, 0.05);
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 5px;
  background: var(--input-bg);
  outline: none;
  margin: 12px 0 8px 0;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-orange) 0%, #ff8e53 100%);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(234,88,12,0.3);
  transition: var(--transition-bounce);
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.slider-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

/* iOS Style Switch */
.ios-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
}

.ios-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.ios-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--input-bg);
  border: 1px solid var(--glass-border);
  border-radius: 34px;
  transition: .4s;
}

.ios-slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  border-radius: 50%;
  transition: .4s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

input:checked + .ios-slider {
  background-color: var(--accent-green);
  border-color: var(--accent-green);
}

input:checked + .ios-slider:before {
  transform: translateX(24px);
}

.exercise-details-field {
  display: none;
  animation: slideDown 0.3s ease;
}

.exercise-details-field.open {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Presets Tap Row */
.presets-row-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.presets-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.btn-preset {
  background: var(--input-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  padding: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  transition: var(--transition-bounce);
}

.btn-preset:hover {
  transform: translateY(-2px);
  background: rgba(0,0,0,0.02);
  border-color: var(--glass-border-focus);
}

body.dark-theme .btn-preset:hover {
  background: rgba(255,255,255,0.03);
}

.preset-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px var(--juice-color, var(--accent-orange));
}

.preset-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.preset-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.preset-desc {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Logged Items List */
.logged-items-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.empty-list-hint {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 12px;
  border: 1px dashed var(--glass-border);
  border-radius: var(--border-radius-md);
}

.logged-juice-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(0,0,0,0.01);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-sm);
  gap: 10px;
}

body.dark-theme .logged-juice-item {
  background: rgba(255,255,255,0.02);
}

.logged-juice-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-grow: 1;
}

.logged-juice-title {
  font-size: 13px;
  font-weight: 600;
}

.logged-juice-ingredients {
  font-size: 11px;
  color: var(--text-secondary);
}

.logged-juice-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.logged-juice-qty {
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-display);
}

/* Custom Inline Time Input for Logged Juices */
.logged-juice-time-input {
  background: var(--input-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-sm);
  padding: 4px 6px;
  font-size: 12px;
  color: var(--text-primary);
  outline: none;
  width: 76px;
  text-align: center;
  font-weight: 500;
}

.logged-juice-time-input:focus {
  border-color: var(--accent-orange);
}

.total-volume-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 700;
  border-top: 1px solid var(--glass-border);
  padding-top: 10px;
}

#formTotalVolume {
  color: var(--accent-green);
  font-family: var(--font-display);
}

/* Symptoms pills container */
.symptom-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.symptom-pill {
  position: relative;
  cursor: pointer;
}

.symptom-pill input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

.symptom-pill span {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 50px;
  background: var(--input-bg);
  border: 1px solid var(--glass-border);
  font-size: 13px;
  transition: var(--transition-bounce);
  user-select: none;
}

.symptom-pill:hover span {
  border-color: var(--glass-border-focus);
}

.symptom-pill input:checked + span {
  background: linear-gradient(135deg, rgba(234, 88, 12, 0.08) 0%, rgba(234, 88, 12, 0.18) 100%);
  border-color: var(--accent-orange);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(234, 88, 12, 0.1);
}

.drawer-actions {
  margin-top: auto;
  padding-top: 20px;
}

.hidden {
  display: none !important;
}

/* Spinner */
.btn-spinner {
  display: flex;
  align-items: center;
}

/* ==========================================
   Modals Setup
   ========================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 110;
  opacity: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  transition: opacity 0.3s ease;
}

body.dark-theme .modal-overlay {
  background: rgba(0, 0, 0, 0.7);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  width: 100%;
  max-width: 440px;
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
  animation: modalScale 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

body.dark-theme .modal {
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

@keyframes modalScale {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--glass-border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Recipe theme color picker */
.color-picker-grid {
  display: flex;
  gap: 12px;
}

.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: var(--transition-bounce);
}

.color-swatch:hover {
  transform: scale(1.15);
}

.color-swatch.active {
  border-color: var(--text-primary);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
}

body.dark-theme .color-swatch.active {
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

/* ==========================================
   Success Screen Overlay
   ========================================== */
.success-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(250, 248, 245, 0.95);
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

body.dark-theme .success-overlay {
  background: rgba(8, 11, 17, 0.95);
}

.success-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.success-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  transform: scale(0.8);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.success-overlay.open .success-content {
  transform: scale(1);
}

.success-circle {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-green) 0%, #34d399 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 40px;
  box-shadow: 0 10px 30px rgba(5, 150, 105, 0.3);
}

.success-content h2 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
}

/* ==========================================
   Animations & Keyframes
   ========================================== */
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.5);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(5, 150, 105, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(5, 150, 105, 0);
  }
}

/* ==========================================
   Mobile Bottom Navigation
   ========================================== */
.mobile-nav {
  display: none;
}

/* ==========================================
   Responsive Breakpoints & Media Queries
   ========================================== */

/* Tablet View Adjustments */
@media (max-width: 991px) {
  .sidebar {
    width: 80px;
    padding: 32px 12px;
    align-items: center;
  }
  
  .logo-text, .sidebar-brand {
    justify-content: center;
  }

  .logo-text, .nav-item span, .sidebar-footer, .btn-log-trigger span {
    display: none;
  }
  
  .nav-item {
    padding: 14px;
    justify-content: center;
    transform: none !important;
  }
  
  .btn-log-trigger {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    padding: 0;
  }
  
  .main-content {
    width: calc(100% - 80px);
    padding: 24px;
  }
}

/* Mobile & Google Pixel 10 Pro Optimizations */
@media (max-width: 767px) {
  .sidebar {
    display: none; /* Hide sidebar completely */
  }
  
  .main-content {
    width: 100%;
    padding: 20px;
    padding-bottom: 110px; /* Leave room for bottom nav */
  }
  
  .top-bar {
    margin-bottom: 24px;
  }
  
  #pageTitle {
    font-size: 26px;
  }
  
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
  }
  
  .kpi-card {
    padding: 16px;
    gap: 12px;
    border-radius: var(--border-radius-md);
  }
  
  .kpi-icon {
    width: 44px;
    height: 44px;
    font-size: 16px;
  }
  
  .kpi-value {
    font-size: 20px;
  }
  
  .kpi-value small {
    font-size: 11px;
  }
  
  .charts-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .chart-card {
    grid-column: span 1 !important;
    padding: 18px;
    border-radius: var(--border-radius-md);
  }
  
  .chart-wrapper {
    height: 220px;
  }
  
  /* Mobile Navigation Bar */
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 72px;
    background: var(--bg-sidebar);
    border-top: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 90;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom, 8px); /* Safe area support for notch phones */
  }
  
  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
    gap: 4px;
    flex-grow: 1;
    height: 100%;
    transition: var(--transition-bounce);
  }
  
  .mobile-nav-item i {
    font-size: 18px;
  }
  
  .mobile-nav-item.active {
    color: var(--accent-orange);
  }
  
  /* Large central add button on mobile bottom nav */
  .mobile-log-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-orange) 0%, #ff8e53 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    box-shadow: 0 4px 15px rgba(234, 88, 12, 0.2);
    margin-top: -24px;
    border: 4px solid var(--bg-sidebar);
    transition: var(--transition-bounce);
  }
  
  .mobile-nav-item:hover .mobile-log-circle {
    transform: scale(1.1);
  }
  
  /* Drawer adaptation for fullscreen mobile view */
  .logger-drawer {
    width: 100%;
    height: 100%;
    max-height: 100%;
    border: none;
    border-radius: 0;
  }
  
  .drawer-header {
    padding: 16px 20px;
  }
  
  .drawer-form {
    padding: 20px;
    gap: 20px;
  }
  
  .presets-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .symptom-pills {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }
  
  .symptom-pill span {
    text-align: center;
    width: 100%;
    padding: 10px 6px;
    font-size: 12px;
  }
  
  .recipes-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  
  .recipes-header button {
    width: 100%;
  }
  
  .recipe-card {
    padding: 16px;
  }
}

/* ==========================================
   Calendar View Components
   ========================================== */
.calendar-card {
  padding: 24px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.calendar-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.calendar-header-row h3 {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-display);
}

.calendar-days-grid-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 8px;
}

.calendar-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  text-align: center;
}

.calendar-day-cell {
  position: relative;
  height: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  background: transparent;
  transition: var(--transition-bounce);
  user-select: none;
}

.calendar-day-cell:hover:not(.empty) {
  background: var(--input-bg);
  transform: scale(1.08);
}

.calendar-day-cell.empty {
  cursor: default;
  pointer-events: none;
  opacity: 0.15;
}

.calendar-day-cell.today {
  border: 2px solid var(--accent-orange);
  color: var(--text-primary);
  font-weight: 700;
}

.calendar-day-cell.logged {
  background: rgba(5, 150, 105, 0.08);
  border: 1px solid rgba(5, 150, 105, 0.15);
  color: var(--accent-green);
  font-weight: 600;
}

body.dark-theme .calendar-day-cell.logged {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.25);
  color: var(--accent-green);
}

/* Juice Drop Dot Indicator inside Calendar Days */
.calendar-day-cell.logged::after {
  content: '';
  position: absolute;
  bottom: 4px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background-color: var(--accent-green);
}

/* ==========================================
   Custom Symptoms Adder Row
   ========================================== */
.custom-symptom-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  width: 100%;
}

/* ==========================================
   Multi-Activity Exercise Logger
   ========================================== */
.exercise-editor-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  width: 100%;
}

.form-exercises-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 20px;
}

.exercise-item-chip {
  display: inline-flex;
  align-items: center;
  background: var(--input-bg);
  border: 1px solid var(--glass-border);
  padding: 6px 12px;
  border-radius: 50px;
  font-size: 13px;
  gap: 8px;
  animation: floatIn 0.3s ease;
}

.exercise-item-chip button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  border-radius: 50%;
  transition: var(--transition-bounce);
}

.exercise-item-chip button:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
}

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

/* Timeline Cards Exercises list */
.timeline-exercise-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(5, 150, 105, 0.02);
  border-left: 3px solid var(--accent-green);
  padding: 8px 12px;
  border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
  font-size: 13px;
}

.timeline-exercise-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.timeline-exercise-item i {
  color: var(--accent-green);
  width: 16px;
}

/* ==========================================
   Photo Library Tab
   ========================================== */

/* Top bar */
.photos-tab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

/* Filter chips */
.photo-filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.photo-filter-chip {
  padding: 7px 16px;
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.photo-filter-chip:hover {
  border-color: var(--accent-orange);
  color: var(--accent-orange);
}

.photo-filter-chip.active {
  background: var(--accent-orange);
  color: #fff;
  border-color: var(--accent-orange);
}

/* Day group */
.photo-day-group {
  margin-bottom: 36px;
}

.photo-day-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.photo-day-badge {
  background: var(--accent-orange);
  color: #fff;
  border-radius: 20px;
  padding: 3px 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.photo-day-date {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Photos grid */
.photos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

@media (max-width: 700px) {
  .photos-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Individual photo card */
.photo-card {
  position: relative;
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.photo-card:hover {
  transform: scale(1.025);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
}

.photo-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.photo-card:hover img {
  transform: scale(1.04);
}

/* Top overlay row: badge + delete */
.photo-card-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.52) 0%, transparent 100%);
  pointer-events: none;
}

.photo-cat-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--cat-color) 20%, transparent);
  color: var(--cat-color);
  border: 1px solid color-mix(in srgb, var(--cat-color) 40%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: none;
}

.photo-delete-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  font-size: 11px;
  transition: opacity 0.18s ease, background 0.18s ease;
  pointer-events: all;
}

.photo-card:hover .photo-delete-btn {
  opacity: 1;
}

.photo-delete-btn:hover {
  background: rgba(239, 68, 68, 0.85);
}

/* Bottom caption strip */
.photo-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 22px 10px 9px;
  font-size: 12px;
  font-weight: 500;
  color: #fff;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.68) 0%, transparent 100%);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Empty state */
.photos-empty-state {
  text-align: center;
  padding: 80px 24px;
  color: var(--text-secondary);
}

.photos-empty-icon {
  font-size: 64px;
  margin-bottom: 18px;
  opacity: 0.8;
}

.photos-empty-state h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.photos-empty-state p {
  font-size: 15px;
  margin-bottom: 28px;
}

/* ==========================================
   Photo Upload Modal
   ========================================== */

/* Drop zone */
.photo-dropzone {
  border: 2px dashed var(--glass-border);
  border-radius: 14px;
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
  overflow: hidden;
}

.photo-dropzone:hover {
  border-color: var(--accent-orange);
  background: rgba(234, 88, 12, 0.04);
}

.photo-dropzone.has-file {
  border-style: solid;
  border-color: var(--accent-orange);
  padding: 6px;
}

.photo-dropzone-content i {
  font-size: 30px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 10px;
}

.photo-dropzone-content p {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.photo-preview-img {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 8px;
}

/* Category picker inside modal */
.photo-cat-selector {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.photo-cat-btn {
  padding: 8px 14px;
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
}

.photo-cat-btn:hover {
  border-color: var(--accent-orange);
  color: var(--accent-orange);
}

.photo-cat-btn.active {
  background: rgba(234, 88, 12, 0.12);
  border-color: var(--accent-orange);
  color: var(--accent-orange);
  font-weight: 600;
}

/* ==========================================
   Photo Lightbox
   ========================================== */

.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.96);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 24px 24px;
  animation: lbFadeIn 0.18s ease;
}

@keyframes lbFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

.lightbox-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  max-width: min(90vw, 900px);
  max-height: calc(100vh - 120px);
}

#lightboxImg {
  max-width: 100%;
  max-height: calc(100vh - 200px);
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.lightbox-info {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.lightbox-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.lightbox-cat {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-orange);
  letter-spacing: 0.3px;
}

.lightbox-date {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
}

.lightbox-caption {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.88);
  margin: 0;
  max-width: 600px;
}

.lightbox-close {
  position: fixed;
  top: 18px;
  right: 18px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
  z-index: 10001;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

.lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, opacity 0.15s ease;
  z-index: 10001;
}

.lightbox-nav:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.25);
}

.lightbox-nav.prev { left: 16px; }
.lightbox-nav.next { right: 16px; }

@media (max-width: 600px) {
  .lightbox-nav.prev { left: 6px; }
  .lightbox-nav.next { right: 6px; }
  .lightbox-nav { width: 40px; height: 40px; font-size: 15px; }
}

