:root {
    --ref-ink: #17324d;
    --ref-muted: #5d7185;
    --ref-blue: #155b8a;
    --ref-blue-dark: #0d456d;
    --ref-teal: #087b75;
    --ref-line: #cedce7;
    --ref-soft: #f3f8fb;
    --ref-info: #e7f5f3;
    --ref-warning: #fff6df;
    --ref-error: #a12622;
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body.referral-page {
    margin: 0;
    background: #edf3f7;
    color: var(--ref-ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    font-size: 17px;
    line-height: 1.55;
}

.referral-shell {
    width: min(100% - 32px, 980px);
    margin: 32px auto 64px;
}

.referral-brand {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.referral-brand img {
    width: min(72vw, 300px);
    height: auto;
}

.referral-hero,
.referral-section,
.referral-submit-panel {
    background: #fff;
    border: 1px solid var(--ref-line);
    border-radius: 18px;
    box-shadow: 0 12px 32px rgba(24, 55, 82, .08);
}

.referral-hero {
    padding: clamp(24px, 5vw, 48px);
    border-top: 7px solid var(--ref-teal);
    margin-bottom: 22px;
}

.referral-hero h1 {
    margin: 0;
    color: #102e49;
    font-size: clamp(2rem, 5vw, 3rem);
    line-height: 1.05;
    letter-spacing: -.035em;
}

.referral-hero .subtitle {
    margin: 4px 0 0;
    color: var(--ref-ink);
    font-size: clamp(1.35rem, 4vw, 2.1rem);
    line-height: 1.15;
}

.service-audience {
    margin: 12px 0 0;
    padding: 5px 10px;
    border-radius: 5px;
    background: #78dab1;
    color: #113a35;
    font-weight: 800;
}

.service-summary,
.clinical-notice,
.privacy-notice,
.next-steps {
    margin-top: 24px;
    padding: 18px 20px;
    border-radius: 12px;
}

.service-summary { background: #d8f3e7; border-left: 5px solid var(--ref-teal); }
.clinical-notice { background: var(--ref-warning); border-left: 5px solid #d39a18; }
.privacy-notice { background: var(--ref-soft); border-left: 5px solid var(--ref-blue); }
.next-steps { background: #eaf3fb; border-left: 5px solid var(--ref-blue); }

.service-summary p,
.clinical-notice p,
.privacy-notice p,
.next-steps p { margin: 0 0 10px; }

.service-summary p:last-child,
.clinical-notice p:last-child,
.privacy-notice p:last-child,
.next-steps p:last-child { margin-bottom: 0; }

.referral-section {
    padding: clamp(22px, 4vw, 38px);
    margin: 20px 0;
}

.referral-section h2 {
    margin: 0 0 8px;
    padding-bottom: 10px;
    border-bottom: 3px solid var(--ref-blue);
    color: #173c5c;
    font-size: clamp(1.45rem, 4vw, 2rem);
    line-height: 1.2;
}

.section-intro { margin: 0 0 24px; color: var(--ref-muted); }

.field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.field { min-width: 0; }
.field.full { grid-column: 1 / -1; }

.field > label,
.field > legend,
.choice-label {
    display: block;
    margin: 0 0 7px;
    color: #193a56;
    font-size: .96rem;
    font-weight: 720;
}

.required-mark { color: #b02a26; }
.hint { display: block; margin-top: 6px; color: var(--ref-muted); font-size: .86rem; }

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
select,
textarea {
    width: 100%;
    min-height: 48px;
    border: 1px solid #9fb5c7;
    border-radius: 9px;
    background: #fff;
    color: #122f48;
    font: inherit;
    padding: 10px 12px;
}

textarea { min-height: 132px; resize: vertical; }
textarea.tall { min-height: 200px; }

input:focus,
select:focus,
textarea:focus {
    border-color: var(--ref-blue);
    outline: 3px solid rgba(21, 91, 138, .18);
    outline-offset: 1px;
}

fieldset {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.choices {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.choices.vertical { flex-direction: column; align-items: stretch; }

.choice {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    min-height: 46px;
    margin: 0;
    padding: 10px 13px;
    border: 1px solid #bfd0dd;
    border-radius: 10px;
    background: #f8fbfd;
    cursor: pointer;
}

.choice:hover { border-color: #7fa6c2; background: #f0f7fb; }
.choice input { flex: 0 0 auto; width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--ref-blue); }
.choice span { flex: 1 1 auto; }

.confirmations {
    display: grid;
    gap: 12px;
}

.confirmation-section { background: #d8f3e7; }
.confirmation-section h2 { border-bottom-color: var(--ref-teal); }

.self-intro-fields { margin-top: 22px; }
.service-summary .choice { background: rgba(255, 255, 255, .7); }

.error-summary {
    margin-bottom: 22px;
    padding: 18px 20px;
    border: 2px solid var(--ref-error);
    border-radius: 12px;
    background: #fff1f0;
    color: #711713;
}

.error-summary h2 { margin: 0 0 8px; border: 0; padding: 0; color: #711713; font-size: 1.25rem; }
.error-summary ul { margin: 0; padding-left: 22px; }

.referral-submit-panel {
    padding: clamp(22px, 4vw, 34px);
    margin-top: 20px;
}

.submit-button {
    min-height: 52px;
    border: 0;
    border-radius: 10px;
    background: var(--ref-blue);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 800;
    padding: 12px 24px;
}

.submit-button:hover { background: var(--ref-blue-dark); }
.submit-button:focus { outline: 3px solid rgba(21, 91, 138, .3); outline-offset: 3px; }

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

[hidden] { display: none !important; }

@media (max-width: 680px) {
    body.referral-page { font-size: 16px; }
    .referral-shell { width: min(100% - 20px, 980px); margin-top: 14px; }
    .field-grid { grid-template-columns: 1fr; gap: 17px; }
    .field.full { grid-column: auto; }
    .choices { flex-direction: column; }
    .choice { width: 100%; }
    .submit-button { width: 100%; }
    .referral-brand img { width: min(72vw, 250px); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
