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

:root {
  --bg: #0f1117;
  --bg2: #1a1d27;
  --bg3: #22263a;
  --border: #2e3350;
  --text: #e8eaf0;
  --text2: #8b90a8;
  --text3: #555c7a;
  --accent: #6c63ff;
  --accent2: #4ecdc4;
  --protein: #ff6b6b;
  --carbs: #ffd93d;
  --fat: #6bcb77;
  --danger: #ff4757;
  --radius: 14px;
  --radius-sm: 8px;
  --nav-h: 72px;
  --header-h: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

html { height: 100%; background: var(--bg); }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
}

/* ── Header ── */
#app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 10px) 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: calc(var(--header-h) + var(--safe-top));
}

#header-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.user-badge {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-badge.alt { background: var(--accent2); color: #111; }

/* ── Main content ── */
#main-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.view {
  display: none;
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 16px 0;
  -webkit-overflow-scrolling: touch;
}

.view.active { display: block; }

.spacer-nav { height: calc(var(--nav-h) + var(--safe-bot) + 16px); }

/* ── Bottom Nav ── */
#bottom-nav {
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  padding: 8px 0 calc(var(--safe-bot) + 4px);
  background: var(--bg2);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
  min-width: 52px;
}

.nav-btn svg { width: 22px; height: 22px; }
.nav-btn span { font-size: 10px; font-weight: 500; }
.nav-btn.active { color: var(--accent); }

.add-btn { position: relative; margin-top: -20px; }
.add-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(108, 99, 255, 0.5);
}
.add-circle svg { width: 26px; height: 26px; color: #fff; }

/* ── Cards ── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Date nav ── */
.date-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 14px;
}

.date-nav span {
  font-size: 16px;
  font-weight: 600;
  min-width: 140px;
  text-align: center;
}

.icon-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ── Macro summary card ── */
.macro-summary-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  gap: 16px;
  align-items: center;
}

.calorie-ring-wrapper {
  position: relative;
  width: 100px;
  height: 100px;
  flex-shrink: 0;
}

.calorie-ring {
  width: 100px;
  height: 100px;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: var(--bg3);
  stroke-width: 10;
}

.ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.4s ease;
}

.ring-fill.over-goal { stroke: var(--danger); }

.ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
}

.ring-label span {
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}

.ring-label small {
  font-size: 11px;
  color: var(--text2);
}

.ring-label em {
  font-size: 10px;
  font-style: normal;
  color: var(--text3);
}

.macro-bars {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.macro-bar-item {}

.macro-bar-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 4px;
}

.macro-name {
  font-weight: 600;
}

.macro-name.protein { color: var(--protein); }
.macro-name.carbs   { color: var(--carbs);   }
.macro-name.fat     { color: var(--fat);     }

.macro-nums { color: var(--text2); }

.bar-track {
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.35s ease;
  max-width: 100%;
}

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

/* ── Food log container ── */
.meal-section {
  margin-bottom: 12px;
}

.meal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.meal-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.meal-name {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text2);
}

.meal-calories {
  font-size: 12px;
  color: var(--text3);
}

.meal-add-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}

.food-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.food-entry:last-child { border-bottom: none; }

.food-entry-left { flex: 1; }

.food-entry-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.food-entry-macros {
  font-size: 11px;
  color: var(--text2);
  margin-top: 2px;
}

.food-entry-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.food-entry-cals {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.delete-btn {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.15s;
}

.delete-btn:hover { color: var(--danger); }

.empty-meal {
  font-size: 13px;
  color: var(--text3);
  padding: 6px 0 4px;
}

/* ── Weight view ── */
.weight-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.input-row {
  display: flex;
  gap: 8px;
}

.big-input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 28px;
  font-weight: 700;
  text-align: center;
}

.big-input:focus { outline: none; border-color: var(--accent); }

.unit-select {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  font-size: 16px;
  font-weight: 600;
}

.date-input {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  width: 100%;
}

.date-input:focus { outline: none; border-color: var(--accent); }

.weight-stats {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.stat-box {
  flex: 1;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.stat-value.positive { color: var(--fat); }
.stat-value.negative { color: var(--danger); }

.stat-label {
  font-size: 11px;
  color: var(--text3);
  text-align: center;
}

.entry-list { display: flex; flex-direction: column; gap: 0; }

.weight-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.weight-entry:last-child { border-bottom: none; }

.weight-entry-date { font-size: 13px; color: var(--text2); }

.weight-entry-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.weight-entry-value {
  font-size: 16px;
  font-weight: 700;
}

/* ── Summary view ── */
.period-toggle {
  display: flex;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 12px;
}

.period-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text2);
  padding: 7px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.period-btn.active {
  background: var(--accent);
  color: #fff;
}

.summary-stats {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.macro-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.macro-summary-item {
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  text-align: center;
}

.macro-summary-item .macro-val {
  font-size: 18px;
  font-weight: 700;
}

.macro-summary-item .macro-lbl {
  font-size: 11px;
  color: var(--text2);
  margin-top: 2px;
}

.day-summary-row {
  display: flex;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.day-summary-row:last-child { border-bottom: none; }

.day-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.day-dot.empty { background: var(--bg3); }

.day-summary-date { font-size: 13px; color: var(--text2); width: 70px; flex-shrink: 0; }
.day-summary-cals { font-size: 14px; font-weight: 600; }
.day-summary-macros { font-size: 11px; color: var(--text2); margin-left: auto; }

/* ── Profile view ── */
.profile-card {
  background: var(--bg2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.profile-card.active { border-color: var(--accent); }

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

.profile-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
}

.profile-info { flex: 1; margin-left: 12px; }

.profile-name {
  font-size: 17px;
  font-weight: 700;
}

.profile-goal-badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
  margin-top: 3px;
}

.badge-gain  { background: rgba(78,205,196,0.15); color: var(--accent2); }
.badge-lose  { background: rgba(108,99,255,0.15);  color: var(--accent);  }
.badge-maintain { background: rgba(255,217,61,0.15); color: var(--carbs); }

.profile-targets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.target-item {
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 8px 4px;
  text-align: center;
}

.target-val {
  font-size: 15px;
  font-weight: 700;
}

.target-lbl {
  font-size: 10px;
  color: var(--text3);
  margin-top: 2px;
}

.profile-actions {
  display: flex;
  gap: 8px;
}

.btn-edit {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-select {
  flex: 1;
  background: var(--accent);
  border: none;
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-select.selected { background: var(--bg3); color: var(--text2); cursor: default; }

/* ── Forms ── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 10px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 15px;
  width: 100%;
  transition: border-color 0.15s;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
}

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

.form-row .form-group { flex: 1; }

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
}

.radio-label input { accent-color: var(--accent); }

.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.unit-label { color: var(--text2); }

/* ── Buttons ── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-primary:hover { opacity: 0.9; }

.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.btn-full { width: 100%; }

/* ── Meal chips ── */
.meal-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

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

/* ── Modal ── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  pointer-events: none;
}

.modal.open { pointer-events: all; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  opacity: 0;
  transition: opacity 0.25s;
  backdrop-filter: blur(2px);
}

.modal.open .modal-backdrop { opacity: 1; }

.modal-sheet {
  position: relative;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(var(--safe-bot) + 20px);
  width: 100%;
  max-height: 90dvh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.modal.open .modal-sheet {
  transform: translateY(0);
}

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

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

.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.close-modal {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  width: 28px;
  height: 28px;
  font-size: 13px;
}

/* ── Recent foods ── */
.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  margin-bottom: 8px;
}

.recent-foods {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.recent-chip {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.recent-chip:hover { border-color: var(--accent); }

/* ── Canvas charts ── */
canvas {
  width: 100%;
  display: block;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bot) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 200;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Meal Plan ── */
.meal-plan-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.meal-plan-card.empty-plan {
  border-style: dashed;
  text-align: center;
}

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

.meal-plan-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text2);
}

.plan-header-actions {
  display: flex;
  gap: 6px;
}

.plan-icon-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: var(--radius-sm);
  width: 30px;
  height: 30px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.meal-plan-hint {
  font-size: 13px;
  color: var(--text3);
  margin-bottom: 12px;
}

.plan-totals-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 12px;
}

.plan-total-item { color: var(--text); }
.plan-total-item.protein { color: var(--protein); }
.plan-total-item.carbs   { color: var(--carbs);   }
.plan-total-item.fat     { color: var(--fat);     }
.plan-total-diff { color: var(--text3); font-size: 11px; margin-left: auto; }

.plan-meal {
  margin-bottom: 12px;
}

.plan-meal:last-child { margin-bottom: 0; }

.plan-meal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0 5px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.plan-meal-name {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text2);
}

.plan-meal-cals {
  font-size: 11px;
  color: var(--text3);
}

.plan-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid rgba(46,51,80,0.5);
  gap: 8px;
}

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

.plan-item-left {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
}

.plan-item-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.plan-item-label {
  font-size: 11px;
  color: var(--text3);
}

.plan-item-macros {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

.pim {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--bg3);
}

.pim.protein { color: var(--protein); }
.pim.carbs   { color: var(--carbs);   }
.pim.fat     { color: var(--fat);     }

/* ── Segmented control ── */
.seg-control {
  display: flex;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}

.seg-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text2);
  padding: 7px 8px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.seg-btn.active {
  background: var(--accent);
  color: #fff;
}

/* ── TDEE section ── */
.tdee-section {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  overflow: hidden;
}

.tdee-toggle-btn {
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.tdee-chevron {
  font-size: 16px;
  color: var(--text2);
  transition: transform 0.2s;
}

.tdee-body {
  display: none;
  padding: 0 14px 14px;
}

.tdee-body.open { display: block; }

.tdee-hint {
  font-size: 12px;
  color: var(--text3);
  margin-bottom: 12px;
}

.tdee-result {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tdee-result-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text2);
}

.tdee-result-row span:last-child {
  font-weight: 700;
  color: var(--text);
}

.tdee-result-row.accent span:last-child {
  color: var(--accent);
  font-size: 15px;
}

/* ── Macro presets ── */
.macro-preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.macro-preset-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
  transition: all 0.15s;
}

.macro-preset-btn.active {
  border-color: var(--accent);
  background: rgba(108, 99, 255, 0.1);
}

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

.preset-split {
  font-size: 11px;
  color: var(--text3);
}

/* ── Macro input group ── */
.macro-input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

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

.macro-input-label {
  width: 54px;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.macro-input-label.protein { color: var(--protein); }
.macro-input-label.carbs   { color: var(--carbs);   }
.macro-input-label.fat     { color: var(--fat);     }

.macro-g-input {
  flex: 1;
  padding: 8px 10px;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
}

.macro-g-label {
  font-size: 13px;
  color: var(--text2);
  width: 14px;
  flex-shrink: 0;
}

.macro-kcal-badge {
  min-width: 62px;
  text-align: right;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.macro-kcal-badge.protein { color: var(--protein); }
.macro-kcal-badge.carbs   { color: var(--carbs);   }
.macro-kcal-badge.fat     { color: var(--fat);     }

/* ── Macro total card ── */
.macro-total-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 14px;
}

.macro-total-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 8px;
}

.macro-total-val {
  font-weight: 700;
  color: var(--text);
}

.macro-stacked-bar {
  height: 8px;
  background: var(--bg2);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  margin-bottom: 6px;
}

.macro-seg {
  height: 100%;
  transition: width 0.3s ease;
}

.macro-seg.protein { background: var(--protein); }
.macro-seg.carbs   { background: var(--carbs);   }
.macro-seg.fat     { background: var(--fat);     }

.macro-pct-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.mpct {
  font-size: 11px;
  font-weight: 600;
}

.mpct.protein { color: var(--protein); }
.mpct.carbs   { color: var(--carbs);   }
.mpct.fat     { color: var(--fat);     }
.mpct.muted   { color: var(--text3); font-weight: 500; }

/* ── Profile card macro bar ── */
.profile-macro-bar {
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
  display: flex;
  margin-bottom: 6px;
}

.profile-macro-pcts {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}

/* ── Large calorie input ── */
.form-input-lg {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  padding: 10px;
}

/* ── Install banner ── */
.install-banner {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bot) + 8px);
  left: 12px;
  right: 12px;
  background: var(--bg2);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  z-index: 150;
  box-shadow: 0 4px 24px rgba(108,99,255,0.25);
}

.install-banner-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.install-banner-text strong {
  font-size: 14px;
  color: var(--text);
}

.install-banner-text span {
  font-size: 12px;
  color: var(--text2);
}

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

.install-dismiss {
  background: none;
  border: none;
  color: var(--text3);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
}

/* ── Utility ── */
.text-center { text-align: center; }
.text-muted { color: var(--text2); }
