/* Shared page styles. Every colour, font, size, radius, shadow and space comes from tokens.css. */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--surface-page); color: var(--ink); min-height: 100vh; display: flex; flex-direction: column; }
img { max-width: 100%; height: auto; }
a { color: var(--surface-brand); text-underline-offset: 3px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header: the full lockup (star + wordmark). The star's ink is exactly surface-brand, so on a surface-brand band it
   vanishes and only the wordmark shows; surface-inverse keeps the star, the butter VAN CITY and the white CONNECT visible.
   On dark screens the darker lilac does the same job (surface-inverse turns light there and would hide CONNECT). */
.site-header { background: var(--surface-inverse); padding: var(--space-4); }
.site-header a { display: inline-block; border-radius: var(--radius-sm); }
.site-header img { display: block; width: 180px; }
@media (prefers-color-scheme: dark) { .site-header { background: var(--surface-lilac); } }

main { width: 100%; max-width: 68ch; margin: 0 auto; padding: var(--space-5) var(--space-4) var(--space-7); flex: 1; }
.site-footer { padding: var(--space-5) var(--space-4); color: var(--ink-subtle); font-size: var(--caption-size); line-height: var(--caption-line); text-align: center; }

/* Type */
h1, h2, h3 { margin: 0; color: var(--ink); }
h1 { font-size: var(--display-lg-size); line-height: var(--display-lg-line); letter-spacing: var(--display-lg-tracking); }
h2 { font-size: var(--display-md-size); line-height: var(--display-md-line); letter-spacing: var(--display-md-tracking); }
h3 { font-size: var(--display-sm-size); line-height: var(--display-sm-line); letter-spacing: var(--display-sm-tracking); }
@media (min-width: 640px) {
  h1 { font-size: var(--display-xl-size); line-height: var(--display-xl-line); letter-spacing: var(--display-xl-tracking); }
}
p { margin: 0; }
.eyebrow { color: var(--ink-muted); margin: 0 0 var(--space-2); }
.lead { font-size: var(--lead-size); line-height: var(--lead-line); font-weight: var(--lead-weight); color: var(--ink-muted); }
.small { font-size: var(--body-sm-size); line-height: var(--body-sm-line); }
.muted { color: var(--ink-muted); }
.stack > * + * { margin-top: var(--space-4); }
.stack-sm > * + * { margin-top: var(--space-2); }
.section { margin-top: var(--space-7); }
.section > h2 { margin-bottom: var(--space-4); }

/* Meta rows: one icon per row */
.meta { list-style: none; margin: var(--space-4) 0 0; padding: 0; }
.meta li { display: flex; gap: var(--space-2); align-items: flex-start; }
.meta li + li { margin-top: var(--space-2); }
.meta .icon { color: var(--ink-muted); flex: none; margin-top: var(--space-1); }
.icon { flex: none; vertical-align: middle; }

/* Cards */
.card { background: var(--surface-card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-4); box-shadow: var(--shadow-sm); }
.cards > * + * { margin-top: var(--space-5); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); }
.card-head h3 { overflow-wrap: anywhere; }

/* Butter: one highlight block per screen. Text on it is always on-butter. */
.butter { background: var(--surface-butter); color: var(--on-butter); border-radius: var(--radius-lg); padding: var(--space-4); }
.butter :focus-visible { outline-color: var(--focus-inverse); }
/* On the dark blocks the purple ring all but vanishes; use the light ink instead. */
.hero :focus-visible, .site-header :focus-visible, .notice-brand :focus-visible { outline-color: var(--ink-inverse); }
.butter .muted, .butter .eyebrow { color: var(--on-butter); }

/* Buttons: pill by default */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--space-7); padding: var(--space-2) var(--space-5); border-radius: var(--radius-pill);
  font: inherit; font-size: var(--label-size); line-height: var(--label-line); font-weight: var(--label-weight);
  border: 1px solid transparent; cursor: pointer; text-decoration: none; transition: background-color 150ms, border-color 150ms;
  background: var(--surface-brand); color: var(--on-brand);
}
.btn:hover { background: var(--surface-brand-strong); }
.btn-sunset { background: var(--surface-sunset); color: var(--on-sunset); }
.btn-sunset:hover { background: var(--surface-sunset); filter: brightness(0.9); }
.btn-quiet { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn-quiet:hover { background: var(--surface-muted); }
.btn-block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { background: var(--surface-muted); color: var(--ink-subtle); border-color: transparent; cursor: not-allowed; filter: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-3); }

/* Forms */
.field { display: block; }
.field + .field, .field + fieldset, fieldset + .field { margin-top: var(--space-4); }
/* Labels only: a hint span inside the label keeps the hint style (it used to come out bold and label-sized). */
.field > span:not(.hint), legend { display: block; padding: 0; font-size: var(--label-size); line-height: var(--label-line); font-weight: var(--label-weight); margin-bottom: var(--space-2); }
.hint { display: block; font-size: var(--caption-size); line-height: var(--caption-line); color: var(--ink-subtle); margin-top: var(--space-1); }
input, select, textarea {
  width: 100%; font: inherit; font-size: var(--body-size); color: var(--ink); background: var(--surface-card);
  border: 1px solid var(--line-strong); border-radius: var(--radius-md); padding: var(--space-3); min-height: var(--space-7);
}
textarea { resize: vertical; min-height: calc(var(--space-7) * 2); }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--status-closed); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.row-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.row-2 > * { min-width: 0; }
/* Date and time inputs keep a wide intrinsic size (iOS Safari especially), which pushed "Arrive by" past the card edge. */
input[type="date"], input[type="time"] { min-width: 0; max-width: 100%; display: block; -webkit-appearance: none; appearance: none; }
input::-webkit-date-and-time-value { text-align: left; }
.row-2 .field + .field { margin-top: 0; }

/* Choice cards (role picker) */
.choices { display: grid; gap: var(--space-2); }
.choice { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4); border: 1px solid var(--line-strong); border-radius: var(--radius-md); background: var(--surface-card); cursor: pointer; }
.choice input { width: auto; min-height: 0; margin: var(--space-1) 0 0; accent-color: var(--surface-brand); }
.choice:has(input:checked) { border-color: var(--surface-brand); background: var(--surface-lilac-soft); box-shadow: inset 0 0 0 1px var(--surface-brand); }
.choice strong { display: block; font-weight: var(--label-weight); }
.choice small { display: block; color: var(--ink-muted); font-size: var(--body-sm-size); line-height: var(--body-sm-line); }

/* Status: always icon + word */
.status { display: inline-flex; align-items: center; gap: var(--space-1); font-size: var(--body-sm-size); line-height: var(--body-sm-line); font-weight: var(--label-weight); white-space: nowrap; }
.status-confirmed { color: var(--status-confirmed); }
.status-pending { color: var(--status-pending); }
.status-closed { color: var(--status-closed); }

/* Notices */
.notice { display: flex; gap: var(--space-3); align-items: flex-start; border: 1px solid var(--line-strong); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); background: var(--surface-card); }
.notice .icon { margin-top: var(--space-1); }
.stale { margin-bottom: var(--space-4); }
.notice-error { border-color: var(--status-closed); }
.notice-error .icon { color: var(--status-closed); }
.notice-warn .icon { color: var(--status-pending); }
.notice-brand { background: var(--surface-inverse); color: var(--ink-inverse); border-color: transparent; }

/* Copy-able link */
.copy-row { display: flex; gap: var(--space-2); align-items: stretch; }
.copy-row input { flex: 1; min-width: 0; font-size: var(--body-sm-size); }

/* People lists */
.people { list-style: none; margin: 0; padding: 0; }
.people li { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); padding: var(--space-2) 0; border-top: 1px solid var(--line); }
.people li:first-child { border-top: 0; }
.people .who { font-weight: var(--label-weight); overflow-wrap: anywhere; }
.people li > :first-child { min-width: 0; }
.people .where { flex: none; max-width: 50%; color: var(--ink-muted); font-size: var(--body-sm-size); line-height: var(--body-sm-line); text-align: right; overflow-wrap: anywhere; }
.people .note { display: block; color: var(--ink-subtle); font-size: var(--caption-size); line-height: var(--caption-line); overflow-wrap: anywhere; }

/* Stat strip: Anton numbers, eyebrow words */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); background: var(--surface-inverse); color: var(--ink-inverse); border-radius: var(--radius-lg); padding: var(--space-4); text-align: center; }
.stats b { display: block; font-family: var(--font-display); font-weight: var(--stat-number-weight); font-size: var(--stat-number-size); line-height: var(--stat-number-line); letter-spacing: var(--stat-number-tracking); }
.stats .eyebrow { color: var(--ink-inverse); margin: var(--space-1) 0 0; }

@media (prefers-reduced-motion: no-preference) {
  .enter { animation: enter 240ms ease-out; }
  @keyframes enter { from { opacity: 0; } to { opacity: 1; } }
}
.plain { list-style: none; margin: 0; padding: 0; }
.meta.flush { margin: 0; }
.section-sm { margin-top: var(--space-4); }
.card-mine { border-color: var(--surface-brand); box-shadow: var(--shadow-md); }
.card-actions { margin-top: var(--space-4); }
.stat { font-family: var(--font-display); font-weight: var(--stat-number-weight); font-size: var(--stat-number-size); line-height: var(--stat-number-line); letter-spacing: var(--stat-number-tracking); }

/* ---------- Organizer dashboard (/e/:code/admin) ---------- */
main.wide { max-width: 1200px; }
.stats-4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 560px) { .stats-4 { grid-template-columns: repeat(4, 1fr); } }
.lock-panel { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; justify-content: space-between; }
.lock-panel .notice { flex-basis: 100%; }

/* Cars as columns: one per row on a phone, side by side as the screen widens. */
.columns { display: grid; gap: var(--space-5); grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); align-items: start; }
.car-col { display: flex; flex-direction: column; gap: var(--space-3); transition: border-color 150ms, background-color 150ms; }
.car-col.drop-ok { border-color: var(--surface-brand); background: var(--surface-lilac-soft); }
.car-col.drop-no { border-color: var(--status-closed); }
.car-facts { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); margin: 0; padding: 0; list-style: none; color: var(--ink-muted); font-size: var(--body-sm-size); line-height: var(--body-sm-line); }
.car-facts li { display: inline-flex; align-items: center; gap: var(--space-1); }
.rider-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.rider { border: 1px solid var(--line-strong); border-radius: var(--radius-md); background: var(--surface-card); padding: var(--space-3); display: grid; gap: var(--space-2); }
.rider[draggable="true"] { cursor: grab; }
.rider.dragging { opacity: 0.5; }
.rider-top { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: flex-start; }
.rider-top .grip { color: var(--ink-subtle); margin-top: var(--space-1); }
/* The name keeps at least ~9rem; on a narrow card the status chip drops below instead of squeezing it. */
.rider-top .who { flex: 1 1 9rem; min-width: 0; font-weight: var(--label-weight); overflow-wrap: anywhere; }
.rider-top .who small { display: block; font-weight: var(--body-weight); color: var(--ink-muted); font-size: var(--body-sm-size); line-height: var(--body-sm-line); }
.rider-actions { display: flex; gap: var(--space-2); align-items: center; }
.rider-actions select { flex: 1; min-width: 0; min-height: var(--space-7); padding: var(--space-2) var(--space-3); font-size: var(--body-sm-size); }
.btn-sm { min-height: var(--space-7); padding: var(--space-2) var(--space-4); }
.btn-icon { min-width: var(--space-7); padding: var(--space-2); }
.empty-drop { border: 1px dashed var(--line-strong); border-radius: var(--radius-md); padding: var(--space-4); text-align: center; color: var(--ink-muted); font-size: var(--body-sm-size); line-height: var(--body-sm-line); }
.wa-text { font-family: var(--font-sans); min-height: calc(var(--space-9) * 2.5); font-size: var(--body-sm-size); line-height: var(--body-sm-line); white-space: pre-wrap; }
.people .phone { white-space: nowrap; }

/* Edit dialog */
dialog { border: 0; border-radius: var(--radius-lg); padding: 0; width: min(100% - var(--space-5), 34rem); max-height: calc(100% - var(--space-5)); background: var(--surface-card); color: var(--ink); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: var(--surface-inverse); opacity: 0.55; }
dialog form { padding: var(--space-5) var(--space-4); }
.dialog-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); justify-content: space-between; margin-top: var(--space-5); }

/* ---------- Rider pages: /e/:code and /e/:code/car/:driverId (SPEC V2.1, restyled to V3.1–V3.3) ---------- */
.site-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }

/* ---------- Shared pieces from vancity-carpool (same design system) ---------- */
.header-tag { color: var(--surface-lilac); margin: 0; }
@media (prefers-color-scheme: dark) { .header-tag { color: var(--ink); } }
/* V3.2 standard header: 52px, small lockup left, page label right, stays on top while you scroll. */
.site-header { height: calc(var(--space-7) + var(--space-1)); padding: 0 var(--space-4); position: sticky; top: 0; z-index: 6; }
.site-header img { width: auto; height: calc(var(--space-6) - var(--space-1)); }
.rider-page main { padding-top: var(--space-4); }
.rider-page h1 { font-size: var(--display-md-size); line-height: var(--display-md-line); letter-spacing: var(--display-md-tracking); }
/* Tags: small pills, icon plus word. The soft grounds are the status colours thinned on the card colour. */
.tag { display: inline-flex; align-items: center; gap: var(--space-1); flex: none; padding: calc(var(--space-1) - 1px) var(--space-2); border-radius: var(--radius-pill);
  font-size: var(--caption-size); line-height: var(--eyebrow-line); font-weight: var(--eyebrow-weight); white-space: nowrap; }
.tag .icon { width: var(--space-3); height: var(--space-3); }
.tag-ok { background: color-mix(in srgb, var(--status-confirmed) 14%, var(--surface-card)); color: var(--status-confirmed); }
.tag-pending { background: color-mix(in srgb, var(--status-pending) 14%, var(--surface-card)); color: var(--status-pending); }
.tag-neutral { background: var(--surface-muted); color: var(--ink-muted); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); margin-bottom: var(--space-3); }
.section-head h2 { font-size: var(--display-sm-size); line-height: var(--display-sm-line); letter-spacing: var(--display-sm-tracking); }
body.has-bar { padding-bottom: calc(var(--space-9) + env(safe-area-inset-bottom)); }

/* Sticky bottom bar: the screen's one sunset action. */
.join-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; background: var(--surface-card); border-top: 1px solid var(--line); box-shadow: var(--shadow-md); padding: var(--space-3) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom)); }
.join-bar > * { max-width: calc(68ch - var(--space-6)); margin-left: auto; margin-right: auto; }
.join-bar .hint { text-align: center; margin-top: var(--space-2); }
/* On the rider pages the bar sits at the end of the page and sticks to the bottom while you scroll (V3), so it never
   covers the last card or the footer. */
.rider-page .join-bar { position: sticky; }
body.rider-page.has-bar { padding-bottom: 0; }

/* Bottom sheet: scrim + radius-xl top corners; full height while a field has focus. */
.scrim { position: fixed; inset: 0; z-index: 8; background: var(--surface-inverse); opacity: 0; visibility: hidden; transition: opacity 240ms, visibility 0s 240ms; }
.scrim.on { opacity: 0.55; visibility: visible; transition: opacity 240ms; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 9; margin: 0 auto; max-width: 40rem; max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--surface-card); color: var(--ink); border-radius: var(--radius-xl) var(--radius-xl) 0 0; box-shadow: var(--shadow-lg);
  transform: translateY(105%); visibility: hidden; transition: transform 240ms ease-out, visibility 0s 240ms; }
.sheet.on { transform: none; visibility: visible; transition: transform 240ms ease-out; }
.sheet.full { top: 0; bottom: auto; height: 100dvh; max-height: none; border-radius: 0; }
.sheet-form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.sheet-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: var(--space-3) var(--space-4) var(--space-4); display: grid; gap: var(--space-4); align-content: start; }
.sheet-foot { padding: var(--space-3) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: grid; gap: var(--space-2); justify-items: center; }
.sheet-handle { justify-self: center; width: var(--space-7); height: var(--space-1); border-radius: var(--radius-pill); background: var(--line); }
.sheet.full .sheet-handle { visibility: hidden; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); }
.sheet-head h2:focus { outline: none; }
.sheet .field + .field { margin-top: 0; }
.sheet .hint { margin-top: var(--space-2); }
body.sheet-open { overflow: hidden; }

/* Segmented control */
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-1); padding: var(--space-1); background: var(--surface-muted); border-radius: var(--radius-pill); }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; width: 100%; height: 100%; inset: 0; margin: 0; min-height: 0; cursor: pointer; }
.seg span { display: flex; align-items: center; justify-content: center; text-align: center; min-height: calc(var(--space-6) + var(--space-2)); padding: 0 var(--space-2); border-radius: var(--radius-pill);
  color: var(--ink-muted); font-size: var(--label-size); line-height: var(--label-line); font-weight: var(--label-weight); transition: background-color 150ms, color 150ms; }
.seg input:checked + span { background: var(--surface-brand); color: var(--on-brand); }
.seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Station chips under the pickup box */
/* Toast */
.toast { position: fixed; top: var(--space-4); left: var(--space-4); right: var(--space-4); z-index: 20; max-width: calc(40rem - var(--space-6)); margin: 0 auto;
  display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); box-shadow: var(--shadow-md);
  background: var(--status-confirmed); color: var(--ink-inverse); font-size: var(--label-size); line-height: var(--label-line); font-weight: var(--label-weight);
  pointer-events: none; opacity: 0; visibility: hidden; transform: translateY(calc(var(--space-2) * -1)); transition: opacity 240ms, transform 240ms, visibility 0s 240ms; }
.toast.on { opacity: 1; visibility: visible; transform: none; transition: opacity 240ms, transform 240ms; }

.link-btn { background: none; border: 0; padding: var(--space-2); font: inherit; font-size: var(--body-sm-size); line-height: var(--body-sm-line); color: var(--surface-brand); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; min-height: var(--space-6); flex: none; }

/* V3.7 skeleton screens while a page loads: shapes of what's coming, no spinner. */
.skeleton { display: grid; gap: var(--space-3); }
.sk { display: block; border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--surface-muted) 25%, var(--surface-lilac-soft) 50%, var(--surface-muted) 75%); background-size: 200% 100%; animation: sk-shimmer 1.4s ease-in-out infinite; }
.sk-eyebrow { width: 40%; height: var(--space-3); }
.sk-title { width: 75%; height: var(--space-6); }
.sk-line { width: 60%; height: var(--space-4); }
.sk-card { height: calc(var(--space-9) + var(--space-2)); border-radius: var(--radius-lg); }
@keyframes sk-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } }

/* V3.7 "Updated just now · Refresh" */
.updated { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--space-1); margin-top: var(--space-5); }
.updated .link-btn { display: inline-flex; align-items: center; gap: var(--space-1); }


/* ---------- Vancity Split ---------- */
.seg-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.seg-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.seg-5 span { font-size: var(--body-sm-size); padding: 0 var(--space-1); }

/* Tabs: Balances · Expenses · Totals · Activity. Sticky under the header. */
.tabs { position: sticky; top: calc(var(--space-7) + var(--space-1)); z-index: 4; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-1);
  background: var(--surface-page); padding: var(--space-2) 0; margin: var(--space-4) 0 var(--space-4); border-bottom: 1px solid var(--line); }
.tab { background: none; border: 0; font: inherit; font-size: var(--label-size); line-height: var(--label-line); font-weight: var(--label-weight); color: var(--ink-muted);
  padding: var(--space-2) var(--space-1); border-radius: var(--radius-pill); cursor: pointer; min-height: var(--space-7); }
.tab[aria-selected="true"] { background: var(--surface-brand); color: var(--on-brand); }
.tab:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Who's who */
.me-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); margin-top: var(--space-2); }
.pick-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 9rem), 1fr)); gap: var(--space-2); }
.pick-list .btn { justify-content: flex-start; }

/* Balance hero: the screen's one butter block. */
.hero-balance { display: grid; gap: var(--space-2); }
.hero-balance .stat { overflow-wrap: anywhere; }
.inverse-block { background: var(--surface-inverse); color: var(--ink-inverse); border-radius: var(--radius-lg); padding: var(--space-4); }
.inverse-block .muted, .inverse-block .eyebrow { color: var(--ink-inverse); }

/* Rows: expenses, balances, suggested payments, activity */
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li + li { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; min-width: 0; }
button.row { width: 100%; background: none; border: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; border-radius: var(--radius-md); padding-left: var(--space-1); padding-right: var(--space-1); }
button.row:hover { background: var(--surface-muted); }
button.row:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.row-main { flex: 1; min-width: 0; }
.row-main strong { display: block; font-weight: var(--label-weight); overflow-wrap: anywhere; }
.row-main small { display: block; color: var(--ink-muted); font-size: var(--body-sm-size); line-height: var(--body-sm-line); overflow-wrap: anywhere; }
.row-end { flex: none; text-align: right; font-size: var(--body-sm-size); line-height: var(--body-sm-line); }
.row-end b { display: block; font-weight: var(--label-weight); font-size: var(--body-size); }
.row-icon { flex: none; display: grid; place-items: center; width: calc(var(--space-7) - var(--space-1)); height: calc(var(--space-7) - var(--space-1)); border-radius: var(--radius-md); background: var(--surface-lilac-soft); color: var(--surface-brand); }
.row-icon.pay { background: var(--surface-muted); color: var(--ink-muted); }
.pos { color: var(--status-confirmed); }
.neg { color: var(--status-closed); }
.date-head { margin: var(--space-5) 0 var(--space-1); }
.date-head:first-child { margin-top: 0; }
.deleted-row { opacity: 0.6; }

/* Settle-up suggestions */
.pay-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-3); padding: var(--space-3) 0; }
.pay-row .who { flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; }
.pay-row .who b { font-weight: var(--label-weight); }
.pay-row.mine { background: var(--surface-lilac-soft); border-radius: var(--radius-md); padding-left: var(--space-3); padding-right: var(--space-3); }

/* Totals: per-person table and category bars */
.tot-table { width: 100%; border-collapse: collapse; font-size: var(--body-sm-size); line-height: var(--body-sm-line); }
.tot-table th, .tot-table td { padding: var(--space-2) var(--space-1); text-align: right; border-top: 1px solid var(--line); }
.tot-table th:first-child, .tot-table td:first-child { text-align: left; overflow-wrap: anywhere; }
.tot-table thead th { border-top: 0; color: var(--ink-muted); font-weight: var(--label-weight); }
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.bar-label { display: flex; justify-content: space-between; gap: var(--space-3); font-size: var(--body-sm-size); line-height: var(--body-sm-line); margin-bottom: var(--space-1); }
.bar { height: var(--space-2); border-radius: var(--radius-pill); background: var(--surface-muted); overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; background: var(--surface-brand); border-radius: var(--radius-pill); }

/* Expense sheet */
.amount-row { display: grid; grid-template-columns: minmax(0, 1fr) 7rem; gap: var(--space-3); }
.amount-row input[name="amount"] { font-size: var(--lead-size); font-weight: var(--label-weight); }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; min-height: 0; cursor: pointer; }
.chip span { display: inline-flex; align-items: center; gap: var(--space-1); padding: var(--space-2) var(--space-3); border-radius: var(--radius-pill); border: 1px solid var(--line-strong);
  font-size: var(--body-sm-size); line-height: var(--body-sm-line); background: var(--surface-card); }
.chip input:checked + span { background: var(--surface-lilac-soft); border-color: var(--surface-brand); box-shadow: inset 0 0 0 1px var(--surface-brand); }
.chip input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.split-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.split-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-md); }
.split-item label { display: flex; align-items: center; gap: var(--space-2); min-width: 0; cursor: pointer; overflow-wrap: anywhere; }
.split-item input[type="checkbox"] { width: auto; min-height: 0; accent-color: var(--surface-brand); flex: none; }
.split-item input[type="text"] { width: 6.5rem; min-height: var(--space-7); padding: var(--space-2); text-align: right; }
.split-item .share-out { color: var(--ink-muted); font-size: var(--body-sm-size); line-height: var(--body-sm-line); text-align: right; white-space: nowrap; }
.split-status { font-size: var(--body-sm-size); line-height: var(--body-sm-line); font-weight: var(--label-weight); }
.rate-box { display: grid; gap: var(--space-2); padding: var(--space-3); border-radius: var(--radius-md); background: var(--surface-lilac-soft); }
details.more summary { cursor: pointer; color: var(--surface-brand); font-size: var(--body-sm-size); line-height: var(--body-sm-line); }
details.more[open] summary { margin-bottom: var(--space-3); }
.sheet-error:empty { display: none; }

/* Expense detail */
.detail-amount { font-family: var(--font-display); font-size: var(--display-lg-size); line-height: var(--display-lg-line); letter-spacing: var(--display-lg-tracking); }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-2) var(--space-4); margin: 0; font-size: var(--body-sm-size); line-height: var(--body-sm-line); }
.kv dt { color: var(--ink-muted); }
.kv dd { margin: 0; text-align: right; overflow-wrap: anywhere; }

/* Home and new trip */
.trip-list .row { padding: var(--space-3) var(--space-2); }
.result-card { border-color: var(--surface-brand); box-shadow: var(--shadow-md); }
.names-input { min-height: calc(var(--space-9) * 2); }
.empty { text-align: center; color: var(--ink-muted); padding: var(--space-6) var(--space-4); display: grid; gap: var(--space-3); justify-items: center; }
.empty .icon { color: var(--surface-brand); }
code.block { display: block; white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--caption-size); line-height: var(--caption-line); background: var(--surface-muted); border-radius: var(--radius-md); padding: var(--space-3); }
.toast-action { color: var(--ink-inverse); margin-left: auto; }
.stats > div { min-width: 0; }
.stats-money b { font-size: var(--display-sm-size); line-height: var(--display-sm-line); overflow-wrap: anywhere; }
@media (min-width: 480px) { .stats-money b { font-size: var(--stat-number-size); line-height: var(--stat-number-line); } }
.table-wrap { overflow-x: auto; }
