/* Clean and calm: soft neutrals, one green money accent. Follows the phone's light/dark setting. */
:root {
  --bg: #f5f7f6; --card: #ffffff; --fg: #17211c; --muted: #66716b; --line: #dfe4e1;
  --accent: #1f8a5b; --accent-fg: #ffffff; --tint: #e6f3ec; --warn: #b4531f;
  --display: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101412; --card: #1b211e; --fg: #e9eeeb; --muted: #97a39c; --line: #2c3430;
    --accent: #3fbf86; --accent-fg: #06140d; --tint: #173126; --warn: #f0955f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font-family: var(--body);
  -webkit-tap-highlight-color: transparent;
}

.screen {
  display: flex; flex-direction: column; gap: 14px;
  max-width: 460px; min-height: 100vh; min-height: 100dvh; margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right))
           max(22px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}

.brand { margin: 0; font-family: var(--display); font-weight: 700; font-size: 1.35rem; }
.brand span { color: var(--accent); }

.label { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 6px; display: block; }
.box { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }

.total { display: flex; align-items: baseline; gap: 4px; font-family: var(--display); font-size: 2rem; font-weight: 700; }
.total input { font: inherit; color: inherit; background: none; border: 0; width: 100%; min-width: 0; padding: 0; outline-offset: 4px; border-radius: 4px; }
.total input::placeholder { color: var(--line); }

.stepper { display: flex; align-items: center; justify-content: space-between; }
.stepper .label { margin: 0; }
.ctl { display: flex; gap: 8px; align-items: center; }
.count { font-family: var(--display); font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 1.4em; text-align: center; }
.btn-sm { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); font-size: 1.1rem; cursor: pointer; touch-action: manipulation; }
.btn-sm:disabled { opacity: .4; cursor: not-allowed; }

.head { display: flex; justify-content: space-between; align-items: baseline; }
.even { border: 0; background: none; color: var(--accent); font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; padding: 0 0 6px; }

.people { display: flex; flex-direction: column; gap: 8px; }
.person { display: grid; grid-template-columns: 1fr 84px; gap: 8px; align-items: center; }
/* 16px text stops iPhone zooming in when a box is tapped */
.person input { font: inherit; font-size: 16px; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-width: 0; width: 100%; }
.pctwrap { position: relative; }
.pctwrap input { text-align: right; padding-right: 26px; font-variant-numeric: tabular-nums; }
.pctwrap span { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.pctwrap.auto input { color: var(--muted); border-style: dashed; }

.remain { margin: 10px 0 0; font-size: .82rem; color: var(--muted); }
.remain.over { color: var(--warn); }
.remain.done { color: var(--accent); }

.go { margin-top: auto; border: 0; border-radius: 14px; padding: 15px; font: inherit; font-family: var(--display); font-weight: 700; font-size: 1.05rem; background: var(--accent); color: var(--accent-fg); cursor: pointer; touch-action: manipulation; }
.go:disabled { opacity: .45; cursor: not-allowed; }
.hint { font-size: .8rem; color: var(--muted); text-align: center; min-height: 1em; margin: -6px 0 0; }
.reset { align-self: center; border: 0; background: none; color: var(--muted); font: inherit; font-size: .8rem; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 4px 8px; margin-top: -8px; }

button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Result card */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.scrim[hidden] { display: none; }
.sheet {
  width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; background: var(--card); border-radius: 14px 14px 0 0;
  padding: 20px 18px max(22px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px;
  animation: up .28s ease-out;
}
@keyframes up { from { transform: translateY(30%); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
.sheet h2 { margin: 0; font-family: var(--display); font-size: 1rem; color: var(--muted); font-weight: 500; }
.owes { display: flex; flex-direction: column; gap: 8px; }
.owe { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 12px 14px; border-radius: 10px; background: var(--tint); }
.owe span { min-width: 0; overflow-wrap: anywhere; }
.owe b { font-family: var(--display); font-size: 1.5rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.owe small { display: block; color: var(--muted); font-size: .75rem; }
.check { font-size: .8rem; color: var(--muted); text-align: center; }
.close { border: 1px solid var(--line); background: transparent; color: var(--fg); border-radius: 14px; padding: 12px; font: inherit; font-weight: 600; cursor: pointer; }
