:root {
  --bg: #F4F4F1;
  --card: #FFFFFF;
  --ink: #15171B;
  --muted: #565B64;
  --line: #E0E1DD;
  --chip: #EEF0EA;
  --accent: #C1F73F;
  --accent-ink: #15171B;
  --ok: #1D6B38;
  --ok-bg: #E6F4EA;
  --warn: #8A4B00;
  --warn-bg: #FFF4E0;
  --bad: #A61B1B;
  --bad-bg: #FDECEC;
  --shadow: 0 1px 2px rgba(21, 23, 27, .06), 0 4px 16px rgba(21, 23, 27, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1114;
    --card: #1A1D22;
    --ink: #F4F4F1;
    --muted: #A9AEB6;
    --line: #2C3038;
    --chip: #23272E;
    --ok: #86DB9C;
    --ok-bg: #16281C;
    --warn: #F2B866;
    --warn-bg: #2B2214;
    --bad: #FF9A9A;
    --bad-bg: #2E1717;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.wrap { max-width: 560px; margin: 0 auto; padding: 20px 16px 40px; }

h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 28px; letter-spacing: -.01em; }
h2 { font-size: 19px; }
h3 { font-size: 15px; margin: 18px 0 8px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
b { font-weight: 650; }

.hero { padding: 8px 2px 18px; }
.eyebrow { font-size: 14px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.hero h1 { margin: 4px 0 6px; }
.sub { color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 16px;
  margin: 0 0 14px;
  box-shadow: var(--shadow);
}
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pill { font-size: 13px; font-weight: 650; background: var(--accent); color: var(--accent-ink); padding: 4px 10px; border-radius: 999px; white-space: nowrap; }

.msg { border-radius: 12px; padding: 12px 14px; margin: 0 0 14px; font-weight: 550; }
.msg.ok { background: var(--ok-bg); color: var(--ok); }
.msg.bad { background: var(--bad-bg); color: var(--bad); }
.msg.info { background: var(--warn-bg); color: var(--warn); }

.names { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 420px) { .names { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.name-btn {
  width: 100%; text-align: left; border: 1px solid var(--line); background: var(--chip); color: var(--ink);
  border-radius: 12px; padding: 10px 12px; font: inherit; cursor: pointer; min-height: 56px;
}
.name-btn:hover { border-color: var(--muted); }
.name-btn:focus-visible, .btn:focus-visible, .link:focus-visible, .step button:focus-visible, .toggle:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.name-btn .nm { display: block; font-weight: 650; }
.name-btn .st { display: block; font-size: 13px; color: var(--muted); }
.name-btn.done { background: var(--ok-bg); border-color: transparent; }
.name-btn.done .st { color: var(--ok); }
.name-btn.mine { border-color: var(--ink); border-width: 2px; }

.link { background: none; border: 0; color: var(--muted); text-decoration: underline; font: inherit; font-size: 14px; cursor: pointer; padding: 4px; }
.p-intro { margin: 10px 0 4px; }
.p-intro p + p { margin-top: 8px; }

.drinks { list-style: none; margin: 0; padding: 0; }
.drink { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.drink:first-child { border-top: 0; }
.drink .info { min-width: 0; }
.drink .dn { font-weight: 600; display: block; }
.drink .dm { font-size: 13px; color: var(--muted); display: block; }
.drink.gone .dn { color: var(--muted); }

.step { display: flex; align-items: center; gap: 4px; flex: none; }
.step button {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--chip); color: var(--ink);
  font-size: 22px; line-height: 1; cursor: pointer;
}
.step button:disabled { opacity: .35; cursor: default; }
.step output { min-width: 26px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }

.toggle {
  flex: none; border: 1px solid var(--line); background: var(--chip); color: var(--ink); border-radius: 10px;
  padding: 9px 12px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; min-height: 40px;
}
.toggle[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

.total-box { margin-top: 16px; }
.lines { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.lines td { padding: 4px 0; }
.lines td:last-child { text-align: right; white-space: nowrap; }
.lines tr.grand td { border-top: 1px solid var(--line); padding-top: 10px; font-weight: 750; font-size: 20px; }
.note { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); font-size: 14px; line-height: 1.45; }
.owe-big { font-size: 30px; font-weight: 800; letter-spacing: -.01em; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }

.btn {
  border: 1px solid var(--line); background: var(--chip); color: var(--ink); border-radius: 12px;
  padding: 10px 16px; font: inherit; font-weight: 650; cursor: pointer; min-height: 44px;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-main { background: var(--ink); color: var(--bg); border-color: transparent; width: 100%; margin-top: 16px; min-height: 52px; font-size: 17px; }
.btn-quiet { background: transparent; }

.explain h2 + ol, .explain h2 + ul { margin-top: 8px; }
.explain h2:not(:first-child) { margin-top: 18px; }
.steps, .rules { margin: 0; padding-left: 22px; }
.steps li, .rules li { margin: 6px 0; }

.owes { width: 100%; border-collapse: collapse; margin-top: 10px; font-variant-numeric: tabular-nums; }
.owes th, .owes td { padding: 8px 0; border-top: 1px solid var(--line); text-align: left; font-weight: 500; }
.owes th { font-weight: 600; }
.owes td:last-child { text-align: right; white-space: nowrap; font-weight: 650; }
.owes td.state { font-size: 13px; color: var(--muted); padding: 8px 8px; }
.owes tr.unclaimed th, .owes tr.unclaimed td { color: var(--warn); }
.owes .who { display: block; font-size: 13px; font-weight: 400; color: var(--muted); line-height: 1.4; margin-top: 2px; }
.owes tr.unclaimed .who { color: var(--warn); }
.owes tfoot th, .owes tfoot td { font-weight: 800; border-top: 2px solid var(--ink); }

details summary { cursor: pointer; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary h2 { display: inline; }
details summary::after { content: "Show"; float: right; font-size: 14px; color: var(--muted); text-decoration: underline; }
details[open] summary::after { content: "Hide"; }
.receipt { list-style: none; margin: 12px 0 0; padding: 0; }
.receipt li { padding: 10px 0; border-top: 1px solid var(--line); }
.receipt .rl { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; }
.receipt .rl span:last-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
.receipt .rw { font-size: 14px; color: var(--muted); }
.receipt .rw.left { color: var(--warn); }
.sums { width: 100%; border-collapse: collapse; margin-top: 8px; font-variant-numeric: tabular-nums; }
.sums th, .sums td { padding: 5px 0; border-top: 1px solid var(--line); text-align: left; font-weight: 500; }
.sums td { text-align: right; }
.sums tr:last-child th, .sums tr:last-child td { font-weight: 800; }

.foot { text-align: center; margin-top: 18px; }

.admin { border: 2px dashed var(--ink); }
.admin-row { margin-top: 14px; }
.assign { display: grid; gap: 10px; }
.assign label { display: grid; gap: 4px; font-size: 14px; font-weight: 600; }
.assign select, .assign input { font: inherit; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); width: 100%; }
.admin-people { list-style: none; margin: 0; padding: 0; }
.admin-people li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.admin-people .claims { font-size: 13px; color: var(--muted); flex-basis: 100%; }
.admin-people .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-people .btn { min-height: 36px; padding: 6px 10px; font-size: 14px; }
.log { margin: 8px 0 0; padding-left: 20px; font-size: 13px; color: var(--muted); }

.sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); display: flex; align-items: flex-end; justify-content: center; padding: 16px; z-index: 10; }
.sheet[hidden] { display: none; }
.sheet-card { background: var(--card); color: var(--ink); border-radius: 18px; padding: 20px 18px; width: 100%; max-width: 520px; max-height: 85vh; overflow: auto; }
.sheet-card h2 { margin-bottom: 10px; }
.sheet-card ul { margin: 8px 0; padding-left: 20px; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.sheet-actions .btn-main { margin-top: 0; min-height: 48px; font-size: 16px; }
@media (min-width: 600px) { .sheet { align-items: center; } }
