/* 
 * Health & Performance Tracker - Premium Glassmorphic Stylesheet
 * Version: 1.9.48
 * Responsive layout using a deep slate background, teal and violet accents, and micro-interactions.
 */

:root {
  /* Color Palette (HSL Tailored) */
  --bg-app: hsl(158, 40%, 9%);
  --bg-card: hsla(158, 40%, 14%, 0.65);
  --border-card: hsla(158, 38%, 25%, 0.4);
  --border-card-hover: hsla(42, 44%, 50%, 0.4);
  
  --text-primary: hsl(0, 0%, 100%);
  --text-secondary: hsl(150, 10%, 79%);
  --text-muted: hsl(153, 10%, 52%);
  
  --color-accent: hsl(42, 44%, 50%); /* Gold/Copper */
  --color-accent-light: hsla(42, 44%, 50%, 0.15);
  --color-peptide: hsl(38, 88%, 65%); /* Brass */
  --color-peptide-light: hsla(38, 88%, 65%, 0.15);
  --color-warning: hsl(38, 92%, 50%); /* Amber: Alerts/Abnormal */
  --color-warning-light: hsla(38, 92%, 50%, 0.15);
  --color-danger: hsl(354, 70%, 54%); /* Red: Avoid/IgG Exclusions */
  --color-danger-light: hsla(354, 70%, 54%, 0.15);
  --color-success: hsl(142, 69%, 45%); /* Green: Optimal/Success */
  --color-success-light: hsla(142, 69%, 45%, 0.15);

  /* Typography */
  --font-family-header: 'Outfit', sans-serif;
  --font-family-body: 'Inter', sans-serif;
  
  /* Spacing & Borders */
  --border-radius-lg: 16px;
  --border-radius-md: 10px;
  --border-radius-sm: 6px;
  --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);

  /* Input & Surface Colors */
  --border-input: rgba(255, 255, 255, 0.15);
  --border-input-subtle: rgba(255, 255, 255, 0.1);
  --bg-input: rgba(0, 0, 0, 0.2);
  --bg-input-dark: rgba(0, 0, 0, 0.3);
  --bg-input-settings: rgba(15, 23, 42, 0.6);
  --bg-subtle: rgba(255, 255, 255, 0.05);
  --bg-subtle-dim: rgba(255, 255, 255, 0.02);
}

/* Global Reset & Base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-family-body);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  padding-bottom: 85px; /* Space for bottom nav */
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-family-header);
  font-weight: 600;
  color: var(--text-primary);
}

/* Header Styling */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  background: hsla(158, 25%, 8%, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-card);
}

.header-logo h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.header-logo .sub-logo {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Viewport Containers */
.app-viewport {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.3s ease;
}

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

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

.tab-header {
  margin-bottom: 24px;
}

.tab-header h2 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 4px;
}

.tab-header p {
  color: var(--text-secondary);
  font-size: 14px;
}

/* Date Header Card */
.date-header-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--border-radius-md);
  padding: 12px 16px;
  margin-bottom: 20px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.date-header-card h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
}

/* Card Structures */
.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--border-radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: var(--transition-smooth);
}

.glass-card:hover {
  border-color: var(--border-card-hover);
  box-shadow: 0 8px 32px hsla(171, 100%, 5%, 0.25);
}

/* Card Collapsibility */
.card-header-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  width: 100%;
}

.card-header-toggle h3 {
  margin-bottom: 0 !important;
  flex: 1;
}

.card-collapsible-content {
  max-height: 2500px;
  overflow: hidden;
  transition: max-height 0.4s ease-out, opacity 0.3s ease-out;
  opacity: 1;
}

.collapsed .card-collapsible-content {
  max-height: 0 !important;
  opacity: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

.glass-card.collapsed {
  padding-bottom: 12px !important;
}

.collapse-icon {
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: transform 0.3s ease;
  margin-left: 10px;
  user-select: none;
}

.collapsed .collapse-icon {
  transform: rotate(180deg);
}

/* Uncompleted item highlight */
.glass-card.card-highlight-pending {
  border-color: hsla(42, 44%, 50%, 0.6) !important;
  box-shadow: 0 0 10px hsla(42, 44%, 50%, 0.25) !important;
}

.glass-card.card-highlight-pending:hover {
  border-color: var(--color-accent) !important;
  box-shadow: 0 0 15px hsla(42, 44%, 50%, 0.4) !important;
}

.glass-card h3 {
  font-size: 18px;
  margin-bottom: 16px;
  border-left: 3px solid var(--color-accent);
  padding-left: 10px;
  color: var(--text-primary);
}

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

.card-header-actions h3 {
  margin-bottom: 0;
}

.card-divider {
  border: 0;
  height: 1px;
  background: var(--border-card);
  margin: 20px 0;
}

/* Grids */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.dashboard-col {
  display: contents !important;
}

#card-habits { order: 1 !important; }
#card-sleep { order: 2 !important; }
#card-hydration-fasting { order: 3 !important; }
#card-nutrition { order: 4 !important; }
#card-meal-logs { order: 5 !important; }
#card-workouts { order: 6 !important; }
#card-peptides { order: 7 !important; }
#card-migraine-tracker { order: 8 !important; }

.tab-grid-two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 768px) {
  .tab-grid-two-column {
    grid-template-columns: 1fr;
  }
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.full-width-card {
  grid-column: 1 / -1;
}

/* Checkbox Lists */
.checkbox-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Habits & Supplement section headings */
#habits-list-container {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.habits-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin: 16px 0 8px 0;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--color-accent-light);
}

#habits-list-container > .checkbox-list {
  margin-bottom: 4px;
}

.checkbox-container {
  display: flex;
  align-items: center;
  position: relative;
  padding-left: 32px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  user-select: none;
  transition: var(--transition-smooth);
}

.checkbox-container input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.checkmark {
  position: absolute;
  top: 0;
  left: 0;
  height: 22px;
  width: 22px;
  background-color: hsla(158, 20%, 30%, 0.4);
  border: 1px solid var(--border-card);
  border-radius: var(--border-radius-sm);
  transition: var(--transition-smooth);
}

.checkbox-container:hover input ~ .checkmark {
  background-color: hsla(158, 20%, 40%, 0.6);
  border-color: var(--color-accent);
}

.checkbox-container input:checked ~ .checkmark {
  background-color: var(--color-accent);
  border-color: var(--color-accent);
}

.checkmark:after {
  content: "";
  position: absolute;
  display: none;
}

.checkbox-container input:checked ~ .checkmark:after {
  display: block;
}

.checkbox-container .checkmark:after {
  left: 7px;
  top: 3px;
  width: 5px;
  height: 10px;
  border: solid var(--bg-app);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checkbox-container input:checked ~ span {
  color: var(--text-primary);
  text-decoration: line-through;
  opacity: 0.6;
}

/* User Toggle Switch */
.user-toggle-container {
  display: flex;
  align-items: center;
  gap: 8px;
  background: hsla(158, 20%, 15%, 0.8);
  padding: 4px 6px;
  border-radius: 30px;
  border: 1px solid var(--border-card);
}

.user-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-smooth);
  padding: 4px 10px;
  border-radius: 20px;
}

.user-label.active {
  color: var(--bg-app);
}

.user-label.cabot-label.active {
  background-color: var(--color-accent);
}

.user-label.ginesta-label.active {
  background-color: var(--color-peptide);
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: hsl(158, 15%, 25%);
  transition: .3s;
  border: 1px solid var(--border-card);
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-primary);
  transition: .3s;
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

input:checked + .slider {
  background-color: hsl(158, 15%, 25%);
}

input:checked + .slider:before {
  transform: translateX(22px);
}

/* Small switches for low energy */
.tired-toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  background: hsla(158, 20%, 30%, 0.3);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border-card);
}

.tired-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.switch-small {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 18px;
}

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

.slider-small {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: hsl(158, 15%, 25%);
  transition: .3s;
}

.slider-small:before {
  position: absolute;
  content: "";
  height: 12px;
  width: 12px;
  left: 2px;
  bottom: 3px;
  background-color: var(--text-primary);
  transition: .3s;
}

.slider-small.round {
  border-radius: 18px;
}

.slider-small.round:before {
  border-radius: 50%;
}

input:checked + .slider-small {
  background-color: var(--color-warning);
}

input:checked + .slider-small:before {
  transform: translateX(16px);
  background-color: var(--bg-app);
}

/* Buttons */
button {
  cursor: pointer;
  border: 0;
  outline: none;
  font-family: var(--font-family-body);
  font-weight: 500;
  transition: var(--transition-smooth);
}

.btn-primary {
  background-color: var(--color-accent);
  color: var(--bg-app);
  font-weight: 600;
  padding: 10px 16px;
  border-radius: var(--border-radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary:hover {
  background-color: hsl(171, 100%, 35%);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: hsla(158, 20%, 35%, 0.4);
  color: var(--text-primary);
  border: 1px solid var(--border-card);
  padding: 10px 16px;
  border-radius: var(--border-radius-sm);
}

.btn-secondary:hover {
  background-color: hsla(158, 20%, 45%, 0.6);
  border-color: var(--text-muted);
}

.btn-tertiary {
  background-color: transparent;
  color: var(--text-muted);
  font-size: 13px;
  text-decoration: underline;
}

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

.btn-icon {
  background: hsla(158, 20%, 30%, 0.4);
  border: 1px solid var(--border-card);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.btn-icon:hover {
  background: hsla(158, 20%, 40%, 0.6);
  border-color: var(--color-accent);
}

/* Input Fields */
input[type="text"],
input[type="url"],
input[type="number"],
input[type="password"],
input[type="time"],
select {
  width: 100%;
  background-color: hsla(158, 25%, 12%, 0.8);
  border: 1px solid var(--border-card);
  color: var(--text-primary);
  padding: 10px 12px;
  border-radius: var(--border-radius-sm);
  font-family: var(--font-family-body);
  font-size: 14px;
  outline: none;
  transition: var(--transition-smooth);
}

input[type="text"]:focus,
input[type="url"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
input[type="time"]:focus,
select:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px var(--color-accent-light);
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.input-group label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.input-group-row {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}

.input-group-row .input-group {
  flex: 1;
  margin-bottom: 0;
}

.credential-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.credential-input-row input {
  flex: 1;
}

.btn-toggle-visibility {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
}

.btn-toggle-visibility:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

.inline-form {
  display: flex;
  gap: 8px;
}

.inline-form input {
  flex: 1;
}

/* Hydration Circle Progress */
.hydration-section {
  display: flex;
  align-items: center;
  gap: 20px;
}

.metric-circle {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: conic-gradient(var(--color-accent) 0%, var(--bg-subtle) 0%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
  box-shadow: 0 0 16px var(--color-accent-light);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.metric-circle::after {
  content: '';
  position: absolute;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: hsl(158, 40%, 11%);
  z-index: 1;
}

.metric-circle span {
  position: relative;
  z-index: 2;
  font-weight: 700;
  font-size: 13px;
  color: var(--text-primary);
  text-align: center;
  line-height: 1.2;
}

.hydration-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Fasting Summary layout */
.fasting-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fasting-section h4 {
  font-size: 13px;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

.fasting-summary {
  display: flex;
  justify-content: space-between;
  background: hsla(158, 20%, 10%, 0.5);
  border-radius: var(--border-radius-sm);
  padding: 8px 12px;
  border: 1px solid var(--border-card);
}

.fasting-hours {
  font-weight: 600;
  color: var(--color-accent);
}

.fasting-target {
  font-size: 13px;
  color: var(--text-muted);
}

/* Workouts List Inside Card */
.workout-item-card {
  background: hsla(158, 20%, 5%, 0.4);
  border: 1px solid var(--border-card);
  border-radius: var(--border-radius-md);
  padding: 12px 14px;
  margin-bottom: 10px;
}

.workout-item-card h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.workout-tag {
  background: var(--color-accent-light);
  color: var(--color-accent);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  display: inline-block;
  margin-bottom: 8px;
}

.workout-tag.recovery {
  background: var(--color-warning-light);
  color: var(--color-warning);
}

.workout-checkbox-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.workout-checkbox-list li {
  padding-left: 4px;
}

.workout-checkbox-list .ex-note {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
  padding-left: 32px;
  margin-top: -2px;
}

.wednesday-workout-alert {
  background: var(--color-warning-light);
  border: 1px solid var(--color-warning);
  color: var(--color-warning);
  border-radius: var(--border-radius-md);
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  line-height: 1.4;
}

.wednesday-workout-alert.hidden {
  display: none !important;
}

.substitution-box h4 {
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 8px;
}

/* Peptide Schedules */
.peptide-dosing-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: hsla(263, 70%, 10%, 0.3);
  border: 1px dashed var(--color-peptide);
  border-radius: var(--border-radius-md);
  padding: 12px 14px;
  margin-bottom: 12px;
}

.peptide-details h4 {
  font-size: 15px;
  color: var(--color-peptide);
  margin-bottom: 2px;
}

.peptide-details p {
  font-size: 12px;
  color: var(--text-muted);
}

.peptide-action-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.peptide-dose-badge {
  background-color: var(--color-peptide);
  color: var(--bg-app);
  font-weight: 700;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 12px;
  margin-bottom: 6px;
}

/* Reconstitution Calculator result box */
.reconstitution-calculator h4 {
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 12px;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.calc-input {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.calc-input label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.calc-input input {
  padding: 8px;
  font-size: 13px;
  text-align: center;
}

.calc-result {
  background: hsla(158, 25%, 6%, 0.8);
  border: 1px solid var(--border-card);
  border-radius: var(--border-radius-md);
  padding: 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.result-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.result-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--color-accent);
  letter-spacing: -0.5px;
}

.result-subtext {
  font-size: 11px;
  color: var(--text-muted);
}

/* Migraine Inputs */
.slider-group {
  margin-bottom: 14px;
}

.slider-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.slider-group input[type="range"] {
  width: 100%;
  background: hsla(158, 20%, 30%, 0.4);
  outline: none;
  height: 6px;
  border-radius: 3px;
  appearance: none;
}

.slider-group input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-accent);
  cursor: pointer;
}

.mini-log-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  font-size: 13px;
}

.mini-log-list li {
  padding: 8px 10px;
  background: hsla(158, 20%, 10%, 0.4);
  border: 1px solid var(--border-card);
  border-radius: var(--border-radius-sm);
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
}

/* Gemini Scanner file input */
.scanner-wrapper {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.scanner-input {
  text-align: center;
}

.scanner-input input[type="file"] {
  display: none;
}

.custom-file-upload {
  border: 2px dashed var(--border-card);
  display: inline-block;
  padding: 24px;
  cursor: pointer;
  border-radius: var(--border-radius-md);
  color: var(--text-secondary);
  font-weight: 600;
  transition: var(--transition-smooth);
  width: 100%;
}

.custom-file-upload:hover {
  border-color: var(--color-accent);
  color: var(--text-primary);
  background: var(--color-accent-light);
}

.upload-icon {
  font-size: 28px;
  display: block;
  margin-bottom: 8px;
}

.meal-preview-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.meal-preview-box img {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-card);
}

.scanner-result {
  background: hsla(158, 20%, 6%, 0.8);
  border: 1px solid var(--border-card);
  border-radius: var(--border-radius-md);
  padding: 14px;
}

.scanner-result h4 {
  font-size: 14px;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.macro-badge-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.macro-badge {
  padding: 6px 2px;
  text-align: center;
  border-radius: var(--border-radius-sm);
  font-size: 11px;
  font-weight: 700;
  color: var(--bg-app);
}

.macro-badge.calories { background-color: var(--text-primary); }
.macro-badge.protein { background-color: var(--color-accent); }
.macro-badge.carbs { background-color: var(--color-peptide); }
.macro-badge.fats { background-color: var(--color-warning); }

.scan-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.scan-actions button {
  flex: 1;
}

/* AIP Lookup box results */
.search-box {
  margin-bottom: 16px;
}

.search-box input {
  width: 100%;
}

.lookup-result-box {
  background: hsla(158, 20%, 6%, 0.8);
  border: 1px solid var(--border-card);
  border-radius: var(--border-radius-md);
  padding: 14px;
  margin-bottom: 16px;
  animation: fadeIn 0.2s ease;
}

.lookup-status-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.lookup-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.lookup-status-dot.allowed { background-color: var(--color-success); }
.lookup-status-dot.avoid { background-color: var(--color-danger); }
.lookup-status-dot.deviation { background-color: var(--color-warning); }

.lookup-status-title {
  font-weight: 700;
  font-size: 15px;
}

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

.bullet-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
}

.bullet-list li {
  position: relative;
  padding-left: 16px;
}

.bullet-list li:before {
  content: "•";
  position: absolute;
  left: 4px;
  color: var(--color-accent);
  font-weight: bold;
}

/* Shared Meal Scheduler Layout */
.meal-plan-scheduler {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.meal-slot {
  background: hsla(158, 20%, 10%, 0.4);
  border: 1px solid var(--border-card);
  border-radius: var(--border-radius-md);
  padding: 12px 14px;
  position: relative;
}

.meal-slot h4 {
  font-size: 14px;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.meal-slot p {
  font-size: 13px;
  color: var(--text-secondary);
}

.slot-badge {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 10px;
}

.shared-slot {
  border-left: 3px solid var(--color-accent);
}

.shared-slot .slot-badge {
  background-color: var(--color-accent-light);
  color: var(--color-accent);
}

.solo-slot {
  border-left: 3px solid var(--color-peptide);
}

.solo-slot .slot-badge {
  background-color: var(--color-peptide-light);
  color: var(--color-peptide);
}

/* Staples inventory list */
.checkbox-grid-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.card-staples {
  grid-column: 1 / -1;
}

.shopping-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.shopping-final-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shopping-final-list li {
  background: hsla(158, 20%, 8%, 0.5);
  border: 1px solid var(--border-card);
  border-radius: var(--border-radius-sm);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.shopping-final-list li .checkbox-container {
  padding-left: 28px;
}

/* Bloodwork Table */
.blood-table-wrapper {
  overflow-x: auto;
  margin-top: 10px;
}

.blood-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.blood-table th, 
.blood-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-card);
}

.blood-table th {
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 11px;
}

.blood-table td {
  color: var(--text-primary);
}

.blood-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
}

.blood-badge.optimal {
  background-color: var(--color-success-light);
  color: var(--color-success);
}

.blood-badge.abnormal {
  background-color: var(--color-warning-light);
  color: var(--color-warning);
}

.blood-badge.unchecked {
  background-color: hsla(158, 20%, 30%, 0.2);
  color: var(--text-muted);
}

/* Recommendations Card Results */
.recommendations-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.recommendation-item {
  padding: 14px;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-card);
  font-size: 13px;
  line-height: 1.4;
}

.recommendation-item.success {
  background-color: var(--color-success-light);
  border-color: var(--color-success);
}

.recommendation-item.warning {
  background-color: var(--color-warning-light);
  border-color: var(--color-warning);
}

.recommendation-item.neutral {
  background-color: hsla(158, 20%, 20%, 0.3);
  border-color: var(--border-card);
}

.recommendation-item p {
  margin-bottom: 6px;
}

.recommendation-item p:last-child {
  margin-bottom: 0;
}

/* Settings Layout */
.settings-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.sync-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.sync-status-box {
  padding: 12px;
  border-radius: var(--border-radius-sm);
  font-size: 12px;
  line-height: 1.4;
  margin-top: 12px;
}

.sync-status-box.info {
  background-color: hsla(171, 100%, 41%, 0.1);
  border: 1px solid var(--color-accent);
  color: var(--color-accent);
}

.sync-status-box.error {
  background-color: var(--color-danger-light);
  border: 1px solid var(--color-danger);
  color: var(--color-danger);
}

.manual-backup-controls {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.manual-backup-controls label {
  margin-bottom: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.manual-backup-controls input[type="file"] {
  display: none;
}

/* Bottom Navigation Bar Styles */
.app-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: hsla(158, 25%, 8%, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-card);
  display: flex;
  justify-content: space-around;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  z-index: 1000;
}

.nav-item {
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  flex: 1;
}

.nav-item.active {
  color: var(--color-accent);
}

.nav-icon {
  font-size: 20px;
  transition: var(--transition-smooth);
}

.nav-item:hover .nav-icon {
  transform: translateY(-2px);
}

.nav-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Utilities */
.hidden {
  display: none !important;
}

/* Visually hidden but still focusable/interactive (for file inputs on iOS).
   iOS Safari does not fire the change event on <input type="file"> elements
   that use display:none. This keeps them in the accessibility tree and
   functional while hiding them visually. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Modal Overlay & Dialog Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(14, 34, 27, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

#exercise-detail-modal {
  z-index: 10010 !important;
}

.modal-card {
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: hsl(158, 40%, 11%) !important;
  border: 1px solid var(--border-card) !important;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.6);
  animation: modalFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-body {
  overflow-y: auto;
  flex: 1;
  padding-right: 4px;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-track {
  background: var(--bg-input);
  border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: var(--border-input);
  border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-input-subtle);
  padding-bottom: 12px;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.35rem;
  color: var(--color-accent);
}

.btn-close {
  background: none;
  border: none;
  color: var(--color-text-dim);
  font-size: 1.8rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.2s ease;
}

.btn-close:hover {
  color: var(--color-accent);
}

.ex-clickable-name {
  cursor: pointer;
  text-decoration: underline dotted;
  color: var(--color-text);
  font-weight: 500;
  transition: color 0.2s ease;
}

.ex-clickable-name:hover {
  color: var(--color-accent);
}

/* Calendar Grid Styles */
.calendar-grid-wrapper {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-top: 16px;
  max-height: 55vh;
  overflow-y: auto;
  padding-right: 4px;
  min-width: 750px;
}

.calendar-day-box {
  background: rgba(21, 49, 38, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100px;
}

.calendar-day-box:hover {
  background: rgba(21, 49, 38, 0.7);
  border-color: var(--color-accent);
  transform: translateY(-2px);
}

.calendar-day-box.shared-meal {
  background: rgba(182, 149, 72, 0.05);
  border-color: rgba(182, 149, 72, 0.2);
}

.calendar-day-box.separate-meal {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.25);
}

.calendar-day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--bg-subtle);
  padding-bottom: 4px;
  margin-bottom: 4px;
}

.calendar-day-num {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.calendar-day-date {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}

.calendar-day-status {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.3;
}

.calendar-day-travel-badge {
  font-size: 0.65rem;
  background: rgba(245, 158, 11, 0.15);
  color: var(--color-warning);
  padding: 1px 4px;
  border-radius: 4px;
  font-weight: 600;
  display: inline-block;
  margin-top: 2px;
}

/* Calendar Weekdays and Scroll container */
.calendar-scroll-container {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Force month view to always scroll horizontally, overriding mobile media query */
.calendar-scroll-container.month-view {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
}

.month-day-cell {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  padding: 3px 2px 4px;
  min-height: 72px;
  cursor: pointer;
  position: relative;
  /* Override calendar-day-box defaults for compact month layout */
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  border-right: 1px solid rgba(255,255,255,0.05) !important;
  border-bottom: 1px solid rgba(255,255,255,0.05) !important;
  box-shadow: none !important;
}

.month-day-cell:hover {
  background: rgba(255,255,255,0.05) !important;
  transform: none !important;
}

.month-day-cell.out-of-month {
  opacity: 0.25;
  border-style: solid !important;
}

.month-day-cell.out-of-month:hover {
  opacity: 0.4;
}

/* Day number badge - small, top-left, circular for today */
.month-day-cell .today-num {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  margin-bottom: 2px;
  flex-shrink: 0;
  align-self: center;
}

.month-day-cell.is-today .today-num {
  background: var(--color-accent);
  color: #000;
  font-weight: 700;
  font-size: 0.78rem;
}

/* ISO week number column */
.calendar-week-num {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 6px;
  font-size: 0.58rem;
  font-weight: 500;
  color: var(--text-muted);
  opacity: 0.45;
  border-right: 1px solid rgba(255,255,255,0.05);
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.calendar-week-num-header {
  border-bottom: 1px solid rgba(255,255,255,0.08);
  border-right: 1px solid rgba(255,255,255,0.05);
}

/* Day-name header cells rendered inline as the first 7 cells of the grid */
.calendar-header-cell {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 6px 4px 8px;
  border-bottom: 1px solid var(--border-card);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.calendar-weekdays-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-card);
  margin-bottom: 12px;
  min-width: 750px;
}

.calendar-weekdays-header div {
  padding: 4px;
}

/* Extracted items checklist styling */
.extracted-marker-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: var(--bg-subtle-dim);
  border: 1px solid var(--bg-subtle);
  border-radius: 6px;
  margin-bottom: 6px;
}

.extracted-marker-item:hover {
  background: var(--bg-subtle);
}

.extracted-marker-item label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.extracted-marker-item .extracted-val {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-accent);
}

/* Responsive Mobile Calendar Grid */
@media (max-width: 768px) {
  .calendar-scroll-container {
    overflow-x: visible;
  }
  /* Always hide the standalone weekday header - headers are now inline grid cells */
  .calendar-weekdays-header {
    display: none !important;
  }
  .calendar-grid-wrapper {
    min-width: unset !important;
    grid-template-columns: 1fr !important;
    max-height: none !important;
    overflow-y: visible !important;
    gap: 12px !important;
  }
  .calendar-day-box.placeholder {
    display: none !important;
  }

  /* Full-bleed calendar grid to maximize cell width on mobile */
  .calendar-scroll-container.month-view {
    margin: 0 -20px !important;
    width: calc(100% + 40px) !important;
  }
  
  /* Even more compact cells for a zoomed-out look */
  .calendar-grid-wrapper.month-view .month-day-cell {
    min-height: 58px !important;
    padding: 2px 1px 3px !important;
  }
  
  /* Smaller day headers */
  .calendar-grid-wrapper.month-view .calendar-header-cell {
    font-size: 0.62rem !important;
    padding: 4px 2px 6px !important;
  }
  
  /* Smaller day numbers */
  .calendar-grid-wrapper.month-view .month-day-cell .today-num {
    font-size: 0.65rem !important;
    width: 18px !important;
    height: 18px !important;
    margin-bottom: 1px !important;
  }
  
  .calendar-grid-wrapper.month-view .month-day-cell.is-today .today-num {
    font-size: 0.68rem !important;
  }
  
  /* Smaller week numbers */
  .calendar-grid-wrapper.month-view .calendar-week-num {
    font-size: 0.52rem !important;
    padding-top: 4px !important;
  }
  
  /* Compact chips to fit more text */
  .calendar-grid-wrapper.month-view .calendar-event-chip {
    font-size: 0.52rem !important;
    padding: 1px 2px !important;
    margin-bottom: 1px !important;
    border-radius: 2px !important;
  }
  
  /* Compact overflow indicator */
  .calendar-grid-wrapper.month-view .calendar-chip-overflow {
    font-size: 0.5rem !important;
    line-height: 1.2 !important;
  }
}

/* Daily Nutrition Progress Tracker Styles */
.nutrition-progress-tracker {
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--border-radius-md);
  padding: 14px 16px;
  margin-bottom: 20px;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  transition: var(--transition-smooth);
}

.nutrition-progress-tracker:hover {
  background: rgba(255, 255, 255, 0.025);
  border-color: rgba(255, 255, 255, 0.06);
}

.progress-bar-group {
  margin-bottom: 12px;
}

.progress-bar-group:last-child {
  margin-bottom: 0;
}

.progress-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  margin-bottom: 5px;
}

.progress-bar-label {
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-size: 0.75rem;
}

.progress-bar-value {
  font-weight: 600;
  color: var(--color-accent);
  font-family: monospace;
}

.progress-bar-outer {
  background: var(--bg-input-dark);
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--bg-subtle-dim);
  position: relative;
}

.progress-bar-inner {
  height: 100%;
  border-radius: 4px;
  width: 0%;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.1);
}

/* Macro Gradients */
.progress-bar-inner.calories {
  background: linear-gradient(90deg, hsl(42, 85%, 50%), hsl(38, 95%, 45%));
  box-shadow: 0 0 10px hsla(42, 85%, 50%, 0.3);
}

.progress-bar-inner.protein {
  background: linear-gradient(90deg, hsl(210, 85%, 55%), hsl(195, 90%, 45%));
  box-shadow: 0 0 10px hsla(210, 85%, 55%, 0.3);
}

.progress-bar-inner.carbs {
  background: linear-gradient(90deg, hsl(325, 80%, 55%), hsl(340, 85%, 48%));
  box-shadow: 0 0 10px hsla(325, 80%, 55%, 0.3);
}

.progress-bar-inner.fats {
  background: linear-gradient(90deg, hsl(20, 85%, 55%), hsl(10, 90%, 48%));
  box-shadow: 0 0 10px hsla(20, 85%, 55%, 0.3);
}

/* Ginesta Pink Skin Overrides */
body.pink-theme {
  --bg-app: hsl(330, 40%, 9%);
  --bg-card: hsla(330, 40%, 14%, 0.65);
  --border-card: hsla(330, 38%, 25%, 0.4);
  
  --text-secondary: hsl(330, 10%, 79%);
  --text-muted: hsl(330, 10%, 52%);
  
  --color-accent: hsl(330, 60%, 65%);
  --color-accent-light: hsla(330, 60%, 65%, 0.15);
  
  --color-peptide: hsl(300, 50%, 65%);
  --color-peptide-light: hsla(300, 50%, 65%, 0.15);
}

body.pink-theme .app-header {
  background: hsla(330, 25%, 8%, 0.85);
}

/* Inline Workout Exercise Row Inputs */
.workout-exercise-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 6px;
  background: rgba(255, 255, 255, 0.015);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}
.workout-exercise-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.workout-exercise-inputs {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-left: 28px;
  margin-top: 2px;
}
.workout-exercise-inputs.hidden {
  display: none !important;
}
.workout-exercise-inputs .input-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.workout-exercise-inputs input {
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--border-input);
  background: var(--bg-input-dark);
  color: white;
  text-align: center;
  font-size: 0.8rem;
}
.prescription-info {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-left: 6px;
}
.ex-last-log {
  display: block;
  font-size: 0.75rem;
  color: var(--color-accent);
  margin-top: 2px;
  margin-left: 28px;
}

/* Premium Macro Sliders styling */
.premium-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border-input-subtle);
  outline: none;
  margin: 10px 0;
}
.premium-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-accent);
  cursor: pointer;
  border: 2px solid var(--text-primary);
  transition: var(--transition-smooth);
}
.premium-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 8px var(--color-accent-light);
}

/* Fitness Progression Table Styling */
.progression-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}
.progression-table th, .progression-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--bg-subtle);
  font-size: 0.85rem;
}
.progression-table th {
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}
.progression-table tr:hover {
  background: var(--bg-subtle-dim);
}
.progression-positive {
  color: var(--color-success);
  font-weight: 600;
}
.progression-neutral {
  color: var(--text-muted);
}

/* Calendar Month View and Toolbar */
.calendar-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  background: var(--bg-subtle-dim);
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--bg-subtle);
}

.calendar-view-toggle {
  display: flex;
  gap: 6px;
}

.calendar-month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 10px 0;
}

.calendar-month-nav button {
  background: var(--bg-subtle);
  border: 1px solid var(--border-input-subtle);
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.calendar-month-nav button:hover {
  background: var(--color-accent);
  border-color: var(--color-accent-light);
}

.calendar-month-nav span {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-accent);
  min-width: 140px;
  text-align: center;
}

/* Event Chips in Grid cells */
.calendar-event-chips-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 4px;
  width: 100%;
}

.calendar-event-chip {
  border-radius: 3px;
  padding: 1px 3px;
  font-size: 0.6rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 1px;
  line-height: 1.5;
}

/* Overflow indicator: "+2" etc */
.calendar-chip-overflow {
  font-size: 0.58rem;
  color: var(--text-muted);
  padding: 0 2px;
  line-height: 1.4;
}

/* Color codes using theme HSL palette */
.calendar-event-chip.workout {
  background: hsla(142, 69%, 45%, 0.2);
  color: hsl(142, 69%, 60%);
}

.calendar-event-chip.travel {
  background: hsla(38, 92%, 50%, 0.2);
  color: hsl(38, 92%, 65%);
}

.calendar-event-chip.meals-shared {
  background: hsla(42, 44%, 50%, 0.18);
  color: hsl(42, 44%, 68%);
}

.calendar-event-chip.meals-separate {
  background: hsla(354, 70%, 54%, 0.18);
  color: hsl(354, 70%, 68%);
}

/* Clickable workout detail links */
.calendar-workout-link {
  color: var(--color-accent) !important;
  text-decoration: underline !important;
  cursor: pointer !important;
  transition: color 0.2s ease;
}

.calendar-workout-link:hover {
  color: var(--color-accent-light) !important;
}

/* Month view overrides: standalone header always hidden (headers are now inline grid cells) */
.calendar-weekdays-header.month-view {
  display: none !important;
}

.calendar-grid-wrapper.month-view {
  grid-template-columns: 22px repeat(7, minmax(0, 1fr)) !important;
  max-height: 55vh !important;
  overflow-y: auto !important;
  gap: 0 !important;
  min-width: unset !important;
}

/* Caffeine progress bar styling */
.progress-bar-group.caffeine {
  border: 1px dashed rgba(180, 83, 9, 0.3);
  padding: 6px;
  border-radius: 6px;
  transition: background 0.2s ease;
}

.progress-bar-group.caffeine:hover {
  background: rgba(180, 83, 9, 0.05);
}

/* ============================== */
/* Utility Classes (Phase 5 Refactor) */
/* ============================== */

/* Form Inputs */
.form-input {
  width: 100%;
  padding: 6px;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-input);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 0.85rem;
}

.form-input-sm {
  width: 100%;
  padding: 4px;
  border-radius: 4px;
  border: 1px solid var(--border-input-subtle);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 0.8rem;
}

/* Settings Inputs */
.settings-input {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border-input);
  background: var(--bg-input-settings);
  color: var(--text-primary);
}

/* Form Labels */
.form-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.form-label-sm {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.form-label-lg {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* Flex Utilities */
.flex-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

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

/* Grid Utilities */
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.grid-2col--lg {
  gap: 12px;
}

/* Progress Bar Modifiers */
.progress-bar-header--sm {
  font-size: 0.75rem;
  margin-bottom: 2px;
}

.progress-bar-outer--sm {
  height: 6px;
}

.progress-bar-fill {
  background: var(--color-accent);
  width: 0%;
}

/* Preview Image */
.preview-image {
  max-width: 100%;
  max-height: 150px;
  border-radius: 8px;
  border: 1px solid var(--border-input);
}

.preview-image--lg {
  max-height: 200px;
  margin-bottom: 8px;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

/* Upload Button Labels */
.upload-btn {
  flex: 1;
  text-align: center;
  cursor: pointer;
  padding: 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.upload-btn--dashed {
  background: var(--bg-subtle);
  border: 1px dashed rgba(255, 255, 255, 0.2);
  margin: 0;
}

/* Spacing Utilities */
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-0 { margin-bottom: 0; }
.mt-6 { margin-top: 6px; }

/* Size Utilities */
.w-full { width: 100%; }
.col-span-2 { grid-column: span 2; }
.max-w-modal { max-width: 450px; }

/* Text Utilities */
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.text-accent-bold { color: var(--color-accent); font-weight: 600; }

/* Card Subtle */
.card-subtle {
  background: rgba(255, 255, 255, 0.03);
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--bg-subtle);
}

/* Compact Button */
.btn-compact {
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 500;
}

/* Flex Input Small */
.flex-input-sm {
  flex: 1;
  padding: 4px 6px;
  font-size: 0.75rem;
}

/* Section Title */
.section-title {
  color: var(--text-primary);
  margin: 0 0 8px 0;
  font-size: 0.95rem;
}

/* Tablet Breakpoint */
@media (min-width: 768px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .card {
    padding: 24px;
  }

  .app-nav {
    max-width: 600px;
    margin: 0 auto;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 16px 16px 0 0;
    border-left: 1px solid var(--border-card);
    border-right: 1px solid var(--border-card);
  }

  .app-viewport {
    padding: 24px 32px;
  }

  .modal-dialog {
    max-width: 520px;
  }
}

/* --- Meal Planner & Shared Pantry Styles --- */

/* Recipe Card Styling */
.recipe-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--border-radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: var(--transition-smooth);
}

.recipe-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--color-accent);
}

.recipe-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
}

.recipe-card-title {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text-primary);
  font-family: var(--font-header);
}

.recipe-card-macros {
  display: flex;
  gap: 10px;
  font-size: 0.75rem;
  color: var(--color-accent);
  background: rgba(255, 198, 10, 0.08);
  padding: 4px 8px;
  border-radius: 4px;
}

.recipe-card-links {
  display: flex;
  gap: 8px;
  font-size: 0.75rem;
}

.recipe-link-tag {
  color: var(--color-accent);
  text-decoration: underline;
}

.recipe-card-substitutions {
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.04);
  padding: 8px 10px;
  border-radius: 6px;
  border-left: 2px solid var(--color-warning);
  color: var(--color-text-dim);
}

.recipe-collapsible-trigger {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  user-select: none;
}

.chat-agent-container {
  height: 350px;
}

/* Chatbot UI */
.chat-messages-box {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.chat-messages-box::-webkit-scrollbar {
  width: 4px;
}

.chat-messages-box::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.chat-msg.user {
  align-self: flex-end;
  background: var(--color-accent);
  color: var(--bg-app);
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 8px 8px 0 8px;
  max-width: 85%;
}

.chat-msg.agent.error {
  border-color: rgba(239, 68, 68, 0.3) !important;
  background: rgba(239, 68, 68, 0.08) !important;
  color: #f87171 !important;
}

/* Pantry Inventory Category Groups */
.pantry-category-group {
  margin-bottom: 16px;
}

.pantry-category-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin: 0 0 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 4px;
}

.pantry-items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}

.pantry-item-card {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.8rem;
  color: var(--color-text-dim);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.pantry-item-card:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--color-accent);
}

.pantry-item-card.out-of-stock {
  opacity: 0.5;
  text-decoration: line-through;
}

/* Shopping Item Styling */
.shopping-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 10px 14px;
}

.shopping-item-row.checked span {
  text-decoration: line-through;
  color: var(--text-muted);
  opacity: 0.6;
}

.shopping-item-row .btn-delete-item {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 4px;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.shopping-item-row .btn-delete-item:hover {
  opacity: 1;
}

.kitchen-task-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 6px;
  border-left: 3px solid var(--color-accent);
  font-size: 0.85rem;
}

.kitchen-task-item.prep {
  border-left-color: var(--color-warning);
}

/* ============================================================================
 * DESKTOP VIEWPORT TRANSFORMATION (sidebar layout on >= 1024px)
 * ============================================================================ */
@media (min-width: 1024px) {
  body {
    display: block;
    min-height: 100vh;
    padding-bottom: 0;
  }

  .app-header {
    position: sticky;
    top: 0;
    width: 100%;
    z-index: 1000;
  }

  .app-nav {
    position: fixed;
    top: 69px; /* aligns with bottom of header */
    left: 0;
    bottom: 0;
    width: 240px;
    height: calc(100vh - 69px);
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    padding: 24px 16px;
    gap: 8px;
    background: hsla(158, 25%, 8%, 0.85); /* Deep Dark Forest Green background */
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--border-card);
    border-top: none;
    border-left: none;
    border-bottom: none;
    border-radius: 0;
    z-index: 900;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.4);
    box-sizing: border-box;
    /* Reset values inherited from 768px tablet query */
    transform: none;
    max-width: none;
    margin: 0;
  }

  .nav-item {
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    border-radius: 10px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
    border-left: 3px solid transparent;
  }

  .nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    transform: translateX(4px);
    border-left: 3px solid var(--color-accent);
    border-radius: 0 10px 10px 0;
  }

  .nav-item:hover .nav-icon {
    transform: scale(1.1);
  }

  .nav-item .nav-icon {
    margin-bottom: 0;
    font-size: 1.2rem;
  }

  .nav-item .nav-label {
    font-size: 0.9rem;
    font-weight: 500;
  }

  .nav-item.active {
    background: rgba(182, 149, 72, 0.15);
    border: 1px solid rgba(182, 149, 72, 0.3);
    color: var(--color-accent);
    border-left: 3px solid var(--color-accent);
    border-radius: 10px;
  }

  .app-viewport {
    grid-area: main;
    margin-left: 240px;
    margin-bottom: 0;
    max-width: 1400px; /* Containment on ultra-wide screens */
    width: calc(100% - 240px);
    padding: 40px;
    box-sizing: border-box;
  }

  /* Grid adjustment for dashboard grid with column containers stacking elements */
  .dashboard-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    align-items: start !important;
    gap: 20px !important;
  }

  .dashboard-col {
    display: flex !important;
    flex-direction: column !important;
    gap: 20px !important;
  }

  #dashboard-col-3 {
    grid-column: span 2 !important;
    flex-direction: row !important;
  }

  #dashboard-col-3 > .glass-card {
    flex: 1 !important;
  }

  /* Habits Checklist side-by-side columns */
  #habits-list-container {
    column-count: 2;
    column-gap: 20px;
  }

  #habits-list-container .habits-section-title,
  #habits-list-container .checkbox-list {
    break-inside: avoid;
  }

  /* Shopping layout side-by-side */
  .shopping-layout {
    grid-template-columns: 1fr 1fr !important;
  }

  .card-staples {
    grid-column: span 1 !important;
  }

  /* Settings responsive grid layout */
  .settings-layout {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Chat container height expansion */
  .chat-agent-container {
    height: 500px !important;
  }
}

/* Wide viewports 3-column dashboard override */
@media (min-width: 1400px) {
  .dashboard-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }

  #dashboard-col-3 {
    grid-column: span 1 !important;
    flex-direction: column !important;
  }

  #dashboard-col-3 > .glass-card {
    flex: none !important;
  }
}

/* Chat attachments UI styles */
.btn-chat-icon {
  opacity: 0.65;
  transition: all 0.2s ease;
}
.btn-chat-icon:hover {
  opacity: 1;
  transform: scale(1.15);
}
.chat-input-bar input[type="text"] {
  margin-left: 4px;
}

/* Sleep history collapsible details styling */
.sleep-history-details summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sleep-history-details summary::-webkit-details-marker {
  display: none;
}
.sleep-history-details summary::after {
  content: '▼';
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}
.sleep-history-details[open] summary::after {
  content: '▲';
}
