/* Buckets: calm, plain and warm. Paper tones, no red, nothing like a statement. */

:root {
  --bg: #f6f1ea;
  --surface: #fffcf8;
  --ink: #2e2a25;
  --muted: #6f655a;
  --line: #e6dccf;
  --accent: #4d7a61;
  --accent-strong: #3b634d;
  --on-accent: #ffffff;
  --accent-soft: #e2ece4;
  --warm: #8a4f20;
  --warm-soft: #f5e6d6;
  --cardc: #4f6288;
  --card-soft: #e5e9f1;
  --danger: #a2493a;
  --focus: rgba(77, 122, 97, 0.45);
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(70, 50, 30, 0.05), 0 6px 20px rgba(70, 50, 30, 0.05);
  --tabs-h: 66px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1b19;
    --surface: #282522;
    --ink: #efe8df;
    --muted: #ada296;
    --line: #3b3631;
    --accent: #8fbf9f;
    --accent-strong: #a6d0b3;
    --on-accent: #142019;
    --accent-soft: #2b3a31;
    --warm: #e0a774;
    --warm-soft: #3d3027;
    --cardc: #a3b3d3;
    --card-soft: #2d3343;
    --danger: #e08f7f;
    --focus: rgba(143, 191, 159, 0.5);
    --shadow: none;
    color-scheme: dark;
  }
}

/* Pink: the same paper and the same contrast, in rose instead of sage. Every
   token the light block sets is set again for dark, because a [data-theme]
   rule outranks the plain dark :root above and would otherwise leak into it.
   test/contrast.test.mjs measures every text pair in all four combinations. */
:root[data-theme="pink"] {
  --bg: #f8f0ee;
  --surface: #fffbfa;
  --ink: #2f2729;
  --muted: #705e66;
  --line: #ecdad6;
  --accent: #a8456e;
  --accent-strong: #8a3258;
  --on-accent: #ffffff;
  --accent-soft: #f6e1e9;
  --focus: rgba(168, 69, 110, 0.45);
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="pink"] {
    --bg: #1f1b1c;
    --surface: #2a2426;
    --ink: #f0e7e9;
    --muted: #ac9ca2;
    --line: #3d3437;
    --accent: #e8a0bc;
    --accent-strong: #f3bdd1;
    --on-accent: #2b141e;
    --accent-soft: #3e2a33;
    --focus: rgba(232, 160, 188, 0.5);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
body.locked { overflow: hidden; }
.app { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { width: 22px; height: 22px; flex: none; vertical-align: middle; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px 16px;
  background: var(--bg);
}
.top h1 { flex: 1; min-width: 0; font-size: 1.35rem; margin: 0; font-weight: 650; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 0; border-radius: 12px; background: transparent; color: var(--muted); cursor: pointer; padding: 0;
}
.icon-btn:hover:not(:disabled) { background: var(--accent-soft); }
.icon-btn:disabled { opacity: 0.3; cursor: default; }

.main { display: grid; gap: 14px; padding: 4px 16px calc(var(--tabs-h) + env(safe-area-inset-bottom) + 28px); }

/* ---------- cards and text ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-size: 1.05rem; margin: 0 0 10px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.card h2 .ic { width: 20px; height: 20px; color: var(--muted); }
h2.with-total { justify-content: space-between; }
h2.with-total .link { margin: -8px -8px -8px auto; font-size: 0.92rem; font-weight: 500; }
h2.with-total span { margin-left: auto; font-weight: 500; color: var(--muted); font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.card > p { margin: 0 0 10px; }
.card > :last-child { margin-bottom: 0; }
h3 { font-size: 0.95rem; margin: 18px 0 6px; color: var(--muted); font-weight: 650; }
.label { margin: 0; color: var(--muted); font-size: 0.85rem; display: flex; align-items: center; gap: 6px; }
.label .ic { width: 18px; height: 18px; }
.big { font-size: 1.7rem; font-weight: 650; margin: 2px 0; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.mid { font-size: 1.3rem; font-weight: 600; margin: 2px 0 0; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.9rem; margin: 0 0 10px; }
.fine { color: var(--muted); font-size: 0.8rem; }
.center { text-align: center; }
.small { font-size: 0.85rem; }
.warm-text { color: var(--warm); }
.good { color: var(--accent-strong); }
.note { background: var(--warm-soft); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 0.92rem; margin: 0 0 12px; }
.note-card { background: var(--warm-soft); border-color: transparent; box-shadow: none; }
/* A notice reads across the card, with its button full width underneath. */
.notice { background: var(--accent-soft); border-color: transparent; box-shadow: none; }
.notice.warm { background: var(--warm-soft); }
.empty { display: flex; align-items: center; gap: 10px; color: var(--muted); margin: 0; }
.empty .ic { color: var(--accent); }
.status { display: flex; align-items: center; gap: 8px; color: var(--accent-strong); font-weight: 600; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 16px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 600; cursor: pointer; text-decoration: none; text-align: center;
}
.btn .ic { width: 20px; height: 20px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.small { min-height: 40px; padding: 6px 14px; font-size: 0.92rem; border-radius: 12px; }
.btn.block { display: flex; width: 100%; }
.btn.danger { color: var(--danger); }
.btn.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-row .btn { flex: 1 1 auto; }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 4px; }
.link { background: none; border: 0; color: var(--accent-strong); text-decoration: underline; padding: 8px; cursor: pointer; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }

:is(.btn, .icon-btn, .row, .tab, .plan-opt, .step, .seg-btn, .link, .fillrow, .toast-undo):focus-visible,
:is(input, select):focus-visible {
  outline: 3px solid var(--focus); outline-offset: 2px;
}

/* ---------- lists ---------- */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li + li { border-top: 1px solid var(--line); }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 11px 2px; border: 0; background: none; text-align: left; cursor: pointer; color: inherit;
}
.row .when { flex: none; width: 82px; color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.row .what { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.row .what > .ic { width: 17px; height: 17px; color: var(--muted); margin-right: 4px; }
.row .what small { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 0.82rem; }
.row .what small .ic { width: 15px; height: 15px; }
.row .amt { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chip { display: inline-flex; align-items: center; gap: 3px; font-size: 0.74rem; font-weight: 650; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.chip .ic { width: 13px; height: 13px; }
.chip.ok { background: var(--accent-soft); color: var(--accent-strong); }
.chip.warm { background: var(--warm-soft); color: var(--warm); }
.sum { margin: 10px 0 0; font-size: 0.92rem; color: var(--muted); }
.sum strong { color: var(--ink); }
.sum strong.warm-text { color: var(--warm); }
.rows.plain .line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.rows.plain .line.total { font-weight: 650; }
.line .amt { font-variant-numeric: tabular-nums; white-space: nowrap; }

.steps { list-style: none; margin: 0; padding: 0; }
.step { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 8px 2px; border: 0; background: none; text-align: left; cursor: pointer; color: inherit; }
.step .ic { color: var(--muted); }
.steps .done .step { color: var(--muted); text-decoration: line-through; }
.steps .done .ic { color: var(--accent); }





/* ---------- the fill: buckets as bars, filling in order ---------- */
.fills { list-style: none; margin: 0 0 12px; padding: 0; }
.fills li { display: flex; align-items: center; gap: 10px; }
.fills li + li { border-top: 1px solid var(--line); }
.fillrow { flex: 1; min-width: 0; display: grid; gap: 8px; padding: 15px 2px; border: 0; background: none; text-align: left; color: inherit; cursor: pointer; }
.row-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.fillrow .name { display: flex; align-items: center; gap: 6px; min-width: 0; font-weight: 650; overflow-wrap: anywhere; }
.fillrow .name .ic { width: 17px; height: 17px; color: var(--muted); }
.fillrow .amt { flex: none; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fillrow .amt small { font-weight: 500; color: var(--muted); }
.fillrow .sub { color: var(--muted); font-size: 0.82rem; }
.bar { display: block; height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar span {
  display: block; height: 100%; border-radius: 99px; background: var(--accent);
  transition: width 0.7s cubic-bezier(0.2, 0.7, 0.2, 1); transition-delay: calc(var(--i, 0) * 120ms);
}
.bar.open span { background: var(--accent-soft); }
.order { display: flex; flex-direction: column; justify-content: center; gap: 4px; padding-left: 8px; border-left: 1px solid var(--line); }

/* ---------- waiting for a tap ---------- */
.prompts { background: var(--accent-soft); border-color: transparent; box-shadow: none; }
.prompt { padding: 10px 0; }
.prompt + .prompt { border-top: 1px solid var(--line); }
.prompt p { margin: 0 0 8px; }
.prompt-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.prompt-actions .money-input { background: var(--surface); }
.prompts .err { display: block; margin-top: 6px; }

/* ---------- inside a bucket ---------- */
.outline { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--accent-soft); }
.outline .ic { width: 20px; height: 20px; margin-top: 1px; color: var(--accent-strong); }
.items .item-name { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.items .item-name > span { min-width: 0; overflow-wrap: anywhere; }
.small-x { width: 34px; height: 34px; }
.small-x .ic { width: 16px; height: 16px; }
.item-add { display: grid; gap: 8px; margin: 10px 0 6px; }
.item-add-row { display: flex; align-items: center; gap: 8px; }
.item-add-row > input { flex: 1; min-width: 0; min-height: 42px; }
.item-add .money-input.small { width: 112px; }
.out-date { display: flex; align-items: center; gap: 6px; flex: 1 1 180px; min-width: 0; }
.out-date span { white-space: nowrap; }
.out-date input { flex: 1; min-width: 0; min-height: 42px; padding: 6px 8px; }

/* ---------- debt plan ---------- */
.plans { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.plan-opt {
  display: grid; gap: 2px; padding: 12px 6px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--surface); color: inherit; text-align: center; cursor: pointer;
}
.plan-opt.on { border-color: var(--accent); background: var(--accent-soft); }
.plan-opt .yrs { font-weight: 700; }
.plan-opt .pay { font-weight: 650; font-size: 1rem; font-variant-numeric: tabular-nums; }
.plan-opt .pay small { display: block; font-weight: 400; color: var(--muted); font-size: 0.74rem; }
.plan-opt .int, .plan-opt .end { font-size: 0.76rem; color: var(--muted); }
.plan-opt .int { font-size: 0.85rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.plan-opt .int small { display: block; font-size: 0.74rem; font-weight: 400; }
.chart-wrap { margin: 4px 0 12px; }
.chart { display: block; width: 100%; height: 110px; }
.chart .area { fill: var(--accent-soft); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.chart-axis { display: flex; justify-content: space-between; gap: 8px; font-size: 0.78rem; color: var(--muted); margin-top: 4px; }
.try { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; }
.try .field { margin-bottom: 8px; }

/* ---------- the lump check ---------- */
.verdict { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; margin: 4px 0; }
.verdict .ic { width: 26px; height: 26px; margin-top: 1px; }
.verdict p { margin: 2px 0 0; }
.verdict.yes { background: var(--accent-soft); }
.verdict.yes .ic { color: var(--accent-strong); }
.verdict.part, .verdict.no { background: var(--warm-soft); }
.verdict.part .ic, .verdict.no .ic { color: var(--warm); }
.sums { margin-top: 10px; border-top: 1px solid var(--line); }
.record { border-top: 1px solid var(--line); margin-top: 12px; }
.inline-form { display: flex; gap: 10px; }
.inline-form .money-input { flex: 1; min-width: 0; }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; margin: 0 0 14px; min-width: 0; }
.lbl { font-size: 0.88rem; color: var(--muted); font-weight: 650; }
.lbl i { font-weight: 400; font-style: normal; }
input:not([type]), input[type="text"], input[type="date"], select {
  width: 100%; min-width: 0; min-height: 48px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg); font-size: 16px;
}
input[type="date"] { -webkit-appearance: none; appearance: none; display: block; }
select {
  -webkit-appearance: none; appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23948a7e' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 20px;
}
.money-input { display: flex; align-items: center; min-width: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); padding-left: 12px; }
.money-input .cur { color: var(--muted); font-weight: 600; }
.money-input input { flex: 1; border: 0; background: transparent; min-height: 48px; padding-left: 6px; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.money-input:focus-within { outline: 3px solid var(--focus); outline-offset: 1px; }
.money-input input:focus-visible { outline: none; }
.money-input.small { flex: none; width: 124px; }
.money-input.small input { min-height: 42px; font-size: 1rem; }
.err { color: var(--danger); font-size: 0.85rem; font-style: normal; }
.err:empty { display: none; }
.err.block { display: block; margin: 0 0 10px; }
.check { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 14px; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; flex: none; accent-color: var(--accent); }
.check small { display: block; color: var(--muted); font-size: 0.85rem; }
.seg { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.seg legend { padding: 0; margin-bottom: 6px; }
.seg-row { display: flex; gap: 8px; }
.seg-opt { flex: 1; min-width: 0; position: relative; }
.seg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg-opt span {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 4px 8px; line-height: 1.2;
  border: 1.5px solid var(--line); border-radius: 12px; font-weight: 600; cursor: pointer; text-align: center;
}
.seg-opt span .ic { width: 19px; height: 19px; }
.seg-opt input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.seg-opt input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.seg-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); font-weight: 600; cursor: pointer;
}
.seg-btn.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.tabs-like { margin-bottom: 12px; }
.choices { display: grid; gap: 8px; margin-bottom: 14px; }
.choice { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 12px; border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; }
.choice input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.actions { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.actions .btn { width: 100%; }

.fill-lines { list-style: none; padding: 0; margin: 0 0 8px; }
.fill-lines li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.fill-lines .name { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 650; overflow-wrap: anywhere; }
.fill-lines .name .ic { width: 18px; height: 18px; color: var(--muted); }
.fill-lines small { display: block; font-weight: 400; color: var(--muted); font-size: 0.8rem; }
.left { margin: 8px 0 12px; }

/* ---------- first run ---------- */
.welcome, .setup { display: grid; gap: 14px; padding: calc(env(safe-area-inset-top) + 28px) 16px 40px; }
/* Set it up shows without scrolling on a small phone: a short gap at the top,
   three short lines, then the button. Looking around with example numbers is
   a quiet link at the foot, there for whoever wants it. */
.welcome { text-align: center; padding-top: calc(env(safe-area-inset-top) + 28px); padding-bottom: 32px; }
.welcome .start { display: grid; gap: 8px; margin-top: 4px; }
.welcome .start .hint { margin: 0; }
.welcome .link.quiet { justify-self: center; padding: 8px; color: var(--muted); font-size: 0.88rem; }
.welcome h1, .setup h1 { font-size: 2rem; margin: 0; letter-spacing: -0.01em; }
.setup h1 { font-size: 1.6rem; }
.mark { display: grid; place-items: center; width: 84px; height: 84px; margin: 0 auto; border-radius: 26px; background: var(--accent-soft); color: var(--accent-strong); }
.mark .ic { width: 46px; height: 46px; }
.lede { font-size: 1.05rem; color: var(--muted); margin: 0; }
.flow { list-style: none; padding: 0; margin: 4px 0 0; display: grid; gap: 10px; text-align: left; }
.flow li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line); }
.flow .ic { color: var(--accent-strong); margin-top: 1px; }
.promises { list-style: none; padding: 0; margin: 4px 0 0; display: grid; gap: 8px; text-align: left; }
.promises li { display: flex; gap: 10px; align-items: flex-start; }
.promises .ic { color: var(--accent); }
.setup form { display: grid; gap: 14px; }
.setup h1:focus { outline: none; }
/* Where setup is: a bar per step, filled once it's reached. */
.progress { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.progress li { padding-top: 7px; border-top: 4px solid var(--line); font-size: 0.82rem; font-weight: 650; color: var(--muted); }
.progress li.done, .progress li.on { border-top-color: var(--accent); }
.progress li.on { color: var(--accent-strong); }
.progress li.skipped { border-top-style: dashed; border-top-color: var(--muted); }
.step-count { margin: -4px 0 -6px; font-size: 0.85rem; color: var(--muted); }
.step-nav { display: flex; justify-content: space-between; gap: 8px; margin-top: -6px; }
.step-nav .btn.ghost:first-child { padding-left: 0; margin-left: -6px; } /* the chevron's own whitespace */
.step-nav .btn.ghost:last-child { padding-right: 0; }
.added .line > span:first-child { flex: 1; min-width: 0; overflow-wrap: anywhere; }
label.plan-opt { cursor: pointer; }
.plan-opt:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
[data-show="setup-second"] { border-top: 1px solid var(--line); padding-top: 14px; }
.setup-buckets { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.setup-buckets > li { display: flex; gap: 12px; align-items: flex-start; padding-top: 14px; border-top: 1px solid var(--line); }
.setup-buckets .check { margin: 13px 0 0; }
.setup-buckets .grow { flex: 1; display: grid; gap: 10px; min-width: 0; }
/* A debt's bucket is named for the debt: its name is shown, not typed. */
.setup-buckets .fixed-name { margin: 0; padding: 12px 0 0; font-weight: 600; }
.setup-buckets .picks, .setup-buckets .grow p { margin: 0; }
/* A date field won't shrink below about 160px, so the date wraps under the amount on a phone. */
.setup-buckets .row2 { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.setup-buckets .row2 select { flex: 1; }

/* ---------- tabs ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 2px;
  max-width: 560px; margin: 0 auto; padding: 6px 6px calc(env(safe-area-inset-bottom) + 6px);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px;
  padding: 4px 0; border: 0; border-radius: 12px; background: none; color: var(--muted);
  font-size: 0.72rem; font-weight: 650; cursor: pointer; white-space: nowrap;
}
.tab.on { color: var(--accent-strong); background: var(--accent-soft); }

/* ---------- sheets ---------- */
.sheet-wrap {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(30, 24, 18, 0.38); animation: fade 0.18s ease-out;
}
.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: 92vh; max-height: 92dvh;
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 22px 22px 0 0;
  padding: 20px 16px calc(env(safe-area-inset-bottom) + 22px);
  animation: rise 0.22s ease-out;
}
.sheet h2 { font-size: 1.25rem; margin: 2px 48px 12px 0; display: flex; align-items: center; gap: 8px; }
.sheet h2:focus { outline: none; }
.sheet h2 .ic { color: var(--muted); }
.sheet .close { position: absolute; top: 10px; right: 8px; }
.detail .big { margin-top: 0; }
@media (min-width: 600px) {
  .sheet-wrap { align-items: center; }
  .sheet { border-radius: 22px; }
}
@keyframes rise { from { transform: translateY(24px); } }
@keyframes fade { from { background-color: rgba(30, 24, 18, 0); } }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px); z-index: 30;
  max-width: calc(100% - 32px); width: max-content; padding: 10px 16px; border-radius: 14px;
  background: var(--ink); color: var(--bg); font-size: 0.92rem;
  opacity: 0; transform: translate(-50%, 12px); pointer-events: none; transition: opacity 0.2s, transform 0.2s;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast { display: flex; align-items: center; gap: 14px; }
.toast.with-undo.on { pointer-events: auto; }
.toast-undo { flex: none; min-height: 32px; padding: 4px 2px; border: 0; background: none; color: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet-wrap { animation: none; }
  .toast, .bar span { transition: none; }
}

/* ---------- the plan's length, half a year at a time ---------- */
.stepper { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; gap: 8px; padding: 8px; margin-bottom: 10px; border-radius: 14px; border: 1.5px solid var(--accent); background: var(--accent-soft); }
.step-value { display: grid; gap: 2px; text-align: center; }
.step-value strong { font-size: 1.25rem; }
.step-value small { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.step-btn { background: var(--surface); border: 1px solid var(--line); }
.step-btn:disabled { opacity: 0.4; }

/* ---------- adding a bucket, where it can be seen ---------- */
/* Under the buckets, set apart from them by a line, with room between the rows. */
.bucket-actions { display: grid; gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.add-bucket { border: 1.5px dashed var(--accent); background: transparent; color: var(--accent-strong); }

/* ---------- the debt check's nudge toward the plan ---------- */
.lump div.note, .sheet div.note { display: grid; gap: 8px; padding: 12px 14px; margin: 8px 0; border-radius: 14px; background: var(--accent-soft); }
.sheet div.note p { margin: 0; }

/* ---------- coming up: occasions to save for ---------- */
.rows.plain .occasion { align-items: center; flex-wrap: wrap; }
.occasion > span:first-child { flex: 1 1 160px; min-width: 0; }
.occasion-acts { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
/* Add a birthday sits under a line, apart from the holidays, and compact,
   centred between that line and the card's bottom edge: 8px each side, as
   the holidays have under their lines. */
.card.coming-up { padding-bottom: 8px; }
.add-line { padding-top: 8px; }
.add-line .btn { width: 100%; min-height: 34px; padding-block: 2px; }

/* ---------- a savings floor ---------- */
.floor-line { display: grid; gap: 8px; padding: 12px 14px; margin: 8px 0; border-radius: 14px; background: var(--accent-soft); }
.floor-line p { margin: 0; }
.floor-line.warm { background: var(--warm-soft); }
.floor-note { margin: 4px 0 8px; }

/* ---------- round amounts to start from ---------- */
.picks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.picks .pick { min-height: 36px; padding: 0 14px; font-variant-numeric: tabular-nums; }

/* ---------- the bucket screen, with room ----------
   Even space between groups; each hint kept with the control it explains;
   the kind picker two by two, so no word is squeezed; and the buttons set
   apart by a line, as under the buckets on Home. */
.roomy { display: grid; gap: 20px; }
.roomy h2 { margin-bottom: 0; }
.roomy .group { display: grid; gap: 10px; }
.roomy .field, .roomy .seg, .roomy .check, .roomy .hint, .roomy p { margin: 0; }
.roomy .picks { margin-top: 10px; }
.kinds .seg-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.roomy .actions { flex-direction: column; align-items: stretch; gap: 12px; margin: 4px 0 0; padding-top: 18px; border-top: 1px solid var(--line); }
.roomy .actions .btn { flex: none; width: 100%; }

/* Tips and other income, under a line below the pay: a row with an arrow.
   Open, it's added; closed, it says None. */
.more-income { margin-top: 18px; border-top: 1px solid var(--line); }
.disclose { border-bottom: 1px solid var(--line); }
.disclose > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 12px 2px; cursor: pointer; font-weight: 700; font-size: 1.05rem; }
.disclose > summary::-webkit-details-marker { display: none; }
.disclose > summary .ic { flex: none; color: var(--muted); transition: transform 0.2s ease; }
.disclose[open] > summary .ic { transform: rotate(180deg); }
.disclose-title small { display: block; margin-top: 2px; font-weight: 400; font-size: 0.85rem; color: var(--muted); }
.disclose[open] .when-closed { display: none; }
.disclose-body { display: grid; gap: 12px; padding: 2px 0 16px; }
.disclose-body > .hint { margin: 0; }
.disclose-body > .link { justify-self: start; margin: -4px -8px 0; }
@media (prefers-reduced-motion: reduce) { .disclose > summary .ic { transition: none; } }

/* Buttons line up with the text beside them. A button on its own in a card
   spans the card, so its edge can't read as an indent; a sheet's buttons
   stack full width; a ghost button left alone on a grid row takes the row;
   and setup's Back and Skip put their words on the text's edges. */
.card > .btn { display: flex; width: 100%; }
.btn-grid .btn.ghost:last-child:nth-child(odd) { grid-column: 1 / -1; }

/* ---------- the list of bills: in setup, and on the Bills tab ---------- */
/* Smaller rows than a bucket's, so they read as parts of one bucket: a name
   that edits in place like a label, an outlined amount, and a dotted line
   at the bottom that becomes the next real one. */
.bill-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.bill { display: flex; align-items: center; gap: 10px; }
/* The name: a label that edits in place, its text on the list's left edge,
   underlined, with the × at its right end. Nothing reaches past the edges. */
.bill-name-box { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; }
.bill-list input.bill-name {
  flex: 1; min-width: 0; min-height: 40px; margin: 0; padding: 6px 36px 6px 0;
  border: 0; border-bottom: 1.5px solid var(--line); border-radius: 0; background: transparent;
  color: var(--ink); font: inherit; font-size: 1rem;
}
.bill-list input.bill-name:focus, .bill-list input.bill-name:focus-visible { border-bottom-color: var(--accent); outline: none; }
.bill-name-box .small-x { position: absolute; right: -4px; top: 50%; transform: translateY(-50%); }
.bill-amt.money-input { flex: none; width: 108px; background: transparent; border: 1.5px solid var(--muted); border-radius: 10px; padding-left: 10px; }
.bill-amt.money-input input { min-height: 38px; font-size: 1rem; }
.bill-add {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 42px; padding: 6px 10px;
  border: 1.5px dashed var(--line); border-radius: 10px; background: none;
  color: var(--muted); font: inherit; font-size: 0.95rem; font-weight: 600; text-align: left; cursor: pointer;
}
.bill-add .ic { width: 18px; height: 18px; }
.bill-new { margin-top: 4px; }
.bills-head { display: grid; gap: 10px; }
.bills-head h2 { margin: 0; }
.bills-head .amt small { font-weight: 500; color: var(--muted); }
.bills-head .sub { margin: 0; color: var(--muted); font-size: 0.85rem; }
/* Under the Bills total, "Fills from a list" opens the list. While it has
   lines, the total is theirs and can't be typed over. */
.bill-items { margin-top: 2px; }
.bill-items > summary { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; color: var(--accent-strong); font-weight: 600; font-size: 0.92rem; cursor: pointer; list-style: none; }
.bill-items > summary::-webkit-details-marker { display: none; }
.bill-items > summary .ic { width: 18px; height: 18px; transition: transform 0.2s ease; }
.bill-items[open] > summary .ic { transform: rotate(180deg); }
.setup-buckets .bill-items > .hint, .bill-items > .hint { margin: 0 0 8px; }
input[data-bills-total]:read-only { color: var(--muted); }
/* Add a bucket, kind Bills: the way onto the list instead. */
.to-bills { display: grid; gap: 10px; padding: 12px; border-radius: 12px; background: var(--bg); }
.to-bills p { margin: 0; font-size: 0.92rem; }
@media (prefers-reduced-motion: reduce) { .bill-items > summary .ic { transition: none; } }

/* ---------- debts: tap one to edit it ---------- */
.debt-row .ic.go { flex: none; width: 18px; height: 18px; margin-left: 2px; color: var(--muted); }
/* Under a debt's edit screen: what pays it, and its latest changes, small. */
.debt-more { display: grid; gap: 6px; }
.debt-more .hint { margin: 0; }
.debt-more .row { font-size: 0.92rem; }

/* ---------- money: in and out, newest first ---------- */
.money-quick { margin: 0 0 4px; }
.row .amt.in { color: var(--accent-strong); }
h2.with-total .io { display: flex; gap: 10px; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
h2.with-total .io .in { color: var(--accent-strong); }
.money-empty { margin: 4px 2px; }
/* The line under a Money row can run long: it wraps like text, and the place
   (bank or cash) moves to the next line whole instead of breaking mid-word. */
.row .what small.money-sub { display: block; }
.row .what small .where { white-space: nowrap; }
.row .what small .where .ic { margin-right: 4px; }
/* Money: what you have in all, and bank and cash side by side under it. */
.money-total h2 { margin-bottom: 8px; }
.money-total h2 .sum { font-size: 1.3rem; font-weight: 650; color: var(--ink); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.split p { margin: 0; }
.split .v { font-size: 1.05rem; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
/* Home's overview: three short lines, then Money in and Spent. */
.glance .row { padding: 8px 2px; }
.glance .quick { margin-top: 10px; }
.glance .amt small { font-size: 0.72rem; font-weight: 500; color: var(--muted); }
div.row { cursor: default; }
/* A quiet way on from a sheet, under its hint: Move money's "Took cash out
   of the bank?" opens Bank and cash. */
.link.aside { display: block; margin: -8px -8px 8px; font-size: 0.92rem; }
/* Bills and each debt's payment bucket are built in: when it goes out,
   small, with a link to change it. */
.out-line { margin: 0; color: var(--muted); font-size: 0.9rem; }
.out-line .link { padding: 6px 0; margin: -6px 0; font-size: inherit; }
.debt-more > .btn { justify-self: start; }
