/* Pantry: warm kitchen. Cream background, white cards, tomato red, Nunito. */
:root {
  --bg: #FBF6EE;
  --card: #FFFFFF;
  --text: #2B2420;
  --muted: #8A7666;
  --faint: #B5A595;
  --edge: #EADFCF;
  --line: #EFE5D8;
  --soft: #F7EFE4;
  --accent: #B23A1F;
  --accent-dark: #8E2C16;
  --accent-soft: #FBEDE6;
  --soon: #8F5300;
  --soon-bg: #FFF3DC;
  --soon-edge: #F3D9A6;
  --out: #A9321A;
  --out-bg: #FCE9E4;
  --out-edge: #F2C8BC;
  --star: #E8890C;
  --dark: #2B2420;
  --r: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tabs: calc(96px + var(--safe-b));
  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 17px; font-weight: 600; line-height: 1.35; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
body.sheet-open { overflow: hidden; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, p { margin: 0; }
b, strong { font-weight: 800; }
.i { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.i.star { fill: var(--star); stroke: var(--star); vertical-align: -1px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 15px; }
.soon { color: var(--soon); }
.out { color: var(--out); }
.center { text-align: center; }
.grow { flex: 1; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 5px; flex: none; }

html.loading #main { opacity: .6; transition: opacity .15s .1s; }

/* ---------- Frame ---------- */
#main { max-width: 640px; margin: 0 auto; padding: env(safe-area-inset-top, 0px) 16px calc(var(--tabs) + 24px); display: flex; flex-direction: column; gap: 16px; }
#main.bare { padding-bottom: 40px; }
#main.notabs { padding-bottom: calc(100px + var(--safe-b)); }
#live { display: flex; flex-direction: column; gap: 18px; }

.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 4px 0; }
.head-t { display: flex; flex-direction: column; min-width: 0; }
.over { font-size: 14px; font-weight: 700; color: var(--muted); }
.head h1, .itemhead h1 { font-size: 32px; line-height: 38px; font-weight: 800; letter-spacing: -0.01em; }
.head-r { display: flex; gap: 8px; }
.avatar, .roundbtn { width: 42px; height: 42px; border-radius: 21px; border: 1.5px solid var(--edge); background: var(--card); color: var(--text); display: flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 800; flex: none; }
.avatar { background: #F1E4D3; border-color: #F1E4D3; color: #6B4A2E; }

.navbar { display: flex; justify-content: space-between; align-items: center; padding-top: 14px; gap: 8px; }
.navback, .navright a, .navright button { display: flex; align-items: center; gap: 4px; height: 42px; padding: 0 16px 0 10px; border-radius: 21px; border: 1.5px solid var(--edge); background: var(--card); color: var(--text); font-size: 15px; font-weight: 800; }
.navright a, .navright button { padding: 0 16px; }
.navback .i { stroke-width: 2.6; }

/* ---------- Search and chips ---------- */
.searchrow { position: relative; }
.search { height: 46px; border-radius: 23px; background: var(--card); border: 1.5px solid var(--edge); display: flex; align-items: center; gap: 10px; padding: 0 8px 0 16px; color: var(--muted); margin: 0; }
.search .i { stroke-width: 2.4; }
.search input { flex: 1; min-width: 0; border: 0 !important; background: transparent !important; border-radius: 0 !important; font-size: 16px; font-weight: 600; color: var(--text); outline: none; padding: 0; height: 100%; }
.search input::placeholder { color: var(--muted); }
.search-scan { width: 34px; height: 34px; border-radius: 17px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; flex: none; }
.search .link { border: 0; background: none; color: var(--accent); font-weight: 800; font-size: 15px; padding: 8px 8px; }
.search:focus-within { border-color: var(--accent); }

.chips { display: flex; gap: 8px; overflow-x: auto; margin: -2px -16px 0; padding: 0 16px 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 20px; border: 1.5px solid var(--edge); background: var(--card); color: var(--text); font-size: 15px; font-weight: 700; white-space: nowrap; }
.chip.on { background: var(--dark); border-color: var(--dark); color: #fff; }
.chip.on .dot { box-shadow: 0 0 0 2px #fff; }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tile { background: var(--card); border: 1.5px solid var(--edge); border-radius: var(--r); padding: 10px 12px; display: flex; flex-direction: column; text-align: left; color: var(--text); transition: box-shadow .15s; }
.tile b { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tile span { font-size: 13px; font-weight: 700; color: var(--muted); }
.tile:has(b.soon) { background: var(--soon-bg); border-color: var(--soon-edge); }
.tile:has(b.soon) span { color: #7A5A2A; }
.tile:has(b.out) { background: var(--out-bg); border-color: var(--out-edge); }
.tile:has(b.out) span { color: #84402F; }
.tile.on { box-shadow: 0 0 0 2.5px var(--text); }

.banner, .shopbtn { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1.5px solid var(--edge); border-radius: var(--r); padding: 12px 14px; color: var(--text); font-size: 15px; }
.banner .i:first-child { color: var(--accent); }
.banner span, .shopbtn span { flex: 1; }
.banner .i:last-child { color: var(--faint); }
.shopbtn { background: var(--accent); border-color: var(--accent); color: #fff; padding: 14px 16px; }
.shopbtn span { display: flex; flex-direction: column; gap: 1px; }
.shopbtn b { font-size: 17px; }
.shopbtn small { font-size: 13px; font-weight: 700; color: #F6D3C8; }
.shopbtn.going { background: var(--dark); border-color: var(--dark); }
.shopbtn.going small { color: #D9CBB8; }

/* ---------- Lists ---------- */
.group { display: flex; flex-direction: column; gap: 8px; }
.sh { margin: 0 4px; font-size: 17px; font-weight: 800; color: var(--text); display: flex; align-items: center; gap: 8px; }
.sh .n { margin-left: auto; font-size: 14px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.card { background: var(--card); border: 1.5px solid var(--edge); border-radius: var(--r); }
.card.pad { padding: 14px 16px; }
.rows, .log, .picks { list-style: none; margin: 0; padding: 0; overflow: hidden; }
.row { display: flex; align-items: center; gap: 10px; padding: 9px 10px 9px 16px; min-height: 60px; }
.row + .row { border-top: 1.5px dashed var(--line); }
.row.wrap { flex-wrap: wrap; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; color: var(--text); padding: 2px 0; }
.row-main.plain { border: 0; background: none; text-align: left; padding: 6px 0; }
.row-t { font-size: 17px; line-height: 22px; font-weight: 700; overflow-wrap: anywhere; }
.row-t.dim { color: var(--faint); }
.row-s { font-size: 14px; line-height: 19px; font-weight: 700; color: var(--muted); }
.row-s:empty { display: none; }
.row-s.soon { color: var(--soon); font-weight: 800; }
.row-s.past, .row-s.out, .row-s.err { color: var(--out); font-weight: 800; }
.row.done .row-t { color: var(--faint); text-decoration: line-through; }
.times { color: var(--muted); font-size: 15px; }
.none { text-align: center; color: var(--muted); padding: 24px 0; }

.qty { display: flex; align-items: center; flex: none; height: 40px; border-radius: 20px; background: var(--soft); }
.count { min-width: 22px; text-align: center; font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.count.big { font-size: 20px; color: var(--out); }
.step { width: 40px; height: 40px; border-radius: 20px; border: 0; background: transparent; color: #6B4A2E; font-size: 21px; font-weight: 800; line-height: 1; display: flex; align-items: center; justify-content: center; padding: 0; flex: none; }
.step.plus { color: var(--accent); font-size: 23px; }
.step:active { background: rgba(178, 58, 31, 0.1); }
.step-gap { width: 12px; }
.qty .count:last-child { padding-right: 12px; }
.xbtn { width: 36px; height: 36px; border-radius: 18px; border: 0; background: none; color: var(--faint); display: flex; align-items: center; justify-content: center; flex: none; }
.xbtn .i { stroke-width: 2.4; }

.tick { width: 30px; height: 30px; border-radius: 15px; border: 2px solid #D9CBB8; background: none; color: transparent; display: flex; align-items: center; justify-content: center; padding: 0; flex: none; }
.tick .i { stroke-width: 3; }
.tick.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.tick.on.theirs { background: #A08C78; border-color: #A08C78; }
.tick:disabled { cursor: default; }

.chipbtn { flex: none; border: 0; background: var(--accent-soft); color: var(--accent); font-size: 14px; font-weight: 800; padding: 8px 14px; border-radius: 18px; white-space: nowrap; }
.rowbtns { display: flex; gap: 6px; flex-wrap: wrap; width: 100%; padding-bottom: 6px; }
.rowbtns form { margin: 0; }

.checkcell { display: flex; flex: none; padding: 6px 2px; cursor: pointer; }
.checkcell input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.checkcell span { width: 26px; height: 26px; border-radius: 13px; border: 2px solid #D9CBB8; display: block; }
.checkcell input:checked + span { background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 12.5 4 4L18 8' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/16px no-repeat; border-color: var(--accent); }
.checkcell input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.row .countin { width: 64px !important; flex: none; padding: 0 4px !important; height: 40px; border-radius: 12px; border: 1.5px solid var(--edge); background: var(--soft); text-align: center; font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.row .countin:focus { outline: none; border-color: var(--accent); background: #fff; }

.log li { display: flex; justify-content: space-between; gap: 12px; padding: 12px 16px; font-size: 15px; }
.log li + li { border-top: 1.5px dashed var(--line); }
.log time { color: var(--muted); flex: none; }

.linkrows { overflow: hidden; }
.linkrows > a, .linkrows > button, .linkrows form > button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; min-height: 56px; border: 0; background: none; color: var(--text); text-align: left; font-size: 17px; font-weight: 700; }
.linkrows > * + * { border-top: 1.5px dashed var(--line); }
.linkrows form { margin: 0; }
.linkrows .i:first-child { color: var(--accent); }
.linkrows span { flex: 1; }
.linkrows small { color: var(--muted); font-size: 14px; font-weight: 700; }
.linkrows .i:last-child:not(:first-child) { color: var(--faint); }
.linkrows .danger-text .i { color: var(--out); }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-t { color: var(--text); font-weight: 800; font-size: 20px; margin-bottom: 6px; }
.hint { font-size: 14px; color: var(--muted); margin: 0 4px; }
.foot { text-align: center; font-size: 14px; color: var(--muted); padding: 8px 0; }
.link { border: 0; background: none; color: var(--accent); font-weight: 800; font-size: 15px; padding: 0; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.notice { background: var(--soon-bg); border-color: var(--soon-edge); color: #5C3A00; font-size: 15px; }
.secret { font-family: var(--mono); background: #fff; padding: 2px 6px; border-radius: 6px; font-weight: 700; }

/* ---------- Item ---------- */
.itemhead { display: flex; flex-direction: column; gap: 12px; padding: 0 4px; }
.itemsub { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.big { display: flex; align-items: baseline; gap: 8px; }
.big b { font-size: 46px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.big span { font-size: 17px; font-weight: 700; color: var(--muted); }
.starbtn { display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 16px; border-radius: 20px; border: 1.5px solid var(--edge); background: var(--card); color: var(--muted); font-size: 15px; font-weight: 800; flex: none; }
.starbtn .i { stroke: #C9B8A5; }
.starbtn.on { background: var(--soon-bg); border-color: var(--soon-edge); color: #7A4B00; }
.starbtn.on .i { fill: var(--star); stroke: var(--star); }
.starbtn.icon { width: 46px; height: 46px; padding: 0; justify-content: center; border-radius: 23px; border-color: transparent; background: none; }
.starbtn.icon.on { background: var(--soon-bg); border-color: var(--soon-edge); }
.actions3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 10px; }
.action { height: 70px; border-radius: var(--r); border: 1.5px solid var(--edge); background: var(--card); color: var(--text); font-size: 14px; font-weight: 800; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.action.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.action:disabled { color: var(--faint); }

/* ---------- Forms ---------- */
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.tight { gap: 8px; }
.form { display: flex; flex-direction: column; gap: 12px; }
.f { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.f > span { font-size: 14px; font-weight: 800; color: var(--muted); }
.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input:not([type=checkbox]):not([type=radio]):not([type=search]), select, textarea {
  width: 100%; height: 46px; border-radius: 14px; border: 1.5px solid var(--edge); background: #FFFDF9; padding: 0 14px; font-size: 17px; font-weight: 600; outline: none; -webkit-appearance: none; appearance: none; }
select { background: #FFFDF9 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m7 10 5 5 5-5' fill='none' stroke='%238A7666' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E") right 12px center/18px no-repeat; padding-right: 38px; }
input:focus, select:focus { border-color: var(--accent); background-color: #fff; }
input[type=date] { min-height: 46px; }
.formerr { color: var(--out); font-size: 15px; font-weight: 800; margin: 0 4px; }

.stepper { display: flex; align-items: center; gap: 4px; background: var(--soft); border-radius: 24px; width: max-content; padding: 0 2px; }
.stepper.center { margin: 0 auto; }
.stepper input { width: 64px !important; text-align: center; font-weight: 800; font-size: 20px !important; border: 0 !important; background: transparent !important; padding: 0 !important; }
.stepper .step { width: 46px; height: 46px; border-radius: 23px; font-size: 24px; }

.toggles { overflow: hidden; }
.toggle { display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; }
.toggles .toggle + .toggle { border-top: 1.5px dashed var(--line); }
.toggle span { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.toggle small { font-size: 14px; font-weight: 600; color: var(--muted); }
.toggle b { font-weight: 700; }
.toggle input { -webkit-appearance: none; appearance: none; width: 48px; height: 28px; border-radius: 14px; background: #E6DACA; position: relative; flex: none; transition: background .2s; margin: 0; cursor: pointer; }
.toggle input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 11px; background: #fff; box-shadow: 0 1px 3px rgba(91,60,30,.3); transition: transform .2s; }
.toggle input:checked { background: var(--accent); }
.toggle input:checked::after { transform: translateX(20px); }
.toggle input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sheet .toggle { padding: 4px 0; }

.radio { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.radio + .radio { border-top: 1.5px dashed var(--line); }
.radio input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 46px; padding: 0 20px; border-radius: 16px; border: 0; background: var(--accent); color: #fff; font-size: 16px; font-weight: 800; text-align: center; white-space: nowrap; }
.btn.big { height: 54px; font-size: 17px; width: 100%; border-radius: 18px; }
.btn.soft { background: var(--card); color: var(--text); border: 1.5px solid var(--edge); }
.sheet .btn.soft, .card .btn.soft { background: var(--soft); border-color: var(--soft); }
.btn.dark { background: var(--dark); color: #fff; }
.btn.danger { background: var(--out); }
.btn:disabled { opacity: .5; }
.btn:active:not(:disabled) { transform: scale(.98); }
.danger-text { color: var(--out) !important; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.two:has(> :only-child) { grid-template-columns: 1fr; }
.addrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.addrow select, .addrow input:not([type=number]) { flex: 1; min-width: 120px; width: auto; }

/* ---------- Pickers ---------- */
.picks { background: var(--card); border: 1.5px solid var(--edge); border-radius: var(--r); }
.picks.float { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 20; box-shadow: 0 12px 30px rgba(91,60,30,.16); max-height: 50vh; overflow-y: auto; }
.picks li + li { border-top: 1.5px dashed var(--line); }
.pick { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; border: 0; background: none; text-align: left; padding: 12px 16px; font-size: 17px; font-weight: 700; color: var(--text); }
.pick small { color: var(--muted); font-size: 13px; flex: none; }
.pick.new span { color: var(--accent); font-weight: 800; }
.pick.on span { color: var(--accent); font-weight: 800; }
.sheet .search, .sheet .picks { background: #FFFDF9; }

/* ---------- Tab bar ---------- */
.tabbar { position: fixed; left: 12px; right: 12px; bottom: calc(12px + var(--safe-b)); z-index: 30; height: 68px; background: rgba(255,255,255,.97); border: 1.5px solid var(--edge); border-radius: 26px; box-shadow: 0 8px 24px rgba(91,60,30,0.12); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center; max-width: 616px; margin: 0 auto; }
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 11px; font-weight: 700; position: relative; }
.tab.on { color: var(--accent); font-weight: 800; }
.badge { position: absolute; top: -4px; left: 50%; margin-left: 6px; min-width: 19px; height: 19px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; padding: 0 5px; border: 2px solid #fff; }
.scanbtn { justify-self: center; width: 58px; height: 58px; border-radius: 20px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 14px rgba(178,58,31,0.35); }
.scanbtn:active { transform: scale(.95); }
.scanbtn.on { background: var(--accent-dark); }
.tabbrand, .scanlabel { display: none; }

.bottombar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; padding: 12px 16px calc(12px + var(--safe-b)); background: rgba(251,246,238,0.97); border-top: 1.5px solid var(--edge); display: flex; gap: 10px; align-items: center; max-width: 640px; margin: 0 auto; }
.bottombar.abovetabs { bottom: calc(86px + var(--safe-b)); left: 12px; right: 12px; max-width: 616px; border: 1.5px solid var(--edge); border-radius: 22px; background: #fff; box-shadow: 0 6px 18px rgba(91,60,30,.12); padding: 10px 12px; }
.bottombar .btn.big { width: auto; padding: 0 20px; }
.bottombar .btn.big.grow { flex: 1; }
.bottombar select { flex: 1; width: auto; }
#movecount { font-size: 15px; white-space: nowrap; }

/* ---------- Camera ---------- */
.camera { position: relative; height: 300px; margin: 0 -16px; background: #1E1915; overflow: hidden; display: flex; align-items: center; justify-content: center; border-radius: 0 0 28px 28px; }
.camera.short { height: 240px; }
.reader { position: absolute !important; inset: 0 !important; width: 100% !important; height: 100% !important; border: 0 !important; }
.reader video { position: absolute; inset: 0; width: 100% !important; height: 100% !important; object-fit: cover; }
.reader img, .reader #qr-shaded-region, .reader > div:not(:first-child) { display: none !important; }
.reader #qr-shaded-region { border: 0 !important; }
.cam-frame { position: relative; width: 260px; height: 130px; border-radius: 20px; border: 3px solid rgba(255,255,255,0.92); pointer-events: none; }
.camera.short .cam-frame { height: 110px; }
.cam-x { position: absolute; top: calc(14px + env(safe-area-inset-top, 0px)); left: 14px; width: 40px; height: 40px; border-radius: 20px; background: rgba(255,255,255,0.18); color: #fff; display: flex; align-items: center; justify-content: center; z-index: 2; }
.cam-title { position: absolute; top: calc(24px + env(safe-area-inset-top, 0px)); left: 64px; right: 64px; text-align: center; color: #fff; font-size: 15px; font-weight: 800; z-index: 2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cam-hint { position: absolute; bottom: 16px; left: 16px; right: 16px; text-align: center; color: #E6DACA; font-size: 14px; font-weight: 700; z-index: 2; }
#main:has(.camera) { padding-top: 0; }
.under { display: flex; flex-direction: column; gap: 12px; }
.res-t { font-size: 20px; font-weight: 800; line-height: 1.25; }
.res-n { margin-top: 4px; color: var(--muted); }
.res-n b { font-size: 30px; color: var(--text); font-variant-numeric: tabular-nums; }
.lastscan { display: flex; flex-direction: column; gap: 6px; box-shadow: 0 4px 14px rgba(91,60,30,0.08); }
.lastscan .res-t { font-size: 17px; }
.lastscan .two { margin-top: 6px; }
.waiting { font-size: 14px; color: var(--soon); font-weight: 800; margin: 0 4px; }

/* ---------- Bottom sheet ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; }
.sheet-back { position: absolute; inset: 0; background: rgba(43,36,32,0); transition: background .25s; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-width: 640px; margin: 0 auto; background: var(--bg); border-radius: 28px 28px 0 0; padding: 10px 16px calc(22px + var(--safe-b)); max-height: 88vh; overflow-y: auto; transform: translateY(100%); transition: transform .26s cubic-bezier(.2,.8,.2,1); box-shadow: 0 -8px 30px rgba(91,60,30,.16); }
.sheet-wrap.open .sheet-back { background: rgba(43,36,32,.36); }
.sheet-wrap.open .sheet { transform: none; }
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: #D9CBB8; margin: 0 auto 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sheet-head h2 { font-size: 22px; font-weight: 800; }
.sheet-x { width: 34px; height: 34px; border-radius: 17px; border: 1.5px solid var(--edge); background: var(--card); color: var(--muted); display: flex; align-items: center; justify-content: center; flex: none; }
.sheet-x .i { stroke-width: 2.6; }
.sheet-text { font-size: 15px; color: var(--muted); }
.sheet-text b { color: var(--text); }
.sheet-note { font-size: 14px; color: var(--muted); text-align: center; }
.sheet .card.pad, .sheet .card.picks { background: var(--card); }

/* ---------- Toast ---------- */
#toast { position: fixed; left: 16px; right: 16px; bottom: calc(96px + var(--safe-b)); z-index: 60; max-width: 520px; margin: 0 auto; background: rgba(43,36,32,.95); color: #fff; padding: 13px 16px; border-radius: 18px; font-size: 15px; font-weight: 700; text-align: center; opacity: 0; transform: translateY(10px); transition: opacity .2s, transform .2s; pointer-events: none; }
#toast.show { opacity: 1; transform: none; }
#toast.err { background: var(--out); }
#toast.warn { background: #7A4B00; }
body.sheet-open #toast { bottom: auto; top: calc(12px + env(safe-area-inset-top, 0px)); }

/* ---------- Places ---------- */
.placeinfo { width: 100%; text-align: left; color: var(--text); font-size: 17px; }
.placeinfo > span:first-child { display: flex; flex-direction: column; gap: 2px; }
.placeinfo small { font-size: 14px; font-weight: 700; color: var(--muted); }

/* ---------- Sign in ---------- */
.login { max-width: 380px; width: 100%; margin: 12vh auto 0; text-align: center; }
.login h1 { font-size: 34px; font-weight: 800; }
.login .card { text-align: left; }
.logo { width: 68px; height: 68px; border-radius: 22px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; margin: 0 auto; box-shadow: 0 8px 20px rgba(178,58,31,.3); }

@media (prefers-reduced-motion: reduce) { .sheet, .sheet-back, #toast, .tile { transition: none; } }

/* ---------- Tidy names ---------- */
.mergecard { gap: 10px; }
.row.tidy { align-items: center; }
.row.tidy .row-main { gap: 4px; }
.row.tidy input:not([type=checkbox]) { width: 100%; height: 42px; border-radius: 12px; border: 1.5px solid var(--edge); background: var(--soft); padding: 0 12px; font-size: 16px; font-weight: 700; }
.row.tidy input:not([type=checkbox]):focus { outline: none; border-color: var(--accent); background: #fff; }
#app[data-page=tidy] #main { padding-bottom: calc(var(--tabs) + 100px); }

/* ---------- Dinners ---------- */
.weeknav { display: flex; align-items: center; gap: 10px; }
.weeklabel { flex: 1; text-align: center; height: 42px; line-height: 39px; border-radius: 21px; border: 1.5px solid var(--edge); background: var(--card); color: var(--text); font-size: 15px; font-weight: 800; }
.weeklabel.on { background: var(--dark); border-color: var(--dark); color: #fff; }
.day { display: flex; flex-direction: column; gap: 8px; scroll-margin-top: 16px; }
.day-h { display: flex; align-items: center; gap: 8px; margin: 0 4px; min-height: 34px; }
.day-h h2 { font-size: 17px; font-weight: 800; }
.day-h h2 span { color: var(--muted); font-weight: 700; font-size: 15px; margin-left: 2px; }
.daymenu { margin-left: auto; width: 36px; height: 34px; border-radius: 17px; border: 0; background: none; color: var(--muted); display: flex; align-items: center; justify-content: center; }
.tagpill { font-size: 12px; font-weight: 800; padding: 3px 9px; border-radius: 10px; background: var(--accent); color: #fff; }
.tagpill.soft { background: var(--soft); color: #6B4A2E; }
.day.today .card { border-color: var(--accent); }
.day.past { opacity: .62; }
.row.dinner { min-height: 58px; }
.who { width: 30px; height: 30px; border-radius: 15px; color: #fff; font-size: 14px; font-weight: 800; display: flex; align-items: center; justify-content: center; flex: none; }
.offplan { display: flex; flex-direction: column; background: var(--soft); border-style: dashed; }
.offplan span { font-size: 14px; color: var(--muted); }
.row-s.plan { color: #3D6F9E; }
.updown { display: flex; gap: 2px; flex: none; }
.iconbtn { width: 36px; height: 36px; border-radius: 18px; border: 0; background: var(--soft); color: #6B4A2E; display: flex; align-items: center; justify-content: center; padding: 0; }
.iconbtn:disabled { opacity: .35; }
.samebtns { display: flex; flex-wrap: wrap; gap: 8px; }
.tonight { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1.5px solid var(--edge); border-radius: var(--r); padding: 12px 14px; color: var(--text); }
.tonight > .i:first-child { color: var(--accent); }
.tonight .i:last-child { color: var(--faint); }
.tonight div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.tonight b { font-size: 15px; }
.tonight span { font-size: 15px; color: var(--muted); }
.tonight span em { font-style: normal; color: var(--text); font-weight: 700; }

/* ---------- Desktop: sidebar instead of the bottom bar, wider pages ---------- */
@media (min-width: 1024px) {
  :root { --side: 236px; --tabs: 0px; }
  body { padding-left: var(--side); }
  #main { --w: 820px; max-width: var(--w); padding: 28px 40px 64px; gap: 18px; }
  #main.bare { padding-left: 16px; padding-right: 16px; }
  body:has(#main.bare) { padding-left: 0; }
  #app[data-page=pantry] #main, #app[data-page=shopping] #main { --w: 1180px; }
  #app[data-page=places] #main, #app[data-page=favourites] #main, #app[data-page=merge] #main { --w: 960px; }
  #app[data-page=dinners] #main { --w: 1640px; }

  .tabbar { left: 0; top: 0; bottom: 0; right: auto; width: var(--side); height: auto; max-width: none; margin: 0; border: 0; border-right: 1.5px solid var(--edge); border-radius: 0; box-shadow: none; background: var(--card);
            display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 26px 16px; }
  .tabbrand { display: flex; align-items: center; gap: 10px; padding: 0 10px 18px; color: var(--text); font-size: 22px; font-weight: 800; order: 0; }
  .tabbrand .i { color: var(--accent); }
  .scanbtn { order: 1; justify-self: auto; width: auto; height: 50px; border-radius: 16px; gap: 10px; justify-content: flex-start; padding: 0 16px; margin-bottom: 14px; box-shadow: 0 4px 12px rgba(178,58,31,.25); }
  .scanbtn .i { width: 22px; height: 22px; }
  .scanlabel { display: inline; font-size: 16px; font-weight: 800; }
  .tab { order: 2; flex-direction: row; gap: 12px; padding: 11px 12px; border-radius: 14px; color: var(--text); font-size: 16px; font-weight: 700; }
  .tab .i { width: 22px; height: 22px; color: var(--muted); }
  .tab:hover { background: var(--soft); }
  .tab.on { background: var(--accent-soft); color: var(--accent); }
  .tab.on .i { color: var(--accent); }
  .badge { position: static; margin-left: auto; border: 0; }

  .bottombar { left: var(--side); right: 0; max-width: 820px; }
  .bottombar.abovetabs { bottom: 24px; left: calc(var(--side) + 40px); right: 40px; max-width: 740px; }
  #toast { bottom: 28px; left: calc(var(--side) + 16px); }

  /* Sheets open as a dialog in the middle of the screen */
  .sheet { top: 50%; bottom: auto; left: calc(50% + var(--side) / 2); right: auto; width: 480px; max-width: calc(100vw - var(--side) - 48px); max-height: 86vh; margin: 0; border-radius: 24px;
           padding: 20px 22px 24px; transform: translate(-50%, -46%); opacity: 0; transition: transform .2s, opacity .2s; box-shadow: 0 20px 60px rgba(43,36,32,.25); }
  .sheet-wrap.open .sheet { transform: translate(-50%, -50%); opacity: 1; }
  .sheet-handle { display: none; }
  body.sheet-open #toast { top: 20px; }

  .camera { margin: 0; border-radius: 24px; height: 380px; }
  #main:has(.camera) { padding-top: 28px; }

  a.row-main:hover .row-t, .row-main.plain:hover .row-t { color: var(--accent); }
  .chips { margin: 0; padding: 0 0 2px; flex-wrap: wrap; }

  /* Pantry: places side by side */
  #list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 24px; align-items: start; }

  /* Shopping: list and suggestions side by side */
  #app[data-page=shopping] #live { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 24px; align-items: start; }
  #app[data-page=shopping] #live > :not(.group) { grid-column: 1 / -1; }
  #app[data-page=shopping] #live:not(:has(.group + .group)) .group { grid-column: 1 / -1; }

  /* Dinners: the whole week at once */
  #app[data-page=dinners] .weeknav { max-width: 520px; }
  #app[data-page=dinners] #live { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px 12px; align-items: start; }
  #app[data-page=dinners] #live > :not(.day) { grid-column: 1 / -1; }
  #app[data-page=dinners] #live > .btn { justify-self: start; width: auto; padding: 0 22px; }
  .day-h { flex-wrap: wrap; row-gap: 2px; min-height: 58px; align-content: flex-start; margin: 0 2px; }
  .day-h h2 { font-size: 16px; width: 100%; }
  .day-h .daymenu { height: 26px; }
  .day.past { opacity: .55; }
  .row.dinner { gap: 8px; padding: 8px 8px 8px 10px; min-height: 56px; }
  .row.dinner .who { width: 24px; height: 24px; font-size: 12px; }
  .row.dinner .row-t { font-size: 15px; line-height: 20px; }
  .row.dinner .row-s { font-size: 13px; line-height: 17px; }
  .offplan { min-height: 120px; justify-content: center; }
}
@media (min-width: 1400px) {
  #app[data-page=dinners] #live { grid-template-columns: repeat(7, minmax(0, 1fr)); }
}
