/* Layout: shopping list and cart on the left, receipt-style total on the right (above the lists on phones) */
:root {
  --bg: #eef2ec;
  --surface: #ffffff;
  --ink: #1b2a21;
  --muted: #5d6e63;
  --line: #d5ddd4;
  --accent: #2e7a4c;
  --accent-ink: #ffffff;
  --paper: #fbfcf7;
  --danger: #b4412a;
  --warn-bg: #fbeee0;
  --warn-ink: #7a4513;
  --focus: #2e7a4c55;
  /* Budget sheet: paid cells and the sheet's row-group colours */
  --paid: #c6efc6;
  --paid-ink: #14532d;
  --paid-strong: #2e9e4f;
  --nocell: #f1f3f0;
  --g-debts: #f6e3e8;
  --g-house: #ebe6f5;
  --g-save: #fcebdc;
  --g-cash: #e0ebf8;
  --g-big: #f5dcdc;
  --comment: #e08a00;
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111814; --surface: #19221d; --ink: #e4ece6; --muted: #93a499;
    --line: #2b3830; --accent: #5cc187; --accent-ink: #0d1a12; --paper: #1d2721;
    --danger: #ef8a72; --warn-bg: #3a2a18; --warn-ink: #f3c48e; --focus: #5cc18766;
    --paid: #1e4d2c; --paid-ink: #bdf0c8; --paid-strong: #5cc187; --nocell: #151d18;
    --g-debts: #33242a; --g-house: #2a2636; --g-save: #352a1f; --g-cash: #1f2a37; --g-big: #362222;
    --comment: #f2b544;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 15px; line-height: 1.5;
  padding-top: calc(env(safe-area-inset-top, 0px) + 20px);
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 32px);
  padding-left: calc(env(safe-area-inset-left, 0px) + 16px);
  padding-right: calc(env(safe-area-inset-right, 0px) + 16px);
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.right { text-align: right; }

h1 {
  font-family: var(--font-display); font-weight: 800; font-size: clamp(28px, 5vw, 40px);
  letter-spacing: -0.02em; line-height: 1; margin: 0; text-wrap: balance;
}
h1 span { color: var(--accent); }

/* 16px inputs stop iOS from zooming the page on focus */
select, input {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-width: 0;
}
input:focus-visible, select:focus-visible, button:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
button {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 8px;
  border: 1px solid transparent; padding: 10px 16px; color: inherit;
}
button:disabled { opacity: .55; cursor: default; }
.primary { background: var(--accent); color: var(--accent-ink); }
.ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.danger { background: var(--danger); color: var(--surface); }
.wide { width: 100%; }
.link { background: none; border: 0; padding: 4px 0; color: var(--muted); font-weight: 500; text-decoration: underline; }
.form-msg { grid-column: 1 / -1; margin: 0; font-size: 14px; color: var(--danger); }
@media (hover: hover) {
  .primary:hover { filter: brightness(1.07); }
  .ghost:hover { color: var(--ink); }
}

/* Sign-in and name screens */
.center-screen { min-height: 70vh; display: grid; place-items: center; }
.gate {
  width: 100%; max-width: 380px; display: grid; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 24px;
}
.gate h1 { font-size: 32px; }
.gate p { margin: 0; }
.field-label { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips:empty { display: none; }
.chip-btn {
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; font-weight: 600; font-size: 14px;
}

/* App shell */
.wrap { max-width: 1040px; margin: 0 auto; display: grid; gap: 20px; }
.top { display: flex; align-items: end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sub { margin: 6px 0 0; color: var(--muted); }
.top-tools { display: flex; align-items: center; gap: 8px; }
.top-tools select { padding: 6px 10px; }
/* Household home */
.home { max-width: 560px; }
.tiles { display: grid; gap: 12px; }
.tile {
  display: flex; align-items: center; gap: 16px; padding: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  color: var(--ink); text-decoration: none; min-width: 0;
}
.tile-icon {
  flex: none; width: 52px; height: 52px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
}
.tile-icon svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tile-body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.tile-body strong { font-family: var(--font-display); font-weight: 600; font-size: 20px; line-height: 1.2; }
.tile-sub { color: var(--muted); font-size: 14px; }
.chev { flex: none; font-size: 28px; line-height: 1; color: var(--muted); }
.tile:active { background: var(--paper); }
@media (hover: hover) { .tile:hover { border-color: var(--accent); } }
.tile:focus-visible, .back:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.back {
  justify-self: start; color: var(--accent); font-weight: 600; text-decoration: none;
  padding: 4px 0; margin-bottom: -8px;
}
/* Budget Tracker — a phone-sized version of the household sheet */
.budget { max-width: 760px; }
.small { padding: 6px 12px; font-size: 14px; }
.period-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.period-bar select { flex: 1 1 180px; font-weight: 600; }
.b-empty { padding: 20px; display: grid; gap: 4px; }
.b-empty p { margin: 0; }
#b-body { display: grid; gap: 14px; }

.bsum {
  position: sticky; top: calc(env(safe-area-inset-top, 0px) + 8px); z-index: 5;
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px; display: grid; gap: 10px;
  box-shadow: 0 6px 18px -12px rgb(0 0 0 / 0.35);
}
.bsum-line { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 8px; }
.bsum-line > span { display: grid; min-width: 0; }
.bsum-line .k { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.bsum-line b { font-weight: 600; font-size: 13px; white-space: nowrap; }
.bsum-line > span:first-child b { font-size: 17px; color: var(--accent); }
.pots-sum { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.potcard {
  display: grid; gap: 2px; text-align: left; min-width: 0; padding: 6px 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; font-weight: 400;
}
.potcard-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.potcard-total { font-size: 13px; font-weight: 600; }
.potcard-meta { font-size: 11px; color: var(--muted); }
.potcard-left { font-size: 11px; color: var(--accent); font-weight: 600; }
.potcard-left.over { color: var(--danger); }
.bar { display: block; height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar-fill { display: block; height: 100%; width: 0; background: var(--paid-strong); border-radius: inherit; }
@media (prefers-reduced-motion: no-preference) { .bar-fill { transition: width .3s ease; } }

/* The sheet */
.sheet-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.sheet { width: 100%; border-collapse: collapse; font-size: 13px; }
.sheet th, .sheet td { padding: 0; border-bottom: 1px solid var(--line); }
.sheet thead th { position: sticky; top: 0; background: var(--surface); font-size: 12px; vertical-align: bottom; }
.sheet .corner { text-align: left; padding: 8px 10px; font-family: var(--font-display); font-size: 14px; }
.pothead {
  width: 100%; display: grid; gap: 1px; padding: 8px 6px; background: transparent; border-radius: 0;
  font-size: 12px; font-weight: 600; text-align: right;
}
.pothead small { font-weight: 400; color: var(--muted); font-size: 10px; }
.sheet tbody th { text-align: left; font-weight: 500; }
.sheet td { text-align: right; width: 24%; }
.linename {
  width: 100%; text-align: left; background: transparent; border-radius: 0;
  padding: 8px 8px 8px 10px; font-weight: 500; font-size: 13px; line-height: 1.3; overflow-wrap: anywhere;
}
.cell {
  width: 100%; min-height: 36px; padding: 8px 6px; border-radius: 0; background: transparent;
  font-weight: 500; font-size: 12px; text-align: right;
}
.cell.paid { background: var(--paid); color: var(--paid-ink); font-weight: 600; }
/* Paid: green fill plus an inset bar, so it doesn't rely on colour alone */
.cell.paid { box-shadow: inset 3px 0 0 var(--paid-strong); }
.cell .num { white-space: nowrap; }
.cell { position: relative; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
/* Comment marker in the corner, like a spreadsheet comment */
.cell.has-comment::before {
  content: ""; position: absolute; top: 0; right: 0;
  border-style: solid; border-width: 0 9px 9px 0;
  border-color: transparent var(--comment) transparent transparent;
}
.cell.menu-open { outline: 2px solid var(--accent); outline-offset: -2px; }

.cellmenu {
  position: fixed; z-index: 50; width: 270px; display: grid; gap: 8px; padding: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 30px -12px rgb(0 0 0 / 0.45);
}
.cm-where { margin: 0; font-size: 12px; font-weight: 600; color: var(--muted); }
.cm-comment {
  margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--paper);
  border-left: 3px solid var(--comment); font-size: 13px; white-space: pre-wrap;
  overflow-wrap: anywhere; max-height: 140px; overflow-y: auto;
}
.cm-actions { display: flex; gap: 6px; }
.cm-actions button { flex: 1; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.cm-actions svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.cm-del { color: var(--danger); }
.cm-del[data-armed] { background: var(--danger); color: var(--surface); border-color: var(--danger); }
#dc-text {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; resize: vertical;
}

.nocell { color: var(--muted); background: var(--nocell); font-size: 12px; text-align: center !important; }
@media (hover: hover) {
  .cell:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
  .linename:hover, .pothead:hover { text-decoration: underline; }
}

/* Group colours, like the sheet */
.line.g-debts th { background: var(--g-debts); }
.line.g-household th { background: var(--g-house); }
.line.g-savings th { background: var(--g-save); }
.line.g-cash th { background: var(--g-cash); }
.line.g-big th { background: var(--g-big); }
.grp th {
  padding: 10px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); border-bottom: 0;
}
.grp th { display: table-cell; }
.grp th span { vertical-align: middle; }
.grp .add-line { float: right; font-size: 12px; text-transform: none; letter-spacing: 0; padding: 0; }
.subtotal th, .subtotal td, .grandtotal th, .grandtotal td { padding: 9px 6px; font-weight: 700; }
.subtotal th, .grandtotal th { padding-left: 10px; }
.grandtotal th, .grandtotal td { border-top: 2px solid var(--ink); }
.incomerow th, .incomerow td, .leftrow th, .leftrow td { padding: 7px 6px; color: var(--muted); }
.incomerow th, .leftrow th { padding-left: 10px; font-weight: 600; }
.leftrow td { color: var(--accent); font-weight: 600; }
.leftrow td.over { color: var(--danger); }
#b-add-pot { justify-self: start; }

.notes { display: grid; }
.notes textarea {
  margin: 0 16px; font: inherit; font-size: 16px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; resize: vertical; min-height: 110px;
}
.notes-actions { padding: 10px 16px 14px; }

/* Dialogs */
dialog {
  width: min(460px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto;
  border: 1px solid var(--line); border-radius: 16px; padding: 0;
  background: var(--surface); color: var(--ink);
}
dialog::backdrop { background: rgb(10 20 14 / 0.45); }
dialog form { display: grid; gap: 12px; padding: 20px; }
dialog h2 { font-family: var(--font-display); font-size: 21px; margin: 0; }
dialog select { width: 100%; }
.hint { margin: 0; font-size: 13px; color: var(--muted); }
.potfields { display: grid; gap: 10px; }
.potfield { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; }
.potfield > label:first-child { grid-column: 1 / -1; font-size: 13px; font-weight: 600; }
.potfield > label small { font-weight: 400; color: var(--muted); }
.potfield input[type=number] { width: 100%; }
.check { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.checks { display: grid; gap: 8px; }
.dlg-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.danger-link { margin-left: auto; background: none; border: 0; color: var(--danger); padding: 8px 4px; font-weight: 600; }

.offline { margin: 0; padding: 10px 14px; border-radius: 8px; background: var(--warn-bg); color: var(--warn-ink); font-weight: 500; }

.main { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.col { display: grid; gap: 20px; min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 14px 16px 10px; }
.card-head h2 { font-family: var(--font-display); font-weight: 600; font-size: 19px; margin: 0; }
.count { font-size: 12px; color: var(--muted); }
.by { font-size: 12px; font-weight: 500; color: var(--muted); }

/* Shopping list */
.shop-summary { margin: -4px 16px 10px; font-size: 13px; font-weight: 600; color: var(--accent); }
.shop-add { display: grid; gap: 8px; padding: 0 16px 14px; }
.shop-add > .primary { justify-self: stretch; }

/* Amount picker: − 2 +  [pcs] [packs] [kg] [g] [More…] */
.amount-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.stepper.big { background: var(--surface); }
.stepper.big button { padding: 8px 14px; font-size: 20px; color: var(--accent); }
.stepper.big input {
  width: 64px; border: 0; border-radius: 0; padding: 8px 0; text-align: center;
  font-family: var(--font-mono); font-weight: 600; background: transparent;
  -moz-appearance: textfield;
}
.stepper.big input::-webkit-inner-spin-button, .stepper.big input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.unit-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip, .unit-more {
  font-size: 14px; font-weight: 600; padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.unit-more { width: auto; padding-right: 8px; }
.chip.on, .unit-more.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.plan-form { display: grid; gap: 10px; padding: 4px 16px 14px 50px; }
.plan-form .btns { display: flex; gap: 8px; }
.srow.planning { background: var(--paper); }
.found-title { grid-column: 1 / -1; margin: 0; font-weight: 600; font-size: 14px; }
.found-form .amount-picker { grid-column: 1 / -1; }
.shop-cat {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  padding: 12px 16px 4px; border-top: 1px solid var(--line);
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.shop-cat + .srow { border-top: 0; }
.nm-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.qty-badge {
  flex: none; font-size: 13px; font-weight: 600; padding: 5px 10px; border-radius: 999px;
  background: var(--bg); color: var(--accent); border: 1px solid var(--line); white-space: nowrap;
}
@media (hover: hover) { .qty-badge:hover { border-color: var(--accent); } }
.shop-empty { margin: 0; padding: 4px 16px 18px; color: var(--muted); font-size: 14px; }
.srow { border-top: 1px solid var(--line); }
.srow-top { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; }
.found {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; text-align: left;
  background: transparent; padding: 10px; font-weight: 600;
}
.found .box { flex: none; width: 22px; height: 22px; border: 2px solid var(--muted); border-radius: 6px; }
.found .nm { min-width: 0; overflow-wrap: anywhere; display: grid; }
.found .hint { margin-left: auto; flex: none; font-size: 12px; font-weight: 500; color: var(--muted); }
.srow.open { background: var(--paper); }
.srow.open .found .box { border-color: var(--accent); background: var(--accent); }
.x { padding: 8px; background: transparent; color: var(--muted); line-height: 0; border-radius: 6px; }
.x svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
@media (hover: hover) {
  .found:hover { background: var(--bg); }
  .found:hover .box { border-color: var(--accent); }
  .x:hover { color: var(--danger); background: var(--bg); }
}
.found-form {
  display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 10px; align-items: end;
  padding: 0 16px 14px 50px;
}
.found-form select { width: 100%; }
.found-form .btns { grid-column: 1 / -1; display: flex; gap: 8px; }
.found-form .form-msg { grid-column: 1 / -1; }

/* Cart */
.add {
  display: grid; gap: 10px; padding: 0 16px 14px;
  grid-template-columns: minmax(0, 1fr) 80px 100px 130px auto; align-items: end;
  border-bottom: 1px solid var(--line);
}
.field { display: grid; gap: 4px; min-width: 0; }
.field label { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.field input, .field select { width: 100%; }
.add-actions { display: flex; gap: 8px; }

.list-head, .row {
  display: grid; grid-template-columns: minmax(0, 1fr) 118px 104px 108px 128px;
  gap: 12px; align-items: center; padding: 10px 16px;
}
.list-head {
  font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted); border-bottom: 1px solid var(--line);
}
.list-head:has(+ #rows:empty) { display: none; }
.row + .row { border-top: 1px solid var(--line); }
.row.editing { background: var(--paper); }
.name { font-weight: 600; overflow-wrap: anywhere; }
.name .by { display: block; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; }
.stepper button { padding: 6px 12px; background: transparent; font-size: 17px; line-height: 1; }
.stepper span { min-width: 30px; text-align: center; white-space: nowrap; }
.stepper small, .c-price small { font-size: 11px; color: var(--muted); font-family: var(--font-body); }
.stepper button:disabled { opacity: 0.3; }
.line-total { font-weight: 600; }
.row-actions { display: flex; justify-content: end; align-items: center; gap: 4px; }
.icon { padding: 7px; background: transparent; color: var(--muted); border-radius: 6px; line-height: 0; }
.icon svg, .remove svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon svg { width: 18px; height: 18px; }
.remove {
  display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px; font-size: 13px;
  background: transparent; color: var(--danger); border: 1px solid var(--line); border-radius: 6px;
}
.remove svg { width: 15px; height: 15px; }
@media (hover: hover) {
  .stepper button:hover { color: var(--accent); }
  .icon:hover { color: var(--ink); background: var(--bg); }
  .remove:hover { border-color: var(--danger); background: var(--bg); }
}
.each { display: none; }
.empty { padding: 32px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-family: var(--font-display); font-size: 20px; margin-bottom: 4px; }

/* Receipt */
.receipt {
  background: var(--paper); border: 1px solid var(--line); border-radius: 4px;
  padding: 20px 20px 26px; font-family: var(--font-mono); font-size: 13px;
  position: sticky; top: calc(env(safe-area-inset-top, 0px) + 16px);
  -webkit-mask: radial-gradient(circle at 50% 100%, transparent 4px, #000 4.5px) bottom / 8px 8px repeat-x,
                linear-gradient(#000, #000) top / 100% calc(100% - 7px) no-repeat;
          mask: radial-gradient(circle at 50% 100%, transparent 4px, #000 4.5px) bottom / 8px 8px repeat-x,
                linear-gradient(#000, #000) top / 100% calc(100% - 7px) no-repeat;
}
.receipt h2 { font-family: var(--font-mono); font-size: 13px; font-weight: 600; letter-spacing: 0.2em; text-align: center; margin: 0 0 4px; }
.receipt .stamp { text-align: center; color: var(--muted); margin: 0 0 12px; }
.rule { border: 0; border-top: 1px dashed var(--muted); margin: 10px 0; opacity: 0.6; }
.rline { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }
.rline span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.rlines { display: grid; gap: 2px; max-height: 260px; overflow-y: auto; }
.grand { font-size: 20px; font-weight: 600; margin-top: 4px; }
.grand span:last-child { color: var(--accent); }
.receipt .meta { color: var(--muted); }
.ramounts { margin: 2px 0 0; color: var(--ink); font-size: 12px; line-height: 1.5; }
.clear { margin-top: 14px; width: 100%; font-family: var(--font-body); font-size: 13px; }
.confirm { margin-top: 12px; font-family: var(--font-body); font-size: 13px; display: grid; gap: 8px; }
.confirm p { margin: 0; }
.confirm div { display: flex; gap: 8px; }
.confirm button { flex: 1; padding: 8px; }

.foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.status { font-size: 13px; color: var(--muted); margin: 0; }

@media (max-width: 760px) {
  .main { grid-template-columns: 1fr; }
  .receipt { position: static; order: -1; }
  .add { grid-template-columns: 1fr 1fr; }
  .add .field:first-child, .add .field:nth-child(4) { grid-column: 1 / -1; }
  .add-actions { grid-column: 1 / -1; }
  .add-actions .primary { flex: 1; }
  .found-form { grid-template-columns: 1fr 1fr; padding-left: 16px; }
  .plan-form { padding-left: 16px; }
  .plan-form .btns .primary { flex: 1; }
  .found-form .btns { grid-column: 1 / -1; }
  .found-form .btns .primary { flex: 1; }
  .found .hint { display: none; }
  .list-head { display: none; }
  .row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "name total" "qty actions";
    row-gap: 8px;
  }
  .row .c-name { grid-area: name; }
  .row .c-qty { grid-area: qty; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-width: 0; }
  .row .c-price { display: none; }
  .row .c-total { grid-area: total; }
  .row .c-actions { grid-area: actions; }
  .each { display: inline; color: var(--muted); font-size: 13px; white-space: nowrap; }
}
@media (prefers-reduced-motion: no-preference) {
  .row, .srow { transition: background-color .2s; }
}

/* ---------- Grocery: search, folding aisles, phone tabs ---------- */
.shop-tools { display: flex; gap: 8px; padding: 0 16px 12px; }
.shop-tools input { flex: 1; min-width: 0; }
.shop-tools button { flex: none; }
.shop-add { padding-top: 2px; }
.card-head .small { flex: none; }

button.shop-cat {
  width: 100%; border-radius: 0; background: transparent; font-family: inherit; text-align: left;
}
button.shop-cat > span:first-child::before {
  content: ""; display: inline-block; width: 0; height: 0; margin: 0 8px 1px 0;
  border-left: 5px solid currentColor; border-top: 4px solid transparent; border-bottom: 4px solid transparent;
  transform: rotate(90deg); transition: transform .15s;
}
button.shop-cat[aria-expanded="false"] > span:first-child::before { transform: none; }
button.shop-cat[aria-expanded="false"] { padding-bottom: 12px; }
@media (hover: hover) { button.shop-cat:hover { color: var(--ink); } }

/* Hidden on computers: there the list, cart and receipt sit side by side. */
.gbar { display: none; }

@media (max-width: 760px) {
  /* Only the chosen tab's part shows. */
  #screen-grocery [data-pane] { display: none; }
  #screen-grocery[data-tab="list"] [data-pane="list"],
  #screen-grocery[data-tab="cart"] [data-pane="cart"],
  #screen-grocery[data-tab="receipt"] [data-pane="receipt"] { display: block; }
  #screen-grocery .sub { display: none; }
  /* Room for the fixed bar at the bottom. */
  #screen-grocery { padding-bottom: calc(118px + env(safe-area-inset-bottom, 0px)); }

  .gbar {
    display: grid; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -8px 24px -16px rgb(0 0 0 / 0.35);
  }
  .gtotal {
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    margin: 0; padding: 9px 16px; border-radius: 0; background: var(--paper);
    border-bottom: 1px solid var(--line); font-weight: 500; font-size: 14px; color: var(--muted);
  }
  .gtotal b { font-size: 18px; color: var(--accent); font-weight: 600; }
  .gtabs { display: grid; grid-template-columns: repeat(3, 1fr); }
  .gtabs button {
    position: relative; display: grid; justify-items: center; gap: 2px;
    padding: 8px 4px 10px; border-radius: 0; background: transparent;
    font-size: 12px; font-weight: 600; color: var(--muted);
  }
  .gtabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .gtabs button[aria-selected="true"] { color: var(--accent); }
  .gtabs button[aria-selected="true"]::before {
    content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px;
    border-radius: 0 0 3px 3px; background: var(--accent);
  }
  .gtabs .badge {
    position: absolute; top: 4px; left: calc(50% + 8px);
    min-width: 18px; padding: 0 5px; border-radius: 999px;
    background: var(--accent); color: var(--accent-ink); font-size: 11px; line-height: 18px;
  }
  .gtabs .badge:empty { display: none; }
}
