/* Deep navy with bordered cards. Cyan is for actions, green for money coming back, red for money owed. */
:root {
  --bg: #080b12;
  --card: #0f141d;
  --raised: #1a2230;
  --line: rgb(150 175 210 / 0.14);
  --ink: #f4f7fb;
  --dim: #8d99ab;
  --act: #56ccf2;
  --on-act: #03212e;
  --go: #4ade80;
  --on-go: #06281a;
  --owe: #ff6b5e;
  --font: "Plus Jakarta Sans", system-ui, sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: linear(0, 0.009, 0.035 2.1%, 0.141 4.4%, 0.723 12.9%, 0.938 16.7%, 1.017, 1.077,
      1.121 24%, 1.149 26.3%, 1.159, 1.163 29.2%, 1.154 31.8%, 1.129 35.2%, 1.051 43.9%,
      1.017 48.5%, 0.991 53.6%, 0.977 58.8%, 0.974 63.6%, 0.975 68%, 0.997 82.8%, 1.003 91.9%, 1);
  --tabs: calc(78px + env(safe-area-inset-bottom));
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  font: 400 16px/1.4 var(--font);
  color: var(--ink);
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 0 calc(var(--tabs) + 96px);
  overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
:focus-visible { outline: 2px solid var(--act); outline-offset: 3px; border-radius: 8px; }
ul { list-style: none; padding: 0; }
h2 { font: 700 1.1875rem/1.25 var(--font); letter-spacing: -0.01em; }
small, .dim { color: var(--dim); font-size: 0.875rem; }
.num, .amt { font-variant-numeric: tabular-nums; }
.pos-t { color: var(--go); }
.neg-t { color: var(--owe); }

.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px 14px; border-bottom: 1px solid var(--line); }
.top > div { flex: 1; min-width: 0; }
.brand { font-size: 0.8125rem; font-weight: 600; color: var(--dim); }
.top h1 { font: 700 1.375rem/1.2 var(--font); letter-spacing: -0.02em; }
.me { border-radius: 50%; transition: scale 0.25s var(--spring); }
.me:active { scale: 0.92; }
#view { padding: 0 20px; view-transition-name: page; }
#view > section { margin-top: 34px; }
#view > section > h2 { margin-bottom: 10px; }

/* Family avatars are circles; categories are squares. */
.av, .cat {
  --c: var(--dim);
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--c);
  color: #101114;
  font: 800 0.8125rem/1 var(--font);
}
.cat { border-radius: 11px; background: color-mix(in srgb, var(--c) 20%, var(--card)); color: var(--c); }
.av.sm { width: 22px; height: 22px; font-size: 0.625rem; }
.av.lg { width: 48px; height: 48px; font-size: 1.0625rem; }
.av.pulse { animation: hop 0.9s var(--spring), ring 1.4s 2; }
@keyframes hop { 30% { scale: 1.35; } }
@keyframes ring { from { box-shadow: 0 0 0 0 var(--c); } to { box-shadow: 0 0 0 18px transparent; } }

.btn {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 54px;
  padding: 0 22px;
  border-radius: 27px;
  background: var(--act);
  color: var(--on-act);
  font-weight: 700;
  font-size: 1.0625rem;
  transition: scale 0.25s var(--spring);
}
.btn:active, .chip:active, .fab:active { scale: 0.95; }
.btn.quiet { background: var(--raised); color: var(--ink); border: 1px solid var(--line); }
a.btn { text-decoration: none; }
.btn.danger { background: none; color: var(--owe); min-height: 44px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 99px;
  background: var(--raised);
  border: 1px solid var(--line);
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  transition: scale 0.25s var(--spring), background 0.2s, color 0.2s;
}
.chip.on { background: var(--act); color: var(--on-act); }
.chip.ghost { background: none; border: 0; padding: 0; color: var(--dim); }
.chip .av { margin-left: -8px; }
.chip.ghost .av { margin-left: 0; }

/* Every list is one bordered card with hairlines between rows. */
.rows, .fams, .day-line, .card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 4px 16px; }
.card { padding: 16px; }
.rows > li + li, .fams > li + li, .day-line > li + li { border-top: 1px solid var(--line); }
.rows > li { display: flex; align-items: center; gap: 14px; padding: 11px 0; min-height: 64px; }
/* Status pills, like a badge on a card. */
.pill { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.02em; background: color-mix(in srgb, currentColor 16%, transparent); }
.rows .grow { flex: 1; min-width: 0; display: grid; }
.rows b { font-weight: 600; font-size: 1.0625rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows .amt { font-weight: 700; font-size: 1.0625rem; }
.empty { padding: 30px 20px; text-align: center; color: var(--dim); background: var(--card); border: 1px solid var(--line); border-radius: 22px; }
.x { width: 32px; height: 32px; border-radius: 50%; color: var(--dim); font-size: 1.25rem; line-height: 1; text-align: center; }

/* Floating glass tab bar. */
.tabs {
  --i: 0;
  position: fixed;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  translate: -50% 0;
  width: min(100% - 28px, 452px);
  height: 66px;
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border-radius: 33px;
  background: rgb(26 33 46 / 0.72);
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  border: 1px solid var(--line);
  box-shadow: 0 14px 40px rgb(0 0 0 / 0.45);
  z-index: 20;
  view-transition-name: tabs;
}
.tabs button { display: grid; justify-items: center; align-content: center; gap: 3px; font-size: 0.75rem; font-weight: 600; color: var(--ink); z-index: 1; transition: color 0.3s; }
.tabs svg, .fab svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs svg { transition: scale 0.5s var(--spring); }
.tabs button[aria-current] { color: var(--act); }
.tabs button[aria-current] svg { scale: 1.12; stroke-width: 2.2; }
.tabs-pill {
  position: absolute;
  top: 6px;
  left: 6px;
  width: calc((100% - 12px) / 5);
  height: calc(100% - 12px);
  border-radius: 27px;
  background: rgb(86 204 242 / 0.13);
  box-shadow: inset 0 0 18px rgb(86 204 242 / 0.18);
  translate: calc(var(--i) * 100%) 0;
  transition: translate 0.55s var(--spring);
}

.fab {
  position: fixed;
  right: max(20px, calc(50% - 220px));
  bottom: calc(var(--tabs) + 14px);
  display: flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  padding: 0 22px 0 18px;
  border-radius: 28px;
  background: var(--act);
  color: var(--on-act);
  font-weight: 700;
  font-size: 1.0625rem;
  box-shadow: 0 12px 30px rgb(0 0 0 / 0.45), 0 0 28px rgb(86 204 242 / 0.25);
  z-index: 21;
  transition: scale 0.25s var(--spring);
  view-transition-name: fab;
}
.fab[hidden] { display: none; }
.fab svg { stroke-width: 2.6; }
.fab.buy { padding-left: 22px; }
.fab.buy svg { display: none; }

#sheet { position: fixed; inset: 0; z-index: 30; }
.sheet-back { position: absolute; inset: 0; background: rgb(0 0 0 / 0.55); backdrop-filter: blur(6px); opacity: 0; transition: opacity 0.3s; }
.sheet-card {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(100%, 480px);
  max-height: 92dvh;
  overflow-y: auto;
  padding: 10px 20px calc(24px + env(safe-area-inset-bottom));
  background: var(--card);
  border-top: 1px solid var(--line);
  border-radius: 30px 30px 0 0;
  translate: -50% 104%;
  transition: translate 0.55s var(--spring);
}
#sheet.open .sheet-back { opacity: 1; }
#sheet.open .sheet-card { translate: -50% 0; }
.grab { display: block; width: 40px; height: 4px; margin: 0 auto 16px; border-radius: 2px; background: var(--raised); }
.sheet-body h2 { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 4px; }
.sheet-body form, .sheet-body .stack-y { display: grid; gap: 16px; margin-top: 16px; }

input[type="text"], input[type="date"], input[type="time"], input[type="number"] {
  width: 100%;
  min-height: 54px;
  padding: 0 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--bg);
}
input:focus { outline: 2px solid var(--act); outline-offset: 0; }
label.field, fieldset { display: grid; gap: 8px; border: 0; padding: 0; min-width: 0; }
label.field > span, legend { font-size: 0.875rem; color: var(--dim); padding: 0; }
legend { margin-bottom: 8px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.amount { display: flex; align-items: baseline; justify-content: center; gap: 6px; font-weight: 800; font-size: 3.25rem; line-height: 1; letter-spacing: -0.04em; padding: 10px 0; }
.amount span { color: var(--dim); font-size: 1.75rem; }
.amount input { all: unset; width: 5.2ch; font-variant-numeric: tabular-nums; caret-color: var(--act); }
.amount input::placeholder { color: color-mix(in srgb, var(--dim) 45%, transparent); }
.picks { display: flex; flex-wrap: wrap; gap: 8px; }
.picks input { position: absolute; opacity: 0; pointer-events: none; }
.picks label:has(:checked) .chip { background: var(--act); color: var(--on-act); border-color: transparent; }
.picks label:has(:focus-visible) .chip { outline: 2px solid var(--act); outline-offset: 2px; }
form:has([name="all"]:checked) .subset, form:not(:has(#kind-plan:checked)) .only-plan, form:has(#kind-fam:checked) .not-fam { display: none; }
.history { border-top: 1px solid var(--line); padding-top: 14px; display: grid; gap: 6px; }

#toasts { position: fixed; top: calc(10px + env(safe-area-inset-top)); left: 50%; translate: -50% 0; width: min(92%, 440px); display: grid; gap: 8px; z-index: 40; pointer-events: none; }
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px 10px 10px;
  border-radius: 28px;
  background: var(--ink);
  color: #101114;
  font-weight: 600;
  font-size: 0.9375rem;
  box-shadow: 0 12px 36px rgb(0 0 0 / 0.5);
  animation: toast-in 0.6s var(--spring) both, toast-out 0.35s 3.4s var(--ease) forwards;
}
.toast.bad { background: var(--owe); padding-left: 18px; }
.toast .av { animation: ring 1.2s 0.2s 2; }
@keyframes toast-in { from { translate: 0 -140%; scale: 0.8; } }
@keyframes toast-out { to { translate: 0 -140%; opacity: 0; } }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 45; }

.landing main { min-height: 80dvh; display: grid; place-content: center; justify-items: center; gap: 14px; padding: 32px; text-align: center; }
.landing img { border-radius: 22px; }
.landing h1 { font-size: 2.5rem; font-weight: 800; letter-spacing: -0.03em; }
.landing p { color: var(--dim); max-width: 30ch; }

/* Tab changes slide; everything with its own name glides to its new place. */
::view-transition-group(*) { animation-duration: 0.45s; animation-timing-function: var(--ease); }
html[data-dir="fwd"]::view-transition-old(page) { animation: 0.28s var(--ease) both out-left; }
html[data-dir="fwd"]::view-transition-new(page) { animation: 0.45s var(--ease) both in-right; }
html[data-dir="back"]::view-transition-old(page) { animation: 0.28s var(--ease) both out-right; }
html[data-dir="back"]::view-transition-new(page) { animation: 0.45s var(--ease) both in-left; }
@keyframes out-left { to { translate: -18% 0; opacity: 0; } }
@keyframes in-right { from { translate: 18% 0; opacity: 0; } }
@keyframes out-right { to { translate: 18% 0; opacity: 0; } }
@keyframes in-left { from { translate: -18% 0; opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
