/* ═════════════════════════════════════════════════════════════════════════
   Fitlog — design tokens + components
   Single source of truth for all colors / radii / typography.
   ═════════════════════════════════════════════════════════════════════════ */

:root {
  /* ── Surfaces ─────────────────────────────────────────────────────────── */
  --bg: #14111c;
  --surface:    #1c1828;   /* legacy alias for surface-1 */
  --surface-1:  #1c1828;
  --surface-2:  #231e32;
  --surface-3:  #2c2540;

  --hairline:        rgba(255, 240, 230, 0.06);
  --hairline-strong: rgba(255, 240, 230, 0.10);
  /* legacy border tokens — point at hairline values so existing rules still read OK */
  --border:        rgba(255, 240, 230, 0.10);
  --border-strong: rgba(255, 240, 230, 0.16);

  /* ── Text (slight warm tint, no pure white) ───────────────────────────── */
  --text:           #f5f0ff;
  --text-primary:   #f5f0ff;
  --text-mute:      #b0a8c4;   /* legacy alias for text-secondary */
  --text-secondary: #b0a8c4;
  --text-dim:       #7a7290;   /* legacy alias for text-tertiary */
  --text-tertiary:  #7a7290;
  --text-faint:     #524a66;   /* legacy alias for text-muted */
  --text-muted:     #524a66;

  /* ── Interface accent — tabs, progress, links, badges ─────────────────── */
  --accent:        #a855f7;
  --accent-strong: #c084fc;
  --accent-soft:   rgba(168, 85, 247, 0.14);
  --accent-glow:   rgba(168, 85, 247, 0.38);

  /* ── CTA — "commit a data point" only (submit meal, save weight) ──────── */
  --cta:        #fbbf24;
  --cta-strong: #f59e0b;
  --cta-soft:   rgba(251, 191, 36, 0.12);
  --cta-glow:   rgba(251, 191, 36, 0.35);
  --cta-ink:    #1c1828;

  /* ── Macro chips (kept from slice 1 — visual category cues) ───────────── */
  --cal:         #fbbf24;
  --cal-soft:    rgba(251, 191, 36, 0.18);
  --protein:     #3b82f6;
  --protein-soft:rgba(59, 130, 246, 0.18);
  --fat:         #f97316;
  --fat-soft:    rgba(249, 115, 22, 0.18);
  --carbs:       #10b981;
  --carbs-soft:  rgba(16, 185, 129, 0.18);

  /* ── Semantic ─────────────────────────────────────────────────────────── */
  --positive:      #4ade80;
  --positive-soft: rgba(74, 222, 128, 0.18);
  --negative:      #f87171;
  --negative-soft: rgba(248, 113, 113, 0.18);
  --success:       #4ade80;
  --danger:        #f87171;

  /* ── Radii ────────────────────────────────────────────────────────────── */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
}

/* ═════════════════════════════════════════════════════════════════════════
   Base
   ═════════════════════════════════════════════════════════════════════════ */

* { box-sizing: border-box; }
/* html background covers the iOS safe-area (notch / Dynamic Island) too —
   otherwise iOS shows a black strip above the content in PWA mode. */
html {
  height: 100%;
  background: var(--bg);
}
body {
  margin: 0; padding: 0;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, sans-serif;
  color: var(--text);
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background: var(--bg);
  height: 100%;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
/* Soft purple radial behind everything — adds depth without competing with content */
body::before {
  content: "";
  position: fixed;
  top: -200px; left: 50%;
  transform: translateX(-50%);
  width: 700px; height: 700px;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.08) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* Numbers everywhere use the mono face for tabular alignment */
.num {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* ═════════════════════════════════════════════════════════════════════════
   App shell
   ═════════════════════════════════════════════════════════════════════════ */

#app-shell {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

/* ── Shared header ─────────────────────────────────────────────────────── */
.main-header {
  flex-shrink: 0;
  display: flex; align-items: flex-start;
  justify-content: space-between;
  /* top padding picks up iOS safe-area-inset so the title clears the notch */
  padding: calc(16px + env(safe-area-inset-top, 0px)) 20px 12px;
  max-width: 480px; width: 100%; margin: 0 auto;
  gap: 16px;
}
.brand-name {
  font-size: 16px; font-weight: 600;
  letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 8px;
}
.brand-date { color: var(--text-tertiary); font-size: 13px; margin-top: 4px; font-weight: 400; }

.head-weight { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.head-weight-row { display: flex; align-items: baseline; gap: 4px; }
.head-weight .big {
  font-size: 28px; font-weight: 600; line-height: 1;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.head-weight .unit { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.remaining-label {
  font-size: 11px; color: var(--text-tertiary);
  text-transform: lowercase; letter-spacing: 0.02em;
}

/* Segmented control (weight display mode) */
.seg {
  display: inline-flex;
  border: 1px solid var(--hairline-strong);
  border-radius: 100px;
  padding: 3px; background: var(--surface-1); gap: 0;
}
.seg button {
  background: transparent; border: 0;
  color: var(--text-secondary); font-family: inherit;
  font-size: 10.5px; font-weight: 500; letter-spacing: 0.04em;
  padding: 4px 10px; border-radius: 100px; cursor: pointer;
  transition: all 120ms ease;
  font-variant-numeric: tabular-nums;
}
.seg button.active { background: var(--accent-soft); color: var(--accent-strong); }
.seg button:hover:not(.active) { color: var(--text); }

/* ── Pages / tab swipe ─────────────────────────────────────────────────── */
#pages-wrap { flex: 1; overflow: hidden; min-height: 0; }
#pages {
  display: flex;
  width: 200%;
  height: 100%;
  will-change: transform;
  transition: transform 320ms cubic-bezier(0.4, 0, 0.2, 1);
}
#pages.show-food { transform: translateX(-50%); }

.page {
  width: 50%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}
.page-inner {
  max-width: 480px;
  margin: 0 auto;
  padding: 4px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
/* Food page needs extra bottom padding to clear the fixed input bar */
body.food-active #page-food .page-inner { padding-bottom: 140px; }

/* ── Tab bar ───────────────────────────────────────────────────────────── */
#tab-bar {
  flex-shrink: 0;
  background: rgba(20, 17, 28, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--hairline);
}
.tab-inner { max-width: 480px; margin: 0 auto; display: flex; }
.tab-btn {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; gap: 3px;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom, 0px));
  background: none; border: none; cursor: pointer;
  color: var(--text-tertiary); font-family: inherit;
  font-size: 10.5px; font-weight: 500; letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: color 150ms;
}
.tab-btn.active { color: var(--accent-strong); }
.tab-btn svg { width: 22px; height: 22px; }

/* ═════════════════════════════════════════════════════════════════════════
   Cards & buttons (shared across slices)
   ═════════════════════════════════════════════════════════════════════════ */

.card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl);
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.weigh-in {
  background: linear-gradient(180deg, #2a2240 0%, var(--surface-2) 100%);
  border: 1px solid var(--hairline-strong);
  border-top: 1px solid rgba(168, 85, 247, 0.5);
  box-shadow: inset 0 1px 0 rgba(168, 85, 247, 0.35), 0 4px 24px rgba(168, 85, 247, 0.08);
}
.weigh-in .row {
  display: flex; align-items: center;
  justify-content: space-between; gap: 12px; margin-top: 14px;
}
.weigh-in-input { flex: 1; display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.weigh-in-input input {
  background: transparent; border: 0; outline: 0;
  color: var(--text-primary); font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 40px; font-weight: 600; letter-spacing: -0.03em;
  width: 100%; min-width: 0; padding: 0;
  font-variant-numeric: tabular-nums;
}
.weigh-in-input input::placeholder { color: var(--text-muted); }
.weigh-in-input .unit { font-size: 16px; color: var(--text-secondary); font-weight: 500; }

.btn-primary {
  background: var(--accent); color: #fff;
  border: 0; border-radius: 8px; padding: 12px 18px;
  font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; letter-spacing: -0.005em;
  transition: filter 120ms ease, transform 120ms ease;
  box-shadow: 0 0 24px var(--accent-glow), 0 4px 12px rgba(168, 85, 247, 0.2);
  white-space: nowrap;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.5; cursor: default; }
.btn-amber {
  background: linear-gradient(135deg, var(--cta) 0%, var(--cta-strong) 100%);
  box-shadow: 0 0 28px var(--cta-glow), 0 4px 14px rgba(245, 158, 11, 0.35);
  color: var(--cta-ink);
}

.divider { height: 1px; background: var(--hairline); margin: 16px 0 14px; border: 0; }
.note-row { display: flex; align-items: center; gap: 10px; }
.note-row input {
  background: transparent; border: 0; outline: 0;
  color: var(--text-primary); font-family: inherit;
  font-size: 14px; font-weight: 400; width: 100%; padding: 0;
}
.note-row input::placeholder { color: var(--text-secondary); }
.note-row svg { color: var(--text-tertiary); flex-shrink: 0; }

/* ═════════════════════════════════════════════════════════════════════════
   Weight tab — stats, history, entries
   ═════════════════════════════════════════════════════════════════════════ */

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: 24px; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  min-width: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.chip {
  width: 24px; height: 24px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.chip svg { width: 14px; height: 14px; }

.micro {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-tertiary);
}
.stat .micro { font-size: 10px; letter-spacing: 0.1em; }
.stat .value {
  display: flex; align-items: baseline; gap: 4px;
  font-size: 22px; font-weight: 600; letter-spacing: -0.02em; line-height: 1;
  color: var(--text-primary);
}
.stat .value .unit { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.stat .sub { font-size: 11px; color: var(--text-secondary); margin-top: -2px; }
.goal-action-btn {
  background: none; border: none; padding: 0; cursor: pointer;
  font-family: inherit; font-size: 11px; color: var(--accent-strong);
  text-decoration: underline; text-decoration-style: dotted;
  text-underline-offset: 2px;
}
.goal-action-btn:hover { opacity: 0.75; }
.stat .value.pos { color: var(--positive); }
.stat .value.neg { color: var(--negative); }
.stat .value.pos .arrow,
.stat .value.neg .arrow { display: inline-flex; margin-right: 4px; opacity: 0.9; }

/* ── History card (chart + entries) ────────────────────────────────────── */
.history-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.trend-badge {
  font-size: 11px; font-weight: 500;
  background: linear-gradient(90deg, var(--accent-soft), rgba(168, 85, 247, 0.22));
  color: var(--accent-strong); padding: 5px 10px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 6px;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.15);
}
.pills { display: flex; gap: 6px; margin-bottom: 14px; }
.pill {
  background: transparent; border: 1px solid var(--hairline-strong);
  color: var(--text-secondary); padding: 6px 12px;
  border-radius: 999px; font-family: inherit; font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all 120ms ease;
}
.pill:hover { background: var(--surface-2); color: var(--text); }
.pill.active { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }

.chart-wrap { position: relative; height: 220px; margin: 4px -4px 0; }

/* ── Entries list (weight) ─────────────────────────────────────────────── */
.entries-list { margin-top: 16px; display: flex; flex-direction: column; }
.entry-empty {
  font-size: 13px; color: var(--text-secondary);
  text-align: center; padding: 16px 0 4px;
}
.entry-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-top: 1px solid var(--hairline);
  min-width: 0;
}
.entry-date { font-size: 12px; color: var(--text-secondary); width: 56px; flex-shrink: 0; }
.entry-weight { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; flex-shrink: 0; }
.entry-unit { font-size: 11px; color: var(--text-secondary); font-weight: 400; }
.entry-note {
  font-size: 12px; color: var(--text-secondary); flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.entry-del {
  background: transparent; border: 0; color: var(--text-tertiary);
  cursor: pointer; padding: 4px; border-radius: 4px;
  transition: color 120ms; flex-shrink: 0;
  display: flex; align-items: center;
}
.entry-del:hover { color: var(--negative); }
.entry-edit {
  background: transparent; border: 0; color: var(--text-tertiary);
  cursor: pointer; padding: 4px 6px; border-radius: 4px;
  transition: color 120ms; flex-shrink: 0;
  font-family: inherit; font-size: 11px; font-weight: 500;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.entry-edit:hover { color: var(--accent-strong); }
.history-more-btn {
  width: 100%; margin-top: 8px;
  background: transparent; border: 1px solid var(--hairline-strong);
  border-radius: 8px; color: var(--text-secondary);
  font-family: inherit; font-size: 12px; font-weight: 500;
  padding: 10px; cursor: pointer;
  transition: border-color 120ms, color 120ms;
}
.history-more-btn:hover { border-color: var(--accent); color: var(--accent-strong); }

/* ── Date label (weight tab) ───────────────────────────────────────────── */
.weigh-in-date-label { cursor: pointer; transition: color 120ms; user-select: none; }
.weigh-in-date-label:hover { color: var(--text); }
.date-reset-btn {
  background: transparent; border: 0;
  color: var(--text-tertiary); font-family: inherit;
  font-size: 13px; cursor: pointer; padding: 2px 5px;
  border-radius: 4px; line-height: 1; transition: color 120ms;
}
.date-reset-btn:hover { color: var(--negative); }

/* ═════════════════════════════════════════════════════════════════════════
   Food tab — progress strip, meal list, expanded detail card
   ═════════════════════════════════════════════════════════════════════════ */

/* ── Progress strip ────────────────────────────────────────────────────── */
.progress-strip {
  padding: 16px 18px;
  border-radius: var(--r-md);
  transition: opacity 200ms ease;
}
.progress-strip.empty { opacity: 0.6; }

.progress-row {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 12px;
}
.progress-eaten {
  font-size: 18px; font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.progress-eaten .separator { color: var(--text-muted); margin: 0 4px; }
.progress-eaten .goal {
  color: var(--text-tertiary); font-weight: 500;
  cursor: pointer; transition: color 120ms;
}
.progress-eaten .goal:hover { color: var(--accent-strong); }
.progress-percent {
  font-size: 13px; color: var(--text-secondary); font-weight: 500;
}
.set-goal-link {
  background: none; border: 0; padding: 0;
  font-family: 'Inter', sans-serif;
  font-size: 13px; font-weight: 500;
  color: var(--accent-strong); cursor: pointer;
  text-decoration: underline; text-decoration-style: dotted;
  text-underline-offset: 3px;
  transition: color 120ms;
}
.set-goal-link:hover { color: var(--text-primary); }
.progress-bar {
  height: 4px; background: var(--surface-3);
  border-radius: 2px; overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-strong) 100%);
  border-radius: 2px;
  transition: width 600ms cubic-bezier(0.16, 1, 0.3, 1), background 200ms;
}
.progress-fill.over {
  background: linear-gradient(90deg, var(--cta) 0%, var(--negative) 100%);
}
.progress-macros {
  display: flex; gap: 18px;
  margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--hairline);
  font-size: 12px;
}
.progress-macros .macro { display: flex; align-items: baseline; gap: 5px; }
.progress-macros .macro-label {
  color: var(--text-tertiary); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
  font-family: 'Inter', sans-serif;
}
.progress-macros .macro-value { color: var(--text-secondary); font-weight: 600; }

/* ── Section header (Сегодня / N приёма) ───────────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin: 4px 4px 10px;
}
.section-title {
  font-size: 11px; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600;
}
.section-count {
  font-size: 11px; color: var(--text-muted);
}

/* ── Meal list ─────────────────────────────────────────────────────────── */
.meal-list { display: flex; flex-direction: column; gap: 8px; }

.meal {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.meal:active { transform: scale(0.985); background: var(--surface-2); }
.meal.expanded { background: var(--surface-2); border-color: var(--hairline-strong); }

.meal-time {
  font-size: 12px; color: var(--text-tertiary);
  font-weight: 500; min-width: 44px;
}
.meal-body { flex: 1; min-width: 0; }
.meal-title {
  font-size: 14px; font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.meal-meta { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }
.meal-kcal {
  font-size: 14px; font-weight: 600;
  color: var(--text-secondary);
  min-width: 56px; text-align: right;
}
.meal-kcal .unit { font-size: 10px; color: var(--text-muted); margin-left: 2px; }
.meal.expanded .meal-kcal { color: var(--text-primary); }

.meal-repeat {
  width: 28px; height: 28px; border-radius: 8px;
  background: transparent;
  border: 1px solid var(--hairline-strong);
  color: var(--text-tertiary);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  cursor: pointer;
  flex-shrink: 0;
}
.meal-repeat:hover, .meal-repeat:active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}
.meal-repeat svg { width: 13px; height: 13px; }

/* ── Expanded meal detail card ─────────────────────────────────────────── */
.meal-detail {
  background: linear-gradient(160deg, #3a2660 0%, #251c3f 100%);
  border: 1px solid rgba(168, 85, 247, 0.28);
  border-radius: var(--r-lg);
  padding: 22px 22px 20px;
  position: relative; overflow: hidden;
  animation: detail-slide 220ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes detail-slide {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.meal-detail::before {
  content: ""; position: absolute;
  top: -40%; right: -20%;
  width: 240px; height: 240px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
}
.meal-detail-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; position: relative;
}
.meal-detail-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  background: rgba(168, 85, 247, 0.2);
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: 999px;
  font-size: 11px; color: var(--accent-strong); font-weight: 500;
}
.meal-detail-tag svg { width: 11px; height: 11px; }
.meal-detail-actions { display: flex; align-items: center; gap: 6px; }
.meal-detail-iconbtn {
  width: 32px; height: 32px; border-radius: 10px;
  background: rgba(255, 240, 230, 0.06);
  border: none; color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.meal-detail-iconbtn:hover { background: rgba(255, 240, 230, 0.10); color: var(--text-primary); }
.meal-detail-iconbtn.danger:hover { color: var(--negative); }
.meal-detail-iconbtn svg { width: 15px; height: 15px; }

.meal-detail-kcal {
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 6px; position: relative;
}
.meal-detail-kcal .number {
  font-size: 56px; font-weight: 600;
  letter-spacing: -0.04em; line-height: 1;
  color: var(--text-primary);
}
.meal-detail-kcal .unit {
  font-size: 13px; color: var(--text-secondary); font-weight: 500;
}
.meal-detail-range {
  font-size: 11px; color: var(--text-tertiary);
  margin-bottom: 14px; position: relative;
}
.meal-detail-range.no-range { margin-bottom: 6px; }
.meal-detail-name {
  font-size: 14px; color: var(--text-secondary);
  margin-bottom: 18px; position: relative;
  line-height: 1.45;
}
.meal-detail-macros {
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(0, 0, 0, 0.22);
  border-radius: var(--r-md);
  padding: 14px 0; position: relative;
}
.meal-detail-macro { text-align: center; position: relative; }
.meal-detail-macro:not(:last-child)::after {
  content: ""; position: absolute; right: 0;
  top: 14%; bottom: 14%; width: 1px;
  background: rgba(255, 240, 230, 0.08);
}
.meal-detail-macro .value {
  font-size: 18px; font-weight: 600;
  color: var(--text-primary); letter-spacing: -0.02em;
}
.meal-detail-macro .label {
  font-size: 10px; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-top: 4px; font-weight: 600;
  font-family: 'Inter', sans-serif;
}
.meal-detail-note {
  display: flex; gap: 10px;
  margin-top: 16px; padding-top: 16px;
  border-top: 1px solid rgba(255, 240, 230, 0.06);
  position: relative;
}
.meal-detail-note-icon {
  width: 22px; height: 22px; border-radius: 6px;
  background: rgba(168, 85, 247, 0.22);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-strong);
}
.meal-detail-note-icon svg { width: 12px; height: 12px; }
.meal-detail-note-text {
  font-size: 13px; line-height: 1.45;
  color: var(--text-secondary);
}

/* ── Empty state ───────────────────────────────────────────────────────── */
.empty { padding: 60px 20px 20px; text-align: center; }
.empty-icon {
  width: 48px; height: 48px; border-radius: 14px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-tertiary);
}
.empty-icon svg { width: 22px; height: 22px; }
.empty-title {
  font-size: 15px; color: var(--text-primary);
  font-weight: 500; margin-bottom: 4px;
}
.empty-subtitle {
  font-size: 13px; color: var(--text-tertiary);
  line-height: 1.5; max-width: 280px; margin: 0 auto;
}

/* ── Input bar (fixed, only on food tab) ───────────────────────────────── */
#food-input-bar {
  display: none;
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  width: 100%; max-width: 480px;
  padding: 12px 16px 14px;
  background: linear-gradient(to top, var(--bg) 70%, rgba(20, 17, 28, 0));
  z-index: 50;
}
body.food-active #food-input-bar { display: block; }

.input-wrap {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--hairline-strong);
  border-radius: 999px;
  padding: 6px 6px 6px 18px;
  transition: border-color 150ms, box-shadow 150ms;
}
.input-wrap:focus-within {
  border-color: var(--cta);
  box-shadow: 0 0 0 4px var(--cta-soft);
}
.input-wrap.loading {
  animation: input-pulse 1.2s ease-in-out infinite;
}
@keyframes input-pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-soft); border-color: var(--hairline-strong); }
  50%      { box-shadow: 0 0 0 6px var(--accent-soft); border-color: var(--accent); }
}
.input-field {
  flex: 1; background: transparent;
  border: none; outline: none;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 15px; padding: 10px 0;
  min-width: 0;
}
.input-field::placeholder { color: var(--text-tertiary); }
.input-field:disabled { color: var(--text-tertiary); }
.input-send {
  width: 38px; height: 38px;
  border-radius: 50%; border: none;
  background: var(--cta); color: var(--cta-ink);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: transform 0.1s, background 0.15s, opacity 0.15s;
  box-shadow: 0 4px 14px var(--cta-glow);
}
.input-send:hover { background: var(--cta-strong); }
.input-send:active { transform: scale(0.92); }
.input-send:disabled { opacity: 0.6; cursor: default; }
.input-send svg { width: 16px; height: 16px; }
.input-hint {
  font-size: 10px; color: var(--text-muted);
  text-align: center; margin-top: 8px; padding: 0 20px;
  min-height: 14px;
  transition: color 200ms;
}
.input-hint.error { color: var(--danger); }

/* ═════════════════════════════════════════════════════════════════════════
   Sheets, modals, toasts (shared)
   ═════════════════════════════════════════════════════════════════════════ */

/* History sheet */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 480px; max-height: 85vh;
  background: var(--surface-2); border: 1px solid var(--hairline-strong);
  border-radius: 16px 16px 0 0;
  display: flex; flex-direction: column;
  animation: slideUp 220ms ease;
}
.sheet-handle {
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--hairline-strong); margin: 10px auto 0; flex-shrink: 0;
}
.sheet-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px 12px; flex-shrink: 0;
  border-bottom: 1px solid var(--hairline);
}
.sheet-body {
  overflow-y: auto; flex: 1; padding: 0 20px 32px;
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}

/* Modals */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, 0.65);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0 16px 24px;
}
.modal-card { width: 100%; max-width: 480px; animation: slideUp 200ms ease; }
@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}
.modal-label {
  font-size: 11px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-secondary); display: block; margin-bottom: 6px;
}
.modal-field { margin-bottom: 14px; }
.modal-input {
  background: var(--surface-2); border: 1px solid var(--hairline-strong);
  border-radius: 8px; padding: 10px 12px;
  color: var(--text-primary); font-family: inherit; font-size: 14px;
  width: 100%; outline: none; color-scheme: dark;
  transition: border-color 120ms; -webkit-appearance: none;
}
.modal-input:focus { border-color: var(--accent); }
.modal-hint {
  font-size: 11px; color: var(--text-tertiary);
  line-height: 1.5; margin-top: 6px;
}
.btn-secondary {
  background: var(--surface-2); border: 1px solid var(--hairline-strong);
  color: var(--text-secondary); border-radius: 8px; padding: 12px 18px;
  font-family: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all 120ms ease; white-space: nowrap;
}
.btn-secondary:hover { color: var(--text); }

/* Toasts */
#toast-container {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  z-index: 100; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; align-items: center;
}
.toast {
  background: var(--surface-2); border: 1px solid var(--hairline-strong);
  color: var(--text); font-family: inherit; font-size: 13px; font-weight: 500;
  padding: 10px 16px; border-radius: 10px;
  opacity: 0; transform: translateY(8px); transition: all 200ms ease;
  white-space: nowrap;
}
.toast.toast-in { opacity: 1; transform: translateY(0); }
.toast.toast-ok    { border-color: var(--positive); color: var(--positive); }
.toast.toast-error { border-color: var(--negative); color: var(--negative); }
.toast.toast-info  { border-color: var(--accent-strong); color: var(--text); }

/* ── Pull-to-refresh ───────────────────────────────────────────────────── */
.ptr-indicator {
  position: fixed; top: 20px; left: 50%;
  transform: translateX(-50%) translateY(-64px);
  z-index: 120;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--hairline-strong);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  transition: transform 250ms ease; pointer-events: none;
}
.ptr-indicator.ptr-visible { transform: translateX(-50%) translateY(0); }
.ptr-spinner { animation: spin 700ms linear infinite; color: var(--accent-strong); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Undo bar ──────────────────────────────────────────────────────────── */
.undo-bar {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  z-index: 150;
  background: var(--surface-2); border: 1px solid var(--hairline-strong);
  border-radius: 12px; padding: 10px 12px 10px 16px;
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--text); white-space: nowrap;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  animation: slideUp 200ms ease; max-width: calc(100vw - 32px);
}
.undo-msg { font-weight: 500; flex: 1; }
.undo-cancel-btn {
  background: transparent; border: 1px solid var(--hairline-strong);
  color: var(--accent-strong); font-family: inherit; font-size: 12px; font-weight: 600;
  padding: 5px 10px; border-radius: 6px; cursor: pointer;
  letter-spacing: 0.01em; transition: background 120ms; flex-shrink: 0;
}
.undo-cancel-btn:hover { background: var(--accent-soft); }
.undo-ring-wrap {
  position: relative; width: 26px; height: 26px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.undo-ring-wrap span {
  position: absolute;
  font-size: 10px; font-weight: 700;
  color: var(--text-secondary);
}
.ring-track { stroke: var(--hairline-strong); fill: none; }
.ring-progress {
  fill: none; stroke-linecap: round;
  transition: stroke-dashoffset 900ms ease-out, stroke 500ms ease;
}
.undo-dismiss-btn {
  background: transparent; border: 0; color: var(--text-tertiary);
  font-family: inherit; font-size: 15px; cursor: pointer;
  padding: 2px 4px; border-radius: 4px; transition: color 120ms; line-height: 1; flex-shrink: 0;
}
.undo-dismiss-btn:hover { color: var(--text); }

/* ── Loading shimmer ───────────────────────────────────────────────────── */
@keyframes shimmer {
  0%, 100% { opacity: 0.25; }
  50%      { opacity: 0.55; }
}
#app-shell.loading .head-weight .big,
#app-shell.loading #head-kcal-value,
#app-shell.loading .stat .value,
#app-shell.loading .stat .sub {
  animation: shimmer 1.4s ease-in-out infinite;
}
