:root {
  --paper: #f3efe4;
  --ink: #221e18;
  --muted: #6e665c;
  --line: #e3d8c6;
  --card: #fffdf8;
  --green: #1d5c3d;
  --green-soft: #e7f3ec;
  --clay: #8a3e16;
  --clay-soft: #f8ebdf;
  --danger: #8d2e2e;
  --desk: #e6dfd2;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { overflow-x: clip; }

body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

.frame {
  width: 100%;
  max-width: 480px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--paper);
  overflow-x: clip;
}

#app { padding: 22px 18px calc(96px + env(safe-area-inset-bottom)); }

h1, h2 {
  font-family: Montserrat, "Segoe UI", system-ui, sans-serif;
}

h1 {
  margin: 0 0 6px;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

a { color: var(--green); }

.lede, .meta, .hint, .kicker { color: var(--muted); }

.lede { margin: 0 0 18px; }

.summary {
  margin: 0 0 18px;
  font-size: 1.02rem;
}

.kicker {
  margin: 0 0 4px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-title {
  margin: 22px 0 10px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.stack { display: grid; gap: 12px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 5px solid var(--green);
  border-radius: 16px;
  padding: 14px 14px 12px;
}

.card.loan { border-left-color: var(--clay); }

.card h2 a {
  color: var(--ink);
  text-decoration: none;
}

.card h2 a:hover { text-decoration: underline; }

.sentence {
  margin: 6px 0;
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: 1.15rem;
  line-height: 1.3;
}

.meta { margin: 0; }

.meta.warn { color: var(--clay); margin-top: 4px; }

.card .button, .card .button-secondary { margin-top: 12px; }

.button, .button-secondary, .text-button, .choice {
  font: inherit;
}

.button, .button-secondary, .text-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border-radius: 14px;
  padding: 10px 14px;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.button + .button,
.button + .button-secondary,
.button-secondary + .button,
.button-secondary + .button-secondary {
  margin-top: 12px;
}

.button {
  border: 0;
  background: var(--green);
  color: white;
  font-weight: 650;
}

.button-secondary {
  border: 1.5px solid var(--green);
  background: transparent;
  color: var(--green);
  font-weight: 650;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--green);
  font-weight: 650;
  min-height: 44px;
}

.text-button.danger { color: var(--danger); }

.button-row { display: grid; gap: 12px; margin-top: 16px; }
.button-row > .button,
.button-row > .button-secondary { margin-top: 0; }

.choice-list { display: grid; gap: 8px; margin: 0 0 16px; padding: 0; border: 0; }

.choice-list legend {
  font-weight: 700;
  margin-bottom: 8px;
  padding: 0;
}

.choice {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: var(--card);
  cursor: pointer;
}

.choice input { grid-row: 1 / span 2; width: 18px; height: 18px; margin: 0; }
.choice span { font-weight: 700; }
.choice small { color: var(--muted); }

.choice.is-selected { border-color: var(--green); background: var(--green-soft); }
.choice.loan.is-selected { border-color: var(--clay); background: var(--clay-soft); }

.field { margin: 0 0 14px; }
.field label, .find label { display: block; font-weight: 700; margin-bottom: 6px; }

input, select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 48px;
  border: 1.5px solid #d3c7b2;
  border-radius: 12px;
  background: white;
  color: var(--ink);
  font: inherit;
  padding: 10px 12px;
}

.dates, .remind {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.dates > *, .remind > * { min-width: 0; }

@media (max-width: 420px) {
  .dates, .remind { grid-template-columns: 1fr; }
}

.field-error, .error-summary {
  color: var(--danger);
  margin: 6px 0 0;
  font-size: 0.92rem;
}

input[aria-invalid="true"] { border-color: var(--danger); }
input[readonly] { background: #f6f1e7; }

.find { margin-bottom: 14px; }

.months { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.months li {
  display: grid;
  gap: 6px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.month-line { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.month-line strong { font-weight: 650; }

.confirm {
  margin-top: 16px;
  padding: 12px;
  border-radius: 14px;
  background: #f8e8e4;
}

.note {
  margin: 16px 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--green-soft);
}

.currency-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.currency-list button[aria-pressed="true"] {
  background: var(--green);
  color: white;
  border-color: var(--green);
}

nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 480px;
  margin-inline: auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  background: #fffdf8;
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 2;
}

nav a {
  min-width: 0;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 6px;
  text-align: center;
  text-decoration: none;
  color: var(--muted);
  font-weight: 650;
  font-size: 0.95rem;
  line-height: 1.15;
  white-space: normal;
}

nav a[aria-current="page"] { color: var(--green); }

.file input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.file { cursor: pointer; }

:focus-visible {
  outline: 3px solid var(--green);
  outline-offset: 2px;
}
