/* ── Nourish — Soft Warm Earthy Theme ── */

:root {
  --bg:          #f5f0e8;
  --bg2:         #ede7da;
  --card:        #faf7f2;
  --card2:       #f0ebe0;
  --text:        #2c2416;
  --text2:       #7a6a52;
  --text3:       #b0a08a;
  --border:      rgba(120,90,50,0.12);
  --border2:     rgba(120,90,50,0.22);
  --eaten:       #c45c2a;
  --eaten-light: #faf0ea;
  --burned:      #3a7d5e;
  --burned-light:#eaf4ef;
  --goal:        #6b5b3e;
  --accent:      #c45c2a;
  --radius-sm:   10px;
  --radius-md:   16px;
  --radius-lg:   22px;
  --safe-top:    env(safe-area-inset-top, 44px);
  --safe-bottom: env(safe-area-inset-bottom, 20px);
  --font-serif:  'Lora', Georgia, serif;
  --font-sans:   'Nunito', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { height: -webkit-fill-available; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }

/* ── App shell ── */
.app {
  max-width: 430px;
  margin: 0 auto;
}

/* ── Header ── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  padding-top: calc(var(--safe-top) + 8px);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}
.app-title {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 26px;
  font-weight: 400;
  color: var(--text);
  letter-spacing: -0.3px;
  line-height: 1;
}
.date-label {
  font-size: 12px;
  color: var(--text3);
  font-weight: 400;
  margin-top: 2px;
}

/* ── Nav ── */
.top-nav {
  display: flex;
  gap: 4px;
}
.nav-btn {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text3);
  transition: all 0.15s;
}
.nav-btn.active {
  background: var(--card2);
  color: var(--accent);
}
.nav-btn:hover { color: var(--text); }

/* ── Main content ── */
.main {
  padding: 18px 16px calc(var(--safe-bottom) + 32px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Ring card ── */
.ring-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 22px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.ring-wrap {
  position: relative;
  width: 130px;
  height: 130px;
  flex-shrink: 0;
}
.ring-svg {
  width: 130px;
  height: 130px;
  transform: rotate(-90deg);
}
.ring-bg {
  fill: none;
  stroke: var(--bg2);
  stroke-width: 10;
}
.ring-fill {
  fill: none;
  stroke: var(--eaten);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.55s cubic-bezier(.4,0,.2,1), stroke 0.3s;
}
.ring-fill.over { stroke: #c0392b; }
.ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
}
.ring-num {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 500;
  color: var(--text);
  line-height: 1;
  transition: color 0.3s;
}
.ring-num.over { color: #c0392b; }
.ring-label {
  font-size: 11px;
  color: var(--text3);
  margin-top: 3px;
  font-weight: 400;
}
.ring-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.ring-stat {
  display: flex;
  flex-direction: column;
  padding: 6px 0;
}
.rs-val {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 500;
  line-height: 1.1;
}
.rs-val.eaten  { color: var(--eaten); }
.rs-val.burned { color: var(--burned); }
.rs-val.goal   { color: var(--goal); }
.rs-lbl {
  font-size: 11px;
  color: var(--text3);
  font-weight: 400;
}
.ring-divider {
  height: 1px;
  background: var(--border);
  margin: 2px 0;
}
.goal-edit-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.goal-edit-label {
  font-size: 11px;
  color: var(--text3);
  display: block;
  margin-bottom: 5px;
}
.goal-edit-wrap {
  display: flex;
  gap: 6px;
  align-items: center;
}
.goal-input {
  width: 70px;
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 6px 8px;
  font-family: var(--font-sans);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  text-align: center;
  -webkit-appearance: none;
}
.goal-input:focus { border-color: var(--eaten); background: #fff; }
.goal-save-btn {
  padding: 6px 12px;
  border-radius: 8px;
  border: none;
  background: var(--eaten);
  color: white;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.1s;
}
.goal-save-btn:active { transform: scale(0.94); opacity: 0.85; }

/* ── Section ── */
.section {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 18px;
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.section-total { font-size: 14px; font-weight: 600; }
.section-link { font-size: 12px; color: var(--accent); font-weight: 500; }
.eaten-color { color: var(--eaten); }
.burned-color { color: var(--burned); }

/* ── Quick chips ── */
.quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.quick-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--eaten-light);
  border: 1px solid rgba(196,92,42,0.18);
  border-radius: 99px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--eaten);
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}
.quick-chip:active { transform: scale(0.95); background: #f5ddd0; }
.quick-chip .chip-cal {
  font-size: 11px;
  opacity: 0.7;
  font-weight: 400;
}
.no-presets-hint {
  font-size: 13px;
  color: var(--text3);
  font-style: italic;
}

/* ── Add row ── */
.add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: flex-end;
}
.add-inputs {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.text-input, .num-input {
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-family: var(--font-sans);
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  width: 100%;
  -webkit-appearance: none;
  transition: border-color 0.15s, background 0.15s;
}
.text-input:focus, .num-input:focus {
  border-color: var(--accent);
  background: white;
}
.text-input::placeholder, .num-input::placeholder { color: var(--text3); }
.num-input { text-align: left; }

.add-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.1s, opacity 0.1s;
  align-self: flex-end;
}
.add-btn:active { transform: scale(0.91); opacity: 0.8; }
.food-add-btn { background: var(--eaten); color: white; }
.ex-add-btn   { background: var(--burned); color: white; }

/* ── Search ── */
.search-wrap { margin-bottom: 10px; }
.search-input {
  width: 100%;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 8px 13px;
  font-family: var(--font-sans);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  -webkit-appearance: none;
}
.search-input:focus { border-color: var(--accent); background: white; }

/* ── Log list ── */
.log-list { list-style: none; }
.log-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 0;
  border-top: 1px solid var(--border);
  animation: fadeSlide 0.2s ease;
}
.log-item:first-child { border-top: none; }
@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(-5px); }
  to   { opacity: 1; transform: translateY(0); }
}
.log-name {
  font-size: 15px;
  color: var(--text);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 8px;
}
.log-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.log-cal { font-size: 14px; font-weight: 600; }
.log-cal.f { color: var(--eaten); }
.log-cal.e { color: var(--burned); }
.del-btn {
  width: 26px; height: 26px;
  border-radius: 7px;
  border: none;
  background: var(--bg2);
  color: var(--text3);
  font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.12s;
  flex-shrink: 0;
}
.del-btn:active { background: #fde8e8; color: #c0392b; }
.log-empty {
  font-size: 14px;
  color: var(--text3);
  text-align: center;
  padding: 10px 0 4px;
  font-style: italic;
}

/* ── Reset ── */
.reset-btn {
  width: 100%;
  padding: 13px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--border2);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text3);
  cursor: pointer;
  transition: all 0.15s;
}
.reset-btn:active { border-color: #c0392b; color: #c0392b; background: #fdf5f5; }

/* ── Week page ── */
.week-summary-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.week-stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 10px;
  text-align: center;
}
.wsc-val {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  line-height: 1;
}
.wsc-lbl {
  font-size: 11px;
  color: var(--text3);
  margin-top: 4px;
}
.chart-legend { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text3); }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.eaten-bg { background: var(--eaten); }
.burned-bg { background: var(--burned); }
.legend-txt { font-size: 12px; color: var(--text3); }

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 120px;
  padding-top: 10px;
}
.bar-day {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  height: 100%;
  justify-content: flex-end;
}
.bar-col {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  justify-content: flex-end;
  flex: 1;
}
.bar-eaten {
  width: 100%;
  background: var(--eaten);
  border-radius: 5px 5px 0 0;
  min-height: 2px;
  transition: height 0.4s ease;
  opacity: 0.85;
}
.bar-burned {
  width: 100%;
  background: var(--burned);
  border-radius: 5px 5px 0 0;
  min-height: 2px;
  transition: height 0.4s ease;
  opacity: 0.8;
}
.bar-day-lbl {
  font-size: 11px;
  color: var(--text3);
  font-weight: 500;
  flex-shrink: 0;
}
.bar-day.today .bar-day-lbl { color: var(--accent); font-weight: 600; }

.day-row {
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.day-row:first-child { border-top: none; }
.day-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.day-row-name { font-size: 14px; font-weight: 600; color: var(--text); }
.day-row-name.today { color: var(--accent); }
.day-row-net { font-size: 13px; color: var(--text3); }
.day-mini-bar {
  height: 5px;
  background: var(--bg2);
  border-radius: 99px;
  overflow: hidden;
}
.day-mini-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--eaten);
  transition: width 0.4s ease;
}
.day-mini-fill.over { background: #c0392b; }
.day-row-stats {
  display: flex;
  gap: 12px;
  margin-top: 5px;
  font-size: 12px;
  color: var(--text3);
}
.day-row-stats span b { font-weight: 600; }
.no-data-week {
  text-align: center;
  padding: 24px 0;
  font-size: 14px;
  color: var(--text3);
  font-style: italic;
}

/* ── Presets page ── */
.common-foods-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.common-food-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  cursor: pointer;
  transition: all 0.12s;
  font-family: var(--font-sans);
  text-align: left;
  gap: 4px;
}
.common-food-btn:active { background: var(--eaten-light); border-color: rgba(196,92,42,0.25); }
.cfb-name { font-size: 13px; font-weight: 500; color: var(--text); }
.cfb-cal { font-size: 12px; color: var(--text3); white-space: nowrap; }

.preset-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.preset-add-btn {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(196,92,42,0.3);
  background: var(--eaten-light);
  color: var(--eaten);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}
.preset-add-btn:active { background: #f0c5ae; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: 99px;
  white-space: nowrap;
  transition: transform 0.25s cubic-bezier(.2,.8,.2,1), opacity 0.25s;
  opacity: 0;
  z-index: 999;
  pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ── Utility ── */
.hidden { display: none !important; }

/* ── Weight page ── */
.weight-color { color: #8b6a3e; }

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

.weight-log-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.weight-big-input {
  flex: 1;
  font-size: 22px !important;
  font-family: var(--font-serif) !important;
  font-weight: 500;
  text-align: left;
  padding: 10px 14px !important;
}
.weight-unit-label {
  font-size: 15px;
  color: var(--text3);
  font-weight: 500;
  flex-shrink: 0;
  min-width: 28px;
}
.weight-add-btn { background: #8b6a3e; color: white; }

.weight-today-note {
  font-size: 13px;
  color: var(--text3);
  font-style: italic;
  min-height: 18px;
}

.weight-chart-wrap {
  position: relative;
  width: 100%;
  height: 220px;
}

.chart-range-btns {
  display: flex;
  gap: 4px;
}
.range-btn {
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid var(--border2);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--text3);
  cursor: pointer;
  transition: all 0.12s;
}
.range-btn.active {
  background: var(--card2);
  color: var(--goal);
  border-color: rgba(107,91,62,0.3);
}

.weight-diff {
  font-size: 12px;
  font-weight: 600;
  min-width: 36px;
  text-align: right;
}

/* ── Meal groups & add form ── */
.add-inputs-row2 {
  display: flex;
  gap: 6px;
}
.meal-select {
  flex: 1;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 10px 10px;
  font-family: var(--font-sans);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23b0a08a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}
.meal-select:focus { border-color: var(--accent); background-color: white; }

.section-right-row { display: flex; align-items: center; }

.log-name-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  padding-right: 6px;
}
.log-meal-badge {
  font-size: 11px;
  color: var(--text3);
  font-weight: 500;
  margin-top: 1px;
}
.meal-edit-hint {
  color: var(--text3);
  display: flex;
  align-items: center;
  opacity: 0.6;
}

/* ── Edit modal ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(44, 36, 22, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
  padding-bottom: var(--safe-bottom);
}
.modal-card {
  background: var(--card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 430px;
  padding: 0 0 8px;
  animation: slideUp 0.22s cubic-bezier(.2,.8,.2,1);
}
@keyframes slideUp {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.modal-close {
  width: 30px; height: 30px;
  border: none; background: var(--bg2);
  border-radius: 50%;
  font-size: 14px; color: var(--text3);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.modal-body {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
}
.modal-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 5px;
}
.modal-footer {
  display: flex;
  gap: 10px;
  padding: 4px 20px 10px;
}
.modal-save-btn {
  flex: 1;
  padding: 13px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--eaten);
  color: white;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.1s;
}
.modal-save-btn:active { opacity: 0.85; }
.modal-delete-btn {
  padding: 13px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border2);
  background: transparent;
  color: #c0392b;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.1s;
}
.modal-delete-btn:active { background: #fdf5f5; }

/* ── Meals breakdown page ── */
.meals-banner {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  padding: 16px 20px;
}
.meals-banner-item {
  flex: 1;
  text-align: center;
}
.mb-val {
  display: block;
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  line-height: 1;
}
.mb-lbl {
  display: block;
  font-size: 11px;
  color: var(--text3);
  margin-top: 3px;
}
.meals-banner-divider {
  width: 1px;
  height: 36px;
  background: var(--border);
  margin: 0 4px;
}

.meal-section { padding-bottom: 4px; }
.meal-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.meal-section-left { display: flex; align-items: center; gap: 8px; }
.meal-emoji { font-size: 16px; line-height: 1; }
.meal-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.meal-section-right { display: flex; align-items: center; gap: 8px; }
.meal-subtotal { font-size: 14px; font-weight: 600; color: var(--eaten); }
.meal-pct { font-size: 12px; color: var(--text3); }

.meal-bar-wrap {
  height: 4px;
  background: var(--bg2);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 10px;
}
.meal-bar-fill {
  height: 100%;
  background: var(--eaten);
  border-radius: 99px;
  transition: width 0.4s ease;
  opacity: 0.7;
}

.meal-log-item { cursor: pointer; }
.meal-log-item:active { background: var(--bg); border-radius: 8px; }

.meals-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text3);
  font-size: 15px;
  font-style: italic;
}
.meals-empty-link {
  display: inline-block;
  margin-top: 12px;
  font-size: 14px;
  font-style: normal;
  color: var(--accent);
  font-weight: 500;
}

/* ── Shared Food Modal extras ── */
.fm-row {
  display: flex;
  gap: 10px;
}
.fm-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.fm-serving-wrap {
  display: flex;
  gap: 5px;
}
.fm-unit-select {
  width: 72px !important;
  flex-shrink: 0;
  font-size: 13px !important;
  padding-left: 6px !important;
  padding-right: 20px !important;
}
.fm-calc-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--eaten-light);
  border: 1px solid rgba(196,92,42,0.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-top: 12px;
}
.fm-preview-label { font-size: 13px; color: var(--text2); }
.fm-preview-val   { font-size: 18px; font-weight: 600; color: var(--eaten); font-family: var(--font-serif); }
.fm-manual-row { margin-top: 12px; display: flex; flex-direction: column; }

/* Food log item serving detail */
.log-serving-detail {
  font-size: 11px;
  color: var(--text3);
  margin-top: 1px;
}

/* Barcode nav button pulse when scanning available */
.nav-btn.scan-btn { position: relative; }

/* ── Add food trigger button ── */
.add-food-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  border: 1.5px dashed var(--border2);
  background: var(--bg);
  color: var(--text2);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 12px;
  transition: all 0.15s;
}
.add-food-trigger:active { background: var(--eaten-light); border-color: var(--eaten); color: var(--eaten); }

/* ════════════════════════════════════
   Floating Save Button
   ════════════════════════════════════ */
.float-save-btn {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 20px) + 18px);
  right: 18px;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 99px;
  padding: 11px 18px 11px 14px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(44,36,22,0.22);
  transition: transform 0.15s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.float-save-btn:active { transform: scale(0.94); }
.float-save-btn.fsb-saved { background: var(--burned); }
.fsb-label { letter-spacing: 0.01em; }

/* Hide float btn on backup page (redundant there) */
.backup-page .float-save-btn { display: none; }

/* ════════════════════════════════════
   Backup Reminder Banner
   ════════════════════════════════════ */
.backup-reminder-banner {
  background: #fdf6e8;
  border: 1px solid rgba(232,160,32,0.3);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transform-origin: top;
  transition: opacity 0.3s, transform 0.3s;
}
.brb-left { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brb-icon { font-size: 20px; flex-shrink: 0; }
.brb-text { display: flex; flex-direction: column; min-width: 0; }
.brb-title { font-size: 13px; font-weight: 600; color: #7a5a10; }
.brb-sub   { font-size: 12px; color: #a07820; line-height: 1.4; margin-top: 1px; }
.brb-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.brb-save-btn {
  padding: 7px 13px;
  border-radius: 8px;
  border: none;
  background: #e8a020;
  color: white;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.12s;
}
.brb-save-btn:active { opacity: 0.8; }
.brb-dismiss {
  width: 28px; height: 28px;
  border-radius: 7px;
  border: none;
  background: rgba(232,160,32,0.15);
  color: #a07820;
  font-size: 14px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ════════════════════════════════════
   Backup Page
   ════════════════════════════════════ */
.backup-status-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--card);
  transition: background 0.2s;
}
.backup-status-card.bsc-good { background: var(--burned-light); border-color: rgba(58,125,94,0.2); }
.backup-status-card.bsc-warn { background: #fdf6e8; border-color: rgba(232,160,32,0.25); }
.bsc-icon { font-size: 28px; flex-shrink: 0; }
.bsc-title { font-size: 15px; font-weight: 600; color: var(--text); }
.bsc-sub   { font-size: 13px; color: var(--text3); margin-top: 2px; }

.backup-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 10px;
}
.bstat {
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 12px 10px;
  text-align: center;
}
.bstat-val { font-family: var(--font-serif); font-size: 20px; font-weight: 500; color: var(--text); }
.bstat-lbl { font-size: 11px; color: var(--text3); margin-top: 3px; }

.backup-desc {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.6;
  margin-bottom: 14px;
}
.backup-desc code   { font-family: var(--font-mono, monospace); font-size: 13px; background: var(--bg2); padding: 1px 5px; border-radius: 4px; }
.backup-desc strong { font-weight: 600; color: var(--text); }

.backup-action-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  font-family: var(--font-sans);
  text-align: left;
  transition: background 0.12s, border-color 0.12s;
  text-decoration: none;
  color: inherit;
}
.backup-action-btn.primary { border-color: rgba(196,92,42,0.3); background: var(--eaten-light); }
.backup-action-btn:active  { background: var(--bg2); }
.backup-action-btn.primary:active { background: #f5ddd0; }

.bab-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius-sm);
  background: var(--eaten-light);
  color: var(--eaten);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.bab-text { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.bab-label { font-size: 15px; font-weight: 600; color: var(--text); }
.bab-sub   { font-size: 12px; color: var(--text3); }

.restore-result {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
}
.restore-result.success { background: var(--burned-light); color: var(--burned); border: 1px solid rgba(58,125,94,0.2); }
.restore-result.error   { background: #fdf0ee; color: var(--eaten); border: 1px solid rgba(196,92,42,0.2); }

.backup-danger-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(192,57,43,0.25);
  background: transparent;
  color: #c0392b;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s;
}
.backup-danger-btn:active { background: #fdf5f5; }

/* ════════════════════════════════════
   Scanner overlay (embedded in scan page)
   ════════════════════════════════════ */
.scan-launch-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-lg);
  border: none;
  background: var(--text);
  color: var(--bg);
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  margin-bottom: 14px;
}
.scan-launch-btn:active { opacity: 0.85; }

.scanner-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: #0f0c08;
  display: flex;
  flex-direction: column;
}
.scanner-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top,44px) + 10px) 20px 14px;
  flex-shrink: 0;
}
.scanner-overlay-title {
  font-family: 'Lora', serif;
  font-style: italic;
  font-size: 18px;
  color: #f5f0e8;
}
.scanner-overlay-close {
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.2);
  background: transparent;
  color: #f5f0e8;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.scanner-vf {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #000;
}
.scanner-vf video {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
}
.scanner-vf canvas { display: none !important; }
.scan-overlay-frame {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -55%);
  width: 260px; height: 170px;
  z-index: 2;
  pointer-events: none;
}
.scan-status-pill {
  position: absolute;
  top: 16px; left: 50%;
  transform: translateX(-50%);
  background: rgba(15,12,8,0.88);
  color: #f5f0e8;
  font-size: 13px;
  font-family: var(--font-sans);
  padding: 8px 18px;
  border-radius: 99px;
  white-space: nowrap;
  z-index: 4;
  border: 1px solid rgba(196,92,42,0.4);
}

/* ════════════════════════════════════
   Meal add button
   ════════════════════════════════════ */
.meal-add-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border2);
  background: var(--bg);
  color: var(--text2);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
}
.meal-add-btn:active { background: var(--eaten-light); color: var(--eaten); border-color: rgba(196,92,42,0.3); }
.meal-empty-slot { color: var(--text3); font-style: italic; font-size: 13px; }

/* ════════════════════════════════════
   Activity page
   ════════════════════════════════════ */
.activity-summary-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 0;
}
.act-stat { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.act-val  { font-family: var(--font-serif); font-size: 32px; font-weight: 500; color: var(--text); }
.act-val.burned-color { color: var(--burned); }
.act-lbl  { font-size: 12px; color: var(--text3); }

/* ════════════════════════════════════
   Section link card
   ════════════════════════════════════ */
.section-link-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 14px;
  font-weight: 500;
  color: var(--text2);
  text-decoration: none;
  transition: background 0.12s;
}
.section-link-card:active { background: var(--bg2); }

/* ════════════════════════════════════
   Nav — tighter for 5 items
   ════════════════════════════════════ */
.top-nav { gap: 2px; }
.nav-btn { width: 36px; height: 36px; }

/* ════════════════════════════════════
   Scan processing state
   ════════════════════════════════════ */
.scan-processing {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 14px;
}
.scan-processing-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text2);
}
.scan-spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border2);
  border-top-color: var(--eaten);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Scan tips */
.scan-tips {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text3);
  padding: 0 4px 14px;
}

/* ════════════════════════════════════
   Scan Result Sheet
   ════════════════════════════════════ */
.scan-sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(44,36,22,0.45);
  z-index: 400;
}
.scan-sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: 430px;
  margin: 0 auto;
  background: var(--card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  z-index: 401;
  display: flex;
  flex-direction: column;
  max-height: 92vh;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(.2,.8,.2,1);
  padding-bottom: env(safe-area-inset-bottom, 16px);
}
.scan-sheet.open { transform: translateY(0); }

.scan-sheet-handle {
  width: 36px; height: 4px;
  background: var(--border2);
  border-radius: 99px;
  margin: 12px auto 0;
  flex-shrink: 0;
}
.scan-sheet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 20px 10px;
  flex-shrink: 0;
}
.scan-sheet-eyebrow {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.scan-sheet-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--burned);
  background: var(--burned-light);
  border-radius: 99px;
  padding: 3px 9px;
  margin-top: 4px;
}
.scan-sheet-dismiss {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--bg2);
  color: var(--text3);
  font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

.scan-sheet-body {
  padding: 0 20px 14px;
  overflow-y: auto;
  flex: 1;
}
.ssi-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 5px;
  margin-top: 12px;
}
.ssi-input { margin-bottom: 0; }
.ssi-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.ssi-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ssi-unit-row { display: flex; gap: 5px; }
.ssi-unit-sel { width: 68px !important; flex-shrink: 0; font-size: 13px !important; }

.ssi-calc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--eaten-light);
  border: 1px solid rgba(196,92,42,0.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-top: 12px;
}
.ssi-calc-label { font-size: 13px; color: var(--text2); }
.ssi-calc-val   { font-size: 18px; font-weight: 600; color: var(--eaten); font-family: var(--font-serif); }

.scan-sheet-actions {
  flex-shrink: 0;
  padding: 10px 20px 14px;
  border-top: 1px solid var(--border);
}
.scan-sheet-meal-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.scan-sheet-meal-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
}
.ss-meal-chip {
  padding: 5px 12px;
  border-radius: 99px;
  border: 1px solid var(--border2);
  background: var(--bg);
  color: var(--text2);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}
.ss-meal-chip.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.scan-sheet-btns {
  display: flex;
  gap: 10px;
}
.ss-btn-primary {
  flex: 1;
  padding: 14px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--eaten);
  color: white;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.12s;
}
.ss-btn-primary:active { opacity: 0.85; }
.ss-btn-secondary {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text2);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s;
}
.ss-btn-secondary:active { background: var(--bg2); }

/* ════════════════════════════════════
   Home inline save button
   ════════════════════════════════════ */
.home-save-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  border: 1.5px solid;
  background: transparent;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  text-align: left;
}
.home-save-btn:active { transform: scale(0.98); opacity: 0.85; }

/* Label + sub */
.home-save-btn span:nth-child(2) {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
}
.hsb-sub {
  font-size: 12px !important;
  font-weight: 400 !important;
  opacity: 0.75;
}

/* Green — all good */
.hsb-green {
  border-color: rgba(58,125,94,0.35);
  background: var(--burned-light);
  color: var(--burned);
}
/* Yellow — changes not backed up */
.hsb-yellow {
  border-color: rgba(200,160,0,0.35);
  background: #fefae8;
  color: #856a00;
}
/* Orange — over 24h or never */
.hsb-orange {
  border-color: rgba(196,92,42,0.35);
  background: var(--eaten-light);
  color: var(--eaten);
}
/* Saved flash */
.hsb-saved {
  border-color: rgba(58,125,94,0.5);
  background: var(--burned-light);
  color: var(--burned);
}

/* Remove old float btn styles that are no longer needed */
.float-save-btn { display: none !important; }

/* ── Scan sheet barcode row ── */
.ssi-barcode-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.ssi-lookup-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background: var(--bg);
  color: var(--text2);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.12s;
}
.ssi-lookup-btn:active { background: var(--eaten-light); color: var(--eaten); border-color: rgba(196,92,42,0.3); }

.ssi-lookup-status {
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  margin-top: 6px;
}
.ssi-lookup-status.looking { background: var(--bg2);          color: var(--text3); }
.ssi-lookup-status.found   { background: var(--burned-light); color: var(--burned); }
.ssi-lookup-status.miss    { background: var(--eaten-light);  color: var(--eaten); }
