:root {
  --bg: #f3efe7;
  --surface: #fbf9f4;
  --sunk: #e9e4d8;
  --ink: #1d1c19;
  --ink-2: #4f4b43;
  --muted: #8d877b;
  --line: #e1dbce;
  --pos: #2e6b4c;
  --neg: #b84a2b;
  --accent: #d0643b;
  --pa: #36574a;
  --pb: #b5603b;
  --serif: "Instrument Serif", ui-serif, Georgia, serif;
  --sans: "Geist", ui-sans-serif, system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease: cubic-bezier(0.2, 0.85, 0.25, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131210;
    --surface: #1c1b18;
    --sunk: #0d0c0b;
    --ink: #f1ece2;
    --ink-2: #c3bcae;
    --muted: #7f796e;
    --line: #2a2824;
    --pos: #7cc49a;
    --neg: #ec8f6d;
    --accent: #e07a50;
    --pa: #4f7a68;
    --pb: #c4714b;
    color-scheme: dark;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-color: color-mix(in srgb, var(--muted) 50%, transparent) transparent;
  scrollbar-width: thin;
}
@media (min-width: 960px) {
  html {
    scrollbar-gutter: stable;
  }
}
html:has(dialog[open]) {
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

[hidden] {
  display: none !important;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

/* ---------- primitives ---------- */

.btn {
  appearance: none;
  border: 0;
  height: 46px;
  padding: 0 20px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 500;
  transition:
    transform 0.12s,
    background 0.2s,
    color 0.2s,
    opacity 0.2s;
}
.btn:active {
  transform: scale(0.97);
}
.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}
.btn.primary {
  background: var(--ink);
  color: var(--bg);
}
.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn.danger {
  background: transparent;
  color: var(--neg);
}
.btn.danger.armed {
  background: var(--neg);
  color: #fff;
}
.btn.block {
  width: 100%;
}

.input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px var(--sans);
  outline: none;
  transition: border-color 0.15s;
}
.input:focus {
  border-color: var(--muted);
}
.input::placeholder {
  color: var(--muted);
}
.input[type="date"] {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 0 10px 0 12px;
  line-height: 46px;
}

.wordmark {
  margin: 0;
  font: 400 30px/1 var(--serif);
  letter-spacing: -0.01em;
}
.wordmark i {
  font-style: normal;
  color: var(--accent);
}

.avatar {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--pa);
  color: #fff;
  font: 400 16px/1 var(--serif);
}
.avatar[data-p="b"] {
  background: var(--pb);
}

.err {
  margin: 0;
  color: var(--neg);
  font-size: 14px;
  text-align: center;
}
.err:empty {
  display: none;
}

/* ---------- login ---------- */

.login {
  max-width: 420px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 24px 24px 18vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  animation: in 0.6s var(--ease) both;
}
.login .wordmark {
  font-size: 84px;
}
.tag {
  margin: 10px 0 34px;
  color: var(--muted);
  font-size: 15px;
}
.login-form {
  display: flex;
  gap: 8px;
}
.login-form .input {
  flex: 1;
  height: 50px;
  border-radius: 999px;
  padding: 0 20px;
  background: var(--surface);
}
.login-form .btn {
  height: 50px;
}
.login .err {
  margin-top: 14px;
  text-align: left;
  padding-left: 20px;
}
.shake {
  animation: shake 0.4s;
}

/* ---------- app ---------- */

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 18px) 20px calc(env(safe-area-inset-bottom) + 120px);
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pill {
  height: 36px;
  padding: 0 14px 0 5px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 500;
}

.hero {
  padding: 48px 0 34px;
}
.label {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
}
.label::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}
.label[data-tone="pos"]::before {
  background: var(--pos);
}
.label[data-tone="neg"]::before {
  background: var(--neg);
}
.balance {
  margin: 8px 0 24px;
  font: 400 clamp(68px, 21vw, 96px)/0.95 var(--serif);
  letter-spacing: -0.03em;
  white-space: nowrap;
}
.balance .cur {
  margin-right: 0.04em;
  color: var(--muted);
  font-size: 0.48em;
  vertical-align: 0.72em;
}
.balance small {
  color: var(--muted);
  font-size: 0.48em;
}

.day h3 {
  margin: 0;
  padding: 26px 0 8px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.tx {
  all: unset;
  box-sizing: border-box;
  position: relative;
  isolation: isolate;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.tx::before {
  content: "";
  position: absolute;
  inset: 3px -12px;
  z-index: -1;
  border-radius: 12px;
  background: var(--sunk);
  opacity: 0;
  transition: opacity 0.2s;
}
.tx:active::before {
  opacity: 0.7;
  transition: none;
}
.tx.active::before {
  opacity: 1;
  box-shadow: inset 3px 0 0 var(--accent);
}
.tx:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
  border-radius: 4px;
}
@media (hover: hover) {
  .tx:hover::before {
    opacity: 0.5;
  }
}

.desc,
.meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.desc {
  font-size: 16px;
  font-weight: 500;
}
.meta {
  color: var(--muted);
  font-size: 13px;
}
.amt,
.eff {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.amt {
  font-size: 15px;
  font-weight: 500;
}
.eff {
  color: var(--muted);
  font-size: 13px;
}
.eff.pos {
  color: var(--pos);
}
.eff.neg {
  color: var(--neg);
}
.tx.settle .desc {
  font: italic 400 18px/1.3 var(--serif);
}

.empty {
  margin: 30px 0;
  padding: 36px 20px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
}
.empty b {
  color: var(--ink-2);
  font-weight: 500;
}

.more {
  display: flex;
  margin: 24px auto 0;
}

.dock {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  padding: 30px 20px calc(env(safe-area-inset-bottom) + 14px);
  background: linear-gradient(to top, var(--bg) 50%, transparent);
  pointer-events: none;
}
.dock .btn {
  width: 100%;
  max-width: 480px;
  height: 56px;
  font-size: 16px;
  pointer-events: auto;
  box-shadow: 0 14px 30px -12px rgb(0 0 0 / 0.45);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 92px);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: calc(100vw - 40px);
  padding: 6px 6px 6px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition:
    opacity 0.25s,
    transform 0.25s var(--ease);
  pointer-events: none;
}
.toast:has(.toast-undo[hidden]) {
  padding-right: 16px;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}
.toast-undo {
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 18%, transparent);
  color: var(--bg);
  font-size: 13.5px;
  font-weight: 600;
}

/* ---------- sheets ---------- */

dialog.sheet {
  width: 100%;
  max-width: 520px;
  max-height: 92dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 26px 26px 0 0;
  background: var(--surface);
  color: var(--ink);
  overflow: hidden auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
/* iOS sheet curve; the enter animation runs once (class removed on animationend) so
   later class changes never replay it */
dialog.sheet.entering {
  animation: rise 0.46s cubic-bezier(0.32, 0.72, 0, 1);
}
dialog.sheet[open] {
  will-change: transform;
}
dialog.sheet::backdrop {
  background: rgb(18 16 13 / 0.4);
  animation: fade 0.3s ease-out;
}
@media (min-width: 640px) {
  dialog.sheet {
    margin: auto;
    border-radius: 26px;
  }
}

.sheet-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  padding: 10px 20px calc(env(safe-area-inset-bottom) + 20px);
}
.grab {
  justify-self: center;
  width: 38px;
  height: 4px;
  border-radius: 4px;
  background: var(--line);
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sheet-head h2 {
  margin: 0;
  font: 400 28px/1 var(--serif);
  letter-spacing: -0.01em;
}
.x {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--sunk);
  color: var(--ink-2);
}

.amount-field {
  display: flex;
  align-items: baseline;
  gap: 4px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  transition: border-color 0.15s;
}
.amount-field:focus-within {
  border-bottom-color: var(--accent);
}
.plus-btn {
  align-self: center;
  flex: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--ink-2);
  font: 400 22px/1 var(--sans);
}
@media (hover: hover) and (pointer: fine) {
  .plus-btn {
    display: none;
  }
}
.amount-note {
  margin: -10px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.amount-note:empty {
  display: none;
}
.amount-field span {
  color: var(--muted);
  font: 400 34px/1 var(--serif);
}
.amount-field input {
  all: unset;
  flex: 1;
  min-width: 0;
  font: 400 56px/1.1 var(--serif);
  letter-spacing: -0.02em;
  caret-color: var(--accent);
}
.amount-field input::placeholder {
  color: var(--muted);
  opacity: 0.4;
}

.chips {
  display: flex;
  gap: 8px;
  margin: 10px -20px 0;
  padding: 0 20px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar {
  display: none;
}
.chip {
  flex: none;
  height: 32px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font-size: 13.5px;
  transition:
    background 0.15s,
    color 0.15s;
}
.chip.on {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg);
}

.field {
  display: grid;
  gap: 8px;
}
.row2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.field-label {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.seg {
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--sunk);
}
.seg button {
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
  transition:
    background 0.15s,
    color 0.15s,
    box-shadow 0.15s;
}
.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow:
    0 1px 2px rgb(0 0 0 / 0.08),
    0 0 0 1px var(--line);
}

.mini-amount {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  transition: border-color 0.15s;
}
.mini-amount:focus-within {
  border-color: var(--muted);
}
.mini-amount span {
  color: var(--muted);
}
.mini-amount input {
  all: unset;
  flex: 1;
  font: 500 16px var(--mono);
}

.summary {
  min-height: 22px;
  margin: 0;
  color: var(--ink-2);
  font-size: 15px;
  text-align: center;
}
.summary b {
  color: var(--ink);
  font-family: var(--mono);
  font-weight: 500;
}

.actions {
  display: grid;
  gap: 6px;
}
.actions .primary {
  height: 52px;
}

[data-mode="settle"] .expense-only,
[data-mode="expense"] .settle-only {
  display: none !important;
}

/* quick add */
.quick {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg);
  transition: border-color 0.15s;
}
.quick:focus-within {
  border-color: var(--accent);
}
.quick-icon {
  flex: none;
  margin-top: 3px;
  color: var(--accent);
}
.quick textarea {
  all: unset;
  flex: 1;
  min-width: 0;
  min-height: 22px;
  max-height: 160px;
  overflow-y: auto;
  font: 400 16px/1.4 var(--sans);
  white-space: pre-wrap;
  field-sizing: content;
}
.quick textarea::placeholder {
  color: var(--muted);
}
.quick-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: -10px;
}
.quick-hints:empty {
  display: none;
}
.hint {
  padding: 3px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--ink-2);
  font-size: 12.5px;
}
.hint.warn {
  background: color-mix(in srgb, var(--neg) 14%, transparent);
}

/* itemised split */
.btn.small {
  height: 36px;
  padding: 0 14px;
  font-size: 13.5px;
}
.items-panel {
  display: grid;
  gap: 10px;
}
.items-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.items-tip {
  color: var(--muted);
  font-size: 12px;
}
.items-list {
  display: grid;
  gap: 6px;
}
.items-list:empty::before {
  content: "Add the items that aren't shared. Everything else in the total is split equally.";
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-size: 13.5px;
}
.item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 84px auto 28px;
  align-items: center;
  gap: 6px;
  padding: 4px 4px 4px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  animation: in 0.25s var(--ease);
}
.item input {
  all: unset;
  min-width: 0;
  height: 36px;
  font-size: 16px;
}
.item input::placeholder {
  color: var(--muted);
}
.item-amt {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px;
  border-left: 1px solid var(--line);
  color: var(--muted);
}
.item-amt input {
  width: 100%;
  color: var(--ink);
  font-family: var(--mono);
  text-align: right;
}
.owner {
  min-width: 64px;
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: var(--sunk);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
  transition:
    background 0.15s,
    color 0.15s;
}
.owner[data-owner="a"] {
  background: var(--pa);
  color: #fff;
}
.owner[data-owner="b"] {
  background: var(--pb);
  color: #fff;
}
.item-x {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}
.items-actions {
  display: flex;
  gap: 8px;
}
.paste {
  display: grid;
  gap: 8px;
}
.paste textarea {
  height: auto;
  min-height: 96px;
  padding: 10px 14px;
  line-height: 1.45;
  resize: vertical;
}
.paste .btn {
  justify-self: start;
}
.breakdown {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--sunk);
  font-size: 13.5px;
}
.breakdown:empty {
  display: none;
}
.breakdown .row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink-2);
}
.breakdown .row b {
  color: var(--ink);
  font-family: var(--mono);
  font-weight: 500;
}
.breakdown .note {
  color: var(--muted);
  font-size: 12.5px;
}

/* UPI */
.upi {
  display: grid;
  gap: 10px;
}
.upi-apps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 8px;
}
.upi-app {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}
.upi-app:active {
  transform: scale(0.97);
}
.upi-app.on {
  border-color: var(--ink);
  background: var(--surface);
}
.qr-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--bg);
  text-align: center;
  animation: in 0.3s var(--ease);
}
.qr {
  display: block;
  width: 196px;
  height: 196px;
  border-radius: 12px;
  background: #fff;
  image-rendering: pixelated;
}
.qr-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.qr-actions .btn {
  text-decoration: none;
}
.upi-to {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}
.upi-to code {
  color: var(--ink-2);
  font-family: var(--mono);
}
.upi-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* entry meta + history */
.meta-foot {
  display: grid;
  gap: 6px;
  justify-items: center;
  padding-top: 4px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.meta-foot p {
  margin: 0;
}
.history {
  width: 100%;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  text-align: left;
}
.history li {
  position: relative;
  padding: 0 0 12px 18px;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.45;
}
.history li::before {
  content: "";
  position: absolute;
  top: 6px;
  left: 3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line);
}
.history li::after {
  content: "";
  position: absolute;
  top: 16px;
  bottom: 0;
  left: 6px;
  width: 1px;
  background: var(--line);
}
.history li:last-child::after {
  display: none;
}
.history time {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.history .chg {
  font-family: var(--mono);
  font-size: 12px;
}

/* menu + summary */
.menu-more {
  display: grid;
  gap: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.upi-form {
  display: grid;
  gap: 10px;
}
.upi-form .btn {
  justify-self: start;
}
.upi-fields {
  display: grid;
  gap: 8px;
}
.upi-field {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
}
.upi-field .input {
  height: 44px;
  font-family: var(--mono);
  font-size: 15px;
}
.menu-links {
  display: grid;
}
.menu-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 2px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  color: var(--ink);
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
}
.menu-link span {
  color: var(--muted);
}
.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: -6px;
  font-weight: 500;
}
.month-nav .x {
  font-size: 20px;
}
.month-nav .x:disabled {
  opacity: 0.35;
}
.summary-body {
  display: grid;
  gap: 16px;
  min-height: 240px;
}
.stat-big {
  font: 400 52px/1 var(--serif);
  letter-spacing: -0.02em;
}
.stat-sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13.5px;
}
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat-card {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg);
  font-size: 13px;
  color: var(--muted);
}
.stat-card b {
  color: var(--ink);
  font: 500 18px var(--mono);
  letter-spacing: -0.02em;
}
.stat-card .who {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
}
.stat-card .avatar {
  width: 22px;
  height: 22px;
  font-size: 13px;
}
.bars {
  display: grid;
  gap: 10px;
}
.bar {
  display: grid;
  gap: 5px;
  font-size: 13.5px;
}
.bar-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.bar-top b {
  font-family: var(--mono);
  font-weight: 500;
}
.bar-track {
  height: 6px;
  border-radius: 6px;
  background: var(--sunk);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 6px;
  background: var(--accent);
}

/* since last settle */
.since {
  margin: -14px 0 22px;
  color: var(--muted);
  font-size: 13.5px;
}
.since:empty {
  display: none;
}
.tx.closed {
  opacity: 0.5;
}
.square {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.square::before,
.square::after {
  content: "";
  flex: 1;
  height: 1px;
  background: repeating-linear-gradient(to right, var(--muted) 0 4px, transparent 4px 8px);
  opacity: 0.6;
}

.sub {
  margin: -8px 0 0;
  color: var(--muted);
}
.who-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.who-btn {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 24px 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--bg);
  font-size: 16px;
  font-weight: 500;
  transition: border-color 0.15s;
}
.who-btn.on {
  border-color: var(--ink);
}
.who-btn .avatar {
  width: 52px;
  height: 52px;
  font-size: 28px;
}
.link {
  all: unset;
  justify-self: center;
  padding: 6px;
  color: var(--muted);
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.link:focus-visible,
.owner:focus-visible,
.item-x:focus-visible,
.plus-btn:focus-visible,
.menu-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}
.item:focus-within {
  border-color: var(--muted);
}

/* ---------- native feel ---------- */

/* iOS 26+ draws installed web apps under the status bar, and iOS 27 blurs that area unless a
   solid fixed element sits at the very top. This strip gives a clean, app-coloured status bar. */
.statusbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 30;
  height: env(safe-area-inset-top, 0px);
  background: var(--bg);
  pointer-events: none;
}

button,
a,
.tx,
.chip,
.pill,
.owner,
.upi-app,
.menu-link,
.who-btn {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
.top,
.hero,
.day h3,
.field-label,
.sheet-head,
.square,
.toast {
  -webkit-user-select: none;
  user-select: none;
}

.ptr {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 50%;
  z-index: 25;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 6px 18px -8px rgb(0 0 0 / 0.35);
  color: var(--muted);
  opacity: 0;
  transform: translate(-50%, calc(var(--pull, 0) * 28px - 12px)) scale(calc(0.6 + var(--pull, 0) * 0.4));
  pointer-events: none;
}
.ptr svg {
  transform: rotate(calc(var(--pull, 0) * 300deg));
  transition: transform 0.1s linear;
}
.ptr.ready {
  color: var(--accent);
}
.ptr.spinning {
  --pull: 1;
  opacity: 1 !important;
  color: var(--accent);
  transition:
    transform 0.25s var(--ease),
    opacity 0.2s;
}
.ptr.spinning svg {
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.offline {
  grid-column: 1 / -1;
  justify-self: start;
  width: fit-content;
  margin: 14px 0 -24px;
  padding: 5px 11px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--neg) 14%, transparent);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 500;
}

.install-hint {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 86px);
  z-index: 11;
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(480px, calc(100vw - 40px));
  padding: 10px 10px 10px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 14px 30px -18px rgb(0 0 0 / 0.4);
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.4;
  transform: translateX(-50%);
  animation: in 0.5s 1s var(--ease) both;
}
.install-hint span {
  flex: 1;
}
.install-hint svg {
  vertical-align: -2px;
  color: var(--accent);
}
.install-hint b {
  color: var(--ink);
  font-weight: 600;
}
.install-hint .x {
  flex: none;
  width: 30px;
  height: 30px;
}

/* swipe to delete */
.swipe {
  position: relative;
}
.swipe .tx {
  transform: translateX(var(--dx, 0px));
  transition: transform 0.28s var(--ease);
}
.swipe.dragging .tx {
  transition: none;
}
.swipe-del {
  position: absolute;
  top: 2px;
  right: -20px;
  bottom: 2px;
  display: none;
  align-items: center;
  justify-content: flex-end;
  width: calc(20px - var(--dx, 0px));
  padding-right: 34px;
  overflow: hidden;
  border-radius: 14px 0 0 14px;
  background: var(--neg);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.swipe.swiping .swipe-del {
  display: flex;
}
.swipe-del span {
  transition: transform 0.15s var(--ease);
}
.swipe.armed .swipe-del span {
  transform: scale(1.12);
}
.swipe.removing .tx {
  transition: transform 0.2s ease-in;
}
.swipe.collapse {
  overflow: hidden;
  transition: height 0.22s var(--ease);
}

.tx.fresh::before {
  animation: fresh 1.6s var(--ease);
}
@keyframes fresh {
  0%,
  35% {
    opacity: 1;
    background: color-mix(in srgb, var(--accent) 16%, transparent);
  }
}

/* sheets: drag to dismiss, animated close, stay above the keyboard */
dialog.sheet {
  transform: translateY(var(--drag, 0px));
}
dialog.sheet:not(.dragging) {
  transition: transform 0.36s cubic-bezier(0.32, 0.72, 0, 1);
}
dialog.sheet.closing {
  animation: sink 0.3s cubic-bezier(0.32, 0.72, 0, 1) forwards;
}
dialog.sheet.closing::backdrop {
  animation: fade-out 0.3s ease-in forwards;
}
@keyframes sink {
  to {
    transform: translateY(100%);
  }
}
@keyframes fade-out {
  to {
    opacity: 0;
  }
}
@media (min-width: 640px) {
  @keyframes sink {
    to {
      opacity: 0;
      transform: translateY(24px) scale(0.98);
    }
  }
}

/* ---------- desktop ---------- */

.composer {
  display: none;
}

@media (min-width: 960px) {
  .app {
    max-width: 1180px;
    display: grid;
    grid-template-columns: 420px minmax(0, 1fr);
    align-items: start;
    column-gap: clamp(56px, 7vw, 112px);
    padding: 32px 48px 24px;
  }
  .top {
    grid-column: 1 / -1;
  }

  .side {
    position: sticky;
    top: 0;
    max-height: 100dvh;
    padding: 28px 0 24px;
    overflow-y: auto;
    scrollbar-width: none;
  }
  .side::-webkit-scrollbar {
    display: none;
  }
  .hero {
    padding: 8px 0 28px;
  }
  .balance {
    font-size: 112px;
  }

  .composer {
    display: block;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--surface);
    box-shadow: 0 24px 48px -32px rgb(0 0 0 / 0.35);
    transition: border-color 0.2s;
  }
  .composer[data-editing] {
    border-color: var(--muted);
  }
  .composer .sheet-body {
    gap: 14px;
    padding: 22px 22px 18px;
  }
  .composer .grab {
    display: none;
  }
  .composer .sheet-head h2 {
    font-size: 24px;
  }
  .composer:not([data-editing]) .x {
    visibility: hidden;
  }
  .composer .amount-field input {
    font-size: 48px;
  }
  .composer .chips {
    flex-wrap: wrap;
    margin: 10px 0 0;
    padding: 0;
    overflow: visible;
  }
  .composer .summary:empty {
    display: none;
  }

  .feed {
    padding-top: 28px;
  }
  .day:first-child h3 {
    padding-top: 14px;
  }
  .tx {
    padding: 16px 0;
  }
  .tx::before {
    inset: 2px -16px;
  }
  .desc {
    font-size: 16.5px;
  }
  .amt {
    font-size: 16px;
  }
  .empty {
    margin-top: 14px;
  }

  .dock {
    display: none;
  }
  .toast {
    bottom: 32px;
  }
}

@media (min-width: 960px) and (max-height: 820px) {
  .app {
    padding-top: 22px;
  }
  .side {
    padding-top: 16px;
  }
  .hero {
    padding: 4px 0 22px;
  }
  .balance {
    margin-bottom: 16px;
    font-size: 88px;
  }
  .composer .sheet-body {
    gap: 12px;
  }
}

/* ---------- motion ---------- */

.intro .top,
.intro .hero > *,
.intro .composer,
.intro .day {
  animation: in 0.6s var(--ease) both;
}
.intro .hero > :nth-child(1) {
  animation-delay: 0.05s;
}
.intro .hero > :nth-child(2) {
  animation-delay: 0.1s;
}
.intro .hero > :nth-child(3) {
  animation-delay: 0.15s;
}
.intro .composer {
  animation-delay: 0.2s;
}
.intro .day:nth-child(1) {
  animation-delay: 0.2s;
}
.intro .day:nth-child(2) {
  animation-delay: 0.26s;
}
.intro .day:nth-child(n + 3) {
  animation-delay: 0.32s;
}

@keyframes in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}
@keyframes rise {
  from {
    transform: translateY(100%);
  }
}
@media (min-width: 640px) {
  @keyframes rise {
    from {
      opacity: 0;
      transform: translateY(16px) scale(0.98);
    }
  }
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
@keyframes shake {
  20%,
  60% {
    transform: translateX(-6px);
  }
  40%,
  80% {
    transform: translateX(6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after,
  *::backdrop {
    animation: none !important;
    transition: none !important;
  }
}
