:root {
  /* Food-centric harvest palette: tomato, citrus, avocado, cream */
  --bg: #fff7ed;
  --bg2: #fffbeb;
  --ink: #431407;
  --muted: #9a3412;
  --line: #fed7aa;
  --brand: #ea580c;
  --brand2: #65a30d;
  --accent: #e11d48;
  --berry: #be123c;
  --honey: #d97706;
  --cream: #fff7ed;
  --danger: #b91c1c;
  --shadow: 0 10px 30px rgba(120, 53, 15, 0.12);
  --radius: 18px;
  --nav-h: 68px;
  --header-h: 68px;
  --max: 720px;
  --page-pad: 16px;
  /* The-Liquid-Diet.jpg — food-centric photo background for mobile PWA */
  --bg-image: url("bg-liquid-diet.jpg");
  --bg-scrim: linear-gradient(
    180deg,
    color-mix(in srgb, var(--bg) 72%, transparent) 0%,
    color-mix(in srgb, var(--bg) 58%, transparent) 35%,
    color-mix(in srgb, var(--bg) 78%, transparent) 100%
  );
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1008;
    --bg2: #2a1810;
    --ink: #fff7ed;
    --muted: #fdba74;
    --line: #7c2d12;
    --brand: #fb923c;
    --brand2: #a3e635;
    --accent: #fb7185;
    --berry: #f43f5e;
    --honey: #fbbf24;
    --cream: #292524;
    --danger: #f87171;
    --shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
    --bg-image: url("bg-liquid-diet.jpg");
    --bg-scrim: linear-gradient(
      180deg,
      color-mix(in srgb, var(--bg) 82%, transparent) 0%,
      color-mix(in srgb, var(--bg) 68%, transparent) 40%,
      color-mix(in srgb, var(--bg) 88%, transparent) 100%
    );
  }
}

*, *::before, *::after { box-sizing: border-box; }

html {
  margin: 0;
  padding: 0;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 20px);
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--bg);
  /* Photo + readability scrim — sized for mobile PWA viewport */
  background-image: var(--bg-scrim), var(--bg-image);
  background-size: cover, cover;
  background-position: center center, center center;
  background-repeat: no-repeat, no-repeat;
  /* scroll is more reliable on iOS PWAs than fixed */
  background-attachment: scroll, scroll;
}

/* Mobile PWA: keep photo framed to screen, avoid heavy fixed attachment */
@media (max-width: 720px) {
  body {
    background-size: cover, cover;
    background-position: center 30%, center 30%; /* favor upper subject on tall phones */
  }
}

/* Prefer fixed fill only on larger screens where it performs well */
@media (min-width: 721px) {
  body {
    background-attachment: fixed, fixed;
    background-position: center center, center center;
  }
}

/* Very small phones: ensure cover still fills without letterboxing */
@media (max-width: 380px) {
  body {
    background-size: cover, cover;
    background-position: center top, center top;
  }
}

/* Shared centered column */
.shell {
  width: 100%;
  max-width: var(--max);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--page-pad);
  padding-right: var(--page-pad);
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--brand);
  color: #fff;
  padding: 8px 12px;
  z-index: 100;
  border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 8px; top: 8px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ---------- Header (centered) ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: var(--header-h);
  background: color-mix(in srgb, var(--bg2) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  max-width: var(--max);
  margin: 0 auto;
  min-height: var(--header-h);
  padding: 10px var(--page-pad);
}

.logo {
  flex-shrink: 0;
}
.logo img {
  display: block;
  border-radius: 12px;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--brand) 25%, transparent);
}

.brand {
  flex: 1;
  min-width: 0;
  text-align: left;
}
.brandname {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.brandsub {
  margin: 2px 0 0;
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--ink);
  font-size: 1.1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover,
.icon-btn:focus-visible {
  border-color: var(--brand);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}

/* ---------- Quick search (centered) ---------- */
.quick-search {
  max-width: var(--max);
  margin: 0 auto;
  padding: 10px var(--page-pad) 0;
}
.quick-search input,
label input,
label select,
label textarea,
.form-grid input,
.form-grid select {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--ink);
  font: inherit;
}
.quick-search input:focus,
label input:focus,
label select:focus,
label textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent);
}

.search-results {
  margin-top: 6px;
  max-height: min(50vh, 360px);
  overflow: auto;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.search-results:empty { display: none; }
.search-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
}
.search-item:last-child { border-bottom: 0; }
.search-item:hover,
.search-item:focus-visible {
  background: color-mix(in srgb, var(--brand) 12%, transparent);
}
.search-item-main { font-weight: 600; }
.search-item-meta { font-size: 0.78rem; }
.search-empty { padding: 12px 14px; margin: 0; }
.search-detail {
  padding: 14px;
  text-align: left;
}
.search-detail-head {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  align-items: baseline;
  margin-bottom: 6px;
}
.search-detail .btn-row { margin-top: 10px; }

/* ---------- Bottom nav (centered pill) ---------- */
.tab-nav {
  position: fixed;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 90;
  width: min(var(--max), calc(100% - 20px));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  min-height: var(--nav-h);
  padding: 6px;
  background: color-mix(in srgb, var(--bg2) 94%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(15, 23, 42, 0.12);
  pointer-events: auto;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.62rem;
  cursor: pointer;
  border-radius: 14px;
  padding: 6px 2px;
  min-height: 48px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto;
  transition: background 0.15s ease, color 0.15s ease;
}
.tab .t-ico { font-size: 1.15rem; line-height: 1; }
.tab.active,
.tab[aria-current="page"] {
  color: var(--brand);
  font-weight: 700;
  background: color-mix(in srgb, var(--brand) 14%, transparent);
}

/* ---------- Main content (centered column) ---------- */
.wrap {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 18px var(--page-pad) 28px;
}

.panel {
  display: none;
  animation: fade 0.22s ease;
}
.panel.active {
  display: block;
}
@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .panel { animation: none; }
}

/* ---------- Cards ---------- */
.card {
  background: color-mix(in srgb, var(--bg2) 94%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  text-align: left;
}

/* Foldable cards (Home Daily Meals open; Plan / Nutrients / Settings all collapsed) */
.home-fold {
  padding: 0;
  overflow: hidden;
}
.home-fold .settings-block.schedule-inner {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.home-fold-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 12px;
  list-style: none;
  cursor: pointer;
  padding: 16px 20px;
  font: inherit;
  color: inherit;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.home-fold-summary::-webkit-details-marker { display: none; }
.home-fold-summary::marker { content: ""; }
.home-fold-summary::after {
  content: "▸";
  margin-left: auto;
  color: var(--brand);
  font-weight: 700;
  font-size: 0.95rem;
  transition: transform 0.15s ease;
}
.home-fold[open] > .home-fold-summary::after {
  transform: rotate(90deg);
}
.home-fold-title {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--ink);
}
.home-fold-hint {
  font-weight: 500;
  font-size: 0.82rem;
}
.home-fold-body {
  padding: 0 20px 18px;
  border-top: 1px solid color-mix(in srgb, var(--line) 85%, transparent);
  padding-top: 14px;
}
.home-fold-open h3 {
  margin-top: 0;
}
.home-fold .stat-grid {
  margin-bottom: 0;
}

.hero {
  text-align: center;
  padding: 28px 22px;
  background:
    radial-gradient(120% 100% at 50% 0%, color-mix(in srgb, var(--honey) 35%, transparent), transparent 55%),
    radial-gradient(100% 80% at 20% 100%, color-mix(in srgb, var(--brand2) 28%, transparent), transparent 55%),
    radial-gradient(90% 70% at 90% 80%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 50%),
    var(--bg2);
  border-color: color-mix(in srgb, var(--brand) 35%, var(--line));
}

.custom-meal-card {
  border-color: color-mix(in srgb, var(--brand2) 40%, var(--line));
  background:
    radial-gradient(100% 80% at 100% 0%, color-mix(in srgb, var(--brand2) 16%, transparent), transparent 50%),
    var(--bg2);
}
.custom-subhead {
  margin: 14px 0 6px;
  font-size: 1rem;
}
.search-pick {
  max-height: 160px;
  overflow: auto;
  padding: 4px 0;
}
.custom-meal-saved {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin: 8px 0;
  background: color-mix(in srgb, var(--bg) 45%, var(--bg2));
  text-align: left;
}
.custom-meal-saved h4 {
  margin: 0 0 6px;
  font-size: 1rem;
}
.custom-nut-heading {
  margin: 14px 0 4px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
}
.serving-grid {
  grid-template-columns: minmax(120px, 1fr) minmax(140px, 1fr);
}
.micro-form-grid {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.custom-meal-card input[type="number"] {
  width: 100%;
  min-height: 42px;
}

.restriction-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 12px 0;
}
.restriction-item {
  align-items: flex-start !important;
  gap: 12px !important;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg) 40%, var(--bg2));
  font-weight: 500 !important;
}
.restriction-item input {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  flex-shrink: 0;
}
.restriction-item strong {
  display: block;
  margin-bottom: 2px;
}
.restriction-item .meta {
  display: block;
  font-weight: 400;
}
.hero h2 {
  font-size: 1.55rem;
  margin-bottom: 8px;
}
.hero .lead {
  max-width: 34em;
  margin-left: auto;
  margin-right: auto;
}
.hero .btn-row {
  justify-content: center;
}

.lead { color: var(--muted); margin: 0 0 4px; }
.hint, .meta { color: var(--muted); font-size: 0.9rem; }
h2, h3, h4 {
  margin-top: 0;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; margin-bottom: 8px; }
.disclaimer {
  border-left: 4px solid var(--accent);
  text-align: left;
}

/* ---------- Buttons ---------- */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  justify-content: flex-start;
}
.card > .btn-row:first-of-type,
.hero .btn-row {
  margin-top: 16px;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.btn:hover,
.btn:focus-visible {
  border-color: var(--brand);
  outline: 2px solid color-mix(in srgb, var(--brand) 40%, transparent);
  outline-offset: 2px;
}
.btn.primary {
  background: linear-gradient(135deg, var(--brand), var(--honey));
  color: #fff7ed;
  border-color: transparent;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}
.btn.ghost { background: transparent; }
.btn.danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, var(--line));
}
.file-btn { display: inline-flex; align-items: center; justify-content: center; }

/* ---------- Forms ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 12px 0;
}
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 600;
}
label.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}
.block-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0;
  font-weight: 600;
}

/* ---------- Stats (centered) ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
@media (min-width: 520px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}
.stat {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 10px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat b {
  display: block;
  font-size: 1.4rem;
  color: var(--brand);
  letter-spacing: -0.02em;
}
.stat span {
  font-size: 0.78rem;
  color: var(--muted);
}

.steps-list {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--muted);
  text-align: left;
}
.steps-list li { margin: 8px 0; }

/* ---------- Meals ---------- */
.day-card { margin-bottom: 12px; }
.day-card h3 { margin-bottom: 8px; text-align: left; }
.meal {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
  background: color-mix(in srgb, var(--bg) 55%, var(--bg2));
  text-align: left;
}
.meal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.meal-actions { flex-shrink: 0; }
.meal-actions .btn { padding: 8px 12px; font-size: 0.8rem; }
.table-wrap { overflow-x: auto; margin: 8px 0; }
.nutrient-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.nutrient-table th,
.nutrient-table td {
  border-bottom: 1px solid var(--line);
  padding: 6px 8px;
  text-align: left;
}
.nutrient-table .num,
.nutrient-table th:not(:first-child),
.nutrient-table td:not(:first-child) { text-align: right; }
.nutrient-table tfoot th { font-weight: 700; }
.nutrient-total-card { margin-bottom: 12px; }
.nutrient-stats { margin: 10px 0 14px; }
.nutrient-ing,
.nutrient-meal,
.meal-nut-breakdown {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  margin: 8px 0;
  background: color-mix(in srgb, var(--bg) 40%, var(--bg2));
}
.nutrient-ing summary,
.nutrient-meal summary,
.meal-nut-breakdown summary {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-weight: 600;
}
.nutrient-ing-body { margin-top: 8px; }
.meal .slot {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.meal-title {
  margin: 4px 0;
  font-weight: 700;
  font-size: 1.05rem;
}
.meal-ing {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  justify-content: flex-start;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 11px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand) 12%, var(--bg2));
  border: 1px solid var(--line);
  font-size: 0.85rem;
}
.chip button {
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  font: inherit;
  padding: 0 2px;
}
.chip-row,
.chip-pick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
  justify-content: flex-start;
}
.chip-pick .chip { cursor: pointer; }

/* ---------- Grocery ---------- */
.grocery-controls { margin: 12px 0 8px; }
.grocery-cat { margin-bottom: 14px; }
.grocery-item-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  margin: 10px 0;
  background: color-mix(in srgb, var(--bg) 45%, var(--bg2));
  text-align: left;
}
.grocery-item-card.done {
  opacity: 0.72;
}
.grocery-item-card.done .grocery-item-title {
  text-decoration: line-through;
  color: var(--muted);
}
.grocery-item-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  margin: 0 0 8px;
}
.grocery-item-check input {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 3px;
}
.grocery-item-title { line-height: 1.3; }
.grocery-item-cost {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  align-items: baseline;
  margin: 0 0 8px;
  padding-left: 28px;
}
.cost-line { color: var(--brand); font-size: 0.95rem; }
.grocery-nav-block {
  padding: 8px 0 0 28px;
  border-top: 1px dashed color-mix(in srgb, var(--line) 80%, transparent);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.grocery-store-nav {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 35%, var(--bg2));
  text-align: left;
}
.grocery-store-nav.is-primary {
  border-color: color-mix(in srgb, var(--brand) 40%, var(--line));
  background: color-mix(in srgb, var(--brand) 8%, var(--bg2));
}
.grocery-store-nav-label {
  margin: 0 0 6px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
}
.grocery-store-nav-label strong {
  font-weight: 800;
  color: var(--brand);
}
.grocery-nav-primary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0;
}
.nav-pill {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand) 16%, var(--bg2));
  border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--line));
  color: var(--ink);
}
.nav-pill.subtle {
  font-weight: 600;
  background: color-mix(in srgb, var(--bg) 50%, var(--bg2));
  border-color: var(--line);
  color: var(--muted);
}
.grocery-nav-steps {
  margin: 6px 0 0;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
  text-align: left;
}
.grocery-nav-steps li { margin: 5px 0; }
.grocery-nav-steps strong {
  font-weight: 800;
  color: var(--brand);
}
.grocery-nav-tip { margin: 4px 0; }
.grocery-nav-alt { margin: 4px 0 0; opacity: 0.9; }
.grocery-cost-summary { margin-top: 12px; }
.cost-total-card {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--brand) 40%, var(--line));
  background: color-mix(in srgb, var(--brand) 10%, var(--bg2));
}
.cost-total-main {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}
.cost-figure {
  font-size: 1.35rem;
  color: var(--brand);
}
.grocery-map-panel {
  margin-top: 14px;
  padding: 14px !important;
}
.grocery-map-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.grocery-map-title {
  margin: 0;
  font-size: 1.05rem;
  text-align: left;
}
.grocery-map-toggles {
  margin: 0;
  gap: 6px;
}
.map-view-btn.active {
  background: color-mix(in srgb, var(--brand) 18%, transparent);
  color: var(--brand);
  font-weight: 700;
  border-color: color-mix(in srgb, var(--brand) 45%, var(--line));
}
.grocery-map-figure {
  margin: 10px 0 8px;
  padding: 0;
  text-align: center;
}
.grocery-map-img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  background: var(--bg2);
  cursor: zoom-in;
}
.grocery-map-figure figcaption {
  margin-top: 8px;
  text-align: left;
}
.grocery-nav-tips { margin-top: 12px; }
.grocery-tips-details summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--brand);
}
.grocery-tips-list {
  margin: 8px 0 0;
  padding-left: 1.2rem;
  text-align: left;
  color: var(--muted);
  font-size: 0.88rem;
}
.grocery-tips-list li { margin: 6px 0; }
.card-inset {
  margin: 10px 0 14px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 40%, var(--bg2));
}

/* ---------- Settings: Job Scheduling (uniform block) ---------- */
.settings-block {
  margin: 20px 0 28px;
  padding: 16px 16px 18px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 45%, var(--bg2));
  text-align: left;
}
.settings-block > h3 {
  margin: 0 0 8px;
  text-align: left;
}
.settings-explain-list {
  margin: 0 0 14px;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}
.settings-explain-list li { margin: 6px 0; }
.settings-explain-list strong { color: var(--ink); }

.schedule-status-card {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--line));
  background: color-mix(in srgb, var(--brand) 10%, var(--bg2));
}
.schedule-status-card .meta { margin: 0; }
.schedule-status-card strong { color: var(--brand); }

.schedule-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.schedule-option {
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  margin: 0;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg2);
}
.schedule-option input {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.schedule-option span {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.schedule-option strong {
  font-size: 0.95rem;
  color: var(--ink);
}
.schedule-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.schedule-time-grid {
  margin: 0;
}
.schedule-time-grid .block-label {
  margin: 0;
}
#scheduleTimePreview {
  margin: -4px 0 0;
}

.schedule-report-card {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.schedule-report-heading {
  margin: 0 0 6px;
  font-size: 1rem;
  text-align: left;
}
.schedule-report-list {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.schedule-run-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 40%, var(--bg2));
  font-size: 0.88rem;
}
.schedule-run-row .run-when {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.schedule-run-row .run-note {
  font-weight: 600;
  color: var(--ink);
}
.schedule-report-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

/* ---------- Ingredient grid (centered cells) ---------- */
.ing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.ing-card {
  background: color-mix(in srgb, var(--bg) 40%, var(--bg2));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  min-height: 120px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.ing-card:hover {
  border-color: color-mix(in srgb, var(--brand) 50%, var(--line));
}
.ing-card .ico { font-size: 1.65rem; }
.ing-card .name {
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.25;
}
.ing-card .cat {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: capitalize;
}
.ing-card .tags {
  font-size: 0.68rem;
  color: var(--muted);
}

/* Custom ingredient list + form helpers */
.custom-ing-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.custom-ing-row:last-child { border-bottom: none; }
.custom-ing-main {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  min-width: 0;
  flex: 1;
}
.custom-ing-main .ico { font-size: 1.35rem; line-height: 1.2; }
.compact-row { margin: 0; }
.ci-flags {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px !important;
}
.ci-flags .check {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg) 40%, var(--bg2));
}
.badge-custom {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand) 22%, transparent);
  color: var(--brand);
  vertical-align: middle;
  margin-left: 4px;
}
.restriction-grid.compact .restriction-item {
  padding: 10px 12px;
}
.custom-restriction-row {
  margin: 10px 0 4px;
}
.inline-add {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}
.inline-add input {
  flex: 1;
  min-width: 0;
}
.chip.rem {
  cursor: pointer;
}

/* ---------- Badges / game ---------- */
.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin: 10px 0;
}
.badge {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 10px;
  text-align: center;
  background: var(--bg2);
}
.badge.locked { opacity: 0.45; filter: grayscale(0.6); }
.badge .bi { font-size: 1.6rem; }
.leaderboard { list-style: none; padding: 0; margin: 0; }
.leaderboard li {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

/* ---------- Toast (centered) ---------- */
/* Must sit above .modal (z-index 200) so auth errors are visible on the login gate */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 28px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  z-index: 300;
  max-width: min(90vw, var(--max));
  text-align: center;
  box-shadow: var(--shadow);
  pointer-events: none;
}
.toast[data-kind="error"] {
  background: #9f1239;
  color: #fff;
}
.hide { display: none !important; }

.auth-error {
  display: none;
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, #e11d48 14%, var(--bg2));
  border: 1px solid color-mix(in srgb, #e11d48 45%, var(--line));
  color: #9f1239;
  font-size: 0.88rem;
  line-height: 1.35;
  text-align: left;
}
.auth-error.is-visible {
  display: block;
}
.auth-form .btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

/* ---------- Account ---------- */
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--ink);
  border-radius: 999px;
  padding: 4px 12px 4px 4px;
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  max-width: 140px;
}
.user-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.avatar {
  border-radius: 50%;
  object-fit: cover;
  background: var(--line);
  flex-shrink: 0;
}
.avatar.lg { width: 72px; height: 72px; }

/* Account panel (Settings) — matches Job Scheduling option cards */
.account-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}
.account-status-card {
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--line));
  background: color-mix(in srgb, var(--brand) 10%, var(--bg2));
}
.account-profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg2);
}
.account-profile-text {
  min-width: 0;
  flex: 1;
}
.account-name {
  margin: 0 0 4px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  word-break: break-word;
}
.account-email {
  margin: 0;
  word-break: break-all;
}
.account-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 0 0;
  border-top: 1px solid var(--line);
}
.account-section:first-of-type {
  border-top: 0;
  padding-top: 0;
}
.account-section-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  text-align: left;
  color: var(--ink);
}
.account-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.account-option {
  margin: 0;
}
.account-actions {
  margin: 0;
  flex-wrap: wrap;
}
.account-section-danger {
  padding-top: 14px;
}
.account-row {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 12px;
}

/* ---------- Meal steps ---------- */
.meal-steps {
  margin-top: 12px;
  border-top: 1px dashed var(--line);
  padding-top: 10px;
  text-align: left;
}
.meal-steps summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--brand);
}
.step-ol {
  margin: 8px 0 0;
  padding-left: 1.2rem;
  color: var(--muted);
}
.step-ol li { margin: 8px 0; }

/* ---------- Links / community ---------- */
.link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  justify-content: center;
}
.ext-link {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--brand);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  background: color-mix(in srgb, var(--brand) 8%, var(--bg2));
}
.ext-link:hover,
.ext-link:focus-visible {
  background: color-mix(in srgb, var(--brand) 16%, transparent);
}
.event-row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.community-post {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin: 8px 0;
  background: color-mix(in srgb, var(--bg) 50%, var(--bg2));
  text-align: left;
}
.community-post p { margin: 6px 0 0; }
.log-box {
  max-height: 200px;
  overflow: auto;
  font-size: 0.75rem;
  background: color-mix(in srgb, var(--ink) 92%, #000);
  color: #d1fae5;
  border-radius: 12px;
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  text-align: left;
}
.sec-list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: left;
}

/* ---------- Modal / Login gate (centered) ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal.hide { display: none !important; }

/* Full-screen login gate on first visit */
.modal.auth-gate {
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, color-mix(in srgb, var(--brand) 28%, transparent), transparent 55%),
    radial-gradient(ellipse 70% 50% at 50% 100%, color-mix(in srgb, var(--brand2) 18%, transparent), transparent 50%),
    var(--bg);
  backdrop-filter: none;
}
body.auth-locked .app-header,
body.auth-locked .tab-nav,
body.auth-locked .wrap,
body.auth-locked .quick-search {
  visibility: hidden;
  pointer-events: none;
}

.modal-card {
  position: relative;
  width: min(420px, 100%);
  margin: 0 auto;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px 22px;
  box-shadow: var(--shadow);
  max-height: 90dvh;
  overflow: auto;
  text-align: left;
}
.auth-gate-card {
  width: min(440px, 100%);
  padding: 28px 24px 24px;
}
.auth-brand {
  text-align: center;
  margin-bottom: 16px;
}
.auth-logo {
  display: block;
  margin: 0 auto 12px;
  border-radius: 14px;
  box-shadow: 0 4px 16px color-mix(in srgb, var(--brand) 30%, transparent);
}
.auth-brand h2 {
  margin: 0 0 6px;
  text-align: center;
}
.auth-tagline {
  margin: 0 auto;
  max-width: 28em;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.35;
  text-align: center;
}
.modal-card h2 { text-align: center; }
.modal-close {
  position: absolute;
  right: 12px;
  top: 10px;
  border: 0;
  background: transparent;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
}
.auth-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  justify-content: center;
}
.auth-tab {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
}
.auth-tab.active {
  background: color-mix(in srgb, var(--brand) 15%, transparent);
  color: var(--brand);
  font-weight: 700;
}
.auth-form label { margin-bottom: 10px; }
.auth-form .btn {
  margin-top: 8px;
  width: 100%;
  position: relative;
  z-index: 1;
  touch-action: manipulation;
  min-height: 48px;
}
.auth-form .btn:disabled {
  opacity: 0.7;
  cursor: wait;
}
.recover-hint {
  margin: 0 0 10px;
  text-align: left;
}
.rec-question {
  margin: 4px 0 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--brand) 8%, var(--bg2));
  border: 1px solid var(--line);
  min-height: 2.5em;
  text-align: left;
  color: var(--ink);
  font-weight: 600;
}
.rec-question.rec-question-loaded {
  border-color: color-mix(in srgb, var(--brand) 45%, var(--line));
}
/* Bottom nav: ensure always clickable above content */
.tab-nav {
  z-index: 90 !important;
  pointer-events: auto;
}
.tab-nav .tab {
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-height: 48px;
}

/* ---------- Nutrient bars ---------- */
.nutrient-bars {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 100%;
}
.nbar-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 5px;
  text-align: left;
}
.nbar-track {
  height: 11px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--line) 80%, var(--bg));
  overflow: hidden;
}
.nbar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--brand2));
  transition: width 0.25s ease;
}
.nbar-fill.over {
  background: linear-gradient(90deg, #f59e0b, #ef4444);
}
.subcard {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin: 10px 0;
  background: color-mix(in srgb, var(--bg) 50%, var(--bg2));
  text-align: left;
}

/* Settings section headings spacing */
#panel-settings h3 {
  margin-top: 22px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  text-align: left;
}
#panel-settings h3:first-of-type {
  margin-top: 8px;
  border-top: 0;
  padding-top: 0;
}

/* Wider desktop: keep content centered, slightly roomier */
@media (min-width: 720px) {
  :root {
    --max: 760px;
    --page-pad: 20px;
  }
  .tab span:not(.t-ico) { font-size: 0.72rem; }
  .brandsub { white-space: normal; }
  .user-chip { max-width: none; }
}

@media (min-width: 960px) {
  :root { --max: 800px; }
}
