@font-face {
  font-family: "Noto Serif Display";
  src: url("fonts/noto-serif-display.woff") format("woff");
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: light;
  --page: #f5f2eb;
  --paper: #fdfbf6;
  --ink: #28372f;
  --muted: #536158;
  --forest: #243b31;
  --line: #dcded3;
  --sage: #e8eee5;
  --gold: #b5a087;
  --serif: "Noto Serif Display", Georgia, serif;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: 20px; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 1rem/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
h1, h2, p, dl, dd { margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid #607b68; outline-offset: 4px; }
input:focus-visible { outline-offset: 2px; }
.frame { width: min(1136px, calc(100% - 64px)); margin-inline: auto; }

.masthead { border-bottom: 1px solid #e2ded4; background: #fbf9f3; }
.masthead-inner { min-height: 70px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: .85rem;
  letter-spacing: .25em;
  font-size: 1.05rem;
  font-weight: 700;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  border: 1px solid #937c64;
  border-radius: 2px;
  transform: rotate(45deg) scale(.84);
}
.brand-mark::after { content: ""; width: 10px; height: 10px; border: 1px solid #937c64; }
.privacy {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  border: 1px solid #deded1;
  padding: 6px 12px;
  color: #47564b;
  font-size: .8125rem;
  line-height: 1.2;
}
.lock {
  position: relative;
  width: 12px;
  height: 9px;
  flex: 0 0 12px;
  margin-top: 3px;
  border: 1.3px solid currentColor;
  border-radius: 2px;
}
.lock::before {
  position: absolute;
  content: "";
  left: 1px;
  right: 1px;
  bottom: 100%;
  height: 6px;
  border: 1.3px solid currentColor;
  border-bottom: 0;
  border-radius: 5px 5px 0 0;
}

.intro { padding: 37px 0 25px; }
.intro::before {
  content: "";
  display: block;
  width: 44px;
  height: 2px;
  margin-bottom: 14px;
  background: var(--gold);
}
.intro h1 {
  margin-bottom: 10px;
  font: 400 clamp(2.55rem, 5.8vw, 4.2rem)/1.1 var(--serif);
  letter-spacing: -.048em;
}
.intro p { max-width: 66ch; color: var(--muted); line-height: 1.6; }
.noscript { padding: 15px; background: var(--paper); }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  align-items: start;
  gap: 24px;
}
.panel {
  min-width: 0;
  padding: 17px 18px 15px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--paper);
  box-shadow: 0 2px 7px #45403808;
}
.budget-form {
  min-width: 0;
  padding: 18px;
  border: 1px solid #deded2;
  border-radius: 15px;
  background: #eeede4;
}
.form-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.form-heading h2 { font: 400 1.8rem/1.1 var(--serif); letter-spacing: -.035em; }
.form-heading p { margin-top: .28rem; color: var(--muted); font-size: .875rem; }
.example-label {
  margin: 12px 0 0;
  padding: 7px 10px;
  background: #e3eadf;
  border-radius: 6px;
  color: #364e3e;
  font-size: .875rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: .52rem .82rem;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--ink);
  text-decoration: none;
  background: transparent;
  font-weight: 650;
  font-size: .875rem;
}
.button-light { border-color: #c6ccc0; background: #faf9f2; }
.button-light:hover { background: #e6ece2; }
.button-primary { background: var(--forest); color: #fffdf6; }
.button-primary:hover { background: #385747; }
.button-text { color: #47604f; padding-inline: 0; text-decoration: underline; text-underline-offset: .2em; }
.button-text:hover { color: #213e2e; }
.button:disabled { cursor: default; color: #626d63; text-decoration: none; }

.sections { display: grid; gap: 12px; margin-top: 15px; }
.budget-section { margin: 0; padding-top: 5px; }
.budget-section legend { padding: 0 7px; margin-left: -4px; font-weight: 680; font-size: .955rem; }
.money-row { padding-block: 8px; }
.money-row + .money-row { border-top: 1px solid #e5e4da; }
.money-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(112px, 142px);
  align-items: center;
  gap: 12px;
}
.field-label { font-size: .925rem; font-weight: 580; line-height: 1.35; }
.money-control { position: relative; display: block; min-width: 0; }
.money-control input {
  width: 100%;
  min-height: 44px;
  padding: .44rem 1.65rem .44rem .55rem;
  border: 1px solid #bcc8bd;
  border-radius: 7px;
  background: #fffefa;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.money-control input::placeholder { color: #637268; }
.money-control input[aria-invalid="true"] { border-color: #96523f; }
.money-control > span { position: absolute; top: 50%; right: .58rem; transform: translateY(-50%); color: #526456; pointer-events: none; }
.field-note { margin-top: .35rem; color: var(--muted); font-size: .84rem; line-height: 1.45; }
.field-error { margin-top: .35rem; color: #863d2d; font-weight: 600; font-size: .875rem; }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px 14px; margin-top: 10px; }
.mobile-result { display: none; }

.calculation { display: grid; min-width: 0; gap: 14px; position: sticky; top: 18px; }
.result {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 26px 25px 20px;
  border-radius: 15px;
  border: 1px solid #405949;
  background: radial-gradient(ellipse at 98% 18%, #45614f, transparent 75%), var(--forest);
  color: #fffdf6;
}
.result::before {
  position: absolute;
  z-index: -1;
  content: "";
  width: 131px;
  height: 131px;
  right: -13px;
  top: -25px;
  border: 1px solid #d4c4af3d;
  border-radius: 50%;
  box-shadow: 0 0 0 17px #d4c4af12, 0 0 0 40px #d4c4af0c;
}
.result h2 { font-weight: 640; font-size: .975rem; color: #e8dac7; }
.balance {
  display: block;
  margin-top: 7px;
  font: 400 clamp(2.72rem, 7vw, 4.65rem)/1.08 var(--serif);
  letter-spacing: -.055em;
  overflow-wrap: anywhere;
}
.balance.wide-amount { font-size: clamp(1.85rem, 5vw, 3.1rem); }
.balance[data-negative="true"] { color: #f6cec3; }
.result-note { min-height: 2.75em; margin-top: .72rem; color: #e0e8dd; font-size: .95rem; line-height: 1.45; }
.budget-bar {
  height: 11px;
  display: flex;
  gap: 2px;
  overflow: hidden;
  margin: 15px 0 12px;
  border-radius: 999px;
  background: #57705f;
}
.budget-bar span { display: block; }
.budget-bar .running, .swatch.running { background: #e2c9af; }
.budget-bar .annual, .swatch.annual { background: #b69b81; }
.budget-bar .reserve, .swatch.reserve { background: #8ca997; }
.budget-bar .available { background: #d7e7d3; }

.breakdown { color: #e5eae0; font-size: .875rem; }
.breakdown > div { display: flex; justify-content: space-between; align-items: baseline; gap: 8px 12px; padding: 7px 0; border-top: 1px solid #d6e0d33d; }
.breakdown .breakdown-income { font-weight: 700; }
.breakdown dt { display: flex; align-items: center; gap: 7px; }
.breakdown dd { text-align: right; font-variant-numeric: tabular-nums; }
.swatch { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 8px; }

.scenario { padding: 18px 20px; }
.scenario h2, dialog h2 { font: 400 1.75rem/1.15 var(--serif); letter-spacing: -.035em; }
.scenario > p:first-of-type { color: var(--muted); font-size: .9rem; margin-top: .37rem; }
.scenario-field { margin-top: 12px; }
.scenario-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 8px;
  align-items: baseline;
  padding: 10px 11px;
  margin-top: 13px;
  border-radius: 7px;
  background: var(--sage);
  color: #314c3b;
}
.scenario-result > span { font-weight: 650; font-size: .875rem; }
.scenario-result > output { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; overflow-wrap: anywhere; }
.scenario-result:has(output[data-negative="true"]) { background: #f3e8e2; color: #813e2f; }
.scenario-result > p { grid-column: 1 / -1; font-size: .85rem; line-height: 1.4; }

.footer { padding: 14px 0 19px; margin-top: 20px; border-top: 1px solid #e0ded2; color: var(--muted); font-size: .8125rem; }
.footer-divider { color: #7f674d; margin-inline: .25rem; }
dialog { max-width: min(410px, calc(100vw - 32px)); padding: 21px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: var(--paper); }
dialog::backdrop { background: #1e322acc; }
dialog p { margin-top: .6rem; color: var(--muted); }
.dialog-actions { margin-top: 13px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }

@media (max-width: 880px) {
  .frame { width: calc(100% - 40px); }
  .workspace { gap: 16px; grid-template-columns: minmax(0, 1fr) minmax(0, .87fr); }
  .budget-form, .scenario, .result { padding-inline: 14px; }
}
@media (max-width: 705px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .calculation { position: static; }
  .intro { padding-top: 24px; padding-bottom: 19px; }
  .masthead-inner { min-height: 61px; }
  .mobile-result { display: inline-flex; }
  .form-actions { justify-content: space-between; }
  .result { padding: 19px 16px 12px; }
}
@media (max-width: 400px) {
  .frame { width: calc(100% - 24px); }
  .masthead-inner { gap: 9px; }
  .brand { font-size: .91rem; gap: .55rem; }
  .privacy { padding-inline: 8px; font-size: .75rem; }
  .budget-form, .panel { padding-inline: 11px; }
  .money-field { gap: 8px; grid-template-columns: minmax(0, 1fr) minmax(90px, 103px); }
  .field-label { font-size: .875rem; }
  .scenario-result { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
