/* SPLIT — thermal-receipt aesthetic */

:root {
  --felt: #142019;
  --felt-glow: #1d2f24;
  --paper: #faf6ec;
  --paper-shade: #f1ebdc;
  --ink: #1c1a16;
  --ink-faint: #6b6455;
  --stamp: #d64533;
  --stamp-dark: #b23425;
  --ok: #2e7d4f;
  /* From the native-app design: a card fill a shade brighter than the paper it
     sits on, and an ochre for "needs attention" that isn't the alert red. */
  --paper-bright: #fffdf6;
  --ochre: #c9862e;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --display: "Anton", Impact, sans-serif;
  /* The design's one structural move: content lives in rounded cards on the
     paper, rather than sitting directly on it. Four steps, no more. */
  --r-card: 0px;   /* flat, like the rest of the receipt — see the item rows */
  --r-btn: 14px;
  --r-field: 12px;
  --r-pill: 999px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { min-height: 100%; }

body {
  font-family: var(--mono);
  color: var(--ink);
  background:
    radial-gradient(ellipse 120% 80% at 50% -10%, var(--felt-glow), transparent 60%),
    var(--felt);
}

/* subtle grain over the table */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

.table-surface {
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  /* env() is 0 in a browser, so this is inert on the web and only does work
     inside the app, where the notch and home indicator eat real estate. */
  padding:
    calc(clamp(12px, 4vw, 44px) + env(safe-area-inset-top, 0px)) 10px
    calc(env(safe-area-inset-bottom, 0px) + 56px);
}

/* ---------- the receipt ---------- */
.receipt {
  position: relative;
  width: min(440px, 100%);
  background: var(--paper);
  color: var(--ink);
  padding: 30px 22px 40px;
  transform: rotate(-0.4deg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.35);
  font-size: 14px;
  line-height: 1.45;
  /* perforated top & bottom edges */
  --zz: 12px;
  clip-path: polygon(
    0% var(--zz), 4% 0%, 8% var(--zz), 12% 0%, 16% var(--zz), 20% 0%, 24% var(--zz), 28% 0%,
    32% var(--zz), 36% 0%, 40% var(--zz), 44% 0%, 48% var(--zz), 52% 0%, 56% var(--zz), 60% 0%,
    64% var(--zz), 68% 0%, 72% var(--zz), 76% 0%, 80% var(--zz), 84% 0%, 88% var(--zz), 92% 0%,
    96% var(--zz), 100% 0%,
    100% calc(100% - var(--zz)), 96% 100%, 92% calc(100% - var(--zz)), 88% 100%,
    84% calc(100% - var(--zz)), 80% 100%, 76% calc(100% - var(--zz)), 72% 100%,
    68% calc(100% - var(--zz)), 64% 100%, 60% calc(100% - var(--zz)), 56% 100%,
    52% calc(100% - var(--zz)), 48% 100%, 44% calc(100% - var(--zz)), 40% 100%,
    36% calc(100% - var(--zz)), 32% 100%, 28% calc(100% - var(--zz)), 24% 100%,
    20% calc(100% - var(--zz)), 16% 100%, 12% calc(100% - var(--zz)), 8% 100%,
    4% calc(100% - var(--zz)), 0% 100%
  );
  animation: settle 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}

@keyframes settle {
  from { transform: translateY(-18px) rotate(-1.6deg); opacity: 0; }
  to   { transform: translateY(0) rotate(-0.4deg); opacity: 1; }
}

/* "CUENTAS" and "CABALES" are both 7 letters — matched size + tracking makes
   an aligned, justified two-line block. text-indent offsets the trailing
   letter-spacing so each line stays optically centered. */
.brand {
  font-family: var(--display);
  line-height: 1;
  text-align: center;
  margin: 8px 0 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.12em; /* breathing room between the two stacked words */
}
.brand .l1,
.brand .l2 {
  font-size: clamp(38px, 12.8vw, 56px);
  letter-spacing: 0.09em;
  text-indent: 0.09em;
}
.brand .dot { color: var(--stamp); margin-left: 0.02em; }

.tagline {
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.28em;
  font-size: 10px;
  color: var(--ink-faint);
  margin: 6px 0 2px;
}

.rule { border: 0; border-top: 1.5px dashed var(--ink); opacity: 0.7; margin: 14px 0; }
.rule.faint { border-top-style: dotted; opacity: 0.35; }

.center { text-align: center; }
.small { font-size: 11px; color: var(--ink-faint); }
.upper { text-transform: uppercase; letter-spacing: 0.12em; }

/* ---------- buttons ---------- */
.btn {
  display: block;
  width: 100%;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  padding: 15px 12px;
  border: 2.5px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  border-radius: var(--r-btn);
  box-shadow: 4px 4px 0 rgba(28, 26, 22, 0.25);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 rgba(28, 26, 22, 0.25); }
/* Paper on --stamp measured 4.09:1 at 15px/700 — below AA, and this is the
   primary action on every screen. --stamp-dark takes it to 5.7:1. */
.btn.stamp { background: var(--stamp-dark); border-color: var(--stamp-dark); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn[disabled] { opacity: 0.55; cursor: wait; }

.field {
  width: 100%;
  font-family: var(--mono);
  font-size: 16px;
  padding: 12px;
  border: 2px solid var(--ink);
  border-radius: var(--r-field);
  background: var(--paper-bright);
  color: var(--ink);
  outline: none;
}
.field:focus { border-color: var(--stamp); }
.field.code {
  text-transform: uppercase;
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.5em;
  padding-left: calc(12px + 0.5em);
}

.join-row { display: flex; gap: 10px; margin-top: 10px; }
.join-row .field { flex: 1; min-width: 0; }
.join-row .btn { width: auto; padding-inline: 18px; }

/* ---------- items ---------- */
.who-bar { display: flex; gap: 8px; align-items: center; margin: 10px 0 2px; }
.who-bar label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; white-space: nowrap; }
.who-bar .field { padding: 8px 10px; font-size: 14px; font-weight: 700; }

/* Flat thermal-receipt lines — the rounded card containers are gone, by
   request: this is the v1 silhouette. Two fixed lines per row (the name, then a
   sub-line that ALWAYS renders) keep every row the same height, so claiming
   never moves the list under the thumb. Price and the delete control are one
   right-hand unit, and the claimer faces live on the sub-line — three things no
   longer fight for the same line, which is what pushed the ✕ out of bounds. */
.item-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 6px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease;
}
.item-row:hover { background: rgba(28, 26, 22, 0.03); }
.item-row .item-main { flex: 1 1 auto; min-width: 0; }
.item-row .item-name {
  display: block; font-size: 13.5px; line-height: 1.5;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.item-row .item-sub {
  display: flex; align-items: center; gap: 6px;
  min-height: 18px; margin-top: 1px;
  font-size: 10.5px; color: var(--ink-faint);
  overflow: hidden;
}
.item-row .item-sub .sub-text { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-row .item-right { flex: 0 0 auto; display: flex; align-items: center; margin-left: auto; }
.item-row .item-price {
  font-size: 13.5px; font-weight: 700; line-height: 1.5;
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
/* The ASCII checkbox, back where it belongs on a thermal receipt. */
.tick {
  flex: 0 0 auto;
  font-weight: 700; font-size: 15px; line-height: 1.4;
  color: var(--ink-faint);
}
.item-row.taken { background: rgba(28, 26, 22, 0.05); }
.item-row.taken .tick { color: var(--ink); }
.item-row.mine { background: rgba(214, 69, 51, 0.07); }
.item-row.mine .tick { color: var(--stamp-dark); }
.item-row.mine .item-name { font-weight: 700; }
.item-row.inert { cursor: default; }
.item-row.inert .tick { opacity: 0.45; }

/* Stacked initials (kept for host mode's colour identity; used full-size in the
   settle cards, small on an item's sub-line). */
.faces { display: flex; flex: 0 0 auto; }
.face {
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--hue, var(--ink)); color: var(--paper);
  font-size: 9.5px; font-weight: 700;
  border: 1.5px solid var(--paper-bright);
  margin-left: -6px;
}
.faces .face:first-child { margin-left: 0; }
.item-sub .face {
  width: 16px; height: 16px; font-size: 8px;
  border-width: 1px; margin-left: -5px;
}

/* A destructive control sitting inside a row whose whole surface is the primary
   action. It was 25×19px, ~8px from the price. Give it a real hit area. */
.item-del {
  border: 0; background: none; color: var(--ink-faint);
  font-family: var(--mono); font-size: 15px; cursor: pointer;
  min-width: 40px; min-height: 40px; padding: 0 6px;
  vertical-align: middle;
}
.item-del:hover, .item-del:focus-visible { color: var(--stamp-dark); }

/* ---------- totals ---------- */
.line { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; font-variant-numeric: tabular-nums; }
.line.strong { font-weight: 700; }
.line.big { font-size: 20px; font-weight: 700; }
.line .amount { white-space: nowrap; }

.your-total {
  border: 2.5px solid var(--stamp);
  color: var(--stamp);
  padding: 12px 14px;
  margin-top: 10px;
  transform: rotate(-1.2deg);
  text-align: center;
}
.your-total .label { font-size: 11px; letter-spacing: 0.25em; text-transform: uppercase; }
.your-total .value { font-family: var(--display); font-size: 40px; letter-spacing: 0.04em; line-height: 1.1; }

/* Four 44px targets plus their caption need more than a 320px phone gives the
   paper, so the caption drops to its own line rather than squeezing the row. */
.tip-row { display: flex; align-items: center; gap: 6px 8px; justify-content: space-between; flex-wrap: wrap; }
.tip-row .small { flex: 1 1 auto; min-width: 0; }
.tip-controls { display: flex; gap: 6px; flex: 0 0 auto; }
.tip-btn {
  font-family: var(--mono); font-weight: 700; font-size: 13px;
  border: 1.5px solid var(--ink); background: transparent; color: var(--ink);
  border-radius: var(--r-pill);
  padding: 3px 12px; min-height: 44px; min-width: 44px; cursor: pointer;
}
.tip-btn.active { background: var(--ink); color: var(--paper); }

/* ---------- split-mode toggle + even split ---------- */
.mode-row { display: flex; gap: 8px; margin: 14px 0 4px; }
.mode-btn {
  flex: 1; font-family: var(--mono); font-weight: 700; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.05em; padding: 9px 6px; min-height: 44px; cursor: pointer;
  border: 2px solid var(--ink); border-radius: var(--r-btn); background: transparent; color: var(--ink);
}
.mode-btn.active { background: var(--ink); color: var(--paper); }
.even-card { border: 2.5px solid var(--stamp); padding: 14px 12px; text-align: center; margin-top: 8px; }
.even-head { font-size: 10px; letter-spacing: 0.22em; color: var(--ink-faint); }
.even-people { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 12px 0 6px; }
.even-people .step {
  width: 40px; height: 40px; font-size: 22px; font-weight: 700; line-height: 1; cursor: pointer;
  font-family: var(--mono); border: 2px solid var(--ink); background: transparent; color: var(--ink);
}
.even-people .step:active { background: var(--ink); color: var(--paper); }
.even-n { font-size: 15px; font-weight: 700; min-width: 120px; font-variant-numeric: tabular-nums; }
.even-each { font-family: var(--display); font-size: 46px; color: var(--stamp); line-height: 1.05; letter-spacing: 0.02em; }
.even-each .small { font-family: var(--mono); color: var(--ink-faint); letter-spacing: 0; }

/* ---------- trips ---------- */
.trip-form { margin-top: 10px; display: block; }
.trip-form .field { margin-bottom: 8px; }
.trip-form label { display: block; margin: 6px 0 4px; }

.trip-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.trip-link {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 13px; text-align: left; cursor: pointer;
  border: 2px solid var(--ink); background: transparent; color: var(--ink); padding: 9px 11px;
}
.trip-link:hover { background: var(--paper-shade); }
.trip-link .t-code { font-weight: 700; letter-spacing: 0.14em; font-size: 12px; }

.demo-row { display: flex; gap: 8px; }
.demo-row .btn { font-size: 12px; letter-spacing: 0.06em; padding: 13px 6px; }

.trip-card {
  border: 2.5px solid var(--ink);
  border-radius: 18px;
  background: var(--paper-shade);
  padding: 14px 16px 15px;
  margin-top: 12px;
  text-align: center;
}
.trip-total {
  font-family: var(--display);
  font-size: clamp(38px, 13vw, 50px);
  line-height: 1.05;
  letter-spacing: 0.02em;
  color: var(--stamp);
  font-variant-numeric: tabular-nums;
}
.trip-card .meter { margin: 10px 0 7px; }
.warn-text { color: var(--stamp-dark); }

/* one receipt in the trip's stack */
.trip-receipt { border-bottom: 1px dotted rgba(28, 26, 22, 0.35); }
.trip-receipt.open { border: 2px solid var(--ink); margin: 8px 0; background: #fffdf6; }

.receipt-head {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  gap: 8px;
  align-items: baseline;
  width: 100%;
  padding: 11px 8px;
  font-family: var(--mono);
  font-size: 14px;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.receipt-head:hover { background: var(--paper-shade); }
.receipt-head.open { background: var(--paper-shade); font-weight: 700; }
.receipt-head .r-caret { color: var(--ink-faint); }
.receipt-head .r-main { min-width: 0; }
.receipt-head .r-name { display: block; overflow-wrap: anywhere; }
.receipt-head .r-meta { display: block; font-weight: 400; margin-top: 1px; }
.receipt-head .r-amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

.receipt-body { padding: 4px 10px 14px; }
/* Merchant and currency stack at every width: side by side, the currency
   select truncated its own option text mid-word ("GTQ — Guatem⌄"). */
.r-fields { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.r-fields .field { padding: 9px 10px; font-size: 14px; width: 100%; min-width: 0; }

.fx-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 4px 0 8px; }
.fx-warn { color: var(--stamp-dark); font-weight: 700; }
.fx-form { display: flex; align-items: center; gap: 6px; margin: 4px 0 8px; flex-wrap: wrap; }
.fx-form .field { flex: 1; min-width: 90px; padding: 8px 10px; }
.fx-form .btn { width: auto; padding: 9px 14px; font-size: 12px; }

.field.mini {
  width: 84px; padding: 3px 6px; font-size: 13px; text-align: right;
  border-width: 1.5px; font-variant-numeric: tabular-nums;
}

/* people pickers: who split this, who paid */
.pick-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; justify-content: center; }
.pick {
  font-family: var(--mono); font-size: 12px; cursor: pointer;
  border: 1.5px solid var(--ink); background: transparent; color: var(--ink);
  padding: 5px 11px; border-radius: 999px;
}
.pick.on { background: var(--stamp); border-color: var(--stamp-dark); color: var(--paper); font-weight: 700; }
.pick.clear { border-style: dashed; color: var(--ink-faint); }
.pick.static { display: inline-flex; align-items: center; gap: 4px; background: var(--paper-shade); }
/* Removing a person from a trip was an 11×15px tap with no confirmation. */
.pick-x {
  border: 0; background: none; color: var(--ink-faint); cursor: pointer;
  font-family: var(--mono); font-size: 14px;
  min-width: 32px; min-height: 32px; padding: 0 4px;
}
.pick-x:hover, .pick-x:focus-visible { color: var(--stamp-dark); }

.even-each.small { margin-top: 4px; font-family: var(--mono); font-size: 12px; color: var(--ink-faint); }

.add-receipt-row { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

/* who owes what */
.ledger { font-variant-numeric: tabular-nums; }
/* Two lines per person. Five money columns never fit a 440px receipt — the last
   one wrapped to its own grid row and the ledger read as broken. The line that
   matters (who is up or down) is on top; the workings sit under it. */
.ledger-key {
  text-align: center; color: var(--ink-faint);
  border-bottom: 1px dotted rgba(28, 26, 22, 0.35); padding-bottom: 5px; margin-bottom: 2px;
}
.ledger-row {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px;
  padding: 8px 0; font-size: 13px;
  border-bottom: 1px dotted rgba(28, 26, 22, 0.16);
}
.ledger-row:last-child { border-bottom: 0; }
.ledger-row.strong { font-weight: 700; }
.ledger-row .l-name { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; font-size: 14px; }
.ledger-row .l-net { flex: 0 0 auto; font-size: 15px; font-weight: 700; white-space: nowrap; }
.ledger-row .l-meta {
  flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 1px 10px;
  margin-top: 3px; font-size: 11px; color: var(--ink-faint);
}
.ledger-row .l-meta span { white-space: nowrap; }
.ledger-row .l-meta span::before {
  content: attr(data-l) " ";
  text-transform: uppercase; letter-spacing: 0.1em; font-size: 9px; opacity: 0.8;
}
.ledger-row .pos { color: var(--ok); }
/* --stamp is 4.1:1 on paper; the darker stamp is 5.7:1 and this is a number
   people read carefully. */
.ledger-row .neg { color: var(--stamp-dark); }
.ledger-row .l-settled { color: var(--ink-faint); }
.ledger-row .l-settled.has { color: var(--ink); }

/* "Ana → Beto  $53.12" on one line, and the 44px action on its own beneath —
   five grid columns plus a full-size button could not share 334px of paper. */
.settle-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  padding: 9px 0;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  border-bottom: 1px dotted rgba(28, 26, 22, 0.25);
}
.settle-row.strong { font-weight: 700; }
.settle-row .s-txt { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.settle-row .s-amt { margin-left: auto; white-space: nowrap; font-weight: 700; }

/* ---------- settling up: recording payments & closing ---------- */
/* The button that moves money was the smallest type on the screen (10px, 24px
   tall). It now meets the 44px target like everything else that matters. */
.pay-btn {
  flex: 1 1 100%;
  font-family: var(--mono); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em;
  border: 1.5px solid var(--ok); background: transparent; color: var(--ok);
  padding: 8px 12px; min-height: 44px; margin-top: 4px; cursor: pointer; white-space: nowrap;
}
.pay-btn:active { background: var(--ok); color: var(--paper); }

.pay-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.pay-form .field { flex: 1 1 34%; min-width: 0; padding: 8px; font-size: 13px; }
.pay-form .pay-arrow { font-size: 11px; color: var(--ink-faint); text-transform: uppercase; }
.pay-form .btn { width: auto; padding: 9px 14px; }

.paid-log { margin-top: 4px; }
.paid-row {
  display: flex; align-items: baseline; gap: 8px; padding: 5px 0;
  font-size: 13px; color: var(--ink-faint);
  border-bottom: 1px dotted rgba(28, 26, 22, 0.18);
  font-variant-numeric: tabular-nums;
}
.paid-row .p-txt { flex: 1; overflow-wrap: anywhere; }
.paid-row .p-amt { color: var(--ok); font-weight: 700; white-space: nowrap; }
.undo-pay { border: 0; background: none; color: var(--ink-faint); font-family: var(--mono); font-size: 12px; cursor: pointer; padding: 0 4px; }
.undo-pay:hover { color: var(--stamp); }

.closed-stamp {
  border: 2.5px solid var(--ok); color: var(--ok);
  padding: 14px 12px; margin-top: 14px; text-align: center;
  transform: rotate(-1deg); background: rgba(46, 125, 79, 0.06);
}
.closed-stamp .cs-mark {
  font-family: var(--display); font-size: 30px; letter-spacing: 0.08em; line-height: 1.1;
}
.closed-stamp .small { color: var(--ink-faint); }
.closed-stamp .copy-btn { margin-top: 8px; border-color: var(--ok); color: var(--ok); }
.settle-row .s-amt { white-space: nowrap; }

.your-total.owed { border-color: var(--ok); color: var(--ok); }

.settings { border: 1.5px dashed var(--ink); padding: 12px; margin-top: 8px; }
.settings label { display: block; margin: 8px 0 4px; }
.settings .field { margin-bottom: 4px; }

.copy-btn.danger { color: var(--stamp-dark); border-color: var(--stamp-dark); margin-top: 14px; }

.code-big.trip { font-size: 28px; letter-spacing: 0.3em; padding-left: 0.3em; }
.field.code.wide { font-size: 22px; letter-spacing: 0.34em; padding-left: calc(12px + 0.34em); }

/* ---------- barcode / code ---------- */
.code-block { text-align: center; margin-top: 6px; }
.barcode {
  height: 46px;
  margin: 8px auto 6px;
  width: 78%;
  background: repeating-linear-gradient(
    90deg,
    var(--ink) 0 2px, transparent 2px 5px,
    var(--ink) 5px 9px, transparent 9px 11px,
    var(--ink) 11px 12px, transparent 12px 17px,
    var(--ink) 17px 20px, transparent 20px 22px
  );
}
.code-big {
  font-family: var(--display);
  font-size: 34px;
  letter-spacing: 0.45em;
  padding-left: 0.45em;
}
.share-link { font-size: 11px; color: var(--ink-faint); overflow-wrap: anywhere; }

.share-btn { margin: 12px 0 6px; }

.copy-btn {
  font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
  border: 1.5px solid var(--ink); background: transparent; cursor: pointer;
  padding: 4px 10px; margin-top: 6px; color: var(--ink);
}

.banner {
  border: 2px dashed var(--stamp);
  color: var(--stamp-dark);
  font-size: 11.5px;
  padding: 8px 10px;
  margin: 10px 0;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.error-note { color: var(--stamp-dark); font-size: 12.5px; text-align: center; margin: 8px 0; }

.spin {
  display: inline-block;
  animation: spin 1s steps(8) infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.add-item-form { display: none; gap: 8px; margin-top: 8px; }
.add-item-form.open { display: flex; }
.add-item-form .name { flex: 2; min-width: 0; }
.add-item-form .price { flex: 1; min-width: 0; }
.add-item-form .btn { width: auto; padding: 10px 14px; }

.footer-note {
  margin-top: 18px;
  text-align: center;
  font-size: 10px;
  color: var(--ink-faint);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

/* ---------- remaining balance ---------- */
.balance {
  border: 2.5px solid var(--ink);
  padding: 11px 12px 12px;
  margin-top: 12px;
  background: var(--paper-shade);
}
.balance-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 11px;
  letter-spacing: 0.16em;
}
.balance-value {
  font-family: var(--display);
  font-size: 30px;
  letter-spacing: 0.02em;
  color: var(--stamp);
  font-variant-numeric: tabular-nums;
}
.balance.settled { border-color: var(--ok); background: rgba(46, 125, 79, 0.08); }
.balance.settled .balance-value { color: var(--ok); font-size: 24px; }

.meter {
  height: 9px;
  margin: 8px 0 7px;
  border: 1.5px solid var(--ink);
  border-radius: var(--r-pill);
  overflow: hidden;
  background: repeating-linear-gradient(45deg, transparent 0 3px, rgba(28, 26, 22, 0.13) 3px 6px);
}
.meter span {
  display: block;
  height: 100%;
  background: var(--ink);
  transition: width 0.35s cubic-bezier(0.3, 0.8, 0.3, 1);
}
.balance.settled .meter span { background: var(--ok); }
.balance-foot { color: var(--ink-faint); }
.balance.settled .balance-foot { color: var(--ok); font-weight: 700; }

/* ---------- sticky mobile total bar ---------- */
.sticky-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  gap: 1px;
  background: var(--ink);
  color: var(--paper);
  padding: 9px 14px calc(9px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -6px 22px rgba(0, 0, 0, 0.45);
  font-variant-numeric: tabular-nums;
}
.sticky-cell { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.sticky-cell.right { text-align: right; }
.sticky-cell .k {
  font-size: 9.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.65;
}
/* The design sets the number you actually care about in the display face. */
.sticky-cell .v { font-family: var(--display); font-size: 25px; letter-spacing: 0.02em; line-height: 1.05; }
.sticky-cell.right .v { font-family: var(--mono); font-size: 17px; font-weight: 700; }
.sticky-cell.right .v { color: #ff8b78; }
.sticky-cell.ok .v { color: #7fd6a2; }
.sticky-cell.right.ok .v { color: #7fd6a2; }
/* A correct figure shown in alarm-red reads as "this number is wrong". The
   trip total is just a total — keep it in plain ink. */
.sticky-cell.right.total .v { color: var(--paper); }

/* Desktop has room for the receipt's own totals — the bar is a phone affordance. */
@media (min-width: 700px) and (min-height: 640px) {
  .sticky-bar { display: none; }
}

/* ---------- small-screen tuning ---------- */
@media (max-width: 430px) {
  /* Keep the top inset — re-declaring the shorthand here used to drop it,
     which slid the header under the status bar on every notched iPhone. */
  .table-surface {
    padding:
      calc(8px + env(safe-area-inset-top, 0px)) 6px
      calc(env(safe-area-inset-bottom, 0px) + 84px);
  }
  .receipt { padding: 24px 16px 30px; transform: rotate(0deg); font-size: 14.5px; }
  /* (the old grid-era override lived here and was squeezing the card's
     horizontal padding to 2px — the row is a flex card now and sets its own) */
  .item-del { padding: 0 8px; font-size: 14px; }
  .tip-btn { padding: 7px 11px; }
  /* A code is 4–6 characters; it never needed a full-width field and its own
     row. Keeping them side by side puts the joiner's whole task on one line. */
  .join-row .field.code { font-size: 20px; letter-spacing: 0.3em; padding-inline: 8px; }
  .join-row .btn { padding-inline: 14px; }
  .add-item-form { flex-wrap: wrap; }
  .add-item-form .name { flex: 1 1 100%; }
  .add-item-form .price { flex: 1 1 40%; }
  .add-item-form .btn { flex: 1 1 40%; width: auto; }
  .barcode { height: 38px; }
  .share-link { font-size: 10.5px; }
  .receipt-head { padding: 13px 4px; grid-template-columns: 14px 1fr auto; gap: 6px; }
  .receipt-body { padding: 4px 4px 14px; }
  /* The ledger is a flex two-liner at every width now — no column count to keep
     in sync, which is exactly how the five-column version broke. */
  .demo-row { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  .receipt { animation: none; }
  .meter span { transition: none; }
  .spin { animation: none; }
}

/* ---------- host-assign ("pass the pen") ---------- */
.cdot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; vertical-align: middle; flex: 0 0 auto; }

.host-toggle {
  display: block; width: 100%; margin: 8px 0 2px;
  padding: 9px 12px; border: 1.5px dashed var(--ink-faint); border-radius: 10px;
  background: var(--paper-shade); color: var(--ink);
  font-family: var(--mono); font-size: 12.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em; cursor: pointer;
}
.host-toggle.on { border-style: solid; border-color: var(--ok); color: var(--ok); background: #eef6ef; }

/* The roster lives in a bottom sheet that grows when you're adding people. */
.roster-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--paper);
  border-top: 2px solid var(--ink);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.30);
  padding: 11px 13px calc(11px + env(safe-area-inset-bottom, 0px));
}
.roster-bar.expanded { box-shadow: 0 -16px 44px rgba(0, 0, 0, 0.40); }

/* ---- add-a-friend panel ---- */
.add-panel { animation: sheetUp 0.24s cubic-bezier(0.2, 0.8, 0.2, 1); margin-bottom: 10px; }
@keyframes sheetUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.add-lead { display: flex; align-items: center; gap: 11px; }
/* the person visibly forming: an avatar that colours in and shows their initial */
.add-preview {
  flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--hue, var(--ink)); color: #fff;
  font-family: var(--display); font-size: 21px; line-height: 1;
  box-shadow: 0 3px 10px color-mix(in srgb, var(--hue, #000) 45%, transparent);
  transition: background 0.25s ease, transform 0.15s ease;
}
.add-input {
  flex: 1 1 auto; min-width: 0;
  border: 0; border-bottom: 2px solid var(--ink);
  background: transparent; color: var(--ink);
  font-family: var(--mono); font-size: 17px; font-weight: 700;
  padding: 8px 2px;
}
.add-input:focus { outline: none; border-bottom-color: var(--stamp); }
.add-confirm {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: var(--ink); color: var(--paper);
  font-size: 20px; font-weight: 700; cursor: pointer;
  display: grid; place-items: center;
  transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s ease;
}
.add-confirm:hover { background: var(--stamp); }
.add-confirm:active { transform: scale(0.88); }
/* When the field is empty the arrow means "done", not "add" — dim it so the
   affordance matches the action. */
.add-confirm.empty { background: var(--ink-faint); opacity: 0.55; }

.recents { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 11px; }
.recents-label { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.16em; color: var(--ink-faint); margin-right: 2px; }
.recent-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px;
  padding: 9px 14px 9px 11px; border-radius: 999px;
  border: 1.5px solid color-mix(in srgb, var(--hue, var(--ink)) 55%, var(--paper-shade));
  background: var(--paper-shade); color: var(--ink); cursor: pointer;
  font-family: var(--mono); font-size: 12.5px; font-weight: 700;
  transition: transform 0.1s ease, background 0.15s ease;
}
.recent-chip:hover { background: var(--paper); }
.recent-chip:active { transform: scale(0.94); }

.add-done {
  display: block; width: 100%; margin-top: 12px;
  padding: 11px; border: 0; border-radius: 11px;
  background: #1a6a3d; color: #fff;
  font-family: var(--mono); font-size: 14px; font-weight: 700; letter-spacing: 0.02em;
  cursor: pointer; transition: filter 0.15s ease;
}
.add-done:hover { filter: brightness(1.08); }
.add-hint { margin-top: 10px; font-size: 11.5px; color: var(--ink-faint); text-align: center; line-height: 1.4; }
/* Reserve the line so acknowledging a duplicate doesn't shove the layout. */
.add-note { min-height: 15px; margin-top: 7px; font-size: 11.5px; font-weight: 700; color: var(--stamp); text-align: center; }

/* ---- roster row ---- */
/* The chips scroll in their own region; the ＋ stays pinned and always visible. */
.roster-row { display: flex; align-items: center; gap: 8px; }
.roster-chips {
  flex: 1 1 auto; min-width: 0;
  display: flex; align-items: center; gap: 7px;
  overflow-x: auto; padding: 2px 1px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
  scroll-padding-inline: 10px;
}
.roster-chips::-webkit-scrollbar { display: none; }
/* A chip is a plain container holding two real sibling buttons: select-the-pen
   and remove — no nested interactive, each independently focusable. */
.rchip {
  display: inline-flex; align-items: stretch; flex: 0 0 auto;
  min-height: 44px; overflow: hidden;
  border: 2px solid var(--hue, var(--ink)); border-radius: 999px;
  background: var(--paper-shade); color: var(--ink);
  font-family: var(--mono); font-size: 12.5px; font-weight: 700; white-space: nowrap;
  user-select: none; transition: box-shadow 0.15s ease, background 0.15s ease;
}
.rchip-select {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 6px 4px 4px; border: 0; background: none; color: inherit;
  font: inherit; cursor: pointer; white-space: nowrap;
}
.rchip-select:focus-visible { outline: 2px solid currentColor; outline-offset: -3px; }
.rchip .ravatar {
  width: 28px; height: 28px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center;
  background: var(--hue); color: #fff; font-family: var(--display); font-size: 14px;
}
.rchip .rname { padding: 0 1px; }
.rchip .rtot { opacity: 0.68; font-weight: 600; font-variant-numeric: tabular-nums; }
/* Remove is a real button with its own hit area, visually separated from the
   select tap so the two don't get confused at a busy table. */
.rchip .rdel {
  flex: 0 0 auto; width: 30px; align-self: stretch;
  display: grid; place-items: center;
  border: 0; border-left: 1px solid color-mix(in srgb, var(--hue) 30%, transparent);
  background: none; color: inherit; opacity: 0.5;
  font-family: var(--mono); font-size: 17px; line-height: 1; cursor: pointer;
}
.rchip .rdel:hover, .rchip .rdel:focus-visible { opacity: 1; color: var(--stamp); outline: none; background: color-mix(in srgb, var(--stamp) 12%, transparent); }
.rchip.locked {
  background: var(--hue); color: #fff; border-color: var(--hue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--hue) 26%, transparent);
}
.rchip.locked .ravatar { background: rgba(255, 255, 255, 0.24); }
.rchip.locked .rtot { opacity: 0.85; }
.rchip.locked .rdel { border-left-color: rgba(255, 255, 255, 0.3); }

.add-open {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%;
  border: 2px dashed var(--ink-faint); background: var(--paper); color: var(--ink-faint);
  cursor: pointer; display: grid; place-items: center; font-size: 18px; font-weight: 700;
  transition: border-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
}
.add-open:hover { border-color: var(--stamp); color: var(--stamp); }
.add-open:active { transform: scale(0.92); }

.roster-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; color: var(--ink-faint); font-size: 11.5px; }
.roster-foot b { color: var(--ink); }
.foot-right { display: inline-flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.undo-btn { border: 0; background: none; color: var(--stamp); font-family: var(--mono); font-size: 12px; font-weight: 700; cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  .add-panel, .sheet, .sheet-scrim { animation: none; }
}

/* ---- "which one are you?" adoption chips on the name gate ---- */
.adopt-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.adopt-chip {
  padding: 8px 14px; border: 2px solid var(--ink); border-radius: 999px;
  background: var(--paper-shade); color: var(--ink); cursor: pointer;
  font-family: var(--mono); font-size: 13px; font-weight: 700;
}
.adopt-chip:hover { background: var(--stamp); border-color: var(--stamp-dark); color: var(--paper); }

/* ---------- settle-up, in the native design's card language ---------- */
.settle-row {
  border: 2px solid var(--ink);
  border-radius: var(--r-card);
  background: var(--paper-bright);
  padding: 13px 14px;
  margin-bottom: 10px;
  position: relative;
  overflow: hidden;
}
.settle-row.done { border-color: var(--ok); }
.settle-row .s-amt { font-family: var(--display); font-size: 22px; letter-spacing: 0.02em; }
.settle-row .s-txt { font-size: 12px; }

/* The moment a debt closes: a stamp lands on the card. */
.paid-stamp {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: rgba(250, 246, 236, 0.82);
}
.paid-stamp span {
  font-family: var(--display); font-size: 26px; letter-spacing: 0.08em;
  color: var(--ok); border: 3px solid var(--ok); border-radius: 8px;
  padding: 2px 16px; transform: rotate(-8deg);
  animation: stampIn 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes stampIn {
  0% { transform: rotate(-14deg) scale(2.2); opacity: 0; }
  60% { transform: rotate(-8deg) scale(0.95); opacity: 1; }
  100% { transform: rotate(-8deg) scale(1); }
}

/* Everyone is square — the design's payoff card. */
.all-square {
  border: 2.5px solid var(--ok);
  border-radius: 18px;
  background: rgba(46, 125, 79, 0.07);
  padding: 18px; text-align: center;
  transform: rotate(-1deg);
  margin-top: 12px;
}
.all-square .as-mark { font-family: var(--display); font-size: 24px; color: var(--ok); letter-spacing: 0.06em; }

@media (prefers-reduced-motion: reduce) {
  .paid-stamp span { animation: none; }
}

/* ---------- confirm sheet (replaces window.confirm) ---------- */
.sheet-scrim {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(10, 16, 12, 0.62);
  animation: scrimIn 0.14s ease-out;
}
.sheet {
  width: min(360px, 100%);
  background: var(--paper); color: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.4);
  padding: 20px 18px 16px;
  animation: sheetPop 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.05);
}
.sheet-title {
  font-family: var(--mono); font-size: 15px; font-weight: 700;
  margin: 0 0 8px; line-height: 1.35;
}
.sheet-body { font-size: 13px; color: var(--ink-faint); line-height: 1.5; margin: 0 0 16px; }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; }
.sheet-actions .btn { width: 100%; }
@keyframes scrimIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheetPop { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }

/* ---------- the dock: bars that must actually be fixed ---------- */
/* Lives outside .receipt, whose transform + clip-path made every fixed child
   neither fixed nor visible. Empty by default so it never eats taps. */
#dock:empty { display: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* One visible focus treatment for everything, in ink rather than red — the red
   border was *lower* contrast than the resting state, so focus made a field
   less prominent. */
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.btn:focus-visible, .btn.stamp:focus-visible { outline-offset: 3px; }
.field:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }

/* Even-split mode: the lines are reference only. They used to stay tappable,
   persisting claims that changed no total — and that turned into real money the
   moment anyone switched back to per-item. */
/* (the inert treatment is defined once, with the other row states) */

/* Inline, next to the control that failed — a join error used to print at the
   top of the page, off-screen from the field you were typing in. */
.error-inline {
  margin: 6px 0 0; font-size: 12.5px; font-weight: 700;
  color: var(--stamp-dark); text-align: left;
}

.promise {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 10px 0 2px;
}
.promise span {
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  border: 1.5px solid var(--ink); padding: 4px 9px; border-radius: 999px;
}

.join-context {
  border: 2px solid var(--ink); background: var(--paper-shade);
  padding: 12px 14px; margin: 12px 0 4px; text-align: center;
}
.join-context .jc-name { font-size: 16px; font-weight: 700; overflow-wrap: anywhere; }
.join-context .jc-meta { font-size: 12px; color: var(--ink-faint); margin-top: 3px; font-variant-numeric: tabular-nums; }
.join-context .jc-safe { font-size: 11.5px; color: var(--ink-faint); margin-top: 7px; }

/* Non-production environment ribbon (v2 beta). Top-right: bottom-left parked it
   on top of the "You owe" cell, the most important number in the product. */
#env-badge {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top, 0px));
  left: 10px;
  z-index: 9999;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
  background: #b8410f;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  user-select: none;
}

/* Settle card internals + the paid log picking up the same people-colours. */
.settle-row .s-head { display: flex; align-items: center; gap: 10px; }
.settle-row .s-head .faces { flex: 0 0 auto; }
.settle-row .s-txt { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.settle-row .s-amt { flex: 0 0 auto; margin-left: auto; }
.settle-row .pay-btn { margin-top: 10px; border-radius: var(--r-field); }
.paid-row .faces { flex: 0 0 auto; margin-right: 8px; }
.paid-row { display: flex; align-items: center; gap: 6px; }
.paid-row .p-txt { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.paid-row .p-amt { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---------- account screen ---------- */
/* No card, no panel: an account is the same paper as everything else. A rounded
   box around "your bank details" would read as a payment widget, which is the
   one thing this screen must never look like. */
.acct-id { text-align: center; margin: 10px 0 2px; }
.acct-id .acct-name { font-size: 18px; font-weight: 700; overflow-wrap: anywhere; }
.acct-id .small { display: block; margin-top: 2px; overflow-wrap: anywhere; }

/* Both providers stacked full width: side by side they'd be two 44px targets
   fighting over 300px of paper, and neither would read as the plain choice. */
.signin-row { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }

.trip-list a.trip-link { text-decoration: none; }

.bank-form label { display: block; margin: 10px 0 4px; }
.bank-num { display: flex; align-items: center; gap: 8px; }
.bank-num .field { flex: 1 1 auto; min-width: 0; }
.bank-num .copy-btn { flex: 0 0 auto; margin-top: 0; min-height: 44px; }
.bank-form .btn { margin-top: 14px; }
.acct-note { margin-top: 8px; }

/* ---------- native app: tab bar, trips, activity ---------- */
/* Every selector below is scoped to .is-native (set on <html> by the app shell)
   so the website cannot inherit a single rule from here. The web build has no
   sections to switch between, and gains nothing from a bar over its content. */

/* The bar lives in #dock, outside .receipt — a transform + clip-path there made
   `position: fixed` neither fixed nor visible. */
.is-native .nv-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  background: var(--felt);
  /* env() is the whole point: the bar sits ABOVE the home indicator, not under
     it, and is 0 in a browser so this stays inert on the web. */
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -6px 22px rgba(0, 0, 0, 0.45);
}
.is-native .nv-tab {
  flex: 1;
  min-height: 48px; /* 48 + the bar's own padding clears the 44px target */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  background: none;
  cursor: pointer;
  font-family: var(--mono);
  color: rgba(250, 246, 236, 0.45);
  -webkit-tap-highlight-color: transparent;
}
.is-native .nv-tab .nv-glyph { font-size: 17px; line-height: 1; }
.is-native .nv-tab .nv-label {
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  /* Trailing letter-spacing pushes the word left of centre; the indent pays it
     back, same trick the brand block uses. */
  text-indent: 0.18em;
  line-height: 1;
}
.is-native .nv-tab[aria-current="page"] { color: var(--paper); font-weight: 700; }
.is-native .nv-tab:active { opacity: 0.7; }

/* The badge is position:fixed, so it does not move with the receipt's safe-area
   padding — at 10px+inset it landed half on the paper and half on the torn edge.
   In the app, park it on the title row, left of the account button. */
.is-native #env-badge {
  top: calc(env(safe-area-inset-top, 0px) + 45px);
  left: auto;
  right: 66px;
}
/* Screens that show the wordmark instead of a title row have no free corner —
   the badge sat on top of "CUENTAS". Centre it above the mark and make room. */
.is-native body:has(.brand) #env-badge,
body.is-native:has(.brand) #env-badge {
  top: calc(env(safe-area-inset-top, 0px) + 18px);
  left: 50%;
  right: auto;
  transform: translateX(-50%);
}
.is-native .brand { margin-top: 30px; }

/* On a tablet the surface's top padding grows (clamp caps at 44px) and the
   safe-area inset shrinks, so a badge pinned to the viewport lands on the torn
   edge instead of the paper. Push it into the sheet on wide screens. */
@media (min-width: 700px) {
  .is-native #env-badge,
  body.is-native:has(.brand) #env-badge {
    top: calc(env(safe-area-inset-top, 0px) + 60px);
  }
}

/* Content must not end underneath the bar. */
.is-native .table-surface { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 96px); }

/* When a trip's sticky bar and the tab bar are both docked, the sticky bar
   stacks on top of it instead of hiding behind it. */
.is-native #dock:has(.nv-tabbar) .sticky-bar {
  bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  padding-bottom: 9px;
}

/* ---------- screen titles ---------- */
.is-native .nv-title {
  font-family: var(--display);
  font-size: 24px;
  letter-spacing: 0.05em;
  text-indent: 0.05em;
  text-align: center;
  margin: 4px 0 14px;
}
.is-native .nv-empty { text-align: center; font-size: 15px; font-weight: 700; margin: 18px 0 6px; }

/* ---------- VIAJES ---------- */
.is-native .nv-trips { display: flex; flex-direction: column; gap: 10px; }

.is-native .nv-trip {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  padding: 12px 14px;
  font-family: var(--mono);
  text-align: left;
  cursor: pointer;
  color: var(--ink);
  background: var(--paper-bright);
  border: 2px solid var(--ink);
  border-radius: var(--r-card);
  -webkit-tap-highlight-color: transparent;
}
.is-native .nv-trip-main { flex: 1 1 auto; min-width: 0; display: block; }
.is-native .nv-trip-name {
  display: block; font-size: 14px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.is-native .nv-trip-code {
  display: block; margin-top: 2px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.16em; color: var(--ink-faint);
}
.is-native .nv-chev { flex: 0 0 auto; font-size: 20px; line-height: 1; color: var(--ink-faint); }

/* The hero: the most recent trip is the one you came back for, so it gets the
   felt block and the total in the display face. Everything else is a row. */
.is-native .nv-hero {
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  text-align: left;
  cursor: pointer;
  font-family: var(--mono);
  background: var(--felt);
  color: var(--paper);
  border: 2px solid var(--ink);
  border-radius: var(--r-card);
  box-shadow: 4px 4px 0 rgba(28, 26, 22, 0.25);
  -webkit-tap-highlight-color: transparent;
}
.is-native .nv-hero:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 rgba(28, 26, 22, 0.25); }
.is-native .nv-hero-top { display: block; padding: 14px 16px 13px; }
.is-native .nv-hero-line { display: flex; align-items: baseline; gap: 10px; }
.is-native .nv-hero-name {
  flex: 1 1 auto; min-width: 0;
  font-size: 13px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.is-native .nv-hero-code {
  flex: 0 0 auto;
  font-size: 11px; font-weight: 700; letter-spacing: 0.16em;
  color: rgba(250, 246, 236, 0.55);
}
.is-native .nv-hero-total {
  display: block;
  margin-top: 6px;
  font-family: var(--display);
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.is-native .nv-hero-meta {
  display: block; margin-top: 4px;
  font-size: 10.5px; letter-spacing: 0.06em;
  color: rgba(250, 246, 236, 0.55);
}
/* The light strip: it is the answer to "and what does that mean for me?", so it
   is on paper rather than buried in the dark block. */
.is-native .nv-hero-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 16px;
  background: var(--paper-shade);
  color: var(--ink);
}
.is-native .nv-hero-stand { flex: 1 1 auto; min-width: 0; font-size: 12px; font-weight: 700; }
.is-native .nv-hero-stand.ok { color: var(--ok); }

/* Dashed, because it is an invitation rather than the action of this screen —
   the same weight as the solid buttons would fight the hero above it. */
.is-native .nv-new {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 14px;
  padding: 14px 12px;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  text-indent: 0.16em;
  cursor: pointer;
  color: var(--ink);
  background: transparent;
  border: 2px dashed var(--ink);
  border-radius: var(--r-btn);
}
.is-native .nv-new:active { background: var(--paper-shade); }

/* ---------- ACTIVIDAD ---------- */
.is-native .nv-feed { display: flex; flex-direction: column; }
.is-native .nv-act {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 6px;
  border-bottom: 1px dotted rgba(28, 26, 22, 0.35);
}
.is-native .nv-act:last-child { border-bottom: 0; }
.is-native .nv-act .face { flex: 0 0 auto; width: 28px; height: 28px; font-size: 12px; margin-left: 0; }
.is-native .nv-act-body { flex: 1 1 auto; min-width: 0; }
.is-native .nv-act-text { display: block; font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.is-native .nv-act-when { display: block; margin-top: 2px; font-size: 10.5px; color: var(--ink-faint); }
/* Ochre, not the alert red: a receipt with no payer is unfinished, not wrong. */
.is-native .nv-act.warn .nv-act-text { color: var(--ochre); }
.is-native .nv-act.warn .nv-act-text b { color: var(--ochre); }

.is-native .nv-pill {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 14px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  color: var(--ink);
  background: transparent;
  border: 2px solid var(--ink);
  border-radius: var(--r-pill);
  -webkit-tap-highlight-color: transparent;
}
.is-native .nv-pill:active { background: var(--ink); color: var(--paper); }


/* ---------- app header + tab bar corrections ---------- */
/* One header for every app screen, so switching tabs doesn't move the world. */
.is-native .nv-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-top: 2px;
}
.is-native .nv-head .nv-title {
  font-family: var(--display); font-size: 24px; letter-spacing: 0.05em; line-height: 1;
  text-indent: 0.05em;
}
/* The account, reachable in one tap but not one of the app's declared pillars. */
.is-native .nv-acct {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid var(--ink); background: var(--paper-shade); color: var(--ink);
  font-family: var(--display); font-size: 15px; line-height: 1; cursor: pointer;
  display: grid; place-items: center;
}
.is-native .nv-acct:active { background: var(--ink); color: var(--paper); }

.is-native .nv-tabbar { border-top: 1px dashed rgba(250, 246, 236, 0.18); }
.is-native .nv-tab {
  /* A transparent border on every tab so the active one's rule doesn't shift
     the row by 2px when it appears. */
  border-top: 2px solid transparent;
}
.is-native .nv-tab[aria-current="page"] { border-top-color: var(--stamp); }
.is-native .nv-glyph { display: block; margin: 0 auto 3px; }

/* ---------- the name badge ---------- */
/* The gate used to ask "¿Cómo te llamamos?" in body text, which read like a
   form. It is the one moment the app asks who you are, so it gets the object
   everybody already knows: the peel-and-stick name badge, slapped on the
   receipt slightly crooked. */
.name-sticker {
  width: min(300px, 92%);
  margin: 0 auto;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 4px;
  box-shadow: 3px 3px 0 rgba(20, 32, 25, 0.18);
  transform: rotate(-1.6deg);
  overflow: hidden;
}
.ns-band {
  background: var(--stamp);
  color: var(--paper);
  border-bottom: 2px solid var(--ink);
  text-align: center;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.14em;
  padding: 8px 6px 7px;
}
/* Ruled like the real thing, so the name sits on a line rather than floating. */
.ns-body { padding: 16px 14px 14px; background: #fff; }
.ns-input {
  width: 100%;
  border: 0;
  border-bottom: 2px solid #8fa9c4;
  background: transparent;
  font-family: inherit;
  font-size: 21px;
  text-align: center;
  padding: 4px 2px 7px;
  color: var(--ink);
  border-radius: 0;
}
.ns-input::placeholder { color: #b9c5d2; }
/* The whole badge takes the focus ring — the bare input has no border to grow. */
.ns-input:focus { outline: none; }
.name-sticker:focus-within {
  box-shadow: 3px 3px 0 rgba(20, 32, 25, 0.18), 0 0 0 3px var(--stamp);
}
/* Deliberately NOT straightened on focus: the field autofocuses, so the badge
   would snap square before anyone ever saw it crooked, which is the whole
   point of it being a badge and not a text input. */

/* ---------- the recap ---------- */
/* Printed, not plotted: the bars are made of the same characters as the rest
   of the paper, so the chart reads as part of the receipt rather than a widget
   dropped onto it. */
.rc-total { text-align:center; margin:16px 0 4px; }
.rc-big {
  font-family: var(--display, inherit);
  font-size: clamp(38px, 13vw, 60px);
  font-weight: 700; line-height: 1; letter-spacing: -.02em;
  color: var(--stamp); margin: 4px 0 6px;
  font-variant-numeric: tabular-nums;
}
.rc-cats { margin: 8px 0 2px; }
.rc-cat {
  display: grid;
  grid-template-columns: 7em 1fr 2.6em 5.2em;
  align-items: baseline; gap: 8px;
  padding: 3px 0; font-size: 13px;
}
.rc-cat-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-bar { color: var(--stamp); letter-spacing: -1px; overflow: hidden; white-space: nowrap; }
.rc-cat-pct { text-align: right; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.rc-cat-amt { text-align: right; font-variant-numeric: tabular-nums; }
.rc-sups { margin: 6px 0 2px; }
.rc-sup {
  padding: 6px 0; font-size: 14px; line-height: 1.4;
  border-bottom: 1px dotted var(--rule-faint, rgba(0,0,0,.14));
}
.rc-sup:last-child { border-bottom: 0; }
.rc-merch { color: var(--ink-faint); font-size: 12px; line-height: 1.5; }
@media (max-width: 380px) {
  .rc-cat { grid-template-columns: 6.4em 1fr 2.3em 4.6em; font-size: 12px; gap: 5px; }
}

/* ---------- month strip (home ledgers) ---------- */
/* A home is browsed by period, so the months sit where a trip shows its code.
   Horizontal scroll rather than a wrap: the current month must stay first and
   reachable without the strip changing height as a household accumulates. */
.month-strip {
  display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 6px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.month-strip::-webkit-scrollbar { display: none; }
.month-chip {
  flex: 0 0 auto; border: 1.5px solid var(--ink); background: transparent;
  color: var(--ink); font: inherit; font-size: 11.5px; letter-spacing: .08em;
  text-transform: uppercase; padding: 5px 10px; cursor: pointer;
  border-radius: 0;
}
.month-chip.on { background: var(--ink); color: var(--paper); font-weight: 700; }
.month-chip:active { opacity: .7; }


/* ---------- tablet ---------- */
/* A receipt is narrow by nature, so this widens rather than fills: enough that
   the sheet reads as chosen for the device instead of a phone column stranded
   in the middle of it, without stretching the paper into something that stops
   looking like paper. Type scales a little with it so the lines keep their
   measure. */
@media (min-width: 700px) {
  .receipt { width: min(580px, 92%); font-size: 16px; }
  .table-surface { padding-top: calc(28px + env(safe-area-inset-top, 0px)); }
  .brand { font-size: clamp(44px, 7vw, 64px); }
  .btn { font-size: 16px; padding: 15px 14px; }
  .item-row { padding: 13px 4px; }
}
