/* Orbit: minimal mobile-first styles. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #16191d;
  --muted: #5f6873;
  --border: #dde1e6;
  --accent: #2f6fdf;
  --accent-text: #ffffff;
  --danger: #c0392b;
  --radius: 12px;
  --gap: 16px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #1b1f24;
    --text: #e8eaed;
    --muted: #9aa3ad;
    --border: #2c323a;
    --accent: #5b8ff0;
    --danger: #f06b5b;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: calc(10px + env(safe-area-inset-top)) max(var(--gap), env(safe-area-inset-right)) 10px
    max(var(--gap), env(safe-area-inset-left));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar form { margin: 0; }

.brand {
  font-weight: 700;
  font-size: 20px;
  color: var(--text);
  text-decoration: none;
}

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: var(--gap) max(var(--gap), env(safe-area-inset-right)) var(--gap)
    max(var(--gap), env(safe-area-inset-left));
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--gap);
}

.card.narrow { max-width: 420px; margin: 8vh auto 0; }

h1 { font-size: 24px; margin: 0 0 12px; }

.muted { color: var(--muted); }

.error { color: var(--danger); font-weight: 600; }

.stack { display: flex; flex-direction: column; gap: 10px; }

label { font-weight: 600; font-size: 15px; }

input, select, textarea, button { font: inherit; }

/* 16px+ font on inputs prevents iOS Safari from zooming on focus. */
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
}

button {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

a { color: var(--accent); }

h2 { font-size: 19px; margin: 0; }

.small { font-size: 14px; }

/* On a phone the links don't all fit: the nav scrolls sideways instead of the page. */
.nav {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav a, .nav button { white-space: nowrap; flex: none; }
.nav a { text-decoration: none; font-weight: 600; }
.nav a[aria-current="page"] { text-decoration: underline; text-underline-offset: 4px; }

.stack-lg { display: flex; flex-direction: column; gap: 20px; }
.nowrap { white-space: nowrap; }
.row { display: flex; gap: 8px; align-items: center; }
.row > input, .row > select { flex: 1; min-width: 0; }
.row.wrap { flex-wrap: wrap; }
.row form { margin: 0; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }

.flash {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.flash-error { border-color: var(--danger); color: var(--danger); }
.flash a { margin-left: 6px; font-weight: 600; }

.pill {
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  text-decoration: none;
  white-space: nowrap;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 36px;
  margin: 0;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: 15px;
}
.chip-active { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip-tag { color: var(--accent); }
.chip-x {
  min-height: 28px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.list.compact { gap: 10px; }
.list-row {
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}
.list-title { font-weight: 600; }
.list-sub { font-size: 14px; }
.tag { color: var(--accent); }

.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.timeline li { border-left: 3px solid var(--border); padding-left: 12px; }
.timeline form { margin: 0; }
.note-text { white-space: pre-wrap; overflow-wrap: anywhere; }

details > summary { cursor: pointer; min-height: 32px; }
details[open] > summary { margin-bottom: 12px; }

.button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.danger { color: var(--danger); border-color: var(--danger); }

.choice { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.choice input { width: auto; min-height: 0; margin-top: 18px; }
.merge-card { flex: 1; }

button.link {
  min-height: 44px;
  border: 0;
  background: none;
  color: var(--accent);
  padding: 0 4px;
}

/* Ledger & promises */
:root { --plus: #1e8e4f; --minus: #c0392b; }
@media (prefers-color-scheme: dark) { :root { --plus: #4cc38a; --minus: #f06b5b; } }

.stack-sm { display: flex; flex-direction: column; gap: 4px; }
h3 { margin: 4px 0 0; font-weight: 600; }
.plus { color: var(--plus); }
.minus { color: var(--minus); }
.balances { display: flex; flex-direction: column; gap: 2px; }
.balance { margin: 0; font-size: 19px; }
.list-row.row-between { flex-direction: row; }
.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.total { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; }
.overdue { color: var(--danger); font-weight: 600; }
.settled { color: var(--muted); }
.actions { gap: 6px; }
.actions form { margin: 0; }
button.small { min-height: 36px; padding: 6px 12px; font-size: 15px; }
details.inline > summary { display: inline-flex; align-items: center; min-height: 36px; color: var(--accent); }
details.inline[open] { flex-basis: 100%; }
details.inline[open] > summary { margin-bottom: 6px; }
input.currency { flex: 0 0 5.5em; text-transform: uppercase; }
/* Quick-add: amount/currency only for money, the reminder only for items (no JS needed). */
.debt-form:not(:has(option[value="money"]:checked)) .money-only { display: none; }
.debt-form:not(:has(option[value="item"]:checked)) .item-only { display: none; }

/* Inbox */
.badge {
  display: inline-block;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 13px;
  line-height: 20px;
  text-align: center;
}
.quote { margin: 0; color: var(--muted); font-style: italic; overflow-wrap: anywhere; }
.bullets { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.warn { color: var(--danger); margin: 0; }
.missing label { font-weight: 600; }
input.needs { border-color: var(--danger); }
fieldset { border: 0; border-top: 1px solid var(--border); margin: 0; padding: 12px 0 0; }
fieldset:first-of-type { border-top: 0; padding-top: 0; }
.include { font-weight: 600; }
.include input { margin-top: 12px; }
select[multiple] { min-height: 120px; }
/* The existing-person picker only when "It's someone I already have" is chosen. */
.new-person:not(:has(option[value="link"]:checked)) .link-only { display: none; }
.sticky-actions {
  position: sticky;
  bottom: 0;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  background: var(--bg);
}

/* Split */
.split-row { align-items: center; }
.split-form .choice { align-items: center; }
.split-form .choice input { margin-top: 0; }
input.amount { width: 7.5rem; flex: none; }
/* Amount fields only for a custom split; "count me in" only for an even one. */
.split-form:has(input[name="mode"][value="even"]:checked) .amount { display: none; }
.split-form:has(input[name="mode"][value="custom"]:checked) .even-only { display: none; }

/* Payment: the debt picker only when "Pick debts myself" is chosen. */
.payment-form .choice { align-items: center; }
.payment-form .choice input { margin-top: 0; }
.payment-form:not(:has(input[name="option"][value="custom"]:checked)) .custom-only { display: none; }

/* Import */
.pill-shared { background: var(--accent); color: var(--accent-text); }
.tx-list .list-row { gap: 2px; }
