/* split.dfive.us — a paper ledger.

   The brief was simple, classy, easy to follow, and the whole design answers
   one question: what is the one thing the person who just opened this needs to
   know? It is always a single number — what they owe, or what they are owed —
   so that number is the largest thing on the screen and everything else is
   arranged underneath it as evidence.

   The look is the dfive.us brand adapted to an app: bone paper, ink, brass for
   labels, Cormorant for headings. Money is set in the system sans with tabular
   figures, never in the serif — old-style numerals are beautiful and wrong for
   a column of amounts that has to line up. Hairline rules rather than boxes
   wherever a list is really a ledger.

   Committed to one light theme, like Schedule. This is a document, and a
   document made of paper does not have a dark mode. */

:root {
  --paper:    #f5f2ec;
  --paper-2:  #efeae1;
  --card:     #fffdf9;
  --ink:      #15181c;
  --ink-soft: #565d64;
  --ink-mute: #8b9199;
  --accent:   #927545;   /* brass — labels and quiet links, never a surface  */
  --rule:     #cdc6b8;
  --rule-2:   #e3ded3;
  --owed:     #3f6b4f;   /* green:   money coming back to you                */
  --owe:      #8c3a34;   /* oxblood: money you have to hand over             */
  --warn:     #8a5a2b;
  --radius:   12px;
  --radius-s: 9px;
  --tap:      48px;
  --safe-b:   env(safe-area-inset-bottom, 0px);
  --safe-t:   env(safe-area-inset-top, 0px);
  --sans:     -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --serif:    "Dfive Cormorant", Cormorant, Georgia, "Times New Roman", serif;
  --shadow:   0 1px 2px rgba(21, 24, 28, .04), 0 8px 22px rgba(21, 24, 28, .05);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* Any rule that sets `display` outranks the `hidden` ATTRIBUTE, and the sheet
   is display:flex. Every hide in this app is the attribute, so state it once
   here rather than remembering it per component. */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; font-family: var(--serif); font-weight: 500; line-height: 1.15; }

/* Money, everywhere. Tabular so a column lines up; the slight negative
   tracking stops big figures looking loose next to the serif. */
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.pos { color: var(--owed); }
.neg { color: var(--owe); }
.muted { color: var(--ink-soft); }
.dim   { color: var(--ink-mute); }
.tiny  { font-size: 12.5px; line-height: 1.45; }
.small { font-size: 14px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.strike { text-decoration: line-through; }

/* ── the shared sign-in card sits on the same paper ──────────────────────── */
body.signing-in #app { padding: 0; max-width: none; }

/* ── page chrome ────────────────────────────────────────────────────────── */
#app { max-width: 620px; margin: 0 auto; padding: calc(var(--safe-t) + 14px) 18px calc(48px + var(--safe-b)); }
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: inherit; }
.brand-mark { width: 26px; height: 26px; flex: none; color: var(--ink); }
.brand-name { font-weight: 600; font-size: 15.5px; letter-spacing: -0.01em; }
.brand-name span { color: var(--ink-mute); font-weight: 500; }
.spacer { flex: 1; }
.who { color: var(--ink-mute); font-size: 13px; max-width: 44%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.eyebrow {
  font-family: var(--sans); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .14em; color: var(--accent);
  margin: 0 0 7px;
}
.eyebrow.plain { color: var(--ink-mute); }
.h-page { font-size: clamp(28px, 7vw, 34px); letter-spacing: .005em; }
.h-card { font-size: 21px; }
.lede { color: var(--ink-soft); font-size: 15.5px; margin: 8px 0 0; }
.rule { height: 1px; background: var(--rule-2); border: 0; margin: 20px 0; }

/* ── cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--rule-2);
  border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card.flat { box-shadow: none; background: transparent; border-color: var(--rule-2); }
.card.quiet { background: var(--paper-2); border-color: transparent; box-shadow: none; }
.card-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.card-head h2 { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack > * + * { margin-top: 12px; }

/* ── the one number ─────────────────────────────────────────────────────────
   The hero of the whole app: what you owe, or what you are owed. Set large,
   in the sans, with the word above it so the figure never has to carry a
   minus sign — "You owe $84.20" is unambiguous in a way that "-$84.20" is
   not, especially on a screen somebody is reading at a bar. */
.figure { padding: 4px 0 2px; }
.figure .word { font-size: 13.5px; font-weight: 600; letter-spacing: .01em; color: var(--ink-soft); }
.figure .amount {
  display: block; font-size: clamp(40px, 12vw, 52px); font-weight: 680;
  letter-spacing: -0.035em; line-height: 1.05; margin-top: 2px;
}
.figure .after { margin-top: 8px; color: var(--ink-mute); font-size: 13.5px; }
.figure.clear .amount { font-family: var(--serif); font-weight: 500; letter-spacing: .01em; color: var(--owed); }

/* ── buttons ────────────────────────────────────────────────────────────── */
.btn {
  min-height: var(--tap); padding: 0 20px; border-radius: var(--radius-s);
  border: 1px solid var(--rule); background: var(--card); color: var(--ink);
  font-weight: 600; font-size: 15.5px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .08s ease, background .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn-ghost { background: transparent; border-color: var(--rule); }
.btn-plain { background: transparent; border-color: transparent; }
.btn-danger { color: var(--owe); border-color: var(--rule); }
.btn-pay { background: var(--owed); border-color: var(--owed); color: #fffdf9; }
.btn-block { display: flex; width: 100%; }
.btn-row { display: flex; gap: 9px; }
.btn-row > .btn { flex: 1; }
.btn-sm { min-height: 38px; padding: 0 13px; font-size: 14px; border-radius: 8px; white-space: nowrap; font-weight: 600; }
.btn-icon { width: 40px; min-height: 40px; padding: 0; border-radius: 9px; font-size: 17px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; font-size: inherit; }
.link-dim { color: var(--ink-mute); font-weight: 500; }
.link-danger { color: var(--owe); }

/* ── inputs ─────────────────────────────────────────────────────────────── */
.field { display: block; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.label { display: block; color: var(--ink-soft); font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.input, textarea.input, select.input {
  width: 100%; min-height: var(--tap); padding: 11px 14px; border-radius: var(--radius-s);
  border: 1px solid var(--rule); background: var(--card); color: var(--ink);
  outline: none; font-size: 16px;   /* 16px stops iOS zooming into the field */
}
.input::placeholder { color: var(--ink-mute); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(146, 117, 69, .15); }
.input.bad { border-color: var(--owe); }
textarea.input { min-height: 76px; resize: vertical; line-height: 1.45; }
.hint { color: var(--ink-mute); font-size: 12.5px; margin-top: 6px; }
.hint.bad { color: var(--owe); }

/* An amount field: the dollar sign lives in the box, the figure is big and
   tabular, and the keypad is numeric. Typing money should feel like money. */
.money-field { position: relative; }
.money-field .sign {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--ink-mute); font-size: 22px; font-weight: 500; pointer-events: none;
}
.money-field .input {
  padding-left: 32px; font-size: 24px; font-weight: 650; min-height: 58px;
  font-variant-numeric: tabular-nums; letter-spacing: -0.01em;
}

.seg { display: grid; grid-auto-flow: column; gap: 3px; padding: 3px; border-radius: var(--radius-s); background: var(--paper-2); border: 1px solid var(--rule-2); }
.seg button { border: 0; background: transparent; color: var(--ink-soft); min-height: 40px; border-radius: 7px; font-weight: 600; font-size: 14.5px; cursor: pointer; }
.seg button.is-on { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(21,24,28,.08); }

.check { display: flex; gap: 11px; align-items: flex-start; color: var(--ink-soft); font-size: 14.5px; line-height: 1.45; cursor: pointer; }
.check input { width: 21px; height: 21px; margin: 1px 0 0; flex: none; accent-color: var(--ink); }
.check b { color: var(--ink); font-weight: 600; }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.stepper button { width: 34px; height: 34px; border: 0; background: var(--card); color: var(--ink-soft); font-size: 17px; cursor: pointer; }
.stepper button:active { background: var(--paper-2); }
.stepper output { min-width: 30px; text-align: center; font-weight: 650; font-size: 14.5px; font-variant-numeric: tabular-nums; }

/* ── people ─────────────────────────────────────────────────────────────────
   Initials in a circle. Cheap, recognisable at a glance, and it never needs a
   photo upload — which is a whole feature this app deliberately does not have. */
.av {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--paper-2); color: var(--ink-soft);
  font-size: 12.5px; font-weight: 700; letter-spacing: .02em;
  border: 1px solid var(--rule-2);
}
.av.sm { width: 26px; height: 26px; font-size: 10.5px; }
.av.me { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* Who was on this bill. A tap target with a name in it, not a checkbox with a
   label beside it — the whole pill is the hit area. */
.who-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.who-pill {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 42px; padding: 0 14px 0 7px; border-radius: 999px;
  border: 1px solid var(--rule); background: var(--card); color: var(--ink-mute);
  font-weight: 600; font-size: 14.5px; cursor: pointer;
  transition: border-color .12s ease, color .12s ease, background .12s ease;
}
.who-pill .av { width: 28px; height: 28px; font-size: 11px; }
/* Selected has to be obvious at a glance in a dim bar, and it must not depend
   on colour alone — hence the tick, a heavier rule and a tinted ground, all
   changing together. The circle marks SELECTION, never identity: marking "you"
   in solid ink made the one pill that is always on the hardest to read. */
.who-pill.is-on {
  border-color: var(--ink); border-width: 1.5px; padding: 0 13px 0 6px;
  color: var(--ink); background: rgba(21, 24, 28, .055); font-weight: 650;
}
.who-pill .av { transition: background .12s ease, color .12s ease; }
.who-pill.is-on .av.on {
  background: var(--ink); color: var(--paper); border-color: var(--ink);
  font-size: 13px; font-weight: 700;
}
.who-pill .share { font-variant-numeric: tabular-nums; color: var(--accent); font-size: 13px; }

/* ── the ledger ─────────────────────────────────────────────────────────────
   Hairline rules, no boxes. Amount right, tabular, so the column reads down
   like a statement. The last row loses its rule so the card does not end on
   a line that goes nowhere. */
.ledger { margin: 0; }
.led {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 13px 0; border: 0; border-bottom: 1px solid var(--rule-2);
  background: none; color: inherit; font: inherit; cursor: pointer;
}
.ledger .led:last-child { border-bottom: 0; padding-bottom: 2px; }
.ledger .led:first-child { padding-top: 2px; }
.led.static { cursor: default; }
.led:not(.static):active { background: var(--paper-2); }
.led-body { flex: 1; min-width: 0; }
.led-title { font-weight: 600; font-size: 15.5px; letter-spacing: -0.005em; }
.led-sub { color: var(--ink-mute); font-size: 13px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Two four-figure amounts on one line do not fit a 375px phone, and an
   ellipsis through somebody's share is worse than a second line. */
.led-sub.wrap { white-space: normal; overflow: visible; }
.led-amt { font-weight: 650; font-size: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: -0.01em; }
.led-amt small, .led-amt + small { display: block; font-size: 12px; font-weight: 500; color: var(--ink-mute); text-align: right; margin-top: 2px; letter-spacing: 0; }
.led-chev { color: var(--rule); font-size: 18px; margin-left: -4px; }
/* The right-hand column of a ledger row: an amount with its label under it, or
   a status tag instead. Right-aligned so a column of them reads down. */
.led-right { text-align: right; flex: none; }

/* The total line under a ledger: heavier rule above, the way a receipt does it. */
.led-total {
  display: flex; justify-content: space-between; align-items: baseline;
  padding-top: 13px; margin-top: 4px; border-top: 1.5px solid var(--ink);
  font-weight: 650;
}
.led-total .led-amt { font-size: 18px; }

/* A person's standing: name, what they put in, and where they land. The bar is
   how much of the total they carried — decoration, but honest decoration. */
.bar { height: 3px; border-radius: 2px; background: var(--rule-2); margin-top: 7px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); opacity: .5; }

/* A prompt the app raises itself, inside a card rather than as a banner —
   it is about your number, so it belongs under your number. */
.nudge {
  margin-top: 14px; padding: 13px 14px; border-radius: var(--radius-s);
  background: rgba(138, 90, 43, .08); border: 1px solid rgba(138, 90, 43, .22);
}
.nudge .tiny { color: var(--warn); font-weight: 600; }

/* ── settle-up lines ────────────────────────────────────────────────────── */
.settle {
  display: flex; align-items: flex-start; gap: 12px; padding: 14px 0;
  border-bottom: 1px solid var(--rule-2);
}
.settle .av { margin-top: 1px; }
.settle:last-child { border-bottom: 0; }
.settle-body { flex: 1; min-width: 0; }
.settle-who { font-weight: 600; font-size: 15.5px; }
.settle-amt { font-variant-numeric: tabular-nums; font-weight: 650; }
.settle.mine { padding: 16px 0; }
.pay-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
/* Who the money is actually going to. The handle is set in the monospace-ish
   weight it deserves: it is the string a payer checks against the name Venmo
   shows them, and the only defence against paying a hijacked seat. */
.pay-to { font-size: 13px; color: var(--ink-mute); margin-top: 4px; line-height: 1.45; }
.pay-to b { color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }

/* ── status words ───────────────────────────────────────────────────────── */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650;
  letter-spacing: .02em; background: var(--paper-2); color: var(--ink-soft);
  white-space: nowrap;
}
.tag.ok   { background: rgba(63, 107, 79, .12);  color: var(--owed); }
.tag.due  { background: rgba(140, 58, 52, .10);  color: var(--owe); }
.tag.wait { background: rgba(138, 90, 43, .12);  color: var(--warn); }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* ── empty states ───────────────────────────────────────────────────────── */
.empty { text-align: center; color: var(--ink-mute); padding: 26px 14px; }
.empty .big { display: block; font-family: var(--serif); font-size: 26px; color: var(--ink-soft); margin-bottom: 6px; }

/* ── bottom sheet ───────────────────────────────────────────────────────── */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(21, 24, 28, .38); }
.sheet-body {
  position: relative; width: 100%; max-width: 620px; margin: 0 auto; max-height: 90dvh; overflow: auto;
  background: var(--card); border: 1px solid var(--rule-2); border-bottom: 0;
  border-radius: 18px 18px 0 0; padding: 10px 18px calc(26px + var(--safe-b));
  box-shadow: 0 -8px 40px rgba(21, 24, 28, .14);
  animation: up .2s cubic-bezier(.2, .7, .3, 1);
}
@keyframes up { from { transform: translateY(22px); opacity: .7; } to { transform: none; opacity: 1; } }
.sheet-grip { display: block; width: 40px; height: 4px; border-radius: 999px; border: 0; background: var(--rule); margin: 4px auto 16px; padding: 0; cursor: pointer; }
.sheet-x { position: absolute; top: 12px; right: 14px; width: 34px; height: 34px; border-radius: 8px; border: 0; background: var(--paper-2); color: var(--ink-soft); font-size: 15px; cursor: pointer; }
.sheet h2 { margin-bottom: 6px; padding-right: 40px; font-size: 23px; }
.sheet .sub { color: var(--ink-soft); font-size: 14.5px; margin: 0 0 18px; }
.sheet-actions { margin-top: 20px; }

/* ── toast ──────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: calc(22px + var(--safe-b)); transform: translateX(-50%);
  z-index: 60; background: var(--ink); color: var(--paper);
  padding: 12px 18px; border-radius: 10px; font-weight: 600; font-size: 14.5px;
  max-width: 92vw; box-shadow: 0 8px 28px rgba(21, 24, 28, .28); text-align: center;
}
.toast.is-bad { background: var(--owe); }

/* ── the install / notification callouts ────────────────────────────────────
   Bottom of the page, quiet. Advice, not an interruption — this app has one
   job and a modal about installing it is not that job. */
.install .h-card { font-size: 19px; }
.steps { margin: 8px 0 0; padding: 0 0 0 20px; color: var(--ink-soft); font-size: 14.5px; line-height: 1.55; }
.steps li { margin-bottom: 8px; }
.steps li::marker { color: var(--accent); font-weight: 700; }
.steps b { color: var(--ink); font-weight: 650; }
/* The iOS share glyph, inline in the sentence, so "tap this" points at the
   thing rather than describing it. */
.ios-share {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 6px; margin: 0 1px;
  background: var(--card); border: 1px solid var(--rule); color: #0a84ff;
  vertical-align: -6px;
}

/* ── misc ───────────────────────────────────────────────────────────────── */
.copybox { display: flex; gap: 8px; align-items: center; }
.copybox .input { flex: 1; font-size: 13px; color: var(--ink-soft); min-height: 42px; }
.spinner { display: inline-block; width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--rule-2); border-top-color: var(--accent); animation: spin .8s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.fade { animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.foot { margin-top: 26px; text-align: center; color: var(--ink-mute); font-size: 12px; }
.foot a { color: var(--ink-mute); }

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