.q-page { padding: 2.5rem 0 4rem; }
    .q-card {
      background: #ffffff;
      border: 1px solid #e2e8f0;
      border-radius: 16px;
      padding: 2rem;
      max-width: 720px;
      margin: 0 auto;
      box-shadow: 0 4px 24px rgba(26, 54, 93, 0.06);
    }
    .q-card h1 {
      font-family: 'Instrument Serif', Georgia, serif;
      font-size: 1.75rem;
      font-weight: 400;
      margin-bottom: 0.4rem;
      letter-spacing: -0.02em;
      color: #1a365d;
    }
    .q-intro {
      color: #5a6a7a;
      font-size: 0.95rem;
      margin-bottom: 1.5rem;
      line-height: 1.55;
    }
    /* Steps indicator */
    .steps {
      display: flex;
      gap: 0.5rem;
      margin-bottom: 1.75rem;
      flex-wrap: wrap;
    }
    .step-pill {
      flex: 1;
      min-width: 100px;
      text-align: center;
      padding: 0.55rem 0.5rem;
      border-radius: 999px;
      font-size: 0.8rem;
      font-weight: 600;
      background: #eef2f7;
      border: 1px solid rgba(255,255,255,0.1);
      color: #8b9aab;
    }
    .step-pill.active {
      background: #e8eef6;
      border-color: #2b4c7e;
      color: #1a365d;
    }
    .step-pill.done {
      background: rgba(16,185,129,0.15);
      border-color: rgba(16,185,129,0.35);
      color: #6ee7b7;
    }
    .q-section-title {
      font-size: 0.8rem;
      text-transform: uppercase;
      letter-spacing: 0.06em;
      color: #8b9aab;
      margin: 1.5rem 0 1rem;
      font-weight: 600;
      border-bottom: 1px solid rgba(255,255,255,0.08);
      padding-bottom: 0.4rem;
    }
    .q-item {
      background: #f7f9fc;
      border: 1px solid #e2e8f0;
      border-radius: 12px;
      padding: 1.1rem 1.25rem;
      margin-bottom: 0.75rem;
    }
    .q-item p {
      font-size: 0.95rem;
      color: #1a2332;
      margin-bottom: 0.75rem;
      line-height: 1.45;
    }
    .q-item .letter {
      display: inline-block;
      width: 26px; height: 26px;
      background: #e8eef6;
      color: #2b4c7e;
      border-radius: 6px;
      text-align: center;
      line-height: 26px;
      font-weight: 700;
      font-size: 0.85rem;
      margin-right: 0.5rem;
    }
    .yes-no {
      display: flex;
      gap: 0.75rem;
    }
    .yes-no label {
      flex: 1;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 0.4rem;
      padding: 0.65rem;
      border-radius: 10px;
      border: 1px solid #e2e8f0;
      cursor: pointer;
      font-weight: 500;
      font-size: 0.9rem;
      color: #5a6a7a;
      transition: all 0.2s;
      background: #ffffff;
    }
    .yes-no input { display: none; }
    .yes-no label:hover { background: rgba(255,255,255,0.08); color: #1a2332; }
    .yes-no label:has(input:checked) {
      background: #e8eef6;
      border-color: #2b4c7e;
      color: #1a365d;
    }
    /* Epworth 0-3 scale */
    .ess-scale {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 0.4rem;
    }
    .ess-scale label {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: 0.55rem 0.3rem;
      border-radius: 10px;
      border: 1px solid #e2e8f0;
      cursor: pointer;
      font-size: 0.75rem;
      color: #5a6a7a;
      text-align: center;
      background: #ffffff;
      transition: all 0.2s;
      line-height: 1.25;
    }
    .ess-scale input { display: none; }
    .ess-scale label:hover { background: rgba(255,255,255,0.08); color: #1a2332; }
    .ess-scale label:has(input:checked) {
      background: #e8eef6;
      border-color: #2b4c7e;
      color: #1a365d;
    }
    .ess-scale .num {
      font-weight: 700;
      font-size: 1rem;
      display: block;
      margin-bottom: 0.15rem;
    }
    .form-row-2 {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 1rem;
    }
    @media (max-width: 540px) {
      .form-row-2 { grid-template-columns: 1fr; }
      .ess-scale { grid-template-columns: 1fr 1fr; }
    }
    .panel { display: none; }
    .panel.active { display: block; }
    .nav-buttons {
      margin-top: 1.75rem;
      display: flex;
      gap: 0.75rem;
      flex-wrap: wrap;
    }
    .result-box {
      display: none;
      margin-top: 1.5rem;
      border-radius: var(--radius);
      padding: 1.5rem;
      border: 1px solid;
    }
    .result-box.show { display: block; animation: modalIn 0.35s ease-out; }
    .result-box.combined {
      background: #f7f9fc;
      border-color: #e2e8f0;
    }
    .score-row {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 1rem;
      margin-bottom: 1.25rem;
    }
    @media (max-width: 500px) { .score-row { grid-template-columns: 1fr; } }
    .score-card {
      background: #f7f9fc;
      border-radius: 12px;
      padding: 1.1rem;
      text-align: center;
      border: 1px solid #e2e8f0;
    }
    .score-card .big {
      font-size: 2.2rem;
      font-weight: 750;
      line-height: 1;
      margin-bottom: 0.25rem;
    }
    .score-card.low .big { color: #34d399; }
    .score-card.intermediate .big { color: #fbbf24; }
    .score-card.high .big { color: #f87171; }
    .score-card.normal .big { color: #34d399; }
    .score-card.mild .big { color: #fbbf24; }
    .score-card.moderate .big { color: #fb923c; }
    .score-card.severe .big { color: #f87171; }
    .score-card .label {
      font-size: 0.85rem;
      font-weight: 600;
      color: #5a6a7a;
    }
    .advice-block {
      background: #f7f9fc;
      border-radius: 12px;
      padding: 1.1rem 1.25rem;
      font-size: 0.95rem;
      color: #5a6a7a;
      line-height: 1.55;
      text-align: left;
    }
    .advice-block h4 {
      color: #1a2332;
      font-size: 0.95rem;
      margin-bottom: 0.5rem;
    }
    .advice-block ul { margin: 0.4rem 0 0 1.1rem; }
    .advice-block li { margin-bottom: 0.3rem; }
    .pdf-summary-box { margin-top:1.25rem; padding:1rem 1.1rem; background:#f0f7f6; border:1px solid rgba(13,148,136,0.25); border-radius:12px; text-align:center; }
    .circumference-units { display:flex; align-items:center; gap:0.5rem; flex-wrap:wrap; margin:0 0 0.9rem; }
    .circumference-units .unit-btn { padding:0.45rem 0.75rem; font-size:0.8rem; }
    .driver-flag {
      margin-top: 1rem;
      padding: 0.9rem 1rem;
      background: rgba(239,68,68,0.15);
      border: 1px solid rgba(239,68,68,0.35);
      border-radius: 10px;
      text-align: left;
    }

    /* ===== Email-format popup ===== */
    .email-format-modal {
      position: fixed;
      inset: 0;
      background: rgba(10, 30, 50, 0.58);
      display: none;
      align-items: center;
      justify-content: center;
      padding: 1.25rem;
      z-index: 10000;
      backdrop-filter: blur(3px);
    }
    .email-format-modal.show { display: flex; }
    .email-format-dialog {
      width: min(520px, 100%);
      background: #fff;
      border-radius: 20px;
      padding: 1.75rem;
      box-shadow: 0 20px 55px rgba(0,0,0,.24);
      border: 2px solid #f1b9b9;
      text-align: left;
    }
    .email-format-dialog h2 { margin: 0 0 .6rem; color: #7f1d1d; font-size: 1.45rem; }
    .email-format-dialog p { margin: 0 0 1rem; color: #4b5563; line-height: 1.55; }
    .email-input-error {
      border: 3px solid #b42318 !important;
      box-shadow: 0 0 0 4px rgba(180,35,24,0.12) !important;
      background: #fff8f7 !important;
    }

    .email-format-example {
      background: #f8fafc;
      border: 1px solid #e5e7eb;
      border-radius: 12px;
      padding: .8rem 1rem;
      margin: .75rem 0 1.1rem;
      font-size: .95rem;
    }

    .privacy-note {
      font-size: 0.8rem;
      color: #8b9aab;
      margin-top: 1.25rem;
      line-height: 1.45;
    }
    .unit-btn {
      padding: 0.45rem 0.95rem !important;
      margin: 0 !important;
      font-size: 0.85rem !important;
      background: #fff !important;
      border: 1px solid #d5dde3 !important;
      color: #1a2b3c !important;
      border-radius: 999px !important;
      font-weight: 500 !important;
    }
    .unit-btn.active {
      background: rgba(42, 111, 106, 0.12) !important;
      border-color: rgba(42, 111, 106, 0.45) !important;
      color: #1a2b3c !important;
    }
    .unit-btn:hover {
      background: rgba(42, 111, 106, 0.08) !important;
    }
    /* Keep height/weight fields always readable */
    #metricInputs input,
    #imperialInputs input,
    #ptBMI {
      background: #fff !important;
      color: #1a2b3c !important;
      border: 1px solid #d5dde3 !important;
    }
    #metricInputs label,
    #imperialInputs label,
    label[for="ptBMI"] {
      color: #5c6b7a !important;
    }

    .choice-row {
      display: flex;
      flex-wrap: wrap;
      gap: 0.5rem;
      margin-top: 0.35rem;
    }
    .choice-chip {
      display: inline-flex;
      align-items: center;
      gap: 0.4rem;
      padding: 0.55rem 0.9rem;
      border: 1px solid #d5dde3;
      border-radius: 999px;
      background: #fff;
      font-size: 0.85rem;
      color: #1a2b3c;
      cursor: pointer;
    }
    .choice-chip:has(input:checked) {
      border-color: #1a365d;
      background: rgba(26, 54, 93, 0.08);
      color: #1a365d;
      font-weight: 550;
    }
    .choice-chip input { accent-color: #1a365d; }
    textarea {
      width: 100%;
      padding: 0.7rem 0.9rem;
      border: 1px solid #d5dde3;
      border-radius: 8px;
      font-size: 0.95rem;
      font-family: inherit;
      background: #fff;
      color: #1a2b3c;
      resize: vertical;
    }




    /* Modern assessment route cards and patient-friendly answer choices */
    .assessment-mode-group {
      margin-top: 1.5rem;
    }
    .assessment-mode-group > label:first-child {
      display: block;
      font-size: clamp(1.35rem, 3.8vw, 1.8rem);
      font-weight: 750;
      color: #173b62;
      margin-bottom: .35rem;
    }
    .assessment-mode-group::after {
      content: 'Choose how much you would like to tell us. You can choose a shorter review or the full sleep history.';
      display: block;
      color: #64748b;
      font-size: 1rem;
      line-height: 1.5;
      margin: 0 0 1rem;
    }
    .assessment-mode-options {
      display: grid;
      grid-template-columns: 1fr;
      gap: 1rem;
    }
    .assessment-mode-card {
      position: relative;
      display: flex;
      align-items: flex-start;
      gap: 1rem;
      min-height: 116px;
      padding: 1.25rem 1.3rem;
      border: 3px solid #d7e2ec;
      border-radius: 18px;
      background: #fff;
      box-shadow: 0 6px 18px rgba(23,59,98,.06);
      cursor: pointer;
      transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease, background .2s ease;
    }
    .assessment-mode-card:hover {
      border-color: #8eb4d1;
      transform: translateY(-1px);
      box-shadow: 0 9px 22px rgba(23,59,98,.09);
    }
    .assessment-mode-card input {
      position: absolute;
      opacity: 0;
      pointer-events: none;
    }
    .assessment-mode-card::before {
      content: '';
      flex: 0 0 28px;
      width: 28px;
      height: 28px;
      margin-top: .1rem;
      border: 3px solid #a9bac9;
      border-radius: 50%;
      background: #fff;
      box-sizing: border-box;
    }
    .assessment-mode-card:has(input:checked) {
      border-color: #176b8c;
      background: #f2fbfd;
      box-shadow: 0 10px 26px rgba(23,107,140,.12);
    }
    .assessment-mode-card:has(input:checked)::before {
      border-color: #176b8c;
      box-shadow: inset 0 0 0 6px #fff;
      background: #176b8c;
    }
    .assessment-mode-card span {
      display: flex;
      flex-direction: column;
      gap: .3rem;
    }
    .assessment-mode-card strong {
      color: #173b62;
      font-size: 1.2rem;
      line-height: 1.25;
    }
    .assessment-mode-card small {
      color: #5f7183;
      font-size: .98rem;
      line-height: 1.5;
    }
    .assessment-flow-step .choice-row {
      display: grid;
      grid-template-columns: 1fr;
      gap: .85rem;
      margin-top: .65rem;
    }
    .assessment-flow-step .choice-chip {
      width: 100%;
      min-height: 68px;
      padding: .9rem 1rem;
      border: 3px solid #cbd8e4;
      border-radius: 16px;
      background: #fff;
      color: #173b62;
      font-size: 1.08rem !important;
      font-weight: 650;
      justify-content: center;
      text-align: center;
      box-shadow: 0 4px 12px rgba(23,59,98,.05);
      transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
    }
    .assessment-flow-step .choice-chip:hover {
      border-color: #7ba8c2;
      background: #f8fcfe;
    }
    .assessment-flow-step .choice-chip:has(input:checked) {
      border-color: #176b8c;
      background: #edf9fb;
      color: #124e67;
      box-shadow: 0 6px 16px rgba(23,107,140,.10);
    }
    .assessment-flow-step .choice-chip input {
      transform: scale(1.2);
    }
    .assessment-flow-step .assessment-mode-card {
      min-height: 125px;
    }

    /* Guided one-question-at-a-time assessment */
    #panel1.assessment-guided { position: relative; }
    #assessmentFlow {
      width: 100%;
      max-width: 760px;
      margin: 0 auto;
      min-height: 520px;
      display: flex;
      align-items: center;
      justify-content: center;
      position: relative;
      overflow: hidden;
    }
    .assessment-flow-step {
      width: 100%;
      background: #fff;
      border: 2px solid #e2e8f0;
      border-radius: 24px;
      padding: clamp(1.5rem, 4vw, 3rem);
      box-shadow: 0 14px 40px rgba(26,54,93,0.10);
      text-align: center;
    }
    .assessment-flow-section {
      font-size: 0.82rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: .07em;
      color: #2b4c7e;
      margin-bottom: .75rem;
    }
    .assessment-flow-step .form-group,
    .assessment-flow-step .form-row-2,
    .assessment-flow-step .circumference-units {
      text-align: left;
    }
    .assessment-flow-step .form-group { margin-bottom: 0; }
    .assessment-flow-step > .flow-question-label {
      display:block;
      font-size: clamp(1.45rem, 4vw, 2.15rem);
      font-weight: 700;
      line-height: 1.25;
      text-align: center;
      color: #1a2332;
      margin-bottom: 1.35rem;
    }
    .assessment-flow-step .form-group > label:first-child,
    .assessment-flow-step .form-row-2 label:first-child {
      font-size: 1.12rem;
      line-height: 1.4;
    }
    .assessment-flow-step input[type="text"],
    .assessment-flow-step input[type="email"],
    .assessment-flow-step input[type="number"],
    .assessment-flow-step input[type="time"],
    .assessment-flow-step textarea,
    .assessment-flow-step select {
      font-size: 1.1rem !important;
      min-height: 54px;
    }
    .assessment-flow-step textarea { min-height: 110px; }
    .assessment-flow-step .choice-row { gap: .75rem; }
    .assessment-flow-step .choice-chip,
    .assessment-flow-step .unit-btn {
      min-height: 56px;
      font-size: 1rem !important;
    }
    .assessment-flow-step .yes-no { gap: .8rem; }
    .assessment-flow-next {
      width: 100%;
      min-height: 62px;
      margin-top: 1.5rem;
      font-size: 1.12rem;
      font-weight: 700;
      border-radius: 14px;
    }
    .assessment-flow-progress {
      position: fixed;
      left: 0;
      right: 0;
      bottom: 0;
      z-index: 1000;
      background: rgba(255,255,255,.98);
      border-top: 1px solid #dfe6ee;
      box-shadow: 0 -5px 22px rgba(26,54,93,.10);
      padding: .65rem 1rem .8rem;
    }
    .assessment-flow-progress-inner { width: min(760px, 100%); margin: 0 auto; }
    .assessment-flow-progress-label {
      display:flex;
      justify-content:space-between;
      gap:1rem;
      font-size:.95rem;
      font-weight:700;
      color:#1a365d;
      margin-bottom:.4rem;
    }
    .assessment-flow-progress-track {
      height: 12px;
      background:#e7edf3;
      border-radius:999px;
      overflow:hidden;
    }
    .assessment-flow-progress-bar {
      width:0%;
      height:100%;
      background:#2b6f6a;
      border-radius:999px;
      transition: width .45s ease;
    }
    .flow-slide-in { animation: flowSlideIn .42s ease both; }
    .flow-slide-out { animation: flowSlideOut .28s ease both; }
    @keyframes flowSlideIn { from{opacity:0;transform:translateX(110px)} to{opacity:1;transform:translateX(0)} }
    @keyframes flowSlideOut { from{opacity:1;transform:translateX(0)} to{opacity:0;transform:translateX(-110px)} }
    @media (max-width: 600px) {
      #assessmentFlow { min-height: 500px; }
      .assessment-flow-step { border-radius: 18px; padding: 1.35rem; }
    }
    @media (prefers-reduced-motion: reduce) {
      .flow-slide-in, .flow-slide-out, .assessment-flow-progress-bar { animation:none !important; transition:none !important; }
    }

    /* Accessible incomplete-question highlighting and validation */
    .form-group.incomplete,
    .q-item.incomplete {
      border: 3px solid #c62828 !important;
      border-radius: 14px;
      background: #fff7f7 !important;
      box-shadow: 0 0 0 2px rgba(198,40,40,0.08);
      scroll-margin-top: 24px;
    }
    .incomplete label:first-child,
    .q-item.incomplete > p:first-child { color: #8f1d1d; }
    .validation-modal {
      position: fixed; inset: 0; z-index: 9999; display: none;
      align-items: center; justify-content: center; padding: 1rem;
      background: rgba(15, 23, 42, 0.62);
    }
    .validation-modal.show { display: flex; }
    .validation-dialog {
      width: min(620px, 100%); max-height: 88vh; overflow: auto;
      background: #fff; border-radius: 18px; padding: 1.5rem;
      box-shadow: 0 18px 60px rgba(0,0,0,.25);
      color: #1a2332;
    }
    .validation-dialog h2 { margin: 0 0 .55rem; color: #8f1d1d; font-size: 1.35rem; }
    .validation-dialog p { font-size: 1rem; line-height: 1.5; margin: 0 0 1rem; }
    .validation-list { margin: 0 0 1.25rem; padding: 0; list-style: none; }
    .validation-list button {
      width: 100%; text-align: left; padding: .85rem 1rem; margin: .45rem 0;
      border: 2px solid #f0b7b7; border-radius: 10px; background: #fff7f7;
      color: #7f1d1d; font-size: 1rem; font-weight: 600; cursor: pointer;
    }
    .validation-list button:hover, .validation-list button:focus { background: #fee2e2; border-color: #c62828; outline: 3px solid rgba(198,40,40,.18); }
    .validation-actions { display:flex; justify-content:flex-end; gap:.75rem; }
    .validation-close { min-width: 140px; min-height: 48px; font-size: 1rem; }
    @media (min-width: 700px) {
      .validation-dialog { padding: 2rem; }
      .validation-dialog h2 { font-size: 1.5rem; }
    }
  .calculated-hidden { display:none !important; }
  .stopbang-auto-item { display:none !important; }
  
    .data-consent-box {
      margin: 1.25rem 0 1rem;
      padding: 1.1rem 1.2rem;
      border: 1px solid #cbd5e1;
      border-radius: 14px;
      background: #f8fafc;
    }
    .data-consent-box h3 { margin:0 0 .45rem; color:#1e3a5f; font-size:1.05rem; }
    .data-consent-box p { margin:0 0 .7rem; color:#475569; line-height:1.55; font-size:.95rem; }
    .data-consent-row { display:flex; align-items:flex-start; gap:.7rem; margin-top:.8rem; }
    .data-consent-row input { margin-top:.28rem; width:20px; height:20px; flex:0 0 auto; }
    .data-consent-row label { color:#1f2937; line-height:1.55; font-size:.98rem; cursor:pointer; }
    .research-consent-note { margin:.55rem 0 0 1.95rem; color:#64748b; font-size:.88rem; line-height:1.5; }
    .cloud-save-status { margin:.9rem 0 0; min-height:1.3rem; font-size:.9rem; color:#475569; text-align:center; }

    .final-consent-modal {
      position: fixed; inset: 0; z-index: 10000; display: none;
      align-items: center; justify-content: center; padding: 1rem;
      background: rgba(15, 23, 42, 0.68);
    }
    .final-consent-modal.show { display:flex; }
    .final-consent-dialog {
      width: min(700px, 100%); max-height: 90vh; overflow:auto;
      background:#fff; border-radius:22px; padding:clamp(1.35rem, 4vw, 2rem);
      box-shadow:0 20px 70px rgba(0,0,0,.28); color:#1a2332;
      border:1px solid #dbe4ec;
    }
    .final-consent-dialog h2 { margin:0 0 .55rem; color:#163b63; font-size:clamp(1.35rem,3vw,1.7rem); }
    .final-consent-dialog .lead { margin:0 0 1rem; color:#516579; line-height:1.6; font-size:1rem; }
    .final-consent-row {
      display:flex; align-items:flex-start; gap:.8rem; margin:1rem 0 0;
      padding:1rem; border:1px solid #d6e0e8; border-radius:14px; background:#f8fbfd;
    }
    .final-consent-row.incomplete { border:3px solid #c62828 !important; background:#fff7f7 !important; }
    .final-consent-row input { width:22px; height:22px; margin-top:.15rem; flex:0 0 auto; }
    .final-consent-row label { line-height:1.55; color:#1f2937; cursor:pointer; }
    .final-consent-note { margin:.9rem 0 0; font-size:.88rem; color:#64748b; line-height:1.55; }
    .final-consent-actions { display:flex; justify-content:flex-end; gap:.75rem; margin-top:1.25rem; flex-wrap:wrap; }
    @media (max-width:600px) {
      .final-consent-dialog { border-radius:18px; padding:1.1rem; }
      .final-consent-actions button { width:100%; }
    }
