:root {
  --cream: #f4ede0;
  --paper: #fffaf1;
  --navy: #1f2a44;
  --navy-2: #2c3a5c;
  --red: #a23b2a;
  --ink: #1f2a44;
  --muted: #5f6677;
  --line: #e4d9c6;
  --toss: #a23b2a;
  --past: #c0641f;
  --soon: #b8860b;
  --rotate: #2c3a5c;
  --good: #2f6b4f;
  --stocked: #7b8190;
  --r: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--cream); color: var(--ink); font: 16px/1.4 Inter, -apple-system, system-ui, sans-serif; }
body { padding-bottom: calc(84px + var(--safe-b)); min-height: 100vh; }
a { color: inherit; }
h1, h2, .display { font-family: 'Bowlby One', Inter, sans-serif; font-weight: 400; letter-spacing: .01em; }
h1 { font-size: 28px; line-height: 1.05; margin: 0; }
h2 { font-size: 17px; margin: 26px 0 10px; text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px; }

/* header */
.top { background: var(--navy); color: var(--cream); padding: calc(18px + var(--safe-t)) 0 22px; border-radius: 0 0 22px 22px; margin-bottom: 18px; }
.top .eyebrow { font-size: 12px; letter-spacing: .16em; text-transform: uppercase; opacity: .75; margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; }
.top .eyebrow a { text-decoration: none; opacity: .9; }
.top .sub { opacity: .8; margin-top: 6px; font-size: 14px; }
.back { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; color: var(--cream); opacity: .85; font-size: 14px; margin-bottom: 8px; }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile { background: var(--paper); border-radius: var(--r); padding: 14px; text-decoration: none; border: 1px solid var(--line); display: block; }
.tile .n { font-family: 'Bowlby One'; font-size: 30px; line-height: 1; }
.tile .l { font-size: 13px; color: var(--muted); margin-top: 4px; font-weight: 600; }
.tile.toss .n { color: var(--toss); } .tile.past .n { color: var(--past); } .tile.cook .n { color: var(--rotate); } .tile.low .n { color: var(--good); }
.tile.zero { opacity: .55; }

/* cards & rows */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 12px; }
.list { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-bottom: 1px solid var(--line); text-decoration: none; }
.row:last-child { border-bottom: 0; }
.row .main { flex: 1; min-width: 0; }
.row .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .q { font-family: 'Bowlby One'; font-size: 18px; min-width: 34px; text-align: right; }
.thumb { width: 42px; height: 42px; border-radius: 10px; background: var(--cream) center/cover no-repeat; flex: none; display: grid; place-items: center; font-size: 20px; border: 1px solid var(--line); }
.empty { text-align: center; padding: 30px 16px; color: var(--muted); }

/* pills */
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 999px; color: #fff; white-space: nowrap; }
.pill.toss { background: var(--toss); } .pill.past { background: var(--past); } .pill.soon { background: var(--soon); }
.pill.rotate { background: var(--rotate); } .pill.good { background: var(--good); } .pill.stocked, .pill.empty { background: var(--stocked); }
.pill.low { background: transparent; color: var(--good); border: 1.5px solid var(--good); }
.pill.est { background: transparent; color: var(--muted); border: 1px dashed var(--muted); font-weight: 500; }

/* chips / filters */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1.5px solid var(--navy); background: transparent; color: var(--navy); border-radius: 999px; padding: 7px 13px; font: 600 14px Inter; }
.chip.on { background: var(--navy); color: var(--cream); }

/* forms */
label { display: block; font-size: 13px; font-weight: 700; margin: 14px 0 6px; color: var(--navy); text-transform: uppercase; letter-spacing: .04em; }
input, select, textarea { width: 100%; font: 16px Inter; padding: 12px 13px; border-radius: 11px; border: 1.5px solid var(--line); background: #fff; color: var(--ink); appearance: none; -webkit-appearance: none; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--navy) 50%), linear-gradient(135deg, var(--navy) 50%, transparent 50%); background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy); }
input[type=date] { min-height: 48px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.search { position: relative; }
.search input { padding-left: 40px; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; stroke: var(--muted); fill: none; stroke-width: 2.2; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 14px 18px; font: 700 16px Inter; background: var(--navy); color: var(--cream); text-decoration: none; cursor: pointer; }
.btn.red { background: var(--red); color: #fff; }
.btn.ghost { background: transparent; color: var(--navy); border: 1.5px solid var(--navy); }
.btn.light { background: var(--cream); color: var(--navy); }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; }
.btns { display: flex; gap: 10px; margin-top: 16px; }
.btns > * { flex: 1; }
.stepper { display: flex; align-items: stretch; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.stepper button { width: 54px; border: 0; background: var(--cream); font: 700 24px Inter; color: var(--navy); }
.stepper input { border: 0; text-align: center; font: 400 22px 'Bowlby One'; border-radius: 0; }
.linkbtn { background: none; border: 0; color: var(--navy); font: 600 14px Inter; text-decoration: underline; padding: 6px 0; cursor: pointer; }

/* scan */
.scanbox { position: relative; border-radius: var(--r); overflow: hidden; background: #000; aspect-ratio: 4/3; margin-bottom: 12px; }
.scanbox video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanbox .aim { position: absolute; left: 10%; right: 10%; top: 38%; bottom: 38%; border: 3px solid rgba(255,255,255,.85); border-radius: 12px; box-shadow: 0 0 0 9999px rgba(0,0,0,.35); }
.scanbox .x { position: absolute; top: 10px; right: 10px; }
.bigchoice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.bigchoice .btn { flex-direction: column; padding: 18px 10px; gap: 6px; }
.bigchoice svg { width: 28px; height: 28px; stroke: currentColor; fill: none; stroke-width: 2; }

/* lots */
.lot { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 13px 14px; border-bottom: 1px solid var(--line); }
.lot:last-child { border-bottom: 0; }
.lot .acts { display: flex; gap: 8px; margin-top: 6px; grid-column: 1 / -1; }

/* meals */
.meal h3 { font-family: 'Bowlby One'; font-weight: 400; font-size: 20px; margin: 0 0 4px; line-height: 1.1; }
.meal .uses { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.meal .use { font-size: 13px; padding: 5px 9px; border-radius: 9px; background: var(--cream); border: 1px solid var(--line); }
.meal .use.urgent { border-color: var(--past); background: #fbe9da; font-weight: 600; }
.meal ol { padding-left: 20px; margin: 8px 0 0; }
.meal li { margin-bottom: 6px; }
.meal details summary { cursor: pointer; font-weight: 600; color: var(--navy); margin-top: 6px; }
.spinner { width: 34px; height: 34px; border: 4px solid var(--line); border-top-color: var(--red); border-radius: 50%; animation: spin .8s linear infinite; margin: 30px auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* shopping */
.check { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-bottom: 1px solid var(--line); }
.check:last-child { border-bottom: 0; }
.check input { width: 24px; height: 24px; flex: none; accent-color: var(--navy); appearance: auto; -webkit-appearance: checkbox; padding: 0; }
.check.done .t { text-decoration: line-through; opacity: .5; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--navy); color: var(--cream); }
.login .box { width: 100%; max-width: 360px; text-align: center; }
.login .mark { width: 84px; height: 84px; margin: 0 auto 14px; }
.login input { text-align: center; font: 400 28px 'Bowlby One'; letter-spacing: .3em; margin: 14px 0; }
.login .who { display: flex; gap: 10px; justify-content: center; margin-top: 8px; }
.login .who .chip { border-color: var(--cream); color: var(--cream); }
.login .who .chip.on { background: var(--cream); color: var(--navy); }
.login .err { color: #ffb4a6; min-height: 22px; }

/* tabs */
#tabs { position: fixed; left: 0; right: 0; bottom: 0; background: var(--paper); border-top: 1px solid var(--line); display: flex; justify-content: space-around; padding: 6px 4px calc(6px + var(--safe-b)); z-index: 10; }
#tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; font-size: 11px; font-weight: 600; color: var(--muted); padding: 4px 0; }
#tabs svg { width: 24px; height: 24px; fill: currentColor; stroke: currentColor; }
#tabs a.on { color: var(--navy); }
#tabs a.add svg { background: var(--red); color: #fff; border-radius: 50%; width: 40px; height: 40px; padding: 8px; margin-top: -18px; box-shadow: 0 4px 12px rgba(162,59,42,.35); }
#tabs a.add { color: var(--red); }

#toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: var(--navy); color: var(--cream); padding: 11px 16px; border-radius: 12px; font-weight: 600; opacity: 0; pointer-events: none; transition: .2s; z-index: 20; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.sheet-bg { position: fixed; inset: 0; background: rgba(20,24,36,.5); z-index: 30; display: flex; align-items: flex-end; }
.sheet { background: var(--cream); width: 100%; max-width: 640px; margin: 0 auto; border-radius: 20px 20px 0 0; padding: 18px 16px calc(20px + var(--safe-b)); max-height: 90vh; overflow: auto; }
.sheet h2 { margin-top: 0; }
.note { background: #fbe9da; border-left: 4px solid var(--past); padding: 10px 12px; border-radius: 8px; font-size: 14px; margin: 10px 0; }

/* disaster mode */
.seg { padding-bottom: 10px; }
.hero { background: var(--navy); color: var(--cream); border-radius: var(--r); padding: 20px 18px; margin-bottom: 12px; }
.hero .big { font-family: 'Bowlby One'; font-size: 64px; line-height: 1; }
.hero .big span { font-size: 22px; }
.hero-alt { margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(244, 237, 224, .2); opacity: .85; }
.plan-h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.plan .list .row { padding: 10px 12px; }
.hrow { display: grid; grid-template-columns: 1fr 100px 70px 38px; gap: 6px; margin-top: 8px; align-items: center; }
.hrow input, .hrow select { min-width: 0; }
.tips { margin: 6px 0 10px; padding-left: 20px; }
.tips li { margin: 6px 0; }
