:root {
  --bg: #f3ede3;
  --paper: #fffbf5;
  --ink: #14241e;
  --muted: #3a4a43;
  --line: #e4d7c6;
  --green: #0c5c46;
  --green-soft: #e4f3ec;
  --clay: #8a3d12;
  --warn-bg: #f8ebd6;
  --warn-ink: #5c3208;
  --danger: #8b1e1e;
  --gold: #f2c14e;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --shadow: 0 12px 30px rgba(20, 36, 30, 0.06);
  --radius: 18px;
}

* { box-sizing: border-box; }

fieldset { border: 0; margin: 0; padding: 0; min-inline-size: 0; }

summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  font-weight: 700;
  cursor: pointer;
}

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background-color: var(--bg);
  background-image: radial-gradient(rgba(20, 36, 30, 0.04) 0.7px, transparent 0.7px);
  background-size: 8px 8px;
  font-family: var(--sans);
  font-size: 1.125rem;
  line-height: 1.5;
  padding-bottom: calc(5.25rem + env(safe-area-inset-bottom));
}

body:focus { outline: none; }

img, svg { max-width: 100%; }

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

a:hover { text-decoration-thickness: 2px; }

.skip {
  position: absolute;
  left: 0.75rem;
  top: -4rem;
  background: var(--paper);
  color: var(--ink);
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
  z-index: 50;
}

.skip:focus { top: 0.6rem; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem 0.2rem;
  max-width: 48rem;
  margin: 0 auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.35rem;
  min-height: 48px;
}

.mark { width: 2rem; height: 2rem; display: block; }

.wrap {
  width: min(100% - 2rem, 40rem);
  margin: 0 auto;
  padding-bottom: 2rem;
}

h1, h2, h3 {
  font-family: var(--serif);
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.02em;
}

h1 { font-size: clamp(1.85rem, 7.4vw, 2.6rem); margin: 0.15rem 0 0.45rem; }

h2 { font-size: 1.55rem; margin: 1.6rem 0 0.55rem; }

h3 { font-size: 1.2rem; margin: 0 0 0.25rem; }

p { margin: 0.4rem 0 0.8rem; }

.kicker {
  margin: 0.75rem 0 0;
  color: var(--green);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.82rem;
}

.lead { font-size: 1.2rem; }

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

.fine { color: var(--muted); font-size: 1rem; }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  margin: 0.8rem 0;
}

.card h2:first-child,
.card h3:first-child { margin-top: 0; }

.callout {
  background: var(--green-soft);
  border: 1px solid #b7dccb;
  border-radius: var(--radius);
  padding: 1rem;
  margin: 0.8rem 0;
}

.callout.clay {
  background: #fbf1ea;
  border-color: #e4c8b6;
}

.banner {
  border-radius: 14px;
  padding: 0.8rem 0.9rem;
  margin: 0.6rem 0 1rem;
}

.banner.warn { background: var(--warn-bg); color: var(--warn-ink); }

.banner.good { background: var(--green-soft); color: var(--green); }

.action {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--paper);
  border: 2px solid var(--green);
  border-radius: 20px;
  padding: 0.85rem 1rem 0.95rem;
  margin: 0.6rem 0;
  box-shadow: var(--shadow);
  min-height: 48px;
}

.action.alt { border-color: var(--clay); }

.action-title {
  display: block;
  font-family: var(--serif);
  font-size: 1.7rem;
  line-height: 1.15;
  margin: 0.15rem 0 0.3rem;
}

.action-text { display: block; color: var(--muted); }

.hero-num {
  font-family: var(--serif);
  font-size: clamp(3.1rem, 14vw, 4.6rem);
  line-height: 0.9;
  color: var(--clay);
  margin: 0.2rem 0;
  letter-spacing: -0.03em;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin: 0.8rem 0;
}

.stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.8rem;
  margin: 0;
}

.stat span, .stat small { display: block; color: var(--muted); font-size: 0.98rem; }

.stat b {
  display: block;
  font-family: var(--serif);
  font-size: 1.45rem;
  line-height: 1.15;
  margin: 0.15rem 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 48px;
  padding: 0.7rem 1rem;
  border-radius: 14px;
  border: 2px solid transparent;
  background: transparent;
  color: var(--green);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  text-align: center;
}

.btn-primary { background: var(--green); color: #fff; }

.btn-secondary { border-color: var(--green); background: var(--paper); }

.btn-danger { border-color: var(--danger); color: var(--danger); background: var(--paper); }

.btn-quiet { color: var(--muted); border-color: transparent; }

.btn-block { width: 100%; }

.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.6rem 0; }

.btn-row .btn { flex: 1 1 9rem; }

.tip-qr {
  display: block;
  width: min(100%, 18rem);
  height: auto;
  margin: 0.85rem auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.4rem;
}

.field { margin: 0.75rem 0; }

.field label, .legend {
  display: block;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.hint { display: block; color: var(--muted); font-weight: 400; margin-top: 0.2rem; }

input[type="text"],
input[type="email"],
input[type="url"],
input[type="date"],
input[type="number"],
select {
  width: 100%;
  min-height: 48px;
  padding: 0.55rem 0.75rem;
  border: 2px solid #c9bba8;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.choice { position: relative; display: block; margin: 0.5rem 0; }

.choice input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.choice span {
  display: block;
  min-height: 48px;
  padding: 0.8rem 0.9rem;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
}

.choice strong { display: block; }

.choice small { display: block; color: var(--muted); font-size: 1rem; }

.choice input:checked + span {
  border-color: var(--green);
  background: var(--green-soft);
}

.choice input:focus-visible + span {
  outline: 3px solid var(--green);
  outline-offset: 3px;
}

.seg { display: flex; gap: 0.5rem; }

.seg label { flex: 1; }

.check {
  display: block;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  margin: 0.55rem 0;
}

.check label {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.check input {
  width: 1.5rem;
  height: 1.5rem;
  margin-top: 0.15rem;
  flex: none;
  accent-color: var(--green);
}

.check .btn { margin-top: 0.65rem; }

.check-title { display: block; font-weight: 700; }

.progress {
  height: 0.55rem;
  background: #e7dccb;
  border-radius: 999px;
  overflow: hidden;
  margin: 0.4rem 0 0.8rem;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--green);
  width: 0;
}

.error { color: var(--danger); font-weight: 700; min-height: 1.5em; }

.debt, .lock-item {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.9rem;
  margin: 0.6rem 0;
}

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.4rem 0; }

.chips button { min-height: 44px; }

table { width: 100%; border-collapse: collapse; }

th, td {
  text-align: left;
  vertical-align: top;
  padding: 0.7rem 0.45rem;
  border-bottom: 1px solid var(--line);
}

th { font-size: 0.95rem; }

tr.is-you { background: var(--green-soft); }

.legend { list-style: none; padding: 0; margin: 0.4rem 0; display: flex; flex-wrap: wrap; gap: 0.8rem 1rem; }

.legend li { display: flex; align-items: center; gap: 0.4rem; }

.swatch { width: 2rem; height: 0; border-top: 3px solid var(--green); display: inline-block; }

.swatch.dashed { border-top: 3px dashed var(--clay); }

.chart { background: #fff; border-radius: 12px; padding: 0.2rem; }

.chart svg { width: 100%; height: auto; display: block; }

.month-list { padding-left: 1.2rem; }

.month-list li { margin: 0.35rem 0; }

.source-list { padding-left: 1.15rem; }

.source-list li { margin: 0.35rem 0; }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  background: var(--paper);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabbar a {
  flex: 1;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.tabbar a svg { width: 1.4rem; height: 1.4rem; }

.tabbar a[aria-current="page"] { color: var(--green); }

.footer {
  width: min(100% - 2rem, 40rem);
  margin: 1rem auto 0;
  padding: 0.5rem 0 1rem;
  color: var(--muted);
}

.footer-nav { display: flex; flex-wrap: wrap; gap: 0.15rem 0.4rem; }

.footer-nav a {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  padding: 0 0.35rem;
  font-weight: 700;
}

dialog {
  border: none;
  border-radius: 18px;
  padding: 1.15rem;
  width: min(26rem, calc(100% - 2rem));
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
}

dialog::backdrop { background: rgba(20, 36, 30, 0.5); }

dialog h2 { margin-top: 0; }

.confetti {
  pointer-events: none;
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 30;
}

.confetti i {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  animation: fall 1.15s ease-in forwards;
}

@keyframes fall {
  to { transform: translateY(105vh) rotate(200deg); opacity: 0.15; }
}

.print-only { display: none; }

@media (min-width: 720px) {
  .stats.three { grid-template-columns: 1fr 1fr 1fr; }
  .split { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
  .split .card { margin: 0; }
}

@media (min-width: 860px) {
  body { padding-bottom: 0; }
  .tabbar {
    position: sticky;
    top: 0;
    bottom: auto;
    max-width: 48rem;
    margin: 0 auto;
    border: 1px solid var(--line);
    border-radius: 999px;
    margin-top: 0.4rem;
  }
  .wrap, .footer { width: min(100% - 3rem, 46rem); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .confetti { display: none; }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media print {
  body { background: #fff; padding: 0; font-size: 12pt; }
  .tabbar, .top, .footer, .no-print, .confetti { display: none !important; }
  .print-only { display: block !important; }
  .wrap { width: auto; }
  a { color: #000; }
}
