/* Kvitt — warm paper, one rust accent for what costs money, one green for progress. */

:root {
  color-scheme: light;
  --ground: #f7f4ee;
  --surface: #ffffff;
  --ink: #201a15;
  --ink-dark: #2b241e;
  --muted: #6b6157;
  --faint: #8a7f72;
  --line: #e6dfd4;
  --line-soft: #eee7dc;
  --rust: #a4503c;
  --rust-deep: #7d3a2b;
  --rust-tint: #f2e2db;
  --rust-edge: #e2c8bd;
  --green: #1f7a5f;
  --green-deep: #2d5c4c;
  --green-tint: #dfeae5;
  --green-edge: #c6dbd2;
  --sand: #e8dfd0;
  --radius: 16px;
  --sans: Archivo, "Helvetica Neue", Arial, sans-serif;
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--rust); }
a:hover { color: var(--rust-deep); }

.num { font-variant-numeric: tabular-nums; }
.serif { font-family: var(--serif); font-weight: 400; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.right { text-align: right; }

.app {
  max-width: 460px;
  margin: 0 auto;
  padding: 0 22px 108px;
}

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 30px 0 0;
}

.wordmark {
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1;
  letter-spacing: -0.01em;
}

.kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}

.display {
  font-family: var(--serif);
  font-size: 52px;
  line-height: 0.95;
  letter-spacing: -0.015em;
}

.display--sm { font-size: 38px; }

h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 28px;
  line-height: 1.1;
}

p { margin: 0; line-height: 1.6; }

.stack { display: flex; flex-direction: column; }
.stack > * + * { margin-top: var(--gap, 14px); }
.gap-6 { --gap: 6px; }
.gap-10 { --gap: 10px; }
.gap-18 { --gap: 18px; }
.gap-24 { --gap: 24px; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.row--between { justify-content: space-between; }
.row--baseline { align-items: baseline; }
.grow { flex-grow: 1; }

.section { padding-top: 26px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 17px 18px;
}
.card--dark { background: var(--ink); border-color: var(--ink); color: var(--ground); }
.card--rust { background: var(--rust-tint); border-color: var(--rust-edge); color: var(--rust-deep); }
.card--green { background: var(--green-tint); border-color: var(--green-edge); color: var(--green-deep); }
.card--dashed { background: none; border: 1px dashed #d5cbbc; }
a.card { color: var(--ink); text-decoration: none; display: block; }

.tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 6px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.tag--rust { color: var(--rust-deep); background: var(--rust-tint); }
.tag--green { color: #4a6b5e; background: var(--green-tint); }

.split {
  display: flex;
  height: 14px;
  border-radius: 7px;
  overflow: hidden;
  background: var(--line);
}
.dot { width: 9px; height: 9px; border-radius: 5px; display: inline-block; }
.dot--rust { background: var(--rust); }
.dot--green { background: var(--green); }

.bar { height: 8px; border-radius: 4px; background: var(--line-soft); overflow: hidden; }
.bar__fill { height: 8px; border-radius: 4px; }

/* A bar with a mark for where the plan says you should be. */
.plan-bar { position: relative; margin-top: 20px; }
.plan-bar__mark { position: absolute; top: -5px; width: 2px; height: 18px; margin-left: -1px; border-radius: 1px; background: var(--ink); }
.plan-bar__mark span { position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--muted); white-space: nowrap; }

/* One dot per month of a plan. */
.dots { display: grid; grid-template-columns: repeat(auto-fill, 26px); gap: 10px; }
.dot { width: 26px; height: 26px; border-radius: 50%; background: var(--line-soft); }
.dot--paid { background: var(--green); }
.dot--short { background: var(--surface); border: 2px solid var(--rust); }
.dot--now { background: var(--surface); border: 2px solid var(--ink); }
.dots-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--muted); }
.dots-legend span { display: inline-flex; align-items: center; gap: 7px; }
.dots-legend .dot { width: 12px; height: 12px; }

.stats { display: flex; gap: 10px; }
.stat { flex-grow: 1; flex-basis: 0; padding: 14px 12px; }
.stat__label {
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--faint);
}
.stat__value { font-size: 18px; font-weight: 600; margin-top: 5px; }

.btn {
  font: inherit;
  border: 0;
  border-radius: 12px;
  min-height: 52px;
  padding: 0 20px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  background: var(--sand);
  color: var(--ink);
}
.btn:hover { background: #ded3c1; }
.btn--block { display: block; width: 100%; }
.btn--ghost { background: var(--surface); border: 1px solid var(--line); font-weight: 500; }
.btn--ghost:hover { background: #faf8f4; }
.btn--danger { background: var(--rust-tint); color: var(--rust-deep); }
.btn--danger:hover { background: #ecd3ca; }
.btn--link {
  background: none;
  min-height: 44px;
  padding: 0;
  font-size: 13px;
  font-weight: 400;
  color: var(--rust);
  text-decoration: underline;
}
.btn--link:hover { background: none; color: var(--rust-deep); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font: inherit;
  flex-grow: 1;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid #ddd4c6;
  background: var(--ground);
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}
.chip:hover { border-color: #c4b8a6; }
.chip[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--ground);
  font-weight: 600;
}

.stepper { display: flex; align-items: center; gap: 8px; }
.step {
  font: inherit;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 22px;
  border: 1px solid #4a4139;
  background: var(--ink-dark);
  color: var(--ground);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.step:hover { background: #362e26; }
.step:disabled { opacity: 0.35; cursor: not-allowed; }

.amount {
  font: inherit;
  font-family: var(--sans);
  font-variant-numeric: tabular-nums;
  width: 104px;
  height: 44px;
  padding: 0 10px;
  text-align: right;
  font-size: 19px;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid #4a4139;
  background: transparent;
  color: var(--ground);
  -moz-appearance: textfield;
}
.amount::-webkit-outer-spin-button,
.amount::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.amount:focus { outline: 2px solid var(--sand); outline-offset: 1px; }
/* The same field on a light card. */
.amount--light { border-color: var(--line); background: var(--surface); color: var(--ink); }
.amount--light:focus { outline-color: var(--green); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13px; color: var(--muted); }
.field > input,
.field > select {
  font: inherit;
  font-variant-numeric: tabular-nums;
  min-height: 48px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}
.field > input:focus,
.field > select:focus { outline: 2px solid var(--sand); outline-offset: 1px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

.divider { height: 1px; background: var(--line); }
.rule-top { padding-top: 14px; border-top: 1px solid #3b332b; }

.ledger { display: flex; flex-direction: column; }
.ledger__row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.ledger__meta { font-size: 12px; color: var(--faint); }

.ms { display: flex; align-items: center; gap: 14px; }
.ms__dot {
  width: 12px;
  height: 12px;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--surface);
  border: 2px solid #ddd4c6;
}
.ms__label { flex-grow: 1; font-size: 15px; color: #9d9284; }
.ms__when { font-size: 13px; color: #b5aa9b; }
.ms--done .ms__dot { background: var(--green); border-color: var(--green); }
.ms--done .ms__label { color: var(--ink); font-weight: 600; }
.ms--done .ms__when { color: var(--muted); }

.compare__bar { height: 10px; border-radius: 5px; background: #eae3d8; overflow: hidden; }
.compare__fill { height: 10px; border-radius: 5px; background: #c3b8a6; }
.compare--best .compare__fill { background: var(--green); }
.compare--best .compare__label { font-weight: 600; }

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; }
.chart__axis {
  display: flex;
  justify-content: space-between;
  padding-left: 12%;
  margin-top: 8px;
  font-size: 12px;
  color: var(--faint);
}
.legend { display: flex; flex-wrap: wrap; gap: 20px; align-items: center; font-size: 14px; }
.legend__swatch { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.legend__line { width: 22px; border-top: 2px dashed var(--muted); display: inline-block; }

.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--ground);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav__inner { max-width: 460px; margin: 0 auto; display: flex; }
.nav a {
  flex-grow: 1;
  flex-basis: 0;
  height: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #a19686;
  text-decoration: none;
  font-size: 11px;
}
.nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }

.notice {
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--rust-tint);
  border: 1px solid var(--rust-edge);
  color: var(--rust-deep);
  font-size: 14px;
  line-height: 1.55;
}

@media (min-width: 1024px) {
  .app--wide { max-width: 980px; }
  .app--wide .nav__inner { max-width: 980px; }
}

/* Operator keys above the on-screen keyboard while an amount field is focused. */
.calcbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  pointer-events: none;
}
.calcbar[hidden] { display: none; }
.calcbar--keyboard { padding-bottom: 6px; }
.card[hidden] { display: none; }
.calcbar__inner {
  max-width: 460px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.calcbar__keys {
  display: flex;
  padding: 4px;
  border-radius: 28px;
  background: var(--ink-dark);
  box-shadow: 0 6px 20px rgb(32 26 21 / 0.22);
  pointer-events: auto;
}
.calcbar__key {
  font: inherit;
  width: 48px;
  height: 44px;
  border: 0;
  border-radius: 22px;
  background: none;
  color: var(--ground);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.calcbar__key:active { background: #4a4139; }
.calcbar__preview {
  padding: 8px 14px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 17px;
  font-weight: 600;
}
.calcbar__preview:empty { display: none; }
