@font-face { font-family: "Titillium Web"; font-weight: 600; font-display: swap; src: url("fonts/titillium-600.woff2") format("woff2"); }
@font-face { font-family: "Bricolage Grotesque"; font-weight: 400; font-display: swap; src: url("fonts/bricolage-400.woff2") format("woff2"); }
@font-face { font-family: "Bricolage Grotesque"; font-weight: 600; font-display: swap; src: url("fonts/bricolage-600.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 400; font-display: swap; src: url("fonts/jetbrains-400.woff2") format("woff2"); }

:root {
  --sand: #F4EDE0;
  --paper: #FAF6EC;
  --hairline: #DDD4C2;
  --stone: #E8DFCB;
  --stone-grey: #8F8672;
  --stone-bar: #CFC5AF;
  --charcoal: #3A3A3A;
  --secondary: #5C5C5C;
  --amber: #F28C5B;
  --amber-text: #B0552A;
  --green: #5F8D5E;
  --alert: #A63A2B;
  --display: "Titillium Web", "Trebuchet MS", sans-serif;
  --body: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
html { background: var(--sand); -webkit-text-size-adjust: 100%; scroll-padding-top: 16px; }
body { margin: 0; background: var(--sand); color: var(--charcoal); font: 400 16px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p, dl, dd, figure { margin: 0; }
h1, h2 { font-family: var(--display); font-weight: 600; letter-spacing: -0.012em; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--amber-text); }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--amber-text); outline-offset: 2px; border-radius: 3px; }
#results:focus { outline: none; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.print-only { display: none; }

.eyebrow, .tile-label, .stat-label, .unit-line, .gpu-detail {
  font-family: var(--mono);
}
.eyebrow { color: var(--amber-text); font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; }

.link-button { padding: 2px 0; border: 0; background: none; color: var(--amber-text); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
.link-button:hover { color: var(--charcoal); }

/* ---------- page frame ---------- */

.masthead { max-width: 1320px; margin: 0 auto; padding: 28px 40px 0; display: flex; justify-content: space-between; align-items: center; }
.logo { display: inline-block; }
.logo img { display: block; width: 150px; height: auto; }
.page { max-width: 1320px; margin: 0 auto; padding: 0 40px 72px; }
.hero { padding: 56px 0 44px; }
.hero h1 { margin-top: 10px; font-size: clamp(36px, 4.3vw, 60px); line-height: 1.06; text-wrap: balance; }
.deal-line { margin-top: 16px; max-width: 760px; font-size: 20px; font-weight: 600; line-height: 1.35; text-wrap: pretty; }
.lede { margin-top: 10px; color: var(--secondary); font-size: 18px; text-wrap: pretty; }

.layout { display: grid; grid-template-columns: 352px minmax(0, 1fr); gap: 44px; align-items: start; }

/* ---------- inputs ---------- */

.panel-inputs { position: sticky; top: 16px; background: var(--paper); border: 1px solid var(--hairline); border-radius: 12px; }
.inputs-body { max-height: calc(100vh - 34px); overflow-y: auto; padding: 22px 22px 8px; scrollbar-width: thin; scrollbar-color: var(--hairline) transparent; }
.drawer-bar { display: none; }
.inputs-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.inputs-head h2 { font-size: 24px; }

.field { margin: 0 0 18px; padding: 0; border: 0; min-width: 0; }
.field-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.field-label { display: block; padding: 0; font-weight: 600; font-size: 15px; }
.field-reset { font-size: 13px; }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) 84px; gap: 14px; align-items: center; margin-top: 6px; }
.unit-line { float: right; margin: 1px 0 0 12px; color: var(--secondary); font-size: 12px; }
.help { margin-top: 2px; color: var(--secondary); font-size: 13.5px; line-height: 1.4; }
.field-error { margin-top: 2px; color: var(--alert); font-size: 13.5px; }

input[type="number"] {
  width: 100%; height: 40px; padding: 0 8px; background: #FFFDF7; border: 1px solid var(--hairline); border-radius: 6px;
  font: 400 15px var(--mono); text-align: right; appearance: textfield; -moz-appearance: textfield;
}
input[type="number"]::-webkit-inner-spin-button { appearance: none; margin: 0; }
input[aria-invalid="true"] { border-color: var(--alert); }

input[type="range"] { --fill: 0%; width: 100%; height: 28px; margin: 0; background: none; appearance: none; -webkit-appearance: none; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--amber) var(--fill), var(--stone) var(--fill)); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--stone); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--amber); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8px; border: 2px solid var(--charcoal); border-radius: 50%; background: var(--paper); }
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border: 2px solid var(--charcoal); border-radius: 50%; background: var(--paper); }

.gpu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0 6px; }
.gpu-option { position: relative; display: block; padding: 9px 10px; background: #FFFDF7; border: 1px solid var(--hairline); border-radius: 8px; cursor: pointer; }
.gpu-option input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.gpu-option:has(input:checked) { border-color: var(--amber); box-shadow: inset 0 0 0 1px var(--amber); }
.gpu-option:has(input:focus-visible) { outline: 2px solid var(--amber-text); outline-offset: 2px; }
.gpu-name { display: block; font-weight: 600; font-size: 15px; line-height: 1.2; }
.gpu-detail { display: block; margin-top: 3px; color: var(--secondary); font-size: 11px; line-height: 1.3; }

.advanced { margin: 0 -22px; border-top: 1px solid var(--hairline); }
.advanced summary { padding: 14px 22px; color: var(--amber-text); font-weight: 600; cursor: pointer; }
.advanced[open] summary { margin-bottom: 4px; }
.advanced > div { padding: 0 22px; }
.fixed-value { margin-top: 2px; font: 400 15px var(--mono); }
.fixed .field-head { align-items: baseline; }
.unit { color: var(--secondary); font: 400 12px var(--mono); }

/* ---------- results ---------- */

.results { min-width: 0; }
/* Filled by script. Staying invisible until then keeps the first paint from shifting. */
.results, .panel-inputs { visibility: hidden; }
.ready .results, .ready .panel-inputs, .ready .site-footer { visibility: visible; }
.block { margin-bottom: 52px; }
.block h2 { margin-top: 6px; font-size: clamp(27px, 3vw, 36px); line-height: 1.12; }
.heading-row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.from-assessment { margin-bottom: 18px; padding: 12px 16px; background: var(--paper); border: 1px solid var(--amber); border-radius: 10px; font-size: 15.5px; }
.from-assessment a { color: var(--amber-text); white-space: nowrap; }
.block-lede { margin-top: 8px; max-width: 66ch; color: var(--secondary); }

.test-bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 30px; padding-bottom: 14px; border-bottom: 1px solid var(--hairline); }
.test-copy { color: var(--secondary); font-size: 15px; }
.segmented { display: inline-flex; padding: 3px; background: var(--stone); border-radius: 8px; }
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.segmented span { display: block; padding: 6px 13px; border-radius: 6px; font-size: 14px; }
.segmented input:checked + span { background: var(--paper); font-weight: 600; }
.segmented input:focus-visible + span { outline: 2px solid var(--amber-text); outline-offset: 1px; }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 20px; }
.tile { display: grid; grid-row: span 3; grid-template-rows: subgrid; row-gap: 0; padding: 16px 18px; background: var(--paper); border: 1px solid var(--hairline); border-radius: 12px; }
.tile-cash { border-color: var(--amber); }
.tile-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.tile-label { color: var(--charcoal); font-family: var(--body, inherit); font-size: 14.5px; font-weight: 600; letter-spacing: 0; text-transform: none; white-space: nowrap; }
.tile-icon { flex: none; width: 17px; height: 17px; fill: none; stroke: var(--secondary); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.tile-cash .tile-icon { stroke: var(--amber-text); }
.tile-value { align-self: center; padding: 30px 0; font: 600 clamp(36px, 3.5vw, 46px)/1 var(--display); letter-spacing: -0.015em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.is-negative .tile-value { color: var(--alert); }
.tile-foot { padding-top: 11px; border-top: 1px solid var(--hairline); }
.tile-strong { font: 400 14px var(--mono); }
.tile-cash .tile-strong { color: var(--amber-text); }
.tile-detail { margin-top: 3px; color: var(--secondary); font-size: 13.5px; line-height: 1.32; }

.flash { animation: flash 900ms ease-out; }
@keyframes flash { 0% { background: var(--stone); } 100% { background: var(--paper); } }

/* ---------- same building, two ways ---------- */

.compare-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 250px); gap: 32px; margin-top: 22px; align-items: end; }
.compare-row + .compare-row { margin-top: 20px; }
.compare-text { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; margin-bottom: 7px; }
.compare-text strong { font: 600 21px var(--display); white-space: nowrap; }
.compare-track { height: 44px; border-bottom: 1px solid var(--charcoal); }
.compare-bar { height: 100%; min-width: 3px; background: var(--charcoal); border-radius: 3px 3px 0 0; transition: width 280ms ease-out; }
.compare-bar.cold { background: var(--amber); }
.compare-bar.negative { background: var(--alert); }
.multiple { color: var(--amber-text); font: 600 clamp(46px, 4vw, 60px)/1 var(--display); letter-spacing: -0.02em; white-space: nowrap; }
.multiple-note { margin-top: 10px; color: var(--secondary); font-size: 14.5px; line-height: 1.35; }

/* ---------- tables ---------- */

.table-card { margin-top: 18px; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; }
.data th, .data td { padding: 13px 16px; border-bottom: 1px solid var(--hairline); text-align: right; white-space: nowrap; font-weight: 400; }
.data td { font: 400 15px var(--mono); }
.data tbody th { text-align: left; font: 600 16px var(--display); }
.data thead th { background: var(--stone); color: var(--charcoal); border-bottom: 0; font: 400 13px var(--mono); letter-spacing: 0.05em; text-transform: uppercase; }
.data thead th:first-child { text-align: left; border-radius: 8px 0 0 8px; }
.data thead th:last-child { border-radius: 0 8px 8px 0; }
.row-cash th, .row-cash td { background: var(--paper); border-bottom-color: var(--charcoal); }
.row-cash td { font-weight: 400; font-family: var(--display); font-size: 18px; font-weight: 600; }
.total-cash { color: var(--amber-text); }
.negative { color: var(--alert); }
.muted { color: var(--secondary); }

.chart-card { margin-top: 18px; padding: 16px 16px 8px; background: var(--paper); border: 1px solid var(--hairline); border-radius: 12px; }
.chart-key { display: flex; gap: 18px; color: var(--secondary); font-size: 14px; }
.chart-key span { display: inline-flex; align-items: center; gap: 7px; }
.swatch { display: inline-block; width: 11px; height: 11px; border-radius: 2px; }
.swatch-cash { background: var(--charcoal); }
.swatch-loan { background: var(--stone-bar); }
.chart-wrap { position: relative; margin-top: 4px; }
#chart { display: block; width: 100%; height: auto; min-height: 240px; }
.grid { stroke: var(--stone); stroke-width: 1; }
.axis-zero { stroke: var(--charcoal); stroke-width: 1; }
.tick { fill: var(--secondary); font: 400 12px var(--mono); }
.bar-cash { fill: var(--charcoal); }
.bar-loan { fill: var(--stone-bar); }
.bar-negative { fill: var(--alert); }
.line-cumulative, .line-loan { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.line-cumulative { stroke: var(--amber); }
.line-loan { stroke: var(--stone-grey); }
.marker-cumulative, .marker-loan { stroke: var(--paper); stroke-width: 2; }
.marker-cumulative { fill: var(--amber); }
.marker-loan { fill: var(--stone-grey); }
.label-cumulative, .label-loan { font: 600 14px var(--body); paint-order: stroke; stroke: var(--paper); stroke-width: 4px; }
.label-cumulative { fill: var(--amber-text); }
.label-loan { fill: var(--secondary); }
.hit { fill: transparent; }
.chart-tip { position: absolute; top: 28px; min-width: 196px; padding: 10px 12px; background: var(--charcoal); color: var(--paper); border-radius: 8px; font-size: 13.5px; pointer-events: none; }
.chart-tip p { margin-bottom: 4px; font: 400 12px var(--mono); }
.chart-tip div { display: flex; justify-content: space-between; gap: 16px; }
.chart-tip strong { font: 400 13px var(--mono); }

.table-scroll { margin-top: 18px; overflow-x: auto; }
.by-year th:first-child { position: sticky; left: 0; z-index: 1; background: var(--sand); }
.by-year thead th:first-child { background: var(--stone); }
.by-year .row-cash th:first-child { background: var(--paper); }
.by-year th, .by-year td { padding: 11px 14px; }
.by-year tbody th { font-size: 15px; }
.by-year td { font-size: 14px; }
.row-coverage td { vertical-align: top; white-space: normal; min-width: 118px; }
.coverage-value { display: block; }
.coverage-word { display: inline-flex; gap: 5px; align-items: baseline; margin-top: 2px; font: 400 12px/1.25 var(--body); color: var(--secondary); text-align: left; }
.dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.coverage-amber .dot { background: var(--amber); }
.coverage-red .dot { background: var(--alert); }
.coverage-amber .coverage-word { color: var(--amber-text); }
.coverage-red .coverage-word, .coverage-red .coverage-value { color: var(--alert); }
.table-note { margin-top: 12px; color: var(--amber-text); font-size: 15px; }
.table-note.is-red { color: var(--alert); }

/* ---------- loan room and drivers ---------- */

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 18px; border-top: 1px solid var(--charcoal); }
.stat { padding: 14px 16px 0 0; }
.stat + .stat { padding-left: 16px; border-left: 1px solid var(--hairline); }
.stat-label { min-height: 2.7em; font-size: 12.5px; line-height: 1.35; }
.stat-value { margin-top: 6px; font: 600 30px/1.1 var(--display); white-space: nowrap; }
.stat-detail { margin-top: 5px; color: var(--secondary); font-size: 13.5px; line-height: 1.32; }

.drivers { margin-top: 16px; }
.driver { display: grid; grid-template-columns: 182px minmax(0, 1fr); gap: 14px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--hairline); }
.driver-label { font-weight: 600; font-size: 15px; }
.driver-chart { display: grid; grid-template-columns: 72px minmax(0, 1fr) minmax(0, 1fr) 72px; align-items: center; }
.driver-value { font: 400 13px var(--mono); color: var(--secondary); }
.driver-value:last-child { text-align: right; }
.driver-side { display: flex; height: 18px; }
.driver-side.loss { justify-content: flex-end; border-right: 1px solid var(--charcoal); }
.driver-bar { height: 100%; min-width: 1px; transition: width 240ms ease-out; }
.driver-bar.loss { background: var(--stone-bar); }
.driver-bar.gain { background: var(--charcoal); }

/* ---------- end, assumptions, actions ---------- */

.end-line { margin-top: 12px; max-width: 34em; font: 600 clamp(22px, 2.3vw, 28px)/1.26 var(--display); }
.end-note { margin-top: 10px; max-width: 66ch; color: var(--secondary); }

.assumptions { margin-top: 14px; columns: 2; column-gap: 40px; }
.assumptions dt { float: left; clear: left; max-width: 60%; padding: 5px 0; color: var(--secondary); font-size: 14px; line-height: 1.3; }
.assumptions dd { padding: 5px 0; border-bottom: 1px solid var(--hairline); font: 400 13px/1.4 var(--mono); text-align: right; break-inside: avoid; min-height: 29px; }

.action-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.button { min-height: 48px; padding: 0 22px; background: transparent; border: 1px solid var(--charcoal); border-radius: 8px; font-weight: 600; font-size: 16px; }
.button:hover { background: var(--stone); }
.button.primary { background: var(--amber); border-color: var(--amber); color: var(--charcoal); }
.button.primary:hover { background: #EE7E48; }
.button:disabled { opacity: 0.6; cursor: progress; }
.known-contact { margin-top: 12px; color: var(--secondary); font-size: 14.5px; }

/* ---------- modal and toast ---------- */

.modal { width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 26px; background: var(--paper); color: var(--charcoal); border: 1px solid var(--hairline); border-radius: 12px; }
.modal::backdrop { background: rgba(58, 58, 58, 0.5); }
.modal h2 { font-size: 28px; line-height: 1.15; }
.modal-copy { margin-top: 6px; color: var(--secondary); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; margin-top: 16px; }
.form-grid label { font-weight: 600; font-size: 14.5px; }
.form-grid input { display: block; width: 100%; height: 44px; margin-top: 4px; padding: 0 10px; background: #FFFDF7; border: 1px solid var(--hairline); border-radius: 6px; font-weight: 400; font-size: 16px; }
.trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.consent { display: flex; gap: 9px; align-items: flex-start; margin-top: 14px; font-size: 15px; cursor: pointer; }
.consent input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--amber-text); }
.form-error { margin-top: 12px; color: var(--alert); font-size: 15px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 40; max-width: calc(100vw - 32px); padding: 12px 18px; background: var(--charcoal); color: var(--paper);
  border-radius: 8px; opacity: 0; transform: translate(-50%, 8px); pointer-events: none; transition: opacity 180ms, transform 180ms;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- footer ---------- */

/* Hidden until the page has built, so it never jumps down during load. */
.site-footer { visibility: hidden; background: var(--stone); border-top: 1px solid var(--hairline); }
.footer-inner { max-width: 1320px; margin: 0 auto; padding: 32px 40px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 18px 48px; }
.footer-brand { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; }
.footer-brand img { display: block; }
.footer-brand p { color: var(--secondary); font-size: 14.5px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.footer-links a { padding: 4px 0; color: var(--charcoal); font-size: 14.5px; text-underline-offset: 3px; }
.footer-links a:hover { color: var(--amber-text); }

.noscript { max-width: 640px; margin: 60px auto; padding: 0 24px; }
.noscript h1 { font-size: 40px; line-height: 1.1; margin-bottom: 14px; }

/* ---------- narrower screens ---------- */

@media screen and (max-width: 1279px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3) { padding-left: 0; border-left: 0; }
  .stat:nth-child(n+3) { margin-top: 12px; }
}

@media screen and (max-width: 1023px) {
  .masthead { padding: 20px 16px 0; }
  .page { padding: 0 16px 40px; }
  .footer-inner { padding: 28px 16px 110px; }
  .hero { padding: 30px 0 26px; }
  .lede { font-size: 16.500px; }
  .layout { display: block; }
  .block { margin-bottom: 42px; }

  .panel-inputs {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 30; border-width: 1px 0 0; border-radius: 14px 14px 0 0;
    box-shadow: 0 -6px 22px rgba(58, 58, 58, 0.16);
  }
  .drawer-bar {
    display: flex; width: 100%; min-height: 64px; padding: 10px 16px; background: none; border: 0; border-radius: 14px 14px 0 0;
    justify-content: space-between; align-items: center; gap: 12px; text-align: left;
  }
  .drawer-summary { min-width: 0; }
  .drawer-site { display: block; color: var(--secondary); font-size: 13.5px; }
  .drawer-cash { display: block; font: 600 19px/1.2 var(--display); }
  .drawer-action { flex: none; padding: 8px 16px; background: var(--amber); border-radius: 8px; font-weight: 600; }
  .inputs-body { display: none; max-height: calc(86vh - 64px); max-height: calc(86dvh - 64px); padding-top: 4px; border-top: 1px solid var(--hairline); }
  .is-open .inputs-body { display: block; }
  body.drawer-open { overflow: hidden; }
  .toast { bottom: 78px; }
  .compare-grid { grid-template-columns: 1fr; gap: 22px; }
}

@media screen and (max-width: 640px) {
  .tile { padding: 13px; }
  .tile-label { white-space: normal; }
  .tile-value { padding: 20px 0; font-size: 34px; }
  .tile-detail { font-size: 13px; }
  .year-one th, .year-one td { padding: 11px 6px; font-size: 13px; }
  .year-one tbody th { white-space: normal; font-size: 14px; }
  .year-one thead th { font-size: 11px; letter-spacing: 0; white-space: normal; }
  .year-one .row-cash td { font-size: 14.500px; }
  .by-year tbody th { max-width: 132px; white-space: normal; }
  .segmented { width: 100%; }
  .segmented label { flex: 1; text-align: center; }
  .driver { grid-template-columns: 1fr; gap: 2px; }
  .assumptions { columns: 1; }
  .action-row .button { flex: 1 1 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .chart-card { padding: 12px 8px 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .compare-bar, .driver-bar, .toast { transition: none; }
}
