/* Split page: a scrolling page built on the tokens, buttons, chips and sheet in style.css.
   The title is the jade sign, cards are cream with a 1px printed edge, jade marks what is on or in focus,
   red stays for the main action (Share split) and errors. */
:root { --danger: var(--accent-ink); } /* errors and remove: the chilli, as text */

body.split { overflow-y: auto; overflow-x: hidden; } /* style.css locks the wheel page in place */
/* the document is what scrolls (body's overflow passes to it): scrolling to a row or Add QR stops above the counter */
html { scroll-padding: 12px 0 calc(136px + env(safe-area-inset-bottom)); }

.page {
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: calc(140px + env(safe-area-inset-bottom)); /* room above the counter and its awning */
}
.top--split { flex-direction: column; align-items: stretch; gap: 0; }
.top--split .sign h1 { white-space: normal; overflow-wrap: anywhere; text-wrap: balance; }
.sign__btn svg { flex: none; }
.sign__btn--icon { width: 44px; padding: 0; justify-content: center; } /* once there is a name, it gets the room */
/* top bar: back on the left, reset on the right, the sign below. Plain jade text with icons */
.nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 -2px 10px; }
.nav__btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 44px;
  padding: 0 2px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--jade-ink);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: opacity .15s ease;
}
.nav__btn svg { flex: none; width: 16px; height: 16px; }
.nav__btn:active:not(:disabled) { opacity: .5; }
.nav__btn:disabled { color: var(--muted); opacity: .5; cursor: default; }
.nav__btn:focus-visible { outline: 3px solid var(--jade-ink); outline-offset: 2px; }
@media (hover: hover) {
  .nav__btn:hover:not(:disabled) { opacity: .75; }
}
.sheet__foot--pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#resetSheet .hint { margin: 6px 0 16px; }
.btn--danger { background: var(--accent); color: var(--on-accent); } /* in the confirm sheet, clearing is the main action */

.block {
  margin-top: 28px;
  padding: 0 max(var(--edge), env(safe-area-inset-right)) 0 max(var(--edge), env(safe-area-inset-left));
}
.block__title { font-size: 26px; font-stretch: 70%; font-weight: 800; line-height: 1; text-transform: uppercase; letter-spacing: 0; margin-bottom: 10px; }
.block__count { margin-left: 6px; color: var(--muted); font-variant-numeric: tabular-nums; }
.input::placeholder { color: var(--muted); } /* full muted: 4.5:1 or more on the field in both modes */
.block__hint { margin: -4px 0 12px; }
.block__hint, .hint-line, .hint { text-wrap: pretty; }
.card { background: var(--surface); border-radius: var(--r-lg); box-shadow: inset 0 0 0 1px var(--hair); padding: 14px 16px; }
.card + .card { margin-top: 10px; }

/* fields */
.field { display: grid; gap: 6px; min-width: 0; }
.field__label { font-size: 15px; font-weight: 600; color: var(--muted); }
.field__error { margin-top: 8px; color: var(--danger); font-size: 15px; font-weight: 600; }
.hint-line { margin-top: 8px; font-size: 15px; }
.input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1.5px solid transparent;
  border-radius: var(--r-md);
  background: var(--fill);
  color: var(--ink);
  font: inherit;
  font-size: 17px; /* 16px or more stops iOS zooming in on focus */
  transition: border-color .15s ease, background-color .15s ease;
}
.input:focus { outline: none; border-color: var(--jade-ink); background: var(--surface); } /* jade, so red only ever means an error */
.input[aria-invalid="true"] { border-color: var(--danger); }
.input:disabled { opacity: .45; }
.input--price, .input--rate { text-align: right; font-variant-numeric: tabular-nums; }
.add-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.remove { color: var(--danger); font-size: 16px; }

/* people: one row each, tap to open their prices */
.list { list-style: none; padding: 0; overflow: hidden; }
.list__add { padding: 14px 16px; }
.person + .list__add { padding: 12px 12px 14px 14px; border-top: 0.5px solid var(--hair); }
.person + .person { border-top: 0.5px solid var(--hair); }
.person.is-open { background: color-mix(in srgb, var(--jade-ink) 8%, var(--surface)); } /* jade-ink, so it shows on dark wood too */
.person__head {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  padding: 10px 12px 10px 14px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color .15s ease;
}
.person__head:active { background: var(--fill); }
.person__head:focus-visible { outline: 3px solid var(--jade-ink); outline-offset: -3px; }
@media (hover: hover) {
  .person__head:hover { background: color-mix(in srgb, var(--fill) 60%, transparent); }
}
.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--r-md); /* square enamel badges */
  background: var(--av, var(--fill));
  color: var(--slice-ink);
  font-size: 14px;
  font-weight: 800;
}
.person__text { flex: 1; min-width: 0; display: grid; }
.person__name { font-size: 17px; font-weight: 700; overflow-wrap: anywhere; }
.person__sub { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person__total { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chev { flex: none; color: var(--muted); transition: rotate .2s ease; }
.is-open .chev { rotate: 90deg; }
.person__panel { padding: 2px 16px 10px; }
.person__detail { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 10px; font-size: 14px; font-variant-numeric: tabular-nums; }
.person__detail span { white-space: nowrap; }
.person__panel .remove { margin-top: 8px; } /* apart from the entry above it; Undo covers a mis-tap */

/* price pills inside an open person */
.prices { display: flex; flex-wrap: wrap; gap: 6px; }
.prices:not(:empty) { margin-bottom: 12px; }
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-left: 14px;
  border-radius: var(--r-md);
  background: var(--fill);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.x {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-left: 2px;
  border: 0;
  border-radius: 0 var(--r-md) var(--r-md) 0;
  background: none;
  box-shadow: inset 1px 0 0 color-mix(in srgb, var(--ink) 14%, transparent);
  color: var(--muted);
  cursor: pointer;
}
.x:focus-visible { outline: 3px solid var(--jade-ink); outline-offset: 2px; }
.x:active { color: var(--danger); }
.pill:has(.pill__amt) { padding-left: 0; }
.pill__amt { /* tap a price to give it to others too */
  min-height: 44px;
  padding: 0 12px 0 14px;
  border: 0;
  border-radius: var(--r-md);
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.pill__amt:focus-visible { outline: 3px solid var(--jade-ink); outline-offset: 2px; }

/* shared dishes */
.dishes { list-style: none; padding: 0; }
.dishes:not(:empty) { margin: -6px 0 12px; }
.dish { display: flex; align-items: center; gap: 10px; min-height: 64px; }
.dish__text { flex: 1; min-width: 0; display: grid; }
.dish__each { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dish__each:empty { display: none; }
.dish + .dish { border-top: 0.5px solid var(--hair); }
.dish__name { min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dish__price { font-weight: 600; font-variant-numeric: tabular-nums; }
.dish__who { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 10px 0 14px; max-width: 46%; }
.dish__who-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dish__who svg { flex: none; color: var(--muted); }
.dish-add { display: grid; grid-template-columns: 1fr 108px; gap: 10px; align-items: end; }
.dish-add .btn { grid-column: 1 / -1; }

/* who-shared sheet */
.who-list { padding: 4px 0 10px; }
.check {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 54px;
  padding: 0 var(--edge);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
}
.check + .check { border-top: 0.5px solid var(--hair); }
.check__name { min-width: 0; overflow-wrap: anywhere; }
.avatar--sm { width: 30px; height: 30px; border-radius: var(--r-sm); font-size: 12px; }
.sheet__fields { padding: 10px var(--edge) 0; }
.sheet__fields + .hint, .sheet__error + .hint, #whoEach { margin-top: 10px; }
.sheet__error { padding: 0 var(--edge); }
.sheet__rows { padding: 4px var(--edge) 12px; }
.check input { flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--jade); }

/* charges */
.charge { display: flex; align-items: center; gap: 12px; min-height: 60px; }
.charge ~ .charge { border-top: 0.5px solid var(--hair); }
.charge__hint { margin: 2px 0 14px; }
.charge > label:not(.btn) { flex: 1; display: flex; align-items: center; min-height: 48px; font-weight: 600; cursor: pointer; }
/* iOS-style switch on a plain checkbox (role="switch" in the markup) */
.switch {
  appearance: none;
  flex: none;
  position: relative;
  width: 51px;
  height: 31px;
  margin: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 16%, var(--surface));
  cursor: pointer;
  transition: background-color .2s ease;
}
.switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 2px 4px rgb(0 0 0 / .25);
  transition: translate .2s ease;
}
.switch:checked { background: var(--jade); }
.switch:checked::before { translate: 20px 0; }
.switch:focus-visible { outline: 3px solid var(--jade-ink); outline-offset: 2px; }
.rate { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.input--rate { width: 76px; }
.input--discount { width: 112px; }
.payer__chips { padding: 0; }
.payer__chips:empty { display: none; }
.payer__chips + .block__hint, .payer__chips + .block__hint + .block__hint { margin-top: 12px; }
.btn--file { position: relative; display: inline-flex; align-items: center; overflow: hidden; }
.btn--file input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 0; }
.btn--file:focus-within { outline: 3px solid var(--jade-ink); outline-offset: 2px; }
.qr-thumb { width: 44px; height: 44px; object-fit: contain; border-radius: var(--r-sm); background: #fff; box-shadow: inset 0 0 0 1px var(--hair); }

/* the charges line: defaults rarely change, so the controls live in a sheet */
.strip {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  margin-top: 12px;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color .15s ease;
}
.strip:active { background: var(--fill); }
.strip:focus-visible { outline: 3px solid var(--jade-ink); outline-offset: 2px; }
.strip__parts { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 2px 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.strip__parts .muted { font-weight: 500; }
.strip.is-bad .strip__parts { color: var(--danger); }
.strip__edit { flex: none; display: inline-flex; align-items: center; gap: 2px; color: var(--jade-ink); font-weight: 600; }

/* bill: the chit that gets shared, cream paper with a torn edge */
.receipt-wrap { margin: 14px 0 0; filter: drop-shadow(0 8px 14px var(--shadow)); }
.receipt {
  padding: 22px 20px 30px;
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  mask:
    linear-gradient(#000 0 0) top / 100% calc(100% - 7px) no-repeat,
    radial-gradient(circle at 50% 100%, transparent 6px, #000 6.5px) bottom / 14px 7px repeat-x;
}
/* the shared picture is always light, so the chit stays cream paper on dark wood too */
@media (prefers-color-scheme: dark) {
  .receipt {
    color-scheme: light;
    --surface: #FFFAF0; --ink: #1D2620; --muted: #5F6559; --hair: #E6D9C1; --fill: #EFE4CF;
    --jade-ink: #0E5A44; --accent-ink: #B02B1A; --danger: #B02B1A;
  }
}
.receipt__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 36px; margin-bottom: 14px; }
.receipt__date { font-size: 12.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.stamp { /* PAY <NAME>, as on the picture's sign */
  max-width: 62%;
  padding: 6px 10px 5px;
  border: 2px solid var(--jade-ink);
  border-radius: var(--r-sm);
  color: var(--jade-ink);
  font-size: 17px;
  font-stretch: 70%;
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  rotate: -5deg;
}
.stamp[hidden] { display: none; }
.receipt .owes { border-bottom-style: dashed; border-bottom-width: 1.5px; margin-bottom: 16px; padding-bottom: 16px; }
.receipt .sum .sum__total { border-top: 1.5px dashed var(--hair); }
.receipt__qr {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 20px;
  padding: 14px;
  border: 1.5px dashed color-mix(in srgb, var(--jade-ink) 55%, transparent);
  border-radius: var(--r-md);
}
.receipt__qr[hidden] { display: none; }
.receipt__qr > svg { flex: none; color: var(--jade-ink); }
.receipt__qr > svg[hidden] { display: none; } /* the browser's own [hidden] rule only covers HTML elements */
.receipt__qr p { flex: 1; min-width: 0; display: grid; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.receipt__qr .muted { font-size: 14px; font-weight: 500; }
.receipt__qr .btn { flex: none; }
.qr-remove { display: block; margin: 4px 0 -12px auto; }
.qr-remove[hidden] { display: none; }
.receipt-wrap + .field__error { margin-top: 12px; }
.receipt-note { margin-top: 14px; font-size: 15px; text-align: center; }

/* bill lines */
.owes { display: grid; gap: 10px; list-style: none; margin: 0 0 14px; padding: 0 0 14px; border-bottom: 0.5px solid var(--hair); }
.owes:empty { display: none; }
.owes li { display: flex; align-items: baseline; gap: 10px; font-size: 17px; font-weight: 600; }
.owes__name { min-width: 0; overflow-wrap: anywhere; }
.owes__dots { flex: 1; min-width: 16px; border-bottom: 2px dotted color-mix(in srgb, var(--muted) 45%, transparent); translate: 0 -5px; }
.owes__amt { white-space: nowrap; font-variant-numeric: tabular-nums; }
.owes .is-paid { color: var(--muted); }
.sum { display: grid; grid-template-columns: 1fr auto; gap: 8px 0; }
.sum dt { color: var(--muted); }
.sum dd { margin: 0; padding-left: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.sum .sum__total { color: var(--ink); font-size: 26px; font-stretch: 70%; font-weight: 800; text-transform: uppercase; letter-spacing: 0; padding-top: 8px; border-top: 0.5px solid var(--hair); }

/* counter: the wheel page's dock with its awning, pinned to the screen here */
.dock--split { position: fixed; left: 0; right: 0; max-width: 480px; margin: 0 auto; z-index: 2; }
.dock--split .dock__row { align-items: center; gap: 24px; }
.grand { display: grid; min-width: 0; line-height: 1.2; white-space: nowrap; }
.grand > * { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.grand .muted { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; } /* small spaced label */
.grand strong { font-size: 32px; font-stretch: 70%; font-weight: 800; letter-spacing: 0; font-variant-numeric: tabular-nums; }

/* toast: one message above the counter, with Undo after a removal */
.toast {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(118px + env(safe-area-inset-bottom)); /* just above the counter's awning */
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(100% - 2 * var(--edge));
  max-width: calc(480px - 2 * var(--edge));
  min-height: 52px;
  margin: 0 auto;
  padding: 4px 4px 4px 16px;
  border-radius: var(--r-md);
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
  box-shadow: 0 10px 24px var(--shadow);
  opacity: 0;
  translate: 0 10px;
  pointer-events: none; /* empty and see-through when off; no hidden, so it stays a live region */
  transition: opacity .2s ease, translate .3s cubic-bezier(.2, .9, .25, 1);
}
.toast.is-on { opacity: 1; translate: 0; pointer-events: auto; }
#toastText { flex: 1; min-width: 0; }
.toast__undo {
  flex: none;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: inherit;
  font: inherit;
  font-stretch: 88%;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .025em;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.toast__undo[hidden] { display: none; }
.toast__undo:focus-visible { outline: 3px solid var(--bg); outline-offset: -4px; }

/* typing on a phone: the keyboard needs the room, so the counter steps aside until the field is left */
@media (pointer: coarse) {
  body:has(.page .input:focus) .dock--split { display: none; }
  body:has(.page .input:focus) .toast { bottom: max(12px, env(safe-area-inset-bottom)); }
}

/* motion: a new person's row and a new price arrive, an opened row unfolds. Totals tick and the PAY stamp lands
   from split.js. All of it is off under reduced motion (style.css), except fades split.js keeps. */
.person { animation: row-in .3s cubic-bezier(.16, 1, .3, 1); }
.person__panel:not([hidden]) { animation: unfold .22s cubic-bezier(.16, 1, .3, 1); }
.pill--new { animation: pop .22s cubic-bezier(.16, 1, .3, 1); }
@keyframes row-in { from { opacity: 0; translate: 0 -8px; } }
@keyframes unfold { from { opacity: 0; translate: 0 -6px; } }
@keyframes pop { from { opacity: 0; scale: .85; } }
