:root {
  --canvas: #f3f1eb;
  --paper: #fbfaf7;
  --surface: #ffffff;
  --ink: #18211c;
  --muted: #67716b;
  --line: #dedfd9;
  --line-strong: #c8cbc4;
  --accent: #245b45;
  --accent-hover: #194a36;
  --accent-soft: #e6eee9;
  --sand: #d9c9ad;
  --danger: #ad3e3e;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow: 0 18px 45px rgba(31, 42, 35, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--canvas); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.5; }
button, input, select { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.site-header { max-width: 1240px; min-height: 78px; margin: auto; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; }
.site-header nav { display: flex; align-items: center; gap: 22px; }
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font-family: Inter, ui-sans-serif, system-ui, sans-serif; font-size: 16px; font-weight: 500; }
.brand strong { font-weight: 700; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: white; }
.brand-mark svg { width: 19px; }
.header-link { color: var(--muted); text-decoration: none; border-bottom: 1px solid transparent; font-size: 14px; font-weight: 500; }
.header-link:hover { color: var(--ink); border-color: var(--ink); }

main { max-width: 1240px; margin: auto; padding: 58px 28px 40px; }
.intro { max-width: 770px; margin-bottom: 46px; }
.eyebrow, .step-label { margin: 0 0 11px; color: var(--accent); font-size: 11px; font-weight: 600; letter-spacing: .15em; text-transform: uppercase; }
.intro h1 { max-width: 750px; margin: 0; font-family: Inter, ui-sans-serif, system-ui, sans-serif; font-size: clamp(40px, 5.2vw, 68px); line-height: 1.04; letter-spacing: -.048em; }
.intro > p:last-child { max-width: 650px; margin: 24px 0 0; color: var(--muted); font-size: 17px; }

.calculator-shell { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(380px, .95fr); overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); }
.inputs-panel, .results-panel { padding: 38px; }
.results-panel { background: var(--ink); color: #f8f7f3; }
.panel-heading { min-height: 56px; margin-bottom: 30px; display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.panel-heading h2, .section-heading h2, .guide-intro h2, .formula-card h2 { margin: 0; font-family: Inter, ui-sans-serif, system-ui, sans-serif; font-size: 26px; line-height: 1.2; letter-spacing: -.025em; }
.text-button { min-height: 40px; padding: 0 6px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; text-decoration: underline; text-underline-offset: 4px; }
.text-button:hover { color: var(--ink); }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 16px; }
.field { min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field > span:first-child, .derived-field > span:first-child { min-height: 22px; margin-bottom: 7px; display: flex; align-items: center; gap: 6px; color: #39433d; font-size: 13px; font-weight: 600; }
.input-wrap, .select-wrap { height: 48px; display: flex; align-items: center; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.input-wrap:focus-within, .select-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(36, 91, 69, .12); }
.input-wrap input, .select-wrap select { min-width: 0; width: 100%; height: 100%; padding: 0 13px; border: 0; outline: 0; background: transparent; font-weight: 500; }
.input-wrap .prefix { padding-left: 13px; color: var(--muted); }
.input-wrap .prefix + input { padding-left: 5px; }
.input-wrap .suffix { padding-right: 13px; color: var(--muted); }
.select-wrap select { cursor: pointer; }
.info-button { width: 19px; height: 19px; padding: 0; display: inline-grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; font: 600 11px/1 serif; }
.info-button:hover, .info-button:focus-visible { border-color: var(--accent); color: var(--accent); }
.field-error { min-height: 0; display: block; color: var(--danger); font-size: 12px; }
.field.invalid .input-wrap { border-color: var(--danger); }
.derived-field { padding: 15px 16px; border-radius: var(--radius-sm); background: #f4f5f1; }
.derived-field > span:first-child { margin: 0; }
.derived-field strong { display: block; font: 700 22px/1.3 Inter, ui-sans-serif, system-ui, sans-serif; }
.derived-field small { color: var(--muted); font-size: 12px; }
.notice { margin-top: 26px; padding: 14px 15px; display: flex; align-items: flex-start; gap: 11px; border: 1px solid #d5e2da; border-radius: var(--radius-sm); background: var(--accent-soft); color: #385447; }
.notice svg { width: 19px; flex: 0 0 auto; margin-top: 1px; }
.notice p { margin: 0; font-size: 12px; }

.results-panel .step-label { color: #a9c4b6; }
.estimate-tag { padding: 7px 10px; border: 1px solid #4b554f; border-radius: 999px; color: #b9c1bc; font-size: 11px; white-space: nowrap; }
.monthly-total { margin-top: 4px; display: flex; align-items: baseline; gap: 8px; }
.monthly-total span { font: 600 clamp(45px, 5vw, 66px)/1 Inter, ui-sans-serif, system-ui, sans-serif; letter-spacing: -.05em; }
.monthly-total small { color: #aab1ad; font-size: 15px; }
.payment-note { max-width: 470px; margin: 14px 0 32px; color: #9ca6a0; font-size: 12px; }
.cost-visual { padding: 24px 0; border-top: 1px solid #3b443e; border-bottom: 1px solid #3b443e; }
.cost-bar { height: 9px; display: flex; overflow: hidden; border-radius: 999px; background: #414a45; }
.cost-bar span { height: 100%; transition: width .2s ease; }
#principal-bar { background: #f3efe5; }
#interest-bar { background: #7aa08d; }
.legend { margin-top: 21px; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.legend div { display: grid; grid-template-columns: 8px 1fr; align-items: center; gap: 0 9px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; }
.principal-dot { background: #f3efe5; }
.interest-dot { background: #7aa08d; }
.legend span { color: #aab1ad; font-size: 12px; }
.legend strong { grid-column: 2; margin-top: 2px; font-size: 15px; }
.summary-grid { margin: 0; padding: 24px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.summary-grid div { min-width: 0; }
.summary-grid dt { margin-bottom: 4px; color: #9ca6a0; font-size: 11px; }
.summary-grid dd { margin: 0; font: 600 17px/1.3 Inter, ui-sans-serif, system-ui, sans-serif; }
.primary-button { min-height: 48px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; border-radius: var(--radius-sm); background: #f4f1e9; color: var(--ink); text-decoration: none; font-size: 13px; font-weight: 600; transition: background .15s, transform .15s; }
.primary-button:hover { background: white; transform: translateY(-1px); }
.primary-button svg { width: 18px; }

.schedule-section, .guide-section { padding: 100px 0 0; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.section-copy { max-width: 640px; margin: 15px 0 30px; color: var(--muted); }
.view-switch { padding: 3px; display: flex; border: 1px solid var(--line); border-radius: 10px; background: #eae8e2; }
.view-switch button { min-height: 36px; padding: 0 15px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; }
.view-switch button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.07); }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; white-space: nowrap; font-variant-numeric: tabular-nums; }
th, td { padding: 15px 20px; border-bottom: 1px solid #ebebe7; text-align: right; font-size: 13px; }
th { position: sticky; top: 0; z-index: 1; background: #f7f6f2; color: var(--muted); font-size: 11px; font-weight: 600; }
th:first-child, td:first-child { text-align: left; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafaf7; }

.guide-section { display: grid; grid-template-columns: .72fr 1.28fr; gap: 90px; align-items: start; }
.guide-intro { position: sticky; top: 30px; }
.guide-intro h2 { max-width: 360px; font-size: clamp(30px, 4vw, 45px); }
.guide-intro > p:last-child { max-width: 390px; margin-top: 18px; color: var(--muted); }
.explanation-list { border-top: 1px solid var(--line-strong); }
.explanation-list details { border-bottom: 1px solid var(--line-strong); }
.explanation-list summary { min-height: 68px; display: flex; align-items: center; gap: 22px; list-style: none; cursor: pointer; font: 600 17px Inter, ui-sans-serif, system-ui, sans-serif; }
.explanation-list summary::-webkit-details-marker { display: none; }
.explanation-list summary span { color: #9aa19c; font: 500 11px Inter, ui-sans-serif, system-ui, sans-serif; letter-spacing: .08em; }
.explanation-list summary::after { content: "+"; margin-left: auto; color: var(--muted); font: 400 22px Inter, ui-sans-serif, system-ui, sans-serif; }
.explanation-list details[open] summary::after { content: "−"; }
.explanation-list p { max-width: 650px; margin: -2px 40px 24px 42px; color: var(--muted); font-size: 14px; }
.explanation-list details:target { scroll-margin-top: 20px; }

.formula-card { margin-top: 100px; padding: 36px; display: grid; grid-template-columns: 1fr 1.1fr; gap: 70px; align-items: center; border: 1px solid var(--line); border-radius: var(--radius-lg); background: #e8e4da; }
.formula-card > div:first-child > p:last-child { margin: 14px 0 0; color: var(--muted); font-size: 14px; }
.formula { padding: 25px; border-radius: var(--radius); background: var(--paper); text-align: center; }
.formula strong { font: 600 clamp(15px, 2vw, 20px) Inter, ui-sans-serif, system-ui, sans-serif; }
.formula p { margin: 13px 0 0; color: var(--muted); font-size: 11px; line-height: 1.8; }
.faq-section { padding: 100px 0 0; display: grid; grid-template-columns: .72fr 1.28fr; gap: 90px; align-items: start; }
.faq-intro { position: sticky; top: 30px; }
.faq-intro h2 { margin: 0; font: 600 clamp(30px, 4vw, 45px)/1.15 Inter, ui-sans-serif, system-ui, sans-serif; letter-spacing: -.03em; }
.faq-intro > p:last-child { max-width: 390px; margin: 18px 0 0; color: var(--muted); }
.faq-list { border-top: 1px solid var(--line-strong); }
.faq-list details { border-bottom: 1px solid var(--line-strong); }
.faq-list summary { min-height: 68px; display: flex; align-items: center; gap: 22px; list-style: none; cursor: pointer; font: 600 17px Inter, ui-sans-serif, system-ui, sans-serif; }
.faq-list summary::-webkit-details-marker { display: none; }
.faq-list summary::after { content: "+"; margin-left: auto; color: var(--muted); font-size: 22px; font-weight: 400; }
.faq-list details[open] summary::after { content: "−"; }
.faq-list p { max-width: 650px; margin: -2px 40px 24px 0; color: var(--muted); font-size: 14px; }
.disclaimer { max-width: 850px; margin: 32px auto 80px; color: #7c847f; text-align: center; font-size: 11px; }
footer { min-height: 88px; max-width: 1240px; margin: auto; padding: 25px 28px; display: flex; justify-content: space-between; gap: 20px; border-top: 1px solid var(--line-strong); color: var(--muted); font-size: 12px; }
footer a { color: inherit; text-decoration: none; }
footer a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 10; padding: 11px 15px; border-radius: var(--radius-sm); background: var(--ink); color: white; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); pointer-events: none; font-size: 12px; transition: opacity .18s, transform .18s; }
.toast.show { opacity: 1; transform: translateY(0); }

:focus-visible { outline: 3px solid rgba(36, 91, 69, .35); outline-offset: 3px; }
@media (max-width: 900px) {
  main { padding-top: 38px; }
  .calculator-shell { grid-template-columns: 1fr; }
  .guide-section, .faq-section { grid-template-columns: 1fr; gap: 34px; }
  .guide-intro, .faq-intro { position: static; }
  .formula-card { grid-template-columns: 1fr; gap: 26px; }
}
@media (max-width: 600px) {
  .site-header, main, footer { padding-left: 18px; padding-right: 18px; }
  .site-header nav { gap: 14px; }
  .header-link { font-size: 12px; }
  .intro { margin-bottom: 30px; }
  .intro h1 { font-size: 39px; }
  .inputs-panel, .results-panel { padding: 26px 20px; }
  .field-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .results-heading { display: block; }
  .estimate-tag { display: inline-block; margin-top: 10px; }
  .monthly-total span { font-size: 45px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .schedule-section, .guide-section, .faq-section { padding-top: 72px; }
  .guide-section, .faq-section { gap: 24px; }
  .formula-card { margin-top: 72px; padding: 25px 20px; }
  .formula { padding: 20px 10px; }
  footer { flex-direction: column; justify-content: center; gap: 4px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }
