/* Meal Prep — warm, kitchen-readable, dark-mode aware */
:root {
  --bg: #fbf5ec; --surface: #fffdf9; --surface2: #f6ebdc; --ink: #2b211b; --muted: #74655a;
  --accent: #c2562b; --accent-ink: #fff; --accent-soft: #f7dccb; --line: #eadcc9;
  --good: #3f7d3a; --warn: #b7791f; --lunch: #e0902f; --dinner: #c2562b; --breakfast: #d9a441;
  --shadow: 0 1px 2px rgba(80,40,10,.06), 0 6px 18px rgba(80,40,10,.08);
  --radius: 18px; --tap: 56px;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1612; --surface: #271f1a; --surface2: #322821; --ink: #f6ece2; --muted: #c0ae9f;
    --accent: #f08a4b; --accent-ink: #1c1612; --accent-soft: #4a2c1c; --line: #3d3129;
    --good: #8ccf7e; --warn: #f0c060; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.25);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 18px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent; min-height: 100vh; min-height: 100dvh;
}
a { color: var(--accent); }
button { font: inherit; color: inherit; }
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px;
  padding: calc(var(--sat) + 10px) calc(var(--sar) + 16px) 10px calc(var(--sal) + 16px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px); backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line); min-height: calc(var(--sat) + 60px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 20px; flex: 1; min-width: 0; }
.brand img { border-radius: 9px; flex: none; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { min-height: 44px; padding: 0 14px 0 8px; border: 0; border-radius: 12px; background: var(--surface2); font-weight: 650; color: var(--accent); cursor: pointer; }
.offline { font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 99px; background: var(--surface2); color: var(--muted); }
main { padding: 16px calc(var(--sar) + 16px) calc(var(--sab) + 104px) calc(var(--sal) + 16px); max-width: 760px; margin: 0 auto; outline: none; }
.loading { color: var(--muted); text-align: center; margin-top: 30vh; }
h1 { font-size: 28px; line-height: 1.2; margin: 6px 0 4px; letter-spacing: -.01em; }
h2 { font-size: 21px; margin: 26px 0 10px; }
.sub { color: var(--muted); margin: 0 0 16px; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: 13px; font-weight: 800; color: var(--muted); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin: 0 0 14px;
}
a.card { display: block; color: inherit; text-decoration: none; }
a.card:active { transform: scale(.99); }
.meal { border-left: 7px solid var(--accent); position: relative; }
.meal.lunch { border-left-color: var(--lunch); }
.meal.dinner { border-left-color: var(--dinner); }
.meal.breakfast { border-left-color: var(--breakfast); }
.meal h3 { font-size: 22px; line-height: 1.25; margin: 4px 0 6px; padding-right: 28px; }
.meal .go { position: absolute; right: 14px; top: 16px; font-size: 28px; color: var(--muted); line-height: 1; }
.meal p { margin: 0 0 12px; color: var(--muted); font-size: 16px; }
.macros { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.macro { background: var(--surface2); border-radius: 12px; padding: 8px 4px; text-align: center; }
.macro b { display: block; font-size: 20px; line-height: 1.2; }
.macro small { display: block; font-size: 12px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; }
@media (max-width: 380px) { .macro small { font-size: 10.5px; letter-spacing: 0; } }
.macro.kcal b { color: var(--accent); }
.total { background: linear-gradient(135deg, var(--accent-soft), var(--surface)); }
.total .big { font-size: 40px; font-weight: 800; line-height: 1.1; }
.total .big small { font-size: 18px; font-weight: 600; color: var(--muted); }
.status { display: inline-block; font-weight: 750; font-size: 15px; padding: 3px 10px; border-radius: 99px; margin-left: 6px; vertical-align: middle; }
.status.ok { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.status.off { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.bar { position: relative; height: 16px; background: var(--surface2); border-radius: 99px; margin: 14px 0 6px; overflow: hidden; }
.bar .seg { position: absolute; top: 0; bottom: 0; }
.bar .target { position: absolute; top: -2px; bottom: -2px; border-left: 2px dashed var(--ink); border-right: 2px dashed var(--ink); opacity: .55; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 14px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 14px; }
.btn {
  min-height: var(--tap); padding: 0 20px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex: 1;
  text-decoration: none; color: var(--ink);
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn:active { filter: brightness(.95); }
.progress { font-weight: 700; color: var(--muted); font-size: 15px; }
.section h2 { display: flex; justify-content: space-between; align-items: baseline; }
.section h2 small { font-size: 14px; color: var(--muted); font-weight: 650; }
.checklist { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.checklist li + li { border-top: 1px solid var(--line); }
.check { display: flex; align-items: flex-start; gap: 14px; padding: 14px 16px; min-height: 64px; cursor: pointer; user-select: none; -webkit-user-select: none; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.box {
  flex: none; width: 32px; height: 32px; border-radius: 10px; border: 2.5px solid var(--muted);
  display: grid; place-items: center; margin-top: 1px; transition: background .15s, border-color .15s;
}
.box svg { width: 20px; height: 20px; stroke: var(--accent-ink); stroke-width: 3.2; fill: none; opacity: 0; }
.check input:checked + .box { background: var(--accent); border-color: var(--accent); }
.check input:checked + .box svg { opacity: 1; }
.check input:focus-visible + .box { outline: 3px solid var(--accent); outline-offset: 2px; }
.check .txt { flex: 1; min-width: 0; }
.check .qty { font-weight: 750; }
.check .note { display: block; color: var(--muted); font-size: 15px; }
.check input:checked ~ .txt { text-decoration: line-through; text-decoration-thickness: 2px; color: var(--muted); }
.steps .num { flex: none; font-weight: 800; color: var(--accent); min-width: 22px; }
.notes { margin: 0; padding-left: 22px; }
.notes li { margin: 6px 0; }
.src { display: flex; align-items: center; gap: 8px; font-weight: 700; word-break: break-word; }
.weeks a.card { display: flex; align-items: center; gap: 14px; min-height: 76px; }
.weeks .when { flex: 1; }
.weeks .when b { display: block; font-size: 19px; }
.weeks .when span { color: var(--muted); font-size: 15px; }
.pill { font-size: 13px; font-weight: 800; padding: 4px 10px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); }
.pill.soft { background: var(--surface2); color: var(--muted); }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 6px calc(var(--sar) + 8px) calc(var(--sab) + 6px) calc(var(--sal) + 8px);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--line);
}
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 60px; border-radius: 14px; color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 700; }
.tabs a.on { color: var(--accent); background: var(--accent-soft); }
.ico { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ico .fill { fill: currentColor; stroke: none; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--sab) + 92px); transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 14px; font-weight: 700; transition: .25s; z-index: 20; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.err { color: var(--warn); }
.print-only { display: none; }
@media (min-width: 700px) { .macros { gap: 12px; } h1 { font-size: 32px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
  @page { margin: 12mm; }
  h1, h2 { break-after: avoid; }
  .checklist { break-inside: auto; }
  :root { --bg: #fff; --surface: #fff; --surface2: #f3f3f3; --ink: #000; --muted: #444; --line: #bbb; --accent: #000; --accent-ink: #fff; --shadow: none; }
  body { font-size: 12pt; background: #fff; color: #000; }
  .topbar, .tabs, .toast, .row, .back, .meal .go { display: none !important; }
  main { padding: 0; max-width: none; }
  .print-only { display: block; }
  .card, .checklist { box-shadow: none; }
  .card { break-inside: avoid; }
  .checklist li { break-inside: avoid; }
  .check { min-height: 0; padding: 6px 10px; }
  .box { width: 16px; height: 16px; border-width: 1.5px; border-radius: 3px; border-color: #000 !important; background: #fff !important; }
  .box svg { width: 12px; height: 12px; stroke: #000; }
  .check input:checked ~ .txt { color: #000; }
  .total { background: #fff; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 10pt; color: #444; }
}
