:root {
  color-scheme: light;
  --paper: #f3eee4;
  --paper-deep: #e9e1d2;
  --ink: #0c1b2a;
  --muted: #5c625e;
  --line: #c8c0b2;
  --green: #255a48;
  --green-light: #b8d1c2;
  --coral: #b84731;
  --white: #fffdf8;
  --error: #a52d21;
  --radius: 3px;
  --shadow: 0 22px 60px rgb(12 27 42 / 13%);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--paper);
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-underline-offset: 0.2em;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible,
details:focus-within,
.result-panel:focus-visible {
  outline: 3px solid var(--coral);
  outline-offset: 3px;
}

.site-header,
main,
footer {
  width: min(100% - 40px, 1240px);
  margin-inline: auto;
}

.site-header {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.site-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 750;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--paper);
  background: var(--ink);
  border-radius: 50%;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.22rem;
}

.tool-shell {
  padding: 72px 0 92px;
}

.intro {
  max-width: 880px;
  margin-bottom: 42px;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--green);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
.section-heading h2,
.example h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 0.98;
}

h1 {
  max-width: 760px;
  font-size: clamp(3rem, 7vw, 6.4rem);
}

.lede {
  max-width: 670px;
  margin: 26px 0 0;
  color: var(--muted);
  font-size: clamp(1.05rem, 1.9vw, 1.35rem);
  line-height: 1.55;
}

.calculator-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
  align-items: start;
  gap: 24px;
}

.calculator-form {
  padding: clamp(22px, 4vw, 42px);
  background: rgb(255 253 248 / 72%);
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgb(12 27 42 / 5%);
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0 0 30px;
  border: 0;
}

fieldset + fieldset {
  padding-top: 29px;
  border-top: 1px solid var(--line);
}

legend {
  width: 100%;
  margin-bottom: 22px;
  padding: 0;
  color: var(--green);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px 18px;
}

.field-grid-target {
  grid-template-columns: minmax(0, 1fr) 118px;
}

.field-wide {
  grid-column: 1 / -1;
}

.field-grid-target .field-wide {
  grid-column: auto;
}

.field label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.88rem;
  font-weight: 750;
}

.field input,
.field select {
  width: 100%;
  min-height: 50px;
  padding: 11px 13px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid #9d978c;
  border-radius: var(--radius);
  font-size: 1rem;
}

.field input:hover,
.field select:hover {
  border-color: var(--ink);
}

.field input[aria-invalid="true"],
.field select[aria-invalid="true"] {
  border-color: var(--error);
  box-shadow: 0 0 0 1px var(--error);
}

.money-input,
.suffix-input {
  position: relative;
}

.money-input > span,
.suffix-input > span {
  position: absolute;
  top: 50%;
  z-index: 1;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.money-input > span {
  left: 14px;
}

.money-input input {
  padding-left: 34px;
}

.suffix-input > span {
  right: 14px;
}

.suffix-input input {
  padding-right: 34px;
}

.help,
.field-error {
  margin: 7px 0 0;
  font-size: 0.76rem;
  line-height: 1.45;
}

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

.field-error {
  min-height: 0;
  color: var(--error);
  font-weight: 700;
}

.field-error:empty {
  display: none;
}

.error-summary {
  margin: 0 0 28px;
  padding: 15px 17px;
  color: #671c15;
  background: #fae5df;
  border-left: 4px solid var(--error);
}

.error-summary p {
  margin: 0;
  font-weight: 800;
}

.error-summary ul {
  margin: 6px 0 0;
  padding-left: 20px;
}

.form-actions,
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button {
  min-height: 48px;
  padding: 12px 17px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 800;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.button-primary {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--white);
  background: var(--green);
}

.button-primary:hover {
  background: #184b3a;
}

.button-quiet {
  color: var(--ink);
  background: transparent;
  border-color: var(--line);
}

.result-panel {
  position: sticky;
  top: 18px;
  min-width: 0;
  padding: clamp(26px, 4vw, 46px);
  color: var(--white);
  background: var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.result-panel[data-state="invalid"] {
  opacity: 0.72;
}

.result-panel .eyebrow {
  color: var(--green-light);
}

.result-heading h2 {
  margin: 4px 0 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.7rem, 6vw, 5.4rem);
  font-weight: 500;
  letter-spacing: -0.05em;
  line-height: 1;
}

.result-heading h2 span {
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 0.22em;
  font-weight: 700;
  letter-spacing: 0;
  white-space: nowrap;
}

.result-heading > p:last-child {
  margin: 0;
  color: #ced5d6;
}

.result-heading strong {
  color: #fff4ba;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 32px 0;
  border-top: 1px solid rgb(255 255 255 / 20%);
  border-bottom: 1px solid rgb(255 255 255 / 20%);
}

.result-stats > div {
  min-width: 0;
  padding: 19px 0;
}

.result-stats > div:nth-child(odd) {
  padding-right: 16px;
  border-right: 1px solid rgb(255 255 255 / 20%);
}

.result-stats > div:nth-child(even) {
  padding-left: 16px;
}

.result-stats > div:last-child {
  grid-column: 1 / -1;
  padding-left: 0;
  border-top: 1px solid rgb(255 255 255 / 20%);
  border-right: 0;
}

.result-stats dt {
  margin-bottom: 5px;
  color: #aab5b8;
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.result-stats dd {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.2rem, 2.7vw, 1.65rem);
}

.result-stats dd span {
  color: #aab5b8;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 0.65rem;
  white-space: nowrap;
}

.revenue-map h3 {
  margin: 0 0 16px;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}

.revenue-map ul {
  display: grid;
  gap: 13px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.revenue-map li > div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 5px;
  color: #c6ced0;
  font-size: 0.76rem;
}

.revenue-map output {
  color: var(--white);
  font-variant-numeric: tabular-nums;
}

meter {
  display: block;
  width: 100%;
  height: 7px;
  background: transparent;
}

meter::-webkit-meter-bar {
  height: 5px;
  background: #32414e;
  border: 0;
  border-radius: 0;
}

meter::-webkit-meter-optimum-value {
  background: var(--green-light);
}

meter::-moz-meter-bar {
  background: var(--green-light);
}

.result-actions {
  margin-top: 28px;
}

.button-light {
  color: var(--ink);
  background: var(--white);
}

.button-outline {
  color: var(--white);
  background: transparent;
  border-color: rgb(255 255 255 / 34%);
}

.copy-status {
  min-height: 1.4em;
  margin: 8px 0 0;
  color: var(--green-light);
  font-size: 0.76rem;
}

.method,
.example,
.faq {
  padding: 90px 0;
  border-top: 1px solid var(--line);
}

.section-heading {
  max-width: 650px;
}

.section-heading h2,
.example h2 {
  font-size: clamp(2.4rem, 5vw, 4.8rem);
}

.method-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 54px;
  border-top: 1px solid var(--line);
}

.method-grid article {
  padding: 26px 26px 28px 0;
}

.method-grid article + article {
  padding-left: 26px;
  border-left: 1px solid var(--line);
}

.method-grid article > span {
  color: var(--coral);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.3rem;
}

.method-grid h3 {
  margin: 40px 0 9px;
  font-size: 1rem;
}

.method-grid p,
.formula-block > p,
.faq details p {
  color: var(--muted);
}

.method-grid p {
  margin: 0;
}

.formula-block {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 48px;
  margin-top: 38px;
  padding: clamp(24px, 4vw, 42px);
  background: var(--paper-deep);
  border-left: 4px solid var(--green);
}

.formula-block h3 {
  margin: 0 0 14px;
}

.formula-block p {
  margin: 0;
}

.formula-block p + p {
  margin-top: 11px;
}

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.85em;
  line-height: 1.6;
}

.example {
  display: grid;
  grid-template-columns: 1fr 0.8fr;
  gap: 70px;
  align-items: end;
}

.example > p {
  margin: 0;
  color: var(--muted);
  font-size: 1.12rem;
  line-height: 1.75;
}

.example strong {
  color: var(--ink);
}

.faq .section-heading {
  margin-bottom: 42px;
}

.faq details {
  border-top: 1px solid var(--line);
}

.faq details:last-child {
  border-bottom: 1px solid var(--line);
}

.faq summary {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 0;
  font-weight: 750;
  cursor: pointer;
  list-style: none;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary::after {
  content: "+";
  flex: 0 0 auto;
  color: var(--green);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.8rem;
  font-weight: 400;
}

.faq details[open] summary::after {
  content: "−";
}

.faq details p {
  max-width: 760px;
  margin: 0 0 25px;
}

footer {
  min-height: 108px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
}

footer a {
  color: var(--ink);
  font-weight: 750;
  text-decoration: none;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.not-found {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  align-content: center;
  justify-items: start;
  padding-block: 48px;
}

.not-found h1 {
  max-width: 780px;
}

.not-found .button {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

@media (max-width: 900px) {
  .tool-shell {
    padding-top: 52px;
  }

  .calculator-layout {
    grid-template-columns: 1fr;
  }

  .result-panel {
    position: static;
  }

  .example {
    grid-template-columns: 1fr;
    gap: 28px;
  }
}

@media (max-width: 680px) {
  .site-header,
  main,
  footer {
    width: min(100% - 32px, 1240px);
  }

  .site-header {
    min-height: 66px;
  }

  .site-header p {
    display: none;
  }

  .tool-shell {
    padding: 40px 0 64px;
  }

  .intro {
    margin-bottom: 28px;
  }

  h1 {
    font-size: clamp(2.75rem, 15vw, 4.4rem);
  }

  .field-grid,
  .field-grid-target {
    grid-template-columns: 1fr;
  }

  .field-grid-target .field-wide {
    grid-column: 1;
  }

  .form-actions .button,
  .result-actions .button {
    width: 100%;
  }

  .result-heading h2 {
    font-size: clamp(2.6rem, 14vw, 4.6rem);
  }

  .method,
  .example,
  .faq {
    padding: 64px 0;
  }

  .method-grid,
  .formula-block {
    grid-template-columns: 1fr;
  }

  .method-grid article {
    padding: 24px 0;
  }

  .method-grid article + article {
    padding-left: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .method-grid h3 {
    margin-top: 17px;
  }

  .formula-block {
    gap: 24px;
  }

  footer {
    min-height: 128px;
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
  }

  footer p {
    margin: 0;
  }
}

@media (max-width: 380px) {
  .site-header,
  main,
  footer {
    width: calc(100% - 24px);
  }

  .calculator-form,
  .result-panel {
    padding: 21px;
  }

  .result-stats {
    grid-template-columns: 1fr;
  }

  .result-stats > div,
  .result-stats > div:nth-child(odd),
  .result-stats > div:nth-child(even),
  .result-stats > div:last-child {
    grid-column: 1;
    padding: 16px 0;
    border: 0;
    border-bottom: 1px solid rgb(255 255 255 / 20%);
  }

  .result-stats > div:last-child {
    border-bottom: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
