:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #faf8f4;
  --ink: #1e2420;
  --muted: #667069;
  --line: #e2ded5;
  --accent: #2c6a4a;
  --accent-ink: #ffffff;
  --accent-soft: #e3efe7;
  --warn: #8a5300;
  --warn-soft: #fbf1dd;
  --danger: #b0372d;
  --macro-p: #3477c9;
  --macro-c: #dba02c;
  --macro-f: #d7604a;
  --shadow: 0 1px 2px rgba(30, 36, 32, .06), 0 4px 14px rgba(30, 36, 32, .05);
  --radius: 12px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141715;
    --surface: #1d211e;
    --surface-2: #232825;
    --ink: #e7ebe7;
    --muted: #9aa49d;
    --line: #2f3632;
    --accent: #74c296;
    --accent-ink: #0e1a13;
    --accent-soft: #223429;
    --warn: #e8b869;
    --warn-soft: #33290f;
    --danger: #ef8478;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1, h2, h3, p, dl, dd, ul { margin: 0; padding: 0; }
ul { list-style: none; }
h1 { font-size: 26px; line-height: 1.2; letter-spacing: -.01em; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.spacer { flex: 1; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 10px 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: var(--ink); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); }
.tabs { display: flex; gap: 2px; flex-wrap: wrap; }
.tabs a { padding: 7px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 550; }
.tabs a:hover { color: var(--ink); background: var(--surface); }
.tabs a.is-current { color: var(--accent); background: var(--accent-soft); }

.view { max-width: 1320px; margin: 0 auto; padding: 24px 24px 80px; outline: none; }
.page { display: grid; gap: 18px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sub { color: var(--muted); max-width: 70ch; }
.page-head .sub { margin-top: 4px; }
.hint { color: var(--muted); }

/* ---------- buttons & inputs ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 6px 14px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--ink);
  font-weight: 550; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-small { min-height: 30px; padding: 3px 10px; font-size: 13px; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-quiet { color: var(--danger); background: transparent; border-color: transparent; }
.btn-danger-quiet:hover { border-color: var(--danger); }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none;
  border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
.icon-btn.is-on { background: var(--accent-soft); color: var(--accent); }

.input {
  width: 100%; min-height: 36px; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink);
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
textarea.input { resize: vertical; }

.field { display: grid; gap: 5px; min-width: 0; }
.field > span, fieldset legend { font-size: 13px; font-weight: 600; color: var(--muted); }
.field em { font-style: normal; font-weight: 400; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row > .field { flex: 1 1 160px; }
.field-row > .field-small { flex: 0 0 110px; }
.field-row > .field-grow { flex: 3 1 260px; }

/* ---------- shared pieces ---------- */

.thumb {
  width: 40px; height: 40px; flex: none; border-radius: 8px; object-fit: contain;
  background: #fff; border: 1px solid var(--line);
}
.thumb-empty { display: inline-block; background: var(--surface-2); }
.thumb-strip { display: flex; gap: 4px; min-height: 40px; overflow: hidden; }
.thumb-strip .thumb { flex: 0 1 40px; min-width: 0; width: auto; aspect-ratio: 1; height: auto; max-height: 40px; }

.macro-bar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--line); }
.macro-bar span { display: block; height: 100%; }
.macro-bar span + span { box-shadow: -1px 0 0 var(--surface); }
.macro-p { background: var(--macro-p); }
.macro-c { background: var(--macro-c); }
.macro-f { background: var(--macro-f); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
.macro-legend, .legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.macro-legend { margin-top: 6px; }

.pill { padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--accent); color: var(--accent-ink); }
.pill-quiet { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.pill-done { background: var(--accent-soft); color: var(--accent); }

.note-warn { padding: 8px 10px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-size: 13px; }

.stat { display: grid; gap: 1px; }
.stat-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat-label { font-size: 12.5px; color: var(--muted); }
.summary-strip, .stat-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 14px 20px;
  padding: 14px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.stat-row { padding: 0; border: 0; background: transparent; }

.link-title {
  padding: 0; border: 0; background: none; cursor: pointer; text-align: left;
  font-weight: 650; font-size: 15px; line-height: 1.25; color: var(--ink);
}
.link-title:hover { color: var(--accent); text-decoration: underline; }

.empty {
  display: grid; gap: 8px; justify-items: center; text-align: center;
  padding: 48px 20px; border: 1px dashed var(--line); border-radius: var(--radius); background: var(--surface);
}
.empty p { color: var(--muted); max-width: 52ch; }
.empty-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: grid; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { padding: 10px 14px; border-radius: 10px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow); font-size: 14px; }
.toast-error { background: var(--danger); color: #fff; }

/* ---------- week ---------- */

.week-nav { display: flex; align-items: center; gap: 6px; }
.week-label { display: grid; padding: 0 6px; }
.week-label strong { font-size: 22px; line-height: 1.2; letter-spacing: -.01em; }
.eyebrow { font-size: 12.5px; color: var(--muted); }

.week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px 10px; }
@media (max-width: 1180px) { .week-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); } }

/* Each day is a column: header, breakfast, lunch, dinner, day total. Subgrid keeps the meals lined up across days. */
.day-col { display: grid; grid-template-rows: subgrid; grid-row: span 5; min-width: 0; margin-bottom: 14px; }
.day-head { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; padding: 0 2px; }
.day-name { font-size: 12.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.day-num { font-size: 18px; font-weight: 700; }
.day-head .pill { margin-left: auto; }
.day-col.is-today .day-name, .day-col.is-today .day-num { color: var(--accent); }
.day-total { display: grid; gap: 1px; padding: 2px 2px 0; font-variant-numeric: tabular-nums; }

/* A meal on a day. Every part has a fixed height, so every cell on the schedule is the same size. */
.week-grid { --dish-h: 92px; }             /* one person: name, macro bar, buttons */
.week-grid.is-family { --dish-h: 120px; }  /* plus the row of initials */
.slot {
  display: flex; flex-direction: column; min-width: 0;
  padding: 10px 10px 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.slot.is-clickable { cursor: pointer; }
.slot.is-clickable:hover { border-color: var(--muted); }
.day-col.is-today .slot { border-color: var(--accent); }
.slot.is-cooked { background: var(--surface-2); }
.slot-empty { border-style: dashed; box-shadow: none; background: transparent; }
.slot-off { opacity: .7; }
.slot-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; height: 20px; margin-bottom: 6px; flex: none; }
.slot-meal { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

/* The space for one dish. A cell has one or two of these whether or not they are filled. */
.dish-cell {
  display: flex; flex-direction: column; gap: 6px; flex: none; min-width: 0;
  height: var(--dish-h); padding-top: 8px; border-top: 1px dashed var(--line); overflow: hidden;
}
.dish { cursor: pointer; }
.dish:hover h3 { color: var(--accent); text-decoration: underline; }
.dish.is-cooked .macro-bar { opacity: .55; }
.dish.is-cooked h3 { color: var(--muted); }
.dish.has-allergy h3 { color: var(--warn); }
.dish-top { display: flex; align-items: center; gap: 6px; height: 22px; flex: none; overflow: hidden; }
.dish-top .avatars { flex-wrap: nowrap; }
.dish h3 {
  flex: none; height: 35px; font-size: 14px; font-weight: 650; line-height: 17.5px;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
.dish .macro-bar { flex: none; }
.dish-none { flex: none; height: 35px; }
.dish-tools { display: flex; align-items: center; gap: 2px; flex: none; margin: 0 -4px; }
.dish-missing .dish-tools { gap: 6px; margin: 0; }
.icon-btn-sm { width: 26px; height: 26px; border-radius: 6px; }
.icon-btn-sm svg { width: 15px; height: 15px; }

/* "… 1 more" when a cell holds more than it has spaces for (households of three or more) */
.slot-more {
  flex: none; height: 22px; padding: 0; border: 0; border-top: 1px dashed var(--line); background: none;
  color: var(--muted); font-size: 13px; font-weight: 600; text-align: left; cursor: pointer;
}
button.slot-more:hover { color: var(--accent); text-decoration: underline; }

/* The cell's totals: one cost and one cost per 100 kcal, however many dishes it holds. */
.slot-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.slot-stats dt, .mini-stats dt { font-size: 11.5px; color: var(--muted); line-height: 1.2; }
.slot-stats dd, .mini-stats dd { font-weight: 650; font-variant-numeric: tabular-nums; }
.slot-total { flex: none; height: 42px; margin: 0; padding-top: 7px; border-top: 1px solid var(--line); overflow: hidden; }
.slot-empty .slot-total, .slot-empty .slot-more { border-top-color: transparent; }
.stat-value small { font-size: 13px; font-weight: 500; color: var(--muted); }

.avatars { display: inline-flex; gap: 3px; flex-wrap: wrap; }
.avatar-md { width: 36px; height: 36px; font-size: 15px; }
.avatar-sm { width: 22px; height: 22px; font-size: 11.5px; }
.avatar-xs { width: 18px; height: 18px; font-size: 10px; }
.avatar.av-0 { background: #dbe8f8; color: #1f4e8c; }
.avatar.av-1 { background: #f8dfd8; color: #9a3423; }
.avatar.av-2 { background: #dff0e3; color: #23653f; }
.avatar.av-3 { background: #f6e8c9; color: #7a5200; }
.avatar.av-4 { background: #e8ddf5; color: #5a2f91; }
.avatar.av-5 { background: #d9eef0; color: #1d616b; }
@media (prefers-color-scheme: dark) {
  .avatar.av-0 { background: #1f3552; color: #a9cbf5; }
  .avatar.av-1 { background: #4d241c; color: #f5b5a8; }
  .avatar.av-2 { background: #1f3f2b; color: #a3dcb6; }
  .avatar.av-3 { background: #46370f; color: #f0d089; }
  .avatar.av-4 { background: #38264f; color: #d0b5f2; }
  .avatar.av-5 { background: #173b40; color: #9fd9e0; }
}
.person-line { display: flex; align-items: center; gap: 6px; }
.off-target { color: var(--warn); font-weight: 600; }
.day-total .macro-bar { height: 6px; margin: 2px 0; }
.who { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.who-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.note-danger { padding: 8px 10px; border-radius: 8px; background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); font-size: 14px; }
.table tfoot th { padding: 8px 12px; border-top: 2px solid var(--line); font-size: 14px; text-transform: none; letter-spacing: 0; color: var(--ink); }
.dish-actions { justify-content: flex-start; }

.view-pick { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.view-pick .input { width: auto; min-width: 130px; font-weight: 600; color: var(--ink); }

.meal-rows { display: grid; gap: 8px; }
.meal-row { display: grid; grid-template-columns: 112px 92px minmax(0, 1fr); align-items: center; gap: 10px; }
.meal-row .chip { justify-content: center; }
.pct-input { display: inline-flex; align-items: center; gap: 4px; }
.pct-input .input { width: 68px; text-align: right; }
@media (max-width: 480px) { .meal-row { grid-template-columns: 104px 92px; } .meal-row > :last-child { grid-column: 1 / -1; } }

.pill-meal { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.pill-meal small { font-weight: 400; }
.meal-pills, .member-meals { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.chip-filter small { color: var(--muted); font-weight: 400; }
.chip-filter.is-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip.chip-meal:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ---------- recipes ---------- */

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card { display: flex; flex-direction: column; gap: 9px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.card-actions { display: flex; gap: 6px; margin-top: auto; }

.editor { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 18px 22px; }
.editor-main { display: grid; gap: 14px; align-content: start; min-width: 0; }
.editor-side { display: grid; gap: 10px; align-content: start; padding: 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); }
.editor-actions { grid-column: 1 / -1; }
@media (max-width: 760px) { .editor { grid-template-columns: 1fr; } }
.side-list { display: grid; gap: 4px; font-size: 13.5px; }
.side-list div { display: flex; justify-content: space-between; gap: 8px; }
.side-list dt { color: var(--muted); }
.side-list dd { font-weight: 600; font-variant-numeric: tabular-nums; }

.ing-list { display: grid; gap: 6px; }
.ing-empty { padding: 10px 0; }
.ing-row {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) 76px 150px 34px; align-items: center; gap: 4px 8px;
  padding: 7px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.ing-name { display: grid; min-width: 0; }
.ing-name strong, .ing-name small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ing-name small { color: var(--muted); font-size: 12.5px; }
.ing-row [data-remove] { grid-column: 5; grid-row: 1; }
.ing-line { grid-column: 2 / 5; grid-row: 2; font-variant-numeric: tabular-nums; }
.ing-line:empty { display: none; }
@media (max-width: 560px) {
  .ing-row { grid-template-columns: 64px minmax(0, 1fr) 34px; }
  .ing-row .thumb { grid-column: 1; grid-row: 1; }
  .ing-row .ing-name { grid-column: 2; grid-row: 1; }
  .ing-row [data-remove] { grid-column: 3; grid-row: 1; }
  .ing-row .ing-qty { grid-column: 1; grid-row: 2; padding-inline: 6px; }
  .ing-row .ing-unit { grid-column: 2 / 4; grid-row: 2; }
  .ing-line { grid-column: 1 / -1; grid-row: 3; }
}
.ing-add { margin-top: 8px; }

/* ---------- product search ---------- */

.picker { position: relative; }
.picker-menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20;
  max-height: 320px; overflow: auto; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
}
.picker-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border: 0; border-radius: 7px; background: none; text-align: left; cursor: pointer; }
.picker-item:hover, .picker-item.is-active { background: var(--accent-soft); }
.picker-text { display: grid; min-width: 0; }
.picker-text small { color: var(--muted); font-size: 12.5px; }
.picker-empty { padding: 12px; color: var(--muted); font-size: 13.5px; }
.add-bar { max-width: 560px; }

/* ---------- lists (inventory, grocery) ---------- */

.group { display: grid; gap: 6px; }
.group-title { font-size: 12.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.rows { display: grid; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 9px 12px; }
.row + .row { border-top: 1px solid var(--line); }
.row-main { display: grid; flex: 1; min-width: 0; }
.row-main small { font-size: 12.5px; }
.row-value { display: grid; min-width: 64px; font-weight: 650; }
.row-value small { font-weight: 400; font-size: 12px; }
.stepper { display: flex; align-items: center; gap: 4px; }
.qty-input { width: 68px; text-align: right; }
.unit { font-size: 13px; color: var(--muted); min-width: 24px; }

.check { display: grid; place-items: center; width: 28px; height: 28px; flex: none; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.buy-qty { color: var(--accent); font-variant-numeric: tabular-nums; }
.buy-row.is-checked .row-main strong { text-decoration: line-through; color: var(--muted); }
.buy-row.is-checked .buy-qty { color: var(--muted); }
.buy-row.is-checked .thumb { opacity: .5; }
.sticky-bar {
  position: sticky; bottom: 12px; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px 10px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 24px rgba(0, 0, 0, .14);
  font-variant-numeric: tabular-nums;
}
.covered summary { cursor: pointer; padding: 6px 0; color: var(--muted); font-weight: 600; }
.covered .rows { margin-top: 6px; }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { padding: 8px 12px; text-align: left; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.table th.num { text-align: right; }
.table td { padding: 8px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
.table-wrap:has(.table-narrow) { max-width: 460px; }
.cell-product { display: flex; align-items: center; gap: 10px; min-width: 240px; }
.cell-product span { display: grid; min-width: 0; }
.cell-actions { white-space: nowrap; text-align: right; }
.product-table .small { max-width: 240px; }
.is-gone td { opacity: .6; }
.table-foot { display: flex; align-items: center; gap: 12px; }
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-bar .input { flex: 1 1 220px; max-width: 420px; }

/* ---------- family ---------- */

.household { display: grid; gap: 10px; }
.stat-wide { grid-column: span 2; gap: 6px; min-width: 0; }
.household-allergies { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-warn small { font-weight: 400; }
.member-head { display: flex; align-items: center; gap: 10px; }
.member-head h3 { flex: 1; min-width: 0; font-size: 17px; overflow-wrap: anywhere; }
.avatar { display: inline-grid; place-items: center; flex: none; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; line-height: 1; }
.mini-stats-2 { grid-template-columns: 1fr 1fr; }
.member-grams { margin-top: 6px; }
.member-allergies { display: flex; gap: 5px; flex-wrap: wrap; margin-top: auto; }

.member-form { display: grid; gap: 16px; }
fieldset.plain { display: grid; gap: 10px; margin: 0; padding: 0; border: 0; min-width: 0; }
fieldset.plain legend { padding: 0; margin-bottom: 6px; color: var(--ink); font-size: 14px; }
.macro-fields > .field-grow { flex: 1 1 100%; }
.macro-fields > .field-pct { flex: 1 1 84px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; padding: 4px 12px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); cursor: pointer; font-size: 14px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:hover { border-color: var(--muted); }
.chip:has(input:checked) { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); font-weight: 600; }
.chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip-custom { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); font-weight: 600; cursor: default; padding-right: 4px; }
.chip-x { display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; }
.chip-x:hover { background: color-mix(in srgb, var(--warn) 18%, transparent); }
.chip-x svg { width: 14px; height: 14px; }
.add-allergy { display: flex; gap: 8px; max-width: 360px; }

/* ---------- dialogs ---------- */

.dialog {
  width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .3); overflow: hidden;
}
.dialog[open] { display: flex; flex-direction: column; }
.dialog-wide { width: min(900px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgba(15, 20, 17, .5); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 12px 12px 20px; border-bottom: 1px solid var(--line); }
.dialog-body { padding: 18px 20px 20px; overflow: auto; display: grid; gap: 14px; }
.dialog-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.detail { display: grid; gap: 12px; }
.detail h3 { margin-top: 6px; }
.notes { white-space: pre-wrap; color: var(--muted); }
.choice-list { display: grid; gap: 4px; }
.choice { display: grid; gap: 1px; width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); text-align: left; cursor: pointer; }
.choice:hover { border-color: var(--accent); }
.choice.is-current { background: var(--accent-soft); border-color: var(--accent); }
.product-form { display: grid; gap: 12px; }
.nutri { margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.nutri-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }

@media (max-width: 640px) {
  .topbar { position: static; padding: 8px 12px; gap: 8px; }
  .view { padding: 16px 12px 80px; }
  .row { flex-wrap: wrap; }
  .row-main { flex-basis: 60%; }
  .week-label strong { font-size: 18px; }
}

@media (prefers-reduced-motion: no-preference) {
  .btn, .icon-btn, .tabs a, .choice { transition: background-color .12s, border-color .12s, color .12s; }
}

/* ---------- recipes: search, include ticks, whole card opens details ---------- */
.recipe-tools { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; }
.recipe-search { flex: 1 1 240px; max-width: 340px; }
.include-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px 14px; flex-wrap: wrap; color: var(--muted); font-size: 13.5px; }
.include-bar strong { color: var(--ink); }
.include-bulk { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.recipe-card { cursor: pointer; }
.recipe-card:hover { border-color: var(--muted); }
.recipe-card:hover h3 { color: var(--accent); text-decoration: underline; }
.recipe-card h3 { font-weight: 650; font-size: 15px; line-height: 1.25; }
.recipe-card.is-included { border-color: var(--accent); }
.recipe-card:focus-visible, .dish:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card-actions { align-items: center; }
.include-check { display: inline-flex; align-items: center; gap: 7px; min-height: 30px; padding-right: 6px; font-weight: 600; font-size: 13.5px; cursor: pointer; }
.include-check input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); cursor: pointer; }

.pill-diet { background: var(--accent-soft); color: var(--accent); border: 1px solid transparent; }

/* ---------- estimated nutrition ---------- */
.est { margin-left: 2px; padding: 0 4px; border-radius: 4px; background: var(--warn-soft); color: var(--warn); font-size: 11px; font-weight: 600; white-space: nowrap; }
.note-est { padding: 6px 10px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 13px; }
.card .note-est { padding: 4px 8px; }

/* ---------- accounts ---------- */
.account { margin-left: auto; display: flex; align-items: center; }
.account-btn { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs[hidden] { display: none; }
.auth { display: grid; place-items: start center; padding: 6vh 0; }
.auth-card {
  display: grid; gap: 14px; width: min(100%, 400px); padding: 24px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 22px; }
.auth-card .btn-primary { justify-content: center; min-height: 40px; }
.auth-switch { text-align: center; }
.link { padding: 0; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; }
.note-danger[hidden] { display: none; }
