:root {
  --ground: #f4f2ec;
  --paper: #ffffff;
  --ink: #111114;
  --muted: #55555e;
  --line: #e4e1d8;
  --accent: #ffd60a;
  --good-bg: #ddf3e8;
  --good-fg: #04563e;
  --warn-bg: #ffe9c7;
  --warn-fg: #5c2e00;
  --sans: 'Bricolage Grotesque', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  --radius: 16px;
  --shadow: 3px 3px 0 var(--ink);
}

/* Fast repeated taps (3 beers = 3 taps) shouldn't double-tap zoom. Pinch zoom still works. */
* { box-sizing: border-box; touch-action: manipulation; }

html, body {
  margin: 0;
  height: 100%;
  background: #e7e4dc;
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
:focus-visible { outline: 3px solid #3d5afe; outline-offset: 2px; }
h1:focus { outline: none; }

.app {
  position: relative;
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  background: var(--ground);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@media (min-width: 520px) {
  .app { border-left: 2px solid var(--ink); border-right: 2px solid var(--ink); }
}

/* Header */
.top {
  flex: none;
  height: 64px;
  padding: env(safe-area-inset-top) 16px 0;
  display: grid;
  grid-template-columns: 72px 1fr 72px;
  align-items: center;
}
button.brand { justify-self: center; display: flex; align-items: center; min-height: 44px; padding: 0 6px; border: none; border-radius: 10px; background: none; }
.brand img { display: block; width: auto; height: 48px; }

/* Screens */
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 20px 24px; display: flex; flex-direction: column; gap: 18px; }
/* Children keep their natural height so the list scrolls instead of being squashed and clipped. */
.scroll > *, .scroll > .col > * { flex-shrink: 0; }
/* A column wrapper only matters on wide screens. On phones its children sit in the main list. */
.col { display: contents; }
.scroll { -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.foot {
  flex: none;
  padding: 14px 20px calc(18px + env(safe-area-inset-bottom));
  border-top: 2px solid var(--ink);
  background: var(--paper);
  display: flex;
  gap: 10px;
  align-items: center;
}
.title { display: flex; flex-direction: column; gap: 6px; }
h1 { margin: 0; font-size: 34px; line-height: 1.05; font-weight: 800; letter-spacing: -0.02em; text-wrap: balance; }
.lead { margin: 0; font-size: 16px; line-height: 1.4; color: var(--muted); }
.note { margin: 0; font-size: 15px; line-height: 1.4; color: var(--muted); }
.mono { font-family: var(--mono); }

/* Buttons */
.btn {
  height: 56px;
  padding: 0 20px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  font-size: 17px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}
.btn-primary { flex: 1; background: var(--accent); font-size: 18px; box-shadow: var(--shadow); }
.btn-primary:active:not(:disabled) { box-shadow: none; transform: translate(3px, 3px); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-sm { height: 44px; padding: 0 16px; font-size: 15px; border-radius: 999px; }
.icon-btn {
  width: 44px; height: 44px; padding: 0; flex: none;
  border: 2px solid var(--ink); border-radius: 12px; background: var(--paper);
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn.plain { border: none; background: var(--ground); }
.icon-btn.square { width: 56px; height: 56px; border-radius: var(--radius); }

/* Card */
.card { background: var(--paper); border: 2px solid var(--ink); border-radius: 20px; box-shadow: 4px 4px 0 var(--ink); }

/* Scan */
.viewfinder {
  flex: 1; min-height: 300px; position: relative; overflow: hidden;
  border: 2px solid var(--ink); border-radius: 24px; background: #1e1e24;
  display: flex; align-items: center; justify-content: center;
}
/* The photo scrolls inside the frame, so long receipts stay readable. */
.preview-scroll { position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 0 0 72px; }
.preview-scroll img.preview { display: block; width: 100%; height: auto; }
.corner, .pill, .scanline { z-index: 1; pointer-events: none; }
.corner { position: absolute; width: 34px; height: 34px; border: 0 solid var(--accent); }
.corner.tl { top: 18px; left: 18px; border-top-width: 4px; border-left-width: 4px; border-top-left-radius: 10px; }
.corner.tr { top: 18px; right: 18px; border-top-width: 4px; border-right-width: 4px; border-top-right-radius: 10px; }
.corner.bl { bottom: 18px; left: 18px; border-bottom-width: 4px; border-left-width: 4px; border-bottom-left-radius: 10px; }
.corner.br { bottom: 18px; right: 18px; border-bottom-width: 4px; border-right-width: 4px; border-bottom-right-radius: 10px; }
.paper {
  width: 210px; background: #fff; padding: 18px 16px 20px; transform: rotate(-2.5deg);
  font-family: var(--mono); font-size: 11px; line-height: 1.3;
  display: flex; flex-direction: column; gap: 6px; box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
}
.paper .row { display: flex; gap: 8px; }
.paper .row span:nth-child(2) { flex: 1; }
.paper .rule { border-top: 1px dashed var(--ink); margin: 4px 0; }
.paper .center { text-align: center; }
/* The looping demo: a receipt whose lines peel off onto three people. app.js plays it. */
.demo { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px; padding: 24px 12px; }
.demo .paper { width: 184px; gap: 8px; padding: 20px 16px 22px; }
.demo-people { display: flex; gap: 12px; }
/* Badges stand on end (initial over total) so the row stays narrower than the frame. */
.demo-person { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 8px 5px; border: 2px solid var(--ink); border-radius: 16px; background: var(--paper); box-shadow: var(--shadow); }
.demo-person .avatar { width: 32px; height: 32px; font-size: 15px; }
.odo { height: 1.25em; overflow: hidden; font-family: var(--mono); font-size: 13px; font-weight: 700; line-height: 1.25em; text-align: center; }
.odo-roll, .odo-roll span { display: block; }
.demo-chip {
  position: absolute; height: 22px; padding: 0 8px; opacity: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  border: 2px solid var(--ink); border-radius: 999px; box-shadow: 2px 2px 0 var(--ink); color: #fff; font-size: 11px; font-weight: 800; line-height: 18px; text-align: center;
}
.demo-scan {
  position: absolute; top: 0; height: 4px; opacity: 0; border-radius: 2px;
  background: var(--accent); box-shadow: 0 0 14px 4px rgba(255, 214, 10, 0.8);
}
/* On short phones the frame is squat, so tighten things up to keep it all inside. */
.viewfinder { container-type: size; }
@container (max-height: 340px) {
  .demo { gap: 14px; padding: 10px 12px; }
  .demo .paper { width: 168px; padding: 10px 12px 12px; gap: 3px; font-size: 9.5px; }
}
.pill {
  position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); white-space: nowrap;
  padding: 10px 16px; border-radius: 999px; background: rgba(17, 17, 20, 0.82); color: #fff; font-size: 15px; font-weight: 600;
}
.pill.busy { background: var(--accent); color: var(--ink); border: 2px solid var(--ink); font-weight: 700; }
/* Scanning: a bright line sweeps up and down the photo while the AI reads it. */
.scan-shade { position: absolute; inset: 0; z-index: 1; pointer-events: none; background: rgba(17, 17, 20, 0.25); }
.scanline {
  position: absolute; left: 14px; right: 14px; top: 0; height: 5px; border-radius: 3px;
  background: var(--accent); box-shadow: 0 0 18px 6px rgba(255, 214, 10, 0.85), 0 0 48px 16px rgba(255, 214, 10, 0.35);
  animation: sweep 2.4s cubic-bezier(0.45, 0, 0.55, 1) infinite alternate;
}
@keyframes sweep { from { top: 4%; } to { top: calc(96% - 5px); } }
.dots span { display: inline-block; animation: blink 1.2s infinite; }
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.2; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  /* No sweeping for people who turn motion off: a gentle glow pulse instead. */
  .scanline { top: 50%; animation: glow 1.6s ease-in-out infinite alternate; }
  @keyframes glow { from { opacity: 0.35; } to { opacity: 1; } }
}
.shutter-row { flex: none; padding: 8px 20px calc(22px + env(safe-area-inset-bottom)); display: flex; align-items: center; justify-content: space-between; }
.shutter {
  width: 80px; height: 80px; border: 3px solid var(--ink); border-radius: 50%; background: var(--accent); box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.shutter span { width: 56px; height: 56px; border: 2px solid var(--ink); border-radius: 50%; }
.file-label { position: relative; }
.file-label input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
/* Ring the label for keyboard focus only, not when a tap lands focus on its input. */
.file-label:has(:focus-visible) { outline: 3px solid #3d5afe; outline-offset: 3px; }
/* The whole frame is a button that opens the take-a-photo / upload menu. */
.viewfinder-hit { position: absolute; inset: 0; z-index: 2; padding: 0; border: none; border-radius: inherit; background: none; }
.viewfinder-hit:focus-visible { outline-offset: -6px; }
.picker {
  width: 100%; max-width: 480px; max-height: none; margin: auto auto 0; padding: 0;
  border: 2px solid var(--ink); border-bottom: none; border-radius: 24px 24px 0 0; background: var(--ground);
  animation: rise 0.2s ease-out;
}
.picker:focus { outline: none; }
.picker::backdrop { background: rgba(17, 17, 20, 0.6); }
.picker-body { display: flex; flex-direction: column; gap: 12px; padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); }
.picker-body strong { font-size: 20px; margin-bottom: 4px; }
.picker .btn { flex: none; width: 100%; }
@keyframes rise { from { transform: translateY(100%); } }
@media (prefers-reduced-motion: reduce) {
  .picker { animation: none; }
}
.links { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; }
.link-btn { border: none; background: none; padding: 10px 4px; min-height: 44px; font-size: 15px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.scan .scroll { padding-bottom: 8px; gap: 16px; }
.upload { display: none; }
.error { padding: 12px 14px; border: 2px solid var(--ink); border-radius: var(--radius); background: var(--warn-bg); color: var(--warn-fg); font-size: 15px; font-weight: 600; line-height: 1.35; }

/* Review */
.receipt { overflow: hidden; }
.edit-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) 72px 44px; gap: 6px; align-items: center; padding: 10px 10px 10px 12px; border-bottom: 1px solid var(--line); }
.field {
  height: 44px; width: 100%; min-width: 0; padding: 0 8px; border: 2px solid var(--line); border-radius: 10px; background: #fff; font-size: 16px;
}
.field:focus { border-color: var(--ink); outline: none; }
.field.num { font-family: var(--mono); text-align: right; padding: 0 8px; }
.field.qty { text-align: center; padding: 0 4px; }
.col-head { display: grid; grid-template-columns: 44px minmax(0, 1fr) 72px 44px; gap: 6px; padding: 12px 10px 0 12px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.col-head span:nth-child(3) { text-align: right; }
.add-row { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.charges { padding: 12px 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.charge { display: grid; grid-template-columns: minmax(0, 1fr) 110px; gap: 10px; align-items: center; font-size: 15px; }
.charge label { color: var(--muted); }
.totals { padding: 14px 16px; border-top: 1px dashed var(--ink); display: flex; flex-direction: column; gap: 6px; font-family: var(--mono); font-size: 14px; }
.totals .row { display: flex; justify-content: space-between; }
.totals .row.big { font-size: 16px; font-weight: 700; }
/* The receipt photo: a quick-look chip on phones, a panel beside the editor on computers. */
.photo-chip {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 10px; height: 52px; padding: 4px 16px 4px 4px;
  border: 2px solid var(--ink); border-radius: 14px; background: var(--paper); box-shadow: var(--shadow); font-size: 15px; font-weight: 700;
}
.photo-chip img { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; object-position: top; }
.photo-chip:active { box-shadow: none; transform: translate(3px, 3px); }
.photo-panel { display: none; }
.photo-head { display: flex; justify-content: space-between; align-items: center; }
.photo-head strong { font-size: 17px; }
.photo-head .link-btn { padding: 0 4px; min-height: 36px; }
.photo-frame { height: min(520px, 60vh); overflow-y: auto; overscroll-behavior: contain; border: 2px solid var(--ink); border-radius: 20px; background: #1e1e24; cursor: zoom-in; }
.photo-frame img { display: block; width: 100%; height: auto; }
/* The photo pops up in a card sized to fit the screen, so the whole receipt shows without scrolling.
   Pinch to zoom still works for small print. */
.viewer {
  width: fit-content; min-width: 240px; max-width: calc(100% - 32px);
  max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  padding: 0 8px 8px; border: 2px solid var(--ink); border-radius: 20px; background: var(--paper); box-shadow: 4px 4px 0 var(--ink); overflow: hidden;
}
.viewer::backdrop { background: rgba(17, 17, 20, 0.8); }
.viewer-head { display: flex; justify-content: space-between; align-items: center; height: 56px; padding-left: 8px; }
.viewer-head strong { font-size: 17px; }
/* Room left for the card's margins, border, padding and header. */
.viewer img {
  display: block; width: auto; height: auto; margin: 0 auto; border-radius: 12px;
  max-width: calc(100vw - 52px); max-height: calc(100dvh - 100px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}
.select { height: 44px; padding: 0 10px; border: 2px solid var(--line); border-radius: 10px; background: #fff; font-size: 16px; }

/* People */
.people .scroll { gap: 20px; }
.add-form { display: flex; flex-direction: column; gap: 8px; }
.add-form label { font-size: 15px; font-weight: 700; }
.add-form .row { display: flex; gap: 10px; }
.add-form input { flex: 1; min-width: 0; height: 52px; padding: 0 14px; border: 2px solid var(--ink); border-radius: 14px; background: #fff; font-size: 17px; }
.person-row { display: flex; align-items: center; gap: 12px; height: 62px; padding: 0 8px 0 12px; border: 2px solid var(--ink); border-radius: var(--radius); background: #fff; }
.avatar { flex: none; width: 38px; height: 38px; border-radius: 50%; color: #fff; font-size: 17px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.person-name { flex: 1; min-width: 0; font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { margin: 0; padding: 18px; border: 2px dashed #b9b5aa; border-radius: var(--radius); font-size: 15px; color: var(--muted); text-align: center; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.count { flex: none; font-family: var(--mono); font-size: 14px; font-weight: 600; color: var(--muted); }

/* Assign */
.assign .scroll { padding-top: 0; gap: 14px; }
.segments { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; }
.segment { height: 40px; padding: 0; border: none; background: transparent; display: flex; align-items: center; }
.segment .bar { display: block; width: 100%; height: 12px; border-radius: 6px; background: #d3d0c7; }
.segment.partial .bar { background: #e8a33d; }
.segment.done .bar { background: var(--ink); }
.segment.current .bar { background: var(--accent); border: 2px solid var(--ink); }
.seg-label { display: none; }
.item-card { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 12px; }
.meta { display: flex; justify-content: space-between; gap: 12px; font-family: var(--mono); font-size: 13px; color: var(--muted); }
.item-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.item-head h1 { font-size: 30px; overflow-wrap: anywhere; }
.item-head .price { flex: none; font-family: var(--mono); font-size: 22px; font-weight: 700; }
.status { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--warn-bg); color: #6b3600; font-size: 14px; font-weight: 700; }
.status.done { background: var(--good-bg); color: var(--good-fg); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.cell { position: relative; min-width: 0; }
.tap {
  width: 100%; height: 68px; padding: 0 12px; border: 2px solid var(--ink); border-radius: var(--radius); background: #fff;
  box-shadow: var(--shadow); text-align: left; display: flex; align-items: center; gap: 8px;
}
.tap.on { color: #fff; box-shadow: none; }
.tap.has-minus { padding-right: 58px; }
.tap .dot { flex: none; width: 12px; height: 12px; border-radius: 50%; }
.tap .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tap .nm { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tap .sub { font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.tap.on .sub { color: #fff; }
.minus { position: absolute; top: 12px; right: 8px; }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Summary */
.banner { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 2px solid var(--ink); border-radius: var(--radius); background: #fff; font-size: 15px; line-height: 1.35; }
.banner .tick { flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--good-bg); color: var(--good-fg); display: flex; align-items: center; justify-content: center; }
.banner .amt { flex: none; font-family: var(--mono); font-weight: 700; }
.banner.warn { background: var(--warn-bg); color: var(--warn-fg); font-weight: 600; padding: 10px 10px 10px 14px; }
.tip-head { display: flex; justify-content: space-between; align-items: baseline; }
.tip-head strong { font-size: 17px; }
/* Presets share the row equally. Custom has a fixed width, so the row doesn't shift when you switch between % and an amount. */
.tips { display: flex; gap: 6px; }
.tips > * { flex: 1 1 0; min-width: 0; }
.tips > :last-child { flex: none; width: 84px; padding: 0 6px; }
.tips button { height: 44px; padding: 0; border: 2px solid var(--ink); border-radius: 12px; background: #fff; font-size: 15px; font-weight: 700; }
.tips button[aria-pressed='true'] { background: var(--ink); color: #fff; }
/* The custom tip box sits in the row like a selected button. */
.tip-custom { height: 44px; display: flex; align-items: center; justify-content: center; border: 2px solid var(--ink); border-radius: 12px; background: var(--ink); color: #fff; font-size: 16px; font-weight: 700; cursor: text; }
.tip-custom:focus-within { outline: 3px solid #3d5afe; outline-offset: 2px; }
/* 16px so iPhones don't zoom in when it's focused. */
.tip-custom input { width: 4ch; min-width: 0; padding: 0; border: none; background: none; font-size: 16px; font-weight: 700; text-align: right; }
.tip-custom input:focus-visible { outline: none; }
.tip-custom input::placeholder { color: rgba(255, 255, 255, 0.5); }
.tip-custom input.amount { width: 5ch; margin-left: 1px; text-align: left; }
/* Switch a custom tip between a percentage and an amount in the bill's currency. */
.tip-unit { display: flex; align-items: center; justify-content: flex-end; gap: 10px; font-size: 15px; color: var(--muted); }
.seg { display: flex; padding: 2px; border: 2px solid var(--ink); border-radius: 12px; background: #fff; }
.seg button { min-width: 48px; height: 40px; padding: 0 12px; border: none; border-radius: 9px; background: none; font-size: 16px; font-weight: 700; }
.seg button[aria-pressed='true'] { background: var(--ink); color: #fff; }
.person-card { border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.person-card > button { width: 100%; height: 68px; padding: 0 14px; border: none; background: transparent; text-align: left; display: flex; align-items: center; gap: 12px; }
.person-card .total { flex: none; font-family: var(--mono); font-size: 20px; font-weight: 700; }
.person-card .chev { flex: none; transition: transform 0.15s; }
.person-card[data-open='true'] .chev { transform: rotate(180deg); }
.breakdown { padding: 0 16px 16px 64px; display: flex; flex-direction: column; gap: 6px; font-family: var(--mono); font-size: 13px; }
.breakdown .row { display: flex; justify-content: space-between; gap: 12px; }
.breakdown .row span:last-child { flex: none; }
.breakdown .muted { color: var(--muted); }
.breakdown .rule { border-top: 1px dashed #b9b5aa; margin: 4px 0; }
.check { display: flex; align-items: center; justify-content: center; gap: 8px; font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--good-fg); }
/* Keep "£x + £y tip" together if a big bill wraps the line. */
.check b { font-weight: inherit; white-space: nowrap; }

.toast {
  position: absolute; left: 50%; bottom: 110px; transform: translateX(-50%); z-index: 5;
  padding: 10px 16px; border: 2px solid var(--ink); border-radius: 999px; background: var(--ink); color: #fff; font-weight: 700; white-space: nowrap;
}

/* ---------- Computer screens ----------
   Same screens, more room: each step gets a second column instead of one long list. */
@media (min-width: 900px) {
  .app { max-width: 1120px; }
  .top { padding: 0 24px; }
  .brand img { height: 52px; }
  h1 { font-size: 40px; }
  .scroll { padding: 12px 40px 40px; }
  .col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
  .foot { justify-content: flex-end; padding: 16px 40px; }
  .foot .btn-primary { flex: none; min-width: 260px; }
  .foot .count { margin-right: auto; }

  /* Scan: the words and buttons on the left, the photo frame filling the right. */
  .scan .scroll { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); grid-template-rows: 1fr auto auto auto auto 1fr; gap: 20px 56px; padding-bottom: 40px; }
  .scan .title { grid-area: 2 / 1; }
  .scan .error { grid-area: 3 / 1; }
  .scan .upload { grid-area: 4 / 1; display: inline-flex; justify-self: start; min-width: 260px; }
  .scan .links { grid-area: 5 / 1; justify-content: flex-start; }
  .scan .viewfinder { grid-column: 2; grid-row: 1 / -1; min-height: 0; }
  .scan .paper { width: 250px; font-size: 12px; }
  /* No camera button on a computer: "Choose a photo" does the job. */
  .scan .shutter-row { display: none; }

  /* Review: the item lines on the left, charges and totals alongside. */
  /* The grid sits inside the scroller so its rows size to their content, not to the screen height. */
  .review .scroll { display: block; }
  .review .col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 360px); grid-template-rows: auto auto auto auto 1fr; align-items: start; gap: 18px 32px; }
  .review .title, .review [data-bind='mismatch'] { grid-column: 1 / -1; }
  .receipt { display: contents; }
  .receipt-items, .receipt-extras { overflow: hidden; background: var(--paper); border: 2px solid var(--ink); border-radius: 20px; box-shadow: 4px 4px 0 var(--ink); }
  .receipt-items { grid-column: 1; grid-row: 3 / 6; }
  .receipt-extras { grid-column: 2; grid-row: 3; }
  .receipt-extras .charges { padding-top: 16px; }
  .review .note { grid-column: 2; grid-row: 4; }
  .photo-chip { display: none; }
  /* Sits in the stretchy last row, so it stays in view while you work down a long receipt. */
  .photo-panel { grid-column: 2; grid-row: 5; position: sticky; top: 0; display: flex; flex-direction: column; gap: 10px; }

  /* People: add names on the left, the table fills up on the right. */
  .people .scroll { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: 24px 48px; }
  .people .col { gap: 24px; }

  /* Assign: every item listed down the side, so you can jump around the receipt. */
  .assign .scroll { display: grid; grid-template-columns: 300px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: 0 36px; padding: 12px 40px 0; overflow: hidden; }
  .assign .segments { grid-auto-flow: row; grid-auto-columns: auto; align-content: start; gap: 4px; min-height: 0; overflow-y: auto; padding: 0 0 32px; border-right: 1px solid var(--line); padding-right: 16px; }
  .segment { min-height: 48px; height: auto; padding: 8px 12px; gap: 12px; border-radius: 12px; text-align: left; }
  .segment:hover { background: rgba(17, 17, 20, 0.05); }
  .segment.current { background: var(--paper); box-shadow: inset 0 0 0 2px var(--ink); }
  .segment .bar { flex: none; width: 12px; height: 12px; border-radius: 4px; }
  .seg-label { flex: 1; min-width: 0; display: flex; justify-content: space-between; gap: 10px; font-size: 15px; font-weight: 600; }
  .seg-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .seg-price { flex: none; font-family: var(--mono); font-size: 13px; color: var(--muted); }
  /* Room on the right and bottom so the hard shadows aren't clipped by the scrolling column. */
  .assign .col { gap: 14px; min-height: 0; overflow-y: auto; padding: 0 6px 32px 0; }
  .assign .col > * { flex-shrink: 0; }
  .item-card { padding: 20px 24px 22px; }
  .item-head h1 { font-size: 36px; }
  .grid2 { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }

  /* Summary: tip and notes on the left, staying put while you scroll through everyone's totals. */
  .summary .scroll { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); align-items: start; gap: 24px 48px; }
  .summary .col { position: sticky; top: 0; }

  /* Full size on a computer: the photo fills the window, at a readable width, and scrolls. */
  .viewer {
    width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 72px 16px 32px;
    border: none; border-radius: 0; box-shadow: none; background: rgba(17, 17, 20, 0.94); overflow-y: auto; overscroll-behavior: contain;
  }
  .viewer::backdrop { background: transparent; }
  .viewer-head { display: contents; }
  .viewer-head strong { display: none; }
  .viewer-close { position: fixed; top: 14px; right: 16px; z-index: 1; border: 2px solid var(--ink); background: var(--paper); }
  .viewer img { width: 100%; max-width: 760px; max-height: none; border-radius: 8px; }
}
