/*
 * FatFork design system.
 * Hand-written, locally-served, zero external dependency (LD-04). Every rule below the
 * token block consumes a token — no raw hex values, no magic numbers for spacing/radius.
 */

:root {
  /* Dark-mode support (260927-rsl): load-bearing, not cosmetic -- this is what makes
     the native date picker on the Today page, number spinners and scrollbars render
     light here and dark in the `[data-theme="dark"]` block below. */
  color-scheme: light;

  /* Brand green ramp */
  --brand: #2f8f4e;
  --brand-dark: #1f6b39;
  --brand-tint: #e7f5ec;
  --brand-contrast: #ffffff;

  /* Neutrals */
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-muted: #fafbf9;
  --border: #e2e6e0;
  --border-strong: #cdd3c9;
  --text: #1f2420;
  --text-muted: #5c6459;
  --text-faint: #838c7e;

  /* Semantic accents */
  --danger: #b3413a;
  --danger-tint: #fbeceb;
  --warn: #a2661a;
  --warn-tint: #fbf1e2;

  /* Macro accents (day-view macro split bar) */
  --macro-protein: #2f8f4e;
  --macro-carbs: #dba53c;
  --macro-fat: #7a6bd6;
  /* Fiber: teal, apart from carbs' amber and protein's green. */
  --macro-fiber: #1f8fa3;

  /* Chart.js theming (260927-rsl): the only lever that reaches tick labels, grid
     lines and legend text, since neither chart passes an `options` object. Light
     values are the pre-existing chart appearance carried over unchanged. */
  --chart-text: #5c6459;
  --chart-grid: rgba(31, 36, 32, 0.10);
  --chart-calories-line: #2f8f4e;
  --chart-calories-fill: rgba(47, 143, 78, 0.15);
  --chart-weight-line: #7a6bd6;
  --chart-weight-fill: rgba(122, 107, 214, 0.15);
  --chart-macro-line: #c2751a;
  --chart-macro-fill: rgba(194, 117, 26, 0.15);
  --chart-goal-line: #2f8f4e;
  --chart-projection-line: #c2751a;

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  /* Radius scale */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(20, 30, 20, 0.06);
  --shadow-md: 0 4px 16px rgba(20, 30, 20, 0.08);
  --shadow-lg: 0 12px 32px rgba(20, 30, 20, 0.12);

  /* Search-thumbnail lightbox scrim -- kept as a token so this file's "no raw
     hex/rgba below the token block" claim stays true. */
  --scrim: rgba(20, 30, 20, 0.6);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

/* ---------------------------------------------------------------------------------
   Dark theme token overrides (260927-rsl)
   --------------------------------------------------------------------------------- */
/* Overrides ONLY colour-valued tokens -- spacing, radius and font tokens are shared
   with the light theme above and are deliberately absent here.
   D-05: --brand-dark inverts its lightness in dark mode. In the light palette it is a
   dark green used as FOREGROUND (links, brand mark, active nav text, <summary>,
   .store-badge text, .auth-notice-info text); on a dark surface that same foreground
   role needs a LIGHT green to stay legible, so this block makes --brand-dark lighter
   than --brand even though the token keeps its light-mode name (renaming it would
   touch ~8 consuming rules for no behavioural gain). --brand-contrast stays
   near-black here because it sits on the --brand and --danger fills, not on --bg. */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #12150f;
  --surface: #1b1f19;
  --surface-muted: #23281f;
  --border: #2e3429;
  --border-strong: #424a3c;
  --text: #e8ece6;
  --text-muted: #a8b0a2;
  --text-faint: #8d9686;

  --brand: #46a76a;
  --brand-dark: #7ed39a;
  --brand-tint: #1e3327;
  --brand-contrast: #0c1410;

  --danger: #f08a82;
  --danger-tint: #3a211f;
  --warn: #e0aa5c;
  --warn-tint: #3a2e18;

  --macro-protein: #4caf6d;
  --macro-carbs: #e0b24f;
  --macro-fat: #9b8cf0;
  --macro-fiber: #4cc3d9;

  --chart-text: #a8b0a2;
  --chart-grid: rgba(232, 236, 230, 0.14);
  --chart-calories-line: #4fbb77;
  --chart-calories-fill: rgba(79, 187, 119, 0.20);
  --chart-weight-line: #9b8cf0;
  --chart-weight-fill: rgba(155, 140, 240, 0.20);
  --chart-macro-line: #e0a04a;
  --chart-macro-fill: rgba(224, 160, 74, 0.20);
  --chart-goal-line: #4fbb77;
  --chart-projection-line: #e0993f;

  --scrim: rgba(0, 0, 0, 0.75);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.65);
}

/* ---------------------------------------------------------------------------------
   Reset + base
   --------------------------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  /* Mobile-app-feel pass: contains the browser's own rubber-band/pull-to-refresh
     bounce to this element instead of revealing the OS chrome behind it on scroll
     overshoot -- a desktop-browser "page" tell that a native app never has. */
  overscroll-behavior-y: contain;
  /* Removes the grey flash Android/iOS browsers paint on every tap -- replaced
     by deliberate :active states below on .btn/.app-nav-links a, since removing
     the browser's own feedback without a replacement would feel less responsive,
     not more native. */
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
h3,
h4 {
  margin: 0 0 var(--space-3);
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
}

p {
  margin: 0 0 var(--space-3);
}

a {
  color: var(--brand-dark);
}

/* ---------------------------------------------------------------------------------
   App shell
   --------------------------------------------------------------------------------- */

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-content {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) var(--space-7);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* SPA pages render one plain wrapper <div>; let its children (the cards) take part
   in .app-content's flex gap directly. */
.app-content > div {
  display: contents;
}

/* Cards nested inside a card (meal builder's search, saved meals list). */
.card .card {
  margin-top: var(--space-4);
}

/* Vertical rhythm inside a card whose children are separate blocks. */
.card-stack > * + * {
  margin-top: var(--space-4);
}

.app-content--narrow {
  max-width: 560px;
}

/* ---------------------------------------------------------------------------------
   Top bar / nav
   --------------------------------------------------------------------------------- */

.app-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.app-nav-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.app-nav-brand {
  font-weight: 700;
  font-size: 18px;
  color: var(--brand-dark);
  text-decoration: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

/* 260928-dfg: the mark has no fill of its own -- it inherits .app-nav-brand's
   `color` via `fill="currentColor"`, so the existing dark-mode token override
   above already re-themes it for free, with no second asset and no JS. */
.app-nav-brand-icon {
  width: 20px;
  height: 20px;
  flex: none;
  display: block;
  /* One playful turn of the fork when the app opens (the nav stays mounted across
     page changes, so it does not repeat on every navigation). */
  animation: fork-spin 0.9s cubic-bezier(0.34, 1.4, 0.64, 1) 0.15s both;
  transform-origin: 50% 50%;
}

@keyframes fork-spin {
  from { transform: rotate(-360deg) scale(0.6); }
  to { transform: rotate(0deg) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .app-nav-brand-icon { animation: none; }
}

.app-nav-links {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  flex: 1;
}

.app-nav-links a {
  display: inline-block;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.app-nav-links a:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.app-nav-links a.is-active {
  background: var(--brand-tint);
  color: var(--brand-dark);
}

.app-nav-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  white-space: nowrap;
}

.app-nav-username {
  font-size: 13px;
  color: var(--text-muted);
}

.app-nav-logout {
  margin: 0;
}

/* ---------------------------------------------------------------------------------
   Cards
   --------------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
}

.card + .card {
  margin-top: 0;
}

.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.card-header h2,
.card-header h3 {
  margin: 0;
}

.card-title {
  margin: 0;
}

.card-muted {
  background: var(--surface-muted);
}

/* ---------------------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  min-height: 38px;
  transition: transform 0.1s ease, opacity 0.1s ease;
}

/* Deliberate tap feedback replacing the suppressed browser tap-highlight
   (see body's -webkit-tap-highlight-color above) -- an immediate, visible
   press state is what makes a tap feel acknowledged instead of inert. */
.btn:active {
  transform: scale(0.97);
  opacity: 0.85;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-contrast);
}

.btn-primary:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--surface-muted);
}

.btn-quiet {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
  padding-left: var(--space-3);
  padding-right: var(--space-3);
}

.btn-quiet:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.btn-danger {
  background: var(--danger-tint);
  border-color: var(--danger-tint);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--brand-contrast);
}

.btn-sm {
  min-height: 30px;
  padding: var(--space-1) var(--space-3);
  font-size: 13px;
}

.btn-full {
  width: 100%;
}

/* 260928-eka: icon-only action controls (Add/Star/Unstar/Delete). No colour declared
   in either rule -- each icon paints with currentColor and inherits the colour its
   surrounding .btn-primary/.btn-quiet/.btn-danger class already sets. .chip-list
   button (line ~642) deliberately still wins on padding inside chips by specificity,
   keeping chip controls compact. */
.btn-icon {
  width: 16px;
  height: 16px;
  flex: none;
  display: block;
}

.btn-icon-only {
  padding-left: var(--space-3);
  padding-right: var(--space-3);
}

/* ---------------------------------------------------------------------------------
   Forms
   --------------------------------------------------------------------------------- */

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

input,
select,
textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  min-height: 38px;
  width: 100%;
  margin-top: var(--space-1);
}

input[type="checkbox"] {
  width: auto;
  min-height: auto;
  margin-top: 0;
  vertical-align: middle;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  border-color: var(--brand);
}

.form-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 400;
  font-size: 14px;
  color: var(--text);
}

.form-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3);
}

.form-inline label {
  margin-bottom: 0;
  flex: 1 1 160px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4) var(--space-5);
}

/* ---------------------------------------------------------------------------------
   Tables
   --------------------------------------------------------------------------------- */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table-wrap {
  overflow-x: auto;
}

.qty-input {
  width: 5.5em;
  min-width: 5.5em;
}

/* Add + Star buttons side by side in a search-result action cell. */
.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

/* Meal builder: one picked ingredient — name grows, qty/unit/remove stay compact. */
.pickedIngredient {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
}

.pickedIngredient-name {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-wrap: anywhere;
}

/* Live nutrient total under a meal's ingredient list (builder + edit recipe). */
.meal-preview-total {
  margin: var(--space-2) 0 var(--space-3);
  font-size: 14px;
}

.pickedIngredient > .qty-input,
.pickedIngredient > span,
.pickedIngredient > .btn {
  flex: 0 0 auto;
}

th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-faint);
  font-weight: 600;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
}

td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

/* ---------------------------------------------------------------------------------
   Disclosure (details/summary)
   --------------------------------------------------------------------------------- */

details {
  margin-top: var(--space-2);
}

summary {
  cursor: pointer;
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-dark);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  list-style: none;
}

summary::-webkit-details-marker {
  display: none;
}

summary:hover {
  background: var(--brand-tint);
}

details[open] summary {
  margin-bottom: var(--space-3);
}

details form {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

/* ---------------------------------------------------------------------------------
   Incomplete-data badge
   --------------------------------------------------------------------------------- */

.incomplete {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--warn);
  background: var(--warn-tint);
  border-radius: var(--radius-pill);
  padding: 1px var(--space-2);
  margin-left: 2px;
}

.incompleteLegend {
  font-size: 12px;
  color: var(--text-faint);
}

/* ---------------------------------------------------------------------------------
   Stat cards / strips
   --------------------------------------------------------------------------------- */

.stat-strip {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.stat {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  flex: 1 1 120px;
}

.stat-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-faint);
  margin-bottom: 2px;
}

.stat-value {
  display: block;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

/* ---------------------------------------------------------------------------------
   Chips (quick-add starred/recents rows)
   --------------------------------------------------------------------------------- */

.chip-section {
  margin-bottom: var(--space-4);
}

.chip-section h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-faint);
  margin-bottom: var(--space-2);
}

.chip-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chip-list li {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: var(--space-1) var(--space-2) var(--space-1) var(--space-3);
  font-size: 13px;
}

.chip-list form {
  margin: 0;
  display: inline-block;
}

.chip-list button {
  min-height: 26px;
  padding: 0 var(--space-2);
  font-size: 12px;
}

/* ---------------------------------------------------------------------------------
   Day-view hero: calorie gauge + macro split bar
   --------------------------------------------------------------------------------- */

.hero-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  text-align: center;
}

.gauge {
  width: 168px;
  height: 168px;
  border-radius: 50%;
  background: conic-gradient(var(--brand) 0deg 360deg, var(--brand) 360deg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
}

.gauge-inner {
  width: 138px;
  height: 138px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.gauge-value {
  font-size: 30px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.gauge-caption {
  font-size: 12px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 2px;
}

.macro-bar {
  display: flex;
  width: 100%;
  max-width: 420px;
  height: 10px;
  border-radius: var(--radius-pill);
  overflow: hidden;
  background: var(--surface-muted);
  border: 1px solid var(--border);
}

.macro-segment {
  flex-grow: 0;
  min-width: 2px;
}

.macro-protein {
  background: var(--macro-protein);
}

.macro-carbs {
  background: var(--macro-carbs);
}

.macro-fat {
  background: var(--macro-fat);
}

.macro-legend {
  display: flex;
  gap: var(--space-4);
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
  justify-content: center;
}

.macro-legend-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.macro-legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.hero-card > h2 {
  margin: 0;
}

.macro-legend-value {
  font-weight: 600;
  color: var(--text);
}

.hero-totals {
  width: 100%;
  text-align: left;
  border-top: 1px solid var(--border);
  padding-top: var(--space-4);
}

.hero-totals p:last-child {
  margin-bottom: 0;
}

/* ---------------------------------------------------------------------------------
   Day switcher bar
   --------------------------------------------------------------------------------- */

.day-switcher {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.day-switcher label {
  margin-bottom: 0;
  flex: 1 1 100%;
}

/* Previous day · date · next day on one row; the date input takes the space between. */
.day-switcher input[type='date'] {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}

.day-switcher .day-step {
  flex: 0 0 auto;
  min-width: 44px;
  font-size: 1.25rem;
  line-height: 1;
}

.day-switcher #daySwitcherHint {
  flex: 1 1 100%;
}

/* ---------------------------------------------------------------------------------
   Meal-slot cards
   --------------------------------------------------------------------------------- */

.meal-slot-card .card-header h3 {
  text-transform: capitalize;
  font-size: 16px;
}

.meal-entries-table {
  margin-top: var(--space-3);
}

/* ---------------------------------------------------------------------------------
   Search / food groups
   --------------------------------------------------------------------------------- */

.search-group {
  margin-bottom: var(--space-3);
}

.search-group:last-child {
  margin-bottom: 0;
}

/* Placeholder AND frame for a search-result thumbnail. The ::after glyph reads as
   "no picture" for the many OpenFoodFacts products with no image on file; the
   absolutely-positioned <img> (below) simply covers it once a real image loads. This
   single mechanism handles all three states -- no URL, failed URL, loaded URL -- with
   no second element and no JavaScript. */
.search-thumb {
  display: inline-block;
  position: relative;
  width: 44px;
  height: 44px;
  margin-right: var(--space-2);
  vertical-align: middle;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  overflow: hidden;
  flex-shrink: 0;
}

.search-thumb::after {
  content: "\2014";
  position: absolute;
  /* Under the photo and never a tap target: drawn after the <img>, it used to sit on
     top of the picture's centre and swallow taps meant to zoom it. */
  z-index: 0;
  pointer-events: none;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-faint);
  font-size: 14px;
}

.search-thumb img {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* STORE-01: favorite-store match badge — modelled on .incomplete above but with the
   brand tokens rather than warn tokens, since this is a helpful signal, not a caution. */
.store-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--brand-dark);
  background: var(--brand-tint);
  border-radius: var(--radius-pill);
  padding: 1px var(--space-2);
  margin-left: var(--space-2);
}

.thumb-zoom {
  cursor: zoom-in;
}

.thumb-zoom:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

/* ---------------------------------------------------------------------------------
   Search-thumbnail enlargement overlay (SEARCH-UX-03)
   --------------------------------------------------------------------------------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background: var(--scrim);
}

/* REQUIRED: `display: flex` above overrides the `hidden` attribute's UA `display: none`
   default, so without this rule the overlay would be visible on page load. */
.lightbox[hidden] {
  display: none;
}

.lightbox-card {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-5);
  max-width: 90vw;
  max-height: 90vh;
}

.lightbox-image {
  display: block;
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: var(--radius-md);
}

/* 260921-lqb, D-07: upscales the already-cached 200px thumbnail to roughly match the
   400px full image's long edge while the real image is still loading, so the overlay
   never paints a tiny box. Removed once the real image swaps in -- the real image's own
   dimensions (bounded by .lightbox-image above) win over this guessed box. */
.lightbox-image.is-fallback {
  width: min(400px, 100%);
  height: auto;
}

/* 260921-lqb, D-05: the genuine-worst-case message, shown only when there is no usable
   fallback AND the zoom image itself failed or timed out. Styled like .lightbox-caption
   above since both are secondary overlay text; has no display rule of its own so the
   `hidden` attribute's UA default governs it until JS reveals it. */
.lightbox-unavailable {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  margin: var(--space-3) 0 0;
}

.lightbox-close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.lightbox-close:hover {
  background: var(--surface-muted);
}

.lightbox-close:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.lightbox-caption {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  margin: var(--space-3) 0 0;
}

.no-results-card {
  background: var(--surface-muted);
}

.search-results-card.is-empty {
  display: none;
}

.search-results-card[aria-busy="true"] {
  opacity: 0.6;
}

/* 07-05 UAT finding — developer-approved UX addition: a small, motion-based
   in-flight indicator alongside the existing opacity dim above (that rule is
   kept unchanged; this is additive). CSS-only, no new npm dependency (LD-04)
   — three dots next to "Search Results", pulsing in a staggered sequence
   while searchQuery.isFetching is true. */
.search-spinner {
  display: inline-flex;
  gap: 3px;
  margin-left: var(--space-2);
  vertical-align: middle;
}

.search-spinner span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--brand);
  animation: search-spinner-pulse 1s ease-in-out infinite;
}

.search-spinner span:nth-child(2) {
  animation-delay: 0.15s;
}

.search-spinner span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes search-spinner-pulse {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: scale(0.8);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ---------------------------------------------------------------------------------
   Trends: granularity pills, period pager
   --------------------------------------------------------------------------------- */

.segmented {
  display: inline-flex;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 2px;
}

.segmented-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.segmented-btn:hover {
  color: var(--text);
}

.segmented-btn[aria-current="true"] {
  background: var(--brand);
  color: var(--brand-contrast);
  box-shadow: var(--shadow-sm);
}

.period-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.period-caption {
  font-size: 13px;
  color: var(--text-muted);
  min-width: 200px;
  text-align: center;
}

#caloriesTrend canvas,
#weightTrend canvas {
  max-height: 320px;
}

/* ---------------------------------------------------------------------------------
   Goal plan: clamped pace cell
   --------------------------------------------------------------------------------- */

.clamped-cell {
  background: var(--warn-tint);
}

.clamped {
  color: var(--warn);
  font-weight: 600;
}

/* ---------------------------------------------------------------------------------
   Auth pages (login, request-problem) — anonymous-safe, minimal, no nav
   --------------------------------------------------------------------------------- */

.auth-page {
  background: var(--brand-tint);
  min-height: 100vh;
}

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5) var(--space-4);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}

.auth-brand {
  text-align: center;
  margin-bottom: var(--space-5);
}

.auth-brand-mark {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: var(--brand-dark);
}

.auth-notice {
  border-radius: var(--radius-md);
  padding: var(--space-3);
  font-size: 13px;
  margin-bottom: var(--space-4);
}

.auth-notice-error {
  background: var(--danger-tint);
  color: var(--danger);
}

.auth-notice-info {
  background: var(--brand-tint);
  color: var(--brand-dark);
}

/* ---------------------------------------------------------------------------------
   Utility
   --------------------------------------------------------------------------------- */

.inline-form {
  display: inline-block;
}

.text-muted {
  color: var(--text-muted);
}

.text-small {
  font-size: 12px;
}

.section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-faint);
  margin: 0 0 var(--space-2);
}

/* ---------------------------------------------------------------------------------
   Responsive pass. CSS-only — no markup ever duplicates a row/card/nav for a
   different screen size (a duplicated meal-entry row would fail a suite assertion
   that counts occurrences of the entry id; a duplicated nav is simply wrong).
   --------------------------------------------------------------------------------- */

@media (max-width: 720px) {
  /* Mobile-app-feel pass: the link list leaves the top bar entirely and
     becomes a fixed bottom tab bar -- the single most recognizable "this is
     an app, not a webpage" convention on a phone, and it puts navigation
     within thumb reach instead of a stretch to the top of the screen. */
  .app-nav-inner {
    gap: var(--space-3);
  }

  .app-nav-links {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    width: auto;
    margin: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    flex-wrap: nowrap;
    justify-content: space-around;
    gap: 0;
    /* env(safe-area-inset-bottom) clears the home-indicator strip on notched
       phones in standalone/PWA mode -- 0 on a browser without that inset. */
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .app-nav-links a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    white-space: nowrap;
    border-radius: 0;
    /* >=44px touch target (Apple HIG / Material minimum) on every tab,
       including the safe-area padding above. */
    min-height: 56px;
    font-size: 12px;
  }

  .app-nav-links a.is-active {
    background: transparent;
  }

  .app-nav-links a:active {
    background: var(--surface-muted);
  }

  /* >=44px touch targets on phones specifically (desktop/.btn's 38px default
     is untouched) -- input/select/textarea's base rule was already 38px;
     .btn-sm (Remove ingredient, Delete recipe, Log Out) was the real gap at
     30px. */
  input,
  select,
  textarea,
  .btn-sm {
    min-height: 44px;
  }

  /* Clears the fixed bottom tab bar's height (56px) plus its safe-area inset
     so the last card in any page is never hidden behind it. */
  .app-content {
    padding: var(--space-4) var(--space-3) calc(56px + env(safe-area-inset-bottom, 0px) + var(--space-5));
    gap: var(--space-4);
  }

  .card {
    padding: var(--space-4);
    border-radius: var(--radius-md);
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }

  .form-inline {
    flex-direction: column;
    align-items: stretch;
  }

  .form-inline label {
    flex-basis: auto;
  }

  .stat-strip {
    gap: var(--space-2);
  }

  .stat {
    flex-basis: 100%;
  }

  .gauge {
    width: 140px;
    height: 140px;
  }

  .gauge-inner {
    width: 114px;
    height: 114px;
  }

  .gauge-value {
    font-size: 24px;
  }

  .period-caption {
    min-width: 0;
  }

  .table-wrap {
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 480px) {
  .app-nav-brand {
    font-size: 16px;
  }

  .app-nav-username {
    display: none;
  }

  .auth-card {
    padding: var(--space-4);
  }
}

/* =================================================================================
   Food search — mobile-first cards (style reference: the user's previous tracker).
   Pill search field, meal picker, one compact card per food with a round add
   button; tapping a card opens its nutrition panel and amount controls.
   ================================================================================= */

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.search-pill {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--surface-muted);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 0 var(--space-2) 0 var(--space-4);
  color: var(--text-muted);
}

.search-pill:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-tint);
}

.search-pill input {
  border: 0;
  background: transparent;
  margin: 0;
  padding: var(--space-3) 0;
  min-height: 46px;
  font-size: 16px;
  box-shadow: none;
  outline: none;
}

.search-pill input::-webkit-search-cancel-button {
  display: none;
}

.search-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  background: var(--border-strong);
  color: var(--surface);
  cursor: pointer;
}

.search-clear .btn-icon {
  width: 12px;
  height: 12px;
}

/* Segmented control (meal picker): one pill track, the active segment raised. */
.segmented {
  display: flex;
  gap: 2px;
  margin-top: var(--space-3);
  padding: 3px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}

.segmented button {
  flex: 1 1 0;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: var(--space-2) var(--space-1);
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.segmented button.is-active {
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

.search-group + .search-group,
.pinned-pick + .search-group {
  margin-top: var(--space-2);
}

.pinned-pick {
  margin-bottom: var(--space-3);
}

.search-group-more > summary {
  font-size: 13px;
  margin: var(--space-1) 0 var(--space-2) var(--space-4);
}

.search-group-more .food-card {
  margin-top: var(--space-2);
}

/* One food. */
.food-card {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.food-card.is-open {
  border-color: var(--border-strong);
}

.food-card-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
}

.food-card-row .search-thumb {
  margin-right: 0;
  border-radius: var(--radius-md);
}

.search-thumb-empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--text-muted);
}

.search-thumb-empty::after {
  content: none;
}

.food-card-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.food-card-name {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.food-card-label {
  display: inline-block;
  margin-left: var(--space-2);
  font-size: 11px;
  font-weight: 600;
  vertical-align: middle;
  color: var(--brand-dark);
  background: var(--brand-tint);
  border-radius: var(--radius-pill);
  padding: 1px var(--space-2);
}

.food-card-brand,
.food-card-meta {
  font-size: 14px;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.food-card-meta .store-badge {
  margin-left: var(--space-2);
}

.food-card-hint::before {
  content: " · ";
}

.food-card-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex: 0 0 auto;
}

/* Round add button — the card's primary action. */
.btn-round {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--bg);
  color: var(--brand-dark);
  cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--border);
}

.btn-round:hover {
  background: var(--brand-tint);
}

.btn-round .btn-icon {
  width: 20px;
  height: 20px;
}

/* Card details: nutrition panel + amount bar. */
.food-card-details {
  border-top: 1px solid var(--border);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.nutrition-panel {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) 2fr;
  align-items: center;
  gap: var(--space-4);
}

.nutrition-kcal {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.nutrition-kcal-value {
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.nutrition-kcal-label {
  font-size: 14px;
  margin-top: var(--space-1);
}

.nutrition-list {
  margin: 0;
  font-size: 14px;
}

.nutrition-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 1px 0;
}

.nutrition-row dt {
  margin: 0;
}

.nutrition-row dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.nutrition-row.is-sub dt {
  padding-left: var(--space-4);
  color: var(--text-muted);
}

.nutrition-row.is-sub dd {
  color: var(--text-muted);
}

.food-card-log {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.food-card-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin: 0;
}

.food-card-field select {
  width: auto;
  margin: 0;
}

.food-card-amount {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.food-card-amount input,
.food-card-amount select {
  margin: 0;
}

.food-card-amount .qty-input {
  flex: 1 1 5em;
  min-width: 4.5em;
}

.food-card-amount select {
  flex: 1 1 auto;
  width: auto;
}

.food-card-amount .btn {
  flex: 0 0 auto;
}

/* Phones: inputs below 16px make iOS Safari zoom the page on focus — one cause of
   having to zoom back out. Also keep every card inside the viewport width. */
@media (max-width: 720px) {
  input,
  select,
  textarea {
    font-size: 16px;
  }

  .nutrition-panel {
    grid-template-columns: 1fr 1.6fr;
  }

  .nutrition-kcal-value {
    font-size: 34px;
  }

  .segmented button {
    font-size: 13px;
  }
}

/* Saved meals / recipes — same nutrition panel + row language as food search. */
.savedMeal .card-header {
  flex-wrap: wrap;
  align-items: baseline;
}

.ingredient-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.ingredient-list > .section-title {
  margin-bottom: 0;
}

.ingredient-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}

.ingredient-row:last-child {
  border-bottom: 0;
}

.ingredient-row .search-thumb {
  margin-right: 0;
  border-radius: var(--radius-md);
}

.ingredient-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ingredient-list .food-card-amount {
  flex: 0 0 auto;
}

.ingredient-list .food-card-amount .qty-input {
  width: 5.5em;
  flex: 0 0 auto;
}

/* Log a saved meal: date / meal / multiplier / button, wrapping on phones. */
.log-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  align-items: end;
  gap: var(--space-3);
}

.log-bar label {
  margin: 0;
}

.recipe-edit > summary {
  font-weight: 600;
}

.recipe-edit[open] > summary {
  margin-bottom: var(--space-3);
}

.nutrition-row dd .incomplete {
  margin-left: 2px;
}

/* Nutrition editor (Edit nutrition / Create food) — the editable twin of the
   nutrition panel: same rows, same order, values as compact right-aligned inputs. */
.correct-food > summary {
  color: var(--brand-dark);
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.correct-food[open] > summary {
  margin-bottom: var(--space-3);
}

/* Grouped label/value rows, like a settings list. */
.form-rows {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
}

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
}

.form-row:last-child {
  border-bottom: 0;
}

.form-row > span:first-child {
  flex: 0 0 auto;
  color: var(--text-muted);
}

.form-row > input {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  border: 0;
  background: transparent;
  text-align: right;
  padding-right: 0;
}

.nutrition-input {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-1);
}

.nutrition-input input {
  width: 5.5em;
  margin: 0;
  min-height: 32px;
  padding: var(--space-1) var(--space-2);
  text-align: right;
}

.nutrition-input .text-muted {
  width: 1.8em;
  text-align: left;
}

.nutrition-panel-edit .nutrition-row {
  align-items: center;
  padding: 3px 0;
}

.nutrition-kcal-input {
  width: 100%;
  max-width: 6em;
  margin: 0;
  font-size: 32px !important;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 480px) {
  .nutrition-panel-edit {
    grid-template-columns: 1fr;
  }

  .nutrition-panel-edit .nutrition-kcal {
    flex-direction: row;
    justify-content: center;
    align-items: baseline;
    gap: var(--space-2);
  }
}

/* Today: logged foods/meals as rows (no table, no sideways scrolling). */
.meal-slot-total {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: baseline;
  column-gap: var(--space-2);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* The slot's protein next to its kcal: "611 kcal · 22.8 g protein". */
.meal-slot-protein {
  color: var(--text-muted);
  font-weight: 500;
}

.meal-slot-protein::before {
  content: "· ";
}

.entry-list {
  list-style: none;
  margin: var(--space-2) 0 0;
  padding: 0;
}

.entry-row {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}

.entry-row:last-child {
  border-bottom: 0;
}

.entry-main {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.entry-main .search-thumb {
  margin-right: 0;
  border-radius: var(--radius-md);
}

.entry-text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.entry-row .correct-food {
  margin: var(--space-2) 0 0 calc(44px + var(--space-3));
}

.entry-delete:hover {
  color: var(--danger, #c0392b);
}

@media (max-width: 720px) {
  /* A column that is noise on a small screen (e.g. raw timestamps). */
  .hide-on-phone {
    display: none;
  }

  /* Stacking table: each row becomes a small card of "label: value" lines
     (labels from each cell's data-label). Still a real <table> for a11y/tests. */
  .stack-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .stack-table,
  .stack-table tbody,
  .stack-table tr,
  .stack-table td {
    display: block;
    width: 100%;
  }

  .stack-table tr {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-3);
    margin-bottom: var(--space-2);
  }

  .stack-table tr[data-selected="true"] {
    border-color: var(--brand);
  }

  .stack-table td {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 3px 0;
    border: 0;
    text-align: right;
  }

  .stack-table td::before {
    content: attr(data-label);
    color: var(--text-muted);
    text-align: left;
  }

  .stack-table td:first-child {
    font-weight: 700;
  }
}

/* Generic food-type icons (style reference: the user's previous tracker) -- an emoji
   on a soft tinted round tile, sized like the photo thumbnails it stands in for. */
.search-thumb.food-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border-color: transparent;
  font-size: 22px;
  line-height: 1;
  --tone: var(--text-faint);
  background: color-mix(in srgb, var(--tone) 18%, var(--surface));
}
.search-thumb.food-icon::after { content: none; }
.food-icon.tone-red { --tone: #e5534b; }
.food-icon.tone-orange { --tone: #f08c2e; }
.food-icon.tone-yellow { --tone: #e8b923; }
.food-icon.tone-green { --tone: #46a76a; }
.food-icon.tone-blue { --tone: #3d8fd6; }
.food-icon.tone-brown { --tone: #a0703f; }
.food-icon.tone-purple { --tone: #8e63c7; }
.food-icon.tone-neutral { --tone: #8a948e; }

/* "1 serving = __ g" under the amount row, for a product with no serving size. */
.food-card-serving {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-top: var(--space-2);
}
.food-card-serving .food-card-amount { align-items: center; }

/* Added-to-meal confirmation on a food card: green check button, a short
   "Added to Breakfast" label and a brief highlight of the card. */
.btn-round.is-done {
  background: var(--brand);
  color: var(--brand-contrast);
  animation: added-pop 0.35s ease-out;
}
.food-card.is-added {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand) inset;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.food-card-added {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--brand-tint);
  color: var(--brand-dark);
  font-weight: 600;
  font-size: 12px;
}
@keyframes added-pop {
  0% { transform: scale(0.7); }
  70% { transform: scale(1.12); }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .btn-round.is-done { animation: none; }
}
.food-card-added:empty { display: none; }

/* "Log your new food" after creating a food (e.g. from a web lookup): the same
   meal/amount controls as a search card, its round Add button kept at a fixed
   size at the end of the amount row, and the same added-to-meal confirmation. */
.quick-add-panel .food-card-amount .btn-round {
  flex: 0 0 44px;
}
.quick-add-panel.is-added {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand) inset;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.quick-add-confirmation {
  margin: var(--space-2) 0 0;
}
.quick-add-confirmation:empty {
  display: none;
}

/* FatFork's own basic foods (generic entries with complete values). */
.food-card-basic {
  display: inline-flex;
  align-items: center;
  margin-left: var(--space-2);
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--brand);
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  vertical-align: middle;
}

/* The user's own foods: "Your foods" in search, the My foods page, verified badge. */
.food-card-verified {
  display: inline-flex;
  align-items: center;
  margin-left: var(--space-2);
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--brand);
  color: var(--brand-contrast);
  font-size: 11px;
  font-weight: 700;
  vertical-align: middle;
}
.my-foods-results { margin-bottom: var(--space-3); }
.my-foods-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  justify-content: space-between;
  margin: var(--space-3) 0;
}
.my-food-row .food-card-body { text-align: left; }
.my-food-missing {
  display: block;
  color: var(--warning, #d08a1e);
  font-size: 12px;
  font-weight: 600;
}
.my-food-star { color: var(--brand-dark); flex: none; }
.my-food-merge select { width: 100%; }
.my-food-usage {
  display: block;
  color: var(--text-muted);
  font-size: 13px;
}
/* Filter pills span the card so "Incomplete"/"Verified" are not cut off on phones. */
.my-foods-controls .segmented { flex: 1 1 100%; display: flex; }
.my-foods-controls .segmented button { font-size: 13px; padding-inline: 2px; }

/* Barcode scanning: the button in the search pill, the camera sheet, the result. */
.search-scan {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  background: var(--brand);
  color: var(--brand-contrast);
  cursor: pointer;
}
.scanner-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
}
.scanner-sheet {
  width: 100%;
  max-width: 520px;
  max-height: 100dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom));
  background: var(--surface);
  border-radius: var(--radius-lg, 16px) var(--radius-lg, 16px) 0 0;
}
.scanner-header { display: flex; align-items: center; justify-content: space-between; }
.scanner-header h3 { margin: 0; }
.scanner-view {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.scanner-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; }
.scanner-view.is-live .scanner-video { opacity: 1; }
.scanner-frame {
  position: absolute;
  left: 12%;
  right: 12%;
  top: 32%;
  bottom: 32%;
  border: 3px solid var(--brand);
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
}
.scanner-message { position: relative; color: #fff; padding: var(--space-4); text-align: center; margin: 0; }
.scanner-photo { position: relative; text-align: center; }
.scanner-typed { display: flex; gap: var(--space-2); }
.scanner-typed input { flex: 1 1 auto; min-width: 0; }
.scan-result {
  border: 1px solid var(--brand);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
}
.scan-result-header { display: flex; align-items: center; justify-content: space-between; }
.scan-result-header .section-title { margin: 0; }
.scan-incomplete { color: var(--warning, #d08a1e); font-weight: 600; }

/* "Look up values online" inside the nutrition form. */
.online-lookup { margin: var(--space-3) 0; }
.online-lookup > summary { cursor: pointer; font-weight: 600; color: var(--brand-dark); }
.online-lookup-search { display: flex; gap: var(--space-2); margin: var(--space-3) 0; }
.online-lookup-search input { flex: 1 1 auto; min-width: 0; }
.online-candidate {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.online-candidate-head { display: flex; flex-direction: column; }
.online-candidate-site { font-weight: 700; color: var(--brand-dark); }
.online-candidate-notes { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.online-candidate-notes .is-good { color: var(--brand-dark); font-weight: 600; }
.online-candidate-notes .is-warn { color: var(--warning, #d08a1e); font-weight: 600; }

/* The web-search button beside the barcode button, and what it found. */
.search-web { background: var(--surface-muted); color: var(--brand-dark); border: 1px solid var(--brand); }
.search-web:disabled { opacity: 0.45; cursor: default; }
.web-results {
  border: 1px solid var(--brand);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
}

/* Fiber against the daily goal, right under the kcal gauge on Today. */
.fiber-progress {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  text-align: left;
}

.fiber-progress-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.fiber-progress-label {
  font-weight: 600;
  color: var(--text);
}

.fiber-progress-value {
  color: var(--text-muted);
}

.fiber-progress-value strong {
  font-size: 20px;
  color: var(--text);
}

.fiber-bar {
  height: 12px;
  border-radius: var(--radius-pill);
  overflow: hidden;
  background: var(--surface-muted);
  border: 1px solid var(--border);
}

.fiber-bar-fill {
  height: 100%;
  background: var(--macro-fiber);
  border-radius: var(--radius-pill);
  transition: width 0.3s ease;
}

.fiber-bar.is-reached .fiber-bar-fill {
  background: var(--brand);
}

.fiber-progress-note {
  font-size: 12px;
  color: var(--text-faint);
}

/* A recipe's name on the Meals page opens it for editing. */
.link-button {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.savedMeal-name:hover,
.savedMeal-name:focus-visible {
  color: var(--brand);
  text-decoration: underline;
}

.meals-search {
  margin-bottom: var(--space-3);
}

.card.is-editing {
  outline: 2px solid var(--brand);
  outline-offset: -1px;
}

/* "Read nutrition label (photo)" in the nutrition editor. */
.label-photo {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  margin: var(--space-2) 0;
}

.label-photo-text {
  white-space: pre-wrap;
  font-size: 12px;
  max-height: 200px;
  overflow: auto;
}

/* "Say what you ate" on Today. */
.quick-log-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
}

.quick-log-card textarea {
  width: 100%;
  resize: vertical;
}

.quick-log-label {
  font-weight: 600;
}

.quick-log-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
}

.quick-log-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border, #e5e5e5);
}

.quick-log-row.is-unmatched .quick-log-name {
  color: var(--text-faint);
}

.quick-log-name {
  flex: 1 1 140px;
}

.quick-log-amount {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* "Save as recipe" under the day's log on Today. */
.save-as-recipe {
  margin-top: var(--space-2);
}

.save-as-recipe-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Trends' period averages: two tiles per row on a phone, more on wider screens. */
#periodAverage .stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

/* Trends tiles: a small line per nutrient, each on its own scale. */
.sparkline {
  display: block;
  width: 100%;
  height: 36px;
  margin-top: var(--space-2);
}

.sparkline-line {
  stroke: var(--brand);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.sparkline-dot {
  fill: var(--brand);
}

.sparkline-goal {
  stroke: var(--warn);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
}
