:root {
  color-scheme: light;
  --red: #e32227;
  --red-deep: #b9171d;
  --ink: #171717;
  --muted: #6c6864;
  --gold: #d3a62f;
  --cream: #f6f3ef;
  --glass: rgba(255, 255, 255, 0.84);
  --line: rgba(23, 23, 23, 0.12);
  --shadow: 0 28px 80px rgba(47, 24, 20, 0.18);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--cream); }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--cream); }
button, input, a { font: inherit; }

.page-shell { min-height: 100svh; padding: 24px; display: grid; place-items: center; }
.hero {
  position: relative;
  width: min(1240px, 100%);
  min-height: calc(100svh - 48px);
  overflow: hidden;
  border-radius: 36px;
  background: #eee8e2;
  box-shadow: var(--shadow);
  isolation: isolate;
}

.portrait { position: absolute; inset: 0; background: url("./assets/diana-approved.jpeg") 72% 28% / cover no-repeat; z-index: -3; }
.wash {
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(90deg, rgba(249,247,244,.97) 0%, rgba(249,247,244,.88) 43%, rgba(249,247,244,.38) 66%, rgba(249,247,244,.12) 100%),
    linear-gradient(0deg, rgba(255,255,255,.20), rgba(255,255,255,.20));
}

.brand { position: absolute; top: 34px; left: 42px; z-index: 2; }
.brand p { margin: 0; }
.brand-name { font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.45rem, 2.2vw, 2rem); line-height: 1; letter-spacing: -.035em; }
.brand-agency { margin-top: 9px !important; font-size: .76rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }

.calc-nav { position: absolute; top: 30px; right: 34px; z-index: 3; display: flex; gap: 4px; padding: 4px; border: 1px solid rgba(255,255,255,.72); border-radius: 999px; background: rgba(255,255,255,.72); box-shadow: 0 8px 24px rgba(48,35,31,.08); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.calc-nav a { padding: 9px 15px; border-radius: 999px; color: var(--muted); text-decoration: none; font-size: .82rem; font-weight: 700; white-space: nowrap; }
.calc-nav a.active { color: #fff; background: var(--red); box-shadow: 0 5px 14px rgba(190,22,28,.2); }

.calculator-panel {
  width: min(610px, calc(100% - 72px));
  margin: 118px 0 46px 42px;
  padding: 32px;
  border: 1px solid rgba(255,255,255,.88);
  border-radius: 28px;
  background: var(--glass);
  box-shadow: 0 18px 50px rgba(48,35,31,.13);
  backdrop-filter: blur(22px) saturate(115%);
  -webkit-backdrop-filter: blur(22px) saturate(115%);
}

.intro .eyebrow { display: inline-block; margin-bottom: 8px; color: var(--red-deep); font-size: .78rem; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; }
.intro h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.25rem, 4vw, 3.5rem); font-weight: 500; line-height: .98; letter-spacing: -.055em; }
.intro p { margin: 13px 0 0; color: var(--muted); font-size: 1rem; line-height: 1.45; }
.family-entry { display: inline-flex; align-items: center; min-height: 44px; margin-top: 16px; padding: 10px 17px; border-radius: 999px; color: #fff; background: var(--red); text-decoration: none; font-size: .87rem; font-weight: 750; box-shadow: 0 10px 24px rgba(190,22,28,.18); }

.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 18px; margin-top: 28px; }
.field { grid-column: 1 / -1; min-width: 0; }
.field.compact { grid-column: auto; }
.field-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.field-head label { font-size: .91rem; font-weight: 650; }
.field-head output { color: var(--red-deep); font-size: .88rem; font-weight: 700; white-space: nowrap; }

.range { width: 100%; margin: 0; accent-color: var(--red); touch-action: pan-y; }
.input-wrap { display: flex; align-items: center; margin-top: 8px; border-bottom: 1px solid var(--line); }
.input-wrap:focus-within { border-bottom-color: var(--red); }
.input-wrap input { width: 100%; min-width: 0; padding: 8px 2px; border: 0; outline: none; background: transparent; color: var(--ink); font-size: 1rem; font-weight: 650; }
.input-wrap span { color: var(--muted); font-size: .9rem; white-space: nowrap; }

.result { margin-top: 26px; padding: 24px; border-radius: 22px; color: #fff; background: linear-gradient(135deg, var(--red), var(--red-deep)); box-shadow: 0 16px 34px rgba(190, 22, 28, .22); }
.payment span { display: block; font-size: .86rem; opacity: .84; }
.payment strong { display: block; margin-top: 4px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2rem, 4.8vw, 3.15rem); font-weight: 500; line-height: 1; letter-spacing: -.04em; }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 20px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.26); }
.result-grid span, .result-grid b { display: block; }
.result-grid span { font-size: .73rem; opacity: .72; }
.result-grid b { margin-top: 4px; font-size: .91rem; font-weight: 650; }

.structure { margin-top: 20px; }
.structure-bar { display: flex; height: 8px; overflow: hidden; border-radius: 999px; background: #ded9d4; }
#down-bar { background: var(--gold); }
#loan-bar { background: var(--red); }
.structure-labels { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; margin-top: 9px; color: var(--muted); font-size: .78rem; }
.structure-labels > span { display: inline-flex; align-items: center; gap: 7px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot-down { background: var(--gold); }
.dot-loan { background: var(--red); }

.disclaimer { margin: 18px 0 0; color: var(--muted); font-size: .75rem; line-height: 1.45; }
.contact { display: inline-flex; justify-content: center; align-items: center; min-height: 48px; margin-top: 16px; padding: 12px 20px; border-radius: 999px; color: #fff; background: var(--ink); text-decoration: none; font-size: .91rem; font-weight: 700; transition: transform .2s ease, background-color .2s ease; }
.contact:hover { background: #000; transform: translateY(-1px); }
.contact:focus-visible { outline: 3px solid rgba(211,166,47,.7); outline-offset: 3px; }

.family-panel { width: min(690px, calc(100% - 72px)); }
.family-panel .intro h1 { font-size: clamp(2.05rem, 3.55vw, 3.05rem); line-height: 1.02; }
.family-form { display: grid; gap: 22px; margin-top: 28px; }
.choice-group { min-width: 0; margin: 0; padding: 0; border: 0; }
.choice-group legend { margin-bottom: 10px; font-size: .92rem; font-weight: 700; }
.segmented { display: grid; gap: 7px; }
.segmented.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.segmented.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.segmented label { position: relative; min-width: 0; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: grid; min-height: 46px; place-items: center; padding: 9px 10px; border: 1px solid var(--line); border-radius: 13px; color: var(--muted); background: rgba(255,255,255,.6); font-size: .86rem; font-weight: 700; text-align: center; line-height: 1.2; transition: border-color .18s ease, color .18s ease, background-color .18s ease; }
.segmented input:checked + span { border-color: var(--red); color: var(--red-deep); background: rgba(227,34,39,.08); }
.segmented input:focus-visible + span { outline: 3px solid rgba(211,166,47,.55); outline-offset: 2px; }

.check-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check-card { display: flex; align-items: flex-start; gap: 11px; min-height: 82px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.55); cursor: pointer; }
.check-card input { width: 19px; height: 19px; margin: 1px 0 0; accent-color: var(--red); flex: 0 0 auto; }
.check-card span, .check-card b, .check-card small { display: block; }
.check-card b { font-size: .84rem; line-height: 1.3; }
.check-card small { margin-top: 5px; color: var(--muted); font-size: .72rem; line-height: 1.35; }
.family-price { min-width: 0; }
.field-hint { margin: 8px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.45; }
.family-form input:disabled { cursor: not-allowed; opacity: .42; }
.family-form.financial-locked .family-price,
.family-form.financial-locked .choice-group:has(#family-down-percent) { opacity: .58; }

.family-result { margin-top: 26px; padding: 24px; border-radius: 22px; color: #fff; transition: background-color .2s ease; }
.family-result.eligible { background: linear-gradient(135deg, var(--red), var(--red-deep)); box-shadow: 0 16px 34px rgba(190,22,28,.22); }
.family-result.not-eligible { background: linear-gradient(135deg, #6f6a67, #393634); box-shadow: 0 16px 34px rgba(40,36,34,.18); }
.eligibility-line { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; }
.eligibility-line span { display: grid; width: 27px; height: 27px; place-items: center; border-radius: 50%; color: var(--red-deep); background: #fff; font-weight: 900; }
.family-result > p { margin: 10px 0 0; font-size: .84rem; line-height: 1.45; opacity: .84; }
.family-result .market-note { margin-top: 16px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.25); }
.family-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 20px; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.28); }
.metric { min-width: 0; padding: 14px; border-radius: 15px; background: rgba(255,255,255,.12); }
.metric span, .metric strong, .metric small { display: block; }
.metric span { font-size: .72rem; line-height: 1.3; opacity: .72; }
.metric strong { margin-top: 5px; font-size: 1.18rem; line-height: 1.15; }
.metric.primary strong { font-family: Georgia, "Times New Roman", serif; font-size: 2rem; font-weight: 500; }
.metric small { margin-top: 5px; font-size: .68rem; line-height: 1.3; opacity: .72; }

.reminder { margin-top: 18px; padding: 17px 18px; border-left: 4px solid var(--gold); border-radius: 0 16px 16px 0; background: rgba(211,166,47,.12); }
.reminder b { font-size: .9rem; }
.reminder p { margin: 7px 0 0; color: #514c47; font-size: .79rem; line-height: 1.48; }
.rules-note { margin-top: 14px; border-bottom: 1px solid var(--line); }
.rules-note summary { padding: 10px 0 13px; font-size: .84rem; font-weight: 700; cursor: pointer; }
.rules-note ul { margin: 0 0 16px; padding-left: 19px; color: var(--muted); font-size: .78rem; line-height: 1.55; }
.rules-note li + li { margin-top: 5px; }
.source-note { margin: 7px 0 0; font-size: .74rem; }
.source-note a { color: var(--red-deep); text-underline-offset: 3px; }

@media (max-width: 760px) {
  .page-shell { display: block; padding: 0 0 78px; }
  .hero { min-height: 100svh; border-radius: 0; box-shadow: none; }
  .portrait { inset: 0 0 auto; height: 62svh; background-position: 60% 20%; }
  .wash { background: linear-gradient(180deg, rgba(255,255,255,.16) 0%, rgba(255,255,255,.34) 31%, rgba(246,243,239,.96) 58%, var(--cream) 76%); }
  .brand { top: 24px; left: 22px; color: #fff; text-shadow: 0 2px 16px rgba(0,0,0,.22); }
  .brand-agency { font-size: .67rem; }
  .calc-nav { position: fixed; top: auto; bottom: max(10px, env(safe-area-inset-bottom)); left: 12px; right: 12px; z-index: 30; display: grid; grid-template-columns: 1fr 1fr; max-width: none; padding: 6px; border-color: rgba(23,23,23,.1); background: rgba(255,255,255,.96); box-shadow: 0 12px 36px rgba(31,24,21,.22); overflow: visible; }
  .calc-nav a { display: grid; min-height: 46px; place-items: center; padding: 8px 9px; font-size: .76rem; line-height: 1.15; text-align: center; white-space: normal; }
  .calculator-panel { width: calc(100% - 24px); margin: 39svh 12px 12px; padding: 24px 20px; border-radius: 24px; background: rgba(255,255,255,.87); }
  .family-panel { margin-top: 43svh; }
  .intro h1 { font-size: clamp(2.2rem, 12vw, 3.2rem); }
  .family-panel .intro h1 { font-size: clamp(2rem, 10vw, 2.7rem); }
  .check-list { grid-template-columns: 1fr; }
}

@media (max-width: 470px) {
  .controls { grid-template-columns: 1fr; }
  .field.compact { grid-column: 1 / -1; }
  .result-grid { grid-template-columns: 1fr 1fr; }
  .result-grid div:last-child { grid-column: 1 / -1; }
  .contact { display: flex; width: 100%; }
  .segmented.two { grid-template-columns: 1fr; }
  .segmented.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .segmented.five span { min-height: 42px; padding: 7px 4px; }
  .family-metrics { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) { .contact { transition: none; } }
