/* Look: loud and friendly. Cobalt page, big round shapes, a yellow answer card. */
:root {
  --bg: #2233d6;
  --surface: #ffffff;
  --ink: #0f1440;
  --muted: #5d648f;
  --accent: #0f1440;
  --accent-ink: #ffffff;
  --plus: #0b8f58;
  --minus: #e0352b;
  --focus: #ffd21f;
  --font: "Avenir Next", Avenir, "Nunito Sans", "Segoe UI", system-ui, sans-serif;
  --h1: 800 2.1rem/1.05 var(--font);
  --h2: 800 1.2rem/1.2 var(--font);
  --radius: 28px;
  --card-border: 0;
  --card-shadow: none;
  --input-bg: #eef0ff;
  --input-border: 2px solid transparent;
  --input-radius: 16px;
  --divider: 2px solid #eef0ff;
  --chip-on: #0f1440;
  --chip-on-line: #0f1440;
  --chip-on-ink: #ffffff;
  color-scheme: light;
}
h1 { color: #fff; letter-spacing: -.03em; }
#home .lead, #missing .lead, .event-head .muted, .back { color: #cdd3ff; }
#recent h2 { color: #fff; margin-top: 24px; }
#recent .list { background: #fff; border-radius: var(--radius); padding: 18px; }
.event-head button { background: #fff; border-radius: 999px; }
button { font-weight: 800; }
button.primary { border-radius: 999px; }
.avatar { width: 32px; height: 32px; background: hsl(var(--hue, 220) 78% 40%); }
.results .avatar { box-shadow: 0 0 0 2px #fff; }
.checks input { accent-color: #ffd21f; }
#event.has-expenses .results { background: #ffd21f; }
#event.has-expenses .results li { border-color: rgba(15, 20, 64, .15); }
.results .num { font-size: 1.15rem; font-weight: 800; }
.results .pay .arrow { color: var(--ink); }

/* Layout and structure. Colors, type and shape come from the tokens above. */
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--font);
  -webkit-text-size-adjust: 100%;
}
main { max-width: 540px; margin: 0 auto; padding: 20px 16px 60px; }
h1 { font: var(--h1); margin: 6px 0 4px; overflow-wrap: anywhere; }
h2 { font: var(--h2); margin: 0 0 12px; }
.lead { color: var(--muted); margin: 0 0 20px; }
.muted { color: var(--muted); margin: 0; }
.back { display: inline-block; color: var(--muted); text-decoration: none; font-size: .9rem; padding: 4px 0; }

#event { display: flex; flex-direction: column; }
#event > .back { order: -4; align-self: flex-start; }
#event > .event-head { order: -3; }
/* Once there is something to settle, the answer moves to the top. */
#event.has-expenses > .results { order: -2; }

.card {
  background: var(--surface);
  border: var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  padding: 18px;
  margin: 8px 0;
}
.event-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; }
.event-head > div:first-child { flex: 1 1 200px; min-width: 0; }
.head-actions { display: flex; gap: 8px; flex: none; }
.event-head button { flex: none; }

#people-dialog {
  border: 0; border-radius: var(--radius); padding: 20px;
  width: min(480px, calc(100vw - 32px));
  background: var(--surface); color: var(--ink);
}
#people-dialog::backdrop { background: rgba(15, 20, 64, .6); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.dialog-head h2 { margin: 0; }
.dialog-head button { border-radius: 999px; padding: 8px 18px; }
#people-hint { margin: 0 0 14px; }

.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; }
.row .amount { flex: 0 0 7.5em; text-align: right; }

input, select, button {
  font: inherit;
  color: inherit;
  border: var(--input-border);
  border-radius: var(--input-radius);
  padding: 10px 12px;
  background: var(--input-bg);
  min-height: 46px;
}
input::placeholder { color: var(--muted); opacity: 1; }
select { width: 100%; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
button { cursor: pointer; font-weight: 600; white-space: nowrap; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
button.wide { width: 100%; margin-top: 16px; }
button:disabled { opacity: .55; cursor: default; }

.field { display: block; margin: 14px 0 0; padding: 0; border: 0; font-size: .9rem; color: var(--muted); }
.field select { margin-top: 6px; color: var(--ink); }
.field legend { padding: 0; margin-bottom: 6px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.checks label {
  display: inline-flex; align-items: center; gap: 6px;
  border: var(--input-border); border-radius: 999px;
  padding: 8px 14px; color: var(--ink); cursor: pointer; min-height: 40px;
  background: var(--input-bg);
}
.checks label:has(input:checked) { background: var(--chip-on); border-color: var(--chip-on-line); color: var(--chip-on-ink); }
.checks input { min-height: 0; margin: 0; accent-color: var(--accent); }

.avatar {
  flex: none; display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: hsl(var(--hue, 220) 62% 40%); color: #fff;
  font-size: .85rem; font-weight: 700; line-height: 1;
}

.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0 0 12px; }
.chips:empty { display: none; }
.chips li {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--input-bg); border: var(--input-border); border-radius: 999px;
  padding: 3px 4px 3px 4px; overflow-wrap: anywhere;
}
.icon {
  border: 0; background: none; color: var(--muted);
  min-height: 36px; min-width: 36px; padding: 0; border-radius: 999px; font-size: 1.1rem; line-height: 1;
}
.icon:hover { color: var(--minus); }

.list { list-style: none; padding: 0; margin: 0; }
.list li {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0; border-top: var(--divider);
}
.list li:first-child { border-top: 0; padding-top: 0; }
.list li:last-child { padding-bottom: 0; }
.list .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.list .sub { display: block; color: var(--muted); font-size: .85rem; }
.list .num { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.list .empty { color: var(--muted); }
.list a { color: inherit; text-decoration: none; font-weight: 600; }
.plus { color: var(--plus); }
.minus { color: var(--minus); }

.pay { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; }
.pay .who { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.pay .arrow { color: var(--muted); }
.results .num { font-size: 1.1rem; }

#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: #16181d; color: #fff;
  padding: 10px 16px; border-radius: 999px; font-size: .9rem;
  max-width: calc(100vw - 32px); text-align: center; z-index: 3;
}
[hidden] { display: none !important; }

.note { color: #cdd3ff; font-size: .85rem; margin: 16px 2px 0; }
#event > .note { order: 10; }

.refresh-note { font-size: .85rem; margin-top: 2px; }
