/* =============================================================
   Cut Plan — Week Builder
   Quiet, considered, editorial.
   Apple Notes × Linear × a Mediterranean menu at the back.
   ============================================================= */

:root {
  /* === Ground === */
  --bg: #f5f3ec;            /* warm paper */
  --bg-2: #efece3;          /* recessed */
  --surface: #fbfaf6;       /* card */
  --surface-2: #f1eee5;     /* sunken */

  /* === Hairlines === */
  --border: rgba(28, 22, 14, 0.08);
  --border-strong: rgba(28, 22, 14, 0.16);
  --border-faint: rgba(28, 22, 14, 0.04);

  /* === Ink === */
  --ink: #1c1a14;
  --ink-2: #4a463d;
  --ink-3: #8a857a;
  --ink-4: #b6b1a4;

  /* === Legacy alias (inline styles in app.js still reference --text-soft) === */
  --text-soft: var(--ink-3);

  /* === HIGH (carb-heavy) — warm ochre === */
  --high: #a8651e;
  --high-soft: #c1854a;
  --high-bg: rgba(168, 101, 30, 0.08);

  /* === LOW (carb-low) — slate === */
  --low: #3d6079;
  --low-soft: #6588a3;
  --low-bg: rgba(61, 96, 121, 0.08);

  /* === Status — quiet, never alarming === */
  --warn: #9a7929;
  --bad: #ad5a45;
  --treat: #5e7a4f;

  /* === Category accents === */
  --cat-core:    #8a857a;
  --cat-swap:    #6e4a96;
  --cat-freezer: #2f7561;
  --cat-snack:   #846a1a;

  /* === Type === */
  --font-display: "Fraunces", "Iowan Old Style", "Georgia", serif;
  --font-body: "Geist", -apple-system, BlinkMacSystemFont, "SF Pro Text", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* === Geometry === */
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 0 rgba(28, 22, 14, 0.02), 0 1px 1.5px rgba(28, 22, 14, 0.03);
  --shadow-lg: 0 24px 60px -22px rgba(28, 22, 14, 0.28),
               0 8px 22px -10px rgba(28, 22, 14, 0.10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection {
  background: rgba(168, 101, 30, 0.22);
  color: var(--ink);
}

/* Quiet, design-matched focus ring */
:focus { outline: none; }
:focus-visible {
  outline: 1.5px solid var(--ink);
  outline-offset: 2px;
  border-radius: 2px;
}
.tab:focus-visible,
.filter:focus-visible {
  outline-offset: 4px;
}
.slot:focus-visible {
  outline-offset: 1px;
}

/* =============================================================
   Buttons — generic baseline (overridden per-context)
   ============================================================= */
button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  color: var(--ink);
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.08s;
}
button:hover { background: var(--surface-2); border-color: var(--border-strong); }
button:active { transform: translateY(0.5px); }

/* =============================================================
   Header
   ============================================================= */
header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 32px 40px 22px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.title h1 {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 30px;
  letter-spacing: -0.025em;
  color: var(--ink);
  line-height: 1;
}
.title .subtitle {
  margin: 8px 0 0;
  color: var(--ink-3);
  font-size: 12px;
  letter-spacing: 0.005em;
}

/* Header buttons → ghost pills */
header .actions {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}
header .actions button {
  border: none;
  background: transparent;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.005em;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
}
header .actions button:hover {
  background: var(--surface-2);
  color: var(--ink);
}

/* =============================================================
   Tabs — text + underline indicator only
   ============================================================= */
nav.tabs {
  display: flex;
  gap: 0;
  padding: 0 40px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
nav.tabs::-webkit-scrollbar { display: none; }

.tab {
  border: none;
  background: none;
  padding: 16px 0;
  margin-right: 28px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-3);
  cursor: pointer;
  position: relative;
  letter-spacing: 0.005em;
  transition: color 0.15s;
  white-space: nowrap;
}
.tab:hover {
  color: var(--ink-2);
  background: none;
}
.tab.active {
  color: var(--ink);
  background: none;
}
.tab.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1.5px;
  background: var(--ink);
  border-radius: 1px;
}

/* =============================================================
   Layout
   ============================================================= */
main {
  padding: 28px 40px 80px;
  max-width: 1360px;
  margin: 0 auto;
}
.view { display: none; }
.view.active { display: block; }

/* =============================================================
   Hint banners — quiet metadata text, no card chrome
   ============================================================= */
.planner-hint, .shopping-hint {
  font-size: 12px;
  color: var(--ink-3);
  background: none;
  border: none;
  padding: 0 2px;
  margin-bottom: 22px;
  letter-spacing: 0.005em;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  line-height: 1.6;
}
.planner-hint .dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border: 1px dashed var(--ink-4);
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  background: transparent;
}
.hint-divider {
  color: var(--ink-4);
  margin: 0 6px;
}

/* =============================================================
   Week grid
   ============================================================= */
#week-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 32px;
}
@media (max-width: 1100px) {
  #week-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; }
}
@media (max-width: 700px) {
  #week-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}
@media (max-width: 460px) {
  #week-grid { grid-template-columns: 1fr; }
}

.day {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  box-shadow: var(--shadow-sm);
}

.day-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  cursor: pointer;
  margin: -2px -4px 4px;
  padding: 4px 6px;
  border-radius: 5px;
  transition: background 0.15s;
  gap: 8px;
}
.day-header:hover {
  background: var(--surface-2);
}
.day-header .day-name {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 19px;
  letter-spacing: -0.015em;
  color: var(--ink);
  line-height: 1;
}
/* Don't show the chevron-on-hover hack anymore */
.day-header:hover .day-name::after { content: none; }

.day-header .day-type {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0;
  background: none;
  border-radius: 0;
  line-height: 1;
}
.day-type.HIGH { color: var(--high); }
.day-type.LOW  { color: var(--low); }

/* =============================================================
   Slots
   ============================================================= */
.slot {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  cursor: pointer;
  font-size: 12px;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  min-height: 50px;
  position: relative;
  background: transparent;
}
.slot.empty {
  border-style: dashed;
}
.slot:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}
.slot.empty:hover {
  border-style: dashed;
}
.slot.selected {
  border: 1px solid var(--ink);
  border-style: solid;
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(28, 22, 14, 0.06);
}
.slot .slot-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  text-transform: uppercase;
  color: var(--ink-3);
  letter-spacing: 0.09em;
  line-height: 1;
}
.slot.empty .slot-meal {
  color: var(--ink-4);
  font-style: italic;
  margin-top: 4px;
  font-size: 12px;
}
.slot:not(.empty) .slot-meal {
  font-weight: 500;
  margin-top: 3px;
  color: var(--ink);
  font-size: 12.5px;
  line-height: 1.35;
  letter-spacing: -0.005em;
}
.slot .slot-sub {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 2px;
  line-height: 1.35;
  letter-spacing: 0.005em;
}
.slot:not(.empty)::after {
  content: "›";
  position: absolute;
  top: 7px;
  right: 10px;
  font-size: 14px;
  line-height: 1;
  color: var(--ink-4);
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
  font-family: var(--font-mono);
}
.slot:not(.empty):hover::after {
  opacity: 1;
  color: var(--ink-3);
  transform: translateX(1px);
}
.slot .slot-macros {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-3);
  margin-top: 5px;
  letter-spacing: 0.005em;
  font-variant-numeric: tabular-nums;
}

/* =============================================================
   Day-totals — quiet grid (color text only when off-target)
   ============================================================= */
.day-totals {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  padding-top: 11px;
  margin-top: auto;
  border-top: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.day-totals .stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 0;
  background: none;
}
.day-totals .stat .label {
  font-family: var(--font-mono);
  color: var(--ink-4);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 500;
  line-height: 1;
}
.day-totals .stat .value {
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  letter-spacing: -0.005em;
  line-height: 1.1;
}
/* No backgrounds. Color the number only when it nudges. */
.day-totals .stat.ok   .value { color: var(--ink-2); }
.day-totals .stat.warn .value { color: var(--warn); }
.day-totals .stat.bad  .value { color: var(--bad); }

/* =============================================================
   Weekly summary
   ============================================================= */
.summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 28px 18px;
  box-shadow: var(--shadow-sm);
}
.summary h2 {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 18px;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.summary-row {
  display: grid;
  grid-template-columns: 168px repeat(4, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  font-variant-numeric: tabular-nums;
  border-bottom: 1px solid var(--border-faint);
}
.summary-row:last-child { border-bottom: none; }
.summary-row .label {
  font-size: 12.5px;
  color: var(--ink-3);
  letter-spacing: 0.005em;
}
.summary-row .value {
  font-size: 13px;
  color: var(--ink-2);
  text-align: right;
  font-weight: 400;
  font-family: var(--font-mono);
  letter-spacing: 0.005em;
}
.summary-row.bold .label {
  font-weight: 500;
  color: var(--ink);
  font-family: var(--font-body);
}
.summary-row.bold .value {
  font-weight: 500;
  color: var(--ink);
}
.summary-row.target .label,
.summary-row.target .value { color: var(--ink-4); }
.summary-row.variance .value.ok   { color: var(--ink-3); }
.summary-row.variance .value.warn { color: var(--warn); }
.summary-row.variance .value.bad  { color: var(--bad); }
.summary-row.treat .label {
  color: var(--treat);
  font-weight: 500;
  font-family: var(--font-body);
}
.summary-row.treat .value {
  color: var(--treat);
  font-weight: 500;
}
/* The first row is column headers (rendered with inline styles by app.js).
   Override the family + tracking to keep them in our mono voice. */
.summary > .summary-row:first-of-type .value,
.summary > .summary-row:first-of-type .label {
  font-family: var(--font-mono);
  letter-spacing: 0.12em;
}

/* =============================================================
   Quick library accordion
   ============================================================= */
.quick-library {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 26px;
  box-shadow: var(--shadow-sm);
}
.quick-library summary {
  cursor: pointer;
  padding: 16px 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 12px;
}
.quick-library summary::-webkit-details-marker { display: none; }
.quick-library summary::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-top: 1.5px solid var(--ink-3);
  border-right: 1.5px solid var(--ink-3);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  flex-shrink: 0;
  margin-left: 1px;
}
.quick-library[open] summary::before {
  transform: rotate(135deg);
  margin-bottom: 2px;
}
.quick-library[open] summary {
  border-bottom: 1px solid var(--border);
}
#quick-meal-list { padding: 16px 0 22px; }

/* =============================================================
   Filters (Library tab) — pill buttons
   ============================================================= */
.filters {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.filter {
  font-size: 12px;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--ink-3);
  padding: 6px 12px;
  border-radius: 100px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  letter-spacing: 0.005em;
}
.filter:hover {
  background: var(--surface-2);
  color: var(--ink-2);
  border-color: transparent;
}
.filter.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.filter.active:hover {
  background: var(--ink);
  color: var(--bg);
}

/* =============================================================
   Meal cards
   ============================================================= */
.meal-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 10px;
}
.meal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: var(--radius);
  padding: 13px 16px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.meal-card.HIGH { border-left-color: var(--high-soft); }
.meal-card.LOW  { border-left-color: var(--low-soft); }
.meal-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px -4px rgba(28, 22, 14, 0.07);
}
.meal-card.HIGH:hover { border-left-color: var(--high); }
.meal-card.LOW:hover  { border-left-color: var(--low); }
.meal-card.disabled { opacity: 0.4; cursor: not-allowed; }
.meal-card.disabled:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--border);
}
.meal-card.disabled.HIGH:hover { border-left-color: var(--high-soft); }
.meal-card.disabled.LOW:hover  { border-left-color: var(--low-soft); }

.meal-card .name {
  font-weight: 500;
  font-size: 13.5px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  letter-spacing: -0.005em;
  color: var(--ink);
  line-height: 1.3;
}
.meal-card .tags {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  align-items: center;
}
.meal-card .tag {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  padding: 0;
  background: none;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  border-radius: 0;
}
.tag.HIGH    { color: var(--high); }
.tag.LOW     { color: var(--low); }
.tag.core    { color: var(--cat-core); }
.tag.swap    { color: var(--cat-swap); }
.tag.freezer { color: var(--cat-freezer); }
.tag.snack   { color: var(--cat-snack); }

.meal-card .desc {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.5;
  letter-spacing: 0.005em;
}
.meal-card .macros {
  display: flex;
  gap: 14px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  margin-top: 7px;
  padding-top: 10px;
  border-top: 1px solid var(--border-faint);
  letter-spacing: 0.005em;
  color: var(--ink-3);
}
.meal-card .macros span { color: var(--ink-3); }
.meal-card .macros .kcal {
  margin-left: auto;
  font-weight: 500;
  color: var(--ink);
}

/* =============================================================
   Day-detail modal
   ============================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 22, 14, 0.38);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 80px 24px 40px;
  z-index: 100;
  animation: fadeIn 0.2s ease-out;
}
.modal-overlay[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 700px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  animation: slideIn 0.28s cubic-bezier(0.2, 0.8, 0.3, 1);
}
@keyframes slideIn {
  from { transform: translateY(8px) scale(0.985); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 28px 16px;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
  border-bottom: 1px solid var(--border);
}
.modal-header .modal-title {
  display: flex;
  align-items: baseline;
  gap: 14px;
}
.modal-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 28px;
  letter-spacing: -0.025em;
  color: var(--ink);
  line-height: 1;
}
.modal-header .day-type {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: none;
  padding: 0;
  border-radius: 0;
}

.modal-header .modal-nav {
  display: flex;
  gap: 0;
  align-items: center;
}
.modal-header .modal-nav button {
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0;
  color: var(--ink-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background 0.15s, color 0.15s;
}
.modal-header .modal-nav button:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.modal-header .modal-nav button:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}
.modal-header .modal-nav button:disabled:hover {
  background: transparent;
  color: var(--ink-3);
}

/* CSS chevrons replace text content */
.btn-prev::before, .btn-next::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-top: 1.5px solid currentColor;
  border-right: 1.5px solid currentColor;
}
.btn-prev::before { transform: rotate(-135deg); margin-left: 3px; }
.btn-next::before { transform: rotate(45deg);   margin-right: 3px; }

.modal-close {
  background: transparent;
  border: none;
  font-size: 0;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  margin-left: 6px;
  position: relative;
  color: var(--ink-3);
  padding: 0;
  transition: background 0.15s, color 0.15s;
}
.modal-close::before, .modal-close::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 1.5px;
  background: currentColor;
  border-radius: 1px;
}
.modal-close::before { transform: translate(-50%, -50%) rotate(45deg); }
.modal-close::after  { transform: translate(-50%, -50%) rotate(-45deg); }
.modal-close:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.modal-body { padding: 6px 28px 14px; }

.modal-meal {
  padding: 22px 0;
  border-bottom: 1px solid var(--border);
}
.modal-meal:last-of-type { border-bottom: none; }

.modal-meal .meal-slot-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 4px;
}
.modal-meal .slot-name {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  text-transform: uppercase;
}
.modal-meal .meal-macros-inline {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.005em;
}
.modal-meal h3 {
  margin: 4px 0 8px;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 21px;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.2;
}
.modal-meal .meal-desc {
  font-size: 13px;
  color: var(--ink-2);
  margin-bottom: 14px;
  line-height: 1.6;
  letter-spacing: 0.005em;
}
.modal-meal .ingredients {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
}
.modal-meal .ingredients-title {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  text-transform: uppercase;
  margin-bottom: 10px;
}
.modal-meal .ingredients ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 28px;
}
@media (max-width: 540px) {
  .modal-meal .ingredients ul { grid-template-columns: 1fr; }
}
.modal-meal .ingredients li {
  font-size: 12.5px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  padding: 1px 0;
  letter-spacing: 0.005em;
}
.modal-meal .ingredients li .ing-item {
  color: var(--ink-2);
  flex-shrink: 1;
  min-width: 0;
}
.modal-meal .ingredients li .ing-qty {
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  flex-shrink: 0;
  white-space: nowrap;
  letter-spacing: 0.005em;
}
.modal-meal .empty-slot {
  color: var(--ink-3);
  font-style: italic;
  padding: 8px 0;
  font-size: 13px;
  font-family: var(--font-display);
}

.modal-totals {
  margin: 18px 0 6px;
  padding: 18px 22px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.modal-totals h4 {
  margin: 0 0 12px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.modal-totals table {
  width: 100%;
  font-variant-numeric: tabular-nums;
  border-collapse: collapse;
}
.modal-totals th, .modal-totals td {
  text-align: right;
  padding: 7px 8px;
  font-size: 12.5px;
  font-family: var(--font-mono);
  letter-spacing: 0.005em;
}
.modal-totals th:first-child, .modal-totals td:first-child {
  text-align: left;
  font-weight: 500;
  color: var(--ink-2);
  font-family: var(--font-body);
}
.modal-totals thead th {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.modal-totals tbody tr:first-child td { padding-top: 10px; }
.modal-totals td.var-ok   { color: var(--ink-2); }
.modal-totals td.var-warn { color: var(--warn); }
.modal-totals td.var-bad  { color: var(--bad); }
.modal-totals td.target   { color: var(--ink-4); }

/* =============================================================
   Meal-detail modal — slot-scoped view + swap
   ============================================================= */
.modal-header .modal-title.meal {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.modal-header .modal-title.meal .slot-context-row {
  display: flex;
  align-items: center;
  gap: 14px;
  line-height: 1;
}
.modal-header .modal-title.meal .slot-context {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.modal-header .modal-title.meal h2 {
  font-size: 22px;
  line-height: 1.2;
  /* allow long meal names to wrap rather than overflow the header */
  white-space: normal;
  overflow-wrap: anywhere;
}

.modal-meal.current {
  padding-top: 20px;
}
.modal-meal.current .meal-empty {
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--ink-3);
  font-style: italic;
  font-family: var(--font-display);
  font-size: 14px;
  text-align: center;
}

.meal-modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}
.btn-clear-slot {
  background: transparent;
  border: none;
  color: var(--ink-3);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.btn-clear-slot:hover {
  color: var(--bad);
  background: rgba(173, 90, 69, 0.06);
}

.meal-swap-section {
  padding: 22px 0 8px;
  border-top: 1px solid var(--border);
}
.modal-meal.current + .meal-swap-section {
  margin-top: 4px;
}
.meal-swap-title {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  text-transform: uppercase;
  margin-bottom: 14px;
}
.meal-swap-section .meal-list {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}
.meal-swap-section .meal-card {
  padding: 11px 14px;
}
.meal-swap-section .meal-card .name {
  font-size: 13px;
}
.meal-swap-section .meal-card .desc {
  font-size: 11.5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.meal-swap-section .meal-card.disabled {
  opacity: 0.55;
  cursor: pointer;
}
.meal-swap-empty {
  color: var(--ink-3);
  font-style: italic;
  font-family: var(--font-display);
  font-size: 13px;
  padding: 10px 0 4px;
}

/* =============================================================
   Build view — protein + main sides + supp sides editor
   ============================================================= */
.modal-meal.build-view { padding-top: 18px; }

.modal-meal.build-view .plate-origin {
  font-size: 11.5px;
  color: var(--ink-3);
  margin-bottom: 14px;
  letter-spacing: 0.005em;
}
.modal-meal.build-view .plate-origin em {
  font-family: var(--font-display);
  font-style: italic;
  color: var(--ink-2);
}

.totals-strip {
  display: flex;
  gap: 18px;
  align-items: baseline;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
  letter-spacing: 0.005em;
  margin-bottom: 18px;
}
.totals-strip .kcal {
  color: var(--ink);
  font-weight: 500;
  font-size: 13px;
  margin-right: auto;
}

.component-section {
  margin-bottom: 18px;
}
.component-section-title {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.component-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-bottom: 4px;
  transition: border-color 0.15s, background 0.15s;
}
.component-row:hover {
  border-color: var(--border);
  background: var(--surface-2);
}
.component-row.protein-row {
  border-color: var(--border);
  background: var(--surface);
}
.component-row .component-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.005em;
  line-height: 1.3;
  min-width: 0;
}
.component-row .component-macros {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  letter-spacing: 0.005em;
}
.component-row .component-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.btn-component {
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 9px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  line-height: 1.2;
}
.btn-component:hover {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--border-strong);
}
.btn-component.remove {
  font-size: 14px;
  font-weight: 400;
  padding: 0;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0;
  color: var(--ink-4);
}
.btn-component.remove:hover {
  color: var(--bad);
  background: rgba(173, 90, 69, 0.08);
  border-color: rgba(173, 90, 69, 0.3);
}

.component-empty {
  font-style: italic;
  color: var(--ink-4);
  font-family: var(--font-display);
  font-size: 12.5px;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
}

.btn-add-component {
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.005em;
  padding: 6px 12px;
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--ink-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-top: 4px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.btn-add-component:hover {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--ink-3);
}

.modal-meal.build-view .meal-modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  gap: 8px;
  flex-wrap: wrap;
}
.btn-pick-plate-link {
  background: transparent;
  border: none;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  letter-spacing: 0.005em;
  transition: color 0.15s, background 0.15s;
}
.btn-pick-plate-link:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.btn-copy-to-next {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--ink-2);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  letter-spacing: 0.005em;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  margin-right: auto;
}
.btn-copy-to-next:hover {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--ink-3);
}

/* Quick-pick / picker mirror checkbox */
.copy-to-next-lunch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--ink-2);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  letter-spacing: 0.005em;
  transition: border-color 0.15s, background 0.15s;
}
.copy-to-next-lunch:hover {
  border-color: var(--border-strong);
}
.copy-to-next-lunch input[type="checkbox"] {
  margin: 0;
  width: 14px;
  height: 14px;
  accent-color: var(--ink);
  cursor: pointer;
}
.copy-to-next-lunch span {
  line-height: 1.3;
}
.copy-to-next-lunch.picker-mirror {
  margin-bottom: 14px;
}

/* Empty-slot quick buttons */
.btn-pick-plate, .btn-pick-protein {
  font-size: 12px;
  font-weight: 500;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  letter-spacing: 0.005em;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-pick-plate:hover, .btn-pick-protein:hover {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

/* =============================================================
   Modified-from-template indicator
   ============================================================= */
.modified-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--high);
  vertical-align: middle;
}
.modified-dot.title-dot {
  margin-left: 8px;
  vertical-align: 0.18em;
}
.slot-meal .modified-dot {
  margin-left: 6px;
  width: 6px;
  height: 6px;
  vertical-align: 0.15em;
}
.modified-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--high);
  padding: 2px 8px;
  background: var(--high-bg);
  border-radius: 100px;
}

.plate-origin {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--ink-3);
  margin-bottom: 14px;
  letter-spacing: 0.005em;
}
.plate-origin em {
  font-family: var(--font-display);
  font-style: italic;
  color: var(--ink-2);
}
.variant-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 1px 7px;
  border-radius: 100px;
}
.variant-tag.high { color: var(--high); background: var(--high-bg); }
.variant-tag.low  { color: var(--low);  background: var(--low-bg); }

.btn-reset-template {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--ink-2);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  letter-spacing: 0.005em;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.btn-reset-template:hover {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--ink-3);
}

/* =============================================================
   Template cards (library + search modal)
   ============================================================= */
.template-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.template-card:hover {
  border-color: var(--border-strong);
  box-shadow: 0 4px 14px -4px rgba(28, 22, 14, 0.07);
}
.template-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.template-name {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 17px;
  letter-spacing: -0.015em;
  color: var(--ink);
  line-height: 1.2;
}

.variant-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.variant-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, transform 0.08s;
}
.variant-row:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
  box-shadow: 0 2px 8px -3px rgba(28, 22, 14, 0.06);
}
.variant-row:active {
  transform: translateY(0.5px);
}
.variant-row.current {
  border-color: var(--ink);
  background: var(--bg-2);
}

/* Chip is now a visual label (still a <button> for a11y but row owns the click). */
.variant-chip {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 5px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  pointer-events: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  line-height: 1;
}
.variant-chip.high {
  color: var(--high);
  background: var(--high-bg);
  border-color: rgba(168, 101, 30, 0.18);
}
.variant-chip.low {
  color: var(--low);
  background: var(--low-bg);
  border-color: rgba(61, 96, 121, 0.18);
}
/* Row hover lifts the chip to its bolder state */
.variant-row:hover .variant-chip.high {
  background: var(--high);
  color: var(--bg);
  border-color: var(--high);
}
.variant-row:hover .variant-chip.low {
  background: var(--low);
  color: var(--bg);
  border-color: var(--low);
}

.variant-summary {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.variant-desc {
  font-size: 11.5px;
  color: var(--ink-2);
  line-height: 1.4;
  letter-spacing: 0.005em;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.variant-macros {
  display: flex;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
  letter-spacing: 0.005em;
}
.variant-macros .kcal {
  margin-left: auto;
  font-weight: 500;
  color: var(--ink-2);
}
.variant-row .current-tag {
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 2px 7px;
  background: var(--surface-2);
  border-radius: 100px;
}

/* =============================================================
   Search view inside the meal modal
   ============================================================= */
.search-body { padding-top: 10px; }
.template-search {
  width: 100%;
  font: inherit;
  font-size: 14px;
  padding: 11px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  margin-bottom: 12px;
  letter-spacing: 0.005em;
}
.template-search::placeholder {
  color: var(--ink-4);
  font-style: italic;
}
.template-search:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(28, 22, 14, 0.06);
}

.search-filters {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.search-filter {
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--ink-3);
  padding: 5px 11px;
  border-radius: 100px;
  cursor: pointer;
  letter-spacing: 0.005em;
  transition: background 0.15s, color 0.15s;
}
.search-filter:hover {
  background: var(--surface-2);
  color: var(--ink-2);
}
.search-filter.active {
  background: var(--ink);
  color: var(--bg);
}
.search-filter.active:hover {
  background: var(--ink);
  color: var(--bg);
}

.search-body .meal-list {
  grid-template-columns: 1fr;
  gap: 8px;
}
@media (min-width: 720px) {
  .search-body .meal-list {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  }
}

/* =============================================================
   Picker sub-view — switching the modal body to a chooser
   ============================================================= */
.modal-header.picker .slot-context-row {
  align-items: center;
}
.btn-picker-back {
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 8px 4px 4px;
  border: none;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  border-radius: var(--radius-sm);
  margin-right: 4px;
  transition: color 0.15s, background 0.15s;
}
.btn-picker-back:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.picker-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
  padding: 4px 0 12px;
}
.picker-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s, background 0.15s;
}
.picker-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px -4px rgba(28, 22, 14, 0.07);
}
.picker-card.current {
  border-color: var(--ink);
  background: var(--bg-2);
}
.picker-card.current:hover {
  border-color: var(--ink);
}
.picker-card.dim {
  opacity: 0.55;
}
.picker-card-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.005em;
  line-height: 1.3;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.picker-card .current-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 1px 6px;
  background: var(--surface-2);
  border-radius: 100px;
}
.picker-card .tags {
  display: inline-flex;
  gap: 8px;
  margin-left: auto;
}
.picker-card .tag {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.picker-card-desc {
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.45;
  letter-spacing: 0.005em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.picker-card-macros {
  display: flex;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
  padding-top: 7px;
  border-top: 1px solid var(--border-faint);
  color: var(--ink-3);
}
.picker-card-macros .kcal {
  margin-left: auto;
  font-weight: 500;
  color: var(--ink);
}

/* On narrow screens, drop the macros column inline so rows stack */
@media (max-width: 540px) {
  .component-row {
    grid-template-columns: 1fr auto;
    gap: 6px 10px;
  }
  .component-row .component-macros {
    grid-column: 1 / -1;
    font-size: 10px;
  }
  .component-row .component-actions {
    grid-column: 2;
    grid-row: 1;
  }
}

/* =============================================================
   Shopping
   ============================================================= */
.shopping-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 28px 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.shopping-section h3 {
  margin: 0 0 14px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
.shopping-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.shopping-section li {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-faint);
  align-items: center;
  font-size: 13px;
  transition: opacity 0.2s;
}
.shopping-section li:last-child { border-bottom: none; }

/* CSS-drawn checkbox replaces unicode glyph */
.shopping-section .check {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 1.25px solid var(--border-strong);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  user-select: none;
  position: relative;
  font-size: 0;
  color: transparent;
  transition: border-color 0.15s, background 0.15s, transform 0.08s;
}
.shopping-section .check:hover {
  border-color: var(--ink-2);
}
.shopping-section .check:active { transform: scale(0.94); }
.shopping-section .check.checked {
  background: var(--ink);
  border-color: var(--ink);
}
.shopping-section .check.checked::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 5px;
  width: 4px;
  height: 8px;
  border-right: 1.5px solid var(--bg);
  border-bottom: 1.5px solid var(--bg);
  transform: rotate(45deg);
}
.shopping-section li:has(.check.checked) {
  opacity: 0.42;
}
.shopping-section li:has(.check.checked) .item {
  text-decoration: line-through;
  text-decoration-color: var(--ink-3);
  text-decoration-thickness: 1px;
}
.shopping-section .item {
  font-weight: 400;
  color: var(--ink);
  letter-spacing: 0.005em;
}
.shopping-section .qty {
  font-family: var(--font-mono);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  letter-spacing: 0.005em;
}
.shopping-empty {
  text-align: center;
  color: var(--ink-3);
  padding: 56px 20px;
  font-style: italic;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 400;
}

/* =============================================================
   Responsive — mobile / tablet polish
   ============================================================= */
@media (max-width: 900px) {
  header { padding: 24px 28px 18px; }
  nav.tabs { padding: 0 28px; }
  main { padding: 24px 28px 60px; }
  .summary { padding: 20px 24px 16px; }
  .shopping-section { padding: 20px 24px 16px; }
}

@media (max-width: 540px) {
  header {
    padding: 20px 20px 16px;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .title h1 { font-size: 26px; }
  header .actions {
    width: 100%;
    margin-left: -10px;
  }
  nav.tabs { padding: 0 20px; }
  .tab { margin-right: 22px; padding: 14px 0; }
  main { padding: 20px 20px 60px; }
  .summary { padding: 18px 20px 14px; }
  .summary-row {
    grid-template-columns: 110px repeat(4, 1fr);
    gap: 8px;
    font-size: 12px;
  }
  .summary-row .label { font-size: 11.5px; }
  .summary-row .value { font-size: 12px; }
  .shopping-section { padding: 18px 20px 14px; }
  .modal-overlay { padding: 32px 12px 20px; }
  .modal { border-radius: 12px; }
  .modal-header { padding: 18px 20px 14px; }
  .modal-header h2 { font-size: 24px; }
  .modal-body { padding: 4px 20px 10px; }
  .modal-meal { padding: 18px 0; }
  .modal-totals { padding: 14px 16px; }
}

/* =============================================================
   Login overlay
   ============================================================= */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 22, 14, 0.46);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  z-index: 200;
  animation: fadeIn 0.2s ease-out;
}
.login-overlay[hidden] { display: none; }

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 360px;
  padding: 28px 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: slideIn 0.28s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.login-card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 28px;
  letter-spacing: -0.015em;
  color: var(--ink);
  line-height: 1;
}
.login-card .login-sub {
  margin: 0 0 6px;
  color: var(--ink-3);
  font-size: 13px;
}
.login-card input[type="password"] {
  font: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.login-card input[type="password"]:focus {
  border-color: var(--ink-3);
  box-shadow: 0 0 0 3px rgba(28, 22, 14, 0.06);
}
.login-card button[type="submit"] {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 14px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity 0.15s;
}
.login-card button[type="submit"]:hover { opacity: 0.9; }
.login-card button[type="submit"]:disabled { opacity: 0.55; cursor: default; }
.login-error {
  font-size: 12px;
  color: var(--bad);
  margin-top: 2px;
}

/* =============================================================
   Sync status pill
   ============================================================= */
.sync-status {
  position: fixed;
  bottom: 14px;
  right: 16px;
  z-index: 90;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink-3);
  box-shadow: var(--shadow-sm);
  transition: opacity 0.2s;
}
.sync-status[hidden] { display: none; }
.sync-status.pending { color: var(--ink-3); }
.sync-status.ok      { color: var(--ink-2); }
.sync-status.err     { color: var(--bad); border-color: var(--bad); }

