/* Split — calm, warm, editorial.
   Light is the default; dark follows the system unless chosen in Settings (data-theme on <html>). */

:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #f1ece5;
  --surface-3: #e9e2d8;
  --line: #e8e1d7;
  --text: #2a2520;
  --text-2: #5d554d;
  --muted: #8f857b;
  --accent: #c2603a;
  --accent-ink: #ffffff;
  --accent-soft: rgba(194, 96, 58, .10);
  --owed: #3e7a5a;
  --owed-soft: rgba(62, 122, 90, .10);
  --owe: #b4553a;
  --owe-soft: rgba(180, 85, 58, .10);
  --danger: #b0413e;
  --glass: rgba(255, 255, 255, .78);
  --shadow-sm: 0 1px 2px rgba(42, 37, 32, .04), 0 2px 8px rgba(42, 37, 32, .04);
  --shadow-lg: 0 10px 30px rgba(42, 37, 32, .12);
  --backdrop: rgba(30, 26, 22, .35);
  --avatar-l: 88%;
  --avatar-s: 38%;
  --avatar-ink: 30%;
  --radius: 20px;
  --radius-sm: 14px;
  --tabbar-h: 84px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171412;
    --surface: #201c19;
    --surface-2: #2a2521;
    --surface-3: #342e29;
    --line: #2f2925;
    --text: #efe8e0;
    --text-2: #c4bab0;
    --muted: #92877d;
    --accent: #df8456;
    --accent-ink: #1b1613;
    --accent-soft: rgba(223, 132, 86, .14);
    --owed: #8fc4a2;
    --owed-soft: rgba(143, 196, 162, .12);
    --owe: #e9a184;
    --owe-soft: rgba(233, 161, 132, .12);
    --danger: #e58a80;
    --glass: rgba(36, 31, 28, .82);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .2);
    --shadow-lg: 0 12px 34px rgba(0, 0, 0, .45);
    --backdrop: rgba(0, 0, 0, .55);
    --avatar-l: 30%;
    --avatar-s: 28%;
    --avatar-ink: 84%;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #171412;
  --surface: #201c19;
  --surface-2: #2a2521;
  --surface-3: #342e29;
  --line: #2f2925;
  --text: #efe8e0;
  --text-2: #c4bab0;
  --muted: #92877d;
  --accent: #df8456;
  --accent-ink: #1b1613;
  --accent-soft: rgba(223, 132, 86, .14);
  --owed: #8fc4a2;
  --owed-soft: rgba(143, 196, 162, .12);
  --owe: #e9a184;
  --owe-soft: rgba(233, 161, 132, .12);
  --danger: #e58a80;
  --glass: rgba(36, 31, 28, .82);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .2);
  --shadow-lg: 0 12px 34px rgba(0, 0, 0, .45);
  --backdrop: rgba(0, 0, 0, .55);
  --avatar-l: 30%;
  --avatar-s: 28%;
  --avatar-ink: 84%;
  color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15.5px/1.5 var(--font);
  letter-spacing: -.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color .2s ease;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.2; font-weight: 500; }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

#app { max-width: 540px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; position: relative; }
main { padding: 4px 20px calc(var(--tabbar-h) + 40px + env(safe-area-inset-bottom)); }

.owed { color: var(--owed); }
.owe { color: var(--owe); }
.muted, .settled { color: var(--muted); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px 14px;
  padding-top: calc(18px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
}
.topbar .titles { flex: 1; min-width: 0; }
.topbar h1 {
  font-family: var(--display); font-size: 28px; font-weight: 500; letter-spacing: -.015em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-variation-settings: "opsz" 48;
}
.subtitle { font-size: 13.5px; color: var(--muted); margin-top: 3px; line-height: 1.4; }
.subtitle .link { font-size: 13.5px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; flex: none; cursor: pointer;
  display: inline-grid; place-items: center;
  background: transparent; border: 1px solid var(--line); color: var(--text-2);
  transition: background-color .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--surface); color: var(--text); }
.icon-btn svg { width: 19px; height: 19px; }

/* ---------- tab bar: floating tabs on the left, round actions on the right ---------- */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom));
  width: calc(100% - 28px); max-width: 512px; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  pointer-events: none;
}
.tabbar > * { pointer-events: auto; }
.tabs {
  display: flex; gap: 2px; padding: 5px;
  background: var(--glass); border: 1px solid var(--line);
  border-radius: 22px; box-shadow: var(--shadow-lg);
  backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px);
}
.tab {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 76px; padding: 7px 10px 6px; border-radius: 17px;
  font-size: 12px; font-weight: 500; color: var(--muted);
  transition: background-color .15s ease, color .15s ease;
}
.tab svg { width: 21px; height: 21px; }
.tab:hover { color: var(--text-2); }
.tab.active { background: var(--surface-2); color: var(--text); }
.tab.has-new::after {
  content: ''; position: absolute; top: 6px; right: 18px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--owed);
  box-shadow: 0 0 0 2px var(--glass);
}
.fabs { display: flex; gap: 8px; align-items: center; }
.fab {
  width: 54px; height: 54px; border-radius: 18px; border: 0; cursor: pointer; flex: none;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  box-shadow: var(--shadow-lg);
  transition: transform .12s ease, filter .15s ease;
}
.fab:hover { filter: brightness(1.05); }
.fab:active { transform: scale(.95); }
.fab svg { width: 24px; height: 24px; }
.fab.secondary { background: var(--glass); color: var(--text); border: 1px solid var(--line); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
@media (max-width: 400px) {
  .tab { min-width: 62px; padding: 7px 6px 6px; }
  .fab { width: 50px; height: 50px; border-radius: 16px; }
  .tabbar { gap: 8px; width: calc(100% - 20px); }
}

/* ---------- sections, cards, lists ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm);
}
.section { margin-top: 30px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 4px 10px; }
.section-head h2 { font-size: 13.5px; font-weight: 500; color: var(--muted); letter-spacing: .01em; }
.section-head a, .link {
  color: var(--accent); font-size: 14px; font-weight: 500; cursor: pointer;
  background: none; border: 0; padding: 0;
}
.link:hover, .section-head a:hover { text-decoration: underline; text-underline-offset: 3px; }
.link.muted { color: var(--muted); }

.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.summary .card { padding: 16px 18px; }
.summary .label { font-size: 13px; color: var(--muted); }
.summary .big {
  font-family: var(--display); font-size: 22px; font-weight: 500; letter-spacing: -.01em;
  margin-top: 4px; font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-variation-settings: "opsz" 36;
}
.summary .big small { display: block; font-size: 16px; margin-top: 2px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 18px 0 2px; scrollbar-width: none; margin: 0 -20px; padding-left: 20px; padding-right: 20px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 7px 14px; border-radius: 999px; cursor: pointer;
  background: transparent; border: 1px solid var(--line); color: var(--text-2); font-size: 13.5px;
  transition: all .15s ease;
}
.chip:hover { border-color: var(--surface-3); background: var(--surface); }
.chip.active { background: var(--text); border-color: var(--text); color: var(--bg); }

.list {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm);
}
.row {
  position: relative;
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  cursor: pointer; width: 100%; text-align: left;
  background: none; border: 0;
  transition: background-color .12s ease;
}
/* Hairline dividers that start after the icon, like a well-set table. */
.list > .row + .row::before, .list > .row + .breakdown + .row::before {
  content: ''; position: absolute; top: 0; right: 0; left: 70px; height: 1px; background: var(--line);
}
.row:hover { background: var(--surface-2); }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.row .amount { text-align: right; flex: none; font-size: 12px; line-height: 1.35; }
.row .amount b { display: block; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.row.static { cursor: default; }
.row.static:hover { background: none; }
button.row.card { border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }

.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 600; font-size: 14px; letter-spacing: .02em;
}
.avatar.square { border-radius: 13px; }
.avatar svg { width: 19px; height: 19px; }
.avatar.emoji { background: var(--surface-2); font-size: 19px; color: var(--text); }

.empty { text-align: center; color: var(--muted); padding: 30px 18px; font-size: 14.5px; }
.empty b { display: block; color: var(--text); margin-bottom: 4px; font-weight: 500; font-family: var(--display); font-size: 18px; }
.card.empty { box-shadow: none; background: transparent; border-style: dashed; }

.date-head { font-size: 14px; font-weight: 500; color: var(--text-2); padding: 18px 6px 9px; }
.date-head:first-child { padding-top: 4px; }
.breakdown { position: relative; padding: 0 16px 14px 70px; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }

/* Dated expense rows: "OCT" over "10". */
.date-col { width: 28px; flex: none; text-align: center; line-height: 1.1; color: var(--muted); }
.date-col span { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; }
.date-col b { display: block; font-size: 18px; font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; margin-top: 1px; }
.list > .row.has-date + .row::before { left: 112px; }
.row.payment-row { padding-top: 10px; padding-bottom: 10px; }
.payment-row .sub { color: var(--text-2); font-size: 13.5px; white-space: normal; }
.pay-icon { width: 40px; flex: none; display: grid; place-items: center; }
.pay-icon svg { width: 18px; height: 18px; padding: 6px; border-radius: 50%; background: var(--owed-soft); color: var(--owed); box-sizing: content-box; }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span { font-size: 13px; font-weight: 500; color: var(--text-2); }
.input, select.input {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line); outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input::placeholder { color: var(--muted); opacity: .8; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.input:disabled { opacity: .5; }
select.input { appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238f857b' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; }
.input.amount-input {
  font-family: var(--display); font-size: 30px; font-weight: 500; padding: 8px 14px;
  font-variant-numeric: tabular-nums lining-nums; letter-spacing: -.01em;
}
textarea.input { resize: vertical; line-height: 1.45; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.amount-row { display: grid; grid-template-columns: 100px 1fr; gap: 8px; }
.currency-select { font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 500; font-size: 15px;
  transition: background-color .15s ease, filter .15s ease, border-color .15s ease;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.05); background: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 7px 14px; font-size: 13.5px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
.btn svg { flex: none; }
.btn.active { border-color: var(--accent); color: var(--accent); }

.segmented {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px;
  background: var(--surface-2); border-radius: var(--radius-sm); padding: 4px;
}
.segmented button {
  border: 0; background: none; padding: 9px 4px; border-radius: 10px; cursor: pointer;
  color: var(--text-2); font-size: 14px; transition: all .15s ease;
}
.segmented button.active { background: var(--surface); color: var(--text); font-weight: 500; box-shadow: var(--shadow-sm); }
.segmented.four { grid-template-columns: repeat(4, 1fr); }
.segmented.four button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 2px; }
.seg-icon { font-size: 19px; line-height: 1.1; }

.split-row { position: relative; display: flex; align-items: center; gap: 12px; padding: 11px 16px; }
.list > .split-row + .split-row::before { content: ''; position: absolute; top: 0; right: 0; left: 16px; height: 1px; background: var(--line); }
.split-row label { flex: 1; display: flex; align-items: center; gap: 12px; cursor: pointer; min-width: 0; }
.split-row .avatar { width: 32px; height: 32px; font-size: 12px; }
.split-row input[type=checkbox] { width: 19px; height: 19px; accent-color: var(--accent); flex: none; }
.split-row .share { width: 110px; text-align: right; padding: 8px 10px; }
.split-row .calc { color: var(--muted); font-size: 13px; min-width: 76px; text-align: right; font-variant-numeric: tabular-nums; }
.split-foot { font-size: 13px; padding: 8px 6px 0; display: flex; justify-content: space-between; }

.cat-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.cat-chips::-webkit-scrollbar { display: none; }
.cat-chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 7px 13px; border-radius: 999px; font-size: 13.5px;
  background: transparent; border: 1px solid var(--line); color: var(--text-2);
  transition: all .15s ease;
}
.cat-chip span { font-size: 15px; }
.cat-chip.active { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }

.cat-preview { display: flex; align-items: center; gap: 10px; }
.cat-preview span { font-size: 26px; width: 50px; height: 50px; display: grid; place-items: center; background: var(--surface-2); border-radius: var(--radius-sm); flex: none; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.icon-grid button { font-size: 21px; height: 44px; border-radius: 12px; border: 1px solid transparent; background: var(--surface-2); cursor: pointer; }
.icon-grid button.active { border-color: var(--accent); background: var(--accent-soft); }

.or { text-align: center; color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 12px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.notice { margin-top: 14px; background: var(--accent-soft); border-color: transparent; box-shadow: none; font-size: 14px; }
.error { color: var(--danger); font-size: 14px; }
.error:empty { display: none; }

/* ---------- sheets & toast ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: 20; background: var(--backdrop);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .18s ease-out;
}
.sheet {
  width: 100%; max-width: 540px; background: var(--surface);
  border-radius: 26px 26px 0 0; padding: 12px 20px calc(22px + env(safe-area-inset-bottom));
  max-height: 90vh; overflow: auto; box-shadow: var(--shadow-lg);
  animation: up .22s cubic-bezier(.2, .8, .2, 1);
}
.sheet::before { content: ''; display: block; width: 38px; height: 4px; border-radius: 4px; background: var(--surface-3); margin: 0 auto 16px; }
.sheet h2 { font-family: var(--display); font-size: 22px; font-weight: 500; letter-spacing: -.01em; margin-bottom: 16px; }
.sheet p { line-height: 1.55; }
.sheet .menu { display: flex; flex-direction: column; gap: 8px; }
.sheet .menu .row { border: 1px solid var(--line); border-radius: var(--radius-sm); }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: .6; } }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 24px); transform: translateX(-50%) translateY(16px);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 500; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .22s ease; z-index: 30; max-width: calc(100% - 32px); box-shadow: var(--shadow-lg);
}
#toast.show { opacity: 1; transform: translateX(-50%); }

/* ---------- auth ---------- */
.auth { padding: 72px 28px 28px; display: flex; flex-direction: column; gap: 28px; }
.auth h2 { font-family: var(--display); font-size: 24px !important; font-weight: 500; letter-spacing: -.01em; }
.brand { display: flex; align-items: center; gap: 12px; font-family: var(--display); font-size: 32px; font-weight: 500; letter-spacing: -.02em; }
.brand .logo { width: 46px; height: 46px; border-radius: 15px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.brand .logo svg { width: 22px; height: 22px; }

/* ---------- detail cards ---------- */
.hero-balance { text-align: center; padding: 24px 18px; }
.hero-balance .big {
  font-family: var(--display); font-size: 36px; font-weight: 500; letter-spacing: -.02em; margin: 6px 0 4px;
  font-variant-numeric: tabular-nums lining-nums; font-variation-settings: "opsz" 72;
}
.hero-icon { font-size: 28px; line-height: 1; margin-bottom: 8px; }
.byline { margin-top: 12px; font-size: 13px; color: var(--muted); line-height: 1.6; }
.payer-row .title { font-size: 16px; }
.share-row { padding-left: 34px; padding-top: 11px; padding-bottom: 11px; }
.share-row .title { font-weight: 400; white-space: normal; color: var(--text-2); }
.share-row .avatar { width: 30px; height: 30px; font-size: 11.5px; }
.list > .share-row + .share-row::before, .list > .payer-row + .share-row::before { left: 80px; }
.plan-row .arrow { color: var(--muted); }

.comments, .activities { display: flex; flex-direction: column; gap: 16px; }
.comment, .activity { display: flex; gap: 12px; }
.comment .avatar, .activity .avatar { width: 30px; height: 30px; font-size: 11.5px; }
.comment .main, .activity .main { flex: 1; min-width: 0; }
.comment-head { display: flex; gap: 8px; align-items: baseline; font-size: 14px; }
.comment-head b { font-weight: 600; }
.comment-head .link { margin-left: auto; font-size: 12px; }
.comment-body { white-space: pre-wrap; word-break: break-word; margin-top: 2px; color: var(--text-2); }
.comment-form { display: flex; gap: 8px; align-items: flex-end; }
.comment-form textarea { min-height: 44px; }
.activity { font-size: 14px; color: var(--text-2); }
.activity b { color: var(--text); font-weight: 600; }
.activity ul { margin: 4px 0 0; padding-left: 18px; color: var(--muted); }
.activity li { margin: 2px 0; }

/* ---------- settle up ---------- */
.settle-parties { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin: 2px 0 6px; }
.party { display: flex; align-items: center; gap: 10px; min-width: 0; font-weight: 500; }
.party span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.party.right { justify-content: flex-end; }
.settle-arrow {
  width: 54px; height: 54px; border-radius: 18px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  display: grid; place-items: center; transition: border-color .15s ease, transform .15s ease;
}
.settle-arrow:hover { border-color: var(--accent); }
.settle-arrow:active { transform: scale(.95); }
.settle-arrow svg { width: 21px; height: 21px; }
.settle-caption { text-align: center; font-size: 13px; margin-bottom: 18px; }
.settle-outcome { background: var(--surface-2); border-radius: var(--radius-sm); padding: 13px 15px; min-height: 46px; line-height: 1.5; }

/* ---------- settings ---------- */
.theme-picker { grid-template-columns: repeat(3, 1fr); }

.payer-row .title { white-space: normal; }

/* ---------- round 6: quick expense form, pickers, group tabs, stats ---------- */
/* Chart series: validated for colour-blind separation on each theme's card surface. */
:root { --c1: #c8592e; --c2: #3b6fd0; --c3: #d49a17; --c4: #8b4fb0; --c5: #1f9b78; --c-other: #b9b0a6; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --c1: #cf6a3d; --c2: #5b8ae3; --c3: #b4821f; --c4: #a57ad0; --c5: #2c9d7f; --c-other: #5c544d; }
}
:root[data-theme="dark"] { --c1: #cf6a3d; --c2: #5b8ae3; --c3: #b4821f; --c4: #a57ad0; --c5: #2c9d7f; --c-other: #5c544d; }

.quick-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pill-btn {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 8px 14px; border-radius: 999px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  font-size: 14.5px; color: var(--text); overflow: hidden;
}
.pill-btn:hover { border-color: var(--surface-3); }
.pill-btn svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.pill-btn b { font-weight: 600; }
.pill-btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* The real date input sits invisibly over the pill so a tap opens the native picker. */
.date-pill input[type=date] { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; }
.avatar.tiny { width: 24px; height: 24px; font-size: 10px; }

.picker-btn { display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; cursor: pointer; min-height: 48px; }
.picker-btn svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.picker-btn > span { display: flex; align-items: center; gap: 10px; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cat-emoji { font-size: 19px; }
.currency-btn { font-weight: 600; justify-content: center; gap: 4px; }
.picker-search { margin-bottom: 12px; }
.picker-list { max-height: 60vh; overflow: auto; box-shadow: none; }
.picker-list .row.selected .title { font-weight: 600; }
.picker-list .check svg { width: 18px; height: 18px; color: var(--accent); }

.group-tabs { margin-top: 18px; }
.tab-panel { margin-top: 6px; }
.tab-panel > .date-head:first-child { padding-top: 14px; }
.tab-panel .section.first { margin-top: 18px; }
.tab-panel > .card.empty { margin-top: 14px; }

.row.expandable .chev { color: var(--muted); display: grid; transition: transform .15s ease; }
.row.expandable .chev svg { width: 16px; height: 16px; }
.row.expandable.open .chev { transform: rotate(180deg); }
.breakdown { padding-top: 2px; gap: 6px; font-size: 13.5px; color: var(--text-2); }
.breakdown b { font-weight: 500; color: var(--text); }
.breakdown-links { display: flex; gap: 16px; margin-top: 4px; }
.breakdown-links .link { font-size: 13.5px; }

.stats-chips { padding-top: 14px; }
.stat-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.stat-tiles .stat-hero { grid-column: 1 / -1; }
.stat-tiles .label { font-size: 13px; color: var(--muted); }
.stat-big { font-family: var(--display); font-size: 34px; font-weight: 500; letter-spacing: -.02em; margin-top: 4px; font-variation-settings: "opsz" 72; }
.stat-mid { font-family: var(--display); font-size: 21px; font-weight: 500; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-note { font-size: 12.5px; margin-top: 4px; }
.share-meter { height: 6px; border-radius: 6px; background: var(--surface-2); margin-top: 10px; overflow: hidden; }
.share-meter span { display: block; height: 100%; border-radius: 6px; background: var(--c1); }

.chart-card { padding: 18px; }
.donut { display: block; width: 168px; height: 168px; margin: 0 auto 14px; }
.donut .arc { cursor: pointer; transition: stroke-width .12s ease; }
.donut .arc.hover { stroke-width: 24; }
.donut-label { font-size: 10px; fill: var(--muted); font-family: var(--font); }
.donut-value { font-size: 14px; fill: var(--text); font-family: var(--display); font-weight: 500; }
.legend { display: flex; flex-direction: column; gap: 10px; }
.legend-row { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 10px; font-size: 14px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; }
.legend-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-val { text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }
.legend-val small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }

.bars { display: block; width: 100%; height: auto; overflow: visible; }
.bars .bar { fill: var(--c1); }
.bars rect[data-tip] { cursor: pointer; }
.bars .baseline { stroke: var(--line); stroke-width: 1; }
.axis-label { font-size: 10px; fill: var(--muted); font-family: var(--font); }
.bar-label { font-size: 10px; fill: var(--text-2); font-family: var(--font); font-weight: 500; }

.paid-bars { display: flex; flex-direction: column; gap: 14px; }
.paid-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) auto; align-items: center; gap: 12px; font-size: 14px; }
.paid-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.paid-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.paid-track { height: 8px; border-radius: 8px; background: var(--surface-2); overflow: hidden; }
.paid-track span { display: block; height: 100%; border-radius: 8px; background: var(--c2); }
.paid-amt { font-weight: 500; font-variant-numeric: tabular-nums; text-align: right; }

#chart-tip {
  position: fixed; z-index: 40; transform: translate(-50%, -100%); pointer-events: none;
  background: var(--text); color: var(--bg); font-size: 12.5px; font-weight: 500;
  padding: 6px 10px; border-radius: 8px; white-space: nowrap; opacity: 0; transition: opacity .12s ease;
  box-shadow: var(--shadow-lg);
}
#chart-tip.show { opacity: 1; }

/* ---------- round 6b: tiles, avatar stack, balance cards ---------- */
.tile-btn {
  position: relative; display: flex; align-items: center; gap: 12px;
  min-height: 64px; padding: 10px 14px; border-radius: var(--radius-sm); cursor: pointer; text-align: left;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); color: var(--text); overflow: hidden;
}
.tile-btn:hover { border-color: var(--surface-3); }
.tile-btn > svg { width: 22px; height: 22px; color: var(--muted); flex: none; }
.tile-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.tile-text small { font-size: 12px; color: var(--muted); }
.tile-text b { font-weight: 500; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar.small { width: 30px; height: 30px; font-size: 11.5px; }

.avatar-stack { display: flex; align-items: center; margin: 2px 0 16px 4px; min-width: 0; }
.avatar-stack .avatar { margin-left: -8px; box-shadow: 0 0 0 2px var(--bg); }
.avatar-stack .avatar:first-child { margin-left: 0; }
.avatar-stack .more { background: var(--surface-2); color: var(--text-2); }
.stack-names { margin-left: 10px; font-size: 13.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.balance-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.balance-card { padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.balance-top { display: flex; align-items: flex-start; gap: 12px; }
.balance-main { flex: 1; min-width: 0; }
.balance-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.pill { font-size: 13px; font-weight: 500; padding: 3px 10px; border-radius: 999px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pill-owed { background: var(--owed-soft); color: var(--owed); }
.pill-owe { background: var(--owe-soft); color: var(--owe); }
.pill-settled { background: var(--surface-2); color: var(--muted); }
.balance-toggle { display: inline-flex; align-items: center; gap: 4px; align-self: flex-start; font-size: 13px; }
.balance-toggle .chev { display: grid; transition: transform .15s ease; }
.balance-toggle .chev svg { width: 14px; height: 14px; }
.balance-card.open .balance-toggle .chev { transform: rotate(180deg); }
.balance-details { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; color: var(--text-2); padding-top: 8px; border-top: 1px solid var(--line); }
.balance-details b { font-weight: 500; color: var(--text); }
.balance-invite { align-self: flex-start; font-size: 13px; }

.plan-row .title { white-space: normal; }

/* ---------- round 7: sentences instead of boxes, people lists with tree lines ---------- */
.summary-text { font-size: 17px; line-height: 1.5; margin: 2px 4px 0; color: var(--text-2); }
.summary-text b { font-weight: 600; font-variant-numeric: tabular-nums; }
.footnote { font-size: 12px; color: var(--muted); margin: 18px 4px 0; }
.amount.inline { display: inline; text-align: left; }

.people-list { padding: 4px 0; }
.person-block + .person-block { border-top: 1px solid var(--line); }
.people-list .row { padding-top: 14px; padding-bottom: 14px; }
.people-list .row::before { display: none; }
.person-name { font-size: 16.5px; }
.tree { position: relative; margin: -6px 16px 14px 35px; padding-left: 0; display: flex; flex-direction: column; }
.tree-row { position: relative; padding: 5px 0 5px 22px; font-size: 13.5px; color: var(--text-2); line-height: 1.4; }
.tree-row b { font-weight: 600; font-variant-numeric: tabular-nums; }
/* Thin connector lines: a vertical spine with an elbow into each line. */
.tree-row::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 1px; background: var(--line); }
.tree-row:last-child::before { bottom: 50%; }
.tree-row::after { content: ''; position: absolute; left: 0; top: 50%; width: 14px; height: 1px; background: var(--line); }
.summary-tree { margin: 8px 0 0 10px; }

.hero-icons { display: flex; justify-content: center; gap: 10px; margin-top: 14px; }
.icon-btn.danger { color: var(--danger); }
.icon-btn.danger:hover { color: var(--danger); }

/* The two round actions in the corner. */
.fab, .fab.secondary { background: #9f2b68; color: #fff; border: 0; }
.fab:hover, .fab.secondary:hover { background: #8d245b; filter: none; }

@media (pointer: fine) { .date-pill input[type=date] { pointer-events: none; } }

/* ---------- round 8: conversion checkbox, management ---------- */
.check-row { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line); cursor: pointer; }
.check-row input { width: 19px; height: 19px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.check-row b { font-weight: 500; display: block; }
.check-row small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; line-height: 1.45; }
.badge { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); vertical-align: 2px; }
a.row.card { border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }

/* ---------- round 9: compact conversion checkbox with a "?" ---------- */
.check-row { align-items: center; justify-content: space-between; padding: 12px 14px; cursor: default; }
.check-row label { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.help {
  position: relative; flex: none; width: 24px; height: 24px; border-radius: 50%; cursor: help;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text-2); font-size: 13px; font-weight: 600;
}
/* Shown on hover, or on tap (the button takes focus). */
.help:hover::after, .help:focus::after {
  content: attr(data-help); position: absolute; right: -6px; bottom: calc(100% + 8px); z-index: 30;
  width: 250px; padding: 10px 12px; border-radius: 10px; text-align: left;
  background: var(--text); color: var(--bg); font-size: 12.5px; font-weight: 400; line-height: 1.45;
  box-shadow: var(--shadow-lg);
}
.row-2 > *, .row-2 .input { min-width: 0; }
