/* Ex-Expenses: light, EX Expenses orange (#ff9f1c) with near-black ink, Liquid Glass nav. */
:root {
  --bg: #f7f3ea;
  --panel: #ffffff;
  --panel-2: #f2eadb;
  --line: #e3d9c4;
  --text: #17140e;
  --muted: #6a6152;
  --brand: #ff9f1c;
  --brand-ink: #10140a;
  --accent: #9a4d00;
  --warn: #d23f2a;
  --display: "Unbounded", "Onest", system-ui, sans-serif;
  --body: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 18px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(900px 480px at 85% -10%, rgba(255, 159, 28, .38), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 400 16px/1.5 var(--body);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
h1, h2, h3, p, ul, fieldset { margin: 0; padding: 0; }
ul { list-style: none; }
fieldset { border: 0; min-width: 0; }
[hidden] { display: none !important; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.page { max-width: 1040px; margin: 0 auto; padding: 20px 16px 130px; }
.pagehead { padding: 14px 0 22px; }
h1 { font: 700 clamp(1.5rem, 5vw, 2.1rem)/1.15 var(--display); letter-spacing: -.02em; }
h2 { font: 600 1.05rem/1.3 var(--body); margin-bottom: 12px; }
h3 { font: 600 .95rem/1.3 var(--body); color: var(--muted); margin: 22px 0 10px; }
.quiet { color: var(--muted); max-width: 60ch; }
.block > .quiet + form { margin-top: 16px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }

/* ---------- month header ---------- */
.monthbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0 6px; }
.monthbar h1 { text-align: center; flex: 1; }
.step {
  width: 44px; height: 44px; display: grid; place-items: center; flex: none;
  border-radius: 50%; border: 1px solid var(--line); background: var(--panel);
}
.step svg, .glassnav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.step:hover { border-color: var(--accent); color: var(--accent); }
.today { text-align: center; font-size: .9rem; }
.today a { color: var(--accent); }

.cols { display: grid; gap: 18px; margin-top: 18px; }
@media (min-width: 900px) {
  .cols { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; gap: 28px; }
  .col-summary { position: sticky; top: 20px; }
}
.col-summary { display: grid; gap: 18px; }

/* ---------- the share: the one loud thing ---------- */
.share {
  background: var(--brand); color: var(--brand-ink);
  border-radius: 26px; padding: 22px 22px 20px;
}
.share-label { font-weight: 600; opacity: .72; }
.share-part { padding-top: 14px; margin-top: 16px; border-top: 1px solid rgba(16, 20, 10, .2); }
.share-label + .share-part { border-top: 0; margin-top: 4px; padding-top: 0; }
.share-kicker { font: 700 .78rem/1.2 var(--display); letter-spacing: .06em; text-transform: uppercase; }
.share-figure {
  font: 700 clamp(2.6rem, 13vw, 4.2rem)/1 var(--display);
  letter-spacing: -.04em; margin: 8px 0 6px;
  font-variant-numeric: tabular-nums;
}
.share-note { font-size: .9rem; opacity: .75; margin-top: 4px; }
.share-row + .share-row { margin-top: 16px; }
.share-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 10px; font-weight: 600; }
.share-line b { font: 700 1.5rem/1.1 var(--display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.share-state {
  display: inline-block; margin-top: 10px; padding: 8px 14px;
  background: var(--brand-ink); color: var(--brand);
  border-radius: 999px; font-weight: 600;
}
.share-pay { display: grid; grid-template-columns: minmax(0, 7.2rem) minmax(0, 1fr); gap: 8px; margin-top: 12px; }
.share-pay input:not([type=radio]):not([type=checkbox]) { background: rgba(255, 255, 255, .75); border-color: rgba(16, 20, 10, .25); }
.share-pay .btn { padding: 0 12px; overflow: hidden; text-overflow: ellipsis; }
.share-hint { font-size: .85rem; opacity: .72; margin-top: 14px; }
.share-marks { margin-top: 6px; font-size: .92rem; }
.share-marks li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 5px 0; }
.share-marks b { font-weight: 700; font-variant-numeric: tabular-nums; }
.share-marks .link { color: var(--brand-ink); }
.btn.dark { background: var(--brand-ink); border-color: var(--brand-ink); color: var(--brand); white-space: nowrap; }
.btn.dark:hover { filter: brightness(1.4); }
.btn.ghost { background: transparent; border-color: var(--brand-ink); color: var(--brand-ink); white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- blocks ---------- */
.block { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.page > .block { margin-bottom: 18px; max-width: 720px; }

.people li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; column-gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.people li:first-child { border-top: 0; }
.people .who { font-weight: 600; }
.people .paid { color: var(--muted); font-variant-numeric: tabular-nums; }
.people .paid.done { color: var(--accent); font-weight: 600; }
.people .items { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 2px; font-size: .9rem; color: var(--muted); }
.people .paid:not(.done) { color: var(--warn); font-weight: 600; }
.people .items.owes { color: var(--warn); }
.people .items b { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }

.quiet.small { font-size: .88rem; margin: -6px 0 8px; }
.transfers li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); color: var(--muted); }
.transfers li:first-child { border-top: 0; }
.transfers li.mine { color: var(--text); font-weight: 600; }
.transfers b { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- expenses ---------- */
.suggest button {
  width: 100%; text-align: left; cursor: pointer; margin-bottom: 10px;
  background: transparent; border: 1px dashed var(--accent); color: var(--accent);
  border-radius: 14px; padding: 12px 14px;
}
.suggest button:hover { background: rgba(255, 159, 28, .3); }
.expenses li { border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.expenses .expense { flex: 1; min-width: 0; }
.receipt { flex: none; width: 44px; height: 44px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.receipt img { width: 100%; height: 100%; object-fit: cover; display: block; }
.receipt:hover { border-color: var(--accent); }
input[type=file] { padding: 9px 10px; color: var(--muted); }
input[type=file]::file-selector-button { margin-right: 12px; padding: 6px 14px; border: 0; border-radius: 999px; background: var(--panel-2); color: var(--text); font: inherit; font-weight: 600; }
.photo-current { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: .9rem; }
.photo-current a { color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: 18px; min-height: 18px; height: 18px; padding: 0; accent-color: var(--accent); }
.expenses li:first-child { border-top: 0; }
.expense {
  display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 12px;
  width: 100%; padding: 12px 4px; text-align: left; background: none; border: 0; border-radius: 12px;
}
button.expense { cursor: pointer; }
button.expense:hover { background: var(--panel-2); }
.ico { width: 44px; height: 44px; display: grid; place-items: center; background: var(--panel-2); border-radius: 13px; font-size: 1.25rem; }
.what { min-width: 0; }
.what b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.what small { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; color: var(--muted); font-size: .85rem; }
.what em { font-style: normal; border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; }
.what time::before { content: ""; }
.amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- history ---------- */
.yearhead { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 22px 0 10px; color: var(--muted); font-weight: 500; }
.yearhead span:first-child { font: 700 1.2rem var(--display); color: var(--text); }
.months { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); max-width: 720px; }
.months li + li { border-top: 1px solid var(--line); }
.months a { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 14px 18px; text-decoration: none; }
.months a:hover { background: var(--panel-2); }
.m-name { font-weight: 600; }
.m-total { font-weight: 600; font-variant-numeric: tabular-nums; }
.m-bar { grid-column: 1 / -1; height: 6px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.m-bar i { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.m-each, .m-state { color: var(--muted); font-size: .88rem; }
.m-state { text-align: right; }
.m-state.open { color: var(--warn); }

/* ---------- forms ---------- */
.stack { display: grid; gap: 14px; }
.row2 { display: grid; gap: 14px; }
@media (min-width: 520px) { .row2 { grid-template-columns: 1fr 1fr; } }
label, legend { display: grid; gap: 6px; font-size: .9rem; color: var(--muted); font-weight: 500; }
input:not([type=radio]):not([type=checkbox]), select {
  width: 100%; min-height: 48px; padding: 10px 14px; font-size: 16px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 13px; color: var(--text);
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 159, 28, .4); }
input::placeholder { color: #a79d8b; }
.money { position: relative; display: block; }
.money::before { content: "£"; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.money input:not([type=radio]):not([type=checkbox]) { padding-left: 30px; font-weight: 600; font-variant-numeric: tabular-nums; }

.btn {
  min-height: 48px; padding: 0 20px; cursor: pointer;
  border-radius: 999px; border: 1px solid var(--line); background: var(--panel-2);
  color: var(--text); font-weight: 600;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--brand); border-color: var(--accent); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--warn); background: transparent; }
.btn.danger:hover { border-color: var(--warn); }
.btn.small { min-height: 40px; padding: 0 16px; font-size: .9rem; }
.link { background: none; border: 0; padding: 4px 0; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.cats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.cats legend { margin-bottom: 6px; }
.cats label { display: block; cursor: pointer; }
.cats input { position: absolute; opacity: 0; pointer-events: none; }
.cats span {
  display: grid; justify-items: center; gap: 2px; padding: 10px 4px;
  border: 1px solid var(--line); border-radius: 13px; background: var(--bg);
  font-size: .72rem; color: var(--muted); text-align: center; line-height: 1.2; height: 100%;
}
.cats i { font-style: normal; font-size: 1.3rem; }
.cats input:checked + span { border-color: var(--brand-ink); color: var(--brand-ink); background: var(--brand); font-weight: 600; }
.cats input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- settings ---------- */
.members { margin-bottom: 6px; }
.members li { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 4px 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.members li:first-child { border-top: 0; }
.members .who { font-weight: 600; }
.members small { display: block; color: var(--muted); font-weight: 400; overflow-wrap: anywhere; }
.members details { grid-column: 2; }
.members summary { color: var(--accent); cursor: pointer; font-size: .9rem; width: fit-content; }
.members details form { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.members details input { flex: 1 1 160px; min-height: 40px; }
.signout { margin-top: 18px; }

/* ---------- sign in ---------- */
.auth { max-width: 400px; margin: 0 auto; padding: 12vh 20px 60px; }
.auth h1 { font-size: 2rem; margin-bottom: 8px; }
.auth .lede { color: var(--muted); margin-bottom: 28px; }
.auth-logo { display: block; width: 170px; height: auto; margin: 0 0 26px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.langs { display: flex; gap: 18px; margin-top: 26px; font-size: .9rem; }
.langs a { color: var(--muted); }
.langs a[aria-current] { color: var(--accent); text-decoration: none; }

/* ---------- flash ---------- */
.flash {
  position: fixed; z-index: 30; left: 50%; top: calc(14px + env(safe-area-inset-top)); transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 11px 18px; border-radius: 999px;
  background: var(--brand); color: var(--brand-ink); font-weight: 600;
  box-shadow: 0 10px 30px rgba(20, 26, 16, .18); transition: opacity .4s, transform .4s;
}
.flash-err { background: var(--warn); color: #fff; }
.flash.gone { opacity: 0; transform: translate(-50%, -12px); pointer-events: none; }

/* ---------- Liquid Glass nav ---------- */
.glassnav {
  position: fixed; z-index: 20; left: 50%; transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 4px;
  width: min(430px, calc(100% - 24px)); padding: 8px;
  border-radius: 32px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .85), rgba(255, 255, 255, .5));
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, .9);
  box-shadow: inset 0 1px 0 #fff, 0 0 0 1px rgba(20, 26, 16, .06), 0 16px 36px rgba(20, 26, 16, .18);
}
.glassnav a {
  display: grid; justify-items: center; gap: 2px; padding: 8px 4px;
  border-radius: 24px; text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 500;
}
.glassnav a[aria-current] { color: var(--brand-ink); background: rgba(255, 159, 28, .75); }
.glassnav a.add {
  order: 0; width: 54px; height: 54px; padding: 0; place-items: center; margin: 0 4px;
  background: var(--brand-ink); color: var(--brand); border-radius: 50%;
  box-shadow: 0 6px 18px rgba(20, 26, 16, .28);
}
.glassnav a.add svg { width: 26px; height: 26px; stroke-width: 2.4; }

/* ---------- add / edit sheet ---------- */
.sheet {
  width: min(520px, 100%); max-width: 100%; max-height: 92dvh; overflow: auto;
  margin: auto auto 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
  border: 1px solid var(--line); border-bottom: 0; border-radius: 26px 26px 0 0;
  background: var(--panel); color: var(--text);
}
.sheet::backdrop { background: rgba(20, 26, 16, .4); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.sheet[open] { animation: rise .22s ease-out; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
.sheet h2 { font: 700 1.2rem var(--display); margin-bottom: 4px; }
.sheet-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.sheet-actions .primary { flex: 1 1 160px; }
@media (min-width: 640px) {
  .sheet { margin: auto; border-radius: 26px; border-bottom: 1px solid var(--line); padding: 26px; }
}

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

/* ---------- installer ---------- */
.install { max-width: 720px; padding-bottom: 60px; }
.install .block { margin-bottom: 0; }
.install > .block { margin-bottom: 18px; }
.install .auth-logo { margin: 14px 0 0; width: 130px; }
.install .quiet + .stack { margin-top: 14px; }
.install-go { margin-top: 18px; }
.install-go .btn { display: inline-grid; place-items: center; text-decoration: none; }
.checks li { display: flex; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.checks li:first-child { border-top: 0; }
.checks span { font-weight: 700; color: var(--accent); }
.checks .bad span, .checks .bad b { color: var(--warn); }
.checks small { display: block; color: var(--muted); }
.errors { border-color: var(--warn); }
.errors li { color: var(--warn); padding: 3px 0; }

/* ---------- loading screen ---------- */
.loader {
  position: fixed; inset: 0; z-index: 60; display: grid; place-content: center; justify-items: center; gap: 22px;
  padding: 24px; text-align: center; background: var(--bg);
  opacity: 0; visibility: hidden; transition: opacity .2s, visibility 0s .2s;
}
.loading .loader { opacity: 1; visibility: visible; transition: opacity .2s .25s, visibility 0s .25s; }
.loader img { width: 150px; height: auto; }
.loader i { width: 150px; height: 5px; border-radius: 999px; background: var(--panel-2); overflow: hidden; position: relative; }
.loader i::after {
  content: ""; position: absolute; inset: 0 60% 0 0; border-radius: 999px; background: var(--brand);
  animation: loader-run 1.1s ease-in-out infinite alternate;
}
@keyframes loader-run { to { inset: 0 0 0 60%; } }
.loader p { color: var(--muted); max-width: 30ch; }
.loader .btn { margin-top: 12px; }
@media (prefers-reduced-motion: reduce) { .loader i::after { animation: none; inset: 0 30% 0 30%; } }

/* ---------- reminders: Home Screen icon, notifications ---------- */
.nudges { max-width: 1040px; margin: 0 auto; padding: 14px 16px 0; display: grid; gap: 10px; }
.nudges:empty { display: none; }
.nudge {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px;
  padding: 12px 12px 12px 16px; border-radius: var(--r); background: var(--brand-ink); color: #fff;
}
.nudge p { font-size: .92rem; line-height: 1.35; }
.nudge .btn { min-height: 40px; padding: 0 16px; background: var(--brand); border-color: var(--brand); color: var(--brand-ink); white-space: nowrap; }
.nudge .x { width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .12); color: #fff; font-size: 1.2rem; line-height: 1; cursor: pointer; }
.steps { counter-reset: step; display: grid; gap: 12px; margin: 4px 0 6px; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; }
.steps li::before { content: counter(step); width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-weight: 700; }
.steps svg { width: 18px; height: 18px; vertical-align: -3px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.appstate li { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--line); }
.appstate li:first-child { border-top: 0; padding-top: 0; }
.appstate b { display: block; font-weight: 600; }
.appstate small { color: var(--muted); display: block; max-width: 34ch; }
.appstate .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.rowlink { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; margin-bottom: 18px; max-width: 720px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); text-decoration: none; font-weight: 600; }
.rowlink:hover { border-color: var(--accent); }
.rowlink svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.today a + a { margin-left: 16px; }
