:root {
  --bg: #f5f4f1;
  --card: #ffffff;
  --ink: #17171a;
  --muted: #71717a;
  --line: #e6e4df;
  --accent: #1f6feb;
  --good: #0f7b4f;
  --bad: #b3261e;
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0 16px calc(40px + env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  max-width: 560px;
  margin-inline: auto;
}

h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(16px + env(safe-area-inset-top)) 0 12px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

/* Balance hero -- the one thing you open the app to see. */
.hero { text-align: center; padding: 26px 16px; }
.hero .who { color: var(--muted); font-size: 15px; }
.hero .amount {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 4px 0 2px;
  font-variant-numeric: tabular-nums;
}
.hero.owed .amount { color: var(--good); }
.hero.owes .amount { color: var(--bad); }
.hero.square .amount { color: var(--ink); font-size: 30px; }

label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }

input[type="text"], input[type="password"], input[type="number"] {
  width: 100%;
  font-size: 16px; /* 16px stops iOS zooming on focus */
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfaf8;
  color: var(--ink);
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: #fff; }

.field { margin-bottom: 14px; }

.amount-field { position: relative; }
.amount-field span {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 18px; pointer-events: none;
}
.amount-field input { padding-left: 32px; font-size: 22px; font-weight: 600; }

/* Segmented pickers: big thumb targets, no dropdowns. */
.seg { display: flex; gap: 8px; }
.seg button {
  flex: 1;
  padding: 13px 8px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  color: var(--muted);
  background: #fbfaf8;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
}
.seg button[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

button.primary {
  width: 100%;
  padding: 15px;
  font-size: 16px;
  font-weight: 650;
  font-family: inherit;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}
button.primary:disabled { opacity: 0.5; }

button.ghost {
  width: 100%;
  padding: 13px;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
}

.icon-btn {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.entries { list-style: none; margin: 0; padding: 0; }
.entries li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.entries li:last-child { border-bottom: 0; }
.entries .body { flex: 1; min-width: 0; }
.entries .top { display: flex; justify-content: space-between; gap: 10px; }
.entries .note { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entries .val { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.entries .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.entries .settle .note { color: var(--good); }
.del {
  border: 0; background: none; color: var(--muted);
  font-size: 20px; line-height: 1; padding: 6px 2px 6px 8px; cursor: pointer;
}

.day-label { font-size: 13px; font-weight: 700; color: var(--muted); margin: 18px 0 2px; }

.msg { padding: 11px 13px; border-radius: 10px; font-size: 14px; margin-bottom: 12px; }
.msg.error { background: #fdeceb; color: var(--bad); }
.msg.ok { background: #e7f5ee; color: var(--good); }

.empty { text-align: center; color: var(--muted); padding: 26px 10px; font-size: 15px; }

.centered { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; }
.centered h1 { text-align: center; margin-bottom: 6px; }
.centered .tagline { text-align: center; color: var(--muted); margin: 0 0 22px; font-size: 15px; }

dialog {
  border: 0; border-radius: var(--radius); padding: 18px;
  width: min(92vw, 420px); background: var(--card); color: var(--ink);
}
dialog::backdrop { background: rgba(0,0,0,0.45); }
dialog h2 { margin: 0 0 14px; font-size: 17px; }
.row { display: flex; gap: 8px; margin-top: 6px; }
.row > * { flex: 1; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131316; --card: #1c1c20; --ink: #f2f2f3; --muted: #9b9ba3;
    --line: #2e2e34; --accent: #4b8bf5; --good: #46c78c; --bad: #f2736a;
  }
  input[type="text"], input[type="password"], input[type="number"], .seg button { background: #232329; }
  input:focus { background: #26262d; }
  .seg button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
  .msg.error { background: #3a1f1d; } .msg.ok { background: #16301f; }
}
