/* Meals: wayfinding yellow for the page headers, quiet everywhere else. */
:root {
  --paper: #F4F6F8;
  --surface: #FFFFFF;
  --ink: #1C2430;
  --muted: #5B6676;
  --line: #D9DFE6;
  --signal: #FFC72C;
  --signal-ink: #1C2430;
  --focus: #1D5FA8;
  --danger: #B42318;

  --ok: #0F7B6C;
  --warn: #B45309;
  --accent: #5A4FCF;

  --radius-s: 6px;
  --radius-m: 10px;
  --body: "Atkinson Hyperlegible", system-ui, sans-serif;
  --display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12161D;
    --surface: #1B212B;
    --ink: #E8ECF1;
    --muted: #9AA5B4;
    --line: #2E3744;
    --focus: #7FB2F0;
    --danger: #F97066;
    --ok: #3CC3AE;
    --warn: #E8A04A;
    --accent: #A39BFF;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--body);
}
body.has-sheet { overflow: hidden; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.center { max-width: 34rem; margin: 20vh auto; padding: 0 16px; text-align: center; }
.error { color: var(--danger); }
.spacer { flex: 1; }

.display {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.25rem, 9vw, 3.5rem);
  line-height: 0.95;
  letter-spacing: -0.01em;
  margin: 0;
}
.h1 { font-family: var(--display); font-weight: 700; font-size: 2rem; line-height: 1.1; margin: 0; }
.h2 { font-family: var(--display); font-weight: 600; font-size: 1.4rem; line-height: 1.2; margin: 1.5rem 0 0.25rem; }

/* ---------- top bar ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-inner {
  max-width: 760px; margin: 0 auto; padding: 8px 16px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.brand { font-family: var(--display); font-weight: 700; font-size: 1.35rem; }
.home { font-size: 0.875rem; color: var(--muted); text-decoration: none; padding-right: 10px; border-right: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
@media (max-width: 520px) {
  .topbar-inner { row-gap: 4px; padding-bottom: 6px; }
  .brand { flex: 1; }
  .tabs { order: 3; flex-basis: 100%; }
  .tab { flex: 1 1 auto; text-align: center; padding: 6px 4px; font-size: 0.9375rem; }
}
@media (max-width: 400px) { .tab { font-size: 0.875rem; padding: 6px 2px; } }
.tab { padding: 6px 10px; border-radius: var(--radius-s); text-decoration: none; color: var(--muted); white-space: nowrap; }
.tab[aria-current="page"] { color: var(--ink); background: var(--paper); font-weight: 700; }

/* ---------- the yellow band ---------- */
.band { background: var(--signal); color: var(--signal-ink); }
.band-inner { max-width: 760px; margin: 0 auto; padding: 12px 16px 18px; }
.band-links { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.band .back { font-size: 0.875rem; text-decoration: none; opacity: 0.85; }
.band-edit { background: none; border: 1.5px solid var(--signal-ink); color: var(--signal-ink); border-radius: var(--radius-s); padding: 3px 10px; font-size: 0.875rem; font-weight: 700; cursor: pointer; }
.band .back::before { content: "‹ "; }
.band-sub { margin: 6px 0 0; font-weight: 700; }
.progress { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.progress-text { white-space: nowrap; }
.meter { display: block; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--ok); }
.meter-band { flex: 1; height: 12px; border-radius: 6px; background: rgba(28, 36, 48, 0.15); }
.meter-band > span { background: var(--signal-ink); transition: width 300ms ease; }
@media (prefers-reduced-motion: reduce) { .meter-band > span { transition: none; } }

/* ---------- pages ---------- */
.page { max-width: 760px; margin: 0 auto; padding: 20px 16px 96px; }
.page-trip { padding-top: 14px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.page > p { max-width: 62ch; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 16px; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 8px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--surface); text-decoration: none; cursor: pointer; font-weight: 700;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn-primary:hover { border-color: var(--ink); opacity: 0.9; }
.btn-quiet { background: transparent; }
.btn-danger { background: transparent; color: var(--danger); border-color: transparent; }
.btn-danger:hover { border-color: var(--danger); }
.btn-big { min-height: 52px; padding: 12px 22px; font-size: 1.1rem; }
.link { background: none; border: 0; padding: 4px; cursor: pointer; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px; cursor: pointer; }

/* ---------- sign-in ---------- */
.signin .band-hero { padding: 18vh 16px 28px; }
.signin .band-hero > * { max-width: 30rem; margin-left: auto; margin-right: auto; }
.signin .band-hero p { margin-top: 12px; font-size: 1.1rem; }
.signin-body { max-width: 30rem; margin: 0 auto; padding: 28px 16px; }

/* ---------- toolbars ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0 6px; }
.toolbar-2 { margin-top: 4px; }
.toolbar select, .toolbar .search, .form input, .form select, .form textarea, .lk-row input, .lk-row select, .lk-add input, .lk-add select {
  min-height: 40px; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface);
}
.toolbar .search { flex: 1 1 14rem; min-width: 0; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 4px; }

/* ---------- grouped rows ---------- */
.group { margin-top: 18px; }
.group-head {
  font-family: var(--display); font-weight: 600; font-size: 1.2rem; margin: 0 0 6px;
  display: flex; gap: 8px; align-items: baseline;
}
.group-head .muted { font-family: var(--body); font-weight: 400; font-size: 0.875rem; }
.rows { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
.row { display: flex; align-items: stretch; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row-open, .pick {
  flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0;
  padding: 10px 12px; background: none; border: 0; text-align: left; cursor: pointer;
}
.row-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.row-title { font-weight: 700; }
.row-meta { font-size: 0.875rem; color: var(--muted); }
.row-note { font-size: 0.8125rem; color: var(--muted); font-style: italic; }
.pick input { width: 20px; height: 20px; flex: none; }

.is-ticked .row-title { text-decoration: line-through; text-decoration-thickness: 2px; color: var(--muted); }
.is-off .row-title { color: var(--muted); }

/* ---------- forms ---------- */
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 4px; min-width: 0; }
.field > span { font-size: 0.875rem; font-weight: 700; }
.field input, .field select, .field textarea { width: 100%; }
.wide { grid-column: 1 / -1; }
@media (max-width: 340px) { .form { grid-template-columns: 1fr; } }

.sticky-actions {
  position: sticky; bottom: 0; margin: 20px -16px -96px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border-top: 1px solid var(--line);
}

/* ---------- sheet (dialog) ---------- */
#sheet { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.scrim { position: absolute; inset: 0; background: rgba(12, 16, 22, 0.45); }
.sheet {
  position: relative; width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto;
  background: var(--surface); border-radius: 14px 14px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  animation: rise 180ms ease-out;
}
@media (min-width: 700px) {
  #sheet { align-items: center; }
  .sheet { border-radius: 14px; }
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
.sheet-head { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 4px; }
.sheet-head .h2 { margin: 0; }
.sheet-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.sheet .rows { max-height: 52vh; overflow-y: auto; }

/* ---------- settings ---------- */
.lookup { margin-top: 12px; padding: 0; }
.lookup > summary { padding: 14px 16px; cursor: pointer; display: flex; align-items: baseline; gap: 8px; }
.lookup > summary .h2 { margin: 0; }
.lookup > :not(summary) { margin-left: 16px; margin-right: 16px; }
.lookup > form { margin-bottom: 16px; }
.lk-rows { list-style: none; margin-top: 10px; margin-bottom: 10px; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.lk-row { display: flex; gap: 8px; align-items: center; min-width: 0; }
.lk-row input { width: 0; }
.lk-row input { flex: 1; min-width: 0; }
.lk-row select { flex: 0 1 auto; min-width: 0; max-width: 45%; }
.lk-row input[readonly] { background: var(--paper); }
.lk-lock, .lk-row .link { flex: none; width: 4.25rem; text-align: right; }
.lk-add { display: flex; gap: 8px; flex-wrap: wrap; }
.lk-add input { flex: 1 1 10rem; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; top: calc(12px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 30;
  max-width: min(92vw, 30rem); padding: 10px 16px; border-radius: var(--radius-s);
  background: var(--ink); color: var(--paper); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
}
#toast[data-kind="error"] { background: var(--danger); color: #fff; }
@media (max-width: 520px) {
  .lk-row:has(select) { flex-wrap: wrap; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
  .lk-row:has(select) input { flex: 1 1 100%; }
  .lk-row:has(select) select { flex: 1 1 auto; max-width: none; }
}

/* ---------- shared bits ---------- */
.band-figures { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; margin-top: 10px; }
.band-figures strong { font-family: var(--display); font-size: 1.5rem; line-height: 1; margin-right: 4px; }
.band-cta { margin-left: auto; padding: 6px 14px; border-radius: var(--radius-s); background: var(--signal-ink); color: var(--signal); font-weight: 700; text-decoration: none; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 24px 0 8px; }
.section-head.first { margin-top: 6px; }
.section-head .h2 { margin: 0; }
.row-static { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; padding: 10px 12px; }
.row .link { flex: none; padding: 0 12px; }
.add-line { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.add-line input, .add-line select { flex: 1 1 10rem; min-width: 0; min-height: 40px; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); }
.add-line .qty, .add-line .unit { flex: 0 1 6rem; }
.add-line input[type="date"] { flex: 0 1 10rem; }
.ri-add input[name="name"] { flex: 2 1 10rem; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); gap: 12px 16px; margin: 0; }
.facts div { min-width: 0; }
.facts dt { font-size: 0.8125rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.notes-text { margin: 14px 0 0; white-space: pre-wrap; }
.ext { color: var(--focus); font-size: 0.875rem; }
.pill { flex: none; font-size: 0.75rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; white-space: nowrap; border: 1.5px solid var(--c, var(--muted)); color: var(--c, var(--muted)); background: var(--surface); }
.pill-draft { --c: var(--accent); }
.pill-soon { --c: var(--warn); }
.star { color: var(--warn); }
.field-label { display: block; font-size: 0.875rem; font-weight: 700; margin-bottom: 6px; }
.notice { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; padding: 10px 14px; border-left: 4px solid var(--accent); background: var(--surface); border-radius: var(--radius-s); }
.switcher { --c: var(--ink); display: flex; flex-wrap: wrap; gap: 6px; }
.switcher button {
  flex: 1 1 auto; min-height: 44px; padding: 6px 12px; cursor: pointer; font-weight: 700;
  border: 1.5px solid var(--line); color: var(--ink); background: var(--surface); border-radius: var(--radius-s);
}
.switcher button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ---------- plan: tick grid ---------- */
.tick-grid {
  display: grid; grid-template-columns: minmax(4.5rem, auto) repeat(var(--cols), minmax(0, 1fr));
  gap: 6px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 10px 12px;
}
.tg-head { font-size: 0.8125rem; font-weight: 700; text-align: center; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-day { font-weight: 700; white-space: nowrap; }
.tg-cell {
  justify-self: center; width: 100%; max-width: 64px; height: 40px; cursor: pointer;
  border: 2px dashed var(--line); border-radius: var(--radius-s); background: none;
}
.tg-cell.on { border: 2px solid var(--ink); }
.tg-cell.on::after { content: "✓"; font-weight: 700; }
.tg-cell.filled { background: var(--ink); color: var(--paper); }

/* ---------- plan: entries ---------- */
.entry-row { align-items: center; }
.slot-tag { flex: none; width: 5.5rem; padding: 0 0 0 12px; font-size: 0.8125rem; font-weight: 700; color: var(--muted); }
.entry-row .row-open { padding-left: 4px; }
.row-title.choose { color: var(--focus); font-weight: 700; }
.synergy { font-size: 0.8125rem; color: var(--ok); font-weight: 700; }
.pick-list { max-height: 48vh; overflow-y: auto; }
.is-current { background: var(--paper); }
@media (max-width: 400px) { .slot-tag { width: 4.6rem; } }

/* ---------- shopping list ---------- */
.store-head { font-size: 1.45rem; margin-top: 8px; }
.aisle-head { margin: 12px 0 4px; font-size: 0.8125rem; font-weight: 700; color: var(--muted); }
.item-row { align-items: stretch; }
.tick {
  flex: none; width: 52px; border: 0; border-right: 1px solid var(--line); background: none; cursor: pointer;
  display: grid; place-items: center; color: transparent; font-size: 1.3rem; font-weight: 700;
}
.tick span { display: grid; place-items: center; width: 28px; height: 28px; border: 2px solid var(--muted); border-radius: 6px; }
.tick[aria-pressed="true"] span { background: var(--ok); border-color: var(--ok); color: #fff; }
.is-ticked .row-title { text-decoration: line-through; text-decoration-thickness: 2px; color: var(--muted); }
.skipped { margin-top: 24px; }
.skipped .rows { margin: 0 16px 16px; }

/* ---------- recipes ---------- */
.qty-lead { font-variant-numeric: tabular-nums; color: var(--muted); }
.steps { margin: 0; padding: 14px 16px 14px 36px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
.steps li { margin: 0 0 10px; padding-left: 4px; }
.steps li:last-child { margin-bottom: 0; }

/* ---------- cupboard ---------- */
.use-soon .row-title { color: var(--warn); }
.pick { flex: 1; display: flex; align-items: center; gap: 12px; min-width: 0; padding: 10px 12px; cursor: pointer; }
.lk-check { flex: none; white-space: nowrap; }
