body.v2 { min-height: 100svh; display: flex; flex-direction: column; }
.toy-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; }
.toy-back { display: inline-flex; min-height: 44px; align-items: center; padding: 8px 14px; border-radius: 999px; background: var(--t-card); box-shadow: inset 0 0 0 1px var(--t-line); text-decoration: none; font-size: 15px; font-weight: 600; }
.toy-bar .t-label { color: var(--t-ink-2); font-size: 10px; text-align: right; }
main { flex: 1; display: flex; flex-direction: column; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.t-stage { margin: 0 12px; padding: 22px 14px 24px; display: grid; min-width: 0; }
.toy-top h1 { font-size: clamp(50px,13.5vw,120px); line-height: .86; margin: 0; }
/* Phones: the title, Vasya's bubble, the receipt, then the sticky total bar. The bubble and the bar
   share one wrapper (.toy-side) so on desktop they stick as a single column and can never overlap. */
.toy-side { display: contents; }
.toy-top { order: -2; }
.t-bubble { order: -1; margin-top: 18px; min-height: 0; }
#plea { display: block; }
/* Focus: an ink ring on the mint slab in both themes (the page ring turns light in dark mode). */
body.v2 .t-stage :focus-visible { outline-color: #141414; }

/* The receipt: a white paper object on the mint slab, torn edge at the bottom. */
.receipt { position: relative; min-width: 0; margin: 24px 0 34px; padding: 18px 12px 20px; border-radius: 18px 18px 0 0; background: var(--paper, #fff); color: #141414; box-shadow: 0 20px 40px -24px rgba(0,0,0,.45); }
.receipt::after { content: ""; position: absolute; left: 0; right: 0; bottom: -11px; height: 12px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='12'%3E%3Cpath d='M0 0h16L8 11z' fill='%23fff'/%3E%3C/svg%3E") repeat-x; }
@media (prefers-color-scheme: dark) {
  /* Off-white paper on the dark page; every receipt text pair stays ≥4.5:1 on it. */
  .receipt { --paper: #f7f6f2; }
  .receipt::after { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='12'%3E%3Cpath d='M0 0h16L8 11z' fill='%23f7f6f2'/%3E%3C/svg%3E"); }
}
body.v2 .receipt :focus-visible { outline: 3px solid #141414; outline-offset: 2px; }
.r-block { min-width: 0; margin: 0 0 16px; padding: 0 0 16px; border: 0; border-bottom: 2px dashed rgba(20,20,20,.18); }
.r-head { float: left; width: 100%; padding: 0; margin: 0 0 10px; font: 500 12px/1.4 var(--t-mono); letter-spacing: .08em; text-transform: uppercase; color: #5d5b55; }
.r-head + * { clear: both; }
.receipt input, .receipt select { min-width: 0; min-height: 44px; border: 0; border-radius: var(--t-r-s); background: #f1f0ec; color: #141414; font-size: 16px; padding: 0 12px; box-shadow: inset 0 0 0 1.5px rgba(20,20,20,.1); }
.receipt input::placeholder { color: #6b6962; opacity: 1; }
.receipt input[aria-invalid="true"] { box-shadow: inset 0 0 0 2px #141414; }
.r-add { min-height: 44px; margin-top: 10px; padding: 0 16px; border: 2px dashed rgba(20,20,20,.4); border-radius: 999px; background: transparent; color: #141414; font-weight: 700; cursor: pointer; transition: transform var(--t-base) var(--t-spring); }
.r-add:active { transform: scale(.94); }
.r-add[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.remove { flex: none; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: #141414; font-size: 24px; line-height: 1; cursor: pointer; }
.remove:hover { background: rgba(20,20,20,.08); }

.people { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.person { display: flex; align-items: center; flex: 1 1 140px; max-width: 100%; min-width: 0; border-radius: 999px; background: #f1f0ec; box-shadow: inset 0 0 0 1.5px rgba(20,20,20,.12); padding-left: 4px; animation: bill-print .45s var(--t-spring) both; }
.receipt .person-name { flex: 1; width: 100%; background: transparent; box-shadow: none; font-weight: 600; border-radius: 999px; }

.dishes { margin: 0; padding: 0; list-style: none; }
.dish { padding: 10px 0 12px; border-bottom: 1px dashed rgba(20,20,20,.16); animation: bill-print .45s var(--t-spring) both; }
.dish:first-child { padding-top: 0; }
.dish-top { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,5.5em) 44px; gap: 4px; align-items: center; }
.price { display: flex; align-items: center; min-width: 0; border-radius: var(--t-r-s); background: #f1f0ec; box-shadow: inset 0 0 0 1.5px rgba(20,20,20,.1); }
.price .sign { padding-left: 10px; font: 600 15px var(--t-mono); }
.receipt .dish-price { width: 100%; padding: 0 8px 0 4px; text-align: right; font-family: var(--t-mono); font-variant-numeric: tabular-nums; background: transparent; box-shadow: none; }
/* One well: the inner input never draws its own box, ring or invalid outline. */
.receipt .price .dish-price[aria-invalid="true"] { box-shadow: none; }
body.v2 .receipt .price .dish-price:focus-visible { outline: none; }
.receipt .price:focus-within { outline: 3px solid #141414; outline-offset: 2px; }
.price:has(.dish-price[aria-invalid="true"]) { box-shadow: inset 0 0 0 2px #141414; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; width: fit-content; max-width: 100%; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; min-height: 44px; max-width: 100%; padding: 0 14px; border: 0; border-radius: 999px; background: #f1f0ec; color: #141414; font-weight: 600; font-size: 15px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; box-shadow: inset 0 0 0 1.5px rgba(20,20,20,.16); transition: transform var(--t-base) var(--t-spring), background var(--t-base); }
.chip:active { transform: translateY(2px) scale(.94); }
.chip[aria-pressed="true"] { background: var(--t-mint); box-shadow: inset 0 -4px 0 rgba(0,0,0,.18), inset 0 0 0 1.5px #141414; }
.chip[aria-pressed="true"]::before { content: "✓"; content: "✓" / ""; margin-right: 6px; }
.chip.all { background: transparent; box-shadow: inset 0 0 0 1.5px rgba(20,20,20,.45); }
.chip.all[aria-pressed="true"] { background: #141414; color: #fff; box-shadow: none; }
.flag { display: flex; gap: 8px; align-items: baseline; margin: 8px 0 0; font-size: 14px; font-weight: 600; line-height: 1.35; color: #141414; }
.flag::before { content: "!"; flex: none; display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 6px; background: #141414; color: #fff; font: 700 12px/1 var(--t-mono); }
/* A priced dish nobody had: the chips row is what needs a tap, so that is what gets the outline. */
.dish.nobody .chips { outline: 2px dashed #141414; outline-offset: 4px; border-radius: 26px; }

.extras-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field span { font: 500 11px/1.3 var(--t-mono); letter-spacing: .06em; text-transform: uppercase; color: #5d5b55; }
.field:last-child { grid-column: 1 / -1; }
.field input { font-family: var(--t-mono); }
.extras-note { margin: 10px 0 0; font-size: 13px; color: #5d5b55; }

.sums { margin: 0; font: 500 14px/1.3 var(--t-mono); font-variant-numeric: tabular-nums; }
.sums div { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.sums dd { margin: 0; overflow-wrap: anywhere; text-align: right; }
.sums .grand { margin-top: 6px; padding-top: 8px; border-top: 2px solid #141414; font-size: 17px; font-weight: 700; }
#unassigned { margin-top: 12px; }

.toy-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.counter { margin: 0; min-width: 0; font: 500 13px/1.3 var(--t-mono); }
#total { display: block; font: 800 clamp(30px,9vw,44px)/1 var(--t-display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
#split { min-width: 132px; font-size: 19px; }

.about { margin: 16px 12px 0; padding: 20px 18px; border-radius: var(--t-r-l); background: var(--t-card); box-shadow: inset 0 0 0 2px var(--t-line); }
.about h2 { margin: 0 0 8px; color: var(--t-ink-2); }
.about p { margin: 0 0 10px; max-width: 62ch; }
.about .fair { margin: 0; font-size: 13px; line-height: 1.45; color: var(--t-ink-2); }

/* Result sheet. */
/* The amount never wraps: long amounts start smaller and app.js shrinks it further to fit the sheet. */
.t-reveal h2 .t-stat { display: block; margin: 10px 0 4px; font-family: var(--t-display); text-transform: none; white-space: nowrap; }
.t-reveal h2 .t-stat.long { font-size: clamp(48px,13vw,96px); }
.t-reveal h2 .t-stat.longer { font-size: clamp(36px,10vw,72px); }
/* Keyboard focus lands on the heading: a thin ring held clear of the label and the amount. */
body.v2 .t-reveal #outcome-title:focus-visible { outline: 2px solid var(--t-ink); outline-offset: 8px; border-radius: 12px; }
.t-reveal .t-verdict { margin: 8px 0 18px; }
.shares { display: grid; gap: 8px; margin: 0 0 12px; padding: 0; list-style: none; }
.shares li { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 2px 12px; align-items: baseline; padding: 10px 12px; border-radius: var(--t-r-s); background: var(--t-surface-2); }
.shares .who { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shares .amt { font: 600 18px/1.2 var(--t-mono); font-variant-numeric: tabular-nums; }
.shares small { grid-column: 1 / -1; font: 500 12.5px/1.35 var(--t-mono); color: var(--t-ink-2); font-variant-numeric: tabular-nums; }
.reconcile, .skipped { margin: 0 0 10px; font-size: 14px; color: var(--t-ink-2); }
/* The button and the answer share one slot: the panel takes the button's place. */
.reveal-box { display: grid; margin: 16px 0 18px; }
.reveal-box > * { grid-area: 1 / 1; }
.reveal-box .t-pill { width: 100%; min-height: 64px; box-shadow: inset 0 0 0 2px var(--t-line), inset 0 -4px 0 rgba(0,0,0,.1); }
.reveal-box .t-pill[aria-expanded="true"] { visibility: hidden; }
.reveal-box .t-pill[aria-disabled="true"] { cursor: progress; }
.reveal-panel { position: relative; display: flex; flex-direction: column; justify-content: center; min-width: 0; min-height: 64px; padding: 12px 18px; border-radius: 22px; background: var(--t-surface-2); }
.reveal-roll { margin: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font: 800 clamp(28px,8vw,36px)/1 var(--t-display); font-variation-settings: "wdth" 88, "opsz" 96; color: var(--toy-text); }
.reveal-roll:empty { display: none; }
.reveal-text { margin: 0; font-size: 20px; font-weight: 600; line-height: 1.3; }
.reveal-text:empty { display: none; }
.reveal-text .dish-hit { color: var(--toy-text); font-weight: 800; }
.reveal-text:focus { outline: none; }
.reveal-text:focus-visible { outline: 3px solid var(--t-ink); outline-offset: 4px; }
/* Focus waits on the panel during the drumroll (the button under it is hidden): a light ring. */
body.v2 .t-reveal .reveal-panel:focus-visible { outline: 2px solid var(--t-ink); outline-offset: 3px; }
.landed .reveal-text { animation: bill-land .5s var(--t-spring); }
.t-share { margin-bottom: 0; }
.t-share .mini { font-size: 34px; }
/* Share and Edit stay reachable when a big table makes the sheet scroll: the foot sticks to its bottom. */
.result-foot { position: sticky; bottom: -26px; z-index: 1; margin: 0 -18px -26px; padding: 18px 18px 26px; background: linear-gradient(to bottom, transparent, var(--t-card) 18px); }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.result-actions .t-pill { flex: 1; padding-inline: 16px; white-space: nowrap; }
/* On the dark sheet the ink pill vanishes: this toy's primary Share turns mint. */
@media (prefers-color-scheme: dark) { .t-reveal .result-actions #share { background: var(--t-mint); color: #141414 !important; box-shadow: inset 0 -4px 0 rgba(0,0,0,.18); } }
#toy-share-status { margin: 12px 0 0; font-size: 14px; }
#toy-share-status:empty { margin: 0; }

@keyframes bill-print { from { transform: translateY(-8px) scale(.97); } }
@keyframes bill-land { from { transform: scale(.86); } }

footer { padding: 16px; font-size: 11.5px; color: var(--t-ink-2); font-family: var(--t-mono); }
footer nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
footer nav a { display: inline-flex; align-items: center; min-height: 44px; }
footer p { margin: 4px 0; }

/* Phones: the total and Split it ride a sticky bar at the bottom of the slab while the
   receipt scrolls; it settles in place at the slab's end, so it never hides content. */
@media (max-width: 899.98px) {
  html { scroll-padding-bottom: 112px; }
  .toy-controls { position: sticky; bottom: 0; z-index: 2; flex-wrap: nowrap; margin: 0 -14px -24px; padding: 12px 14px calc(22px + env(safe-area-inset-bottom, 0px)); border-radius: 22px 22px 34px 34px; background: var(--toy); box-shadow: inset 0 -10px 0 rgba(0,0,0,.16), 0 -16px 24px -20px rgba(0,0,0,.55); }
  #total { font-size: clamp(24px,7.6vw,34px); }
  #split { flex: none; }
}
@media (min-width: 640px) {
  .extras-grid { grid-template-columns: 1fr 1fr 1fr; }
  .field:last-child { grid-column: auto; }
  .person { flex: 0 1 200px; }
}
@media (min-width: 900px) {
  .t-stage { margin: 0 24px; padding: 48px; column-gap: 48px; grid-template-columns: minmax(0,1fr) minmax(0,1.1fr); grid-template-rows: auto auto 1fr; align-items: start; }
  /* Desktop: the title scrolls away; Vasya's bubble and the total + Split it row stick together as one
     column beside a long receipt and are pushed up together at the slab's end. */
  .toy-top, .toy-side { grid-column: 1; width: 100%; max-width: 460px; }
  .toy-top { grid-row: 1; }
  .toy-side { grid-row: 2; display: block; position: sticky; top: 24px; }
  .toy-controls { margin-top: 28px; }
  .receipt { grid-column: 2; grid-row: 1 / -1; margin: 0 0 12px; padding: 24px 22px 26px; }
  .about { margin: 24px 24px 0; padding: 28px 32px; }
}
@media (prefers-reduced-motion: reduce) {
  .person, .dish, .landed .reveal-text { animation: none !important; }
  .r-add, .chip { transition: none; }
  .r-add:active, .chip:active { transform: none; }
}
