:root {
  --bar: #4a6785; --bar-text: #fff; --bg: #eef1f4; --card: #fff; --line: #d8dee5;
  --text: #1f2a35; --muted: #6b7885; --accent: #f28c00; --accent-soft: #ffe2b8;
  --sun: #d6283a; --day: #4a6785; --chip: #eaf1f8; --chip-text: #23466b; --noshop: #f1ecf7;
  --ok: #2e7d4f; --danger: #c0392b;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text); background: var(--bg);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { margin: 0; min-height: 100dvh; padding-bottom: calc(64px + var(--safe-b)); }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; font-size: 16px; } /* 16px stops iOS zoom-on-focus */
[hidden] { display: none !important; }

.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 4px;
  background: var(--bar); color: var(--bar-text); padding: calc(10px + var(--safe-t)) 8px 10px; }
.bar .title { flex: 1; text-align: center; line-height: 1.2; }
#title-main { font-size: 20px; font-weight: 600; }
#title-sub { font-size: 14px; opacity: .85; }
.icon { background: none; border: 0; color: inherit; font-size: 30px; width: 44px; height: 44px; border-radius: 22px; }
.icon.small { font-size: 13px; width: auto; padding: 0 10px; border: 1px solid rgba(255,255,255,.5); height: 30px; }
.icon:active { background: rgba(255,255,255,.15); }

/* ---- week grid: mirrors her calendar app (2 columns, Sunday first, mini month in the 8th cell) ---- */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); grid-auto-flow: column; grid-template-rows: repeat(4, auto); }
@media (min-width: 900px) { .grid { grid-auto-flow: row; grid-template-columns: repeat(4, 1fr); grid-template-rows: none; } }
.day { background: var(--card); min-height: 132px; padding: 8px 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.day.past { background: #f6f7f9; }
.day.past .dish { opacity: .75; }
.day.today { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.day-head { display: flex; align-items: baseline; gap: 6px; }
.day-num { font-size: 20px; font-weight: 600; }
.day-name { font-size: 16px; color: var(--day); }
.day.sun .day-num, .day.sun .day-name { color: var(--sun); }
.dishes { display: flex; flex-direction: column; gap: 5px; flex: 1; }
.dish { background: var(--chip); color: var(--chip-text); border-radius: 6px; padding: 7px 9px; font-size: 15px; text-align: left; border: 0; border-left: 4px solid #6d95bf; }
.dish.noshop { background: var(--noshop); border-left-color: #a58cc9; color: #4d3a6b; }
.add { border: 1px dashed #b9c4cf; background: none; color: var(--muted); border-radius: 6px; padding: 6px; font-size: 14px; }
.week-actions { display: flex; gap: 8px; padding: 10px; }
.week-actions button { flex: 1; }

.mini { background: var(--card); padding: 6px; }
.mini-head { background: var(--bar); color: #fff; text-align: center; padding: 4px; font-weight: 600; font-size: 15px; display: flex; justify-content: space-between; align-items: center; }
.mini-head button { background: none; border: 0; color: #fff; font-size: 20px; width: 32px; }
.mini table { width: 100%; border-collapse: collapse; text-align: center; font-size: 14px; }
.mini th { color: var(--muted); font-weight: 500; padding: 3px 0; }
.mini td { padding: 0; }
.mini td button { width: 100%; padding: 4px 0; border: 0; background: none; border-radius: 4px; }
.mini td.out button { color: #b7c0c9; }
.mini td.sun button { color: var(--sun); }
.mini tr.cur td { background: #e3ebf3; }
.mini td.today button { font-weight: 700; outline: 2px solid var(--accent); }

/* ---- grocery ---- */
.g-top { padding: 10px 12px; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.g-top .grow { flex: 1; }
.g-top .warn { color: var(--danger); }
.btn { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; }
.btn.primary { background: var(--bar); color: #fff; border-color: var(--bar); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 5px 9px; font-size: 13px; }
.section h3 { margin: 0; padding: 14px 14px 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.item { display: flex; align-items: center; gap: 12px; background: var(--card); border-bottom: 1px solid var(--line); padding: 12px 10px 12px 14px; }
.item .box { width: 24px; height: 24px; border-radius: 6px; border: 2px solid #9aa8b5; flex: none; display: grid; place-items: center; font-size: 16px; color: #fff; }
.item.done .box { background: var(--ok); border-color: var(--ok); }
.item.done .name { text-decoration: line-through; color: var(--muted); }
.item .main { flex: 1; min-width: 0; }
.item .name { font-size: 17px; }
.item .amount { color: var(--muted); font-size: 14px; margin-left: 6px; }
.item .src { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag-keep { background: #fff4d6; color: #8a5a00; border-radius: 4px; padding: 0 4px; }
.item .more { background: none; border: 0; font-size: 20px; color: var(--muted); padding: 4px 8px; }
details.staples summary { padding: 14px; color: var(--muted); font-size: 14px; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* ---- meals library ---- */
.search { padding: 10px; position: sticky; top: 0; }
.search input, .field input, .field textarea, .field select { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.row { display: flex; align-items: center; justify-content: space-between; background: var(--card); border-bottom: 1px solid var(--line); padding: 13px 14px; width: 100%; border-left: 0; border-right: 0; border-top: 0; text-align: left; }
.row .meta { color: var(--muted); font-size: 13px; }

/* ---- bottom sheet ---- */
#sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; }
#sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; background: var(--card); border-radius: 16px 16px 0 0;
  max-height: 88dvh; overflow: auto; padding: 14px 16px calc(18px + var(--safe-b)); box-shadow: 0 -4px 20px rgba(0,0,0,.15); }
@media (min-width: 700px) { #sheet { left: 50%; transform: translateX(-50%); width: 560px; bottom: 5vh; border-radius: 16px; } }
#sheet h2 { margin: 0 0 12px; font-size: 19px; }
#sheet .sub { color: var(--muted); font-size: 14px; margin: -8px 0 12px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field textarea { min-height: 120px; resize: vertical; }
.check { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }
.suggest { list-style: none; margin: 8px 0 0; padding: 0; }
.suggest li button { width: 100%; text-align: left; padding: 12px; border: 0; border-bottom: 1px solid var(--line); background: none; display: flex; justify-content: space-between; }
.suggest li button .meta { color: var(--muted); font-size: 13px; }
.suggest li.new button { color: var(--bar); font-weight: 600; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.quick button { border: 1px solid var(--line); background: var(--noshop); border-radius: 16px; padding: 6px 12px; font-size: 14px; }
.ing-list { margin: 0 0 12px; padding-left: 20px; }
.recipe { white-space: pre-wrap; background: #f6f7f9; border-radius: 8px; padding: 10px; font-size: 15px; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(76px + var(--safe-b)); background: #222; color: #fff;
  padding: 10px 16px; border-radius: 20px; z-index: 30; font-size: 14px; max-width: 90vw; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tabs button { flex: 1; border: 0; background: none; padding: 7px 0 9px; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabs button svg { display: block; }
.tabs button.active { color: var(--bar); font-weight: 600; }

/* ---- pairing / admin pages ---- */
.page { max-width: 460px; margin: 0 auto; padding: 40px 20px; }
.page h1 { font-size: 22px; }
.page p { color: var(--muted); line-height: 1.5; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; background: #fff; }
table.list td, table.list th { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; }
.mono { font-family: ui-monospace, monospace; word-break: break-all; background: #f6f7f9; padding: 10px; border-radius: 8px; }
