:root {
  --bg: #f4f1ea;
  --paper: #fffcf7;
  --ink: #1c2430;
  --muted: #5d6978;
  --line: #e4ddd2;
  --navy: #16324f;
  --accent: #1f6f8b;
  --accent-soft: #e8f3f6;
  --good: #2f6f57;
  --warn: #8a5a12;
  --alert: #9b3a36;
  --shadow: 0 1px 2px rgba(28, 36, 48, 0.06), 0 12px 32px rgba(22, 50, 79, 0.06);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "DM Sans", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  font-size: 16px;
}
.hidden { display: none !important; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 28px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--navy);
  text-decoration: none;
  font-weight: 650;
  font-size: 15px;
}
.brand img { border-radius: 7px; }
.top-meta { color: var(--muted); font-size: 13px; }

main { max-width: 880px; margin: 0 auto; padding: 28px 20px 72px; }

.hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 40px;
  align-items: center;
  padding: 36px 0 20px;
}
.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 10px;
}
h1, h2, h3, h4 {
  font-family: "Source Serif 4", Georgia, serif;
  color: var(--navy);
  font-weight: 560;
  line-height: 1.2;
  margin: 0 0 10px;
}
h1 { font-size: clamp(1.9rem, 4vw, 2.7rem); }
.subhead { margin: 0 0 22px; color: var(--muted); max-width: 34rem; }
.hero-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.fine, .helper, .phi-note { color: var(--muted); font-size: 13px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
}
.btn.primary { background: var(--navy); color: #fff; }
.btn.primary:hover { background: #0f2438; }
.btn.ghost { background: transparent; color: var(--navy); border-color: var(--line); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.paper {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.flow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 18px;
}
.flow span {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--navy);
}
.flow .arrow { border: 0; background: none; color: var(--muted); padding: 0; }
.flow .denied { border-color: #e6cfc0; color: var(--alert); }
.flow .paid { border-color: #cde3d7; color: var(--good); }
.viz-caption { margin: 10px 0 0; font-size: 13px; color: var(--muted); }

.progress-wrap { margin-bottom: 18px; }
.progress-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.progress-bar {
  height: 3px;
  background: #e8e2d8;
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar span {
  display: block;
  height: 100%;
  width: 12.5%;
  background: var(--accent);
  transition: width .25s ease;
}

.wizard-grid { display: block; }
.question-panel { padding: 28px 32px 24px; max-width: 640px; margin: 0 auto; }
.question-panel h2 { font-size: 1.45rem; margin-bottom: 6px; }
.question-panel h3 { font-size: 1.05rem; margin-top: 22px; }

.field { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; }
.field span { font-size: 13px; font-weight: 600; color: var(--navy); }
input, select, textarea {
  width: 100%;
  min-height: 40px;
  border-radius: 9px;
  border: 1px solid #d9d2c7;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  padding: 8px 11px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { min-height: 84px; resize: vertical; }

.segmented, .stack-choices {
  border: 0;
  padding: 0;
  margin: 12px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.segmented legend, fieldset legend {
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 8px;
  padding: 0;
}
.segmented label, .stack-choices label, .chip, .choice {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
}
.choice {
  font: inherit;
  color: inherit;
}
.chip input, .segmented input, .stack-choices input { width: auto; min-height: 0; accent-color: var(--navy); }
.choice.active, .segmented label:has(input:checked), .stack-choices label:has(input:checked), .chip:has(input:checked) {
  background: var(--accent-soft);
  border-color: #b7d4de;
  color: var(--navy);
}
.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.live-result {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  font-size: 14px;
}
.live-result p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.nav-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 20px; }
.phi-note { margin-top: 16px; }
.error { color: var(--alert); font-size: 14px; }
.check { display: flex; gap: 8px; align-items: center; margin: 8px 0; font-size: 14px; }
.check input { width: auto; min-height: 16px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.two-col .full { grid-column: 1 / -1; }
.payer-row { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.info {
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 0 2px;
}

.analyze { min-height: 46vh; display: grid; place-items: center; }
.analyze-card { padding: 28px; width: min(420px, 100%); text-align: center; }
.analyze-steps { list-style: none; padding: 0; margin: 16px 0 0; font-size: 14px; color: var(--muted); }
.analyze-steps li { display: none; }
.analyze-steps li.active, .analyze-steps li.done { display: block; }
.analyze-steps li.active { color: var(--navy); }

.results-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 18px;
}
.results-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.results-actions .btn { width: auto; }
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 0 0 18px;
}
.metric { padding: 14px 16px; }
.metric .k { color: var(--muted); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; font-weight: 650; }
.metric .v { font-size: 1.35rem; margin: 8px 0 4px; color: var(--navy); font-weight: 650; }
.metric.lower .v { color: var(--good); }
.metric.elevated .v, .metric.moderate .v { color: var(--warn); }
.metric.high .v { color: var(--alert); }
.block { padding: 18px 20px; margin-bottom: 12px; }
.block h3 { font-size: 1.15rem; }
.finding, .fix {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.finding:last-child, .fix:last-child { border: 0; }
.finding h4, .fix h4 { font-family: "DM Sans", sans-serif; font-size: 14px; margin: 0 0 4px; }
.fix summary { cursor: pointer; list-style: none; }
.fix summary::-webkit-details-marker { display: none; }
.finding p, .fix p { margin: 0; color: var(--muted); }
.badge {
  display: inline-block;
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 4px;
}
.missing-list { margin: 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
details.calc {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.tip {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: min(300px, calc(100vw - 24px));
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  z-index: 40;
  box-shadow: var(--shadow);
  font-size: 13px;
}
.tip button { margin-top: 8px; }

.buddy {
  position: fixed;
  right: 12px;
  bottom: 8px;
  width: 240px;
  z-index: 18;
  text-align: center;
  pointer-events: none;
}
.buddy-stage {
  width: 240px;
  height: 340px;
  margin: 0 auto;
  filter: drop-shadow(0 14px 24px rgba(22, 50, 79, 0.16));
}
.buddy-stage canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}
.buddy-face {
  width: 118px;
  height: 148px;
  margin: 0 auto;
  position: relative;
  animation: buddy-bob 2.4s ease-in-out infinite;
}
.doctor-fallback {
  width: 120px;
  height: 150px;
}
.doctor-fallback .head {
  position: absolute;
  left: 32px; top: 22px;
  width: 56px; height: 62px;
  border-radius: 50%;
  background: #e6c2a6;
}
.doctor-fallback .hair {
  position: absolute;
  left: 30px; top: 14px;
  width: 60px; height: 32px;
  border-radius: 40px 40px 8px 8px;
  background: #2b241e;
}
.doctor-fallback .eyes {
  position: absolute;
  left: 0; right: 0; top: 46px;
  letter-spacing: 10px;
  font-size: 11px;
  color: #16324f;
}
.doctor-fallback .mouth {
  position: absolute;
  left: 50px; top: 64px;
  width: 20px; height: 8px;
  border-bottom: 2px solid #c48678;
  border-radius: 0 0 10px 10px;
}
.doctor-fallback[data-mood="sad"] .mouth,
.doctor-fallback[data-mood="concern"] .mouth {
  border-bottom: 0;
  border-top: 2px solid #c48678;
  border-radius: 10px 10px 0 0;
  top: 68px;
}
.doctor-fallback .coat {
  position: absolute;
  left: 18px; top: 82px;
  width: 84px; height: 68px;
  background: #f8f6f1;
  border: 1px solid #e4ddd2;
  border-radius: 12px 12px 8px 8px;
}
.doctor-fallback .coat::before {
  content: "";
  position: absolute;
  left: 18px; right: 18px; top: 0;
  height: 34px;
  background: #1f6f8b;
  border-radius: 0 0 8px 8px;
}
.doctor-fallback .scope {
  position: absolute;
  left: 38px; top: 76px;
  width: 44px; height: 22px;
  border: 3px solid #1c2430;
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
}
@keyframes buddy-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.expert-book {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.expert-title {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 650;
  color: var(--navy);
}
.expert-book .btn { width: 100%; }
#buddy-says {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.35;
  color: var(--navy);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 8px;
  box-shadow: var(--shadow);
  max-width: 100%;
}
.buddy-call {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  margin-top: 8px;
  width: 100%;
  box-sizing: border-box;
  border: 0;
  border-radius: 10px;
  background: var(--navy);
  color: #fff;
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
  padding: 8px 10px 7px;
  box-shadow: var(--shadow);
}
.buddy-call span {
  font-size: 10px;
  font-weight: 500;
  opacity: 0.85;
}
.buddy-call:hover { filter: brightness(1.08); }

.contact-split {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 14px;
  align-items: start;
  margin-bottom: 12px;
}
.book-card .btn { width: 100%; margin-top: 8px; }
.field-hint {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}
.results-phi { margin: 0 0 16px; }

@media (max-width: 800px) {
  .hero, .metric-grid, .two-col, .payer-row, .contact-split { grid-template-columns: 1fr; }
  .hero { padding-top: 8px; }
  .question-panel { padding: 20px 16px; }
  main { padding-top: 16px; padding-bottom: 180px; }
  .buddy {
    width: min(220px, calc(100% - 24px));
    right: 12px;
    bottom: 8px;
  }
  .buddy-stage { display: none; }
  .buddy-call { font-size: 11px; padding: 7px 8px; }
  .buddy-face, .doctor-fallback { width: 96px; height: 120px; }
  .results-head { flex-direction: column; align-items: flex-start; }
}

@media print {
  .topbar, .buddy, .contact-split, #get-full-report, #print-snapshot, .hero-actions { display: none !important; }
  main { padding: 0 !important; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
