:root {
  --bg: #fdf3f7;
  --card: #ffffff;
  --pink: #f5b9cf;
  --pink-soft: #fde4ee;
  --pink-ink: #b8467a;
  --green: #2f5d46;
  --green-dark: #1e3b2d;
  --green-soft: #e3efe7;
  --purple: #cdb6ea;
  --purple-soft: #f1e9fb;
  --purple-ink: #6e4f9c;
  --ink: #1e3b2d;
  --muted: #687a70;
  --line: #f1dde6;
  --radius: 22px;
  --shadow: 0 6px 18px rgba(184, 70, 122, 0.08);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.4 ui-rounded, "SF Pro Rounded", -apple-system, system-ui, "Segoe UI", sans-serif;
  padding: env(safe-area-inset-top) 16px calc(32px + env(safe-area-inset-bottom));
  max-width: 560px;
  margin-inline: auto;
}
h1 { font-size: 30px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 20px; margin: 0; }
p { margin: 6px 0; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: 15px; }
.strong { font-weight: 700; }
.good { color: var(--green); }
.soft { color: var(--purple-ink); }
.right { text-align: right; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.center { text-align: center; padding: 40px 12px; }
.center.small-pad { padding: 16px; }

.top { display: flex; align-items: center; gap: 12px; padding: 20px 0 12px; flex-wrap: wrap; }
.back {
  font-weight: 600; color: var(--pink-ink); min-height: 44px; display: inline-flex; align-items: center;
  padding-right: 8px;
}
.back::before { content: "‹"; font-size: 28px; margin-right: 4px; line-height: 1; }
.title-btn { text-align: left; min-height: 44px; flex: 1 1 100%; }
.title-btn h1::after { content: " ›"; color: var(--pink); font-weight: 400; }

.pig { width: 96px; height: 96px; object-fit: contain; flex: none; }
.pig.big { width: 160px; height: 160px; }
.pig.tiny { width: 48px; height: 48px; }

.card {
  display: block; background: var(--card); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); margin: 12px 0;
}
.trip-card h2 { font-size: 24px; }
.trip-card:active { transform: scale(0.98); }

.pill { border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: 15px; white-space: nowrap; }
.pill.ok { background: var(--green-soft); color: var(--green); }
.pill.over { background: var(--purple-soft); color: var(--purple-ink); }

.bar { height: 10px; background: var(--pink-soft); border-radius: 999px; overflow: hidden; margin: 10px 0 6px; }
.bar.big { height: 16px; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--pink), var(--purple)); border-radius: inherit; }

.hero { display: flex; align-items: center; gap: 14px; margin: 4px 0 8px; }
.hero-num { font-size: 46px; font-weight: 800; line-height: 1.05; margin: 0; letter-spacing: -0.02em; }
.hero-num.soft { color: var(--purple-ink); font-size: 38px; }

.actions { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.actions.two { flex-direction: row; }
.actions.two > * { flex: 1; }
.btn {
  min-height: 56px; border-radius: 18px; font-weight: 700; font-size: 18px; display: flex;
  align-items: center; justify-content: center; padding: 0 16px; background: var(--card);
  box-shadow: var(--shadow); text-align: center;
}
.btn.primary { background: var(--pink); color: var(--green-dark); }
.btn.green { background: var(--green); color: #fff; }
.btn.ghost { background: transparent; box-shadow: none; border: 2px dashed var(--pink); color: var(--pink-ink); width: 100%; margin: 8px 0; }
.btn.danger { border-color: var(--purple); color: var(--purple-ink); border-style: solid; margin: 0; }
.btn:active { transform: scale(0.97); }
.btn.wide { flex: 1 1 100%; }

.tabs { display: flex; background: var(--pink-soft); border-radius: 999px; padding: 4px; margin: 8px 0 12px; }
.tabs a { flex: 1; text-align: center; padding: 12px 4px; border-radius: 999px; font-weight: 600; color: var(--muted); min-height: 48px; }
.tabs a[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

.list { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list.plain:empty { display: none; }
.list > li + li { border-top: 1px solid var(--line); }
.cat { display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 8px; }
.check {
  width: 44px; height: 44px; flex: none; border-radius: 50%; border: 2.5px solid var(--pink);
  display: grid; place-items: center; font-size: 22px; font-weight: 800; color: #fff; margin: 4px;
}
.cat.paid .check { background: var(--green); border-color: var(--green); }
.cat-body { flex: 1; text-align: left; display: flex; flex-direction: column; padding: 8px 0; min-height: 56px; justify-content: center; }
.cat-name { font-weight: 700; font-size: 18px; }
.cat-sub { font-size: 15px; color: var(--muted); }
.cat-left { font-weight: 800; font-size: 20px; text-align: right; }
.cat-left .soft { font-size: 16px; }
.done { font-size: 15px; color: var(--green); background: var(--green-soft); padding: 4px 10px; border-radius: 999px; }
.line { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; min-height: 56px; text-align: left; font-size: 18px; }
.totals .line { padding: 6px 0; min-height: 0; }
.totals .line.strong { font-size: 22px; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; }
.section { font-size: 18px; margin: 22px 4px 8px; }
.link { color: var(--pink-ink); font-weight: 700; min-height: 44px; padding: 0 4px; text-decoration: underline; text-decoration-color: var(--pink); text-underline-offset: 4px; }

.compare-wrap { overflow-x: auto; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.compare { border-collapse: collapse; width: 100%; font-size: 17px; }
.compare th, .compare td { padding: 12px; text-align: right; white-space: nowrap; }
.compare th:first-child, .compare td:first-child { text-align: left; color: var(--muted); position: sticky; left: 0; background: var(--card); }
.compare th { font-size: 18px; background: var(--pink-soft); }
.compare tr + tr td { border-top: 1px solid var(--line); }
.compare tr.strong td { font-weight: 800; color: var(--ink); }

.tip { background: var(--purple-soft); color: var(--ink); border-radius: 18px; padding: 14px 16px; text-align: left; font-size: 16px; }
.banner { width: 100%; background: var(--purple-soft); color: var(--purple-ink); border-radius: 14px; padding: 12px; margin-top: 12px; font-weight: 600; }

/* Bottom sheet */
dialog#sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px; max-height: 94vh;
  border-radius: 28px 28px 0 0; background: var(--bg); color: var(--ink);
}
dialog#sheet[open] { animation: up 0.22s ease-out; }
dialog::backdrop { background: rgba(30, 59, 45, 0.28); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-form { padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.x { color: var(--pink-ink); font-weight: 700; min-height: 44px; padding: 0 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.chip span, .chip.date input {
  display: inline-flex; align-items: center; min-height: 46px; padding: 0 16px; border-radius: 999px;
  background: var(--card); border: 2px solid var(--line); font-weight: 600;
}
.chip.date input { font-size: 16px; -webkit-appearance: none; appearance: none; }
.chip input:checked + span { background: var(--pink); border-color: var(--pink); color: var(--green-dark); }
.chip input:focus-visible + span { outline: 3px solid var(--purple); }
.amount {
  display: block; background: var(--card); border-radius: 18px; padding: 10px 16px; border: 2.5px solid var(--line);
  min-height: 84px; cursor: pointer;
}
.amount.active { border-color: var(--pink); }
.amount.error { border-color: var(--purple); }
.amount .lbl, .field .lbl { display: block; font-size: 14px; color: var(--muted); font-weight: 600; }
.amount .expr { font-size: 34px; font-weight: 800; min-height: 1.2em; display: inline-block; word-break: break-all; }
.amount .expr:empty::before { content: "$0"; color: #c9b9c1; }
.amount.active .expr::after { content: ""; display: inline-block; width: 2px; height: 30px; background: var(--pink-ink); margin-left: 2px; vertical-align: -4px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.amount .eq { font-size: 20px; font-weight: 700; color: var(--green); margin-left: 8px; }
.pair { display: flex; gap: 10px; }
.pair .amount { flex: 1; min-width: 0; }
.pair .amount .expr { font-size: 28px; }
.field input {
  width: 100%; font-size: 20px; padding: 14px 16px; border-radius: 16px; border: 2.5px solid var(--line); background: var(--card);
}
.field input:focus { outline: none; border-color: var(--pink); }
.keypad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.keypad button { min-height: 56px; border-radius: 16px; background: var(--card); font-size: 24px; font-weight: 700; box-shadow: var(--shadow); }
.keypad button:active { background: var(--pink-soft); }
.keypad [data-key="+"], .keypad [data-key="−"] { background: var(--purple-soft); color: var(--purple-ink); }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--green-dark); color: #fff; padding: 12px 20px; border-radius: 999px; font-weight: 600;
  opacity: 0; transition: opacity 0.2s, transform 0.2s; pointer-events: none; z-index: 10;
  display: flex; align-items: center; gap: 10px; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.party { background: var(--card); color: var(--ink); box-shadow: 0 10px 30px rgba(184, 70, 122, 0.25); border: 2px solid var(--pink); }
#toast.party .pig { animation: hop 0.6s ease-out 2; }
@keyframes hop { 40% { transform: translateY(-8px) rotate(-6deg); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
