/* Meal Planner — navy ink, egg-yolk yellow, index-card recipe cards.
   Green and red are reserved for "have" and "out". */

:root {
  --paper: #f4f6fa;
  --card: #ffffff;
  --ink: #1d2b4f;
  --ink-2: #44547a;
  --muted: #6a7591;
  --line: #dbe2ee;
  --rule: #b7c9e6;          /* index-card blue lines */
  --margin: #e39a9a;        /* index-card red header line (recipe cards only) */
  --yolk: #f4b41a;
  --yolk-ink: #5a3d00;
  --yolk-soft: #fff2c9;
  --have: #1f7f55;
  --have-soft: #e1f3e9;
  --out: #c23838;
  --out-soft: #fbe5e5;
  --shadow: 0 1px 0 rgba(29, 43, 79, .06), 0 6px 18px -10px rgba(29, 43, 79, .25);
  --r-sm: 8px;
  --r: 14px;
  --display: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --tabs-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f1629; --card: #172138; --ink: #e8edf7; --ink-2: #bdc7dc; --muted: #8b97b1; --line: #29355a;
    --rule: #33476f; --margin: #8c4b55; --yolk: #f6c033; --yolk-ink: #2a1d00; --yolk-soft: #3a3115;
    --have: #52c690; --have-soft: #15382a; --out: #f17a7a; --out-soft: #3d1d24;
    --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 8px 20px -12px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0f1629; --card: #172138; --ink: #e8edf7; --ink-2: #bdc7dc; --muted: #8b97b1; --line: #29355a;
  --rule: #33476f; --margin: #8c4b55; --yolk: #f6c033; --yolk-ink: #2a1d00; --yolk-soft: #3a3115;
  --have: #52c690; --have-soft: #15382a; --out: #f17a7a; --out-soft: #3d1d24;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 17px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 24px);
}
body.sheet-open { overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
:focus-visible { outline: 3px solid var(--yolk); outline-offset: 2px; border-radius: 6px; }
.ic { width: 22px; height: 22px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
b, strong { font-weight: 700; }

.view { max-width: 640px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 18px) 16px 0; }

/* header */
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
h1 { font: 800 34px/1 var(--display); letter-spacing: -.02em; margin: 0; }
.sub { margin: 6px 0 0; color: var(--muted); }
.top-actions { display: flex; gap: 6px; align-items: center; }
.icon-btn { width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 50%; color: var(--ink-2); }
.icon-btn:hover { background: var(--card); }
.icon-btn.sm { width: 36px; height: 36px; border: 1px solid var(--line); background: var(--card); }
.icon-btn.sm .ic { width: 18px; height: 18px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-weight: 700; color: var(--ink);
}
.btn .ic { width: 18px; height: 18px; }
.btn-quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-primary { background: var(--yolk); border-color: var(--yolk); color: var(--yolk-ink); }
.btn-primary[disabled] { opacity: .45; cursor: default; }
.btn-primary.armed { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn-on { background: var(--yolk-soft); border-color: var(--yolk); color: var(--ink); }
.link { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.link .ic { width: 16px; height: 16px; }

/* segmented control */
.seg { display: flex; gap: 4px; padding: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; margin: 4px 0 14px; }
.seg button { flex: 1; min-height: 40px; border-radius: 999px; font-weight: 700; color: var(--ink-2); }
.seg button[aria-selected="true"] { background: var(--ink); color: var(--paper); }
.seg-sm button { min-height: 36px; font-size: 15px; }
.seg-n { font-weight: 400; opacity: .7; font-size: 14px; }

/* plan */
.tallies { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.tally { font-size: 14px; padding: 3px 10px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--ink-2); }
.tally.over { border-color: var(--out); color: var(--out); }
.tally.miss { border-style: dashed; color: var(--muted); }
.days { display: flex; flex-direction: column; gap: 8px; }
.day {
  display: grid; grid-template-columns: 62px 1fr auto; gap: 12px; align-items: center; width: 100%; text-align: left;
  background: var(--card); border-radius: var(--r); padding: 14px 10px 14px 14px; box-shadow: var(--shadow); position: relative;
}
.day.is-today::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 4px; border-radius: 0 4px 4px 0; background: var(--yolk); }
.day-date { display: flex; flex-direction: column; line-height: 1.15; }
.dow { font: 800 19px/1.1 var(--display); letter-spacing: -.01em; }
.is-today .dow { color: var(--ink); }
.dnum { font-size: 14px; color: var(--muted); }
.day-title { font-weight: 700; font-size: 18px; line-height: 1.25; }
.day-sub { color: var(--muted); font-size: 15px; }
.day-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.day-off { background: transparent; box-shadow: none; border: 1.5px dashed var(--line); }
.day-end { display: flex; align-items: center; gap: 2px; color: var(--muted); }
.day-end .ic { width: 18px; height: 18px; }
.lock { color: var(--ink-2); }
.note { font-size: 14px; margin-top: 6px; }
.note-extra { color: var(--yolk-ink); background: var(--yolk-soft); display: inline-block; padding: 1px 8px; border-radius: 6px; }
.note-pair { color: var(--ink-2); }
.note-warn { color: var(--out); }
.hint { color: var(--muted); font-size: 15px; margin: 16px 2px; }
.top-hint { margin: 0 2px 12px; }

/* chips + badges */
.chip { font-size: 13.5px; line-height: 1; padding: 5px 8px; border-radius: 6px; background: var(--paper); color: var(--ink-2); white-space: nowrap; }
.chip-macro { color: var(--muted); }
.badge { display: inline-block; vertical-align: 2px; font: 700 12px/1 var(--body); padding: 4px 7px; border-radius: 5px; margin-left: 4px; }
.badge-stub { border: 1px dashed var(--muted); color: var(--muted); }
.badge-new { background: var(--yolk-soft); color: var(--yolk-ink); }

/* groceries */
.window { background: var(--card); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }
.window-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.stepper { display: inline-flex; align-items: center; gap: 8px; }
.window-meals { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 10px; font-size: 15px; color: var(--ink-2); align-items: center; }
.wm b { color: var(--ink); }
.wm-trip { display: inline-flex; align-items: center; gap: 4px; background: var(--yolk-soft); color: var(--ink); padding: 2px 4px 2px 10px; border-radius: 999px; }
.wm-trip button { display: grid; place-items: center; width: 26px; height: 26px; }
.wm-trip .ic { width: 15px; height: 15px; }
.add { display: flex; gap: 8px; margin: 0 0 12px; }
.add input, .search input, select {
  flex: 1; min-height: 46px; border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; background: var(--card); min-width: 0;
}
.progress { display: flex; gap: 16px; color: var(--ink-2); margin: 4px 2px 6px; font-size: 15px; }
.aisle { margin-top: 18px; }
.aisle h3, .sheet-h {
  font: 800 20px/1.2 var(--display); letter-spacing: -.01em; margin: 0 0 8px 2px; display: flex; align-items: baseline; gap: 8px;
}
.count { font: 700 13px/1 var(--body); color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px 8px; }
.items { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.item { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 10px 10px 10px 12px; border-top: 1px solid var(--line); min-height: 60px; }
.item:first-child { border-top: 0; }
.item-check, .item-have { grid-template-columns: 1fr auto; padding-left: 16px; }
.check { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--rule); display: grid; place-items: center; color: transparent; }
.check .ic { width: 18px; height: 18px; stroke-width: 3; }
.check.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.item-body { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; cursor: pointer; min-width: 0; }
.item-check .item-body, .item-have .item-body { cursor: default; }
.name { font-weight: 700; }
.amt { color: var(--ink-2); }
.srcs { flex-basis: 100%; font-size: 13.5px; color: var(--muted); line-height: 1.35; }
.item-cart .name, .item-cart .amt { text-decoration: line-through; color: var(--muted); }
.item-opt .name { font-weight: 400; }
.tag { font: 700 12px/1 var(--body); padding: 3px 6px; border-radius: 4px; }
.tag-out { background: var(--out-soft); color: var(--out); }
.tag-opt { border: 1px dashed var(--muted); color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); font-size: 14px; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.pill .ic { width: 16px; height: 16px; }
.pill-have { color: var(--have); border-color: color-mix(in srgb, var(--have) 40%, transparent); }
.pill-have:hover, .pill-have:active { background: var(--have-soft); }
.pill-out { color: var(--out); border-color: color-mix(in srgb, var(--out) 40%, transparent); }
.pill-on { background: var(--yolk-soft); border-color: var(--yolk); color: var(--ink); }
.item-have .name { color: var(--have); }
.fold { margin-top: 18px; }
.fold-head { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 2px; font: 800 18px/1.2 var(--display); color: var(--ink-2); }
.fold-head .ic { width: 18px; height: 18px; transition: transform .15s; }
.fold.open .fold-head .ic { transform: rotate(90deg); }
.fold-help { color: var(--muted); font-size: 15px; margin: 0 2px 10px; }
.finish { margin: 26px 0 8px; text-align: center; }
.finish .btn { width: 100%; min-height: 52px; font-size: 18px; }
.finish p { margin: 8px 12px 0; }
.empty { text-align: center; padding: 28px 16px; }
.empty p { margin: 4px 0; }

/* pantry */
.pantry-head p { margin: 0 2px 8px; color: var(--ink-2); }
.switch { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.switch input { width: 22px; height: 22px; accent-color: var(--ink); }
.pantry { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.p-row { width: 100%; min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 8px 10px 8px 12px; border-radius: 12px; background: var(--card); box-shadow: var(--shadow); text-align: left; border: 2px solid transparent; }
.p-name { font-weight: 700; font-size: 15.5px; line-height: 1.25; }
.p-state { font: 700 12px/1 var(--body); padding: 4px 7px; border-radius: 5px; flex: none; }
.p-have .p-state { background: var(--have-soft); color: var(--have); }
.p-out { border-color: var(--out); }
.p-out .p-state { background: var(--out); color: #fff; }
.p-cart .p-state { background: var(--yolk-soft); color: var(--yolk-ink); }

/* recipes */
.search { display: flex; align-items: center; gap: 8px; position: relative; margin-bottom: 10px; }
.search .ic { position: absolute; left: 13px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 40px; }
.filters { display: flex; gap: 6px; overflow-x: auto; padding: 2px 16px 10px; margin: 0 -16px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.fchip { flex: none; min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: 15px; color: var(--ink-2); }
.fchip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.recipes, .swap { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.r-row { display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding-right: 10px; }
.r-row.benched { opacity: .6; }
.r-main, .swap button, .current-card { flex: 1; display: flex; flex-direction: column; gap: 6px; text-align: left; padding: 14px; min-width: 0; }
.r-title { font-weight: 700; font-size: 17.5px; line-height: 1.3; }
.r-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.r-when { font-size: 14px; color: var(--muted); }
.swap button { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); width: 100%; }
.warns { font-size: 14px; color: var(--out); }

/* sheets */
.sheet { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(15, 22, 41, .45); animation: fade .18s ease-out; }
.sheet-panel {
  position: relative; width: 100%; max-width: 640px; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--paper); border-radius: 22px 22px 0 0; padding: 10px 16px calc(28px + env(safe-area-inset-bottom));
  animation: rise .22s cubic-bezier(.2, .8, .2, 1);
}
.sheet-recipe .sheet-panel { max-height: 100dvh; height: 100dvh; border-radius: 0; padding-top: calc(env(safe-area-inset-top) + 6px); }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet-panel, .sheet-backdrop { animation: none; } .fold-head .ic { transition: none; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0 10px; position: sticky; top: -10px; background: var(--paper); z-index: 2; }
.sheet-head h2 { font: 800 24px/1.15 var(--display); margin: 0; letter-spacing: -.01em; }
.sheet-head-card { top: calc(-6px - env(safe-area-inset-top)); }
.sheet-h { margin-top: 22px; }
.sheet-p { color: var(--ink-2); }
.current { margin-top: 6px; }
.current-card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); width: 100%; }
.row-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.row-actions .btn { flex: 1; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; border-bottom: 1px solid var(--line); }
.set-row select { flex: 0 1 180px; }
.set-row.switch { justify-content: space-between; }
.set-row .stepper b { min-width: 2ch; text-align: center; }

/* recipe card — the index card */
.card { background: var(--card); border-radius: 6px; box-shadow: var(--shadow); overflow: hidden; }
.card-head { padding: 20px 18px 18px; position: relative; }
/* index-card look: red header line under the title, blue ruled lines below */
.card-head h2 { padding-bottom: 10px; border-bottom: 2px solid var(--margin); }
.card-head::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 12px;
  background: repeating-linear-gradient(to bottom, var(--rule) 0, var(--rule) 1px, transparent 1px, transparent 6px);
  opacity: .7;
}
.card-kicker { margin: 0 0 4px; color: var(--ink-2); font-size: 15px; }
.card-head h2 { font: 800 32px/1.05 var(--display); letter-spacing: -.02em; margin: 2px 0 10px; text-wrap: balance; }
.card-head .badge { margin-left: 0; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 14px 0 0; background: var(--card); }
.facts div { background: var(--paper); border-radius: 8px; padding: 8px 10px; }
.facts dt { font-size: 13px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 700; font-size: 15px; }
.card-body { padding: 4px 18px 8px; }
.card-actions { padding: 8px 18px 18px; display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.file { padding: 0 18px 18px; margin: 0; }
.daypick { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.daypick button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); min-height: 64px; }
.daypick button span { font-size: 11px; color: var(--muted); line-height: 1.15; text-align: center; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.daypick button[aria-pressed="true"] { background: var(--yolk-soft); border-color: var(--yolk); }

/* markdown inside cards */
.md { max-width: 68ch; }
.md h2, .md h3 { font: 800 21px/1.2 var(--display); margin: 24px 0 8px; letter-spacing: -.01em; }
.md h3 { font-size: 17px; margin-top: 16px; color: var(--ink-2); }
.md h4 { margin: 14px 0 6px; }
.md p { margin: 8px 0; }
.md ul, .md ol { margin: 8px 0; padding-left: 22px; }
.md li { margin: 5px 0; }
.md ol li::marker { font-weight: 700; color: var(--ink-2); }
.md blockquote { margin: 12px 0; padding: 10px 12px; border-radius: 10px; background: var(--yolk-soft); color: var(--ink); font-size: 15.5px; }
.md code { background: var(--paper); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.md a { color: var(--ink); text-underline-offset: 3px; }
.table-wrap { overflow-x: auto; }
.md table { border-collapse: collapse; width: 100%; font-size: 15px; margin: 8px 0; }
.md th, .md td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); }
.md th { color: var(--muted); font-weight: 700; font-size: 13.5px; }
.md td:not(:first-child), .md th:not(:first-child) { text-align: right; white-space: nowrap; }

/* tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: center;
  background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs button { flex: 1; max-width: 213px; height: var(--tabs-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 13px; font-weight: 700; color: var(--muted); position: relative; }
.tabs button .ic { width: 40px; height: 28px; padding: 3px 9px; border-radius: 999px; }
.tabs button[aria-current="page"] { color: var(--ink); }
.tabs button[aria-current="page"] .ic { background: var(--yolk); color: var(--yolk-ink); }
.dot { position: absolute; top: 6px; left: calc(50% + 10px); font: 700 11px/1 var(--body); font-style: normal; background: var(--ink); color: var(--paper); border-radius: 999px; padding: 3px 6px; }

/* sync + toast */
.sync { position: fixed; right: 12px; top: calc(env(safe-area-inset-top) + 8px); z-index: 31; font-size: 13px; font-weight: 700; padding: 5px 10px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); color: var(--muted); }
.sync.ok { display: none; }
.sync.off { color: var(--out); }
#toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 14px); transform: translate(-50%, 20px); opacity: 0; z-index: 60; background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 12px; max-width: min(92vw, 520px); font-size: 15px; transition: opacity .2s, transform .2s; pointer-events: none; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* login + loading */
.loading { min-height: 70vh; display: grid; place-content: center; text-align: center; color: var(--ink-2); padding: 16px; }
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border-radius: 20px; padding: 28px 22px; box-shadow: var(--shadow); text-align: center; }
.login-card h1 { margin: 14px 0 6px; }
.login-card form { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.login-card input { min-height: 50px; border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; background: var(--paper); }
.login-card .btn { min-height: 50px; }
.err { color: var(--out); margin: 12px 0 0; }
.logo { width: 76px; height: 64px; margin: 0 auto; position: relative; background: #fff; border-radius: 52% 48% 55% 45% / 58% 52% 48% 42%; box-shadow: inset 0 0 0 2px var(--line); }
.logo::after { content: ""; position: absolute; width: 30px; height: 30px; border-radius: 50%; background: var(--yolk); left: 24px; top: 16px; box-shadow: inset -4px -4px 0 rgba(0, 0, 0, .08); }

@media (min-width: 560px) {
  .pantry { grid-template-columns: 1fr 1fr 1fr; }
  h1 { font-size: 40px; }
}

.source a { color: var(--ink-2); }
@media (max-width: 380px) { .seg button { font-size: 15px; } }
.set-row .stepper b { white-space: nowrap; }

/* breakfast / lunch / dinner switch on the plan */
.seg-meal { margin-top: 0; }
.sheet-kicker { margin: 0 0 2px; font-size: 14px; font-weight: 700; color: var(--muted); }
.window-more { margin: 10px 0 0; font-size: 14px; color: var(--muted); }
