/* ═══════════════════════════════════════════════════════════════
   CalTracker — Styles
   ═══════════════════════════════════════════════════════════════ */

/* ─── Variables de thème ──────────────────────────────────────── */
:root {
  --color-bg: #09090b;
  --color-surface: #18181b;
  --color-surface-2: #27272a;
  --color-border: #3f3f46;
  --color-text: #fafafa;
  --color-text-muted: #a1a1aa;
  --color-text-subtle: #71717a;
  --color-primary: #16a34a;
  --color-primary-hover: #15803d;
  --color-primary-muted: #14532d20;
  --color-accent: #22c55e;
  --color-danger: #ef4444;
  --color-warning: #f59e0b;
  --color-info: #3b82f6;
  --color-protein: #f97316;
  --color-fat: #eab308;
  --color-carbs: #3b82f6;
  --color-fiber: #22c55e;
  --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.4), 0 4px 6px rgba(0,0,0,0.3);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --nav-height: 64px;
  --safe-bottom: max(8px, env(safe-area-inset-bottom));
}

[data-theme="light"] {
  --color-bg: #f4f4f5;
  --color-surface: #ffffff;
  --color-surface-2: #f4f4f5;
  --color-border: #e4e4e7;
  --color-text: #09090b;
  --color-text-muted: #52525b;
  --color-text-subtle: #71717a;
  --color-primary-muted: #16a34a15;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

/* ─── Reset & Base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  overflow-y: auto;
  overscroll-behavior: none;
}

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

button { cursor: pointer; }

img { max-width: 100%; }

/* ─── Layout ──────────────────────────────────────────────────── */
#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.page {
  flex: 1;
  padding: 16px 16px calc(var(--nav-height) + var(--safe-bottom) + 16px);
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-top: 8px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

/* ─── Bottom Nav ──────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-height) + var(--safe-bottom));
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: flex-start;
  padding-top: 8px;
  padding-bottom: var(--safe-bottom);
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 4px;
  background: none;
  border: none;
  color: var(--color-text-subtle);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.2px;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.nav-item.active { color: var(--color-primary); }
.nav-item svg { width: 22px; height: 22px; flex-shrink: 0; }

.nav-item.nav-log {
  flex: 1.2;
  position: relative;
  top: -16px;
}

.nav-log-btn {
  width: 52px;
  height: 52px;
  background: var(--color-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(22,163,74,0.4);
  color: white;
}

.nav-log-btn svg { width: 26px; height: 26px; }

/* ─── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 15px;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; pointer-events: none; }

.btn-primary {
  background: var(--color-primary);
  color: white;
}
.btn-primary:hover { background: var(--color-primary-hover); }

.btn-secondary {
  background: var(--color-surface-2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover { background: var(--color-border); }

.btn-danger {
  background: var(--color-danger);
  color: white;
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}
.btn-ghost:hover { background: var(--color-surface-2); }

.btn-icon {
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { background: var(--color-border); color: var(--color-text); }
.btn-icon svg { width: 18px; height: 18px; }

.btn-full { width: 100%; }

/* ─── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}

/* ─── Form Elements ───────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

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

.form-input, .form-select, .form-textarea {
  padding: 11px 14px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: 16px;
  transition: border-color 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

/* ─── Auth Screen ─────────────────────────────────────────────── */
.auth-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  gap: 24px;
}

.auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.auth-logo-icon {
  width: 64px;
  height: 64px;
  background: var(--color-primary);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}

.auth-logo h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.auth-logo p {
  font-size: 14px;
  color: var(--color-text-muted);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.auth-tabs {
  display: flex;
  background: var(--color-surface-2);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 20px;
}

.auth-tab {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 14px;
  transition: all 0.15s;
}

.auth-tab.active {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow);
}

.auth-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: #fca5a5;
  margin-bottom: 16px;
}

/* ─── Onboarding ──────────────────────────────────────────────── */
.onboarding-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 24px 20px calc(var(--safe-bottom) + 24px);
  max-width: 500px;
  margin: 0 auto;
}

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

.onboarding-step {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.step-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-border);
  transition: background 0.2s;
}
.step-dot.active { background: var(--color-primary); width: 20px; border-radius: 3px; }

.onboarding-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.onboarding-subtitle {
  font-size: 15px;
  color: var(--color-text-muted);
}

.pal-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pal-option {
  padding: 12px 14px;
  background: var(--color-surface-2);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--color-text);
  width: 100%;
}

.pal-option.selected {
  border-color: var(--color-primary);
  background: var(--color-primary-muted);
}

.pal-option-title {
  font-weight: 600;
  font-size: 14px;
  display: block;
}

.pal-option-desc {
  font-size: 12px;
  color: var(--color-text-muted);
  display: block;
}

.goal-options {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.goal-option {
  padding: 20px 14px;
  background: var(--color-surface-2);
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--color-text);
}

.goal-option.selected {
  border-color: var(--color-primary);
  background: var(--color-primary-muted);
}

.goal-option-icon { font-size: 32px; display: block; margin-bottom: 8px; }
.goal-option-title { font-weight: 700; font-size: 14px; display: block; }
.goal-option-desc { font-size: 11px; color: var(--color-text-muted); display: block; margin-top: 4px; }

/* TDEE Preview */
.tdee-preview {
  background: var(--color-primary-muted);
  border: 1px solid var(--color-primary);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
}

.tdee-preview-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-primary);
  margin-bottom: 12px;
}

.tdee-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.tdee-stat { text-align: center; }
.tdee-stat-value { font-size: 20px; font-weight: 800; color: var(--color-text); display: block; }
.tdee-stat-label { font-size: 11px; color: var(--color-text-muted); }

/* ─── Dashboard ───────────────────────────────────────────────── */
.dashboard-greeting {
  margin-bottom: 0;
}

.dashboard-greeting h2 {
  font-size: 20px;
  font-weight: 700;
}

.dashboard-greeting p {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* Calorie Ring */
.calorie-ring-container {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.calorie-ring-svg {
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.calorie-ring-info { flex: 1; }

.calorie-ring-consumed {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
}

.calorie-ring-label {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.calorie-ring-remaining {
  font-size: 14px;
  font-weight: 600;
  margin-top: 12px;
}

/* Macro Bars */
.macro-bars {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.macro-bar-item {
  display: grid;
  grid-template-columns: 70px 1fr 60px;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.macro-bar-item:last-child { margin-bottom: 0; }

.macro-bar-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
}

.macro-bar-track {
  height: 7px;
  background: var(--color-surface-2);
  border-radius: 4px;
  overflow: hidden;
}

.macro-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.macro-bar-fill.protein { background: var(--color-protein); }
.macro-bar-fill.fat { background: var(--color-fat); }
.macro-bar-fill.carbs { background: var(--color-carbs); }
.macro-bar-fill.fiber { background: var(--color-fiber); }

.macro-bar-value {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-align: right;
}

/* Coach Banner */
.coach-banner {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.coach-banner-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.coach-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-surface-2);
}

.coach-item:last-child { border-bottom: none; }

.coach-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  flex-shrink: 0;
  margin-top: 1px;
}

.coach-icon.success { background: rgba(34,197,94,0.2); }
.coach-icon.warning { background: rgba(245,158,11,0.2); }
.coach-icon.tip { background: rgba(59,130,246,0.2); }

.coach-text { font-size: 13px; line-height: 1.4; }

/* Coach Modal */
.coach-modal-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
}
.coach-modal-item.coach-modal-success { border-left: 3px solid var(--color-accent); }
.coach-modal-item.coach-modal-warning { border-left: 3px solid var(--color-warning); }
.coach-modal-item.coach-modal-tip { border-left: 3px solid #3b82f6; }
.coach-modal-icon { font-size: 18px; flex-shrink: 0; }
.coach-modal-text { font-size: 14px; line-height: 1.4; }

/* Meals Section */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

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

/* Meal Card */
.meal-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}

.meal-time-badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  border-radius: 6px;
  padding: 4px 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

.meal-info { flex: 1; min-width: 0; }

.meal-description {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meal-macros {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.meal-macro-tag {
  font-size: 11px;
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  border-radius: 4px;
  padding: 2px 6px;
}

.meal-calories {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text);
  flex-shrink: 0;
}

.meal-confidence-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 5px;
}

.meal-confidence-dot.high { background: var(--color-accent); }
.meal-confidence-dot.medium { background: var(--color-warning); }
.meal-confidence-dot.low { background: var(--color-danger); }

/* ─── Log Screen ──────────────────────────────────────────────── */
.log-tabs {
  display: flex;
  background: var(--color-surface-2);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 20px;
}

.log-tab {
  flex: 1;
  padding: 8px 4px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 13px;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.log-tab.active {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow);
}

/* ─── Advanced details ────────────────────────────────────────── */
.advanced-details {
  margin-top: 4px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.advanced-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-muted);
  list-style: none;
  user-select: none;
}
.advanced-summary::-webkit-details-marker { display: none; }
.advanced-summary::before {
  content: '▶';
  font-size: 10px;
  transition: transform 0.2s;
  color: var(--color-text-subtle);
}
.advanced-details[open] .advanced-summary::before { transform: rotate(90deg); }

.advanced-badge {
  font-size: 11px;
  font-weight: 600;
  background: var(--color-surface-2);
  color: var(--color-text-subtle);
  padding: 2px 7px;
  border-radius: 99px;
  margin-left: auto;
}

.advanced-content {
  padding: 14px 14px 14px;
  border-top: 1px solid var(--color-border);
}

.log-tab svg { width: 16px; height: 16px; }

/* AI Result Preview */
.ai-result {
  background: var(--color-surface);
  border: 1px solid var(--color-primary);
  border-radius: var(--radius);
  padding: 16px;
  margin: 16px 0;
  animation: slideIn 0.2s ease;
}

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

.ai-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.ai-result-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-result-calories {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
}

.ai-result-macros {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.ai-macro-item {
  text-align: center;
  padding: 8px 4px;
  background: var(--color-surface-2);
  border-radius: var(--radius-sm);
}

.ai-macro-value { font-size: 16px; font-weight: 700; display: block; }
.ai-macro-label { font-size: 10px; color: var(--color-text-muted); margin-top: 2px; display: block; }

/* Photo Input */
.photo-drop-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--color-surface-2);
}

.photo-drop-zone:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-muted);
}

.photo-drop-zone svg { width: 40px; height: 40px; color: var(--color-text-muted); margin-bottom: 12px; }
.photo-drop-text { font-size: 15px; font-weight: 500; color: var(--color-text-muted); }
.photo-drop-hint { font-size: 12px; color: var(--color-text-subtle); margin-top: 6px; }

.photo-preview {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}

.photo-preview img {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  display: block;
}

.photo-preview-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0,0,0,0.7);
  color: white;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Favorite Picker */
.fav-info-btn {
  font-size: 15px;
  color: var(--color-text-muted);
  cursor: pointer;
  line-height: 1;
  user-select: none;
}
.fav-info-btn:hover { color: var(--color-primary); }
.fav-info-tip {
  font-size: 12px;
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 8px;
}

.favorite-picker-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 4px;
}

.favorite-picker-item {
  padding: 10px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
}

.favorite-picker-item:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-muted);
}

.fav-name { font-size: 13px; font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fav-detail { font-size: 11px; color: var(--color-text-muted); display: block; margin-top: 2px; }

/* ─── History Screen ──────────────────────────────────────────── */
.history-day {
  margin-bottom: 16px;
}

.history-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--color-surface-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: 6px;
  border: 1px solid var(--color-border);
}

.history-day-date {
  font-size: 14px;
  font-weight: 600;
}

.history-day-calories {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-primary);
}

.history-day-chevron {
  color: var(--color-text-muted);
  transition: transform 0.2s;
}

.history-day.open .history-day-chevron { transform: rotate(180deg); }

.history-day-meals {
  display: none;
  padding-left: 4px;
}

.history-day.open .history-day-meals { display: block; }

/* ─── Weight Screen ───────────────────────────────────────────── */
.weight-chart-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.weight-chart-canvas {
  width: 100%;
  height: 160px;
  display: block;
}

.weight-log-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.weight-log-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.weight-log-date { font-size: 14px; color: var(--color-text-muted); }
.weight-log-value { font-size: 18px; font-weight: 700; }

/* ─── Favorites Screen ────────────────────────────────────────── */
.favorites-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.favorite-item {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}

.favorite-item-info { flex: 1; min-width: 0; }
.favorite-item-name { font-size: 15px; font-weight: 600; }
.favorite-item-serving { font-size: 12px; color: var(--color-text-muted); }
.favorite-item-macros { font-size: 12px; color: var(--color-text-subtle); margin-top: 4px; }
.favorite-item-kcal { font-size: 16px; font-weight: 700; flex-shrink: 0; }
.favorite-item-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ─── Shopping Screen ─────────────────────────────────────────── */
.shopping-category {
  margin-bottom: 20px;
}

.shopping-category-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.shopping-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.shopping-item.checked {
  opacity: 0.5;
  text-decoration: line-through;
}

.shopping-checkbox {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.shopping-item.checked .shopping-checkbox {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.shopping-item-name { font-size: 14px; font-weight: 500; }
.shopping-item-reason { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }

/* ─── Settings Screen ─────────────────────────────────────────── */
.settings-divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 0 0 24px;
}

.settings-section {
  margin-bottom: 24px;
}

.settings-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  margin-bottom: 10px;
  padding-left: 4px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}

.settings-row-label { font-size: 15px; font-weight: 500; }
.settings-row-value { font-size: 14px; color: var(--color-text-muted); display: flex; align-items: center; gap: 8px; }

.settings-row-tappable { cursor: pointer; transition: background 0.15s; }
.settings-row-tappable:active { background: var(--color-surface-2); }

.profile-identity-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.profile-identity-card:active { background: var(--color-surface-2); border-color: var(--color-primary); }
.profile-identity-name {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}
.profile-identity-email {
  font-size: 13px;
  color: var(--color-text-muted);
}

.form-input-static {
  padding: 12px 16px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--color-text-muted);
}

.profile-data-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.profile-data-card:active { background: var(--color-surface-2); border-color: var(--color-primary); }

.profile-data-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}
.profile-data-weight {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.profile-data-goal {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-muted);
}
.profile-data-targets {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}
.profile-data-hint {
  font-size: 12px;
  color: var(--color-text-subtle);
}

.settings-edit-icon { display: flex; align-items: center; opacity: 0.4; }
.settings-edit-icon svg { width: 13px; height: 13px; }

.settings-row-editing {
  align-items: flex-start;
  background: var(--color-surface-2);
  border-color: var(--color-primary);
}

/* Toggle Switch */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--color-border);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-slider:before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle input:checked + .toggle-slider { background: var(--color-primary); }
.toggle input:checked + .toggle-slider:before { transform: translateX(20px); }

/* ─── Modal / Dialog ──────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.15s ease;
}

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

.modal-sheet {
  width: 100%;
  max-width: 600px;
  background: var(--color-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 20px 20px calc(20px + var(--safe-bottom));
  max-height: 90dvh;
  overflow-y: auto;
  animation: slideUp 0.25s ease;
}

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

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  margin: 0 auto 16px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

/* ─── Loading ─────────────────────────────────────────────────── */
.loading-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}

.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text { font-size: 14px; color: var(--color-text-muted); }

/* ─── Empty State ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-text-muted);
}

.empty-state-icon { font-size: 48px; display: block; margin-bottom: 12px; }
.empty-state-title { font-size: 17px; font-weight: 600; color: var(--color-text); margin-bottom: 6px; }
.empty-state-text { font-size: 14px; line-height: 1.5; }

/* ─── Toast ───────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 400px;
}

.toast {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  animation: toastIn 0.2s ease;
  width: 100%;
  text-align: center;
}

.toast.success { background: var(--color-primary); color: white; }
.toast.error { background: var(--color-danger); color: white; }
.toast.info { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); }

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

/* ─── Date Nav ────────────────────────────────────────────────── */
.date-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.date-nav-label {
  flex: 1;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
}

.date-nav-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  padding: 4px;
  display: flex;
  align-items: center;
  border-radius: 6px;
  transition: all 0.15s;
}

.date-nav-btn:hover {
  color: var(--color-text);
  background: var(--color-surface-2);
}

.date-nav-btn svg { width: 20px; height: 20px; }
.date-nav-btn:disabled { opacity: 0.3; pointer-events: none; }

/* ─── Utils ───────────────────────────────────────────────────── */
.text-muted { color: var(--color-text-muted); }
.text-sm { font-size: 13px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-green { background: rgba(34,197,94,0.15); color: var(--color-accent); }
.badge-orange { background: rgba(249,115,22,0.15); color: var(--color-protein); }
.badge-red { background: rgba(239,68,68,0.15); color: var(--color-danger); }

/* ─── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 2px; }

/* ─── Responsive ──────────────────────────────────────────────── */
@media (min-width: 500px) {
  .form-row { grid-template-columns: 1fr 1fr; }
  .ai-result-macros { grid-template-columns: repeat(4, 1fr); }
}
