/* Party Split: "2 am living room". Grape night, party-light person colours,
   Shrikhand for money and titles, Gabarito for everything else. */
:root {
  --night: #1a1033;
  --night-2: #251847;
  --night-3: #2f2059;
  --line: #3a2a63;
  --ink: #f6f0ff;
  --muted: #a79bc9;
  --butter: #ffd75e;
  --mint: #6ef2b0;
  --rose: #ff6b8b;
  --shadow: #0d0820;
  --display: "Shrikhand", "Gabarito", system-ui, sans-serif;
  --text: "Gabarito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --tabs-h: 60px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--night); color: var(--ink);
  font: 16px/1.45 var(--text);
  min-height: 100vh;
  padding-bottom: calc(var(--tabs-h) + 96px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--butter); outline-offset: 2px; border-radius: 6px; }

/* ---------- chrome ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; padding-top: calc(14px + env(safe-area-inset-top));
  background: var(--night);
}
.brand { font-family: var(--display); font-size: 21px; text-decoration: none; color: var(--butter); transform: rotate(-3deg); display: inline-block; }
.brand-dot { display: none; }
.me-name { color: var(--muted); font-size: 14px; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--night); border-top: 1px solid var(--line);
}
.tabs a { position: relative; display: flex; align-items: center; justify-content: center; text-decoration: none; color: var(--muted); font-size: 14px; font-weight: 600; }
.tabs a i { display: none; }
.tabs a.on { color: var(--ink); }
.tabs a.on::after { content: ""; position: absolute; bottom: 10px; width: 6px; height: 6px; border-radius: 50%; background: var(--butter); }

.wrap { max-width: 560px; margin: 0 auto; padding: 8px 20px 20px; }

/* ---------- type ---------- */
h1, h2, h3 { margin: 0; font-weight: 400; }
h1 { font-family: var(--display); font-size: 34px; line-height: 1.1; letter-spacing: .005em; }
h2 { font-family: var(--text); font-size: 15px; font-weight: 700; color: var(--muted); margin: 32px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.back { font-size: 15px; color: var(--muted); text-decoration: none; display: inline-block; margin-bottom: 12px; }
.back:hover { color: var(--ink); }
.quip { color: var(--muted); margin-top: 6px; }

/* ---------- buttons: text first, one solid button per screen ---------- */
.btn {
  appearance: none; border: 0; background: none; padding: 8px 0; cursor: pointer;
  font-weight: 700; font-size: 16px; color: var(--butter); text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
.btn:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.btn.primary, .btn.lime {
  background: var(--butter); color: var(--night); padding: 15px 22px; border-radius: 14px;
  box-shadow: 3px 3px 0 var(--shadow);
}
.btn.primary:hover, .btn.lime:hover { text-decoration: none; filter: brightness(1.06); }
.btn.primary:active, .btn.lime:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--shadow); }
.btn.wa { color: var(--mint); }
.btn.ghost { color: var(--muted); }
.btn.danger { color: var(--rose); }
.btn.sm { font-size: 15px; padding: 6px 0; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .35; cursor: not-allowed; box-shadow: none; transform: none; }
.btnrow { display: flex; gap: 22px; flex-wrap: wrap; align-items: center; }
.linkbtn { background: none; border: 0; padding: 4px 0; color: var(--muted); cursor: pointer; font-size: 14px; font-weight: 600; }
.linkbtn:hover { color: var(--ink); }

/* ---------- inputs ---------- */
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.input {
  width: 100%; background: var(--night-2); border: 2px solid transparent; border-radius: 14px;
  padding: 12px 14px; outline: none; font-size: 17px;
}
.input::placeholder { color: #6f62a0; }
.input:focus { border-color: var(--butter); }
textarea.input { resize: vertical; min-height: 60px; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 52%, calc(100% - 14px) 52%; background-size: 6px 6px; background-repeat: no-repeat; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.money { position: relative; display: block; }
.money > span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.money input { padding-left: 30px; }
.money.big input { font-family: var(--display); font-size: 32px; padding: 10px 14px 10px 40px; color: var(--butter); }
.money.big > span { font-family: var(--display); font-size: 26px; left: 16px; }
.money.sm { display: inline-block; }
.money.sm input { width: 88px; padding: 6px 8px 6px 24px; font-size: 16px; border-radius: 10px; background: var(--night-3); }
.money.sm > span { left: 10px; font-size: 15px; }

/* ---------- surfaces: lists are flat, things you fill in are raised ---------- */
.card { background: none; border: 0; }
.card.sec, .card.payform, .card.summary, .card.settle-head, .card.notes, .card.check, .card.invite {
  background: var(--night-2); border-radius: 20px;
}
.empty { padding: 28px 0; color: var(--muted); }
.empty b { display: block; font-family: var(--display); font-weight: 400; font-size: 24px; color: var(--ink); margin-bottom: 4px; }

/* people: everyone has their own party colour */
.avatar {
  --pc: var(--butter);
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--pc); color: var(--night); font-family: var(--display); font-size: 17px; line-height: 1;
}
.avatar.guest { background: transparent; color: var(--pc); border: 2px dashed var(--pc); }
.tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 0 7px; border-radius: 999px; border: 1.5px dashed var(--muted); color: var(--muted); margin-left: 6px; vertical-align: 2px; }
.amt { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amt small { display: block; font-weight: 500; font-size: 13px; color: var(--muted); }
.pos { color: var(--mint); }
.neg { color: var(--rose); }
.pill { font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.pill.open { color: var(--rose); }
.pill.done { color: var(--mint); }

.lrow { display: flex; gap: 14px; padding: 14px 0; text-decoration: none; align-items: center; }
.lrow + .lrow { border-top: 1px solid var(--line); }
a.lrow:hover .t { text-decoration: underline; text-underline-offset: 3px; }
.lmain { flex: 1; min-width: 0; }
.lmain .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lmain .s { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { display: none; }
.date-badge { width: 42px; flex: none; text-align: center; line-height: 1; }
.date-badge b { display: block; font-family: var(--display); font-weight: 400; font-size: 24px; }
.date-badge span { font-size: 13px; color: var(--muted); }

/* ---------- the opening sentence ---------- */
.hero { display: block; text-decoration: none; margin: 4px 0 8px; }
.hero .line { font-size: 22px; font-weight: 600; color: var(--muted); }
.hero .money-big { font-family: var(--display); font-size: 64px; line-height: 1.05; display: block; margin: 2px 0 4px; letter-spacing: .01em; }
.hero .detail { color: var(--muted); font-size: 15px; }
.hero .go { margin-top: 10px; }

/* ---------- balances ---------- */
.balwrap + .balwrap { border-top: 1px solid var(--line); }
.bal { width: 100%; display: grid; grid-template-columns: 1fr 1fr; align-items: center; padding: 10px 0; background: none; border: 0; cursor: pointer; color: inherit; text-align: inherit; }
.bal .side { display: flex; align-items: center; gap: 8px; min-height: 30px; }
.bal .side.l { justify-content: flex-end; padding-right: 10px; }
.bal .side.r { padding-left: 10px; border-left: 2px solid var(--line); }
.bar { height: 22px; border-radius: 6px; flex: none; }
.bar.pos { background: var(--mint); }
.bar.neg { background: var(--rose); }
.bamt { font-size: 14px; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bal .nm { font-weight: 600; font-size: 15px; }
.bdown { padding: 2px 0 14px; }
.bl { display: flex; justify-content: space-between; font-size: 15px; padding: 3px 0; color: var(--muted); }
.bl.tot { color: var(--ink); font-weight: 800; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; }
.check { padding: 16px 18px; margin-top: 22px; }
.check b { font-weight: 800; }
.check.ok b { color: var(--mint); }
.check.bad b { color: var(--rose); }

/* ---------- expense detail ---------- */
.dhead .big { font-family: var(--display); font-size: 56px; line-height: 1.1; margin-top: 10px; color: var(--butter); }
.notes { white-space: pre-wrap; padding: 14px 16px; color: var(--muted); margin-top: 14px; }
.secv { padding: 10px 0 14px; }
.secv + .secv { border-top: 1px solid var(--line); }
.secv .ph { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 6px; }
.secv .pm { display: flex; justify-content: space-between; font-size: 15px; padding: 2px 0; color: var(--muted); }
.secv .pm b { color: var(--ink); font-weight: 500; }
.mod { font-size: 12px; font-weight: 800; color: var(--butter); margin-left: 6px; }

/* ---------- builder ---------- */
.sec { padding: 16px 16px 12px; margin-bottom: 14px; }
.sec-n { font-size: 15px; font-weight: 700; color: var(--muted); margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.sec-head { display: grid; grid-template-columns: 1fr 130px; gap: 10px; margin-bottom: 12px; }
.sec .input { background: var(--night-3); }
.sec-head .money input { font-weight: 700; }
.glbl { display: flex; justify-content: space-between; align-items: center; font-size: 14px; font-weight: 700; color: var(--muted); margin: 14px 0 2px; }
.prow2 { display: flex; align-items: center; gap: 12px; padding: 6px 0; min-height: 50px; cursor: pointer; user-select: none; }
.cb {
  --pc: var(--butter);
  width: 26px; height: 26px; flex: none; border-radius: 50%; border: 2px solid var(--line);
  display: grid; place-items: center; font-size: 14px; font-weight: 900; color: transparent; transition: transform .12s;
}
.prow2.on .cb { background: var(--pc); border-color: var(--pc); color: var(--night); }
.prow2.guest .cb { border-style: dashed; }
.prow2.on.guest .cb { border-style: solid; }
.prow2:active .cb { transform: scale(.88); }
.prow2 .n { flex: 1; font-weight: 600; min-width: 0; }
.prow2:not(.on) .n { color: var(--muted); font-weight: 500; }
.prow2 .n small { color: var(--muted); font-weight: 500; }
.prow2 .share { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 66px; text-align: right; }
.mini { border: 0; background: none; padding: 6px 4px; font-size: 14px; font-weight: 800; color: #6f62a0; cursor: pointer; min-width: 30px; }
.mini:hover { color: var(--ink); }
.mini.on { color: var(--butter); }
.sugg { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 4px 0; }
.chip { border: 0; background: none; padding: 6px 0; cursor: pointer; font-size: 15px; font-weight: 600; color: var(--muted); }
.chip:hover { color: var(--butter); }
.addguest { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.addguest .plus { width: 26px; height: 26px; flex: none; border-radius: 50%; border: 2px dashed var(--muted); color: var(--muted); display: grid; place-items: center; font-weight: 800; }
.addguest .input { padding: 9px 12px; font-size: 16px; border-radius: 12px; }
.each { font-size: 14px; color: var(--muted); margin-top: 10px; }
.perr { color: var(--rose); font-size: 14px; margin-top: 6px; font-weight: 700; }
.perr:empty, .each:empty { display: none; }
.alloc { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 4px 0 12px; font-size: 15px; font-weight: 700; }
.alloc.ok { color: var(--mint); }
.alloc.bad { color: var(--rose); }
.addsec { width: 100%; border: 2px dashed var(--line); background: transparent; border-radius: 20px; padding: 16px; cursor: pointer; color: var(--muted); font-weight: 700; text-align: left; }
.addsec:hover { border-color: var(--butter); color: var(--butter); }
.addsec small { display: block; font-weight: 500; font-size: 14px; margin-top: 2px; }
.summary { margin-top: 16px; padding: 16px 18px; }
.summary .sr { display: flex; justify-content: space-between; font-size: 15px; padding: 3px 0; }
.summary .sr span:first-child { color: var(--muted); }
.savebar { position: sticky; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding: 14px 0; background: linear-gradient(transparent, var(--night) 40%); margin-top: 8px; }

/* ---------- settle ---------- */
.settle-head { text-align: center; padding: 22px 16px; }
.settle-head .avatar { margin: 0 auto; width: 56px; height: 56px; font-size: 24px; }
.settle-head .big { font-family: var(--display); font-size: 52px; line-height: 1.1; margin-top: 6px; }
.it { display: flex; align-items: center; gap: 10px; padding: 12px 0; }
.it + .it { border-top: 1px solid var(--line); }
.it a { flex: 1; min-width: 0; text-decoration: none; }
.it .d { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.it .when { font-size: 13px; color: var(--muted); }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--night-3); border-radius: 14px; padding: 4px; margin-bottom: 14px; }
.seg button { border: 0; background: transparent; padding: 10px; border-radius: 10px; cursor: pointer; font-weight: 700; color: var(--muted); font-size: 15px; }
.seg button.on { background: var(--ink); color: var(--night); }
.payform { padding: 16px; }
.payform .input { background: var(--night-3); }
details.more { margin-top: 18px; }
details.more summary { cursor: pointer; color: var(--muted); font-size: 15px; font-weight: 600; padding: 8px 0; }

/* ---------- join ---------- */
.join { max-width: 420px; margin: 7vh auto 0; }
.join h1 { font-size: 52px; line-height: 1; margin-bottom: 12px; color: var(--butter); transform: rotate(-2deg); transform-origin: left; }
.join .lede { color: var(--muted); margin-bottom: 26px; font-size: 17px; }
.whoami { display: flex; flex-direction: column; margin-bottom: 18px; }
.whoami button { display: flex; align-items: center; gap: 14px; padding: 12px 0; text-align: left; cursor: pointer; font-weight: 700; font-size: 18px; background: none; border: 0; border-top: 1px solid var(--line); }
.whoami button:first-child { border-top: 0; }
.whoami button:hover { color: var(--butter); }
.err { color: var(--rose); font-size: 15px; font-weight: 600; min-height: 20px; margin: 4px 0 10px; }
.codebox { font-family: var(--display); font-size: 40px; text-align: center; padding: 8px; color: var(--butter); margin: 6px 0; user-select: all; letter-spacing: .04em; }
.code-in { text-transform: uppercase; letter-spacing: .25em; text-align: center; font-size: 24px; font-weight: 800; }
.invite { padding: 18px; margin-top: 14px; }

/* ---------- activity ---------- */
.act { display: flex; gap: 12px; padding: 11px 0; font-size: 15px; }
.act + .act { border-top: 1px solid var(--line); }
.act .when { font-size: 13px; color: var(--muted); white-space: nowrap; }
.act a { text-decoration: none; }

/* ---------- the + sticker and toasts ---------- */
.fab {
  position: fixed; right: 20px; bottom: calc(var(--tabs-h) + 18px + env(safe-area-inset-bottom)); z-index: 19;
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  background: var(--butter); color: var(--night); text-decoration: none;
  box-shadow: 4px 4px 0 var(--shadow); transform: rotate(-8deg); font-size: 0;
}
.fab span { font-family: var(--display); font-size: 38px; line-height: 1; margin-top: 4px; }
.fab:active { transform: rotate(-8deg) translate(3px, 3px); box-shadow: 1px 1px 0 var(--shadow); }
.toast {
  position: fixed; left: 50%; top: calc(64px + env(safe-area-inset-top)); transform: translateX(-50%) rotate(-1.5deg);
  background: var(--butter); color: var(--night); padding: 11px 18px; border-radius: 14px; font-weight: 800;
  font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; max-width: 88vw; text-align: center;
  box-shadow: 3px 3px 0 var(--shadow);
}
.toast.show { opacity: 1; }
.toast.bad { background: var(--rose); }

@media (min-width: 640px) {
  .fab { right: calc(50% - 260px); }
  .tabs { left: 50%; right: auto; width: 560px; transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
.install { margin: 18px 0 4px; }
