/* ── Brand font ─────────────────────────────────────────────────────────────── */
@font-face {
  font-family: 'EarthForm';
  src: url('/fonts/EarthForm-Bold.woff2') format('woff2'),
       url('/fonts/EarthForm-Bold.woff')  format('woff');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
  --primary:   #ea6a2f;
  --primary-dk:#c34f1e;
  --primary-soft: rgba(234,106,47,0.16);
  --bg:        #141922;
  --bg2:       #1b2230;
  --bg3:       #253042;
  --bg4:       #2f3a4d;
  --border:    rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.14);
  --text:      #f4f1eb;
  --text-2:    #b4b0a8;
  --text-3:    #7f8897;
  --error:     #ef4444;
  --warning:   #f2a93b;
  --success:   #39b980;
  --radius:    14px;
  --radius-sm: 8px;
  --nav-h:     64px;
  --safe-b:    env(safe-area-inset-bottom, 0px);
  --shadow-lg: 0 22px 48px rgba(5, 9, 16, 0.28);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-io: cubic-bezier(0.77, 0, 0.175, 1);
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background:
    radial-gradient(circle at top center, rgba(234,106,47,0.10), transparent 28%),
    linear-gradient(180deg, #171d28 0%, #141922 46%, #11161f 100%);
  color: var(--text);
  min-height: 100dvh;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1, "ss01" 1;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font: inherit; }
button, a, input, select, textarea, .goal-card, .intensity-btn, .nav-item, .meal-card-header {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2px solid rgba(234,106,47,0.7);
  outline-offset: 2px;
}

/* ── Screen system ──────────────────────────────────────────────────────────── */
.screen { display: none; min-height: 100dvh; }
.screen.active { display: flex; flex-direction: column; }
.screen-center { align-items: center; justify-content: center; }

/* ── Bottom nav ─────────────────────────────────────────────────────────────── */
.nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + var(--safe-b));
  background: rgba(20,25,34,0.92);
  backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  padding-bottom: var(--safe-b);
  z-index: 100;
  box-shadow: 0 -10px 32px rgba(5, 9, 16, 0.22);
}
.nav-item {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px;
  color: var(--text-3);
  font-size: 10px; font-weight: 500;
  padding: 8px 4px;
  transition: color 160ms var(--ease-out), transform 160ms var(--ease-out);
}
.nav-item.active { color: var(--primary); }
.nav-item:active { transform: scale(0.97); }
.nav-item svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav-brand-icon {
  width: 22px; height: 22px;
  display: block; border-radius: 6px;
  filter: grayscale(1) brightness(0.55);
  transition: filter 160ms var(--ease-out);
}
.nav-item.active .nav-brand-icon { filter: none; }

/* ── Page layout ────────────────────────────────────────────────────────────── */
.page {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
}
.page-header {
  position: sticky; top: 0;
  background: rgba(27,34,48,0.88);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px; z-index: 10;
  display: flex; align-items: center; gap: 12px;
}
.page-header-inner {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
}
.page-title { font-size: 18px; font-weight: 700; flex: 1; }
.page-subtitle {
  font-size: 12px;
  color: var(--text-3);
}
.page-content {
  padding: 16px 20px;
  display: flex; flex-direction: column; gap: 16px;
}
.app-shell-brand {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.app-shell-logo {
  width: 24px;
  height: 24px;
  display: block;
}

/* ── Login ──────────────────────────────────────────────────────────────────── */
.login-box {
  width: 100%;
  max-width: 392px;
  padding: 32px 24px;
  background: linear-gradient(180deg, rgba(27,34,48,0.94), rgba(20,25,34,0.94));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  display: block;
  width: min(100%, 280px);
  height: auto;
  margin: 0 auto 12px;
}
.login-tagline { color: var(--text-2); text-align: center; margin-bottom: 32px; font-size: 14px; }
.login-tabs {
  display: flex;
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius-sm);
  margin-bottom: 20px; padding: 3px;
}
.login-tab {
  flex: 1; padding: 8px; text-align: center;
  color: var(--text-2); font-size: 14px; font-weight: 500;
  border-radius: 6px;
  transition: background-color 160ms var(--ease-out), color 160ms var(--ease-out), transform 160ms var(--ease-out);
}
.login-tab.active { background: rgba(255,255,255,0.06); color: var(--text); font-weight: 700; }
.login-tab:active { transform: scale(0.98); }
.login-input { background: var(--bg3) !important; }

/* ── Form elements ──────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.input {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg3);
  color: var(--text);
  font-size: 16px;
  transition: border-color 160ms var(--ease-out), background-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out);
  -webkit-appearance: none;
}
.input:focus {
  outline: none;
  border-color: rgba(234,106,47,0.62);
  background: var(--bg4);
  box-shadow: 0 0 0 4px rgba(234,106,47,0.10);
}
.input::placeholder { color: var(--text-3); }
input[type="number"] {
  -moz-appearance: textfield;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.select-wrap { position: relative; }
.select-wrap select {
  appearance: none;
  width: 100%; padding: 12px 36px 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg3);
  color: var(--text);
  font-size: 15px;
}
.select-wrap::after {
  content: '';
  position: absolute; right: 14px; top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-top-color: var(--text-2);
  pointer-events: none;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600;
  transition: background-color 160ms var(--ease-out), color 160ms var(--ease-out), border-color 160ms var(--ease-out), opacity 160ms var(--ease-out), transform 120ms var(--ease-out), box-shadow 160ms var(--ease-out);
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn-primary {
  background: linear-gradient(180deg, var(--primary), var(--primary-dk));
  color: #fff;
  width: 100%;
  font-weight: 700;
  box-shadow: 0 12px 28px rgba(195,79,30,0.22);
}
.btn-primary:hover { box-shadow: 0 14px 30px rgba(195,79,30,0.28); }
.btn-outline { border: 1.5px solid var(--border); color: var(--text); background: var(--bg3); }
.btn-ghost { color: var(--text-2); }
.btn-danger { background: var(--error); color: white; }
.btn-secondary { border: 1.5px solid var(--border); color: var(--text-2); background: transparent; }
.btn-secondary.active { border-color: var(--accent); color: var(--accent); background: rgba(195,79,30,0.10); }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-icon {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
}
.btn-icon:hover { background: var(--bg3); }
.btn-icon.logout { color: var(--error); }
.btn-icon.logout:hover { background: rgba(239,68,68,0.08); }
.btn-icon svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: linear-gradient(180deg, rgba(29,37,51,0.96), rgba(24,31,43,0.96));
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(5, 9, 16, 0.16);
}
.card-header {
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 14px; font-weight: 700; }
.card-body { padding: 16px; }

/* ── Stats row ──────────────────────────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat-item { text-align: center; }
.stat-value { font-size: 18px; font-weight: 700; }
.stat-label { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.stat-unit { font-size: 12px; font-weight: 400; color: var(--text-2); }

/* ── Progress bars ──────────────────────────────────────────────────────────── */
.progress-group { display: flex; flex-direction: column; gap: 10px; }
.progress-row {
  display: grid;
  grid-template-columns: 105px minmax(0, 1fr) 76px;
  align-items: center;
  gap: 10px;
}
.progress-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  min-width: 0;
}
.progress-track { flex: 1; height: 8px; background: var(--bg3); border-radius: 4px; overflow: hidden; }
.progress-fill {
  height: 100%; border-radius: 4px;
  background: var(--primary);
  transition: width 220ms var(--ease-out); max-width: 100%;
}
.progress-fill.over    { background: var(--error); }
.progress-fill.warn    { background: var(--warning); }
.progress-fill.protein { background: #3b82f6; }
.progress-fill.carbs   { background: #f59e0b; }
.progress-fill.fat     { background: #ec4899; }
.progress-val {
  font-size: 12px;
  color: var(--text-2);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ── Meal cards ─────────────────────────────────────────────────────────────── */
.meal-card {
  background: linear-gradient(180deg, rgba(29,37,51,0.96), rgba(24,31,43,0.96));
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 10px 26px rgba(5, 9, 16, 0.14);
}
.meal-card-header { padding: 14px 16px; display: flex; align-items: center; gap: 12px; cursor: pointer; }
.meal-status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; background: var(--bg3); }
.meal-status-dot.eaten   { background: var(--success); }
.meal-status-dot.skipped { background: var(--text-3); }
.meal-status-dot.modified{ background: var(--warning); }
.meal-name { font-size: 15px; font-weight: 600; flex: 1; }
.meal-kcal { font-size: 13px; color: var(--text-2); }
.meal-chevron { color: var(--text-3); transition: transform 180ms var(--ease-out); }
.meal-chevron.open { transform: rotate(90deg); }
.meal-items { border-top: 1px solid var(--border); display: none; }
.meal-items.open { display: block; }
.meal-item-row {
  display: flex; align-items: center;
  padding: 10px 16px; gap: 10px;
  border-bottom: 1px solid var(--border);
}
.meal-item-row:last-child { border-bottom: none; }
.meal-item-name { flex: 1; font-size: 14px; }
.meal-item-qty  { font-size: 13px; color: var(--text-2); }
.meal-item-kcal { font-size: 12px; color: var(--text-3); width: 56px; text-align: right; }
.meal-actions { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }

/* ── Home meal check button ─────────────────────────────────────────────── */
.meal-home-check {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.18);
  display: flex; align-items: center; justify-content: center;
  transition: background-color 160ms var(--ease-out), border-color 160ms var(--ease-out), transform 120ms var(--ease-out);
  color: transparent;
}
.meal-home-check svg {
  width: 14px; height: 14px;
  stroke: currentColor; fill: none;
  stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round;
}
.meal-home-check.done {
  background: rgba(57,185,128,0.14);
  border-color: var(--success);
  color: var(--success);
}
.meal-home-check:active { transform: scale(0.88); }

.card-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

/* ── Target breakdown ───────────────────────────────────────────────────── */
.target-breakdown {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.target-breakdown-base {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.target-adj-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.target-adj-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.target-adj-val {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.target-adj-lbl {
  font-size: 11px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

/* ── Plan training context bar ──────────────────────────────────────────── */
.plan-training-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  gap: 10px;
  min-height: 44px;
}
.plan-training-empty { opacity: 0.7; }
.plan-training-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.meal-card-locked { opacity: 0.85; }
.meal-card-locked .meal-name { color: var(--text-2); }
.locked-meals-card {
  overflow: hidden;
}
.locked-meals-card-empty .card-body {
  padding-block: 18px;
}
.locked-meals-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.locked-meals-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.locked-meals-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.locked-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.locked-summary-stat {
  padding: 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
}
.locked-summary-value {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.locked-summary-label {
  font-size: 11px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 4px;
}
.locked-remaining {
  margin-top: 12px;
}
.locked-slots-grid {
  display: grid;
  gap: 12px;
  margin-top: 4px;
}
.locked-slot-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,0.025);
  overflow: hidden;
}
.locked-slot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.locked-slot:last-child { border-bottom: none; }
.locked-slot-name { font-size: 14px; font-weight: 600; flex: 1; }
.locked-slot-empty .locked-slot-name { color: var(--text-3); font-weight: 500; }
.locked-slot-kcal { font-size: 13px; color: var(--text-2); }
.locked-slot-detail {
  padding: 0 16px 12px;
}
.locked-slot-empty-copy {
  padding: 0 16px 16px;
  color: var(--text-3);
  font-size: 13px;
}
.locked-item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.locked-item-row:last-child { border-bottom: none; }
.locked-slot-footer {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 12px;
}
.locked-sheet-slot {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  margin-bottom: 14px;
}
.locked-sheet-slot-label {
  font-size: 11px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.locked-sheet-slot-name {
  font-size: 16px;
  font-weight: 700;
}
.locked-sheet-preview {
  min-height: 18px;
  margin-top: 10px;
}
.chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  color: var(--text-2);
  white-space: nowrap;
}
.chip.chip-active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.plan-meals-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.plan-section-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}
.plan-section-title {
  font-size: 16px;
  font-weight: 700;
}
.plan-section-copy {
  max-width: 58ch;
}
.plan-empty-card .card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-block: 18px;
}
.plan-empty-title {
  font-size: 15px;
  font-weight: 700;
}
.plan-empty-copy {
  font-size: 14px;
  line-height: 1.45;
}

@media (max-width: 640px) {
  .locked-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .locked-meals-head {
    flex-direction: column;
  }
}
.locked-item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.locked-item-row:last-of-type { border-bottom: none; }
.locked-totals {
  display: flex;
  gap: 12px;
  padding-top: 8px;
  font-size: 13px;
  font-weight: 600;
  flex-wrap: wrap;
}
.locked-remaining { padding-top: 4px; }
.food-result-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.food-result-item:last-child { border-bottom: none; }
.food-result-item:active { background: var(--surface-2); }

.plan-inline-note {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.plan-note-summary {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
}

.plan-note-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}

.plan-note-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}

.plan-note-empty {
  color: var(--text-2);
  font-size: 13px;
}

/* ── Training badge ─────────────────────────────────────────────────────────── */
.training-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
  background: rgba(234,88,12,0.12);
  color: var(--primary);
}
.intensity-dots { display: flex; gap: 3px; }
.intensity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bg3); }
.intensity-dot.active { background: var(--primary); }

/* ── Tomorrow preview ───────────────────────────────────────────────────────── */
.tomorrow-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0; font-size: 14px;
}
.tomorrow-row + .tomorrow-row { border-top: 1px solid var(--border); }
.tomorrow-detail {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 0 4px;
  border-top: 1px solid var(--border);
}
.tomorrow-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(234,106,47,0.12);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
}
.tomorrow-note {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-2);
}
.tomorrow-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 0 16px;
}
.check-icon { width: 20px; height: 20px; color: var(--success); }
.cross-icon { width: 20px; height: 20px; color: var(--text-3); }

/* ── Weight chart ───────────────────────────────────────────────────────────── */
.weight-chart { height: 80px; position: relative; }
.weight-svg { width: 100%; height: 100%; overflow: visible; }

/* ── Date nav ───────────────────────────────────────────────────────────────── */
.date-nav { display: flex; align-items: center; gap: 8px; }
.date-label { font-size: 15px; font-weight: 600; }
.date-today-btn {
  font-size: 11px; font-weight: 600;
  color: var(--primary);
  background: rgba(234,88,12,0.12);
  padding: 3px 8px; border-radius: 20px;
}

/* ── Food list ──────────────────────────────────────────────────────────────── */
.food-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 14px 0;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}
.food-row:last-child { border-bottom: none; }
.food-row-main {
  display: flex;
  align-items: center;
  gap: 12px;
}
.food-info { flex: 1; min-width: 0; }
.food-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.food-meta { font-size: 12px; color: var(--text-3); }
.food-kcal { font-size: 13px; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.food-pref-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.food-pref-chip {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  transition: background-color 160ms var(--ease-out), color 160ms var(--ease-out), border-color 160ms var(--ease-out), transform 160ms var(--ease-out);
}
.food-pref-chip:active { transform: translateY(1px) scale(0.99); }

.food-toolbar-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.08);
  background: linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.02));
  box-shadow: 0 14px 32px rgba(5, 9, 16, 0.16);
}

.food-toolbar-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.food-toolbar-title {
  font-size: 16px;
  font-weight: 700;
}

.food-toolbar-text {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.45;
}

.food-toolbar-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 2px;
}

.food-list-card,
.template-list-card {
  margin-top: 4px;
}

.food-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.food-group-title {
  padding: 16px 0 4px;
  font-size: 11px;
  font-weight: 800;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.onboard-pref-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
}
.onboard-pref-title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  color: rgba(255,255,255,0.92);
}
.onboard-pref-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.onboard-pref-chip {
  min-height: 32px;
  transition: background-color 160ms var(--ease-out), color 160ms var(--ease-out), transform 160ms var(--ease-out), border-color 160ms var(--ease-out);
}
.onboard-pref-chip:active {
  transform: translateY(1px) scale(0.98);
}
.pref-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.pref-dot.favorite  { background: #f59e0b; }
.pref-dot.preferred { background: var(--primary); }
.pref-dot.excluded  { background: var(--error); }
.pref-dot.neutral   { background: var(--bg3); }

/* ── Tabs ───────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; padding: 4px; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.06); border-radius: 12px; }
.tab {
  flex: 1; padding: 8px; text-align: center;
  font-size: 13px; font-weight: 600;
  color: var(--text-2); border-radius: 6px;
  transition: background-color 160ms var(--ease-out), color 160ms var(--ease-out), transform 160ms var(--ease-out), box-shadow 160ms var(--ease-out);
}
.tab.active { background: rgba(255,255,255,0.08); color: var(--text); box-shadow: inset 0 1px 0 rgba(255,255,255,0.04); }
.tab:active { transform: scale(0.985); }

/* ── Search ─────────────────────────────────────────────────────────────────── */
.search-wrap { position: relative; }
.search-wrap .input { padding-left: 40px; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.search-icon svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }

/* ── Onboarding ─────────────────────────────────────────────────────────────── */
.onboard-step { display: none; }
.onboard-step.active { display: flex; flex-direction: column; gap: 20px; }
.onboard-progress { display: flex; gap: 6px; }
.onboard-dot { height: 4px; flex: 1; border-radius: 2px; background: var(--bg3); }
.onboard-dot.done { background: var(--primary); }
.onboard-title { font-size: 24px; font-weight: 800; }
.onboard-desc  { font-size: 15px; color: var(--text-2); }
.goal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.goal-card {
  background: var(--bg2); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 16px; text-align: center;
  color: var(--text); cursor: pointer;
  transition: transform 160ms var(--ease-out), border-color 160ms var(--ease-out), background-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out);
}
.goal-card.selected { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 12px 28px rgba(195,79,30,0.16); }
.goal-card:active { transform: scale(0.985); }
.goal-card-icon { font-size: 28px; margin-bottom: 8px; }
.goal-card-name { font-size: 13px; font-weight: 700; }
.intensity-row { display: flex; gap: 8px; }
.intensity-btn {
  flex: 1; padding: 12px 8px; text-align: center;
  background: var(--bg2); border: 2px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-weight: 700; font-size: 16px; cursor: pointer;
  transition: transform 160ms var(--ease-out), border-color 160ms var(--ease-out), background-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out);
}
.intensity-btn.selected { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px rgba(234,106,47,0.16); }
.intensity-btn:active { transform: scale(0.985); }

/* ── Profile ────────────────────────────────────────────────────────────────── */
.profile-row {
  display: flex; align-items: center;
  padding: 14px 0; border-bottom: 1px solid var(--border); gap: 12px;
}
.profile-row:last-child { border-bottom: none; }
.profile-key { font-size: 14px; color: var(--text-2); flex: 1; }
.profile-val { font-size: 14px; font-weight: 600; }

/* ── Overlays / sheets ──────────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200; display: none; align-items: flex-end;
}
.overlay.open { display: flex; }
.sheet {
  background: linear-gradient(180deg, rgba(29,37,51,0.98), rgba(20,25,34,0.98));
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%; max-height: 90dvh;
  overflow-y: auto;
  padding-bottom: calc(24px + var(--safe-b));
}
.sheet-handle {
  width: 40px; height: 4px;
  background: var(--bg3); border-radius: 2px;
  margin: 12px auto 20px;
}
.sheet-header {
  padding: 0 20px 16px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border); margin-bottom: 16px;
}
.sheet-title { font-size: 17px; font-weight: 700; }
.sheet-body { padding: 0 20px; display: flex; flex-direction: column; gap: 16px; }

/* ── SweetAlert ─────────────────────────────────────────────────────────────── */
.swal2-container.swal2-backdrop-show {
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(8px);
}
.swal-app-popup {
  background: linear-gradient(180deg, rgba(29,37,51,0.98), rgba(20,25,34,0.98));
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 22px 22px 18px;
}
.swal-app-title {
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
}
.swal-app-text {
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.5;
}
.swal-app-actions {
  gap: 10px;
  margin-top: 18px;
}
.swal-app-confirm,
.swal-app-cancel {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 120px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  border: 1.5px solid transparent;
}
.swal-app-confirm {
  background: linear-gradient(180deg, var(--primary), var(--primary-dk));
  color: #fff;
  box-shadow: 0 12px 28px rgba(195,79,30,0.22);
}
.swal-app-cancel {
  background: var(--bg3);
  color: var(--text);
  border-color: var(--border);
}
.swal-app-icon.swal2-warning {
  border-color: var(--warning);
  color: var(--warning);
}

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

/* ── Spinner ────────────────────────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid rgba(255,255,255,0.1);
  border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center { display: flex; align-items: center; justify-content: center; padding: 40px; }

.skeleton-stack { display: grid; gap: 14px; }
.skeleton-card {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(29,37,51,0.96), rgba(24,31,43,0.96));
  padding: 18px 16px;
  box-shadow: 0 12px 32px rgba(5, 9, 16, 0.14);
}
.skeleton-line,
.skeleton-pill,
.skeleton-bar {
  background: linear-gradient(90deg, rgba(255,255,255,0.05), rgba(255,255,255,0.10), rgba(255,255,255,0.05));
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
.skeleton-line {
  height: 12px;
  border-radius: 999px;
  margin-bottom: 10px;
}
.skeleton-line:last-child { margin-bottom: 0; }
.skeleton-line.w-70 { width: 70%; }
.skeleton-line.w-55 { width: 55%; }
.skeleton-line.w-40 { width: 40%; }
.skeleton-line.w-30 { width: 30%; }
.skeleton-pill {
  width: 96px;
  height: 26px;
  border-radius: 999px;
}
.skeleton-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.skeleton-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  margin-top: 10px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Empty states ───────────────────────────────────────────────────────────── */
.empty { text-align: center; padding: 48px 24px; color: var(--text-3); }
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-text { font-size: 15px; margin-bottom: 20px; }

/* ── Misc ───────────────────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); }
.text-muted { color: var(--text-2); font-size: 13px; }
.text-error { color: var(--error); font-size: 13px; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 700;
  background: var(--bg3); color: var(--text-2);
}
.badge.green  { background: rgba(234,88,12,0.12); color: var(--primary); }
.badge.orange { background: rgba(245,158,11,0.12); color: #f59e0b; }
.badge.blue   { background: rgba(59,130,246,0.12);  color: #60a5fa; }
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 4px; }
.flex-1 { flex: 1; }
.mt-auto { margin-top: auto; }
.mt-2 { margin-top: 8px; }
.gap-2 { gap: 8px; }
.fw-bold { font-weight: 700; }
.fs-sm { font-size: 13px; }

@media (max-width: 640px) {
  .login-box { border-radius: 22px; margin: 20px; }
  .page-content { padding: 14px 16px; }
  .page-header { padding: 12px 16px; }
  .stats-row,
  .skeleton-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .progress-row {
    grid-template-columns: minmax(0, 1fr) 76px;
    grid-template-areas:
      "label value"
      "track track";
    gap: 6px 10px;
    align-items: end;
  }
  .progress-label { grid-area: label; }
  .progress-track { grid-area: track; }
  .progress-val { grid-area: value; }
  .tomorrow-actions,
  .card-actions {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
