:root {
  --paper: #f7f3e9;
  --card: #fffdf7;
  --ink: #21312b;
  --muted: #68736d;
  --line: #d9d8cb;
  --accent: #e4a21a;
  --accent-dark: #9a6810;
  --green: #315c49;
  --green-soft: #e3eee8;
  --danger: #9e3f36;
  --danger-soft: #f8e6e3;
  --shadow: 0 18px 45px rgba(45, 52, 42, 0.09);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button, input { font: inherit; }

.site-header {
  border-bottom: 1px solid rgba(49, 92, 73, 0.15);
  background: rgba(247, 243, 233, 0.94);
}

.header-inner,
.page-shell {
  width: min(1160px, calc(100% - 40px));
  margin-inline: auto;
}

.header-inner {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  width: 30px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 2px solid var(--green);
  border-radius: 52% 52% 46% 46% / 61% 61% 39% 39%;
  transform: rotate(7deg);
}

.brand-mark span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
}

.save-status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.save-status::before {
  content: "";
  width: 6px;
  height: 6px;
  display: inline-block;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--green);
  vertical-align: 1px;
}

.page-shell { padding: 66px 0 28px; }

.intro {
  max-width: 690px;
  margin-bottom: 38px;
}

.eyebrow,
.step-label {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.intro h1 {
  max-width: 650px;
  margin: 0;
  font-family: "Newsreader", Georgia, serif;
  font-size: clamp(38px, 5vw, 62px);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 0.98;
}

.intro > p:last-child {
  max-width: 580px;
  margin: 19px 0 0;
  color: var(--muted);
  font-size: 17px;
}

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

.input-panel,
.result-panel {
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
}

.input-panel { padding: 30px; }
.result-panel { padding: 30px; }

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.panel-heading h2 {
  margin: 0;
  font-family: "Newsreader", Georgia, serif;
  font-size: 29px;
  line-height: 1;
}

.text-button {
  padding: 7px 0;
  border: 0;
  color: var(--muted);
  background: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.text-button:hover { color: var(--danger); }

.form-section {
  margin-top: 30px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}

.form-section h3 {
  margin: 0 0 17px;
  font-size: 14px;
  letter-spacing: 0.02em;
}

.section-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
}

.section-title-row span {
  color: var(--muted);
  font-size: 12px;
}

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

.field { display: grid; gap: 8px; }

.field > span:first-child {
  color: #4d5953;
  font-size: 13px;
  font-weight: 600;
}

.money-input,
.suffix-input {
  min-width: 0;
  height: 48px;
  display: flex;
  align-items: center;
  border: 1px solid #cfd0c5;
  background: #fff;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.money-input:focus-within,
.suffix-input:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(49, 92, 73, 0.12);
}

.money-input > span,
.suffix-input > span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

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

.money-input input,
.suffix-input input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0 12px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-weight: 600;
}

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

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button { margin: 0; appearance: none; }
input[type="number"] { appearance: textfield; }

.result-panel {
  position: sticky;
  top: 22px;
  color: #f9f6ed;
  border-color: var(--green);
  background: var(--green);
  box-shadow: 0 22px 50px rgba(25, 57, 43, 0.2);
}

.result-panel .step-label { color: #eac46c; }
.result-panel h2 { color: #fff; }

.profit-badge {
  padding: 5px 10px;
  border-radius: 999px;
  color: #234936;
  background: #d9ebdd;
  font-size: 12px;
  font-weight: 700;
}

.profit-badge.is-loss {
  color: #7e302b;
  background: var(--danger-soft);
}

.main-result {
  margin-top: 30px;
  padding: 26px 0;
  border-top: 1px solid rgba(255,255,255,0.18);
  border-bottom: 1px solid rgba(255,255,255,0.18);
}

.main-result p,
.main-result span { margin: 0; color: #cad7d0; }
.main-result p { font-size: 13px; }

.main-result strong {
  display: block;
  margin: 5px 0 3px;
  font-family: "Newsreader", Georgia, serif;
  font-size: clamp(36px, 4vw, 48px);
  font-weight: 600;
  line-height: 1;
  overflow-wrap: anywhere;
}

.main-result strong.is-loss { color: #ffd2cb; }
.main-result span { font-size: 12px; }

.result-list { margin: 10px 0 24px; }

.result-list div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}

.result-list dt { color: #cad7d0; font-size: 13px; }
.result-list dd { margin: 0; font-size: 13px; font-weight: 700; text-align: right; }

.break-even-box {
  display: flex;
  gap: 12px;
  padding: 15px;
  color: var(--ink);
  background: #f1d98f;
}

.small-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  margin-top: 1px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
}

.break-even-box p,
.break-even-box span { margin: 0; font-size: 12px; }
.break-even-box strong { display: block; margin: 2px 0; font-size: 16px; }
.break-even-box span { color: #5f604d; }

.footer-note {
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 820px) {
  .page-shell { padding-top: 48px; }
  .calculator-layout { grid-template-columns: 1fr; }
  .result-panel { position: static; }
}

@media (max-width: 560px) {
  .header-inner,
  .page-shell { width: min(100% - 28px, 1160px); }

  .site-header .save-status { display: none; }
  .page-shell { padding-top: 38px; }
  .intro { margin-bottom: 28px; }
  .intro h1 { font-size: 40px; }
  .intro > p:last-child { font-size: 15px; }
  .input-panel,
  .result-panel { padding: 22px 18px; }
  .field-grid { grid-template-columns: 1fr; gap: 14px; }
  .section-title-row { align-items: flex-start; flex-direction: column; gap: 0; }
  .section-title-row h3 { margin-bottom: 2px; }
  .section-title-row span { margin-bottom: 15px; }
  .main-result strong { font-size: 39px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
