:root {
  --navy-950: #0a1729;
  --navy-900: #10233f;
  --navy-800: #183252;
  --teal-700: #087782;
  --teal-500: #1aa7a5;
  --teal-200: #bfe8e4;
  --teal-100: #e3f5f2;
  --amber-500: #f4a64b;
  --amber-100: #fff1d9;
  --ink: #17243a;
  --muted: #5d6879;
  --line: #dce3eb;
  --surface: #ffffff;
  --canvas: #f4f7fa;
  --danger: #a63333;
  --shadow: 0 18px 50px rgba(16, 35, 63, 0.1);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 90% 4%, rgba(26, 167, 165, 0.12), transparent 24rem),
    var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.55;
}

button, input { font: inherit; }
button { cursor: pointer; }

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 5vw;
  color: #fff;
  background: var(--navy-950);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: inherit;
  text-decoration: none;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 9px;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 11px;
  background: rgba(255,255,255,0.06);
}

.brand-mark i { height: 2px; border-radius: 4px; background: var(--teal-200); }
.brand-mark i:nth-child(2) { width: 70%; background: var(--amber-500); }
.brand-mark i:nth-child(3) { width: 88%; }

.privacy-note {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: #d8e7ef;
  font-size: 0.875rem;
}

.privacy-dot {
  width: 9px;
  height: 9px;
  border-radius: 99px;
  background: #54d3c8;
  box-shadow: 0 0 0 4px rgba(84,211,200,0.14);
}

main { padding-bottom: 4rem; }

.intro-shell {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: clamp(2rem, 5vw, 6rem);
  align-items: center;
  padding: clamp(3rem, 6vw, 6.5rem) max(5vw, calc((100vw - 1320px) / 2));
  color: #fff;
  background: var(--navy-900);
}

.intro-shell::after {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  right: -160px;
  top: -210px;
  border: 1px solid rgba(91, 209, 202, 0.28);
  border-radius: 50%;
  box-shadow: 0 0 0 44px rgba(91,209,202,0.04), 0 0 0 88px rgba(91,209,202,0.03);
  pointer-events: none;
}

.intro-copy, .patient-card { position: relative; z-index: 1; }
.eyebrow {
  display: inline-block;
  color: var(--teal-700);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.intro-shell .eyebrow { color: #77ded7; }

h1, h2, p { margin-top: 0; }

h1 {
  margin-bottom: 1.25rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.45rem, 5vw, 5rem);
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: -0.045em;
}

h1 em { color: var(--amber-500); font-weight: 500; }

.intro-text {
  max-width: 680px;
  margin-bottom: 0;
  color: #d6e0ec;
  font-size: clamp(1.05rem, 1.6vw, 1.25rem);
}

.patient-card {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1rem;
  padding: 1.5rem;
  color: var(--ink);
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 70px rgba(0,0,0,0.25);
}

.field-group { display: flex; flex-direction: column; gap: 0.45rem; }
.field-group label { font-size: 0.875rem; font-weight: 800; }
.field-group input {
  width: 100%;
  min-height: 48px;
  padding: 0.7rem 0.85rem;
  color: var(--ink);
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
}
.field-group input:focus { outline: 3px solid rgba(26,167,165,0.2); border-color: var(--teal-700); }

.instructions { grid-column: 1 / -1; padding-top: 0.5rem; border-top: 1px solid var(--line); }
.instructions summary { color: var(--teal-700); font-weight: 800; cursor: pointer; }
.instructions p { margin: 0.8rem 0; color: var(--muted); font-size: 0.95rem; }

.questionnaire-layout {
  width: min(1320px, 90vw);
  margin: 3rem auto 0;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.progress-panel, .question-surface, .results-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.progress-panel { position: sticky; top: 1.25rem; padding: 1.3rem; }
.progress-heading { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.9rem; font-weight: 750; }
.progress-heading strong { color: var(--teal-700); }
.progress-track { height: 8px; margin: 0.75rem 0; overflow: hidden; border-radius: 99px; background: #e8edf2; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal-700), var(--teal-500)); transition: width 240ms ease; }
.progress-panel > p { margin: 0 0 1.25rem; color: var(--muted); font-size: 0.875rem; }

.block-nav {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.45rem;
  margin: 0 0 1.25rem;
  padding: 0;
  list-style: none;
}
.block-nav button {
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 0.8rem;
  font-weight: 800;
}
.block-nav button:hover { border-color: var(--teal-500); }
.block-nav button.active { color: #fff; border-color: var(--navy-900); background: var(--navy-900); }
.block-nav button.complete { color: var(--teal-700); border-color: var(--teal-200); background: var(--teal-100); }
.block-nav button.active.complete { color: #fff; border-color: var(--navy-900); background: var(--navy-900); }

.question-surface { overflow: hidden; }
.surface-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 2rem 2rem 1.5rem;
}
.surface-header h2, .results-header h2 {
  margin: 0.35rem 0 0;
  color: var(--navy-900);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.65rem, 3vw, 2.45rem);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.025em;
}
.status-pill {
  flex: 0 0 auto;
  padding: 0.45rem 0.75rem;
  color: var(--teal-700);
  border: 1px solid var(--teal-200);
  border-radius: 99px;
  background: var(--teal-100);
  font-size: 0.82rem;
  font-weight: 800;
}

.scale-key {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1px;
  margin: 0 2rem 1rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--line);
}
.scale-key span { min-height: 62px; display: flex; align-items: center; gap: 0.45rem; padding: 0.65rem; background: #f9fbfc; color: var(--muted); font-size: 0.72rem; line-height: 1.25; }
.scale-key b { color: var(--navy-900); font-size: 1.05rem; }
.scale-key.compact { grid-template-columns: 1fr 1fr; margin: 0; }
.scale-key.compact span { min-height: auto; }

.questions-list { border-top: 1px solid var(--line); }
.question-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1.5rem; align-items: center; padding: 1.4rem 2rem; border-bottom: 1px solid var(--line); }
.question-card:focus-within { background: #f8fcfc; }
.question-copy { display: flex; align-items: flex-start; gap: 0.9rem; }
.question-number { flex: 0 0 36px; width: 36px; height: 36px; display: grid; place-items: center; color: var(--teal-700); border-radius: 10px; background: var(--teal-100); font-weight: 850; }
.question-copy p { margin: 0.25rem 0 0; max-width: 700px; font-size: 1.02rem; line-height: 1.5; }
.rating-group { display: flex; gap: 0.45rem; border: 0; padding: 0; margin: 0; }
.rating-option { position: relative; }
.rating-option input { position: absolute; opacity: 0; pointer-events: none; }
.rating-option label { width: 42px; height: 42px; display: grid; place-items: center; color: var(--navy-800); border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; font-weight: 800; transition: transform 120ms ease, background 120ms ease, color 120ms ease; }
.rating-option label:hover { transform: translateY(-1px); border-color: var(--teal-500); }
.rating-option input:focus-visible + label { outline: 3px solid rgba(26,167,165,0.28); outline-offset: 2px; }
.rating-option input:checked + label { color: #fff; border-color: var(--teal-700); background: var(--teal-700); box-shadow: 0 5px 14px rgba(8,119,130,0.24); }

.surface-actions { display: flex; justify-content: space-between; gap: 1rem; padding: 1.5rem 2rem; background: #f8fafc; }
.button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1rem;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 800;
  text-decoration: none;
}
.button:focus-visible, .text-button:focus-visible { outline: 3px solid rgba(26,167,165,0.28); outline-offset: 3px; }
.button-primary { color: #fff; background: var(--teal-700); }
.button-primary:hover { background: #05636d; }
.button-secondary { color: var(--navy-900); border-color: #bcc8d6; background: #fff; }
.button-secondary:hover { border-color: var(--teal-500); background: var(--teal-100); }
.button-ghost { color: var(--muted); background: transparent; }
.button-ghost:hover { color: var(--navy-900); background: #e9eef3; }
.button:disabled { opacity: 0.45; cursor: not-allowed; }
.full-width { width: 100%; }
.danger { color: var(--danger); }

.results-section { width: min(1320px, 90vw); margin: 3rem auto 0; padding: clamp(1.5rem, 4vw, 3rem); }
.results-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; }
.results-person { margin: 0.65rem 0 0; color: var(--muted); }
.results-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; justify-content: flex-end; }
.clinical-note { display: flex; gap: 0.85rem; align-items: flex-start; margin: 2rem 0 1rem; padding: 1rem 1.1rem; color: #5d441a; border: 1px solid #f0d29c; border-radius: 14px; background: var(--amber-100); }
.clinical-note p { margin: 0; }
.note-icon { flex: 0 0 27px; width: 27px; height: 27px; display: grid; place-items: center; color: #fff; border-radius: 99px; background: #bb7422; font-family: Georgia, serif; font-weight: 800; }
.score-legend { display: flex; flex-wrap: wrap; gap: 0.8rem 1.4rem; margin: 1rem 0 1.5rem; color: var(--muted); font-size: 0.9rem; }
.results-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem; }
.score-card { padding: 1.15rem; border: 1px solid var(--line); border-radius: 14px; background: #fbfcfd; }
.score-card:first-child { grid-column: 1 / -1; border-color: #a8dcd7; background: linear-gradient(110deg, #f0fbfa, #fff); }
.score-row { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.score-row h3 { margin: 0; color: var(--navy-900); font-size: 1rem; }
.score-value { color: var(--teal-700); font-weight: 900; white-space: nowrap; }
.score-track { height: 9px; margin: 0.8rem 0 0.65rem; overflow: hidden; border-radius: 99px; background: #e6ebf0; }
.score-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal-700), var(--amber-500)); }
.score-meta { display: flex; justify-content: space-between; gap: 1rem; color: var(--muted); font-size: 0.82rem; }
.results-footer { display: flex; justify-content: space-between; gap: 2rem; align-items: flex-end; margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.results-footer p { max-width: 750px; margin: 0; color: var(--muted); font-size: 0.82rem; }
.text-button { padding: 0.25rem; color: var(--teal-700); border: 0; background: transparent; font-weight: 850; white-space: nowrap; }

.site-footer { padding: 0 5vw 2rem; color: var(--muted); text-align: center; font-size: 0.82rem; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 1.5rem; transform: translate(-50%, 150%); max-width: min(90vw, 540px); padding: 0.85rem 1rem; color: #fff; border-radius: 12px; background: var(--navy-950); box-shadow: 0 12px 30px rgba(0,0,0,0.25); opacity: 0; transition: transform 180ms ease, opacity 180ms ease; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 980px) {
  .intro-shell { grid-template-columns: 1fr; }
  .patient-card { max-width: 720px; }
  .questionnaire-layout { grid-template-columns: 1fr; }
  .progress-panel { position: static; }
  .block-nav { grid-template-columns: repeat(15, minmax(34px, 1fr)); overflow-x: auto; padding-bottom: 0.35rem; }
  .block-nav button { aspect-ratio: auto; min-height: 38px; }
  .scale-key { grid-template-columns: repeat(3, 1fr); }
  .question-card { grid-template-columns: 1fr; }
}

@media (max-width: 650px) {
  .topbar { padding: 0.8rem 5vw; }
  .privacy-note { display: none; }
  .intro-shell { padding-top: 3rem; padding-bottom: 3rem; }
  .patient-card { grid-template-columns: 1fr; padding: 1.1rem; }
  .instructions { grid-column: 1; }
  .questionnaire-layout, .results-section { width: 94vw; margin-top: 1rem; }
  .progress-panel { padding: 1rem; }
  .surface-header { padding: 1.25rem; flex-direction: column; }
  .scale-key { margin: 0 1.25rem 0.75rem; grid-template-columns: 1fr 1fr; }
  .scale-key span { min-height: 54px; }
  .question-card { padding: 1.2rem; gap: 1rem; }
  .question-copy p { font-size: 1rem; }
  .rating-group { display: grid; grid-template-columns: repeat(6, 1fr); width: 100%; }
  .rating-option label { width: 100%; min-width: 0; }
  .surface-actions { padding: 1rem 1.25rem; }
  .surface-actions .button { flex: 1; }
  .results-header, .results-footer { align-items: flex-start; flex-direction: column; }
  .results-actions { justify-content: flex-start; }
  .results-grid { grid-template-columns: 1fr; }
  .score-card:first-child { grid-column: auto; }
}

/* Responsive controls retain the same questions, answers and scoring. */
html { -webkit-text-size-adjust: 100%; }
.intro-copy, .patient-card, .field-group, .progress-panel, .question-surface,
.question-copy, .rating-group, .score-card, .score-row h3 { min-width: 0; }
.field-group input { min-width: 0; max-width: 100%; font-size: 1rem; }
button, label, summary { touch-action: manipulation; }
.brand-mark, .privacy-dot { flex-shrink: 0; }
.rating-description { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.block-picker summary, .rating-help summary { cursor: pointer; min-height: 44px; padding: .65rem 0; font-size: .875rem; font-weight: 750; color: var(--teal-700); }
.block-picker { margin-bottom: .75rem; }
.block-picker .block-nav { margin: .5rem 0; }
.rating-help { margin: 0 2rem 1rem; }
.rating-help .scale-key { margin: .5rem 0 0; }
.scale-key span { font-size: .875rem; }
.block-nav button { min-height: 44px; font-size: .875rem; }
.eyebrow { font-size: .875rem; letter-spacing: .08em; }
.question-surface, .results-section { scroll-margin-top: 1rem; }
.results-person, .score-row h3 { overflow-wrap: anywhere; }
@media screen and (max-width: 980px) {
  .intro-shell, .questionnaire-layout { grid-template-columns: minmax(0, 1fr); }
  .block-nav { grid-template-columns: repeat(5, minmax(0, 1fr)); overflow: visible; }
  .block-nav button { aspect-ratio: auto; }
}
@media screen and (max-width: 650px) {
  .topbar { min-height: 56px; padding: .65rem max(1rem, env(safe-area-inset-left)); }
  .intro-shell { padding: 1.5rem 1rem; gap: 1.25rem; }
  h1 { font-size: clamp(2rem, 8vw, 2.75rem); line-height: 1.12; letter-spacing: -.025em; margin: .6rem 0 .8rem; }
  .intro-text { font-size: 1rem; line-height: 1.55; }
  .patient-card { width: 100%; padding: 1rem; gap: .85rem; border-radius: 16px; }
  .questionnaire-layout, .results-section { width: calc(100% - 24px); }
  .progress-panel, .question-surface, .results-section { border-radius: 16px; }
  .progress-panel > p { margin-bottom: .25rem; }
  .surface-header { padding: 1rem; gap: .75rem; }
  .surface-header h2 { font-size: 1.65rem; line-height: 1.2; }
  .status-pill { font-size: .875rem; }
  .rating-help { margin: 0 1rem .75rem; }
  .rating-help .scale-key { grid-template-columns: minmax(0, 1fr); }
  .scale-key.compact { grid-template-columns: minmax(0, 1fr); }
  .scale-key span { min-height: 44px; }
  .question-card { padding: 1.2rem 1rem; gap: .85rem; }
  .question-copy { gap: .65rem; }
  .question-copy p { margin: 0; line-height: 1.6; overflow-wrap: anywhere; }
  .question-number { flex-basis: 30px; width: 30px; height: 32px; }
  .rating-group { min-width: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
  .rating-option { min-width: 0; }
  .rating-option label { height: 100%; min-height: 64px; padding: .65rem; display: flex; gap: .5rem; align-items: center; justify-content: flex-start; cursor: pointer; }
  .rating-option label > span:first-child { flex-shrink: 0; font-size: 1.125rem; }
  .rating-description { position: static; width: auto; height: auto; overflow: visible; clip-path: none; font-size: .875rem; line-height: 1.35; font-weight: 500; overflow-wrap: anywhere; }
  .surface-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; padding: 1rem; }
  .surface-actions .button { min-width: 0; min-height: 52px; padding: .65rem .45rem; font-size: .875rem; }
  .results-section { padding: 1rem; }
  .results-header h2 { font-size: 1.8rem; line-height: 1.2; }
  .results-actions, .results-actions .button { width: 100%; }
  .clinical-note { padding: .85rem; gap: .5rem; }
  .score-row { gap: .5rem; flex-wrap: wrap; }
  .score-meta { flex-wrap: wrap; gap: .4rem; font-size: .875rem; }
  .results-footer { gap: 1rem; }
  .text-button { white-space: normal; min-height: 44px; text-align: left; }
  .toast { width: calc(100% - 32px); bottom: max(1rem, env(safe-area-inset-bottom)); }
  .site-footer { padding-bottom: max(1.5rem, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

@media print {
  body { background: #fff; }
  .topbar, .intro-shell, .questionnaire-layout, .site-footer, .results-actions, .text-button, .toast { display: none !important; }
  main { padding: 0; }
  .results-section { width: 100%; margin: 0; padding: 0; border: 0; box-shadow: none; }
  .results-section[hidden] { display: block !important; }
  .results-grid { grid-template-columns: 1fr 1fr; }
  .score-card { break-inside: avoid; }
}
