/* Peachy Pantry: a peach gingham picnic cloth sprinkled with little flowers; paper cards sit on top.
   Phone first: one column, tabs under the thumb, edit sheets slide up from the bottom.
   Tablet (640px+): lists go two-up. Desktop (900px+): tabs become a left rail, sheets open as a side drawer.
   Wide desktop (1180px+): a "This week" panel stays in view.
   One bright, warm look on purpose; it stays light even when the device is in dark mode. */
:root {
  color-scheme: light;
  --cloth: #fffaf3;
  --check: rgba(244, 160, 120, .2);
  --pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='136' height='136'%3E%3Cellipse cx='30' cy='33' rx='5' ry='2.2' transform='rotate(35 30 33)' fill='%23a8c79a'/%3E%3Cellipse cx='96' cy='96' rx='5' ry='2.2' transform='rotate(-30 96 96)' fill='%23a8c79a'/%3E%3Cg fill='%23ffffff' stroke='%23efc9b3' stroke-width='.7'%3E%3Ccircle cx='22' cy='19.5' r='4'/%3E%3Ccircle cx='26.3' cy='22.6' r='4'/%3E%3Ccircle cx='24.6' cy='27.6' r='4'/%3E%3Ccircle cx='19.4' cy='27.6' r='4'/%3E%3Ccircle cx='17.7' cy='22.6' r='4'/%3E%3C/g%3E%3Cg fill='%23f4a7b9'%3E%3Ccircle cx='104' cy='83.5' r='4'/%3E%3Ccircle cx='108.3' cy='86.6' r='4'/%3E%3Ccircle cx='106.6' cy='91.6' r='4'/%3E%3Ccircle cx='101.4' cy='91.6' r='4'/%3E%3Ccircle cx='99.7' cy='86.6' r='4'/%3E%3C/g%3E%3Cg fill='%239fbfe8'%3E%3Ccircle cx='70' cy='60.6' r='3'/%3E%3Ccircle cx='73.2' cy='63' r='3'/%3E%3Ccircle cx='72' cy='66.8' r='3'/%3E%3Ccircle cx='68' cy='66.8' r='3'/%3E%3Ccircle cx='66.8' cy='63' r='3'/%3E%3C/g%3E%3Cg fill='%23f5c84c'%3E%3Ccircle cx='22' cy='24' r='2.2'/%3E%3Ccircle cx='104' cy='88' r='2.2'/%3E%3Ccircle cx='70' cy='64' r='1.7'/%3E%3C/g%3E%3C/svg%3E"),
    linear-gradient(90deg, var(--check) 50%, transparent 50%),
    linear-gradient(var(--check) 50%, transparent 50%);
  --pattern-size: 136px 136px, 34px 34px, 34px 34px;
  --header: #f8cdb0;
  --header-ink: #5b3627;
  --rose: #b84f66;
  --butter: #f5c84c;
  --paper: #fffefb;
  --paper-2: #fff4ea;
  --edge: #f0dccb;
  --ink: #4a3530;
  --ink-soft: #85685e;
  --sage: #5f8a4f;
  --sage-ink: #ffffff;
  --have: #4f8a46;
  --low: #a2680f;
  --out: #c0505f;
  --on-state: #ffffff;
  --rule-blue: #dbe8f2;
  --rule-red: #f2b0b8;
  --tape: rgba(247, 170, 185, .6);
  --live: #4fae5c;
  --scrim: rgba(74, 53, 48, .35);
  --shadow: 0 1px 0 rgba(120, 70, 40, .05), 0 8px 20px -10px rgba(120, 70, 40, .3);
  --shadow-lift: 0 1px 0 rgba(120, 70, 40, .05), 0 18px 40px -16px rgba(120, 70, 40, .45);

  --f-hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;
  --f-head: "Libre Baskerville", Georgia, "Times New Roman", serif;
  --f-body: "Lato", -apple-system, "Segoe UI", Roboto, sans-serif;
  --bar-h: 64px;
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--bar-h) + 12px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  background-color: var(--cloth); background-image: var(--pattern); background-size: var(--pattern-size);
  color: var(--ink); font-family: var(--f-body); font-size: 16px; line-height: 1.45;
  padding-top: env(safe-area-inset-top, 0px);
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--header); }
body.locked { overflow: hidden; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--butter); outline-offset: 2px; }
a { color: var(--rose); }

.app { margin: 0 auto; max-width: 560px; padding-bottom: calc(86px + env(safe-area-inset-bottom, 0px)); }

/* Header */
.bar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; min-height: var(--bar-h);
  background: var(--header); color: var(--header-ink);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-block: 10px 12px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  box-shadow: 0 2px 12px rgba(120, 70, 40, .15);
}
.brand { font-family: var(--f-hand); font-weight: 700; font-size: 2rem; line-height: 1; margin: 0; position: relative; letter-spacing: .5px; }
.brand::after { content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 3px; border-radius: 2px; background: var(--butter); }
.live { display: flex; align-items: center; gap: 7px; font-size: .78rem; font-weight: 700; background: rgba(255, 255, 255, .6); padding: 5px 11px; border-radius: 999px; white-space: nowrap; border: 0; cursor: default; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); animation: pulse 2.2s ease-in-out infinite; }
.live.off .dot { background: var(--low); animation: none; }
.live.wait .dot { background: var(--ink-soft); }
@keyframes pulse { 50% { opacity: .35; } }

main {
  display: grid; gap: 14px; min-width: 0; align-content: start;
  padding-block: 16px 24px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.view, .stack { display: grid; gap: 14px; align-items: start; min-width: 0; }
.span { grid-column: 1 / -1; }

.paper { background: var(--paper); border: 1px solid var(--edge); border-radius: 6px; box-shadow: var(--shadow); position: relative; min-width: 0; }
.head { padding: 16px; display: grid; gap: 4px; }
.title { font-family: var(--f-head); font-weight: 700; font-size: 1.35rem; line-height: 1.25; margin: 0; text-wrap: balance; }
.lede { font-family: var(--f-hand); font-size: 1.35rem; line-height: 1.15; color: var(--ink-soft); margin: 0; }
.tally { font-size: .85rem; color: var(--ink-soft); margin: 4px 0 0; font-variant-numeric: tabular-nums; }
.tally b { color: var(--ink); }
.tape { position: absolute; top: -9px; left: 50%; width: 76px; height: 20px; background: var(--tape); transform: translateX(-50%) rotate(-3deg); pointer-events: none; }

/* Buttons and fields */
.btn { border: 0; border-radius: 999px; padding: 10px 18px; min-height: 44px; background: var(--sage); color: var(--sage-ink); font-weight: 700; font-size: .95rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; }
.btn.ghost { background: transparent; border: 2px solid var(--sage); color: var(--ink); }
.btn.rose { background: var(--rose); color: var(--on-state); }
.btn.quiet { background: transparent; color: var(--ink-soft); border: 0; padding-inline: 10px; }
.btn.danger { background: transparent; border: 2px solid var(--out); color: var(--out); }
.btn.small { min-height: 38px; padding: 6px 14px; font-size: .85rem; }
.btn.wide { width: 100%; }
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .55; cursor: wait; }
.add { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; }
.field, .add input, .add select {
  min-height: 44px; padding: 8px 14px; border: 1.5px solid var(--edge); border-radius: 999px; background: var(--paper-2); width: 100%;
}
.add input { flex: 1 1 160px; min-width: 0; width: auto; }
.add select { width: auto; }
textarea.field { border-radius: 14px; min-height: 120px; resize: vertical; }
.field::placeholder, .add input::placeholder { color: var(--ink-soft); }
.form { display: grid; gap: 12px; }
.form label, .lbl { display: grid; gap: 5px; font-size: .78rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.form label .field, .form label select, .form label textarea { font-size: 1rem; font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--ink); }
.form label > span.hint-text { font-weight: 400; letter-spacing: 0; text-transform: none; font-size: .8rem; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.search { padding: 10px 12px; }

/* Segmented control */
.seg { flex: none; display: inline-flex; border: 1.5px solid var(--edge); border-radius: 999px; overflow: hidden; background: var(--paper); }
.seg button { border: 0; background: transparent; padding: 6px 11px; min-height: 40px; font-weight: 700; font-size: .8rem; color: var(--ink-soft); cursor: pointer; }
.seg button + button { border-left: 1.5px solid var(--edge); }
.seg button[aria-pressed="true"] { color: var(--on-state); background: var(--sage); }
.seg .have[aria-pressed="true"] { background: var(--have); }
.seg .low[aria-pressed="true"] { background: var(--low); }
.seg .out[aria-pressed="true"] { background: var(--out); }
.seg.wide { display: flex; }
.seg.wide button { flex: 1; }

/* Lists */
.group-label { font-size: .72rem; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); padding: 12px 14px 6px; margin: 0; }
.hand { font-family: var(--f-hand); font-size: 1.45rem; letter-spacing: 0; text-transform: none; color: var(--rose); font-weight: 700; }
.row { display: flex; align-items: center; gap: 4px; border-top: 1px dashed var(--edge); min-height: 58px; transition: background .4s; }
.row:hover { background: var(--paper-2); }
.tick { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; padding: 10px 4px 10px 14px; background: none; border: 0; text-align: left; cursor: pointer; align-self: stretch; }
.box { flex: none; width: 28px; height: 28px; border: 2px solid var(--sage); border-radius: 8px 10px 7px 9px; display: grid; place-items: center; color: var(--have); }
.box path { stroke-dasharray: 32; stroke-dashoffset: 32; transition: stroke-dashoffset .35s ease-out; }
.row.done .box path { stroke-dashoffset: 0; }
.txt { display: grid; min-width: 0; flex: 1; }
.name { font-weight: 700; font-size: 1.05rem; overflow-wrap: anywhere; }
.qty { font-weight: 900; font-size: .8rem; color: var(--rose); margin-left: 6px; white-space: nowrap; }
.why { font-size: .82rem; color: var(--ink-soft); }
.row.done .name { text-decoration: line-through; text-decoration-color: var(--rose); text-decoration-thickness: 2px; color: var(--ink-soft); }
.who { flex: none; font-family: var(--f-hand); font-size: 1.15rem; font-weight: 700; color: var(--rose); }
.more { flex: none; width: 44px; align-self: stretch; border: 0; background: none; color: var(--ink-soft); cursor: pointer; font-size: 1.2rem; border-radius: 8px; }
.more:hover { color: var(--rose); }
.just { animation: glow 1.6s ease-out; }
@keyframes glow { 0%, 30% { background: rgba(245, 200, 76, .35); } 100% { background: transparent; } }
.empty { padding: 18px 16px; font-family: var(--f-hand); font-size: 1.4rem; color: var(--ink-soft); margin: 0; }
.home { padding: 12px 14px 14px; border-top: 1px dashed var(--edge); }

/* Pantry rows */
.prow { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 14px; border-top: 1px dashed var(--edge); min-height: 60px; }
.pinfo { flex: 1; min-width: 0; display: grid; background: none; border: 0; text-align: left; padding: 4px 0; cursor: pointer; }
.pname { font-weight: 700; overflow-wrap: anywhere; }
.pinfo:hover .pname { color: var(--rose); }
.psub { font-size: .78rem; color: var(--ink-soft); }
.psub .low { color: var(--low); font-weight: 700; }
.psub .out, .psub .expired { color: var(--out); font-weight: 700; }
.step { flex: none; display: flex; align-items: center; border: 1.5px solid var(--edge); border-radius: 999px; overflow: hidden; background: var(--paper); }
.step button { width: 42px; min-height: 40px; border: 0; background: transparent; font-weight: 900; font-size: 1.15rem; color: var(--sage); cursor: pointer; }
.step button:hover { background: var(--paper-2); }
.step output { min-width: 38px; text-align: center; font-weight: 900; font-variant-numeric: tabular-nums; }
.untracked { font-size: .78rem; color: var(--ink-soft); font-style: italic; }

/* Pills */
.pill { justify-self: start; display: inline-block; font-size: .7rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.pill.ok { background: rgba(79, 138, 70, .14); color: var(--have); }
.pill.miss { background: rgba(192, 80, 95, .12); color: var(--out); }
.pill.soon { background: rgba(162, 104, 15, .13); color: var(--low); }

/* Recipe cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 22px 16px; padding-top: 8px; }
.card { perspective: 1200px; cursor: pointer; border-radius: 4px; display: grid; }
.inner { display: grid; transform-style: preserve-3d; transition: transform .7s cubic-bezier(.34, 1.4, .5, 1); }
.card.flipped .inner { transform: rotateY(180deg); }
.face {
  grid-area: 1 / 1; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background-color: var(--paper); border-radius: 4px; box-shadow: var(--shadow);
  padding: 20px 16px 40px; position: relative; min-height: 250px; display: grid; align-content: start; gap: 8px;
}
.card:hover .face { box-shadow: var(--shadow-lift); }
.front {
  background-image:
    linear-gradient(transparent 62px, var(--rule-red) 62px, var(--rule-red) 64px, transparent 64px),
    repeating-linear-gradient(transparent 0 27px, var(--rule-blue) 27px 28px);
  background-position: 0 0, 0 8px;
}
.back { transform: rotateY(180deg); }
.rtitle { font-family: var(--f-hand); font-weight: 700; font-size: 1.95rem; line-height: 1; margin: 0 0 12px; min-height: 30px; text-wrap: balance; overflow-wrap: anywhere; }
.meta { font-size: .86rem; color: var(--ink-soft); margin: 0; }
.havebar { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.havebar i { width: 14px; height: 6px; border-radius: 3px; background: var(--edge); }
.havebar i.on { background: var(--have); }
.planned { font-family: var(--f-hand); font-size: 1.25rem; color: var(--rose); margin: 0; }
.hint { position: absolute; right: 14px; bottom: 9px; font-family: var(--f-hand); font-size: 1.1rem; color: var(--rose); }
.fav { position: absolute; left: 14px; bottom: 10px; color: var(--rose); font-size: 1rem; }
.ing { list-style: none; padding: 0; margin: 0; display: grid; gap: 3px; font-size: .92rem; }
.ing li { display: flex; gap: 8px; align-items: baseline; }
.ing small { color: var(--ink-soft); }
.mk { flex: none; width: 40px; font-size: .72rem; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.mk.ok { color: var(--have); }
.mk.need { color: var(--out); }
.mk.free { color: var(--ink-soft); }
.tip { font-family: var(--f-head); font-style: italic; font-size: .85rem; color: var(--ink-soft); margin: 4px 0 0; }
.days { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1.5px solid var(--sage); background: transparent; border-radius: 999px; padding: 4px 12px; min-height: 38px; font-weight: 700; font-size: .82rem; cursor: pointer; }
.chip:hover, .chip[aria-pressed="true"] { background: var(--sage); color: var(--sage-ink); }
.card-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

/* Recipe photos as little taped polaroids */
.polaroid { margin: 0; background: #fff; padding: 6px 6px 18px; box-shadow: var(--shadow); transform: rotate(3deg); width: 96px; position: absolute; right: 12px; top: 14px; }
.polaroid img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.front .rtitle { padding-right: 0; }
.front:has(.polaroid) .rtitle, .front:has(.polaroid) .meta:first-of-type { padding-right: 104px; }
.polaroid.big { position: relative; right: auto; top: auto; width: min(260px, 70%); margin: 4px auto 12px; transform: rotate(-1.5deg); padding: 8px 8px 26px; }
.step-head { list-style: none; margin-left: -1.3em; font-weight: 900; color: var(--rose); }
.paste { display: grid; gap: 8px; }
.place-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 40px 40px; gap: 8px; align-items: center; }
.x:disabled { opacity: .35; cursor: not-allowed; }
.exp-inline { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--ink-soft); }
.lot select.field { width: auto; flex: 1 1 130px; }
.form.move { padding: 12px; border: 1px dashed var(--edge); border-radius: 12px; background: var(--paper-2); }
.newplace { margin-top: -2px; }

/* Meals */
.day { display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: 12px; padding: 12px 14px; border-top: 1px dashed var(--edge); align-items: start; }
.day.today { background: rgba(245, 200, 76, .1); }
.dname { font-family: var(--f-hand); font-weight: 700; font-size: 1.6rem; line-height: 1; color: var(--rose); }
.dname small { display: block; font-family: var(--f-body); font-size: .66rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); margin-top: 4px; }
.dbody { display: grid; gap: 10px; min-width: 0; }
.meal { display: grid; gap: 6px; min-width: 0; }
.meal + .meal { padding-top: 10px; border-top: 1px dotted var(--edge); }
.dmeal { font-weight: 700; font-size: 1.05rem; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; }
.dmeal:hover { color: var(--rose); }
.dneed { font-size: .82rem; color: var(--ink-soft); }
.dacts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stamp { display: inline-block; border: 2px solid var(--out); color: var(--out); font-weight: 900; font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; padding: 2px 9px; border-radius: 4px; transform: rotate(-6deg); }
.stamp.skip { border-color: var(--ink-soft); color: var(--ink-soft); }
.flow { padding: 14px 16px; display: grid; gap: 6px; font-size: .88rem; }
.flow ol { margin: 0; padding-left: 1.2em; display: grid; gap: 4px; }

/* Side panel (wide desktop only) */
.side { display: none; }
.srow { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 8px; align-items: center; width: 100%; padding: 9px 14px; background: none; border: 0; border-top: 1px dashed var(--edge); text-align: left; cursor: pointer; }
.srow:hover { background: var(--paper-2); }
.sday { font-family: var(--f-hand); font-size: 1.3rem; font-weight: 700; color: var(--rose); line-height: 1; }
.sname { font-weight: 700; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sbody { padding: 4px 14px 14px; display: grid; gap: 10px; font-size: .88rem; }
.lowchips { display: flex; flex-wrap: wrap; gap: 6px; }
.lowchips button { font-size: .78rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--paper-2); border: 1px solid var(--edge); cursor: pointer; }

/* Tabs (bottom bar on phones, left rail on desktop) */
.tabs {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); z-index: 20;
  width: min(100%, 560px); display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--paper); border-top: 1px solid var(--edge); box-shadow: 0 -6px 18px -12px rgba(120, 70, 40, .35);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px);
}
.tab { position: relative; display: grid; justify-items: center; align-content: center; gap: 2px; min-height: 62px; padding: 9px 4px 10px; background: none; border: 0; color: var(--ink-soft); font-weight: 700; font-size: .74rem; cursor: pointer; }
.tab[aria-current="page"] { color: var(--rose); }
.tab[aria-current="page"]::after { content: ""; position: absolute; bottom: 5px; width: 22px; height: 3px; border-radius: 2px; background: var(--butter); }
.badge { position: absolute; top: 5px; left: calc(50% + 7px); min-width: 19px; padding: 1px 6px; border-radius: 999px; background: var(--out); color: var(--on-state); font-size: .68rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.badge.pop { animation: pop .4s ease-out; }
@keyframes pop { 40% { transform: scale(1.35); } }

/* Sheets: slide up on phones, a drawer on desktop */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 40; animation: fade .2s ease-out; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--paper); border-radius: 18px 18px 0 0; box-shadow: var(--shadow-lift);
  padding: 8px max(16px, env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  animation: rise .28s cubic-bezier(.2, .9, .3, 1);
}
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.grip { width: 44px; height: 5px; border-radius: 3px; background: var(--edge); margin: 4px auto 10px; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.sheet-head h2 { font-family: var(--f-head); font-size: 1.3rem; margin: 0; line-height: 1.25; overflow-wrap: anywhere; }
.sheet-head .sub { font-family: var(--f-hand); font-size: 1.25rem; color: var(--ink-soft); margin: 2px 0 0; }
.x { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--paper-2); font-size: 1.3rem; cursor: pointer; color: var(--ink-soft); }
.sheet section { display: grid; gap: 10px; padding-block: 14px; border-top: 1px dashed var(--edge); }
.sheet section:first-of-type { border-top: 0; padding-top: 0; }
.sheet h3 { margin: 0; font-size: .72rem; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); }
.bigqty { font-family: var(--f-hand); font-size: 2.6rem; line-height: 1; color: var(--ink); font-weight: 700; }
.nums { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .88rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.nums b { color: var(--ink); }
.lot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: .9rem; }
.lot .field { width: auto; flex: 1 1 150px; }
.hist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: .86rem; max-height: 260px; overflow-y: auto; }
.hist li { display: flex; gap: 10px; align-items: baseline; }
.hist .d { color: var(--ink-soft); width: 92px; flex: none; font-size: .78rem; }
.hist .q { font-weight: 900; width: 54px; flex: none; text-align: right; font-variant-numeric: tabular-nums; }
.hist .q.plus { color: var(--have); }
.hist .q.minus { color: var(--out); }
.sheet-acts { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; padding-top: 14px; border-top: 1px dashed var(--edge); }
.sheet-acts .push { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.lines { display: grid; gap: 10px; }
.line-edit { display: grid; grid-template-columns: minmax(0, 1fr) 90px 40px; gap: 6px; align-items: center; padding: 10px; border: 1px solid var(--edge); border-radius: 12px; background: var(--paper-2); }
.line-edit .field { background: var(--paper); }
.line-edit .wide { grid-column: 1 / -1; }
.line-edit .needs { grid-column: 1 / -1; font-size: .78rem; color: var(--low); font-weight: 700; }
.line-edit label.opt { display: flex; gap: 6px; align-items: center; font-size: .8rem; text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--ink-soft); }
.steps { margin: 0; padding-left: 1.3em; display: grid; gap: 8px; }
.qcell { display: flex; align-items: center; gap: 6px; }
.qcell .field { width: 84px; }
.qcell small { color: var(--ink-soft); min-width: 3em; }
.checkout-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 10px; align-items: center; padding: 10px 0; border-top: 1px dashed var(--edge); }
.checkout-row:first-child { border-top: 0; }
.checkout-row .field { padding-inline: 10px; }
.checkout-row .exp { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; font-size: .85rem; color: var(--ink-soft); }
.checkout-row .exp .field { width: auto; flex: 1; }

/* Toasts */
.toasts {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50;
  bottom: calc(74px + env(safe-area-inset-bottom, 0px));
  width: min(calc(100% - 32px), 528px); display: grid; gap: 8px; pointer-events: none;
}
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; background: var(--paper); border: 1px solid var(--edge); border-radius: 6px; box-shadow: var(--shadow); padding: 9px 10px 9px 14px; font-family: var(--f-hand); font-size: 1.3rem; line-height: 1.15; transform: rotate(-.6deg); animation: tin .3s ease-out; }
.toast span { flex: 1; }
.toast.err { border-color: var(--out); }
.toast b { color: var(--rose); }
.toast .btn { font-family: var(--f-body); }
@keyframes tin { from { opacity: 0; translate: 0 10px; } }

/* Sign in */
.signin { max-width: 400px; margin: 10vh auto 0; padding: 0 16px; }
.signin .paper { padding: 26px 22px 22px; }
.err { color: var(--out); font-weight: 700; font-size: .9rem; margin: 0; }

/* ---------- Tablet ---------- */
@media (min-width: 640px) {
  .app { max-width: 820px; }
  .tabs { width: min(100%, 820px); }
  .toasts { width: min(calc(100% - 32px), 440px); }
  #shopList, #pantryList { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  main { padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); }
  .sheet { left: 50%; right: auto; width: min(640px, 100%); transform: translateX(-50%); animation: rise-c .28s cubic-bezier(.2, .9, .3, 1); }
  @keyframes rise-c { from { transform: translate(-50%, 40px); opacity: 0; } }
}

/* ---------- Desktop ---------- */
@media (min-width: 900px) {
  .app { max-width: 1320px; padding-bottom: 0; display: grid; grid-template-columns: 112px minmax(0, 1fr); grid-template-areas: "bar bar" "nav main"; }
  .bar { grid-area: bar; box-shadow: 0 0 0 100vmax var(--header), 0 2px 12px rgba(120, 70, 40, .15); clip-path: inset(0 -100vmax -20px); }
  main { grid-area: main; padding-block: 24px 48px; padding-left: 12px; padding-right: max(28px, env(safe-area-inset-right, 0px)); }
  .tabs {
    grid-area: nav; position: sticky; top: calc(env(safe-area-inset-top, 0px) + var(--bar-h) + 16px);
    left: auto; bottom: auto; transform: none; width: auto; align-self: start;
    grid-template-columns: 1fr; gap: 6px; margin: 16px 0 0 max(16px, env(safe-area-inset-left, 0px));
    padding: 8px; border: 1px solid var(--edge); border-radius: 14px; box-shadow: var(--shadow);
  }
  .tab { min-height: 74px; border-radius: 10px; font-size: .78rem; }
  .tab:hover { background: var(--paper-2); }
  .tab[aria-current="page"] { background: var(--paper-2); }
  .tab[aria-current="page"]::after { left: 0; bottom: auto; top: 50%; width: 3px; height: 26px; translate: 0 -50%; }
  .badge { top: 8px; }
  .toasts { left: auto; right: 24px; bottom: 24px; transform: none; width: 380px; }
  .head { grid-template-columns: minmax(0, 1fr) auto; align-items: end; column-gap: 24px; padding: 18px 20px; }
  .head .title, .head .lede { grid-column: 1; }
  .head .tally { grid-column: 2; grid-row: 1 / span 2; margin: 0; text-align: right; font-size: .92rem; }
  .title { font-size: 1.6rem; }
  #week { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  #week .day { grid-template-columns: 1fr; gap: 10px; border-right: 1px dashed var(--edge); padding: 14px 16px 18px; }
  .dname small { display: inline; margin-left: 6px; }
  #shopList { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
  #pantryList { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
  .cards { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 28px 22px; }
  .sheet { left: auto; right: 0; top: 0; bottom: 0; width: 520px; max-height: none; transform: none; border-radius: 18px 0 0 18px; padding: 22px 26px 26px; animation: slide .28s cubic-bezier(.2, .9, .3, 1); }
  @keyframes slide { from { transform: translateX(60px); opacity: 0; } }
  .grip { display: none; }
}

/* ---------- Wide desktop ---------- */
@media (min-width: 1180px) {
  .app { grid-template-columns: 112px minmax(0, 1fr) 310px; grid-template-areas: "bar bar bar" "nav main side"; }
  .side {
    grid-area: side; display: grid; gap: 14px; align-content: start;
    position: sticky; top: calc(env(safe-area-inset-top, 0px) + var(--bar-h)); max-height: calc(100vh - var(--bar-h)); overflow-y: auto;
    padding: 24px max(24px, env(safe-area-inset-right, 0px)) 24px 0;
  }
  main { padding-right: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .inner, .box path, .row { transition: none; }
  .dot, .just, .badge.pop, .toast, .sheet, .scrim { animation: none; }
}
