:root {
  /* Fluid typography */
  --font-size-base: clamp(14px, 2vw, 16px);
  --font-size-small: clamp(12px, 1.8vw, 13px);
  --font-size-h1: clamp(20px, 4vw, 28px);
  --font-size-h3: clamp(16px, 2.5vw, 18px);
  --font-size-stat: clamp(18px, 3vw, 22px);

  /* Colors */
  --bg: #0b0d12;
  --panel: #0f1623;
  --card: #111827;
  --card-muted: #0f141d;
  --border: rgba(255, 255, 255, 0.06);
  --text: #e5e7eb;
  --muted: #9ca3af;
  --primary: #16a34a;
  --primary-strong: #15803d;
  --accent: #f97316;
  --info: #3b82f6;
  --success: #22c55e;
  --danger: #ef4444;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);

  /* Spacing */
  --card-pad: 16px;
  --card-inner-pad: 18px;
  --section-gap: 14px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: var(--font-size-base);
  line-height: 1.6;
}

/* === MOBILE NAVIGATION SYSTEM === */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 1001;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
}

.mobile-menu-toggle:hover {
  background: var(--primary);
  transform: scale(1.05);
}

.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.mobile-overlay.active {
  display: block;
  opacity: 1;
}

.layout {
  display: flex;
  min-height: 100vh;
}

.tabs.sidebar {
  width: 240px;
  background: #0d121c;
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: transform 0.3s ease;
}

.tabs.sidebar .brand {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}
.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--primary);
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
}
.brand-title { font-weight: 700; }
.brand-sub { color: var(--muted); font-size: 12px; }

.tabs.sidebar button {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}
.tabs.sidebar button:hover {
  border-color: rgba(255,255,255,0.2);
}
.tabs.sidebar button.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  box-shadow: 0 12px 28px rgba(22, 163, 74, 0.35);
}
.sidebar-footer {
  margin-top: auto;
  color: var(--muted);
  font-size: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-muted);
}

.content { flex: 1; padding: 18px 22px 32px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.topbar h1 { margin: 0; font-size: var(--font-size-h1); }
.tagline { color: var(--muted); }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: var(--card-pad);
  box-shadow: var(--shadow);
}
.card.inner {
  background: var(--card-muted);
  box-shadow: none;
  padding: var(--card-inner-pad);
}
.card h3 { margin: 0 0 12px; letter-spacing: 0.01em; font-size: var(--font-size-h3); }
.card h4 { margin: 0 0 10px; letter-spacing: 0.01em; }
.card > .stat,
.card > .grid,
.card > form,
.card > .history,
.card > .list,
.card > .quick-add,
.card > .pill-row,
.card > .water-actions,
.card > .muted,
.card > .timer { margin-top: 10px; }
.alert {
  background: #1f2937;
  border-color: rgba(255, 255, 255, 0.12);
}
.alert-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.alert-actions { display: flex; gap: 8px; }

.grid {
  display: grid;
  gap: var(--section-gap);
}

/* Mobile-first: Single column by default */
.cards-4,
.cards-2,
.auto-fit,
.balance-grid {
  grid-template-columns: 1fr;
}

.cards-4 > .card.inner,
.cards-2 > .card.inner { grid-column: span 1; }

/* 480px: Large phones (landscape) */
@media (min-width: 480px) {
  .cards-2 {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  }
  .auto-fit {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
}

/* 600px: Small tablets / Large phones */
@media (min-width: 600px) {
  .cards-4 {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }
  .balance-grid {
    grid-template-columns: minmax(200px, 280px) 1fr;
  }
}

/* 768px: Tablets */
@media (min-width: 768px) {
  .cards-4 {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  }
  .cards-2 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  }
  .balance-grid {
    grid-template-columns: minmax(220px, 300px) 1fr;
  }
}

/* 961px: Desktop (sidebar visible) */
@media (min-width: 961px) {
  .cards-4 {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  }
  .cards-2 {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  }
}

/* 1200px: Large desktop */
@media (min-width: 1200px) {
  .cards-4 {
    grid-template-columns: repeat(4, 1fr);
  }
  .content {
    max-width: 1400px;
    margin: 0 auto;
  }
}
.form-grid { display: grid; gap: 10px; }

.panel > .card,
.panel > .grid { margin-bottom: var(--section-gap); }
.panel > .card:last-child,
.panel > .grid:last-child { margin-bottom: 0; }

.panel { display: none; }
.panel.active { display: block; }

.stat { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.stat-label { color: var(--muted); font-size: var(--font-size-small); }
.stat-value { font-size: var(--font-size-stat); font-weight: 700; line-height: 1.2; }

.muted { color: var(--muted); font-size: var(--font-size-small); }

.progress {
  position: relative;
  height: 10px;
  background: #1f2937;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.progress.slim { height: 8px; }
.progress .fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--primary), #22c55e);
  border-radius: inherit;
  transition: width 0.3s ease;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}
.pill.small { padding: 4px 8px; font-size: 11px; }
.pill.success { background: rgba(34, 197, 94, 0.12); color: #8ef5b6; }
.pill.warn { background: rgba(251, 191, 36, 0.12); color: #ffd87a; }
.pill.danger { background: rgba(239, 68, 68, 0.12); color: #ff9b9b; }
.pill.info { background: rgba(59, 130, 246, 0.14); color: #c7ddff; }

.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #fff;
  border: none;
  padding: 14px 18px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.1s ease, box-shadow 0.2s ease;
  box-shadow: 0 14px 35px rgba(22, 163, 74, 0.35);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.primary:active { transform: translateY(1px); }
.primary.warm { background: linear-gradient(135deg, var(--accent), #c2410c); box-shadow: 0 14px 35px rgba(249, 115, 22, 0.25); }
.primary.success { background: linear-gradient(135deg, var(--success), #16a34a); box-shadow: 0 14px 35px rgba(34, 197, 94, 0.25); }
.primary.info { background: linear-gradient(135deg, var(--info), #2563eb); box-shadow: 0 14px 35px rgba(59, 130, 246, 0.25); }
.primary.danger { background: linear-gradient(135deg, var(--danger), #b91c1c); box-shadow: 0 14px 35px rgba(239, 68, 68, 0.25); }

.mini-btn {
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.mini-btn.danger { background: rgba(239, 68, 68, 0.12); color: #ff9b9b; }

.input, input[type="time"], input[type="date"], input[type="number"], select, textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
  outline: none;
  font-size: 16px;
  min-height: 44px;
  -webkit-appearance: none;
}
.input:focus, select:focus { border-color: rgba(255, 255, 255, 0.2); }
.input.short { max-width: 140px; }

.flex { display: flex; }
.gap { gap: 10px; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.align-center { align-items: center; }
.flex-1 { flex: 1; }

.list { display: grid; gap: 10px; margin-top: 8px; }
.list .row, .list .item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--card-muted);
  border: 1px solid var(--border);
}

.history { display: grid; gap: 10px; }
.history .item { padding: 12px; }
.history.empty { padding: 6px 0; }

/* Meal item with delete button */
.meal-item {
  display: flex !important;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.meal-content {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.meal-content:hover {
  opacity: 0.8;
}

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

.meal-actions .calories {
  font-weight: 500;
  white-space: nowrap;
}

.icon-btn {
  background: none;
  border: none;
  padding: 12px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s ease;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  min-width: 44px;
  min-height: 44px;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.icon-btn.delete-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

/* Edit mode banner */
.edit-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  margin: 12px 0;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 12px;
  color: #c7ddff;
}

.edit-banner.hidden {
  display: none;
}

/* Favorites list */
.favorites-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.favorite-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(14, 163, 93, 0.08);
  border: 1px solid rgba(14, 163, 93, 0.3);
  cursor: pointer;
  transition: all 0.2s ease;
}

.favorite-card:hover {
  background: rgba(14, 163, 93, 0.12);
  border-color: rgba(14, 163, 93, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.favorite-card-content {
  flex: 1;
  min-width: 0;
}

.favorite-card-name {
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

.favorite-card-macros {
  font-size: 12px;
  margin-bottom: 2px;
}

.favorite-card-stats {
  font-size: 10px;
  font-style: italic;
}

.favorite-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.favorite-card-calories {
  font-weight: 600;
  color: var(--primary);
  font-size: 14px;
}

.favorite-empty {
  padding: 20px;
  text-align: center;
  font-style: italic;
}

/* Star button */
.icon-btn.star-btn {
  opacity: 0.4;
  transition: all 0.2s ease;
}

.icon-btn.star-btn:hover {
  opacity: 1;
  transform: scale(1.2);
}

.icon-btn.star-btn.favorited {
  opacity: 1;
  background: rgba(251, 191, 36, 0.2);
  color: #fbbf24;
}

/* Remove favorite button */
.icon-btn.remove-fav-btn {
  font-size: 16px;
  opacity: 0.5;
}

.icon-btn.remove-fav-btn:hover {
  opacity: 1;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.macro-progress .row {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  align-items: center;
  gap: 8px;
}
.macro-chip {
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.05);
  margin-bottom: 6px;
}

.heatmap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 6px;
}
.heat-cell {
  padding: 8px 6px;
  border-radius: 8px;
  text-align: center;
  font-size: 11px;
  border: 1px solid var(--border);
}
.heat-green { background: rgba(34, 197, 94, 0.14); color: #9af5b9; }
.heat-yellow { background: rgba(251, 191, 36, 0.12); color: #ffd87a; }
.heat-red { background: rgba(239, 68, 68, 0.12); color: #ff9b9b; }
.prayer-list .row.highlight {
  border-color: rgba(14, 163, 93, 0.45);
  background: rgba(14, 163, 93, 0.08);
}

/* Food search results */
#search-results {
  max-height: 400px;
  overflow-y: auto;
  transition: all 0.3s ease;
}

#search-results.collapsed {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  margin: 0;
  padding: 0;
}

#search-results .row {
  cursor: pointer;
  transition: all 0.2s ease;
}

#search-results .row:hover {
  border-color: rgba(14, 163, 93, 0.3);
  background: rgba(14, 163, 93, 0.05);
  transform: translateX(2px);
}

#search-results .row.selected {
  border-color: rgba(14, 163, 93, 0.6);
  background: rgba(14, 163, 93, 0.12);
  box-shadow: 0 0 0 2px rgba(14, 163, 93, 0.2);
}

.timer { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.timer-ring {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: conic-gradient(var(--primary) 0%, rgba(255, 255, 255, 0.07) 0%);
  display: grid;
  place-items: center;
  position: relative;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
}
.timer-ring::after {
  content: '';
  position: absolute;
  width: 78px;
  height: 78px;
  background: var(--card);
  border-radius: 50%;
  border: 1px solid var(--border);
  box-shadow: inset 0 8px 18px rgba(0, 0, 0, 0.25);
}
.timer-value { position: relative; font-size: 18px; font-weight: 600; z-index: 1; }

.quick-add { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.quick-add button {
  padding: 8px 10px;
  background: rgba(22, 163, 74, 0.15);
  color: var(--text);
  border-radius: 10px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s ease;
}
.quick-add button:hover { background: rgba(22, 163, 74, 0.25); }

.dropzone {
  margin-top: 10px;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  text-align: center;
  background: var(--card-muted);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 40;
  overflow-y: auto;
}
.modal.active { display: flex; }
.modal-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  margin: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.modal-close {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 6px 10px;
  cursor: pointer;
}

.chart-holder { position: relative; }
.chart-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  padding: 8px;
  pointer-events: none;
}
.score-label { font-size: 28px; font-weight: 700; }
.balance-grid { grid-template-columns: minmax(220px, 300px) 1fr; align-items: center; }
.chart-overlay .pill { pointer-events: none; }
.chart-overlay .pill.small { margin-top: 2px; }

/* === RESPONSIVE CHARTS === */
canvas {
  background: #0b1220;
  border-radius: 12px;
  display: block;
  width: 100% !important;
  height: auto !important;
  max-height: 400px;
}

.chart-holder {
  position: relative;
  width: 100%;
  min-height: 250px;
}

#macro-balance-chart {
  max-width: 350px;
  margin: 0 auto;
}

@media (max-width: 768px) {
  canvas { max-height: 300px; }
  .chart-holder { min-height: 200px; }
  #macro-balance-chart { max-width: 280px; }
  .score-label { font-size: 24px; }
}

@media (max-width: 480px) {
  canvas { max-height: 250px; }
  #macro-balance-chart { max-width: 240px; }
  .score-label { font-size: 20px; }
  .chart-overlay .pill.small {
    font-size: 9px;
    padding: 2px 6px;
  }
}

.pill-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pill.ghost { background: rgba(255, 255, 255, 0.03); box-shadow: none; }

.water-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  min-width: 280px;
  max-width: 400px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  border-left: 4px solid var(--success);
  background: linear-gradient(to right, rgba(34, 197, 94, 0.1), var(--card));
}

.toast-error {
  border-left: 4px solid var(--danger);
  background: linear-gradient(to right, rgba(239, 68, 68, 0.1), var(--card));
}

.toast-warning {
  border-left: 4px solid var(--accent);
  background: linear-gradient(to right, rgba(249, 115, 22, 0.1), var(--card));
}

.toast-info {
  border-left: 4px solid var(--info);
  background: linear-gradient(to right, rgba(59, 130, 246, 0.1), var(--card));
}

/* Tooltips */
[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 100;
  margin-bottom: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

[data-tooltip]:hover::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--border);
  z-index: 100;
  margin-bottom: 2px;
}

.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  font-size: 13px;
  cursor: help;
  margin-left: 6px;
  transition: background 0.2s ease;
}

.help-icon:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Empty States */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state h4 {
  margin: 8px 0;
  color: var(--text);
}

.empty-state p {
  margin: 8px 0 16px;
}

.empty-state button {
  margin-top: 12px;
}

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

.fade-in {
  animation: fadeIn 0.3s ease;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.pulse {
  animation: pulse 0.5s ease;
}

/* Button hover effects */
.primary:hover, .mini-btn:hover {
  transform: translateY(-1px);
}

.primary:hover {
  box-shadow: 0 18px 40px rgba(22, 163, 74, 0.45);
}

/* Mobile: transform sidebar into slide-out drawer */
@media (max-width: 960px) {
  .tabs.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    transform: translateX(-100%);
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.4);
  }

  .tabs.sidebar.mobile-open {
    transform: translateX(0);
  }

  .mobile-menu-toggle {
    display: flex;
  }

  .content {
    padding: 16px;
    padding-top: 72px;
  }

  .toast {
    bottom: 16px;
    right: 16px;
    left: 16px;
    min-width: auto;
  }
}

/* Mobile touch target size boost */
@media (max-width: 768px) {
  .icon-btn {
    padding: 14px;
    min-width: 48px;
    min-height: 48px;
  }

  .mini-btn {
    padding: 14px 18px;
    min-height: 48px;
  }

  .primary {
    padding: 16px 20px;
    min-height: 48px;
  }

  .flex.gap { gap: 12px; }
}

/* Small screen optimizations */
@media (max-width: 480px) {
  :root {
    --card-pad: 14px;
    --section-gap: 12px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

@media (max-width: 375px) {
  :root {
    --card-pad: 12px;
    --section-gap: 10px;
  }

  .content {
    padding: 12px;
    padding-top: 64px;
  }

  .topbar h1 {
    font-size: 20px;
  }
}

/* Mobile modals - bottom sheet style */
@media (max-width: 768px) {
  .modal {
    padding: 12px;
    align-items: flex-end;
  }

  .modal-content {
    max-height: 85vh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }

  .input,
  input[type="time"],
  input[type="date"],
  input[type="number"],
  select {
    padding: 14px 16px;
    min-height: 48px;
    font-size: 16px;
  }

  .input.short {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .modal {
    padding: 0;
  }

  .modal-content {
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
    padding: 14px;
  }

  /* Meal cards */
  .meal-item {
    gap: 8px;
  }

  .meal-actions {
    gap: 6px;
  }

  /* Fasting timer */
  .timer {
    flex-direction: column;
    gap: 12px;
  }

  .timer-ring {
    width: 90px;
    height: 90px;
  }

  .timer-ring::after {
    width: 64px;
    height: 64px;
  }
}

/* Component-specific responsive fixes */
.meal-item {
  display: flex !important;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.meal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.timer {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

/* Heatmap responsive */
.heatmap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 6px;
}

.heat-cell {
  aspect-ratio: 1;
}

@media (max-width: 600px) {
  .heatmap {
    grid-template-columns: repeat(auto-fill, minmax(32px, 1fr));
    gap: 4px;
  }
  .heat-cell { font-size: 10px; }
}

@media (max-width: 375px) {
  .heatmap {
    grid-template-columns: repeat(auto-fill, minmax(28px, 1fr));
    gap: 3px;
  }
  .heat-cell { font-size: 9px; }
}
