/* Phones first: a tablet is secondary and there is no desktop requirement.
   Tap targets are sized for one hand on a trolley. */

:root {
  --bg: #fbfaf7;
  --fg: #23241f;
  --muted: #6b6d64;
  --line: #e0ded6;
  --accent: #2f6f4f;
  --warn: #9a5b1c;
  --warn-bg: #fdf3e6;
  --done: #9a9c92;
  --tap: 44px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171a; --fg: #e9e8e3; --muted: #9a9c94; --line: #2e3036;
    --accent: #6db98d; --warn: #e0a35e; --warn-bg: #2c2317; --done: #61635c;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(60px + env(safe-area-inset-bottom));
}

main { padding: 12px 16px 24px; max-width: 760px; margin: 0 auto; }
h1 { font-size: 1.25rem; margin: 8px 0 4px; }
h2 { font-size: 1rem; margin: 20px 0 4px; letter-spacing: .02em; }
h3 { font-size: .8rem; margin: 12px 0 2px; color: var(--muted); font-weight: 600;
     text-transform: uppercase; letter-spacing: .06em; }
p { margin: 4px 0; }
ul, ol { margin: 4px 0; padding-left: 0; list-style: none; }
ol { padding-left: 20px; list-style: decimal; }
small { color: var(--muted); }

/* --- status header ------------------------------------------------------ */

.status {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: max(8px, env(safe-area-inset-top)) 16px 8px;
}
.status.warn { background: var(--warn-bg); }
.status-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.phase { font-weight: 650; }
.sync { color: var(--muted); font-size: .82rem; }
.sync.stale { color: var(--warn); font-weight: 600; }
.roster { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 2px; }
.who { font-size: .78rem; color: var(--muted); }
.who.stale { color: var(--warn); font-weight: 600; }
.warn-text { color: var(--warn); font-size: .82rem; margin-top: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* --- controls ----------------------------------------------------------- */

button {
  min-height: var(--tap); padding: 0 14px;
  font: inherit; font-size: .9rem;
  background: transparent; color: var(--fg);
  border: 1px solid var(--line); border-radius: 10px;
  cursor: pointer;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.ghost { border: none; color: var(--muted); font-size: .82rem; min-height: 36px; padding: 0 8px; }
button.link { border: none; text-align: left; padding: 0; min-height: 36px; }
button:disabled { opacity: .4; }

input[type="search"] {
  width: 100%; min-height: var(--tap); padding: 0 12px; margin: 8px 0;
  font: inherit; background: transparent; color: var(--fg);
  border: 1px solid var(--line); border-radius: 10px;
}
input[type="checkbox"] { width: 26px; height: 26px; accent-color: var(--accent); flex: none; }

/* --- lists -------------------------------------------------------------- */

li { display: flex; align-items: center; gap: 10px; padding: 4px 0;
     border-bottom: 1px solid var(--line); min-height: var(--tap); }
li:last-child { border-bottom: none; }
.grow { flex: 1 1 auto; min-width: 0; }
label { display: flex; align-items: center; gap: 10px; flex: 1 1 auto; cursor: pointer; }
.name { flex: 1 1 auto; }
.qty { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .88rem; }
li.done .name { text-decoration: line-through; color: var(--done); }
li.done .qty { color: var(--done); }
.pref { font-size: .75rem; color: var(--accent); }
.count { color: var(--muted); font-size: .88rem; }
.hint { color: var(--muted); font-size: .84rem; }
.empty { color: var(--muted); padding: 16px 0; }
.since { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.servings { color: var(--muted); font-variant-numeric: tabular-nums; }

.group { margin-top: 16px; }
.aisle { margin-left: 2px; }

/* Carried over — a prompt, not a gate. Visually distinct so it reads as a
   reminder rather than as part of the list you are working. */
.carry { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin: 12px 0; }
.carry h2 { margin-top: 4px; }

.sel .status { font-size: .75rem; color: var(--muted); margin-left: 8px; }
.sel.carried .status { color: var(--warn); }
.sel.flagged { background: var(--warn-bg); }
.sel.flagged .status { color: var(--warn); font-weight: 600; }
.nudge { display: block; font-size: .75rem; color: var(--warn); }

.refusal { border: 1px solid var(--warn); background: var(--warn-bg);
           border-radius: 12px; padding: 12px; }
.close-report .ok { color: var(--accent); font-weight: 600; }
.problems { color: var(--warn); }

/* --- bottom navigation -------------------------------------------------- */

nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: flex; background: var(--bg); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
nav button { flex: 1; border: none; border-radius: 0; min-height: 56px; color: var(--muted); }
nav button.on { color: var(--accent); font-weight: 650; box-shadow: inset 0 2px 0 var(--accent); }

/* --- print: the list goes on the fridge door (§10.2) -------------------- */

@media print {
  :root { --bg: #fff; --fg: #000; --muted: #444; --line: #bbb; }
  .status, nav, button, input, .hint, .problems { display: none !important; }
  body { padding: 0; font-size: 11pt; }
  main { max-width: none; padding: 0; }
  h1 { font-size: 14pt; }
  h2 { font-size: 11pt; border-bottom: 1px solid var(--line); margin-top: 12pt; }
  h3 { font-size: 9pt; margin-top: 6pt; }
  li { min-height: 0; padding: 1pt 0; border-bottom: none; break-inside: avoid; }
  /* A tick box you can use with a pen, since this copy is on the door. */
  label::before { content: "☐"; margin-right: 6pt; }
  li.done label::before { content: "☑"; }
  input[type="checkbox"] { display: none; }
  .carry { border: 1px solid var(--line); }
}

/* --- settings ----------------------------------------------------------- */

.field { display: block; margin: 10px 0; }
.field > span { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 4px; }
.field input[type="text"] {
  width: 100%; min-height: var(--tap); padding: 0 12px;
  font: inherit; background: transparent; color: var(--fg);
  border: 1px solid var(--line); border-radius: 10px;
}
.ok { color: var(--accent); font-weight: 600; }

/* --- recipe editor ------------------------------------------------------ */

.title-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.editor .field input[type="number"], .editor textarea, .ing-row input, .ing-row select {
  font: inherit; background: transparent; color: var(--fg);
  border: 1px solid var(--line); border-radius: 10px; min-height: var(--tap); padding: 0 10px;
}
.editor .field input[type="number"] { width: 8em; }
.editor textarea { width: 100%; padding: 8px 10px; line-height: 1.4; }
.ing-rows { margin: 4px 0 8px; }
.unit-fixed { color: var(--muted); font-size: .88rem; padding-left: 4px; }
.version { color: var(--muted); font-size: .84rem; font-variant-numeric: tabular-nums; margin-top: 0; }

.failure pre { white-space: pre-wrap; word-break: break-word; font-size: .78rem; color: var(--muted);
               border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }

/* --- search with a filter, lists ---------------------------------------- */

.search-row { display: flex; gap: 8px; align-items: center; }
.search-row input[type="search"] { flex: 1 1 auto; min-width: 0; }
select.filter, .alloc select, .editor select {
  min-height: var(--tap); padding: 0 8px; font: inherit; font-size: .9rem;
  background: transparent; color: var(--fg); border: 1px solid var(--line); border-radius: 10px;
}
select.filter { flex: 0 1 11em; max-width: 45%; }
.actions.tight { margin-top: 0; }
.title-row { flex-wrap: wrap; }
.picker .free { background: var(--warn-bg); padding-left: 8px; border-radius: 8px; }

.athome { margin: 16px 0; border: 1px solid var(--line); border-radius: 12px; padding: 4px 12px; }
.athome summary, .setup-block summary, .grab summary { cursor: pointer; font-weight: 600; min-height: var(--tap);
  display: flex; align-items: center; gap: 8px; }
.keep-awake, .check { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: .9rem; }
.steps { list-style: decimal; padding-left: 20px; }
.steps li { display: list-item; border: none; min-height: 0; padding: 2px 0; }
.bookmarklet { display: inline-block; padding: 10px 16px; border-radius: 10px; background: var(--accent); color: #fff;
  text-decoration: none; font-weight: 600; cursor: grab; }
button.danger { color: var(--warn); border-color: var(--warn); margin-left: auto; }

/* --- editor additions --------------------------------------------------- */

.flags { display: flex; gap: 20px; margin: 10px 0; }
.flags label { flex: 0 0 auto; }
.editor input[type="url"] { width: 100%; min-height: var(--tap); padding: 0 12px; font: inherit;
  background: transparent; color: var(--fg); border: 1px solid var(--line); border-radius: 10px; }
.ing-item { border-bottom: 1px solid var(--line); padding: 4px 0; }
.web-line { font-size: .84rem; margin: 6px 0 0; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.chip { min-height: 34px; padding: 0 10px; border-radius: 17px; font-size: .84rem; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.new-ing { background: var(--warn-bg); border-radius: 10px; padding: 6px 8px; margin: 2px 0 6px; }
.alloc { display: flex; flex-wrap: wrap; gap: 6px; }
.alloc select { flex: 1 1 9em; min-width: 0; }
.ing-heading { display: flex; gap: 6px; align-items: center; padding: 10px 0 4px; border-bottom: 1px solid var(--line); }
.ing-heading .heading-name { flex: 1 1 auto; min-width: 0; font-weight: 650; min-height: var(--tap); padding: 0 10px;
  font: inherit; font-weight: 650; background: transparent; color: var(--fg); border: 1px dashed var(--line); border-radius: 10px; }

/* --- Setup blocks ------------------------------------------------------- */

.setup-block { border: 1px solid var(--line); border-radius: 12px; padding: 4px 12px; margin: 10px 0; }
.badge { font-size: .75rem; font-weight: 600; color: var(--warn); background: var(--warn-bg);
  border-radius: 10px; padding: 2px 8px; }
.staple-qty { width: 6em; min-height: 38px; padding: 0 8px; font: inherit; background: transparent; color: var(--fg);
  border: 1px solid var(--line); border-radius: 8px; }
.staple-add { display: flex; gap: 6px; margin: 8px 0; }
.staple-add input:first-child { flex: 1 1 auto; min-width: 0; min-height: var(--tap); padding: 0 10px; font: inherit;
  background: transparent; color: var(--fg); border: 1px solid var(--line); border-radius: 10px; }
.ingredients li.ing-edit { display: block; padding: 8px 0; }
.ing-edit.attention .ing-edit-name strong { color: var(--warn); }
.ing-edit .alloc { margin-top: 6px; }

/* --- the week's menu, printed for the fridge ---------------------------- */

.menu-print { display: none; }
@media print {
  body.print-menu main > section > *:not(.menu-print) { display: none !important; }
  body.print-menu .menu-print { display: block; }
  .menu-print h1 { font-size: 18pt; }
  .menu-print li { font-size: 13pt; padding: 6pt 0; border-bottom: 1px solid var(--line); }
  .menu-print .box { font-size: 16pt; margin-right: 8pt; }
  .athome:not([open]) { display: none; }
}

/* Editor line: two rows inside, each a flex line. */
.ing-row { display: block; padding: 4px 0; }
.ing-line { display: flex; gap: 6px; align-items: center; margin: 3px 0; }
.ing-line .ing-name { flex: 1 1 auto; min-width: 0; }
.ing-line .ing-desc { flex: 1 1 auto; min-width: 0; }
.ing-line .ing-qty, .ing-line .unit, .ing-line select, .ing-line .unit-fixed { flex: 0 0 5.5em; width: 5.5em; }
.ing-line .ghost { flex: none; min-width: 34px; padding: 0 4px; }
textarea { width: 100%; padding: 8px 10px; font: inherit; line-height: 1.4; background: transparent; color: var(--fg);
  border: 1px solid var(--line); border-radius: 10px; }
.staples .unit-fixed { flex: 0 0 3em; padding-left: 0; }
/* What a line is for, under its name: the recipes, staple, Wait List. */
.for { display: block; font-size: .75rem; color: var(--muted); line-height: 1.3; margin-top: 1px; }
li.done .for { color: var(--done); }
.list .qty, .list button.ghost { white-space: nowrap; flex: none; }
.list .name { min-width: 0; }
.folders li { flex-wrap: wrap; }
.folders li.current strong { color: var(--accent); }
.count-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.hide-done { margin: 0; font-size: .85rem; color: var(--muted); flex: none; }
.menu-print .menu-note { color: var(--muted); font-size: 10pt; }
@media print { .hide-done { display: none !important; } }
