/* ─── Design tokens ─────────────────────────────────────────────────────── */
:root {
  --c-primary:      #2bcbba;
  --c-primary-dim:  #1fa898;
  --c-bg:           #2d3436;
  --c-surface:      #363d3f;
  --c-surface-2:    #404849;
  --c-surface-3:    #4a5254;
  --c-text:         #f0f4f5;
  --c-text-muted:   #8fa3a8;
  --c-text-faint:   #5c7378;
  --c-danger:       #ff6b6b;
  --c-over-budget:  #ff9f43;
  --c-warning:      #feca57;
  --c-success:      #2bcbba;
  --c-zero:         #a29bfe;
  --nav-h:          64px;
  --header-h:       56px;
  --radius:         12px;
  --radius-sm:      8px;
  --radius-lg:      20px;
  --shadow:         0 2px 12px rgba(0,0,0,0.35);
  --shadow-lg:      0 8px 32px rgba(0,0,0,0.5);
  --transition:     0.18s ease;
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

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

button { cursor: pointer; border: none; background: none; }

a { color: var(--c-primary); text-decoration: none; }

/* ─── App shell ─────────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  padding-top: env(safe-area-inset-top, 0);
}

#screen-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--nav-h);
}

#screen-container.no-nav {
  padding-bottom: 0;
}

/* ─── Bottom nav ────────────────────────────────────────────────────────── */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--nav-h);
  background: var(--c-surface);
  border-top: 1px solid var(--c-surface-3);
  display: flex;
  align-items: stretch;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--c-text-faint);
  transition: color var(--transition);
  padding: 8px 4px;
  -webkit-tap-highlight-color: transparent;
}

.nav-item.active { color: var(--c-primary); }
.nav-item svg { width: 22px; height: 22px; }
.nav-item span { font-size: 10px; font-weight: 500; letter-spacing: 0.3px; }

/* ─── Screen header ─────────────────────────────────────────────────────── */
.screen-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--c-bg);
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--c-surface-2);
  gap: 12px;
}

.screen-header h1 {
  font-size: 18px;
  font-weight: 700;
  flex: 1;
  letter-spacing: -0.3px;
}

.screen-header .header-sub {
  font-size: 12px;
  color: var(--c-text-muted);
  font-weight: 400;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text-muted);
  transition: background var(--transition), color var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover, .icon-btn:active { background: var(--c-surface-2); color: var(--c-text); }
.icon-btn svg { width: 20px; height: 20px; }

/* ─── Scrollable screen body ────────────────────────────────────────────── */
.screen-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ─── Cards ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--c-surface);
  border-radius: var(--radius);
  padding: 16px;
}

.card-sm {
  background: var(--c-surface);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

/* ─── Points ring (Today screen) ─────────────────────────────────────────── */
.points-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 16px 16px;
  gap: 16px;
}

.ring-wrap {
  position: relative;
  width: 180px;
  height: 180px;
}

.ring-wrap svg {
  width: 180px;
  height: 180px;
  transform: rotate(-90deg);
}

.ring-track { fill: none; stroke: var(--c-surface-2); stroke-width: 12; }
.ring-fill  { fill: none; stroke: var(--c-primary); stroke-width: 12; stroke-linecap: round; transition: stroke-dashoffset 0.5s ease; }
.ring-fill.over-budget { stroke: var(--c-over-budget); }

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

.ring-value {
  font-size: 42px;
  font-weight: 800;
  letter-spacing: -2px;
  line-height: 1;
  color: var(--c-text);
}
.ring-value.danger { color: var(--c-danger); }

.ring-label {
  font-size: 11px;
  color: var(--c-text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.points-badges {
  display: flex;
  gap: 12px;
}

.points-badge {
  flex: 1;
  background: var(--c-surface);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  text-align: center;
}

.points-badge .badge-val {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
}
.points-badge .badge-val.danger { color: var(--c-danger); }
.points-badge .badge-val.warning { color: var(--c-warning); }

.points-badge .badge-label {
  font-size: 11px;
  color: var(--c-text-muted);
  margin-top: 2px;
}

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

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.section-action {
  font-size: 13px;
  color: var(--c-primary);
  font-weight: 500;
}

/* ─── Food log entries ──────────────────────────────────────────────────── */
.food-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--c-surface);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  position: relative;
  overflow: hidden;
}

.food-entry:last-child { margin-bottom: 0; }

.food-entry-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--c-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
}

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

.food-entry-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.food-entry-meta {
  font-size: 12px;
  color: var(--c-text-muted);
  margin-top: 1px;
}

.food-entry-points {
  text-align: right;
  flex-shrink: 0;
}

.food-entry-pts-val {
  font-size: 18px;
  font-weight: 700;
  color: var(--c-primary);
  line-height: 1;
}
.food-entry-pts-val.zero { color: var(--c-zero); }

.food-entry-pts-label {
  font-size: 10px;
  color: var(--c-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.food-entry-actions {
  display: flex;
  gap: 8px;
  margin-left: 4px;
  flex-shrink: 0;
}

.food-entry-actions button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text-muted);
  transition: background var(--transition);
}
.food-entry-actions button:hover { background: var(--c-surface-2); }
.food-entry-actions button.delete:hover { color: var(--c-danger); }
.food-entry-actions button svg { width: 15px; height: 15px; }

.zero-pill {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  background: var(--c-zero);
  color: var(--c-bg);
  border-radius: 4px;
  padding: 1px 5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  vertical-align: middle;
  margin-left: 4px;
}

/* ─── FAB ────────────────────────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  right: max(16px, calc(50vw - 224px));
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--c-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  z-index: 90;
  transition: transform var(--transition), background var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.fab:active { transform: scale(0.92); background: var(--c-primary-dim); }
.fab svg { width: 24px; height: 24px; }

/* ─── Search screen ─────────────────────────────────────────────────────── */
.search-bar-wrap {
  padding: 12px 16px;
  background: var(--c-bg);
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--c-surface-2);
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--c-surface);
  border-radius: var(--radius);
  padding: 10px 14px;
  border: 2px solid transparent;
  transition: border-color var(--transition);
}
.search-bar:focus-within { border-color: var(--c-primary); }
.search-bar svg { width: 18px; height: 18px; color: var(--c-text-muted); flex-shrink: 0; }
.search-bar input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--c-text);
  font-size: 15px;
}
.search-bar input::placeholder { color: var(--c-text-faint); }
.search-clear {
  color: var(--c-text-muted);
  padding: 2px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.search-clear svg { width: 16px; height: 16px; }
.scan-btn {
  color: var(--c-primary);
  padding: 2px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.scan-btn svg { width: 20px; height: 20px; }

.scanner-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.scanner-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  color: #fff;
}
.scanner-title { font-size: 17px; font-weight: 700; }
.scanner-close {
  background: none;
  border: none;
  color: #fff;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.scanner-close svg { width: 22px; height: 22px; }
.scanner-viewport {
  position: relative;
  width: 100%;
  flex: 1;
  overflow: hidden;
}
#scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.scanner-reticle {
  position: absolute;
  inset: 20%;
  border: 2px solid var(--c-primary);
  border-radius: var(--radius-sm);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .5);
}
.scanner-hint {
  color: rgba(255, 255, 255, .7);
  font-size: 14px;
  padding: 16px;
  text-align: center;
}

.food-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--c-surface);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
  transition: background var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.food-card:active { background: var(--c-surface-2); }
.food-card:last-child { margin-bottom: 0; }

.food-card-info { flex: 1; min-width: 0; }
.food-card-name {
  font-size: 14px;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.food-card-sub {
  font-size: 12px;
  color: var(--c-text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.food-card-right {
  text-align: right;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.pts-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--c-primary);
  color: var(--c-bg);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}
.pts-chip.zero-pts { background: var(--c-zero); }
.pts-chip-label { font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; opacity: 0.75; }

.star-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text-muted);
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}
.star-btn:hover { background: var(--c-surface-2); }
.star-btn.active { color: var(--c-warning); }
.star-btn svg { width: 18px; height: 18px; }

/* ─── Search states ─────────────────────────────────────────────────────── */
.search-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  gap: 12px;
  color: var(--c-text-muted);
  font-size: 14px;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--c-surface-2);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  gap: 12px;
  text-align: center;
  color: var(--c-text-muted);
}
.empty-state svg { width: 48px; height: 48px; opacity: 0.4; }
.empty-state p { font-size: 14px; line-height: 1.5; }
.empty-state strong { color: var(--c-text); }

/* ─── Forms & inputs ────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  background: var(--c-surface-2);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--c-text);
  font-size: 16px;
  padding: 12px 14px;
  outline: none;
  transition: border-color var(--transition);
  width: 100%;
  -webkit-appearance: none;
}
.form-input:focus { border-color: var(--c-primary); }
.form-input::placeholder { color: var(--c-text-faint); }

select.form-input { cursor: pointer; }

.form-row {
  display: flex;
  gap: 12px;
}
.form-row .form-group { flex: 1; }

.form-hint {
  font-size: 12px;
  color: var(--c-text-faint);
  margin-top: 2px;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  transition: opacity var(--transition), transform var(--transition);
  -webkit-tap-highlight-color: transparent;
  width: 100%;
}
.btn:active { transform: scale(0.97); opacity: 0.9; }

.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-dim); }

.btn-secondary { background: var(--c-surface-2); color: var(--c-text); }
.btn-secondary:hover { background: var(--c-surface-3); }

.btn-danger { background: var(--c-danger); color: #fff; }

.btn-ghost { background: transparent; color: var(--c-primary); border: 2px solid var(--c-primary); }

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.btn svg { width: 18px; height: 18px; }

/* ─── Quantity stepper ──────────────────────────────────────────────────── */
.qty-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--c-surface-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.qty-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-primary);
  font-size: 22px;
  font-weight: 300;
  transition: background var(--transition);
  flex-shrink: 0;
}
.qty-btn:active { background: var(--c-surface-3); }

.qty-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  text-align: center;
  color: var(--c-text);
  font-size: 16px;
  font-weight: 600;
  padding: 0;
  min-width: 0;
  -webkit-appearance: none;
}

/* ─── Modal ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal-sheet {
  width: 100%;
  max-width: 480px;
  background: var(--c-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 0 0 env(safe-area-inset-bottom, 16px);
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 90dvh;
  overflow-y: auto;
}
.modal-overlay.open .modal-sheet { transform: translateY(0); }

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

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px 20px 0;
  gap: 12px;
}

.modal-title { font-size: 17px; font-weight: 700; line-height: 1.3; }
.modal-brand { font-size: 13px; color: var(--c-text-muted); margin-top: 2px; }

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--c-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text-muted);
  flex-shrink: 0;
  margin-top: 2px;
}
.modal-close svg { width: 16px; height: 16px; }

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

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

.macro-cell {
  background: var(--c-surface-2);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
}
.macro-cell .macro-val {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.1;
}
.macro-cell .macro-lbl {
  font-size: 10px;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.points-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px;
  background: var(--c-surface-2);
  border-radius: var(--radius);
}
.pts-big { font-size: 40px; font-weight: 800; color: var(--c-primary); line-height: 1; letter-spacing: -2px; }
.pts-big.zero { color: var(--c-zero); }
.pts-side { display: flex; flex-direction: column; }
.pts-side-label { font-size: 11px; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: 0.6px; }
.pts-side-cals { font-size: 16px; font-weight: 600; margin-top: 2px; }

.serving-info { font-size: 13px; color: var(--c-text-muted); text-align: center; }

/* ─── Progress ring (Activity) ──────────────────────────────────────────── */
.activity-ring-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  gap: 8px;
}

.ring-wrap-sm {
  position: relative;
  width: 140px;
  height: 140px;
}
.ring-wrap-sm svg { width: 140px; height: 140px; transform: rotate(-90deg); }
.ring-wrap-sm .ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-wrap-sm .ring-value { font-size: 32px; font-weight: 800; letter-spacing: -1px; line-height: 1; }
.ring-wrap-sm .ring-label { font-size: 10px; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: 0.8px; font-weight: 500; }

/* ─── Progress / charts ─────────────────────────────────────────────────── */
.chart-wrap {
  background: var(--c-surface);
  border-radius: var(--radius);
  padding: 16px;
  overflow: hidden;
}

.chart-wrap svg { width: 100%; display: block; }

.weight-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.stat-card {
  background: var(--c-surface);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.stat-card .stat-val { font-size: 22px; font-weight: 700; line-height: 1; }
.stat-card .stat-val.positive { color: var(--c-primary); }
.stat-card .stat-val.negative { color: var(--c-danger); }
.stat-card .stat-lbl { font-size: 12px; color: var(--c-text-muted); margin-top: 4px; }

.week-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.week-table th {
  color: var(--c-text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.5px;
  padding: 6px 8px;
  text-align: left;
}
.week-table td { padding: 10px 8px; border-top: 1px solid var(--c-surface-2); }
.week-table tr.today td { background: rgba(43,203,186,0.07); }
.week-table .pts-cell { font-weight: 600; }
.week-table .pts-cell.over { color: var(--c-danger); }
.week-table .pts-cell.under { color: var(--c-primary); }

/* ─── Onboarding ────────────────────────────────────────────────────────── */
#onboarding {
  position: fixed;
  inset: 0;
  background: var(--c-bg);
  z-index: 300;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.ob-header {
  padding: 48px 24px 24px;
  text-align: center;
}

.ob-logo {
  font-size: 36px;
  font-weight: 900;
  color: var(--c-primary);
  letter-spacing: -1.5px;
  margin-bottom: 8px;
}

.ob-tagline {
  font-size: 15px;
  color: var(--c-text-muted);
}

.ob-step {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.ob-step-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.ob-step-sub {
  font-size: 14px;
  color: var(--c-text-muted);
  margin-top: -12px;
}

.ob-progress {
  display: flex;
  gap: 6px;
  padding: 0 24px 16px;
}
.ob-progress-dot {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: var(--c-surface-2);
  transition: background 0.3s;
}
.ob-progress-dot.done { background: var(--c-primary); }

.budget-result {
  background: var(--c-surface);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.budget-result .budget-val {
  font-size: 56px;
  font-weight: 900;
  color: var(--c-primary);
  letter-spacing: -3px;
  line-height: 1;
}
.budget-result .budget-label {
  font-size: 14px;
  color: var(--c-text-muted);
  margin-top: 8px;
}
.budget-adjust {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.seg-control {
  display: flex;
  background: var(--c-surface-2);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}
.seg-btn {
  flex: 1;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text-muted);
  transition: background var(--transition), color var(--transition);
  text-align: center;
}
.seg-btn.active {
  background: var(--c-surface-3);
  color: var(--c-text);
}

/* ─── Tag / pill ─────────────────────────────────────────────────────────── */
.tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.tag-primary { background: rgba(43,203,186,0.15); color: var(--c-primary); }
.tag-danger  { background: rgba(255,107,107,0.15); color: var(--c-danger); }
.tag-zero    { background: rgba(162,155,254,0.15); color: var(--c-zero); }
.tag-warning { background: rgba(254,202,87,0.15); color: var(--c-warning); }

/* ─── Divider ────────────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--c-surface-2);
  margin: 4px 0;
}

/* ─── Profile rows ──────────────────────────────────────────────────────── */
.pref-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--c-surface);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  gap: 12px;
  cursor: pointer;
  transition: background var(--transition);
}
.pref-row:last-child { margin-bottom: 0; }
.pref-row:active { background: var(--c-surface-2); }
.pref-row-label { font-size: 15px; font-weight: 500; }
.pref-row-value { font-size: 14px; color: var(--c-text-muted); }
.pref-row-icon { color: var(--c-text-faint); }
.pref-row-icon svg { width: 16px; height: 16px; }
.pref-row.danger .pref-row-label { color: var(--c-danger); }

/* ─── Toast ──────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 440px;
}

.toast {
  background: var(--c-surface-3);
  color: var(--c-text);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: toast-in 0.25s ease forwards;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast.success { border-left: 3px solid var(--c-success); }
.toast.error   { border-left: 3px solid var(--c-danger); }
.toast.fade-out { animation: toast-out 0.25s ease forwards; }

@keyframes toast-in  { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; transform: translateY(-8px); } }

/* ─── Confirm dialog ────────────────────────────────────────────────────── */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.confirm-box {
  background: var(--c-surface);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 320px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}
.confirm-title { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.confirm-msg { font-size: 14px; color: var(--c-text-muted); margin-bottom: 20px; }
.confirm-actions { display: flex; gap: 10px; }

/* ─── Steps entry ───────────────────────────────────────────────────────── */
.steps-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--c-surface);
  border-radius: var(--radius);
}
.steps-icon { font-size: 32px; }
.steps-info { flex: 1; }
.steps-val { font-size: 26px; font-weight: 700; line-height: 1; }
.steps-label { font-size: 12px; color: var(--c-text-muted); margin-top: 2px; }
.steps-input-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.steps-input-row .form-input { flex: 1; padding: 8px 12px; font-size: 15px; }

/* ─── Activity entry ────────────────────────────────────────────────────── */
.activity-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--c-surface);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.activity-entry:last-child { margin-bottom: 0; }
.activity-entry-icon {
  width: 36px;
  height: 36px;
  background: rgba(43,203,186,0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.activity-entry-info { flex: 1; }
.activity-entry-name { font-size: 14px; font-weight: 600; }
.activity-entry-meta { font-size: 12px; color: var(--c-text-muted); }
.activity-entry-dur { font-size: 16px; font-weight: 700; color: var(--c-primary); text-align: right; }

/* ─── Weight log list ───────────────────────────────────────────────────── */
.weight-entry {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  background: var(--c-surface);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  gap: 12px;
}
.weight-entry:last-child { margin-bottom: 0; }
.weight-entry-date { flex: 1; font-size: 14px; color: var(--c-text-muted); }
.weight-entry-val { font-size: 16px; font-weight: 700; }
.weight-entry-diff { font-size: 12px; font-weight: 600; margin-left: 6px; }
.weight-entry-diff.down { color: var(--c-primary); }
.weight-entry-diff.up   { color: var(--c-danger); }

/* ─── In-red state ──────────────────────────────────────────────────────── */
.in-the-red {
  background: rgba(255,159,67,0.12);
  border: 1px solid rgba(255,159,67,0.3);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--c-over-budget);
  display: flex;
  align-items: center;
  gap: 8px;
}
.in-the-red svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ─── Custom food form ──────────────────────────────────────────────────── */
.custom-food-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--c-primary);
  font-size: 14px;
  font-weight: 500;
  padding: 4px 0;
}
.custom-food-toggle svg { width: 18px; height: 18px; }

/* ─── Misc ──────────────────────────────────────────────────────────────── */
.text-muted { color: var(--c-text-muted); }
.text-danger { color: var(--c-danger); }
.text-primary { color: var(--c-primary); }
.text-center { text-align: center; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.fw-700 { font-weight: 700; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mb-8  { margin-bottom: 8px; }

.no-entries {
  text-align: center;
  padding: 24px;
  color: var(--c-text-faint);
  font-size: 14px;
}

/* ─── Today screen header ────────────────────────────────────────────────── */
.today-header {
  height: auto;
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  gap: 0;
  border-bottom: none;
  background: var(--c-surface);
}

.today-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 4px;
  gap: 12px;
}

/* ─── Points hero (arc layout) ───────────────────────────────────────────── */
.points-hero-new {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 16px 4px;
  gap: 8px;
}

.hero-stat {
  min-width: 68px;
  padding-bottom: 12px;
}
.hero-stat-left { text-align: right; }
.hero-stat-right { text-align: left; }

.hero-val {
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.5px;
}
.hero-val.danger  { color: var(--c-over-budget); }
.hero-val.warning { color: var(--c-warning); }

.hero-lbl {
  font-size: 10px;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
  margin-top: 3px;
}

.arc-center {
  position: relative;
  flex: 1;
  display: flex;
  justify-content: center;
}

.arc-svg {
  width: 100%;
  max-width: 190px;
  display: block;
  overflow: visible;
}

.arc-track {
  fill: none;
  stroke: var(--c-surface-3);
  stroke-linecap: round;
}

.arc-fill {
  fill: none;
  stroke: var(--c-primary);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease;
}
.arc-fill.over-budget { stroke: var(--c-over-budget); }

.arc-center-text {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
  padding-bottom: 4px;
}

.arc-value {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1.5px;
  line-height: 1;
  color: var(--c-text);
}
.arc-value.danger { color: var(--c-over-budget); }

.arc-label {
  font-size: 10px;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 500;
  margin-top: 1px;
}

.arc-budget-sub {
  font-size: 11px;
  color: var(--c-text-faint);
  margin-top: 1px;
}

/* ─── Calories bar ───────────────────────────────────────────────────────── */
.calories-bar-wrap {
  height: 5px;
  background: var(--c-surface-3);
  margin: 0 16px;
  border-radius: 3px;
  overflow: hidden;
}

.calories-bar-fill {
  height: 100%;
  background: var(--c-primary);
  border-radius: 3px;
  transition: width 0.4s ease;
  min-width: 0;
}

.calories-bar-label {
  display: flex;
  justify-content: space-between;
  padding: 4px 16px 6px;
  font-size: 10px;
  color: var(--c-text-faint);
}

/* ─── Week strip ─────────────────────────────────────────────────────────── */
.week-strip {
  display: flex;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-surface-2);
  padding: 6px 8px 8px;
}

.week-strip-day {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 2px;
  border-radius: var(--radius-sm);
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
.week-strip-day:disabled { cursor: default; }
.week-strip-day.future { opacity: 0.3; pointer-events: none; }

.wsd-letter {
  font-size: 10px;
  font-weight: 600;
  color: var(--c-text-faint);
  letter-spacing: 0.3px;
}

.wsd-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  color: var(--c-text-muted);
}
.week-strip-day.active .wsd-num {
  background: var(--c-primary);
  color: var(--c-bg);
  font-weight: 700;
}
.wsd-num.today-dot-ring {
  border: 2px solid var(--c-primary);
  color: var(--c-primary);
}

.wsd-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--c-primary);
}
.wsd-dot.invisible { visibility: hidden; }

/* ─── Meal sections ──────────────────────────────────────────────────────── */
.meal-section {
  margin-bottom: 4px;
}

.meal-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--c-surface-2);
  margin-bottom: 8px;
}

.meal-icon { font-size: 17px; flex-shrink: 0; }

.meal-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--c-text-muted);
}

.meal-pts {
  flex: 1;
  text-align: right;
  font-size: 12px;
  color: var(--c-text-muted);
  font-weight: 500;
}

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

.meal-complete-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text-faint);
  border: 1.5px solid var(--c-surface-3);
  transition: all var(--transition);
}
.meal-complete-btn.done {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: var(--c-bg);
}
.meal-complete-btn svg { width: 13px; height: 13px; }

.meal-add-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-primary);
  background: rgba(43,203,186,0.12);
  transition: background var(--transition);
}
.meal-add-btn:active { background: rgba(43,203,186,0.25); }
.meal-add-btn svg { width: 14px; height: 14px; }

.meal-empty {
  text-align: center;
  padding: 10px;
  color: var(--c-text-faint);
  font-size: 12px;
  font-style: italic;
}

/* ─── Meal selector pills (modal) ────────────────────────────────────────── */
.meal-pills {
  display: flex;
  gap: 6px;
}

.meal-pill {
  flex: 1;
  padding: 8px 4px;
  font-size: 11px;
  font-weight: 600;
  background: var(--c-surface-2);
  color: var(--c-text-muted);
  border-radius: var(--radius-sm);
  text-align: center;
  transition: background var(--transition), color var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.meal-pill.active {
  background: var(--c-primary);
  color: var(--c-bg);
}

/* ─── Totals card ────────────────────────────────────────────────────────── */
.totals-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ─── Water & supplement tracker sections ──────────────────────────────── */
.tracker-section {
  background: var(--c-surface);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
}
.tracker-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.tracker-icon { font-size: 16px; }
.tracker-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--c-text-muted);
  flex: 1;
}
.tracker-value { font-size: 13px; font-weight: 600; }
.tracker-bar-wrap {
  height: 6px;
  background: var(--c-surface-2);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 10px;
}
.tracker-bar-fill { height: 100%; border-radius: 3px; transition: width .3s ease; }
.water-fill { background: #4fc3f7; }

.water-btns {
  display: flex;
  gap: 6px;
}
.water-quick-btn {
  flex: 1;
  background: var(--c-surface-2);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--c-text);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 0;
  cursor: pointer;
  transition: background var(--transition);
}
.water-quick-btn:active { background: var(--c-primary); color: var(--c-bg); }
.water-custom-btn {
  background: var(--c-surface-2);
  border: none;
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  cursor: pointer;
  font-size: 14px;
  transition: background var(--transition);
}
.water-custom-btn:active { background: var(--c-surface-2); }

/* Supplement rows */
.supp-list { display: flex; flex-direction: column; gap: 6px; }
.supp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  transition: opacity .2s;
}
.supp-row.done { opacity: .55; }
.supp-check {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--c-surface-2);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color .15s, background .15s;
}
.supp-check svg { width: 14px; height: 14px; opacity: 0; transition: opacity .15s; }
.supp-check.checked { border-color: var(--c-primary); background: var(--c-primary); }
.supp-check.checked svg { opacity: 1; stroke: var(--c-bg); }
.supp-info { display: flex; flex-direction: column; gap: 1px; overflow: hidden; min-width: 0; }
.supp-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.supp-dosage { font-size: 12px; }

/* ─── Custom food form (Search screen) ─────────────────────────────────── */
.cf-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cf-pts-preview {
  background: var(--c-surface);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  text-align: center;
  font-size: 14px;
  color: var(--c-text-muted);
}

.cf-pts-val {
  color: var(--c-primary);
  font-size: 22px;
}

/* ─── Profile avatar ────────────────────────────────────────────────────── */
.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--c-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  color: var(--c-bg);
  flex-shrink: 0;
}

/* ─── Activity type picker ──────────────────────────────────────────────── */
.act-type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.act-type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  background: var(--c-surface-2);
  border-radius: var(--radius-sm);
  color: var(--c-text-muted);
  transition: background var(--transition), color var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.act-type-btn.active {
  background: var(--c-primary);
  color: var(--c-bg);
}

.act-type-emoji { font-size: 20px; line-height: 1; }
.act-type-name  { font-size: 11px; font-weight: 600; }

/* ─── Weight hero (Progress screen) ────────────────────────────────────── */
.weight-hero-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.weight-hero-val {
  font-size: 48px;
  font-weight: 800;
  letter-spacing: -2px;
  line-height: 1;
}

.weight-hero-unit {
  font-size: 20px;
  font-weight: 600;
  color: var(--c-text-muted);
  letter-spacing: 0;
}

.weight-hero-lbl {
  font-size: 12px;
  color: var(--c-text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.weight-goal-bar-wrap {
  height: 6px;
  background: var(--c-surface-2);
  border-radius: 3px;
  overflow: hidden;
}

.weight-goal-bar-fill {
  height: 100%;
  background: var(--c-primary);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.weight-goal-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--c-text-faint);
  margin-top: 4px;
}

.weight-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

/* ─── Weekly day rows (Progress screen) ─────────────────────────────────── */
.week-day-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.week-day-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  background: var(--c-surface-2);
  border-radius: var(--radius-sm);
}

.week-day-row.is-today {
  background: rgba(43,203,186,0.1);
  border: 1px solid rgba(43,203,186,0.2);
}

.week-day-row.is-future { opacity: 0.4; }

.wdr-name {
  font-size: 12px;
  font-weight: 600;
  width: 30px;
  flex-shrink: 0;
  color: var(--c-text-muted);
}

.week-day-row.is-today .wdr-name { color: var(--c-primary); }

.wdr-bar-wrap {
  flex: 1;
  height: 5px;
  background: var(--c-surface-3);
  border-radius: 3px;
  overflow: hidden;
}

.wdr-bar-fill {
  height: 100%;
  background: var(--c-primary);
  border-radius: 3px;
  transition: width 0.3s ease;
  min-width: 0;
}

.wdr-bar-fill.over { background: var(--c-over-budget); }

.wdr-pts {
  font-size: 13px;
  font-weight: 700;
  width: 28px;
  text-align: right;
  flex-shrink: 0;
  color: var(--c-text);
}

.wdr-pts.over { color: var(--c-over-budget); }

.wdr-rollover {
  font-size: 11px;
  font-weight: 600;
  color: var(--c-primary);
  width: 26px;
  text-align: right;
  flex-shrink: 0;
}

/* ─── Responsive tweaks for desktop ────────────────────────────────────── */
@media (min-width: 480px) {
  #app { box-shadow: var(--shadow-lg); }
  .fab { right: calc(50vw - 224px); }
}

@media (prefers-color-scheme: light) {
  /* App intentionally dark-only; ignore system preference */
}
