*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green: #27AE60;
  --green-light: #D5F5E3;
  --orange: #E67E22;
  --red: #E74C3C;
  --blue: #2980B9;
  --purple: #8E44AD;
  --teal: #16A085;
  --bg: #F4F6F9;
  --card: #FFFFFF;
  --text: #1A1A2E;
  --text-muted: #7F8C8D;
  --border: #E8ECEF;
  --radius: 14px;
  --shadow: 0 2px 12px rgba(0,0,0,0.07);
  --input-bg: #FAFBFC;
  --input-bg-focus: #FFFFFF;
  --success-bg: #D5F5E3;
  --success-text: #1E8449;
  --error-bg: #FADBD8;
  --error-text: #A93226;
  --danger-hover-bg: #FFEBEE;
  --media-bg: #000000;
  --shell-width: 480px;
}

/* Dark theme — explicit choice (data-theme="dark") or system preference when
   no explicit choice has been made (data-theme absent/"system"). */
:root[data-theme="dark"] {
  --green: #2ECC71;
  --green-light: rgba(46,204,113,0.16);
  --orange: #F39C12;
  --red: #FF6B6B;
  --blue: #5DADE2;
  --purple: #BB8FCE;
  --teal: #48C9B0;
  --bg: #0D0D0F;
  --card: #1C1C1F;
  --text: #F2F2F5;
  --text-muted: #9A9AA3;
  --border: #2E2E32;
  --shadow: 0 2px 12px rgba(0,0,0,0.45);
  --input-bg: #17171A;
  --input-bg-focus: #202024;
  --success-bg: rgba(46,204,113,0.16);
  --success-text: #4EE38A;
  --error-bg: rgba(255,107,107,0.16);
  --error-text: #FF8A8A;
  --danger-hover-bg: rgba(255,107,107,0.16);
  --media-bg: #000000;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --green: #2ECC71;
    --green-light: rgba(46,204,113,0.16);
    --orange: #F39C12;
    --red: #FF6B6B;
    --blue: #5DADE2;
    --purple: #BB8FCE;
    --teal: #48C9B0;
    --bg: #0D0D0F;
    --card: #1C1C1F;
    --text: #F2F2F5;
    --text-muted: #9A9AA3;
    --border: #2E2E32;
    --shadow: 0 2px 12px rgba(0,0,0,0.45);
    --input-bg: #17171A;
    --input-bg-focus: #202024;
    --success-bg: rgba(46,204,113,0.16);
    --success-text: #4EE38A;
    --error-bg: rgba(255,107,107,0.16);
    --error-text: #FF8A8A;
    --danger-hover-bg: rgba(255,107,107,0.16);
    --media-bg: #000000;
    color-scheme: dark;
  }
}

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  max-width: var(--shell-width);
  margin: 0 auto;
}

/* Phone-width layout stays exactly as-is below this point (matches the
   deployed Airtable app pixel-for-pixel) — these breakpoints only widen the
   centered column on larger screens so tablet/desktop aren't stuck with a
   480px island in an otherwise empty viewport. Single-column structure is
   unchanged throughout; only the available width grows. body and
   .bottom-nav both read --shell-width so they can never drift apart. */
@media (min-width: 640px) {
  :root { --shell-width: 620px; }
}
@media (min-width: 900px) {
  :root { --shell-width: 760px; }
  html { font-size: 17px; }
}
@media (min-width: 1280px) {
  :root { --shell-width: 900px; }
}

.hidden { display: none !important; }

/* ── Overlay / Setup Modal ─────────────────────────────────────────────────── */

.overlay {
  position: fixed; inset: 0; z-index: 200;
  background: linear-gradient(135deg, #1a2a1a 0%, #2d4a2d 100%);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 1.5rem 1rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Can be opened on top of another overlay (e.g. scanning a barcode from
   inside the Add Staple modal) — always wins the stacking order. */
#barcode-modal { z-index: 210; }

.modal {
  background: var(--card);
  border-radius: var(--radius);
  padding: 2rem 1.5rem 1.5rem;
  width: 100%; max-width: 400px;
  margin: auto;
}

.modal-logo { text-align: center; margin-bottom: 0.75rem; }
/* Fixed box + object-fit:contain (not height:Npx;width:auto) — the 4
   language variants have different aspect ratios (translated wordmarks
   vary in length), so scaling by height alone gave each one a different
   final width. A shared box makes every language render at the same size. */
.modal-logo img { width: 190px; height: 56px; object-fit: contain; }

/* The logo's wordmark is baked-in dark navy — unreadable against a dark
   header/modal background, and CSS custom properties can't reach into a
   raster image, so recolor it to a plain white silhouette in dark mode
   instead (full color only applies where the background is actually light). */
:root[data-theme="dark"] .header-brand img,
:root[data-theme="dark"] .modal-logo img { filter: brightness(0) invert(1); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .header-brand img,
  :root:not([data-theme="light"]) .modal-logo img { filter: brightness(0) invert(1); }
}
.modal h1 { font-size: 1.6rem; font-weight: 800; text-align: center; margin-bottom: 0.25rem; }
.subtitle { color: var(--text-muted); font-size: 0.875rem; text-align: center; margin-bottom: 1.75rem; line-height: 1.5; }

.section-divider {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--green);
  margin: 1.5rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--green-light);
}

/* ── Form Elements ─────────────────────────────────────────────────────────── */

.field-label {
  display: flex; flex-direction: column; gap: 0.3rem;
  font-size: 0.8rem; font-weight: 600; color: var(--text-muted);
  margin-bottom: 0.875rem;
}

.restrictions-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 0.75rem;
  margin-bottom: 1rem;
}
.restriction-check {
  display: flex; align-items: center; gap: 0.45rem;
  font-size: 0.8rem; font-weight: 600; color: var(--text);
  cursor: pointer;
}
.restriction-check input { width: 16px; height: 16px; flex-shrink: 0; accent-color: var(--green); cursor: pointer; }

input[type="text"],
input[type="number"],
input[type="password"],
input[type="email"],
input[type="date"],
input[type="time"],
select,
textarea {
  padding: 0.65rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--input-bg);
  color: var(--text);
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(39,174,96,0.12);
  background: var(--input-bg-focus);
}

textarea { resize: vertical; min-height: 64px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.height-ft-in-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-top: 0.3rem; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */

.btn-primary {
  display: block; width: 100%;
  padding: 0.9rem;
  background: var(--green);
  color: #FFF;
  border: none; border-radius: 10px;
  font-size: 1rem; font-weight: 700; font-family: inherit;
  cursor: pointer;
  margin-top: 0.5rem;
  transition: opacity 0.15s, transform 0.1s;
}
.btn-primary:hover { opacity: 0.92; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-outline {
  display: block; width: 100%;
  padding: 0.8rem;
  background: transparent;
  color: var(--green);
  border: 2px solid var(--green); border-radius: 10px;
  font-size: 0.95rem; font-weight: 700; font-family: inherit;
  cursor: pointer;
  margin-top: 0.75rem;
  transition: background 0.15s, color 0.15s;
}
.btn-outline:hover { background: var(--green-light); }

.btn-chip {
  padding: 0.45rem 1rem;
  background: var(--green);
  color: #FFF;
  border: none; border-radius: 20px;
  font-size: 0.8rem; font-weight: 700; font-family: inherit;
  cursor: pointer;
}

/* ── App Shell ─────────────────────────────────────────────────────────────── */

.app-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--card);
  padding: 0.9rem 1.25rem 0.75rem;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.header-brand { display: flex; align-items: center; }
.header-brand img { width: 90px; height: 26px; object-fit: contain; object-position: left center; }
.header-date { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }

.main-content { padding: 1rem 1rem 5.5rem; }

.view { display: none; }
.view.active { display: block; }

.view-title { font-size: 1.3rem; font-weight: 800; margin-bottom: 1rem; }
.view-title-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.view-title-row .view-title { margin-bottom: 0; }

/* ── Bottom Nav ────────────────────────────────────────────────────────────── */

.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: var(--shell-width);
  background: var(--card);
  display: flex;
  border-top: 1px solid var(--border);
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
}

.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 0.6rem 0.25rem 0.55rem;
  border: none; background: none; cursor: pointer; gap: 0.15rem;
}
.nav-icon { font-size: 1.35rem; line-height: 1.1; }
.nav-label { font-size: 0.62rem; font-weight: 500; color: var(--text-muted); }
.nav-btn.active .nav-label { color: var(--green); font-weight: 700; }

/* ── Card ──────────────────────────────────────────────────────────────────── */

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 0.875rem;
}
.card-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); margin-bottom: 0.875rem; }

/* ── Dashboard Greeting / Day Strip ────────────────────────────────────────── */

.greeting-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.greeting-sub { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }
.greeting-name { font-size: 1.3rem; font-weight: 800; }
.greeting-row input[type="date"].avatar-badge-date {
  width: auto; flex: 0 0 auto; flex-shrink: 0; height: 42px; border-radius: 999px;
  background: var(--green-light); border: none; padding: 0 0.75rem;
  font-family: inherit; font-size: 0.85rem; font-weight: 700; color: var(--green);
  cursor: pointer;
}

.day-strip { display: flex; justify-content: space-between; gap: 0.3rem; margin-bottom: 1rem; }
.day-strip-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
  padding: 0.5rem 0.1rem; border-radius: 12px; border: none; background: none;
  font-family: inherit; cursor: pointer;
}
.day-strip-dow { font-size: 0.62rem; font-weight: 600; color: var(--text-muted); }
.day-strip-num { font-size: 0.85rem; font-weight: 700; color: var(--text); width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.day-strip-item.selected .day-strip-num { background: var(--green); color: #FFF; }
.day-strip-item.selected .day-strip-dow { color: var(--green); }
.day-strip-item:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── Calorie Ring Card ─────────────────────────────────────────────────────── */

.calorie-card {
  display: flex; align-items: center; gap: 1.5rem;
}
.ring-wrap {
  position: relative; width: 120px; height: 120px; flex-shrink: 0;
}
.ring { width: 120px; height: 120px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--border); stroke-width: 10; }
.ring-fill {
  fill: none; stroke: var(--green); stroke-width: 10; stroke-linecap: round;
  stroke-dasharray: 314; stroke-dashoffset: 314;
  transition: stroke-dashoffset 0.7s cubic-bezier(.4,0,.2,1);
}
.ring-fill.over { stroke: var(--red); }
.ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.ring-value { font-size: 1.5rem; font-weight: 800; line-height: 1; }
.ring-unit { font-size: 0.62rem; color: var(--text-muted); font-weight: 600; }

.calorie-stats { display: flex; flex-direction: column; gap: 0.875rem; }
.calorie-stat { display: flex; flex-direction: column; gap: 0.1rem; }
.calorie-stat-val { font-size: 1.1rem; font-weight: 800; color: var(--text); }
.calorie-stat-lbl { font-size: 0.7rem; color: var(--text-muted); font-weight: 500; }
.calorie-stat.accent .calorie-stat-val { color: var(--orange); }
.calorie-stat.cheat .calorie-stat-val { color: var(--green); font-size: 0.9rem; }

/* ── Macro Bars ────────────────────────────────────────────────────────────── */

.macro-card { padding: 1rem 1.25rem; }
.macro-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.macro-row:last-child { margin-bottom: 0; }
.macro-label { width: 46px; font-size: 0.75rem; font-weight: 700; color: var(--text-muted); }
.macro-bar-track { flex: 1; height: 7px; background: var(--border); border-radius: 4px; overflow: hidden; }
.macro-bar { height: 100%; border-radius: 4px; width: 0%; transition: width 0.6s cubic-bezier(.4,0,.2,1); min-width: 0; }
.macro-bar.protein { background: var(--blue); }
.macro-bar.carbs { background: var(--orange); }
.macro-bar.fat { background: var(--purple); }
.macro-bar.fiber { background: var(--green); }
.macro-bar.sugar { background: var(--red); }
.macro-bar.sodium { background: var(--teal); }
.macro-val { width: 64px; font-size: 0.75rem; font-weight: 700; text-align: right; }

/* ── Weekly Activity Card ──────────────────────────────────────────────────── */

.activity-card { padding: 1rem 1.25rem 1.1rem; }
.activity-card-hdr { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.9rem; }
.streak-badge {
  font-size: 0.7rem; font-weight: 700; color: var(--orange);
  background: rgba(230,126,34,0.14); padding: 0.2rem 0.6rem; border-radius: 20px;
}
.weekly-bars { display: flex; align-items: flex-end; justify-content: space-between; gap: 0.5rem; height: 80px; }
.weekly-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 0.3rem; }
.weekly-bar-track { width: 100%; max-width: 22px; flex: 1; display: flex; align-items: flex-end; background: var(--border); border-radius: 6px; overflow: hidden; }
.weekly-bar { width: 100%; border-radius: 6px 6px 0 0; background: var(--green); min-height: 2px; transition: height 0.5s cubic-bezier(.4,0,.2,1); }
.weekly-bar.over { background: var(--red); }
.weekly-bar.empty { background: transparent; }
.weekly-bar-lbl { font-size: 0.62rem; font-weight: 700; color: var(--text-muted); }
.weekly-bar-lbl.is-today { color: var(--green); }

/* ── Food Log List ─────────────────────────────────────────────────────────── */

.list-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.625rem; }
.list-header h3 { font-size: 1rem; font-weight: 700; }

.food-item {
  background: var(--card);
  border-radius: 12px;
  padding: 0.875rem 1rem;
  display: flex; align-items: center; gap: 0.75rem;
  box-shadow: var(--shadow);
  margin-bottom: 0.5rem;
}
.food-icon { font-size: 1.6rem; flex-shrink: 0; }
.food-info { flex: 1; min-width: 0; }
.food-name { font-size: 0.9rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.food-meta { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.15rem; }
.food-cal { font-size: 0.9rem; font-weight: 800; color: var(--orange); flex-shrink: 0; }
.food-repeat, .food-edit, .food-del {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 0.9rem; padding: 0.35rem;
  border-radius: 6px; flex-shrink: 0;
  transition: background 0.1s, color 0.1s;
}
.food-repeat:hover { background: var(--green-light); color: var(--green); }
.food-edit:hover { background: var(--green-light); color: var(--green); }
.food-del:hover { background: var(--danger-hover-bg); color: var(--red); }

.meal-group { margin-bottom: 1rem; }
.meal-group-hdr { display: flex; justify-content: space-between; align-items: center; padding: 0 0.1rem 0.5rem; }
.meal-group-name { font-size: 0.85rem; font-weight: 800; color: var(--green); }
.meal-group-cal { font-size: 0.8rem; font-weight: 700; color: var(--text-muted); }
.meal-group-add {
  background: var(--green-light); color: var(--green); border: none; border-radius: 50%;
  width: 22px; height: 22px; font-size: 0.85rem; font-weight: 800; cursor: pointer; flex-shrink: 0;
  margin-left: 0.5rem;
}

.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); font-size: 0.9rem; line-height: 1.6; }

/* ── Log Form ──────────────────────────────────────────────────────────────── */

.water-card, .water-summary-card { padding: 0.9rem 1.1rem; }
.water-card-hdr { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.7rem; }
.water-total-text { font-size: 0.8rem; font-weight: 700; color: var(--blue); }
.water-quick-btns { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.water-quick-btns .btn-chip { background: var(--blue); }
.water-quick-btns .btn-sm { margin-left: auto; }

.water-cups { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.water-cup { font-size: 1.3rem; opacity: 0.3; }
.water-cup.filled { opacity: 1; }

.alcohol-card { padding: 0.9rem 1.1rem; }
.alcohol-total-text { font-size: 0.8rem; font-weight: 700; color: var(--purple); }
.alcohol-chip { background: var(--purple); }

.alcohol-glasses { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.alcohol-glass { font-size: 1.3rem; opacity: 0.3; }
.alcohol-glass.filled { opacity: 1; }

.mini-entries-list { margin-top: 0.5rem; }
.mini-entry-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.4rem 0; border-top: 1px solid var(--border);
  font-size: 0.78rem;
}
.mini-entry-row:first-child { border-top: none; }
.mini-entry-label { color: var(--text-muted); }
.mini-entry-del {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 0.85rem; padding: 0.25rem 0.4rem;
  border-radius: 6px; transition: background 0.1s, color 0.1s;
}
.mini-entry-del:hover:not(:disabled) { background: var(--danger-hover-bg); color: var(--red); }
.mini-entry-del:disabled { opacity: 0.4; cursor: default; }

.log-cal-pill {
  font-size: 0.78rem; font-weight: 700; color: var(--text-muted);
  background: var(--card); border: 1.5px solid var(--border);
  padding: 0.35rem 0.75rem; border-radius: 20px; white-space: nowrap;
}

.log-tabs {
  display: flex; border-bottom: 1.5px solid var(--border); margin-bottom: 1rem;
}
.log-tab {
  flex: 1; background: none; border: none; cursor: pointer; font-family: inherit;
  padding: 0.6rem 0.25rem; font-size: 0.78rem; font-weight: 700; color: var(--text-muted);
  border-bottom: 2.5px solid transparent; margin-bottom: -1.5px;
  transition: color 0.15s, border-color 0.15s;
}
.log-tab.active { color: var(--green); border-color: var(--green); }
.log-tab-panel { margin-bottom: 1rem; }

.log-picks-heading { font-size: 0.95rem; font-weight: 800; margin-bottom: 0.5rem; }
#log-recent-list { margin-bottom: 1.25rem; }

.combo-basket { margin-bottom: 1rem; border: 1.5px solid var(--green); }
.combo-item-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem;
  padding: 0.5rem 0; border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.combo-item-row:last-child { border-bottom: none; }
.combo-item-name { font-weight: 700; word-break: break-word; }
.combo-item-cal { color: var(--text-muted); font-size: 0.78rem; }
.combo-item-remove {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 1rem; padding: 0 0.25rem; line-height: 1;
}
.combo-item-remove:hover { color: var(--red); }
/* Qualified with the parent class (not just .combo-item-portion alone) so
   this beats the global `input[type="number"]{width:100%}` rule further up
   this file on CSS specificity -- a bare class selector loses to that
   element+attribute selector, which was silently stretching this input to
   full row width and squeezing long AI-combined names into a one-word-per-
   line mess. */
.combo-item-row .combo-item-portion {
  /* flex-basis (not width) drives sizing here, same as .staple-match-qty's
     `flex: 0 0 68px` -- for a flex item with flex-basis: auto (the
     default), `width` alone is what the global input[type=number] rule
     above was overriding; an explicit flex-basis sidesteps that fight
     entirely instead of relying on the specificity bump above. */
  flex: 0 0 3.4rem; width: 3.4rem; font-size: 0.8rem; padding: 0.15rem 0.3rem;
  border: 1px solid var(--border); border-radius: 6px; background: var(--card-bg, transparent);
}
.combo-item-unit { color: var(--text-muted); font-size: 0.78rem; flex-shrink: 0; }

#log-ai-suggest, #recipe-ai-suggest {
  background: var(--card); border-radius: 10px; box-shadow: var(--shadow);
  margin: -0.5rem 0 0.75rem; overflow: hidden;
}
.log-ai-suggest-row {
  padding: 0.5rem 0.9rem; font-size: 0.85rem; cursor: pointer;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; gap: 0.6rem;
}
.log-ai-suggest-row:last-child { border-bottom: none; }
.log-ai-suggest-row:hover, .log-ai-suggest-row:active { background: var(--green-light); }
.log-ai-suggest-hint { color: var(--text-muted); font-size: 0.75rem; white-space: nowrap; flex-shrink: 0; }
.combo-total-text { font-weight: 700; font-size: 0.85rem; margin: 0.6rem 0; }
.combo-item-warning { cursor: help; }

.staple-match-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 0; border-bottom: 1px solid var(--border);
}
.staple-match-row:last-child { border-bottom: none; }
.staple-match-word { font-weight: 700; font-size: 0.82rem; width: 72px; flex-shrink: 0; text-transform: capitalize; }
.staple-match-select { flex: 1 1 0%; min-width: 0; margin-bottom: 0; }
.staple-match-qty { flex: 0 0 68px; width: 68px; margin-bottom: 0; padding-right: 0.2rem; }
.staple-match-unit { font-size: 0.72rem; color: var(--text-muted); flex-shrink: 0; width: 46px; }

.diet-warning-banner {
  background: var(--error-bg); color: var(--error-text);
  border-radius: 10px; padding: 0.7rem 0.9rem;
  font-size: 0.8rem; font-weight: 600; line-height: 1.4;
  margin-bottom: 1rem;
}

.log-pick-row {
  background: var(--card); border-radius: 12px; padding: 0.75rem 0.9rem;
  display: flex; align-items: center; gap: 0.75rem; box-shadow: var(--shadow);
  margin-bottom: 0.5rem; cursor: pointer;
}
.log-pick-icon { font-size: 1.5rem; flex-shrink: 0; }
.log-pick-info { flex: 1; min-width: 0; }
.log-pick-name { font-size: 0.88rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-pick-meta { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.1rem; }
.log-pick-plus {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%;
  background: var(--green-light); color: var(--green); border: none;
  font-size: 1rem; font-weight: 800; cursor: pointer;
}

.meal-chips {
  display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem;
}

.chip {
  padding: 0.45rem 0.85rem;
  border: 1.5px solid var(--border); border-radius: 20px;
  background: var(--card); font-size: 0.8rem; font-weight: 600;
  font-family: inherit; cursor: pointer; white-space: nowrap;
  transition: all 0.15s;
}
.chip.active { background: var(--green); color: #FFF; border-color: var(--green); }

.log-card { margin-bottom: 0.875rem; }

/* ── Status Message ────────────────────────────────────────────────────────── */

.status-msg {
  padding: 0.75rem 1rem; border-radius: 9px;
  font-size: 0.875rem; font-weight: 600;
  margin-bottom: 0.75rem; text-align: center;
}
.status-msg.success { background: var(--success-bg); color: var(--success-text); }
.status-msg.error { background: var(--error-bg); color: var(--error-text); }

/* ── Recipes ───────────────────────────────────────────────────────────────── */

.recipe-search { margin-bottom: 0.75rem; }

.recipe-card {
  background: var(--card);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
  margin-bottom: 0.625rem;
  cursor: pointer;
}
.recipe-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; }
.recipe-name { font-size: 0.95rem; font-weight: 700; }
.recipe-cuisine { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.15rem; }
.recipe-cal { font-size: 0.9rem; font-weight: 800; color: var(--orange); white-space: nowrap; flex-shrink: 0; }
.recipe-cal-lbl { font-size: 0.62rem; color: var(--text-muted); font-weight: 500; display: block; text-align: right; }
.recipe-desc { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.5rem; line-height: 1.5; }
.recipe-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.65rem; }
.recipe-tag { font-size: 0.65rem; font-weight: 700; background: var(--green-light); color: var(--green); padding: 0.2rem 0.55rem; border-radius: 20px; }
.recipe-macros { display: flex; gap: 1.25rem; margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }
.recipe-macro { font-size: 0.72rem; color: var(--text-muted); }
.recipe-macro b { color: var(--text); }
.recipe-detail { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border); font-size: 0.82rem; line-height: 1.6; white-space: pre-wrap; }
.recipe-detail h4 { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin: 0.75rem 0 0.3rem; }
.recipe-detail h4:first-child { margin-top: 0; }
.recipe-image { width: 100%; height: 160px; object-fit: cover; border-radius: 10px; margin-bottom: 0.75rem; display: block; }
.recipe-video-link { display: inline-block; margin-top: 0.6rem; font-size: 0.78rem; font-weight: 700; color: var(--green); text-decoration: none; }
.recipe-video-link:hover { text-decoration: underline; }
.recipe-delete-btn { display: block; margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border); width: 100%; background: none; border-left: none; border-right: none; border-bottom: none; text-align: left; font-size: 0.72rem; font-weight: 700; color: var(--text-muted); cursor: pointer; }
.recipe-delete-btn:hover:not(:disabled) { color: var(--red); }
.recipe-delete-btn:disabled { opacity: 0.6; cursor: default; }
.rv-image-preview { width: 100%; max-height: 180px; object-fit: cover; border-radius: 10px; margin-bottom: 0.75rem; display: block; }

/* ── Add Recipe ────────────────────────────────────────────────────────────── */

.add-option-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  display: flex; align-items: center; gap: 0.9rem;
  cursor: pointer;
  margin-bottom: 0.75rem;
  transition: border-color 0.15s, background 0.15s;
}
.add-option-card:hover { border-color: var(--green); background: var(--green-light); }
.add-option-icon { font-size: 1.8rem; flex-shrink: 0; }
.add-option-title { font-size: 0.92rem; font-weight: 700; }
.add-option-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.1rem; }

#url-input-row { margin-bottom: 0.75rem; }

#camera-box { margin-bottom: 0.75rem; }
#camera-video { width: 100%; border-radius: 12px; background: #000; display: block; }
.camera-controls { display: flex; gap: 0.6rem; margin-top: 0.6rem; }
.camera-controls .btn-primary, .camera-controls .btn-outline { margin-top: 0; }

#barcode-camera-box { margin-bottom: 0.75rem; }
#barcode-video { width: 100%; border-radius: 12px; background: #000; display: block; }

.tag-picker-chip { padding: 0.4rem 0.8rem; border: 1.5px solid var(--border); border-radius: 20px; background: var(--card); font-size: 0.75rem; font-weight: 600; font-family: inherit; cursor: pointer; }
.tag-picker-chip.active { background: var(--green); color: #FFF; border-color: var(--green); }
.tag-picker-add { border-style: dashed; color: var(--text-muted); }
.tag-picker-add:hover { border-color: var(--green); color: var(--green); }

/* ── Recipe Web Scraper Modal ──────────────────────────────────────────────── */

.scraper-modal { max-width: 480px; text-align: left; }
.scraper-modal-hdr { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.scraper-modal-hdr h3 { font-size: 1.1rem; font-weight: 800; }
.scraper-close-btn { background: none; border: none; font-size: 1.1rem; color: var(--text-muted); cursor: pointer; padding: 0.25rem; line-height: 1; }
.scraper-close-btn:hover { color: var(--text); }
.field-hint { font-weight: 500; text-transform: none; letter-spacing: normal; font-size: 0.7rem; }
.scraper-meta { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.75rem; }
.scraper-meta .meta-chip { padding: 0.15rem 0.6rem; border-radius: 20px; font-size: 0.68rem; font-weight: 700; background: var(--green-light); color: var(--green); }
#scraper-markdown { font-family: 'Courier New', monospace; font-size: 0.78rem; line-height: 1.6; }
.hint-text { font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; }
#scraper-links-list .add-option-card { margin-bottom: 0.5rem; }
.scraper-discover-results { margin-top: 0.75rem; }
.scraper-discover-card {
  display: block; width: 100%; text-align: left;
  background: var(--card); border: 1.5px solid var(--border); border-radius: 12px;
  padding: 0.75rem 1rem; margin-bottom: 0.6rem; cursor: pointer; font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.scraper-discover-card:hover { border-color: var(--green); background: var(--green-light); }
.scraper-discover-card-title { font-size: 0.88rem; font-weight: 700; }
.scraper-discover-card-desc { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.2rem; line-height: 1.4; }
.scraper-discover-card-url { font-size: 0.72rem; color: var(--green); margin-top: 0.3rem; word-break: break-all; }
.scraper-links-heading { font-size: 0.95rem; font-weight: 800; margin-bottom: 0.35rem; }
.scraper-links-pager { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin: 0.75rem 0; }
.scraper-links-pager-count { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; }
.btn-sm {
  padding: 0.45rem 0.85rem;
  border: 1.5px solid var(--border); border-radius: 8px;
  background: var(--card); color: var(--text);
  font-size: 0.78rem; font-weight: 700; font-family: inherit;
  cursor: pointer;
}
.btn-sm:hover { border-color: var(--green); color: var(--green); }
.btn-sm:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-sm:disabled:hover { border-color: var(--border); color: var(--text); }

/* ── AI Coach Chat ─────────────────────────────────────────────────────────── */

.chat-messages { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 0.875rem; min-height: 200px; }
.chat-bubble { max-width: 85%; padding: 0.65rem 0.9rem; border-radius: 14px; font-size: 0.88rem; line-height: 1.55; white-space: pre-wrap; }
.chat-bubble.user { align-self: flex-end; background: var(--green); color: #FFF; border-bottom-right-radius: 4px; }
.chat-bubble.assistant { align-self: flex-start; background: var(--card); box-shadow: var(--shadow); border-bottom-left-radius: 4px; }
.chat-bubble.pending { color: var(--text-muted); font-style: italic; }
.chat-input-row { display: flex; gap: 0.5rem; align-items: flex-end; }
.chat-input-row textarea { flex: 1; resize: none; min-height: 44px; max-height: 120px; }
.chat-send-btn { flex-shrink: 0; padding: 0.65rem 1.1rem; }

/* ── Coming Soon ───────────────────────────────────────────────────────────── */

.coming-soon { text-align: center; padding: 4rem 1.5rem 2rem; }
.coming-icon { font-size: 4rem; margin-bottom: 1rem; }
.coming-soon h3 { font-size: 1.3rem; font-weight: 800; margin-bottom: 0.625rem; }
.coming-soon p { font-size: 0.9rem; color: var(--text-muted); line-height: 1.6; margin-bottom: 0.5rem; }
.coming-tag { display: inline-block; background: var(--green-light); color: var(--green); font-size: 0.75rem; font-weight: 700; padding: 0.25rem 0.75rem; border-radius: 20px; margin-top: 0.5rem; }

/* ── Profile ───────────────────────────────────────────────────────────────── */

.profile-row { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.profile-row:last-child { border-bottom: none; }
.profile-row-label { font-size: 0.85rem; color: var(--text-muted); }
.profile-row-val { font-size: 0.85rem; font-weight: 700; }

.loading-text { text-align: center; color: var(--text-muted); padding: 1rem 0; font-size: 0.9rem; }

/* ── Inactivity nudge ──────────────────────────────────────────────────────── */

.inactivity-banner {
  background: var(--card); border-left: 4px solid var(--orange);
  border-radius: var(--radius); padding: 0.85rem 1rem;
  font-size: 0.85rem; font-weight: 600; line-height: 1.5;
  margin-bottom: 1rem; box-shadow: var(--shadow);
}

/* ── Weekly AI insight ─────────────────────────────────────────────────────── */

.insight-card { margin-top: 1rem; }
.insight-text { font-size: 0.85rem; line-height: 1.6; color: var(--text); margin-top: 0.75rem; white-space: pre-wrap; }

/* ── Weight tracking ───────────────────────────────────────────────────────── */

.weight-chart { width: 100%; height: 100px; display: block; margin-bottom: 0.75rem; }
.weight-log-form { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; }
.weight-log-form input[type="date"] { flex: 1.3; }
.weight-log-form input[type="number"] { flex: 1; }
.weight-unit-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; white-space: nowrap; }

/* ── Health report ─────────────────────────────────────────────────────────── */

.report-hint { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.85rem; line-height: 1.5; }
.report-range-row { display: flex; gap: 0.5rem; margin-bottom: 0.85rem; }
.report-range-row input[type="date"] { flex: 1; }
.repeat-yesterday-btn { margin-bottom: 1rem; }

.ticket-row { border-top: 1px solid var(--border); padding: 0.75rem 0; }
.ticket-row:first-child { border-top: none; padding-top: 0; }
.ticket-hdr { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.ticket-subject { font-weight: 700; font-size: 0.88rem; }
.ticket-date { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.15rem; }
.ticket-badge { padding: 0.15rem 0.6rem; border-radius: 20px; font-size: 0.68rem; font-weight: 700; flex-shrink: 0; }
.ticket-badge.open { background: rgba(243,156,18,0.16); color: #F39C12; }
.ticket-badge.resolved { background: var(--green-light); color: var(--green); }
.ticket-message { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.4rem; line-height: 1.5; }
.ticket-reply {
  background: var(--green-light); border-radius: 8px; padding: 0.6rem 0.75rem;
  margin-top: 0.5rem; font-size: 0.82rem; line-height: 1.5;
}
.ticket-reply-label { font-weight: 700; color: var(--green); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; display: block; margin-bottom: 0.2rem; }

.report-header { text-align: center; margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 2px solid var(--border); }
.report-brand { font-size: 1.3rem; font-weight: 800; color: var(--green); }
.report-meta { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.25rem; }
.report-summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; margin-bottom: 1.5rem; }
.report-stat { background: var(--card); border-radius: var(--radius); padding: 0.85rem; text-align: center; box-shadow: var(--shadow); }
.report-stat-val { display: block; font-size: 1.3rem; font-weight: 800; }
.report-stat-lbl { display: block; font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 0.2rem; }
.report-section-title { font-size: 0.95rem; font-weight: 800; margin: 1.25rem 0 0.6rem; }
.report-chart { display: flex; align-items: flex-end; gap: 3px; height: 120px; margin-bottom: 1rem; }
.report-chart-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 3px; min-width: 0; }
.report-chart-track { width: 100%; flex: 1; display: flex; align-items: flex-end; background: var(--border); border-radius: 3px; overflow: hidden; }
.report-chart-bar { width: 100%; background: var(--green); min-height: 2px; }
.report-chart-bar.over { background: var(--red); }
.report-chart-lbl { font-size: 0.6rem; color: var(--text-muted); white-space: nowrap; }
.report-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.report-table th, .report-table td { text-align: left; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border); }
.report-table th { font-weight: 700; color: var(--text-muted); font-size: 0.7rem; text-transform: uppercase; }

#tutorials-header { text-align: center; margin: 0.5rem 0 1rem; }
#tutorials-logo { height: 56px; display: block; margin: 0 auto 0.35rem; }
#tutorials-subtitle { font-size: 0.95rem; font-weight: 700; color: var(--text-muted); margin: 0; }
#tutorials-lang-chips, #tutorials-mode-chips { justify-content: center; margin-bottom: 0.75rem; }
#tutorials-pdf-container { display: flex; justify-content: center; overflow: auto; max-height: 65vh; }
#tutorials-pdf-container canvas { max-width: 100%; box-shadow: 0 0 0 1px var(--border); }
#tutorials-panel-wrap .pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 0.85rem; }
#tutorials-panel-wrap .pager button { border: none; background: var(--green); color: #fff; border-radius: 8px; padding: 0.5rem 1rem; font-size: 0.9rem; cursor: pointer; }
#tutorials-panel-wrap .pager button:disabled { background: var(--border); color: var(--text-muted); cursor: not-allowed; }
#tutorials-video-panel video { width: 100%; border-radius: 10px; display: block; }
#tutorials-audio-panel { padding: 1.5rem 1rem; text-align: center; }
#tutorials-audio-panel audio { width: 100%; }
#tutorials-audio-panel p { color: var(--text-muted); font-size: 0.9rem; margin-top: 1rem; }

.shopping-print-group { margin-bottom: 1.25rem; }
.shopping-print-store-meta { font-size: 0.8rem; color: var(--text-muted); margin: -0.4rem 0 0.5rem; }
.shopping-print-list { list-style: none; padding: 0; margin: 0; }
.shopping-print-list li { padding: 0.3rem 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.shopping-print-list li.checked { color: var(--text-muted); text-decoration: line-through; }

@media print {
  body.printing-report * { visibility: hidden; }
  body.printing-report #report-print-area,
  body.printing-report #report-print-area * { visibility: visible; }
  body.printing-report #report-print-area { position: absolute; left: 0; top: 0; width: 100%; }
  body.printing-report .no-print { display: none !important; }

  body.printing-shopping-list * { visibility: hidden; }
  body.printing-shopping-list #shopping-print-area,
  body.printing-shopping-list #shopping-print-area * { visibility: visible; }
  body.printing-shopping-list #shopping-print-area { position: absolute; left: 0; top: 0; width: 100%; }
}

/* ── Responsive ────────────────────────────────────────────────────────────── */

@media (max-width: 360px) {
  .two-col { grid-template-columns: 1fr; }
  .calorie-card { flex-direction: column; align-items: flex-start; }
  .calorie-stats { flex-direction: row; gap: 1.5rem; }
}
