@font-face { font-family: 'Fraunces'; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(fonts/fraunces-latin-opsz-normal.woff2) format('woff2-variations'), url(fonts/fraunces-latin-opsz-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'DM Sans'; font-style: normal; font-display: swap; font-weight: 100 1000;
  src: url(fonts/dm-sans-latin-wght-normal.woff2) format('woff2-variations'), url(fonts/dm-sans-latin-wght-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
/* Layout: one phone-width column, centered on wide screens. Scrolling screen on top, three-tab bar at the bottom of the column (hidden during first-time setup). */
:root {
  --bg: #F7F3EA;
  --surface: #FFFDF8;
  --line: #E9E0CF;
  --line-strong: #D8CDB6;
  --ink: #2B332E;
  --muted: #5F6B63;
  --sage: #7C9A87;
  --sage-deep: #3F5B4B;
  --sage-tint: #DCE6DD;
  --plan-bg: #E3ECE5;
  --on-deep: #FFFDF8;
  --warn: #A5543A;
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151A17;
    --surface: #1E2521;
    --line: #2F3832;
    --line-strong: #3C4740;
    --ink: #ECE9E0;
    --muted: #A3AEA6;
    --sage: #8FB09B;
    --sage-deep: #A9CDB6;
    --sage-tint: #26332B;
    --plan-bg: #22302A;
    --on-deep: #12201A;
    --warn: #E39C82;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #151A17;
  --surface: #1E2521;
  --line: #2F3832;
  --line-strong: #3C4740;
  --ink: #ECE9E0;
  --muted: #A3AEA6;
  --sage: #8FB09B;
  --sage-deep: #A9CDB6;
  --sage-tint: #26332B;
  --plan-bg: #22302A;
  --on-deep: #12201A;
  --warn: #E39C82;
  color-scheme: dark;
}

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
}
button, input, select { font-family: inherit; }
[hidden] { display: none !important; }

.app {
  box-sizing: border-box;
  height: 100%;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.screens {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-block: 28px 24px;
  padding-left: max(24px, env(safe-area-inset-left, 0px));
  padding-right: max(24px, env(safe-area-inset-right, 0px));
}
.screen { display: flex; flex-direction: column; gap: 18px; }

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 28px;
  line-height: 1.15;
  text-wrap: balance;
}
h1:focus { outline: none; }
.sub { margin: -8px 0 0; font-size: 15px; color: var(--muted); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.eyebrow, .card p.eyebrow {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sage-deep);
}
.card p { margin: 0; font-size: 15px; color: var(--muted); }
.card p.lead { color: var(--ink); font-size: 16px; }

/* Form */
form { display: flex; flex-direction: column; gap: 20px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
legend, .label { padding: 0; font-size: 14px; font-weight: 600; color: var(--ink); }
.hint { font-size: 13px; font-weight: 400; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 14px; font-weight: 600; }
.field label.quiet { font-size: 13px; font-weight: 400; color: var(--muted); }

.chips { display: flex; gap: 10px; }
.chip {
  flex: 1;
  min-height: 48px;
  padding: 0 8px;
  border-radius: 14px;
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--sage-deep); border-color: var(--sage-deep); color: var(--on-deep); }

.text, .money, .select {
  box-sizing: border-box;
  min-height: 48px;
  width: 100%;
  border-radius: 14px;
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}
.text, .select { padding: 0 14px; font-size: 16px; }
.money { display: flex; align-items: center; gap: 4px; min-height: 52px; padding: 0 14px; }
.money span { font-size: 18px; color: var(--muted); }
.money input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 20px;
  font-weight: 600;
}
.money input::placeholder, .text::placeholder { color: var(--muted); opacity: 0.8; font-weight: 400; }
.text:focus-visible, .select:focus-visible { outline: 2px solid var(--sage-deep); outline-offset: 1px; border-color: var(--sage-deep); }
.money:focus-within { border-color: var(--sage-deep); outline: 2px solid var(--sage-deep); outline-offset: 1px; }
.has-error .money, .has-error .select, .has-error .text { border-color: var(--warn); }
.err { margin: 0; font-size: 13px; line-height: 1.4; color: var(--warn); }

.amounts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }

.seg { display: flex; gap: 4px; padding: 4px; border-radius: 16px; background: var(--line); }
.seg button {
  flex: 1;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; }

.plan {
  border-radius: 18px;
  background: var(--plan-bg);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.plan .eyebrow { text-transform: none; letter-spacing: 0; font-size: 13px; }
.plan .figure { font-family: var(--font-display); font-weight: 600; font-size: 30px; line-height: 1.15; }
.plan .detail { font-size: 14px; color: var(--muted); }
.plan .detail.warn { color: var(--warn); }
.plan .waiting { font-size: 15px; color: var(--muted); }

.btn {
  min-height: 54px;
  border-radius: 16px;
  border: 0;
  background: var(--sage-deep);
  color: var(--on-deep);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
}
.btn.secondary { min-height: 50px; background: transparent; border: 1.5px solid var(--sage-deep); color: var(--sage-deep); font-size: 16px; }
.btn:focus-visible, .chip:focus-visible, .seg button:focus-visible, .tab:focus-visible { outline: 2px solid var(--sage-deep); outline-offset: 2px; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* Plan ready */
.badge { width: 56px; height: 56px; border-radius: 50%; background: var(--sage-tint); display: flex; align-items: center; justify-content: center; }
.badge svg { width: 28px; height: 28px; fill: none; stroke: var(--sage-deep); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.rows { display: flex; flex-direction: column; margin: 0; }
.rows div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.rows div:last-child { border-bottom: 0; }
.rows dt { color: var(--muted); }
.rows dd { margin: 0; font-weight: 600; text-align: right; }
.goal-name { font-family: var(--font-display); font-weight: 600; font-size: 22px; line-height: 1.2; color: var(--ink); overflow-wrap: anywhere; }

/* Dashboard */
.dash-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dash-head h1 { font-size: 26px; overflow-wrap: anywhere; }
.icon-btn {
  flex: none; width: 44px; height: 44px; padding: 0; border-radius: 50%;
  border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--sage-deep);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:focus-visible, .textbtn:focus-visible { outline: 2px solid var(--sage-deep); outline-offset: 2px; }
.ring-block { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.ring { position: relative; width: 156px; height: 156px; }
.ring svg { display: block; width: 156px; height: 156px; }
.ring .track { stroke: var(--line); }
.ring .arc { stroke: var(--sage); }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-pct { font-family: var(--font-display); font-weight: 600; font-size: 42px; line-height: 1; }
.ring-sub { margin-top: 4px; font-size: 13px; color: var(--muted); }
.saved-line { margin: 0; display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 8px; }
.saved-line strong { font-family: var(--font-display); font-weight: 600; font-size: 30px; line-height: 1.1; }
.saved-line span { font-size: 15px; color: var(--muted); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.label-sage { font-size: 13px; font-weight: 600; color: var(--sage-deep); }
.status-chip { font-size: 12px; font-weight: 600; border-radius: 999px; padding: 4px 10px; background: var(--sage-tint); color: var(--sage-deep); white-space: nowrap; }
.status-chip.later { background: var(--line); color: var(--ink); }
.big-date { font-family: var(--font-display); font-weight: 600; font-size: 28px; line-height: 1.15; color: var(--ink); }
.card p.note { font-size: 14px; }
.bar { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar > div { height: 100%; border-radius: 999px; background: var(--sage); }
.ms-title { font-size: 14px; font-weight: 600; }
.ms-togo { font-size: 14px; color: var(--muted); }
.deposits { display: flex; flex-direction: column; gap: 2px; }
.deposits h2 { margin: 0 0 4px; font-size: 14px; font-weight: 600; }
.dep-list { list-style: none; margin: 0; padding: 0; }
.dep-list li { display: flex; justify-content: space-between; align-items: center; min-height: 40px; border-bottom: 1px solid var(--line); font-size: 15px; }
.dep-list li:last-child { border-bottom: 0; }
.dep-list .amt { font-weight: 600; color: var(--sage-deep); }
.empty { margin: 0; font-size: 14px; color: var(--muted); }
.textbtn { align-self: center; min-height: 44px; padding: 0 12px; border: 0; background: transparent; color: var(--sage-deep); font-size: 14px; font-weight: 600; text-decoration: underline; cursor: pointer; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.devnote { margin: -6px 0 0; font-size: 13px; color: var(--muted); text-align: center; }

/* Log a deposit */
.dep-head { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 8px; }
.dep-head h1 { font-size: 22px; text-align: center; }
.goal-pill { margin: 0; align-self: center; max-width: 100%; box-sizing: border-box; font-size: 13px; font-weight: 600; text-align: center; overflow-wrap: anywhere; color: var(--sage-deep); background: var(--sage-tint); border-radius: 999px; padding: 6px 14px; }
.amount-box { min-height: 76px; border-radius: 18px; border-color: var(--sage-deep); padding: 0 18px; gap: 6px; }
.amount-box span { font-family: var(--font-display); font-size: 34px; font-weight: 500; }
.amount-box input { font-family: var(--font-display); font-size: 44px; font-weight: 600; }
.quick { display: flex; gap: 8px; margin-top: 4px; }
.quick button { flex: 1; min-width: 0; min-height: 44px; border-radius: 12px; border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink); font-size: 15px; font-weight: 600; cursor: pointer; }
.quick button[aria-pressed="true"] { background: var(--sage-deep); border-color: var(--sage-deep); color: var(--on-deep); }
.quick button:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--sage-deep); outline-offset: 2px; }
.text[type="date"] { box-sizing: border-box; height: 52px; min-height: 52px; padding-block: 0; font-size: 17px; line-height: 1.2; display: flex; align-items: center; text-align: left; -webkit-appearance: none; appearance: none; }
.text[type="date"]::-webkit-date-and-time-value { text-align: left; margin: 0; min-height: 1.2em; }
.text[type="date"]::-webkit-datetime-edit { padding: 0; }
.text[type="date"]::-webkit-calendar-picker-indicator { margin-left: auto; }
.text[type="date"]::-webkit-datetime-edit-fields-wrapper { padding: 0; }
#dep-preview { gap: 12px; }
.plan-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.plan-row .k { font-size: 14px; color: var(--muted); }
.plan-row .val { font-family: var(--font-display); font-weight: 600; font-size: 20px; text-align: right; }
.plan .gain { font-size: 14px; font-weight: 600; color: var(--sage-deep); }

/* All deposits + edit */
.dep-title-row { display: flex; align-items: center; justify-content: space-between; min-height: 28px; }
.dep-title-row h2 { margin: 0; }
.see-all { min-height: 44px; margin: -8px 0; padding: 0 0 0 12px; border: 0; background: transparent; color: var(--sage-deep); font-size: 14px; font-weight: 600; cursor: pointer; }
.see-all:focus-visible, .all-row:focus-visible { outline: 2px solid var(--sage-deep); outline-offset: 2px; }
.all-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.all-list li { border-bottom: 1px solid var(--line); }
.all-list li:last-child { border-bottom: 0; }
.all-row { width: 100%; min-height: 56px; box-sizing: border-box; display: flex; align-items: center; gap: 12px; padding: 0 16px 0 18px; border: 0; background: transparent; color: var(--ink); font-size: 16px; text-align: left; cursor: pointer; }
.all-row .d { flex: 1; }
.all-row .a { font-weight: 600; color: var(--sage-deep); }
.all-row svg { flex: none; width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn.secondary.danger { color: var(--warn); border-color: var(--line-strong); }
.btn.warn { background: var(--warn); color: var(--on-deep); }
.confirm-box { border-radius: 18px; background: var(--surface); border: 1.5px solid var(--warn); padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.confirm-box p { margin: 0; font-size: 15px; }

/* Welcome */
.welcome .hero { display: flex; flex-direction: column; align-items: center; gap: 12px; padding-top: 4px; text-align: center; }
.welcome h1 { font-size: 32px; }
.welcome .tag { margin: 0; font-size: 16px; color: var(--muted); }
.welcome .card { padding: 20px; gap: 14px; }
.welcome .card h2 { margin: 0; font-family: var(--font-display); font-weight: 500; font-size: 21px; line-height: 1.2; }
.welcome .card .notice { padding: 12px 14px; border-radius: 14px; background: var(--plan-bg); color: var(--ink); font-size: 14px; line-height: 1.4; }
.steps { list-style: none; counter-reset: s; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.steps li { counter-increment: s; display: flex; align-items: flex-start; gap: 12px; font-size: 15px; line-height: 1.4; }
.steps li::before { content: counter(s); flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--sage-tint); color: var(--sage-deep); font-weight: 600; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.steps li span { padding-top: 3px; }
.privacy { display: flex; align-items: center; gap: 10px; margin: 0; padding: 0 4px; font-size: 14px; line-height: 1.4; color: var(--muted); }
.privacy svg { flex: none; width: 20px; height: 20px; fill: none; stroke: var(--sage-deep); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.fine { margin: 0; font-size: 13px; line-height: 1.4; text-align: center; color: var(--muted); }

/* Settings + restore */
.set-line { margin: 0; }
.backup-status { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.backup-status .dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--line-strong); }
.backup-status.ok .dot { background: var(--sage); }
textarea.text { display: block; padding: 12px 14px; min-height: 104px; line-height: 1.4; font-size: 14px; resize: vertical; }
textarea.text[readonly] { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
input.filepick { padding: 10px 14px; font-size: 14px; }
.disclaimer { margin: 4px 0 0; font-size: 13px; text-align: center; color: var(--muted); }
.card p.msg { font-size: 14px; color: var(--sage-deep); font-weight: 600; }

/* Calendar */
.cal-finish { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; }
.cal-finish-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal-finish .big-date { font-size: 26px; }
.btn.cal-toggle { flex: none; min-height: 44px; padding: 0 14px; border-radius: 12px; font-size: 14px; white-space: nowrap; }
.cal-card { padding: 14px 10px 16px; gap: 8px; }
.cal-nav { display: flex; align-items: center; justify-content: space-between; }
.cal-title { font-family: var(--font-display); font-weight: 600; font-size: 21px; }
.icon-btn.flat { border: 0; background: transparent; }
table.cal { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal th { padding: 4px 0; font-size: 12px; font-weight: 600; color: var(--muted); }
.cal td { padding: 2px 0; text-align: center; }
.cal .day { position: relative; box-sizing: border-box; width: 100%; max-width: 40px; aspect-ratio: 1 / 1; margin: 0 auto; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 15px; color: var(--ink); }
.cal .day.dep { background: var(--sage-tint); border: 1px solid var(--sage); color: var(--sage-deep); font-weight: 600; }
.cal .day.fin { background: var(--sage-deep); color: var(--on-deep); font-weight: 600; }
.cal .day.today { font-weight: 700; }
.cal .day.today::after { content: ""; position: absolute; bottom: 5px; width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: center; padding-top: 8px; }
.cal-legend span { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.cal-legend i { display: block; width: 16px; height: 16px; border-radius: 50%; box-sizing: border-box; }
.cal-legend .k-dep { background: var(--sage-tint); border: 1px solid var(--sage); }
.cal-legend .k-fin { background: var(--sage-deep); }
.cal-legend .k-today { width: 4px; height: 4px; background: var(--ink); margin: 0 6px; }

/* Milestone celebration */
.celebrate { align-items: center; text-align: center; padding-top: 12px; }
.celebrate h1 { font-size: 30px; }
.cel-hero { width: 100%; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.cel-eyebrow { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--sage-deep); }
.cel-msg { margin: 0; max-width: 34ch; font-size: 16px; color: var(--muted); }
.cel-badge { position: relative; width: 150px; height: 150px; }
.cel-badge svg.ring-svg { display: block; width: 100%; height: 100%; }
.cel-badge .track { stroke: var(--line); }
.cel-badge .arc { stroke: var(--sage); transition: stroke-dashoffset 900ms ease-out; }
.cel-center { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 600; font-size: 40px; }
.cel-center svg { width: 56px; height: 56px; fill: none; stroke: var(--sage-deep); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.celebrate.big .cel-hero { width: 100%; box-sizing: border-box; border-radius: 28px; background: var(--sage-tint); padding: 28px 16px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.celebrate.big .cel-badge { width: 176px; height: 176px; animation: cel-pop 600ms ease-out; }
.celebrate.big h1 { font-size: 36px; }
.celebrate .card { width: 100%; box-sizing: border-box; text-align: left; }
.celebrate .btn { width: 100%; }
@keyframes cel-pop { 0% { transform: scale(0.85); opacity: 0.4; } 100% { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .cel-badge .arc { transition: none; }
  .celebrate.big .cel-badge { animation: none; }
}

/* Tab bar */
.tabbar {
  display: flex;
  justify-content: space-around;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-top: 8px;
  padding-bottom: 14px;
  padding-left: max(24px, env(safe-area-inset-left, 0px));
  padding-right: max(24px, env(safe-area-inset-right, 0px));
}
.tab {
  min-width: 72px;
  min-height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--sage-deep); font-weight: 600; }
.tab[aria-current="page"] svg { stroke-width: 2; }

/* Standalone page basics */
:root { color-scheme: light; }
html { box-sizing: border-box; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); -webkit-text-size-adjust: 100%; }
@supports (height: 100dvh) { html, body { height: 100dvh; } }
