/* ═══════════════════════════════════════════════════
   BellyBuster – Stylesheet
   Font: Nunito (body) + Fredoka One (logo/headings)
═══════════════════════════════════════════════════ */

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

:root {
  --orange:    #f97316;
  --orange-d:  #ea6c0a;
  --orange-l:  #fed7aa;
  --green:     #22c55e;
  --red:       #ef4444;
  --blue:      #3b82f6;
  --radius:    14px;
  --radius-sm: 8px;
  --trans:     .18s ease;
  --font:      'Nunito', sans-serif;
  --font-h:    'Fredoka One', cursive;
}

/* Dark theme (default) */
body.dark {
  --bg:        #0f172a;
  --bg2:       #1e293b;
  --bg3:       #334155;
  --text:      #f1f5f9;
  --text2:     #94a3b8;
  --text3:     #64748b;
  --border:    #334155;
  --card:      #1e293b;
  --card2:     #0f172a;
  --shadow:    0 4px 24px rgba(0,0,0,.4);
}

/* Light theme */
body.light {
  --bg:        #f8fafc;
  --bg2:       #ffffff;
  --bg3:       #e2e8f0;
  --text:      #0f172a;
  --text2:     #475569;
  --text3:     #94a3b8;
  --border:    #e2e8f0;
  --card:      #ffffff;
  --card2:     #f1f5f9;
  --shadow:    0 4px 24px rgba(0,0,0,.08);
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Screens ────────────────────────────────────────── */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* ── PIN Screen ─────────────────────────────────────── */
#pin-screen {
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.pin-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
  padding: 2rem 1.5rem;
  max-width: 360px;
  width: 100%;
}
.logo-mark {
  font-size: 3.5rem;
  line-height: 1;
  animation: bounce 1s ease infinite alternate;
}
.logo-mark.sm { font-size: 1.5rem; }
@keyframes bounce { from { transform: translateY(0); } to { transform: translateY(-6px); } }

.logo-text {
  font-family: var(--font-h);
  font-size: 2.4rem;
  color: var(--orange);
  letter-spacing: .5px;
}
.logo-sub { color: var(--text2); font-size: .95rem; }

.pin-dots {
  display: flex;
  gap: 1rem;
  margin: .5rem 0;
}
.dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2.5px solid var(--text3);
  transition: background var(--trans), border-color var(--trans);
}
.dot.filled { background: var(--orange); border-color: var(--orange); }
.dot.wrong { background: var(--red); border-color: var(--red); }

.pin-error {
  font-size: .85rem;
  color: var(--red);
  min-height: 1.2em;
  text-align: center;
}

.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .6rem;
  width: 100%;
  max-width: 280px;
}
.num {
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1.4rem;
  font-family: var(--font);
  font-weight: 700;
  padding: .85rem;
  cursor: pointer;
  transition: background var(--trans), transform .08s;
  -webkit-tap-highlight-color: transparent;
}
.num:active { background: var(--orange); color: #fff; transform: scale(.95); }
.num.del { font-size: 1.2rem; }
.num.ghost { background: transparent; border-color: transparent; pointer-events: none; }

/* ── Setup Screen ───────────────────────────────────── */
#setup-screen {
  align-items: center;
  background: var(--bg);
  padding: 1.5rem 1rem;
  overflow-y: auto;
}
.setup-wrap {
  width: 100%; max-width: 480px;
  display: flex; flex-direction: column;
  align-items: center; gap: .75rem;
}
.setup-step { display: none; flex-direction: column; gap: .75rem; width: 100%; }
.setup-step.active { display: flex; }
.setup-step h2 { font-family: var(--font-h); font-size: 1.6rem; color: var(--orange); }
.setup-step p { color: var(--text2); line-height: 1.6; }

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}
.choice-btn {
  background: var(--bg2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem .75rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .3rem;
  color: var(--text);
  font-family: var(--font);
  transition: border-color var(--trans), background var(--trans);
}
.choice-btn.active {
  border-color: var(--orange);
  background: rgba(249,115,22,.1);
}
.choice-btn .choice-icon { font-size: 1.8rem; }
.choice-btn strong { font-size: .95rem; }
.choice-btn small { font-size: .78rem; color: var(--text2); }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}
.form-field { display: flex; flex-direction: column; gap: .3rem; }
.form-field.full { grid-column: 1/-1; }
.form-field label { font-size: .83rem; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: .04em; }

.big-input, .inp {
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  padding: .7rem .9rem;
  width: 100%;
  transition: border-color var(--trans);
}
.big-input { font-size: 1.1rem; padding: .85rem 1rem; }
.big-input:focus, .inp:focus {
  outline: none;
  border-color: var(--orange);
}
.big-input::placeholder, .inp::placeholder { color: var(--text3); }

select.big-input, select.inp { appearance: none; }

.info-card {
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .85rem 1rem;
  font-size: .9rem;
  color: var(--text2);
  line-height: 1.6;
}

.err-msg { color: var(--red); font-size: .85rem; min-height: 1.2em; }

/* ── Buttons ────────────────────────────────────────── */
.btn-primary {
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 800;
  padding: .75rem 1.4rem;
  cursor: pointer;
  transition: background var(--trans), transform .08s;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary:hover { background: var(--orange-d); }
.btn-primary:active { transform: scale(.97); }
.btn-primary.full { width: 100%; }
.btn-primary.sm { padding: .5rem .9rem; font-size: .88rem; }

.btn-secondary {
  background: var(--bg2);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .95rem;
  font-weight: 700;
  padding: .7rem 1.2rem;
  cursor: pointer;
  transition: background var(--trans);
}
.btn-secondary:hover { background: var(--bg3); }
.btn-secondary.full { width: 100%; }

.btn-danger {
  background: transparent;
  color: var(--text2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .95rem;
  font-weight: 700;
  padding: .7rem 1.2rem;
  cursor: pointer;
}
.btn-danger.full { width: 100%; }

/* ── Top Bar ────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg);
  border-bottom: 1.5px solid var(--border);
  padding: .6rem 1rem;
}
.topbar-left { display: flex; align-items: center; gap: .5rem; }
.brand { font-family: var(--font-h); font-size: 1.3rem; color: var(--orange); }
.topbar-right { display: flex; gap: .3rem; }
.icon-btn {
  background: none; border: none;
  font-size: 1.3rem; cursor: pointer;
  padding: .3rem .4rem; border-radius: 6px;
  transition: background var(--trans);
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { background: var(--bg2); }

/* ── Date Nav ───────────────────────────────────────── */
.date-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: .5rem 1rem;
  background: var(--bg2);
  border-bottom: 1.5px solid var(--border);
}
.date-center { display: flex; align-items: center; gap: .6rem; }
.date-label { font-weight: 700; font-size: .95rem; color: var(--text); }
.today-btn {
  background: var(--orange);
  color: #fff; border: none;
  border-radius: 20px;
  padding: .2rem .7rem;
  font-size: .72rem;
  font-family: var(--font);
  font-weight: 800;
  cursor: pointer;
}
.nav-arrow {
  background: none; border: none;
  color: var(--text2);
  font-size: 1.8rem; cursor: pointer;
  padding: 0 .3rem;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}
.nav-arrow:hover { color: var(--orange); }

/* ── Tabs ────────────────────────────────────────────── */
.tabs {
  display: flex;
  background: var(--bg);
  border-bottom: 1.5px solid var(--border);
  position: sticky; top: 49px; z-index: 40;
}
.tab {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: .15rem;
  background: none; border: none; border-bottom: 3px solid transparent;
  color: var(--text3); font-family: var(--font);
  font-size: .72rem; font-weight: 700;
  padding: .5rem .25rem;
  cursor: pointer;
  transition: color var(--trans), border-color var(--trans);
  -webkit-tap-highlight-color: transparent;
}
.tab span:first-child { font-size: 1.15rem; }
.tab.active { color: var(--orange); border-bottom-color: var(--orange); }

.tab-content { display: none; flex: 1; overflow-y: auto; padding: 1rem; }
.tab-content.active { display: block; }

/* ── Dashboard ──────────────────────────────────────── */
.dash-summary { display: flex; flex-direction: column; gap: .85rem; }

.summary-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.cal-card { border-left: 4px solid var(--orange); }

.sc-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: .25rem; }
.sc-label { font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--text2); }
.sc-target { font-size: .78rem; color: var(--text3); }
.sc-big { font-family: var(--font-h); font-size: 3rem; color: var(--orange); line-height: 1.1; }
.sc-bottom { font-size: .82rem; color: var(--text2); margin-top: .4rem; }

.progress-bar {
  height: 8px;
  background: var(--bg3);
  border-radius: 4px;
  overflow: hidden;
  margin: .5rem 0 .3rem;
}
.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width .4s ease;
  background: var(--orange);
}
.progress-fill.over { background: var(--red); }

.summary-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; }

.mini-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .6rem .5rem;
  text-align: center;
}
.mc-val { font-family: var(--font-h); font-size: 1.15rem; color: var(--text); }
.mc-label { font-size: .65rem; color: var(--text3); font-weight: 700; text-transform: uppercase; margin-top: .2rem; }

.water-card { grid-column: span 1; }
.water-btns { display: flex; justify-content: center; gap: .3rem; margin-top: .35rem; }
.water-btns button {
  background: var(--bg3); border: none;
  border-radius: 4px; color: var(--text);
  font-size: .85rem; font-weight: 700;
  padding: .1rem .4rem; cursor: pointer;
}
.water-btns button:active { background: var(--orange); color: #fff; }

.streak-card .mc-val { font-size: 1rem; }

.weekly-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  font-size: .88rem;
}
.weekly-card h4 { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text2); margin-bottom: .6rem; }
.weekly-row { display: flex; justify-content: space-between; padding: .25rem 0; border-top: 1px solid var(--border); color: var(--text2); }
.weekly-row span:last-child { font-weight: 700; color: var(--text); }
.badge-g { color: var(--green); }
.badge-r { color: var(--red); }
.badge-o { color: var(--orange); }

/* ── Meal Log ───────────────────────────────────────── */
.meal-sections { display: flex; flex-direction: column; gap: .75rem; }

.meal-section {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.meal-header {
  display: flex; align-items: center; gap: .6rem;
  padding: .8rem 1rem;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.meal-header:hover { background: var(--bg3); }
.meal-icon { font-size: 1.3rem; }
.meal-name { flex: 1; font-weight: 800; font-size: .95rem; }
.meal-cals { font-size: .82rem; color: var(--orange); font-weight: 700; }
.meal-chevron { font-size: .8rem; color: var(--text3); transition: transform var(--trans); }
.meal-chevron.open { transform: rotate(180deg); }

.meal-body { display: none; border-top: 1.5px solid var(--border); padding: .5rem; }
.meal-body.open { display: block; }

.meal-items { display: flex; flex-direction: column; gap: .4rem; margin-bottom: .5rem; }
.food-item {
  display: flex; align-items: center;
  background: var(--bg2);
  border-radius: var(--radius-sm);
  padding: .45rem .7rem;
  gap: .6rem;
}
.fi-name { flex: 1; font-size: .88rem; font-weight: 600; }
.fi-meta { font-size: .78rem; color: var(--text2); white-space: nowrap; }
.fi-del {
  background: none; border: none;
  color: var(--text3); cursor: pointer;
  font-size: 1rem; padding: .1rem .3rem;
  border-radius: 4px;
  -webkit-tap-highlight-color: transparent;
}
.fi-del:hover { color: var(--red); background: rgba(239,68,68,.1); }

.add-food-btn {
  width: 100%; background: none;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--orange);
  font-family: var(--font); font-size: .88rem; font-weight: 700;
  padding: .5rem;
  cursor: pointer;
  transition: background var(--trans);
}
.add-food-btn:hover { background: rgba(249,115,22,.07); }

/* ── Weight Tab ─────────────────────────────────────── */
.weight-log-area { display: flex; flex-direction: column; gap: 1rem; }

.weight-input-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.weight-input-card h3 { font-family: var(--font-h); font-size: 1.1rem; color: var(--orange); margin-bottom: .75rem; }
.weight-row { display: flex; align-items: center; gap: .6rem; }
.weight-inp {
  flex: 1;
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text); font-family: var(--font); font-size: 1.1rem;
  padding: .65rem .9rem;
}
.weight-inp:focus { outline: none; border-color: var(--orange); }
.weight-unit { font-weight: 700; color: var(--text2); }

.chart-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.chart-card h3 { font-family: var(--font-h); font-size: 1.05rem; color: var(--text2); margin-bottom: .75rem; }
.chart-card canvas { max-height: 220px; }

/* ── Stats Tab ──────────────────────────────────────── */
.stats-area { display: flex; flex-direction: column; gap: 1rem; }

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}
.stat-item {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .85rem;
}
.stat-val { font-family: var(--font-h); font-size: 1.5rem; color: var(--orange); }
.stat-label { font-size: .75rem; color: var(--text2); font-weight: 700; text-transform: uppercase; margin-top: .15rem; }

/* ── Modals ─────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.6);
  align-items: flex-end;
  padding: 0;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%; max-width: 600px; margin: 0 auto;
  max-height: 92vh; overflow-y: auto;
  padding: 1rem;
  animation: slideUp .22s ease;
}
.modal.sm { border-radius: var(--radius); margin: auto; max-height: 80vh; }

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

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .75rem;
}
.modal-header h3 { font-family: var(--font-h); font-size: 1.2rem; color: var(--orange); }
.modal-close {
  background: none; border: none;
  font-size: 1.2rem; color: var(--text2);
  cursor: pointer; padding: .25rem .4rem;
  border-radius: 6px;
}
.modal-close:hover { background: var(--bg2); color: var(--text); }

.modal-tabs {
  display: flex; gap: .4rem;
  margin-bottom: .85rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.modal-tabs::-webkit-scrollbar { display: none; }
.mtab {
  background: var(--bg2); border: 1.5px solid var(--border);
  border-radius: 20px;
  color: var(--text2); font-family: var(--font);
  font-size: .8rem; font-weight: 700;
  padding: .3rem .85rem; cursor: pointer; white-space: nowrap;
  transition: background var(--trans), color var(--trans), border-color var(--trans);
}
.mtab.active { background: var(--orange); border-color: var(--orange); color: #fff; }

.mtab-content { display: none; flex-direction: column; gap: .75rem; }
.mtab-content.active { display: flex; }

/* Scan */
#scan-viewfinder {
  position: relative;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
  min-height: 200px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
#scanner-container { width: 100%; }
#scanner-container video { width: 100%; display: block; }
.scan-line {
  position: absolute; left: 10%; right: 10%; top: 50%;
  height: 2px; background: var(--orange);
  box-shadow: 0 0 8px var(--orange);
  animation: scanPulse 1.5s ease-in-out infinite alternate;
}
@keyframes scanPulse { from { opacity: .4; } to { opacity: 1; } }
.scan-hint {
  position: absolute; bottom: .75rem;
  color: rgba(255,255,255,.7); font-size: .8rem;
}

.product-confirm-card {
  background: var(--bg2);
  border-radius: var(--radius-sm);
  padding: .85rem;
  border: 1.5px solid var(--border);
}
.pc-name { font-weight: 800; font-size: 1rem; margin-bottom: .2rem; }
.pc-brand { font-size: .82rem; color: var(--text2); margin-bottom: .5rem; }
.pc-macros { display: flex; gap: .75rem; flex-wrap: wrap; }
.pc-macro { font-size: .8rem; color: var(--text3); }
.pc-macro strong { color: var(--text); }
.pc-status { font-size: .75rem; padding: .15rem .5rem; border-radius: 20px; display: inline-block; margin-bottom: .5rem; }
.pc-status.local { background: rgba(34,197,94,.15); color: var(--green); }
.pc-status.off   { background: rgba(59,130,246,.15); color: var(--blue); }
.pc-status.empty { background: rgba(249,115,22,.15); color: var(--orange); }

.product-form { display: flex; flex-direction: column; gap: .6rem; }
.product-form h4 { font-family: var(--font-h); font-size: 1rem; color: var(--text2); }
.save-confirm-row { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--text2); }

/* Search / Results */
.search-row { display: flex; gap: .5rem; }
.search-row .inp { flex: 1; }

.results-list { display: flex; flex-direction: column; gap: .4rem; max-height: 300px; overflow-y: auto; }
.result-item {
  display: flex; align-items: center;
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .6rem .75rem;
  gap: .75rem;
  cursor: pointer;
  transition: background var(--trans);
}
.result-item:hover { background: var(--bg3); border-color: var(--orange); }
.ri-info { flex: 1; }
.ri-name { font-size: .9rem; font-weight: 700; }
.ri-meta { font-size: .75rem; color: var(--text2); margin-top: .1rem; }
.ri-cal { font-family: var(--font-h); font-size: 1rem; color: var(--orange); white-space: nowrap; }
.ri-badge { font-size: .65rem; padding: .1rem .4rem; border-radius: 10px; }
.ri-badge.db { background: rgba(34,197,94,.15); color: var(--green); }
.ri-badge.off { background: rgba(59,130,246,.15); color: var(--blue); }

/* Serving size prompt after search result click */
.serving-prompt { display: flex; flex-direction: column; gap: .75rem; padding: .5rem 0; }
.serving-prompt label { font-size: .85rem; font-weight: 700; color: var(--text2); }

/* Form helpers */
.form-row { display: flex; gap: .6rem; }
.form-row .form-field { flex: 1; }

/* ── Side Panels ────────────────────────────────────── */
.side-panel {
  position: fixed; inset: 0; z-index: 300;
  background: var(--bg);
  transform: translateX(100%);
  transition: transform .25s ease;
  overflow-y: auto;
  display: flex; flex-direction: column;
}
.side-panel.open { transform: translateX(0); }

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem;
  border-bottom: 1.5px solid var(--border);
  position: sticky; top: 0;
  background: var(--bg);
  z-index: 1;
}
.panel-header h3 { font-family: var(--font-h); font-size: 1.3rem; color: var(--orange); }
.panel-body { padding: 1rem; display: flex; flex-direction: column; gap: .5rem; }

.setting-section {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex; flex-direction: column; gap: .6rem;
}
.setting-section h4 { font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--text2); }

.toggle-row {
  display: flex; align-items: center; gap: .75rem;
  font-size: .88rem; color: var(--text2);
}
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--bg3); border-radius: 24px;
  transition: background var(--trans);
}
.slider::before {
  content: ''; position: absolute;
  height: 18px; width: 18px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%;
  transition: transform var(--trans);
}
input:checked + .slider { background: var(--orange); }
input:checked + .slider::before { transform: translateX(20px); }

.data-note { font-size: .78rem; color: var(--text3); line-height: 1.5; }

/* Help body */
.help-body { gap: 0; padding: 0 1rem 2rem; }
.help-section { padding: 1rem 0; border-bottom: 1px solid var(--border); }
.help-section:last-child { border-bottom: none; }
.help-section h4 { font-size: .95rem; font-weight: 800; color: var(--orange); margin-bottom: .4rem; }
.help-section p { font-size: .88rem; color: var(--text2); line-height: 1.65; }
.help-section p + p { margin-top: .5rem; }
.help-section strong { color: var(--text); }

/* ── Toast ───────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 80px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg2); color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: .55rem 1.2rem;
  font-size: .88rem; font-weight: 700;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  z-index: 9999;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Utilities ───────────────────────────────────────── */
.loading {
  text-align: center; color: var(--text3);
  padding: 1.5rem; font-size: .88rem;
}
.empty-state {
  text-align: center; color: var(--text3);
  padding: 2rem 1rem; font-size: .88rem;
}

/* ── Responsive tweaks ───────────────────────────────── */
@media (max-width: 360px) {
  .summary-row { grid-template-columns: repeat(2, 1fr); }
  .sc-big { font-size: 2.4rem; }
  .mc-val { font-size: 1rem; }
}

@media (min-width: 600px) {
  .modal { align-self: center; border-radius: var(--radius); margin: auto; }
  .modal-overlay { align-items: center; padding: 1rem; }
  .side-panel { max-width: 440px; left: auto; right: 0; border-left: 1.5px solid var(--border); }
}

/* ── Food item edit button ──────────────────────────── */
.fi-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  min-width: 0;
}
.fi-main:hover .fi-name { color: var(--orange); }
.fi-edit {
  background: none; border: none;
  font-size: .95rem; padding: .1rem .3rem;
  border-radius: 4px; cursor: pointer;
  color: var(--text3);
  -webkit-tap-highlight-color: transparent;
}
.fi-edit:hover { color: var(--orange); background: rgba(249,115,22,.1); }

/* ── Clickable date label ───────────────────────────── */
.date-clickable {
  cursor: pointer;
  padding: .15rem .4rem;
  border-radius: 6px;
  transition: background var(--trans);
}
.date-clickable:hover { background: var(--bg3); }

/* ── Date picker modal ──────────────────────────────── */
.dp-modal { padding: 1rem; min-width: 300px; }
.dp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
  gap: .5rem;
}
.dp-header span { flex: 1; text-align: center; font-weight: 700; font-size: .95rem; }
.dp-nav {
  background: var(--bg2); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text); font-size: 1.2rem;
  padding: .2rem .6rem; cursor: pointer;
  line-height: 1;
}
.dp-nav:hover { background: var(--bg3); color: var(--orange); }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.cal-hdr {
  text-align: center;
  font-size: .7rem;
  font-weight: 800;
  color: var(--text3);
  padding: .25rem 0;
  text-transform: uppercase;
}
.cal-day {
  position: relative;
  text-align: center;
  padding: .45rem .1rem .3rem;
  border-radius: 6px;
  font-size: .88rem;
  cursor: pointer;
  color: var(--text2);
  transition: background var(--trans), color var(--trans);
  line-height: 1.2;
}
.cal-day:hover:not(.cal-future) { background: var(--bg3); color: var(--text); }
.cal-day.cal-has  { color: var(--text); font-weight: 700; }
.cal-day.cal-today { background: rgba(249,115,22,.15); color: var(--orange); font-weight: 800; }
.cal-day.cal-sel  { background: var(--orange) !important; color: #fff !important; font-weight: 800; border-radius: 6px; }
.cal-day.cal-future { color: var(--text3); cursor: default; opacity: .4; }

.cal-dot {
  display: block;
  width: 4px; height: 4px;
  background: var(--orange);
  border-radius: 50%;
  margin: 2px auto 0;
}
.cal-day.cal-sel .cal-dot { background: rgba(255,255,255,.8); }

/* ── Help warning box ───────────────────────────────── */
.help-warning {
  background: rgba(239,68,68,.08);
  border: 2px solid var(--red) !important;
  border-radius: var(--radius-sm);
  padding: 1rem !important;
  margin-bottom: .5rem;
}
.help-warning h4 { color: var(--red) !important; font-size: 1rem !important; }
.help-warning p { color: var(--text) !important; }

/* ── Barcode display in product card ─────────────── */
.pc-barcode {
  font-size: .72rem;
  color: var(--text3);
  margin-top: .4rem;
  font-family: var(--font);
  letter-spacing: .03em;
}
.pc-barcode strong { color: var(--text2); font-family: monospace; }

/* ── Stats range buttons ─────────────────────────── */
.stats-range-btns {
  display: flex;
  gap: .4rem;
  margin-bottom: .75rem;
  flex-wrap: wrap;
}
.range-btn {
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  color: var(--text2);
  font-family: var(--font);
  font-size: .8rem;
  font-weight: 700;
  padding: .3rem .85rem;
  cursor: pointer;
  transition: background var(--trans), color var(--trans), border-color var(--trans);
}
.range-btn.active {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
}

/* ── Goal celebration animation ─────────────────── */
@keyframes celebPop {
  0%   { transform: scale(0.7); opacity: 0; }
  70%  { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

/* ── Trend info card (weight tab + dashboard) ─────── */
.trend-info-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  margin-top: .75rem;
}
.trend-info-card h4 {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text2);
  font-weight: 800;
  margin-bottom: .5rem;
}
.ti-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .28rem 0;
  border-top: 1px solid var(--border);
  font-size: .84rem;
  color: var(--text2);
}
.ti-row:first-of-type { border-top: none; }
.ti-row span:last-child { font-weight: 700; color: var(--text); }

/* ── Goal tab ─────────────────────────────────────── */
.goal-section {
  margin-bottom: 1rem;
}
.goal-section-title {
  font-family: var(--font-h);
  font-size: 1rem;
  color: var(--text2);
  margin-bottom: .6rem;
}
.goal-header-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: .85rem 1rem;
}
.gh-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .25rem 0;
  border-top: 1px solid var(--border);
  font-size: .87rem;
  color: var(--text2);
}
.gh-row:first-child { border-top: none; }
.gh-row strong { color: var(--text); }

.intensity-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.intensity-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  cursor: pointer;
  transition: border-color var(--trans), background var(--trans);
  -webkit-tap-highlight-color: transparent;
}
.intensity-card:hover { border-color: var(--orange); }
.intensity-card.active {
  border-color: var(--orange);
  background: rgba(249,115,22,.07);
}
.ic-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .35rem;
}
.ic-emoji { font-size: 1.3rem; }
.ic-label {
  font-weight: 800;
  font-size: .95rem;
  color: var(--text);
  flex: 1;
}
.ic-active-badge {
  background: var(--orange);
  color: #fff;
  font-size: .65rem;
  font-weight: 800;
  padding: .15rem .5rem;
  border-radius: 20px;
  text-transform: uppercase;
}
.ic-stats {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem .75rem;
  font-size: .8rem;
  color: var(--text3);
}
.ic-target { color: var(--orange); font-weight: 700; }
.ic-date   { color: var(--green);  font-weight: 700; }

.custom-goal-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  transition: border-color var(--trans);
}
.custom-goal-card.active { border-color: var(--orange); background: rgba(249,115,22,.07); }
.custom-goal-card label { font-size: .9rem; color: var(--text2); font-weight: 600; }
.custom-goal-card label strong { color: var(--orange); }

.goal-slider {
  width: 100%;
  accent-color: var(--orange);
  height: 6px;
  cursor: pointer;
}
.custom-goal-stats {
  background: var(--bg2);
  border-radius: var(--radius-sm);
  padding: .5rem .75rem;
}

/* ── About section ───────────────────────────────── */
.about-section h4 { color: var(--orange); }

.about-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .3rem 0;
  border-top: 1px solid var(--border);
  font-size: .87rem;
  color: var(--text2);
}
.about-row:first-of-type { border-top: none; }
.about-val { font-weight: 700; color: var(--text); }
.about-link {
  color: var(--orange);
  font-weight: 700;
  text-decoration: none;
  font-size: .87rem;
}
.about-link:hover { text-decoration: underline; }

.bmc-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  background: #FFDD00;
  color: #000;
  border-radius: 10px;
  padding: .65rem 1rem;
  font-weight: 800;
  font-size: .95rem;
  font-family: var(--font);
  text-decoration: none;
  margin-top: .75rem;
  transition: opacity var(--trans), transform .08s;
  -webkit-tap-highlight-color: transparent;
}
.bmc-btn:hover { opacity: .9; }
.bmc-btn:active { transform: scale(.97); }

/* ── Entry mode toggle ───────────────────────────── */
.entry-mode-toggle {
  display: flex;
  gap: .4rem;
  margin-bottom: .6rem;
}
.emt-btn {
  flex: 1;
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  color: var(--text2);
  font-family: var(--font);
  font-size: .8rem;
  font-weight: 700;
  padding: .35rem .5rem;
  cursor: pointer;
  transition: background var(--trans), color var(--trans), border-color var(--trans);
}
.emt-btn.active {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
}

/* ── Calculated result bar ───────────────────────── */
.calc-result-bar {
  background: rgba(249,115,22,.1);
  border: 1.5px solid rgba(249,115,22,.3);
  border-radius: var(--radius-sm);
  padding: .5rem .75rem;
  font-size: .85rem;
  color: var(--text2);
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
}
.calc-result-bar strong { color: var(--orange); font-size: 1rem; }

/* ── Library match suggestion ────────────────────── */
.library-match-card {
  background: var(--bg2);
  border: 1.5px solid var(--orange);
  border-radius: var(--radius-sm);
  padding: .5rem .75rem;
  font-size: .83rem;
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .5rem;
}
.library-match-card strong { color: var(--text); }
.library-match-card button {
  background: var(--orange);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-family: var(--font);
  font-size: .78rem;
  font-weight: 800;
  padding: .25rem .65rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}