/* Splitter: mobile first, one column, big tap targets. Light and dark follow the system. */

:root {
  --bg: #f5f5f3;
  --surface: #ffffff;
  --surface-2: #fafaf8;
  --text: #1c1c1a;
  --muted: #66645f;
  --border: #e2e0db;
  --accent: #3f5fbf;
  --accent-hover: #344fa3;
  --accent-text: #ffffff;
  --accent-soft: #e8ecfa;
  --pos: #15803d;
  --pos-soft: #e3f5e8;
  --neg: #c2410c;
  --neg-soft: #fdeee5;
  --warn: #a16207;
  --warn-soft: #fdf5d9;
  --danger: #b91c1c;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 16px rgb(0 0 0 / 6%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --surface: #1c1c1e;
    --surface-2: #232325;
    --text: #ececec;
    --muted: #9a9a9e;
    --border: #333336;
    --accent: #8da2f0;
    --accent-hover: #aab9f5;
    --accent-text: #121a38;
    --accent-soft: #252b45;
    --pos: #4ade80;
    --pos-soft: #143222;
    --neg: #fb923c;
    --neg-soft: #3a2314;
    --warn: #facc15;
    --warn-soft: #332b0d;
    --danger: #f87171;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
    color-scheme: dark;
  }
}

/* Person colours: avatars, chips and tags. */
.c0 { --pc: #2563eb; --pc-soft: #dbe7fe; }
.c1 { --pc: #db2777; --pc-soft: #fce1ee; }
.c2 { --pc: #059669; --pc-soft: #d5f5e8; }
.c3 { --pc: #d97706; --pc-soft: #fdeccd; }
.c4 { --pc: #7c3aed; --pc-soft: #ebe1fd; }
.c5 { --pc: #0891b2; --pc-soft: #d3f1f8; }
.c6 { --pc: #dc2626; --pc-soft: #fde0e0; }
.c7 { --pc: #4d7c0f; --pc-soft: #e5f2cf; }

@media (prefers-color-scheme: dark) {
  .c0 { --pc: #60a5fa; --pc-soft: #1b2b4a; }
  .c1 { --pc: #f472b6; --pc-soft: #42182d; }
  .c2 { --pc: #34d399; --pc-soft: #12352a; }
  .c3 { --pc: #fbbf24; --pc-soft: #3b2b0c; }
  .c4 { --pc: #a78bfa; --pc-soft: #2c1f4d; }
  .c5 { --pc: #22d3ee; --pc-soft: #0f3540; }
  .c6 { --pc: #f87171; --pc-soft: #421a1a; }
  .c7 { --pc: #a3e635; --pc-soft: #263512; }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

a {
  color: var(--accent);
}

h1 {
  font-size: 1.6rem;
  line-height: 1.2;
  margin: 0;
}

h2 {
  font-size: 1.15rem;
  margin: 0 0 8px;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 120px;
}

main.narrow {
  max-width: 640px;
}

p {
  margin: 0 0 12px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.875rem;
}

.pos {
  color: var(--pos);
}

.neg {
  color: var(--neg);
}

.error {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  padding: 10px 12px;
  border-radius: 8px;
}

.success {
  color: var(--pos);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

/* ---- controls ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--accent);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

.btn.primary:hover {
  background: var(--accent-hover);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
}

.btn.ghost:hover {
  background: var(--surface-2);
}

.btn.danger {
  color: var(--danger);
}

.btn.danger-solid {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  font-weight: 600;
}

.btn.small {
  min-height: 36px;
  padding: 4px 12px;
  font-size: 0.9rem;
}

.btn.big {
  min-height: 52px;
  padding: 12px 24px;
  font-size: 1.05rem;
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

input,
select {
  font: inherit;
  font-size: 16px; /* no zoom on focus in iOS */
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
  width: 100%;
}

input:disabled,
select:disabled {
  opacity: 1;
  background: var(--surface-2);
  color: var(--text);
}

input:focus,
select:focus,
button:focus-visible,
.btn:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9rem;
  color: var(--muted);
}

.row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.row .grow {
  flex: 1;
}

.row .qty {
  width: 110px;
}

.row-end {
  display: flex;
  justify-content: flex-end;
}

.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.link {
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

/* ---- top bar ---- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 12px 6px 16px;
  padding-top: max(6px, env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}

.logo {
  display: block;
  width: 30px;
  height: 30px;
  flex: none;
}

.menu {
  position: relative;
}

.menu summary {
  list-style: none;
  max-width: 50vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu summary::-webkit-details-marker {
  display: none;
}

.menu summary::after {
  content: '▾';
  font-size: 0.8em;
  color: var(--muted);
}

.menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 180px;
  display: flex;
  flex-direction: column;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.menu-list a,
.menu-list button {
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.menu-list a:hover,
.menu-list button:hover {
  background: var(--surface-2);
}

/* ---- auth pages (from song-writer) ---- */

.auth {
  max-width: 420px;
  padding-top: 48px;
}

.auth h1 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 24px;
}

.auth h1 .logo {
  width: 44px;
  height: 44px;
}

.auth form,
.auth .auth-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth h2 {
  margin: 0;
}

.auth .btn {
  width: 100%;
}

.auth .captcha:empty {
  display: none;
}

.auth p {
  margin: 0;
}

.auth .forgot {
  align-self: flex-end;
  font-size: 0.9rem;
  margin-top: -6px;
}

.dev-mail {
  margin-bottom: 16px;
}

.dev-mail pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9rem;
}

.account {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.account form,
.account section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.account h2,
.account p {
  margin: 0;
}

.account .btn {
  align-self: flex-start;
}

.account-email {
  font-weight: 600;
}

/* ---- shared pieces ---- */

.back {
  margin: 0 0 8px;
}

.back a {
  text-decoration: none;
  font-weight: 500;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 24px 0 8px;
}

.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  border-radius: 50%;
  background: var(--pc, var(--muted));
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.02em;
  user-select: none;
}

@media (prefers-color-scheme: dark) {
  .avatar {
    color: #121212;
  }
}

/* A profile picture covers the initials (which stay as the fallback underneath). */
.avatar {
  position: relative;
  overflow: hidden;
}

.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* No coloured rim or initials peeking out around a picture. */
.avatar:has(img) {
  background: var(--surface-2);
  color: transparent;
}

.avatar.xl {
  width: 88px;
  height: 88px;
  font-size: 1.6rem;
}

.avatar.md {
  width: 40px;
  height: 40px;
  font-size: 0.85rem;
}

.avatar.sm {
  width: 26px;
  height: 26px;
  font-size: 0.65rem;
}

.avatar.invited {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px dashed var(--border);
}

.avatars {
  display: inline-flex;
  align-items: center;
}

.avatars .avatar + .avatar {
  margin-left: -3px;
}

.avatars .avatar {
  box-shadow: 0 0 0 2px var(--surface);
}

.avatars .more {
  margin-left: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.empty {
  text-align: center;
  padding: 40px 16px;
}

.empty-icon {
  font-size: 2.6rem;
  margin-bottom: 8px;
}

.empty .btn {
  margin-top: 8px;
}

/* ---- dialogs (bottom sheets on phones) ---- */

dialog.sheet {
  width: min(480px, 100%);
  max-width: 100%;
  max-height: 90vh;
  margin: auto auto 0;
  padding: 20px 16px calc(16px + env(safe-area-inset-bottom));
  border: 0;
  border-radius: 18px 18px 0 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 -4px 30px rgb(0 0 0 / 20%);
  /* A long sheet scrolls by itself; reaching its end doesn't scroll the page behind. */
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* On touch screens the page behind an open sheet doesn't move at all. (Not with a mouse: hiding
   the page's scrollbar would shift the layout sideways.) */
@media (pointer: coarse) {
  html:has(dialog.sheet[open]),
  html:has(dialog.sheet[open]) body {
    overflow: hidden;
  }
}

dialog.sheet::backdrop {
  background: rgb(0 0 0 / 40%);
}

dialog.sheet[open] {
  animation: sheet-in 0.18s ease-out;
}

@keyframes sheet-in {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
}

@media (min-width: 600px) {
  dialog.sheet {
    margin: auto;
    border-radius: 18px;
    padding-bottom: 20px;
  }
}

dialog.sheet form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

dialog.sheet h2,
dialog.sheet p {
  margin: 0;
}

.sheet-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  margin-top: 4px;
}

.sheet-actions .spacer {
  flex: 1;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow);
  animation: sheet-in 0.18s ease-out;
}

.toast-action {
  border: 0;
  background: none;
  color: var(--accent-soft);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 6px;
}

/* ---- groups page ---- */

.total-line {
  margin: -6px 0 16px;
  color: var(--muted);
}

.group-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.group-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
}

.group-card:hover {
  border-color: var(--accent);
}

.group-card-main {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.group-name {
  font-size: 1.1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-card-balance {
  text-align: right;
  font-weight: 600;
  font-size: 0.95rem;
}

/* ---- group page ---- */

.group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.balance-banner {
  margin: 12px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-weight: 600;
}

.balance-banner.pos {
  background: var(--pos-soft);
  color: var(--pos);
}

.balance-banner.neg {
  background: var(--neg-soft);
  color: var(--neg);
}

.balance-banner.even {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
}

.tabs {
  position: sticky;
  top: 57px;
  z-index: 5;
  display: flex;
  gap: 4px;
  margin: 16px -16px 8px;
  padding: 0 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.tabs button {
  flex: 1;
  min-height: 48px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.tabs button[aria-selected='true'] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.date-head {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin: 18px 4px 6px;
}

.expense-list {
  display: flex;
  flex-direction: column;
}

.expense-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-bottom: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
}

.expense-row:hover {
  border-color: var(--accent);
}

.expense-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 1.2rem;
}

.expense-main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.expense-main strong {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.expense-mine {
  text-align: right;
  font-weight: 600;
  white-space: nowrap;
}

.expense-mine small {
  display: block;
  font-size: 0.72rem;
  font-weight: 500;
}

.fab {
  position: fixed;
  right: 16px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 0 22px 0 18px;
  border-radius: 28px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 6px 20px rgb(0 0 0 / 25%);
}

.fab span {
  font-size: 1.6rem;
  line-height: 1;
}

.debt-list,
.payment-list,
.member-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.debt {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.debt.neg {
  border-left: 4px solid var(--neg);
}

.debt.pos {
  border-left: 4px solid var(--pos);
}

.debt-text {
  flex: 1;
  min-width: 0;
}

.debt .btn {
  flex: none;
  white-space: normal;
  max-width: 45%;
  text-align: center;
}

.debt-amount {
  display: block;
  font-size: 1.2rem;
  font-weight: 700;
}

.debt.neg .debt-amount {
  color: var(--neg);
}

.debt.pos .debt-amount {
  color: var(--pos);
}

.debt:not(.neg, .pos) .debt-amount {
  font-size: 1rem;
}

.all-even {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--pos-soft);
  color: var(--pos);
  font-weight: 600;
  margin: 0;
}

.payment {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.payment > span:first-child {
  flex: 1;
}

.pay-people {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 8px 0;
}

.pay-people > span:not(.arrow) {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-weight: 600;
}

.pay-people .arrow {
  font-size: 1.6rem;
  color: var(--muted);
}

#pay-amount {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
}

.add-member {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.add-member p {
  margin: 0;
}

.member {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.member-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.member-main .small {
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  flex-basis: 100%;
  margin-top: -4px;
}

.settings {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}

.settings h2,
.settings p {
  margin: 0;
}

.danger-zone {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 24px;
}

/* ---- expense page: start ---- */

.start {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.start h1 {
  margin-bottom: 8px;
}

.choice {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 18px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
}

.choice:hover {
  border-color: var(--accent);
}

.choice > span:last-child {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.choice .muted {
  font-size: 0.9rem;
}

.choice-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: 14px;
  background: var(--surface-2);
  font-size: 1.6rem;
}

.primary-choice {
  padding: 24px 16px;
  border: 2px solid var(--accent);
  background: var(--accent-soft);
}

.primary-choice .choice-icon {
  background: var(--accent);
}

.primary-choice strong {
  font-size: 1.15rem;
}

.choice-link {
  display: block;
  text-align: center;
  margin: -4px 0 12px;
  cursor: pointer;
}

/* ---- expense page: scanning ---- */

.scanning {
  text-align: center;
  padding-top: 8px;
}

.scanning p {
  margin: 0 0 4px;
}

.scan-photo {
  position: relative;
  width: min(280px, 80%);
  margin: 0 auto 20px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.scan-photo img {
  display: block;
  width: 100%;
  max-height: 50vh;
  object-fit: cover;
}

.scan-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  box-shadow: 0 0 12px 4px color-mix(in srgb, var(--accent) 60%, transparent);
  animation: scan 1.8s ease-in-out infinite alternate;
}

@keyframes scan {
  from {
    top: 0;
  }
  to {
    top: calc(100% - 3px);
  }
}

/* ---- expense page: editor ---- */

.editor {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.editor-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.title-input {
  font-size: 1.3rem;
  font-weight: 600;
  border-color: transparent;
  background: transparent;
  padding-left: 4px;
}

.title-input:hover,
.title-input:focus {
  border-color: var(--border);
  background: var(--surface);
}

.amount-field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.amount-field:focus-within {
  outline: 2px solid var(--accent);
}

.amount-input {
  border: 0;
  background: transparent;
  font-size: 2rem;
  font-weight: 700;
  padding: 10px 0;
  outline: none !important;
}

.amount-input:disabled {
  background: transparent;
}

.currency {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--muted);
}

.meta-row {
  display: flex;
  gap: 10px;
}

.meta-row label {
  flex: 1;
  min-width: 0;
}

.segmented {
  display: flex;
  padding: 4px;
  gap: 4px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--border) 60%, transparent);
}

.segmented button {
  flex: 1;
  min-height: 40px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.segmented button[aria-checked='true'] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.note {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  margin: 0;
}

.warnings {
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--warn-soft);
  color: var(--text);
  border-left: 4px solid var(--warn);
}

.warnings ul {
  margin: 4px 0 0;
  padding-left: 20px;
}

.simple .section-title {
  margin: 4px 0;
}

.people-pick {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.person-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 8px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.person-toggle > span:nth-child(2) {
  flex: 1;
}

.person-toggle .check {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-weight: 800;
}

/* One highlight colour for everyone who is selected; the avatars keep their own colours. */
.person-toggle[aria-checked='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.person-toggle[aria-checked='true'] .check {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}

.person-toggle[aria-checked='false'] .avatar {
  opacity: 0.5;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  min-height: 44px;
  padding: 4px 14px 4px 6px;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.chip .avatar {
  background: var(--pc, var(--muted));
}

.chip[aria-checked='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.chip.everyone .avatar {
  background: var(--muted);
}

.hint {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item {
  scroll-margin-top: 70px; /* stays clear of the sticky top bar */
  scroll-margin-bottom: 100px; /* and of the summary bar */
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.item.unassigned {
  border-style: dashed;
}

.item-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}

.item-main:active {
  background: var(--surface-2);
}

.item-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
}

.qty {
  font-weight: 700;
  color: var(--accent);
}

.item-name {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.item-price {
  font-weight: 600;
  white-space: nowrap;
}

.item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 24px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--pc-soft, var(--surface-2));
  color: var(--pc, var(--text));
  font-size: 0.82rem;
  font-weight: 700;
}

.tag.open {
  background: var(--warn-soft);
  color: var(--warn);
  font-weight: 600;
}

.add-item {
  align-self: flex-start;
  margin-top: 4px;
  color: var(--accent);
}

.extra-line {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.9rem;
}

.extra-line.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.photo-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.photo-link img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.editor-actions {
  display: flex;
  justify-content: center;
}

/* The bar at the bottom: live totals per person and Save. */
.summary-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgb(0 0 0 / 8%);
}

.summary {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9rem;
}

.sum-chips {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.sum-chip {
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--pc-soft);
  color: var(--pc);
  font-weight: 700;
  font-size: 0.82rem;
  white-space: nowrap;
}

.sum-open {
  color: var(--warn);
  font-size: 0.82rem;
}

.summary-bar .btn {
  min-width: 96px;
  min-height: 48px;
}

.split-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 50vh;
  overflow-y: auto;
}

.split-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.split-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
}

.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.stepper button {
  width: 44px;
  height: 44px;
  border: 0;
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.3rem;
  cursor: pointer;
}

.stepper output {
  min-width: 36px;
  text-align: center;
  font-weight: 700;
  font-size: 1.1rem;
}

@media (min-width: 700px) {
  .summary-bar {
    left: 50%;
    right: auto;
    width: 640px;
    transform: translateX(-50%);
    border: 1px solid var(--border);
    border-bottom: 0;
    border-radius: 16px 16px 0 0;
  }
}

.toast {
  width: max-content;
}

/* Short messages stay on one line; long ones wrap, and Undo stays visible. */
.toast > span {
  min-width: 0;
  white-space: normal;
}

.toast-action {
  flex: none;
}

/* ---- admin: users ---- */

.admin-users #filter {
  margin-bottom: 12px;
}

.admin-users {
  max-width: 1200px;
}

.table-wrap {
  overflow-x: auto;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table.users {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

table.users th,
table.users td {
  padding: 8px 12px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

table.users tbody tr:last-child td {
  border-bottom: 0;
}

table.users tbody tr:hover {
  background: var(--surface-2);
}

table.users th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

table.users th button {
  border: 0;
  background: none;
  padding: 4px 0;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

table.users th[aria-sort='ascending'] button,
table.users th[aria-sort='descending'] button {
  color: var(--text);
}

table.users th button::after {
  content: attr(data-arrow);
  margin-left: 4px;
}

table.users .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

table.users .date {
  white-space: nowrap;
  color: var(--muted);
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
}

.user-names {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.table-actions {
  display: flex;
  justify-content: flex-end;
  gap: 2px;
  white-space: nowrap;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

table.users .badges {
  flex-wrap: nowrap;
  align-items: center;
  white-space: nowrap;
}

/* ---- actions dropdown (members) ---- */

.actions-menu {
  margin-left: auto;
}

.actions-menu summary {
  gap: 4px;
}

.actions-menu .menu-list {
  z-index: 15;
  min-width: 200px;
}

.menu-list button.danger {
  color: var(--danger);
}

.member.pending {
  border-style: dashed;
}

/* ---- invitations (groups page) ---- */

.invitations {
  margin-bottom: 20px;
}

.invitations .section-title {
  margin-top: 0;
}

.invitation-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.invitation {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 16px;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: var(--radius);
}

.invitation-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 1.1rem;
}

.invitation-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 180px;
}

.invitation-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* ---- "By items": calculated total and tip ---- */

.amount-field.computed {
  background: var(--surface-2);
  border-style: dashed;
}

.amount-field.computed:focus-within {
  outline: none;
}

.amount-field.computed .amount-input {
  cursor: default;
}

.tip-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.tip-row label {
  font-weight: 600;
  color: var(--text);
}

.tip-row p {
  margin: 0;
}

.tip-field {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 200px;
}

.tip-field input.invalid {
  border-color: var(--danger);
}

.items-total {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---- item panel: who had it ---- */

.item-who {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.item-who-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 36px;
  font-size: 0.9rem;
  color: var(--muted);
}


.item-who-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 40vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.who-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}


#item-line-total {
  margin: -6px 0 0;
}

#item-line-total:empty {
  display: none;
}

.each {
  font-weight: 400;
  white-space: nowrap;
}

/* ---- IBAN ---- */

.iban-value {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  word-break: break-all;
  user-select: all;
}

.iban-sheet .iban-value {
  padding: 12px;
  border-radius: 10px;
  background: var(--surface-2);
  text-align: center;
}

.pay-iban {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
}

.pay-iban.empty {
  background: none;
  padding: 0;
}

.pay-iban-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.member .iban-btn {
  margin-left: auto;
}

.member .iban-btn + .actions-menu {
  margin-left: 0;
}

.pay-iban .iban-value {
  font-size: 0.92rem;
  word-break: normal;
}

.empty-logo {
  display: block;
  margin: 0 auto 12px;
  filter: drop-shadow(0 6px 16px rgb(63 95 191 / 30%));
}

/* ---- saying an expense ---- */

.voice-icon {
  color: var(--accent);
}

.dictate {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dictate h1,
.dictate p {
  margin: 0;
}

.mic-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mic-side {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.mic-status {
  font-weight: 600;
}

.voice-lang {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.voice-lang select {
  flex: 1;
  width: auto;
  min-width: 0;
  min-height: 36px;
  padding: 4px 8px;
}

.mic-btn {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 40%, transparent);
}

.mic-btn svg {
  width: 34px;
  height: 34px;
}

.mic-btn[aria-pressed='true'] {
  background: var(--danger);
  color: #fff;
  animation: listening 1.4s ease-in-out infinite;
}

@keyframes listening {
  0%,
  100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 45%, transparent);
  }
  50% {
    box-shadow: 0 0 0 14px color-mix(in srgb, var(--danger) 0%, transparent);
  }
}

.voice-input {
  width: 100%;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  resize: vertical;
}

.voice-input:focus {
  outline: 2px solid var(--accent);
}

.item-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.item-buttons .btn svg {
  flex: none;
}

#say-dialog .mic-btn {
  width: 64px;
  height: 64px;
}

/* ---- export ---- */

.export-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 32px;
  text-align: center;
}

.export-row p {
  margin: 0;
}

/* ---- profile picture ---- */

.avatar-edit {
  display: flex;
  align-items: center;
  gap: 20px;
}

.avatar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#display-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
