:root {
  --ground: #F3EFE6;
  --ink: #17201D;
  --muted: #4A5551;
  --green: #0E5E4E;
  --green-dark: #083D33;
  --green-tint: #EAF2EE;
  --alarm: #C2410C;
  --alarm-dark: #8A2E08;
  --orange-light: #F28A55;
  --line: #E4DED1;
  --field: #F9F7F2;
  --error: #B42318;
  --display: 'Bricolage Grotesque', 'Arial Black', sans-serif;
  --body: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.5; }
a { color: var(--green); }
a:hover { color: var(--green-dark); }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--display); font-weight: 800; letter-spacing: -0.02em; margin: 0; line-height: 1.05; }
p { margin: 0; }
button, input { font: inherit; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }

.page { min-height: 100vh; display: flex; flex-direction: column; }

/* Header */
.site-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; padding: 18px clamp(16px, 4vw, 56px); border-bottom: 2px solid var(--ink); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.wordmark { font-family: var(--display); font-weight: 800; font-size: 26px; letter-spacing: -0.02em; }
.wordmark span { color: var(--alarm); }
.site-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 20px; font-weight: 600; font-size: 15px; }
.linkish { background: none; border: none; padding: 0; min-height: 44px; color: var(--green); font-weight: 600; text-decoration: underline; cursor: pointer; }
.site-nav a { min-height: 44px; display: inline-flex; align-items: center; }

/* Main */
.main { flex: 1; width: 100%; max-width: 960px; margin: 0 auto; padding: 40px clamp(16px, 4vw, 40px) 56px; }
.screen { display: flex; flex-direction: column; gap: 24px; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 28px; align-items: end; }
.hero-text { display: flex; flex-direction: column; gap: 14px; min-width: 0; padding-bottom: 20px; }
/* The doctor stands behind the intake form: his feet tuck under the card below. */
.hero-doc { position: relative; z-index: 0; margin: 0 0 -96px; width: clamp(150px, 24vw, 250px); padding-top: 92px; }
.hero-doc img { display: block; width: 100%; height: auto; max-width: 100%; }
.speech {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 230px;
  background: #fff; border: 2px solid var(--ink); border-radius: 16px; padding: 8px 12px;
  font-size: 14px; font-weight: 600; line-height: 1.3; box-shadow: 3px 3px 0 var(--ink); text-align: center;
}
.speech::after {
  content: ""; position: absolute; left: 50%; bottom: -9px; width: 14px; height: 14px; margin-left: -7px;
  background: #fff; border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); transform: rotate(45deg);
}
.intake { position: relative; z-index: 1; }
@media (max-width: 900px) { .speech { display: none; } .hero-doc { padding-top: 0; } }
@media (max-width: 640px) {
  .hero { grid-template-columns: minmax(0, 1fr) 112px; gap: 8px 12px; }
  .hero-doc { width: 112px; margin-bottom: -48px; }
  .hero-text { padding-bottom: 8px; }
}
.hero h1 { font-size: clamp(38px, 6vw, 72px); line-height: 1; letter-spacing: -0.03em; }
.eyebrow { font-size: 13px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--green); }
.eyebrow.muted { color: var(--muted); }
.eyebrow.alarm { color: var(--alarm); }
.eyebrow.orange { color: var(--orange-light); }
.lede { font-size: 18px; color: var(--muted); max-width: 640px; }

.card { background: #fff; border: 2px solid var(--ink); border-radius: 16px; padding: clamp(20px, 3vw, 28px); box-shadow: 6px 6px 0 var(--ink); display: flex; flex-direction: column; gap: 14px; }
.card h2 { font-size: clamp(28px, 4vw, 36px); }
.card.dark { background: var(--ink); color: var(--ground); box-shadow: none; }
.card.dark p { color: #D6D2C8; }
.card-title { font-family: var(--display); font-weight: 800; font-size: 22px; line-height: 1.15; }
.card.dark .card-title { color: var(--ground); }

/* Intake form */
.intake { gap: 18px; }
.row { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 8px; border: none; margin: 0; padding: 0; min-width: 0; }
.field label, .field legend { font-weight: 700; font-size: 16px; padding: 0; }
.field legend { margin-bottom: 8px; }
.field-age { flex: 0 0 140px; }
.field .row { gap: 12px; }
input[type="text"], input[type="number"] { width: 100%; font-size: 18px; padding: 12px 14px; border: 2px solid var(--ink); border-radius: 10px; background: var(--field); color: var(--ink); }
#symptoms { flex: 1 1 300px; width: auto; min-width: 0; }
.toggle-row { display: flex; flex-wrap: wrap; gap: 8px; }
.toggle { min-height: 50px; min-width: 110px; padding: 0 18px; font-weight: 700; border: 2px solid var(--ink); border-radius: 10px; background: var(--field); color: var(--ink); cursor: pointer; }
.toggle[aria-pressed="true"] { background: var(--green); color: #fff; }
.form-error { font-weight: 600; color: var(--error); }
.small-label { font-size: 14px; font-weight: 600; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 0 16px; background: var(--ground); color: var(--ink); border: 1.5px solid var(--ink); border-radius: 999px; cursor: pointer; font-size: 15px; }
.chip:hover { background: #fff; }

/* Buttons */
.btn { min-height: 52px; padding: 0 24px; font-weight: 700; font-size: 16px; border: 2px solid var(--ink); border-radius: 10px; cursor: pointer; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-ghost { background: #fff; color: var(--ink); }
.btn-alarm { background: var(--alarm); color: #fff; border-color: var(--ground); font-size: 17px; }
.btn-alarm:hover { background: var(--alarm-dark); }
.btn-white { background: #fff; color: var(--alarm); }
.btn-cream { background: var(--ground); color: var(--ink); border-color: var(--ground); }
.btn-outline-light { background: transparent; color: #fff; border-color: #fff; }
.btn-wide { width: 100%; min-height: 56px; font-size: 17px; }
.intake .btn-primary { flex: 0 0 auto; }

/* Loading */
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; font-size: 18px; }
.steps li { display: flex; align-items: center; gap: 12px; }
.steps li::before { content: ""; width: 16px; height: 16px; border-radius: 50%; background: var(--green); flex: 0 0 auto; }
.steps li.active::before { background: var(--alarm); animation: pulse 0.8s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .steps li.active::before { animation: none; } }

/* Results */
.result-head { display: flex; flex-direction: column; gap: 8px; }
.result-head h1 { font-size: clamp(28px, 4.5vw, 46px); overflow-wrap: anywhere; }
.result-layout { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.dx-card { flex: 2 1 420px; min-width: 0; }
.dx-card h2 { color: var(--green); font-size: clamp(28px, 4vw, 34px); }
.dx-blurb { font-size: 17px; }
.chart-note { font-size: 15px; color: var(--muted); background: var(--ground); border-radius: 10px; padding: 10px 14px; }
.chart-note strong { color: var(--ink); }
.rx { display: flex; gap: 12px; align-items: flex-start; background: var(--green-tint); border-radius: 10px; padding: 14px 16px; font-size: 16px; }
.rx-mark { font-family: var(--display); font-weight: 800; font-size: 22px; line-height: 1; color: var(--green); }
.meter { display: flex; flex-direction: column; gap: 6px; }
.meter-top { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; }
.meter-bar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.meter-bar > div { height: 100%; background: var(--green); width: 0; transition: width 0.6s ease; }
.meter-light .meter-bar { background: var(--alarm-dark); }
.meter-light .meter-bar > div { background: #fff; }
.side { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.fineprint { font-size: 12px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.share-status { font-size: 15px; font-weight: 600; color: var(--green); }
.help-list { margin: 0; padding-left: 22px; font-size: 18px; line-height: 1.6; }

/* Ads */
.ad { display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 16px auto 0; width: 100%; padding: 0 clamp(16px, 4vw, 56px); }
.ad-label { font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.ad-top { max-width: calc(728px + 2 * clamp(16px, 4vw, 56px)); }
.ad-top .adsbygoogle { width: 100%; min-height: 90px; }
.ad-result { margin: 0; padding: 0; }
.ad-result .adsbygoogle { width: 100%; max-width: 300px; min-height: 250px; }
.ad-placeholder { border: 2px dashed #8C8A82; border-radius: 8px; background: #E9E4D8; justify-content: center; color: var(--muted); font-weight: 600; font-size: 14px; text-align: center; }
.ad-top.ad-placeholder { height: 90px; max-width: 728px; padding: 0 12px; }
.ad-result.ad-placeholder { height: 250px; max-width: 300px; align-self: center; }

/* Footer */
.site-footer { border-top: 2px solid var(--ink); padding: 18px clamp(16px, 4vw, 56px); font-size: 14px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.site-footer .linkish { min-height: 0; font-weight: 700; }

/* Modals */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(23, 32, 29, 0.78); display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; }
.modal { width: 100%; max-width: 540px; margin: auto; border: 2px solid var(--ink); border-radius: 18px; padding: clamp(22px, 4vw, 32px); display: flex; flex-direction: column; gap: 16px; }
.modal:focus { outline: none; }
.modal h2 { font-size: clamp(32px, 6vw, 40px); }
.modal p { font-size: 17px; }
.modal-cream { background: var(--ground); box-shadow: 8px 8px 0 var(--alarm); }
.modal-alarm { background: var(--alarm); color: #fff; box-shadow: 8px 8px 0 var(--ink); }
.modal-alarm .eyebrow { color: #fff; }
.modal-dark { background: var(--ink); color: var(--ground); border-color: var(--orange-light); box-shadow: 8px 8px 0 var(--alarm); }
.doom-name { font-size: clamp(44px, 9vw, 68px) !important; line-height: 0.95; letter-spacing: -0.03em; }
.modal-dark .doom-name { color: #fff; }
.doom-line { font-size: 18px !important; }
.source { font-size: 14px !important; }
.muted-light { color: #D6D2C8; font-size: 15px !important; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.modal-actions .btn { flex: 1 1 200px; }
.modal-actions .btn-outline-light { flex: 0 1 auto; }
.modal-dark .modal-actions .btn-outline-light { flex: 1 1 200px; }
body.modal-open { overflow: hidden; }

/* Simple content pages (privacy) */
.prose { max-width: 720px; display: flex; flex-direction: column; gap: 14px; }
.prose h1 { font-size: clamp(34px, 5vw, 52px); }
.prose h2 { font-size: 24px; margin-top: 12px; }
.prose ul { margin: 0; padding-left: 22px; }

@media (max-width: 520px) {
  .field-age { flex: 1 1 100%; }
  .intake .btn-primary { width: 100%; }
  .actions .btn { flex: 1 1 100%; }
}
